|
|
|
@ -586,46 +586,6 @@ void Player::Update(float fElapsedTime){ |
|
|
|
|
AutoAttack(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
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 |
|
|
|
|
&&HasEnoughOfItem(ability)){ |
|
|
|
|
PrepareCast(ability); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} else
|
|
|
|
|
if(ability.cooldown==0&&GetMana()<ability.manaCost&&key.Pressed()){ |
|
|
|
|
notEnoughManaDisplay={ability.name,1.f}; |
|
|
|
|
} |
|
|
|
|
}else |
|
|
|
|
if(key.Released()||!key.Held())ability.waitForRelease=false; |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
CheckAndPerformAbility(rightClickAbility,Player::KEY_DEFENSIVE); |
|
|
|
|
CheckAndPerformAbility(ability,Player::KEY_ABILITY1); |
|
|
|
|
CheckAndPerformAbility(ability2,Player::KEY_ABILITY2); |
|
|
|
@ -766,7 +726,7 @@ bool Player::CanAct(){ |
|
|
|
|
return CanAct(dummyAbility); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
bool Player::CanAct(Ability&ability){ |
|
|
|
|
const bool Player::CanAct(const Ability&ability){ |
|
|
|
|
return knockUpTimer==0&&!ability.waitForRelease&&(ability.canCancelCast||state!=State::CASTING)&&state!=State::ANIMATION_LOCK&& |
|
|
|
|
(GameState::STATE==GameState::states[States::GAME_RUN] |
|
|
|
|
||GameState::STATE==GameState::states[States::GAME_HUB]&&!ability.itemAbility); |
|
|
|
@ -851,6 +811,7 @@ void Player::AddAnimation(std::string state){ |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void Player::UpdateAnimation(std::string animState,int specificClass, const float frameMult){ |
|
|
|
|
if(game->TestingModeEnabled())return; |
|
|
|
|
if(specificClass==ANY||specificClass&GetClass()){ |
|
|
|
|
animation.ChangeState(internal_animState,animState,frameMult); |
|
|
|
|
} |
|
|
|
@ -1601,3 +1562,40 @@ const float Player::GetHealthRatio()const{ |
|
|
|
|
const bool Player::IsAlive()const{ |
|
|
|
|
return GetHealth()>0; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void Player::CheckAndPerformAbility(Ability&ability,InputGroup key){ |
|
|
|
|
const bool AllowedToCast=!ability.precastInfo.precastTargetingRequired&&GetState()!=State::ANIMATION_LOCK; |
|
|
|
|
const bool HasEnoughOfItem=!ability.itemAbility|| |
|
|
|
|
&ability==&useItem1&&game->GetLoadoutItem(0).lock()->Amt()>0|| |
|
|
|
|
&ability==&useItem2&&game->GetLoadoutItem(1).lock()->Amt()>0|| |
|
|
|
|
&ability==&useItem3&&game->GetLoadoutItem(2).lock()->Amt()>0; |
|
|
|
|
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==&GetRightClickAbility()){ |
|
|
|
|
Tutorial::GetTask(TutorialTaskName::USE_DEFENSIVE).I(A::DEFENSIVE_COUNT)++; |
|
|
|
|
}else{ |
|
|
|
|
Tutorial::GetTask(TutorialTaskName::USE_ABILITIES).I(A::ABILITY_COUNT)++; |
|
|
|
|
} |
|
|
|
|
#pragma endregion |
|
|
|
|
if(AllowedToCast&&ability.action(this,{})){ |
|
|
|
|
bool allowed=ability.actionPerformedDuringCast; |
|
|
|
|
ability.cooldown=ability.GetCooldownTime(); |
|
|
|
|
CancelCast(); |
|
|
|
|
ConsumeMana(ability.manaCost); |
|
|
|
|
}else |
|
|
|
|
if(ability.precastInfo.precastTargetingRequired&&GetState()==State::NORMAL |
|
|
|
|
&&HasEnoughOfItem){ |
|
|
|
|
PrepareCast(ability); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} else
|
|
|
|
|
if(ability.cooldown==0&&GetMana()<ability.manaCost&&key.Pressed()){ |
|
|
|
|
notEnoughManaDisplay={ability.name,1.f}; |
|
|
|
|
} |
|
|
|
|
}else |
|
|
|
|
if(key.Released()||!key.Held())ability.waitForRelease=false; |
|
|
|
|
} |
|
|
|
|
} |