diff --git a/Crawler/Player.cpp b/Crawler/Player.cpp index 262ae714..5abb2e42 100644 --- a/Crawler/Player.cpp +++ b/Crawler/Player.cpp @@ -260,7 +260,9 @@ void Player::Update(float fElapsedTime){ if(castInfo.castTimer>0){ castInfo.castTimer-=fElapsedTime; if(castInfo.castTimer<=0){ - if(castPrepAbility->action(this,castInfo.castPos)){ + bool allowed=castPrepAbility->actionPerformedDuringCast; + if(!allowed&&castPrepAbility->action(this,castInfo.castPos))allowed=true; + if(allowed){ castPrepAbility->cooldown=castPrepAbility->COOLDOWN_TIME; ConsumeMana(castPrepAbility->manaCost); } @@ -438,13 +440,11 @@ void Player::Update(float fElapsedTime){ if(CanAct(ability)){ if(ability.cooldown==0&&GetMana()>=ability.manaCost){ if(key.Held()||key.Released()&&&ability==castPrepAbility&&GetState()==State::PREP_CAST){ - if(AllowedToCast(ability)){ + if(AllowedToCast(ability)&&ability.action(this,{})){ bool allowed=ability.actionPerformedDuringCast; - if(!allowed&&ability.action(this,{}))allowed=true; - if(allowed){ - ability.cooldown=ability.COOLDOWN_TIME; - ConsumeMana(ability.manaCost); - } + ability.cooldown=ability.COOLDOWN_TIME; + CancelCast(); + ConsumeMana(ability.manaCost); }else if(ability.precastInfo.precastTargetingRequired&&GetState()==State::NORMAL){ PrepareCast(ability); @@ -654,13 +654,17 @@ Key Player::GetFacingDirection(){ return facingDirection; } +void Player::CancelCast(){ + castInfo={"",0}; + std::erase_if(buffList,[](Buff&b){return b.type==RESTORATION_DURING_CAST;}); //Remove all buffs that would be applied during a cast, as we got interrupted. + DAMAGENUMBER_LIST.push_back(std::make_shared(GetPos(),0,true,INTERRUPT)); +} + void Player::Moved(){ if(state==State::CASTING){ state=State::NORMAL; castPrepAbility->waitForRelease=true; - castInfo={"",0}; - std::erase_if(buffList,[](Buff&b){return b.type==RESTORATION_DURING_CAST;}); //Remove all buffs that would be applied during a cast, as we got interrupted. - DAMAGENUMBER_LIST.push_back(std::make_shared(GetPos(),0,true,INTERRUPT)); + CancelCast(); } for(MonsterSpawner&spawner:SPAWNER_LIST){ if(!spawner.SpawnTriggered()&&spawner.DoesUpperLevelSpawning()==OnUpperLevel()&&geom2d::contains(geom2d::rect{spawner.GetPos(),spawner.GetRange()},pos)){ diff --git a/Crawler/Player.h b/Crawler/Player.h index 91bd5c09..b3a3fe31 100644 --- a/Crawler/Player.h +++ b/Crawler/Player.h @@ -259,6 +259,8 @@ public: static void AddMoneyListener(MenuComponent*component); uint32_t GetMoney()const; void SetMoney(uint32_t newMoney); + + void CancelCast(); }; struct Warrior:Player{ diff --git a/Crawler/Version.h b/Crawler/Version.h index 753e56ea..bf15cc55 100644 --- a/Crawler/Version.h +++ b/Crawler/Version.h @@ -39,7 +39,7 @@ All rights reserved. #define VERSION_MAJOR 0 #define VERSION_MINOR 2 #define VERSION_PATCH 1 -#define VERSION_BUILD 4534 +#define VERSION_BUILD 4538 #define stringify(a) stringify_(a) #define stringify_(a) #a diff --git a/Crawler/assets/Campaigns/1_1_v2.tmx b/Crawler/assets/Campaigns/1_1_v2.tmx index 56d0f4ee..8ebd0bc4 100644 --- a/Crawler/assets/Campaigns/1_1_v2.tmx +++ b/Crawler/assets/Campaigns/1_1_v2.tmx @@ -1,5 +1,5 @@ - + @@ -1261,10 +1261,10 @@ - - - - + + + + @@ -1274,6 +1274,7 @@ +