Adds script hook for preventing the opponent from switching out.
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
Signed-off-by: Deukhoofd <Deukhoofd@gmail.com>
This commit is contained in:
parent
1ddbfd2357
commit
acacd02ef9
|
@ -251,14 +251,33 @@ void TurnHandler::HandleAttackForTarget(ExecutingAttack* attack, const ArbUt::Bo
|
|||
}
|
||||
|
||||
void TurnHandler::ExecuteSwitchChoice(const ArbUt::BorrowedPtr<SwitchTurnChoice>& choice) {
|
||||
auto user = choice->GetUser();
|
||||
auto battle = user->GetBattle();
|
||||
if (!battle.HasValue()) {
|
||||
return;
|
||||
}
|
||||
|
||||
bool preventSwitch = false;
|
||||
HOOK(PreventSelfSwitch, choice, choice.GetRaw(), &preventSwitch);
|
||||
if (preventSwitch) {
|
||||
return;
|
||||
}
|
||||
// HOOK: PreventOpponentSwitch for each opponent.
|
||||
for (auto* side : battle.GetValue()->GetSides()) {
|
||||
if (side == user->GetBattleSide()) {
|
||||
continue;
|
||||
}
|
||||
for (const auto& creature : side->GetCreatures()) {
|
||||
if (!creature.HasValue()) {
|
||||
continue;
|
||||
}
|
||||
HOOK(PreventOpponentSwitch, creature.GetValue(), choice, &preventSwitch);
|
||||
if (preventSwitch) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
auto user = choice->GetUser();
|
||||
user->ClearVolatileScripts();
|
||||
auto userSide = user->GetBattleSide();
|
||||
if (userSide.HasValue()) {
|
||||
|
|
|
@ -71,6 +71,8 @@ namespace CreatureLib::Battling {
|
|||
|
||||
virtual void PreventSelfSwitch([[maybe_unused]] const SwitchTurnChoice* choice,
|
||||
[[maybe_unused]] bool* outResult){};
|
||||
virtual void PreventOpponentSwitch([[maybe_unused]] const SwitchTurnChoice* choice,
|
||||
[[maybe_unused]] bool* outResult){};
|
||||
|
||||
virtual void ModifyEffectChance([[maybe_unused]] const ExecutingAttack* attack,
|
||||
[[maybe_unused]] Creature* target, [[maybe_unused]] float* chance){};
|
||||
|
|
Loading…
Reference in New Issue