From 583bde3768bd601730f33e5d552cd97ce1943e6c Mon Sep 17 00:00:00 2001 From: Deukhoofd Date: Sun, 24 Nov 2019 10:34:42 +0100 Subject: [PATCH] Adds more script hooks --- src/Battling/Flow/TurnHandler.cpp | 11 ++++++++--- src/Battling/ScriptHandling/Script.hpp | 3 +++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/Battling/Flow/TurnHandler.cpp b/src/Battling/Flow/TurnHandler.cpp index 52efffa..9e2c901 100644 --- a/src/Battling/Flow/TurnHandler.cpp +++ b/src/Battling/Flow/TurnHandler.cpp @@ -77,10 +77,15 @@ void TurnHandler::ExecuteAttackChoice(AttackTurnChoice *choice) { } //HOOK: check if attack fails + bool fail = false; + HOOK(FailAttack, attack, attack, fail); + if (fail){ + //TODO: Fail handling. + return; + } - //HOOK: Check if attack stops after decreasing PP - - //HOOK: On Before Attack + HOOK(StopBeforeAttack, attack, attack); + HOOK(OnBeforeAttack, attack, attack); for (auto& kv: attack->GetTargets()){ HandleAttackForTarget(attack, kv.first, kv.second); diff --git a/src/Battling/ScriptHandling/Script.hpp b/src/Battling/ScriptHandling/Script.hpp index 815e3c0..e17f2f9 100644 --- a/src/Battling/ScriptHandling/Script.hpp +++ b/src/Battling/ScriptHandling/Script.hpp @@ -29,6 +29,9 @@ namespace CreatureLib::Battling{ virtual void ChangeAttack(AttackTurnChoice* choice, std::string& attack){}; virtual void PreventAttack(ExecutingAttack* attack,bool& result){}; + virtual void FailAttack(ExecutingAttack* attack, bool& failed){}; + virtual void StopBeforeAttack(ExecutingAttack* attack){}; + virtual void OnBeforeAttack(ExecutingAttack* attack){}; virtual void FailIncomingAttack(ExecutingAttack* attack, Creature* target, bool& result){}; virtual void IsInvulnerable(ExecutingAttack* attack, Creature* target , bool& result){};