Added the ability for items to be activated upon cast instead of on completion of cast. These item effects also get interrupted by any movement.
This commit is contained in:
+9
-3
@@ -438,9 +438,13 @@ 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)&&ability.action(this,{})){
|
||||
ability.cooldown=ability.COOLDOWN_TIME;
|
||||
ConsumeMana(ability.manaCost);
|
||||
if(AllowedToCast(ability)){
|
||||
bool allowed=ability.actionPerformedDuringCast;
|
||||
if(!allowed&&ability.action(this,{}))allowed=true;
|
||||
if(allowed){
|
||||
ability.cooldown=ability.COOLDOWN_TIME;
|
||||
ConsumeMana(ability.manaCost);
|
||||
}
|
||||
}else
|
||||
if(ability.precastInfo.precastTargetingRequired&&GetState()==State::NORMAL){
|
||||
PrepareCast(ability);
|
||||
@@ -655,6 +659,7 @@ void Player::Moved(){
|
||||
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<DamageNumber>(GetPos(),0,true,INTERRUPT));
|
||||
}
|
||||
for(MonsterSpawner&spawner:SPAWNER_LIST){
|
||||
@@ -748,6 +753,7 @@ void Player::CastSpell(Ability&ability){
|
||||
castPosition=GetPos()+pointToCursor;
|
||||
}
|
||||
castInfo={ability.name,ability.precastInfo.castTime,ability.precastInfo.castTime,castPosition};
|
||||
if(ability.actionPerformedDuringCast){ability.action(this,castPosition);}
|
||||
SetState(State::CASTING);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user