Make Script functions use pointers for out variables, instead of references.
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
836a201b2d
commit
c3877e0151
|
@ -52,7 +52,7 @@ void TurnHandler::ExecuteChoice(BaseTurnChoice* choice) {
|
||||||
|
|
||||||
void TurnHandler::ExecuteAttackChoice(AttackTurnChoice* choice) {
|
void TurnHandler::ExecuteAttackChoice(AttackTurnChoice* choice) {
|
||||||
auto attackName = choice->GetAttack()->GetAttack()->GetName();
|
auto attackName = choice->GetAttack()->GetAttack()->GetName();
|
||||||
HOOK(ChangeAttack, choice, choice, attackName);
|
HOOK(ChangeAttack, choice, choice, &attackName);
|
||||||
if (attackName != choice->GetAttack()->GetAttack()->GetName()) {
|
if (attackName != choice->GetAttack()->GetAttack()->GetName()) {
|
||||||
// TODO: Change attack
|
// TODO: Change attack
|
||||||
}
|
}
|
||||||
|
@ -63,7 +63,7 @@ void TurnHandler::ExecuteAttackChoice(AttackTurnChoice* choice) {
|
||||||
|
|
||||||
auto attack = new ExecutingAttack(targets, 1, choice->GetUser(), choice->GetAttack(), choice->GetAttackScript());
|
auto attack = new ExecutingAttack(targets, 1, choice->GetUser(), choice->GetAttack(), choice->GetAttackScript());
|
||||||
bool prevented = false;
|
bool prevented = false;
|
||||||
HOOK(PreventAttack, attack, attack, prevented);
|
HOOK(PreventAttack, attack, attack, &prevented);
|
||||||
if (prevented) {
|
if (prevented) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -76,7 +76,7 @@ void TurnHandler::ExecuteAttackChoice(AttackTurnChoice* choice) {
|
||||||
|
|
||||||
// HOOK: check if attack fails
|
// HOOK: check if attack fails
|
||||||
bool fail = false;
|
bool fail = false;
|
||||||
HOOK(FailAttack, attack, attack, fail);
|
HOOK(FailAttack, attack, attack, &fail);
|
||||||
if (fail) {
|
if (fail) {
|
||||||
// TODO: Fail handling.
|
// TODO: Fail handling.
|
||||||
return;
|
return;
|
||||||
|
@ -101,14 +101,14 @@ void TurnHandler::HandleAttackForTarget(ExecutingAttack* attack, Creature* targe
|
||||||
ScriptSource* userSource = attack;
|
ScriptSource* userSource = attack;
|
||||||
|
|
||||||
bool fail = false;
|
bool fail = false;
|
||||||
HOOK(FailIncomingAttack, targetSource, attack, target, fail);
|
HOOK(FailIncomingAttack, targetSource, attack, target, &fail);
|
||||||
if (fail) {
|
if (fail) {
|
||||||
// TODO: Fail handling.
|
// TODO: Fail handling.
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool invulnerable = fail;
|
bool invulnerable = fail;
|
||||||
HOOK(IsInvulnerable, targetSource, attack, target, invulnerable);
|
HOOK(IsInvulnerable, targetSource, attack, target, &invulnerable);
|
||||||
if (invulnerable) {
|
if (invulnerable) {
|
||||||
// TODO: We should probably do something when a target is invulnerable.
|
// TODO: We should probably do something when a target is invulnerable.
|
||||||
return;
|
return;
|
||||||
|
@ -136,7 +136,7 @@ void TurnHandler::HandleAttackForTarget(ExecutingAttack* attack, Creature* targe
|
||||||
auto hit = targetData->GetHit(hitIndex);
|
auto hit = targetData->GetHit(hitIndex);
|
||||||
|
|
||||||
auto hitType = hit->GetType();
|
auto hitType = hit->GetType();
|
||||||
HOOK(ChangeAttackType, targetSource, attack, target, hitIndex, hitType);
|
HOOK(ChangeAttackType, targetSource, attack, target, hitIndex, &hitType);
|
||||||
hit->SetEffectiveness(library->GetTypeLibrary()->GetEffectiveness(hitType, target->GetTypes()));
|
hit->SetEffectiveness(library->GetTypeLibrary()->GetEffectiveness(hitType, target->GetTypes()));
|
||||||
hit->SetCritical(library->GetMiscLibrary()->IsCritical(attack, target, hitIndex));
|
hit->SetCritical(library->GetMiscLibrary()->IsCritical(attack, target, hitIndex));
|
||||||
hit->SetBasePower(dmgLibrary->GetBasePower(attack, target, hitIndex));
|
hit->SetBasePower(dmgLibrary->GetBasePower(attack, target, hitIndex));
|
||||||
|
@ -169,7 +169,7 @@ void TurnHandler::HandleAttackForTarget(ExecutingAttack* attack, Creature* targe
|
||||||
|
|
||||||
void TurnHandler::ExecuteSwitchChoice(CreatureLib::Battling::SwitchTurnChoice* choice) {
|
void TurnHandler::ExecuteSwitchChoice(CreatureLib::Battling::SwitchTurnChoice* choice) {
|
||||||
bool preventSwitch = false;
|
bool preventSwitch = false;
|
||||||
HOOK(PreventSelfSwitch, choice, choice, preventSwitch);
|
HOOK(PreventSelfSwitch, choice, choice, &preventSwitch);
|
||||||
if (preventSwitch) {
|
if (preventSwitch) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,16 +31,16 @@ namespace CreatureLib::Battling {
|
||||||
|
|
||||||
virtual void OnBeforeTurn(const BaseTurnChoice* choice){};
|
virtual void OnBeforeTurn(const BaseTurnChoice* choice){};
|
||||||
|
|
||||||
virtual void ChangeAttack(AttackTurnChoice* choice, std::string& attack){};
|
virtual void ChangeAttack(AttackTurnChoice* choice, std::string* attack){};
|
||||||
virtual void PreventAttack(ExecutingAttack* attack, bool& result){};
|
virtual void PreventAttack(ExecutingAttack* attack, bool* result){};
|
||||||
virtual void FailAttack(ExecutingAttack* attack, bool& failed){};
|
virtual void FailAttack(ExecutingAttack* attack, bool* failed){};
|
||||||
virtual void StopBeforeAttack(ExecutingAttack* attack){};
|
virtual void StopBeforeAttack(ExecutingAttack* attack){};
|
||||||
virtual void OnBeforeAttack(ExecutingAttack* attack){};
|
virtual void OnBeforeAttack(ExecutingAttack* attack){};
|
||||||
|
|
||||||
virtual void FailIncomingAttack(ExecutingAttack* attack, Creature* target, bool& result){};
|
virtual void FailIncomingAttack(ExecutingAttack* attack, Creature* target, bool* result){};
|
||||||
virtual void IsInvulnerable(ExecutingAttack* attack, Creature* target, bool& result){};
|
virtual void IsInvulnerable(ExecutingAttack* attack, Creature* target, bool* result){};
|
||||||
virtual void OnAttackMiss(ExecutingAttack* attack, Creature* target){};
|
virtual void OnAttackMiss(ExecutingAttack* attack, Creature* target){};
|
||||||
virtual void ChangeAttackType(ExecutingAttack* attack, Creature* target, uint8_t hitNumber, uint8_t& type){};
|
virtual void ChangeAttackType(ExecutingAttack* attack, Creature* target, uint8_t hitNumber, uint8_t* type){};
|
||||||
virtual void OnStatusMove(const ExecutingAttack* attack, Creature* target, uint8_t hitNumber){};
|
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& result){};
|
bool& result){};
|
||||||
|
@ -48,7 +48,7 @@ namespace CreatureLib::Battling {
|
||||||
|
|
||||||
virtual void OnAfterHits(const ExecutingAttack* attack, Creature* target){};
|
virtual void OnAfterHits(const ExecutingAttack* attack, Creature* target){};
|
||||||
|
|
||||||
virtual void PreventSelfSwitch(const SwitchTurnChoice* choice, bool& result){};
|
virtual void PreventSelfSwitch(const SwitchTurnChoice* choice, bool* result){};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue