|
|
|
@ -520,24 +520,34 @@ void Player::Update(float fElapsedTime){ |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
auto AllowedToCast=[&](Ability&ability){return !ability.precastInfo.precastTargetingRequired&&GetState()!=State::ANIMATION_LOCK;}; |
|
|
|
|
auto HasEnoughOfItem=[&](Ability&ability){ |
|
|
|
|
if(!ability.itemAbility)return true; |
|
|
|
|
if(&ability==&item1&&game->GetLoadoutItem(0).lock()->Amt()>0)return true; |
|
|
|
|
if(&ability==&item2&&game->GetLoadoutItem(1).lock()->Amt()>0)return true; |
|
|
|
|
if(&ability==&item3&&game->GetLoadoutItem(2).lock()->Amt()>0)return true; |
|
|
|
|
return false; |
|
|
|
|
}; |
|
|
|
|
//If pressed is set to false, uses held instead.
|
|
|
|
|
auto CheckAndPerformAbility=[&](Ability&ability,InputGroup key){ |
|
|
|
|
if(ability.name!="???"){ |
|
|
|
|
if(CanAct(ability)){ |
|
|
|
|
if(ability.cooldown==0&&GetMana()>=ability.manaCost){ |
|
|
|
|
if(key.Held()||key.Released()&&&ability==castPrepAbility&&GetState()==State::PREP_CAST){ |
|
|
|
|
#pragma region Tutorial Defensive/Use Ability Tasks |
|
|
|
|
if(&ability==&rightClickAbility){ |
|
|
|
|
Tutorial::GetTask(TutorialTaskName::USE_DEFENSIVE).I(A::DEFENSIVE_COUNT)++; |
|
|
|
|
}else{ |
|
|
|
|
Tutorial::GetTask(TutorialTaskName::USE_ABILITIES).I(A::ABILITY_COUNT)++; |
|
|
|
|
} |
|
|
|
|
#pragma endregion |
|
|
|
|
if(AllowedToCast(ability)&&ability.action(this,{})){ |
|
|
|
|
bool allowed=ability.actionPerformedDuringCast; |
|
|
|
|
ability.cooldown=ability.GetCooldownTime(); |
|
|
|
|
CancelCast(); |
|
|
|
|
ConsumeMana(ability.manaCost); |
|
|
|
|
}else |
|
|
|
|
if(ability.precastInfo.precastTargetingRequired&&GetState()==State::NORMAL){ |
|
|
|
|
if(ability.precastInfo.precastTargetingRequired&&GetState()==State::NORMAL |
|
|
|
|
&&HasEnoughOfItem(ability)){ |
|
|
|
|
PrepareCast(ability); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|