From 4631733497f6632988e491003d027873cb973435 Mon Sep 17 00:00:00 2001 From: sigonasr2 Date: Fri, 15 Sep 2023 16:32:04 -0500 Subject: [PATCH] Corrected issues with Ability declaration not matching macro. Cast cancelling moves now properly cancel any active cast. All abilities have configurable cancelCast settings. --- Crawler/Ability.cpp | 4 ++-- Crawler/Ability.h | 4 ++-- Crawler/Player.cpp | 14 ++++++++++++-- Crawler/Player.h | 5 +++-- Crawler/Version.h | 2 +- Crawler/Warrior.cpp | 2 +- Crawler/assets/config/classes/Warrior.txt | 2 ++ 7 files changed, 23 insertions(+), 10 deletions(-) diff --git a/Crawler/Ability.cpp b/Crawler/Ability.cpp index 482c16be..b9d251d3 100644 --- a/Crawler/Ability.cpp +++ b/Crawler/Ability.cpp @@ -10,5 +10,5 @@ PrecastData::PrecastData(float castTime,float range,float size) }; Ability::Ability(){}; -Ability::Ability(std::string name,float cooldownTime,int manaCost,Pixel barColor1,Pixel barColor2,PrecastData precastInfo) - :name(name),cooldown(0),COOLDOWN_TIME(cooldownTime),manaCost(manaCost),barColor1(barColor1),barColor2(barColor2),precastInfo(precastInfo){} \ No newline at end of file +Ability::Ability(std::string name,float cooldownTime,int manaCost,Pixel barColor1,Pixel barColor2,PrecastData precastInfo,bool canCancelCast) + :name(name),cooldown(0),COOLDOWN_TIME(cooldownTime),manaCost(manaCost),barColor1(barColor1),barColor2(barColor2),precastInfo(precastInfo),canCancelCast(canCancelCast){} \ No newline at end of file diff --git a/Crawler/Ability.h b/Crawler/Ability.h index 2839c75b..9c9d5705 100644 --- a/Crawler/Ability.h +++ b/Crawler/Ability.h @@ -22,9 +22,9 @@ struct Ability{ float COOLDOWN_TIME=0; int manaCost=0; Pixel barColor1,barColor2; - bool canCancelCast=false; PrecastData precastInfo; + bool canCancelCast=false; std::functionaction=[](Player*,vf2d){return false;}; Ability(); - Ability(std::string name,float cooldownTime,int manaCost,Pixel barColor1=VERY_DARK_RED,Pixel barColor2=DARK_RED,PrecastData precastInfo={}); + Ability(std::string name,float cooldownTime,int manaCost,Pixel barColor1=VERY_DARK_RED,Pixel barColor2=DARK_RED,PrecastData precastInfo={},bool canCancelCast=false); }; \ No newline at end of file diff --git a/Crawler/Player.cpp b/Crawler/Player.cpp index 2c0fc981..15db6da0 100644 --- a/Crawler/Player.cpp +++ b/Crawler/Player.cpp @@ -341,9 +341,14 @@ void Player::Update(float fElapsedTime){ //If pressed is set to false, uses held instead. auto CheckAndPerformAbility=[&](Ability&ability,HWButton key){ if(ability.name!="???"){ - if(CanAct()){ + if(CanAct(ability)){ if(ability.cooldown==0&&GetMana()>=ability.manaCost){ if(key.bHeld||key.bReleased&&&ability==castPrepAbility&&GetState()==State::PREP_CAST){ + if(GetState()==State::CASTING){ + SetState(State::NORMAL); + castInfo.castTimer=castInfo.castTotalTime=0; + } + if(AllowedToCast(ability)&&ability.action(this,{})){ ability.cooldown=ability.COOLDOWN_TIME; mana-=ability.manaCost; @@ -483,7 +488,12 @@ bool Player::CanMove(){ } bool Player::CanAct(){ - return state!=State::CASTING&&state!=State::ANIMATION_LOCK; + Ability dummyAbility{"Dummy Ability",0,0}; + return CanAct(dummyAbility); +} + +bool Player::CanAct(Ability&ability){ + return (ability.canCancelCast||state!=State::CASTING)&&state!=State::ANIMATION_LOCK; } bool Player::HasIframes(){ diff --git a/Crawler/Player.h b/Crawler/Player.h index 5a3f3ea3..8ea5396c 100644 --- a/Crawler/Player.h +++ b/Crawler/Player.h @@ -130,6 +130,7 @@ public: bool CanPathfindTo(vf2d pos,vf2d targetPos,float range=8); bool CanMove(); bool CanAct(); + bool CanAct(Ability&ability); void AddBuff(BuffType type,float duration,float intensity); std::vectorGetBuffs(BuffType buff); @@ -353,7 +354,7 @@ struct Witch:Player{ {uint8_t(#class".Right Click Ability.Cooldown Bar Color 1"_f[0]),uint8_t(#class".Right Click Ability.Cooldown Bar Color 1"_f[1]),uint8_t(#class".Right Click Ability.Cooldown Bar Color 1"_f[2]),uint8_t(#class".Right Click Ability.Cooldown Bar Color 1"_f[3]==0?255:#class".Right Click Ability.Cooldown Bar Color 1"_f[3])}, \ {uint8_t(#class".Right Click Ability.Cooldown Bar Color 2"_f[0]),uint8_t(#class".Right Click Ability.Cooldown Bar Color 2"_f[1]),uint8_t(#class".Right Click Ability.Cooldown Bar Color 2"_f[2]),uint8_t(#class".Right Click Ability.Cooldown Bar Color 2"_f[3]==0?255:#class".Right Click Ability.Cooldown Bar Color 2"_f[3])}, \ {#class".Right Click Ability.Precast Time"_F,#class".Right Click Ability.Casting Range"_I/100.f*24,#class".Right Click Ability.Casting Size"_I/100.f*24}, \ - bool(#class".Right Click Ability.CancelCast"_I) \ + bool( #class".Right Click Ability.CancelCast"_I ) \ }; \ class::ability1={ \ #class".Ability 1.Name"_S, \ @@ -370,7 +371,7 @@ struct Witch:Player{ #class".Ability 2.Mana Cost"_I, \ {uint8_t(#class".Ability 2.Cooldown Bar Color 1"_f[0]),uint8_t(#class".Ability 2.Cooldown Bar Color 1"_f[1]),uint8_t(#class".Ability 2.Cooldown Bar Color 1"_f[2]),uint8_t(#class".Ability 2.Cooldown Bar Color 1"_f[3]==0?255:#class".Ability 2.Cooldown Bar Color 1"_f[3])}, \ {uint8_t(#class".Ability 2.Cooldown Bar Color 2"_f[0]),uint8_t(#class".Ability 2.Cooldown Bar Color 2"_f[1]),uint8_t(#class".Ability 2.Cooldown Bar Color 2"_f[2]),uint8_t(#class".Ability 2.Cooldown Bar Color 2"_f[3]==0?255:#class".Ability 2.Cooldown Bar Color 2"_f[3])}, \ - {#class".Ability 2.Precast Time"_F,#class".Ability 2.Casting Range"_I/100.f*24,#class".Ability 2.Casting Size"_I/100.f*24} \ + {#class".Ability 2.Precast Time"_F,#class".Ability 2.Casting Range"_I/100.f*24,#class".Ability 2.Casting Size"_I/100.f*24}, \ bool(#class".Ability 2.CancelCast"_I) \ }; \ class::ability3={ \ diff --git a/Crawler/Version.h b/Crawler/Version.h index 3d1a749e..92ed6dac 100644 --- a/Crawler/Version.h +++ b/Crawler/Version.h @@ -2,7 +2,7 @@ #define VERSION_MAJOR 0 #define VERSION_MINOR 2 #define VERSION_PATCH 0 -#define VERSION_BUILD 1275 +#define VERSION_BUILD 1283 #define stringify(a) stringify_(a) #define stringify_(a) #a diff --git a/Crawler/Warrior.cpp b/Crawler/Warrior.cpp index d55dd5bb..d6988418 100644 --- a/Crawler/Warrior.cpp +++ b/Crawler/Warrior.cpp @@ -11,7 +11,7 @@ INCLUDE_BULLET_LIST INCLUDE_game void Warrior::Initialize(){ - Warrior::name="Warrior"".ClassName"_S; Warrior::cl=WARRIOR; Warrior::rightClickAbility=Ability{ "Warrior"".Right Click Ability.Name"_S, "Warrior"".Right Click Ability.Cooldown"_F, "Warrior"".Right Click Ability.Mana Cost"_I, {uint8_t("Warrior"".Right Click Ability.Cooldown Bar Color 1"_f[0]),uint8_t("Warrior"".Right Click Ability.Cooldown Bar Color 1"_f[1]),uint8_t("Warrior"".Right Click Ability.Cooldown Bar Color 1"_f[2]),uint8_t("Warrior"".Right Click Ability.Cooldown Bar Color 1"_f[3]==0?255:"Warrior"".Right Click Ability.Cooldown Bar Color 1"_f[3])}, {uint8_t("Warrior"".Right Click Ability.Cooldown Bar Color 2"_f[0]),uint8_t("Warrior"".Right Click Ability.Cooldown Bar Color 2"_f[1]),uint8_t("Warrior"".Right Click Ability.Cooldown Bar Color 2"_f[2]),uint8_t("Warrior"".Right Click Ability.Cooldown Bar Color 2"_f[3]==0?255:"Warrior"".Right Click Ability.Cooldown Bar Color 2"_f[3])}, {"Warrior"".Right Click Ability.Precast Time"_F,"Warrior"".Right Click Ability.Casting Range"_I/100.f*24,"Warrior"".Right Click Ability.Casting Size"_I/100.f*24}, bool("Warrior"".Right Click Ability.CancelCast"_I) }; Warrior::ability1={ "Warrior"".Ability 1.Name"_S, "Warrior"".Ability 1.Cooldown"_F, "Warrior"".Ability 1.Mana Cost"_I, {uint8_t("Warrior"".Ability 1.Cooldown Bar Color 1"_f[0]),uint8_t("Warrior"".Ability 1.Cooldown Bar Color 1"_f[1]),uint8_t("Warrior"".Ability 1.Cooldown Bar Color 1"_f[2]),uint8_t("Warrior"".Ability 1.Cooldown Bar Color 1"_f[3]==0?255:"Warrior"".Ability 1.Cooldown Bar Color 1"_f[3])}, {uint8_t("Warrior"".Ability 1.Cooldown Bar Color 2"_f[0]),uint8_t("Warrior"".Ability 1.Cooldown Bar Color 2"_f[1]),uint8_t("Warrior"".Ability 1.Cooldown Bar Color 2"_f[2]),uint8_t("Warrior"".Ability 1.Cooldown Bar Color 2"_f[3]==0?255:"Warrior"".Ability 1.Cooldown Bar Color 2"_f[3])}, {"Warrior"".Ability 1.Precast Time"_F,"Warrior"".Ability 1.Casting Range"_I/100.f*24,"Warrior"".Ability 1.Casting Size"_I/100.f*24}, bool("Warrior"".Ability 1.CancelCast"_I) }; Warrior::ability2={ "Warrior"".Ability 2.Name"_S, "Warrior"".Ability 2.Cooldown"_F, "Warrior"".Ability 2.Mana Cost"_I, {uint8_t("Warrior"".Ability 2.Cooldown Bar Color 1"_f[0]),uint8_t("Warrior"".Ability 2.Cooldown Bar Color 1"_f[1]),uint8_t("Warrior"".Ability 2.Cooldown Bar Color 1"_f[2]),uint8_t("Warrior"".Ability 2.Cooldown Bar Color 1"_f[3]==0?255:"Warrior"".Ability 2.Cooldown Bar Color 1"_f[3])}, {uint8_t("Warrior"".Ability 2.Cooldown Bar Color 2"_f[0]),uint8_t("Warrior"".Ability 2.Cooldown Bar Color 2"_f[1]),uint8_t("Warrior"".Ability 2.Cooldown Bar Color 2"_f[2]),uint8_t("Warrior"".Ability 2.Cooldown Bar Color 2"_f[3]==0?255:"Warrior"".Ability 2.Cooldown Bar Color 2"_f[3])}, {"Warrior"".Ability 2.Precast Time"_F,"Warrior"".Ability 2.Casting Range"_I/100.f*24,"Warrior"".Ability 2.Casting Size"_I/100.f*24} bool("Warrior"".Ability 2.CancelCast"_I) }; Warrior::ability3={ "Warrior"".Ability 3.Name"_S, "Warrior"".Ability 3.Cooldown"_F, "Warrior"".Ability 3.Mana Cost"_I, {uint8_t("Warrior"".Ability 3.Cooldown Bar Color 1"_f[0]),uint8_t("Warrior"".Ability 3.Cooldown Bar Color 1"_f[1]),uint8_t("Warrior"".Ability 3.Cooldown Bar Color 1"_f[2]),uint8_t("Warrior"".Ability 3.Cooldown Bar Color 1"_f[3]==0?255:"Warrior"".Ability 3.Cooldown Bar Color 1"_f[3])}, {uint8_t("Warrior"".Ability 3.Cooldown Bar Color 2"_f[0]),uint8_t("Warrior"".Ability 3.Cooldown Bar Color 2"_f[1]),uint8_t("Warrior"".Ability 3.Cooldown Bar Color 2"_f[2]),uint8_t("Warrior"".Ability 3.Cooldown Bar Color 2"_f[3]==0?255:"Warrior"".Ability 3.Cooldown Bar Color 2"_f[3])}, {"Warrior"".Ability 3.Precast Time"_F,"Warrior"".Ability 3.Casting Range"_I/100.f*24,"Warrior"".Ability 3.Casting Size"_I/100.f*24}, bool("Warrior"".Ability 3.CancelCast"_I) }; Warrior::ability4={"???",0,0}; + READFROMCONFIG(Warrior,WARRIOR); Warrior::idle_n="WARRIOR_IDLE_N"; Warrior::idle_e="WARRIOR_IDLE_E"; Warrior::idle_s="WARRIOR_IDLE_S"; diff --git a/Crawler/assets/config/classes/Warrior.txt b/Crawler/assets/config/classes/Warrior.txt index fb3e4b98..d5309a41 100644 --- a/Crawler/assets/config/classes/Warrior.txt +++ b/Crawler/assets/config/classes/Warrior.txt @@ -115,6 +115,8 @@ Warrior Name = Sonic Slash Cooldown = 40 Mana Cost = 60 + # Whether or not this ability cancels casts. + CancelCast = 0 #RGB Values. Color 1 is the left side of the bar, Color 2 is the right side. Cooldown Bar Color 1 = 64, 0, 0, 255