Move priority scripthook to more sensible place in turn flow.
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Deukhoofd 2020-06-20 19:51:34 +02:00
parent b3366f7b58
commit f50f76e993
Signed by: Deukhoofd
GPG Key ID: ADF2E9256009EDCE
2 changed files with 12 additions and 3 deletions

View File

@ -30,5 +30,13 @@ public:
};
void TurnOrdering::OrderChoices(std::vector<std::shared_ptr<BaseTurnChoice>>& vec, ArbUt::Random& rand) {
for (auto item : vec) {
if (item->GetKind() == TurnChoiceKind::Attack) {
auto attackChoice = static_cast<AttackTurnChoice*>(item.get());
auto priority = attackChoice->GetPriority();
HOOK(ChangePriority, attackChoice, attackChoice, &priority);
attackChoice->SetPriority(priority);
}
}
std::sort(vec.begin(), vec.end(), ChoiceCompare());
}

View File

@ -43,7 +43,7 @@ namespace CreatureLib::Battling {
AssertNotNull(attack)
#endif
ResolveScript();
HOOK(ChangePriority, this, this, &_priority);
_priority = _attack->GetAttack()->GetPriority();
}
AttackTurnChoice(Creature* user, const ArbUt::BorrowedPtr<LearnedAttack>& attack, const CreatureIndex& target,
Script* script)
@ -52,7 +52,7 @@ namespace CreatureLib::Battling {
AssertNotNull(user)
AssertNotNull(attack)
#endif
HOOK(ChangePriority, this, this, &_priority);
_priority = _attack->GetAttack()->GetPriority();
}
~AttackTurnChoice() = default;
@ -61,7 +61,8 @@ namespace CreatureLib::Battling {
TurnChoiceKind GetKind() const noexcept override { return TurnChoiceKind ::Attack; }
inline int8_t GetPriority() const { return _attack->GetAttack()->GetPriority(); }
inline int8_t GetPriority() const noexcept { return _priority; }
inline void SetPriority(int8_t priority) noexcept { _priority = priority; }
const CreatureIndex& GetTarget() const noexcept { return _target; }