Corrected issues with Ability declaration not matching macro. Cast cancelling moves now properly cancel any active cast. All abilities have configurable cancelCast settings.

pull/28/head
sigonasr2 1 year ago
parent dbc68b8c4b
commit 4631733497
  1. 4
      Crawler/Ability.cpp
  2. 4
      Crawler/Ability.h
  3. 14
      Crawler/Player.cpp
  4. 5
      Crawler/Player.h
  5. 2
      Crawler/Version.h
  6. 2
      Crawler/Warrior.cpp
  7. 2
      Crawler/assets/config/classes/Warrior.txt

@ -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){}
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){}

@ -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::function<bool(Player*,vf2d)>action=[](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);
};

@ -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(){

@ -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::vector<Buff>GetBuffs(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={ \

@ -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

@ -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";

@ -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

Loading…
Cancel
Save