Removed OnStatusMove hook, now just uses OnSecondaryEffect hook.
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Deukhoofd 2020-04-10 23:06:19 +02:00
parent 5ac2b7b3c9
commit 04bf061115
Signed by: Deukhoofd
GPG Key ID: ADF2E9256009EDCE
3 changed files with 11 additions and 6 deletions

View File

@ -69,10 +69,6 @@ export uint8_t CreatureLib_Script_OverrideDamage(Script* p, ExecutingAttack* att
uint8_t hitNumber, uint32_t* damage) { uint8_t hitNumber, uint32_t* damage) {
Try(p->OverrideDamage(attack, target, hitNumber, damage)); Try(p->OverrideDamage(attack, target, hitNumber, damage));
} }
export uint8_t CreatureLib_Script_OnStatusMove(Script* p, ExecutingAttack* attack, Creature* target,
uint8_t hitNumber) {
Try(p->OnStatusMove(attack, target, hitNumber));
}
export uint8_t CreatureLib_Script_PreventSecondaryEffects(Script* p, ExecutingAttack* attack, Creature* target, export uint8_t CreatureLib_Script_PreventSecondaryEffects(Script* p, ExecutingAttack* attack, Creature* target,
uint8_t hitNumber, bool* outResult) { uint8_t hitNumber, bool* outResult) {
Try(p->PreventSecondaryEffects(attack, target, hitNumber, outResult)); Try(p->PreventSecondaryEffects(attack, target, hitNumber, outResult));

View File

@ -155,7 +155,17 @@ void TurnHandler::HandleAttackForTarget(ExecutingAttack* attack, Creature* targe
if (attackData->GetCategory() == Library::AttackCategory::Status) { if (attackData->GetCategory() == Library::AttackCategory::Status) {
if (attackData->HasSecondaryEffect()) { if (attackData->HasSecondaryEffect()) {
HOOK(OnStatusMove, userSource, attack, target, hitIndex); auto effect = attackData->GetSecondaryEffect();
bool hasSecondaryEffect;
if (effect->GetChance() == -1) {
hasSecondaryEffect = true;
} else {
hasSecondaryEffect =
user->GetBattle()->GetRandom()->EffectChance(effect->GetChance(), attack, target);
}
if (hasSecondaryEffect) {
HOOK(OnSecondaryEffect, userSource, attack, target, hitIndex);
}
} }
} else { } else {
auto damage = hit->GetDamage(); auto damage = hit->GetDamage();

View File

@ -50,7 +50,6 @@ namespace CreatureLib::Battling {
float* modifier){}; float* modifier){};
virtual void OverrideDamage(ExecutingAttack* attack, Creature* target, uint8_t hitIndex, uint32_t* damage){}; virtual void OverrideDamage(ExecutingAttack* attack, Creature* target, uint8_t hitIndex, uint32_t* damage){};
virtual void OnStatusMove(const ExecutingAttack* attack, Creature* target, uint8_t hitNumber){};
virtual void PreventSecondaryEffects(const ExecutingAttack* attack, Creature* target, uint8_t hitNumber, virtual void PreventSecondaryEffects(const ExecutingAttack* attack, Creature* target, uint8_t hitNumber,
bool* outResult){}; bool* outResult){};
virtual void OnSecondaryEffect(const ExecutingAttack* attack, Creature* target, uint8_t hitNumber){}; virtual void OnSecondaryEffect(const ExecutingAttack* attack, Creature* target, uint8_t hitNumber){};