Adds script hook to modify number of hits
continuous-integration/drone/push Build is passing Details

Signed-off-by: Deukhoofd <Deukhoofd@gmail.com>
This commit is contained in:
Deukhoofd 2021-03-28 19:43:26 +02:00
parent 374a4d10a8
commit a3b7002cd4
Signed by: Deukhoofd
GPG Key ID: F63E044490819F6F
2 changed files with 8 additions and 1 deletions

View File

@ -96,8 +96,14 @@ void TurnHandler::ExecuteAttackChoice(const ArbUt::BorrowedPtr<AttackTurnChoice>
try_creature(targets = TargetResolver::ResolveTargets(choice->GetTarget(), targetType, battle.GetValue()); try_creature(targets = TargetResolver::ResolveTargets(choice->GetTarget(), targetType, battle.GetValue());
, "Exception during target determination"); , "Exception during target determination");
u8 numberHits = 1;
HOOK(ModifyNumberOfHits, choice, choice, &numberHits);
if (numberHits == 0) {
return;
}
auto attackScoped = ArbUt::ScopedPtr<ExecutingAttack>( auto attackScoped = ArbUt::ScopedPtr<ExecutingAttack>(
new ExecutingAttack(targets, 1, choice->GetUser(), choice->GetAttack(), choice->GetAttackScript())); new ExecutingAttack(targets, numberHits, choice->GetUser(), choice->GetAttack(), choice->GetAttackScript()));
bool prevented = false; bool prevented = false;
HOOK(PreventAttack, attackScoped, attackScoped, &prevented); HOOK(PreventAttack, attackScoped, attackScoped, &prevented);
if (prevented) { if (prevented) {

View File

@ -30,6 +30,7 @@ namespace CreatureLib::Battling {
virtual void ChangePriority([[maybe_unused]] AttackTurnChoice* choice, [[maybe_unused]] int8_t* priority){}; virtual void ChangePriority([[maybe_unused]] AttackTurnChoice* choice, [[maybe_unused]] int8_t* priority){};
virtual void ChangeAttack([[maybe_unused]] AttackTurnChoice* choice, virtual void ChangeAttack([[maybe_unused]] AttackTurnChoice* choice,
[[maybe_unused]] ArbUt::StringView* outAttack){}; [[maybe_unused]] ArbUt::StringView* outAttack){};
virtual void ModifyNumberOfHits([[maybe_unused]] AttackTurnChoice* choice, [[maybe_unused]] u8* numberOfHits){};
virtual void PreventAttack([[maybe_unused]] ExecutingAttack* attack, [[maybe_unused]] bool* outResult){}; virtual void PreventAttack([[maybe_unused]] ExecutingAttack* attack, [[maybe_unused]] bool* outResult){};
virtual void FailAttack([[maybe_unused]] ExecutingAttack* attack, [[maybe_unused]] bool* outFailed){}; virtual void FailAttack([[maybe_unused]] ExecutingAttack* attack, [[maybe_unused]] bool* outFailed){};
virtual void StopBeforeAttack([[maybe_unused]] ExecutingAttack* attack, [[maybe_unused]] bool* outResult){}; virtual void StopBeforeAttack([[maybe_unused]] ExecutingAttack* attack, [[maybe_unused]] bool* outResult){};