Add in extra debug access option when reading configuration properties. Implement Wizard Auto attack and teleport configuration options.
This commit is contained in:
parent
8862c3eb08
commit
08dd776595
@ -56,6 +56,7 @@ Crawler::Crawler()
|
|||||||
std::cout<<cl<<std::endl;
|
std::cout<<cl<<std::endl;
|
||||||
utils::datafile::Read(DATA,CONFIG_PATH + "class_directory"_S + cl + ".txt");
|
utils::datafile::Read(DATA,CONFIG_PATH + "class_directory"_S + cl + ".txt");
|
||||||
}
|
}
|
||||||
|
utils::datafile::DEBUG_ACCESS_OPTIONS="debug_access_options"_I;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Crawler::OnUserCreate(){
|
bool Crawler::OnUserCreate(){
|
||||||
@ -1162,33 +1163,64 @@ int main()
|
|||||||
}
|
}
|
||||||
|
|
||||||
datafilestringdata operator ""_s(const char*key,std::size_t len){
|
datafilestringdata operator ""_s(const char*key,std::size_t len){
|
||||||
|
if(utils::datafile::DEBUG_ACCESS_OPTIONS){
|
||||||
|
std::cout<<"Reading "<<std::string(key,len)<<std::endl;
|
||||||
|
}
|
||||||
return {DATA,std::string(key,len)};
|
return {DATA,std::string(key,len)};
|
||||||
}
|
}
|
||||||
|
|
||||||
datafileintdata operator ""_i(const char*key,std::size_t len){
|
datafileintdata operator ""_i(const char*key,std::size_t len){
|
||||||
|
if(utils::datafile::DEBUG_ACCESS_OPTIONS){
|
||||||
|
std::cout<<"Reading "<<std::string(key,len)<<std::endl;
|
||||||
|
}
|
||||||
return {DATA,std::string(key,len)};
|
return {DATA,std::string(key,len)};
|
||||||
}
|
}
|
||||||
|
|
||||||
datafilefloatdata operator ""_f(const char*key,std::size_t len){
|
datafilefloatdata operator ""_f(const char*key,std::size_t len){
|
||||||
|
if(utils::datafile::DEBUG_ACCESS_OPTIONS){
|
||||||
|
std::cout<<"Reading "<<std::string(key,len)<<std::endl;
|
||||||
|
}
|
||||||
return {DATA,std::string(key,len)};
|
return {DATA,std::string(key,len)};
|
||||||
}
|
}
|
||||||
|
|
||||||
datafiledoubledata operator ""_d(const char*key,std::size_t len){
|
datafiledoubledata operator ""_d(const char*key,std::size_t len){
|
||||||
|
if(utils::datafile::DEBUG_ACCESS_OPTIONS){
|
||||||
|
std::cout<<"Reading "<<std::string(key,len)<<std::endl;
|
||||||
|
}
|
||||||
return {DATA,std::string(key,len)};
|
return {DATA,std::string(key,len)};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Pixel operator ""_Pixel(const char*key,std::size_t len){
|
||||||
|
if(utils::datafile::DEBUG_ACCESS_OPTIONS){
|
||||||
|
std::cout<<"Reading "<<std::string(key,len)<<std::endl;
|
||||||
|
}
|
||||||
|
return {uint8_t(DATA.GetProperty(std::string(key,len)).GetInt(0)),uint8_t(DATA.GetProperty(std::string(key,len)).GetInt(1)),uint8_t(DATA.GetProperty(std::string(key,len)).GetInt(2)),uint8_t(DATA.GetProperty(std::string(key,len)).GetInt(3))};
|
||||||
|
}
|
||||||
|
|
||||||
std::string operator ""_S(const char*key,std::size_t len){
|
std::string operator ""_S(const char*key,std::size_t len){
|
||||||
|
if(utils::datafile::DEBUG_ACCESS_OPTIONS){
|
||||||
|
std::cout<<"Reading "<<std::string(key,len)<<std::endl;
|
||||||
|
}
|
||||||
return DATA.GetProperty(std::string(key,len)).GetString();
|
return DATA.GetProperty(std::string(key,len)).GetString();
|
||||||
}
|
}
|
||||||
|
|
||||||
int operator ""_I(const char*key,std::size_t len){
|
int operator ""_I(const char*key,std::size_t len){
|
||||||
|
if(utils::datafile::DEBUG_ACCESS_OPTIONS){
|
||||||
|
std::cout<<"Reading "<<std::string(key,len)<<std::endl;
|
||||||
|
}
|
||||||
return DATA.GetProperty(std::string(key,len)).GetInt();
|
return DATA.GetProperty(std::string(key,len)).GetInt();
|
||||||
}
|
}
|
||||||
|
|
||||||
float operator ""_F(const char*key,std::size_t len){
|
float operator ""_F(const char*key,std::size_t len){
|
||||||
|
if(utils::datafile::DEBUG_ACCESS_OPTIONS){
|
||||||
|
std::cout<<"Reading "<<std::string(key,len)<<std::endl;
|
||||||
|
}
|
||||||
return DATA.GetProperty(std::string(key,len)).GetReal();
|
return DATA.GetProperty(std::string(key,len)).GetReal();
|
||||||
}
|
}
|
||||||
|
|
||||||
double operator ""_D(const char*key,std::size_t len){
|
double operator ""_D(const char*key,std::size_t len){
|
||||||
|
if(utils::datafile::DEBUG_ACCESS_OPTIONS){
|
||||||
|
std::cout<<std::string(key,len)<<std::endl;
|
||||||
|
}
|
||||||
return DATA.GetProperty(std::string(key,len)).GetReal();
|
return DATA.GetProperty(std::string(key,len)).GetReal();
|
||||||
}
|
}
|
@ -178,6 +178,7 @@
|
|||||||
<ClInclude Include="Bullet.h" />
|
<ClInclude Include="Bullet.h" />
|
||||||
<ClInclude Include="BulletTypes.h" />
|
<ClInclude Include="BulletTypes.h" />
|
||||||
<ClInclude Include="Class.h" />
|
<ClInclude Include="Class.h" />
|
||||||
|
<ClInclude Include="config.h" />
|
||||||
<ClInclude Include="Crawler.h" />
|
<ClInclude Include="Crawler.h" />
|
||||||
<ClInclude Include="DamageNumber.h" />
|
<ClInclude Include="DamageNumber.h" />
|
||||||
<ClInclude Include="DEFINES.h" />
|
<ClInclude Include="DEFINES.h" />
|
||||||
|
@ -123,6 +123,9 @@
|
|||||||
<ClInclude Include="olcUTIL_DataFile.h">
|
<ClInclude Include="olcUTIL_DataFile.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="config.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="Player.cpp">
|
<ClCompile Include="Player.cpp">
|
||||||
|
@ -601,8 +601,8 @@ CastInfo&Player::GetCastInfo(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool Player::CanPathfindTo(vf2d pos,vf2d targetPos,float range){
|
bool Player::CanPathfindTo(vf2d pos,vf2d targetPos,float range){
|
||||||
std::vector<vf2d>pathing=game->pathfinder.Solve_AStar(pos,targetPos,8,upperLevel);
|
std::vector<vf2d>pathing=game->pathfinder.Solve_AStar(pos,targetPos,range,upperLevel);
|
||||||
return pathing.size()>0&&pathing.size()<8;//We'll say 7 tiles or less is close enough to 650 range. Have a little bit of wiggle room.
|
return pathing.size()>0&&pathing.size()<range;//We'll say 7 tiles or less is close enough to 650 range. Have a little bit of wiggle room.
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player::PrepareCast(Ability&ability){
|
void Player::PrepareCast(Ability&ability){
|
||||||
|
@ -55,7 +55,7 @@ private:
|
|||||||
void Initialize();
|
void Initialize();
|
||||||
protected:
|
protected:
|
||||||
const float ATTACK_COOLDOWN="Warrior.Auto Attack.Cooldown"_F;
|
const float ATTACK_COOLDOWN="Warrior.Auto Attack.Cooldown"_F;
|
||||||
const float MAGIC_ATTACK_COOLDOWN=0.85f;
|
const float MAGIC_ATTACK_COOLDOWN="Wizard.Auto Attack.Cooldown"_F;
|
||||||
const float ARROW_ATTACK_COOLDOWN=0.6f;
|
const float ARROW_ATTACK_COOLDOWN=0.6f;
|
||||||
void SetSwordSwingTimer(float val);
|
void SetSwordSwingTimer(float val);
|
||||||
void SetState(State newState);
|
void SetState(State newState);
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
#define VERSION_MAJOR 0
|
#define VERSION_MAJOR 0
|
||||||
#define VERSION_MINOR 2
|
#define VERSION_MINOR 2
|
||||||
#define VERSION_PATCH 0
|
#define VERSION_PATCH 0
|
||||||
#define VERSION_BUILD 890
|
#define VERSION_BUILD 906
|
||||||
|
|
||||||
#define stringify(a) stringify_(a)
|
#define stringify(a) stringify_(a)
|
||||||
#define stringify_(a) #a
|
#define stringify_(a) #a
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
#include "Crawler.h"
|
#include "Crawler.h"
|
||||||
#include "BulletTypes.h"
|
#include "BulletTypes.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
#include "utils.h"
|
||||||
|
|
||||||
INCLUDE_MONSTER_LIST
|
INCLUDE_MONSTER_LIST
|
||||||
INCLUDE_BULLET_LIST
|
INCLUDE_BULLET_LIST
|
||||||
@ -66,7 +67,7 @@ void Wizard::OnUpdate(float fElapsedTime){
|
|||||||
bool Wizard::AutoAttack(){
|
bool Wizard::AutoAttack(){
|
||||||
attack_cooldown_timer=MAGIC_ATTACK_COOLDOWN;
|
attack_cooldown_timer=MAGIC_ATTACK_COOLDOWN;
|
||||||
float angleToCursor=atan2(game->GetWorldMousePos().y-GetPos().y,game->GetWorldMousePos().x-GetPos().x);
|
float angleToCursor=atan2(game->GetWorldMousePos().y-GetPos().y,game->GetWorldMousePos().x-GetPos().x);
|
||||||
BULLET_LIST.push_back(std::make_unique<EnergyBolt>(EnergyBolt(GetPos(),{cos(angleToCursor)*200,sin(angleToCursor)*200},12,GetAttack(),upperLevel,true,WHITE)));
|
BULLET_LIST.push_back(std::make_unique<EnergyBolt>(EnergyBolt(GetPos(),{cos(angleToCursor)*"Wizard.Auto Attack.Speed"_F,sin(angleToCursor)*"Wizard.Auto Attack.Speed"_F},"Wizard.Auto Attack.Radius"_F/100*12,GetAttack(),upperLevel,true,WHITE)));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
void Wizard::InitializeClassAbilities(){
|
void Wizard::InitializeClassAbilities(){
|
||||||
@ -76,21 +77,37 @@ void Wizard::InitializeClassAbilities(){
|
|||||||
if(p->GetState()==State::CASTING)return false;
|
if(p->GetState()==State::CASTING)return false;
|
||||||
float pointMouseDirection=atan2(game->GetWorldMousePos().y-p->GetPos().y,game->GetWorldMousePos().x-p->GetPos().x);
|
float pointMouseDirection=atan2(game->GetWorldMousePos().y-p->GetPos().y,game->GetWorldMousePos().x-p->GetPos().x);
|
||||||
vf2d pointTowardsMouse={cos(pointMouseDirection),sin(pointMouseDirection)};
|
vf2d pointTowardsMouse={cos(pointMouseDirection),sin(pointMouseDirection)};
|
||||||
float dist=std::clamp(geom2d::line<float>{p->GetPos(),game->GetWorldMousePos()}.length(),0.f,6.5f*24);
|
float dist=std::clamp(geom2d::line<float>{p->GetPos(),game->GetWorldMousePos()}.length(),0.f,"Wizard.Right Click Ability.TeleportRange"_F/100*24);
|
||||||
if(dist<12)return false;
|
if(dist<"Wizard.Right Click Ability.TilesMin"_I*12)return false;
|
||||||
vf2d teleportPoint=p->GetPos()+pointTowardsMouse*dist;
|
vf2d teleportPoint=p->GetPos()+pointTowardsMouse*dist;
|
||||||
while(dist>0&&game->HasTileCollision(game->GetCurrentLevel(),teleportPoint)&&p->CanPathfindTo(p->GetPos(),teleportPoint)){
|
while(dist>0&&game->HasTileCollision(game->GetCurrentLevel(),teleportPoint)&&p->CanPathfindTo(p->GetPos(),teleportPoint,"Wizard.Right Click Ability.TilesMax"_I)){
|
||||||
dist-=24;
|
dist-=24;
|
||||||
teleportPoint=p->GetPos()+pointTowardsMouse*dist;
|
teleportPoint=p->GetPos()+pointTowardsMouse*dist;
|
||||||
}
|
}
|
||||||
if(dist>0&&p->CanPathfindTo(p->GetPos(),teleportPoint)){
|
if(dist>0&&p->CanPathfindTo(p->GetPos(),teleportPoint,"Wizard.Right Click Ability.TilesMax"_I)){
|
||||||
p->SetState(State::TELEPORT);
|
p->SetState(State::TELEPORT);
|
||||||
p->teleportAnimationTimer=0.35;
|
p->teleportAnimationTimer="Wizard.Right Click Ability.AnimationTime"_F;
|
||||||
p->teleportTarget=teleportPoint;
|
p->teleportTarget=teleportPoint;
|
||||||
p->teleportStartPosition=p->GetPos();
|
p->teleportStartPosition=p->GetPos();
|
||||||
p->iframe_time=0.35;
|
p->iframe_time="Wizard.Right Click Ability.IframeTime"_F;
|
||||||
for(int i=0;i<16;i++){
|
for(int i=0;i<"Wizard.Right Click Ability.ParticleCount"_I;i++){
|
||||||
game->AddEffect(std::make_unique<Effect>(p->GetPos()+vf2d{(rand()%160-80)/10.f,(rand()%160-80)/10.f},float(rand()%300)/1000,AnimationState::DOT_PARTICLE,p->upperLevel,0.3,0.2,vf2d{float(rand()%1000-500)/100,float(rand()%1000-500)/100},BLACK));
|
game->AddEffect(
|
||||||
|
std::make_unique<Effect>(
|
||||||
|
p->GetPos()+
|
||||||
|
vf2d{(util::random("Wizard.Right Click Ability.ParticleRange"_F/100*2)-
|
||||||
|
"Wizard.Right Click Ability.ParticleRange"_F/100)*12
|
||||||
|
,(util::random("Wizard.Right Click Ability.ParticleRange"_F/100*2)-
|
||||||
|
"Wizard.Right Click Ability.ParticleRange"_F/100)*12},
|
||||||
|
util::random("Wizard.Right Click Ability.ParticleLifetimeMax"_F)+
|
||||||
|
"Wizard.Right Click Ability.ParticleLifetimeMin"_F,
|
||||||
|
AnimationState::DOT_PARTICLE,p->upperLevel,
|
||||||
|
"Wizard.Right Click Ability.ParticleSize"_F,
|
||||||
|
"Wizard.Right Click Ability.ParticleFadetime"_F,
|
||||||
|
vf2d{util::random("Wizard.Right Click Ability.ParticleSpeedMax"_F*2)+
|
||||||
|
"Wizard.Right Click Ability.ParticleSpeedMin"_F,
|
||||||
|
util::random("Wizard.Right Click Ability.ParticleSpeedMax"_F*2)+
|
||||||
|
"Wizard.Right Click Ability.ParticleSpeedMin"_F},
|
||||||
|
"Wizard.Right Click Ability.ParticleColor"_Pixel));
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
Warrior
|
Warrior
|
||||||
{
|
{
|
||||||
ClassName = Warrior
|
ClassName = Warrior
|
||||||
|
|
||||||
Auto Attack
|
Auto Attack
|
||||||
{
|
{
|
||||||
DamageMult = 1
|
DamageMult = 1
|
||||||
|
@ -2,6 +2,14 @@ Wizard
|
|||||||
{
|
{
|
||||||
ClassName = Wizard
|
ClassName = Wizard
|
||||||
|
|
||||||
|
Auto Attack
|
||||||
|
{
|
||||||
|
DamageMult = 1
|
||||||
|
Radius = 100
|
||||||
|
Speed = 200
|
||||||
|
Cooldown = 0.85
|
||||||
|
}
|
||||||
|
|
||||||
Right Click Ability
|
Right Click Ability
|
||||||
{
|
{
|
||||||
Name = Teleport
|
Name = Teleport
|
||||||
@ -15,6 +23,28 @@ Wizard
|
|||||||
Precast Time = 0
|
Precast Time = 0
|
||||||
Casting Range = 0
|
Casting Range = 0
|
||||||
Casting Size = 0
|
Casting Size = 0
|
||||||
|
|
||||||
|
|
||||||
|
TeleportRange = 650
|
||||||
|
|
||||||
|
AnimationTime = 0.35
|
||||||
|
IframeTime = 0.35
|
||||||
|
|
||||||
|
# The minimum tile range required for a teleport.
|
||||||
|
TilesMin = 1
|
||||||
|
# The maximum tile range a teleport is allowed to go.
|
||||||
|
TilesMax = 8
|
||||||
|
|
||||||
|
# Number of teleport particles to spawn.
|
||||||
|
ParticleCount = 16
|
||||||
|
ParticleRange = 33.33
|
||||||
|
ParticleLifetimeMin = 0
|
||||||
|
ParticleLifetimeMax = 0.3
|
||||||
|
ParticleSize = 0.3
|
||||||
|
ParticleFadetime = 0.2
|
||||||
|
ParticleSpeedMin = -5
|
||||||
|
ParticleSpeedMax = 5
|
||||||
|
ParticleColor = 0, 0, 0, 255
|
||||||
}
|
}
|
||||||
Ability 1
|
Ability 1
|
||||||
{
|
{
|
||||||
|
@ -13,4 +13,7 @@ map_config = levels.txt
|
|||||||
class_directory = classes/
|
class_directory = classes/
|
||||||
|
|
||||||
# Class list to be loaded into the game.
|
# Class list to be loaded into the game.
|
||||||
class_list = Warrior, Thief, Ranger, Trapper, Wizard, Witch
|
class_list = Warrior, Thief, Ranger, Trapper, Wizard, Witch
|
||||||
|
|
||||||
|
# Whether or not to show individual data accesses from config data structure.
|
||||||
|
debug_access_options = 0
|
@ -1,3 +1,4 @@
|
|||||||
|
#pragma once
|
||||||
#include "olcUTIL_DataFile.h"
|
#include "olcUTIL_DataFile.h"
|
||||||
|
|
||||||
using namespace olc;
|
using namespace olc;
|
||||||
@ -17,4 +18,6 @@ int operator ""_I(const char*key,std::size_t len);
|
|||||||
//Read a float key from the config.
|
//Read a float key from the config.
|
||||||
float operator ""_F(const char*key,std::size_t len);
|
float operator ""_F(const char*key,std::size_t len);
|
||||||
//Read a double key from the config.
|
//Read a double key from the config.
|
||||||
double operator ""_D(const char*key,std::size_t len);
|
double operator ""_D(const char*key,std::size_t len);
|
||||||
|
|
||||||
|
Pixel operator ""_Pixel(const char*key,std::size_t len);
|
@ -62,12 +62,15 @@ David Barr, aka javidx9, <20>OneLoneCoder 2019, 2020, 2021, 2022
|
|||||||
#include <stack>
|
#include <stack>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
|
int operator ""_I(const char*key,std::size_t len);
|
||||||
|
|
||||||
namespace olc::utils
|
namespace olc::utils
|
||||||
{
|
{
|
||||||
class datafile
|
class datafile
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
inline datafile() = default;
|
inline datafile() = default;
|
||||||
|
inline static bool DEBUG_ACCESS_OPTIONS=false;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// Sets the String Value of a Property (for a given index)
|
// Sets the String Value of a Property (for a given index)
|
||||||
@ -86,8 +89,9 @@ namespace olc::utils
|
|||||||
std::cout<<"WARNING! Accesing out-of-bounds list item "<<nItem<<" of "<<lastAccessedProperty<<"!"<<std::endl;
|
std::cout<<"WARNING! Accesing out-of-bounds list item "<<nItem<<" of "<<lastAccessedProperty<<"!"<<std::endl;
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
return m_vContent[nItem];
|
return m_vContent[nItem];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Retrieves the Real Value of a Property (for a given index) or 0.0
|
// Retrieves the Real Value of a Property (for a given index) or 0.0
|
||||||
|
Loading…
x
Reference in New Issue
Block a user