Adds script hook to change choice speed when determining turn order
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2022-02-19 16:11:25 +01:00
parent c078d91b0d
commit 5fce541ffb
3 changed files with 11 additions and 6 deletions

View File

@@ -22,12 +22,8 @@ public:
if (aPriority != bPriority)
return aPriority > bPriority;
}
auto aUser = a->GetUser();
auto bUser = b->GetUser();
auto aSpeed = aUser->GetBoostedStat(Library::Statistic::Speed);
auto bSpeed = bUser->GetBoostedStat(Library::Statistic::Speed);
if (aSpeed != bSpeed)
return aSpeed > bSpeed;
if (a->__GetSpeed() != b->__GetSpeed())
return a->__GetSpeed() > b->__GetSpeed();
return a->__GetRandomValue() > b->__GetRandomValue();
}
@@ -43,6 +39,10 @@ void TurnOrdering::OrderChoices(std::vector<std::shared_ptr<BaseTurnChoice>>& ve
HOOK(ChangePriority, attackChoice, attackChoice.get(), &priority);
attackChoice->SetPriority(priority);
}
auto speed = item->GetUser()->GetBoostedStat(Library::Statistic::Speed);
HOOK(ChangeSpeed, item, item.get(), &speed);
item->__SetSpeed(speed);
}
std::sort(vec.begin(), vec.end(), ChoiceCompare());
}