From cacf169668224bebaef899eecc23c559ce4d5913 Mon Sep 17 00:00:00 2001 From: sigonasr2 Date: Fri, 28 Jul 2023 04:41:18 -0500 Subject: [PATCH] Add in extra debug access option when reading configuration properties. Implement Wizard Auto attack and teleport configuration options. --- Crawler/Crawler.cpp | 32 +++++++++++++++++++++ Crawler/Crawler.vcxproj | 1 + Crawler/Crawler.vcxproj.filters | 3 ++ Crawler/Player.cpp | 4 +-- Crawler/Player.h | 2 +- Crawler/Version.h | 2 +- Crawler/Wizard.cpp | 35 +++++++++++++++++------ Crawler/assets/config/classes/Warrior.txt | 1 + Crawler/assets/config/classes/Wizard.txt | 30 +++++++++++++++++++ Crawler/assets/config/configuration.txt | 5 +++- Crawler/config.h | 5 +++- Crawler/olcUTIL_DataFile.h | 6 +++- 12 files changed, 110 insertions(+), 16 deletions(-) diff --git a/Crawler/Crawler.cpp b/Crawler/Crawler.cpp index 7dba7f71..2829b527 100644 --- a/Crawler/Crawler.cpp +++ b/Crawler/Crawler.cpp @@ -56,6 +56,7 @@ Crawler::Crawler() std::cout< + diff --git a/Crawler/Crawler.vcxproj.filters b/Crawler/Crawler.vcxproj.filters index eaf162f7..9fb70b72 100644 --- a/Crawler/Crawler.vcxproj.filters +++ b/Crawler/Crawler.vcxproj.filters @@ -123,6 +123,9 @@ Header Files + + Header Files + diff --git a/Crawler/Player.cpp b/Crawler/Player.cpp index 891bd875..8183a0ef 100644 --- a/Crawler/Player.cpp +++ b/Crawler/Player.cpp @@ -601,8 +601,8 @@ CastInfo&Player::GetCastInfo(){ } bool Player::CanPathfindTo(vf2d pos,vf2d targetPos,float range){ - std::vectorpathing=game->pathfinder.Solve_AStar(pos,targetPos,8,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. + std::vectorpathing=game->pathfinder.Solve_AStar(pos,targetPos,range,upperLevel); + return pathing.size()>0&&pathing.size()GetWorldMousePos().y-GetPos().y,game->GetWorldMousePos().x-GetPos().x); - BULLET_LIST.push_back(std::make_unique(EnergyBolt(GetPos(),{cos(angleToCursor)*200,sin(angleToCursor)*200},12,GetAttack(),upperLevel,true,WHITE))); + BULLET_LIST.push_back(std::make_unique(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; } void Wizard::InitializeClassAbilities(){ @@ -76,21 +77,37 @@ void Wizard::InitializeClassAbilities(){ if(p->GetState()==State::CASTING)return false; float pointMouseDirection=atan2(game->GetWorldMousePos().y-p->GetPos().y,game->GetWorldMousePos().x-p->GetPos().x); vf2d pointTowardsMouse={cos(pointMouseDirection),sin(pointMouseDirection)}; - float dist=std::clamp(geom2d::line{p->GetPos(),game->GetWorldMousePos()}.length(),0.f,6.5f*24); - if(dist<12)return false; + float dist=std::clamp(geom2d::line{p->GetPos(),game->GetWorldMousePos()}.length(),0.f,"Wizard.Right Click Ability.TeleportRange"_F/100*24); + if(dist<"Wizard.Right Click Ability.TilesMin"_I*12)return false; 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; 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->teleportAnimationTimer=0.35; + p->teleportAnimationTimer="Wizard.Right Click Ability.AnimationTime"_F; p->teleportTarget=teleportPoint; p->teleportStartPosition=p->GetPos(); - p->iframe_time=0.35; - for(int i=0;i<16;i++){ - game->AddEffect(std::make_unique(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)); + p->iframe_time="Wizard.Right Click Ability.IframeTime"_F; + for(int i=0;i<"Wizard.Right Click Ability.ParticleCount"_I;i++){ + game->AddEffect( + std::make_unique( + 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; } else { diff --git a/Crawler/assets/config/classes/Warrior.txt b/Crawler/assets/config/classes/Warrior.txt index b920f775..1c6b0f0b 100644 --- a/Crawler/assets/config/classes/Warrior.txt +++ b/Crawler/assets/config/classes/Warrior.txt @@ -1,6 +1,7 @@ Warrior { ClassName = Warrior + Auto Attack { DamageMult = 1 diff --git a/Crawler/assets/config/classes/Wizard.txt b/Crawler/assets/config/classes/Wizard.txt index fc04174e..82b0127e 100644 --- a/Crawler/assets/config/classes/Wizard.txt +++ b/Crawler/assets/config/classes/Wizard.txt @@ -2,6 +2,14 @@ Wizard { ClassName = Wizard + Auto Attack + { + DamageMult = 1 + Radius = 100 + Speed = 200 + Cooldown = 0.85 + } + Right Click Ability { Name = Teleport @@ -15,6 +23,28 @@ Wizard Precast Time = 0 Casting Range = 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 { diff --git a/Crawler/assets/config/configuration.txt b/Crawler/assets/config/configuration.txt index deb90aed..2f4e114c 100644 --- a/Crawler/assets/config/configuration.txt +++ b/Crawler/assets/config/configuration.txt @@ -13,4 +13,7 @@ map_config = levels.txt class_directory = classes/ # Class list to be loaded into the game. -class_list = Warrior, Thief, Ranger, Trapper, Wizard, Witch \ No newline at end of file +class_list = Warrior, Thief, Ranger, Trapper, Wizard, Witch + +# Whether or not to show individual data accesses from config data structure. +debug_access_options = 0 \ No newline at end of file diff --git a/Crawler/config.h b/Crawler/config.h index 19b16792..11806fbf 100644 --- a/Crawler/config.h +++ b/Crawler/config.h @@ -1,3 +1,4 @@ +#pragma once #include "olcUTIL_DataFile.h" using namespace olc; @@ -17,4 +18,6 @@ int operator ""_I(const char*key,std::size_t len); //Read a float key from the config. float operator ""_F(const char*key,std::size_t len); //Read a double key from the config. -double operator ""_D(const char*key,std::size_t len); \ No newline at end of file +double operator ""_D(const char*key,std::size_t len); + +Pixel operator ""_Pixel(const char*key,std::size_t len); \ No newline at end of file diff --git a/Crawler/olcUTIL_DataFile.h b/Crawler/olcUTIL_DataFile.h index 8b0acf23..3e388809 100644 --- a/Crawler/olcUTIL_DataFile.h +++ b/Crawler/olcUTIL_DataFile.h @@ -62,12 +62,15 @@ David Barr, aka javidx9, �OneLoneCoder 2019, 2020, 2021, 2022 #include #include +int operator ""_I(const char*key,std::size_t len); + namespace olc::utils { class datafile { public: inline datafile() = default; + inline static bool DEBUG_ACCESS_OPTIONS=false; public: // 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 "<