Update CreatureLib.
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Deukhoofd 2020-06-10 14:53:03 +02:00
parent 9e587b3d0b
commit 698bc62b47
Signed by: Deukhoofd
GPG Key ID: ADF2E9256009EDCE
1 changed files with 14 additions and 25 deletions

View File

@ -3,36 +3,25 @@
void PkmnLib::Battling::Pokemon::Evolve(ArbUt::BorrowedPtr<const Library::PokemonSpecies> mon,
ArbUt::BorrowedPtr<const Library::PokemonForme> forme) {
// Set species and variant
_species = mon.ForceAs<const CreatureLib::Library::CreatureSpecies>();
_variant = forme.ForceAs<const CreatureLib::Library::SpeciesVariant>();
ArbUt::Random* rand;
if (!_battle.IsNull()) {
rand = &_battle->GetRandom()->GetRNG();
} else {
rand = new ArbUt::Random();
}
ChangeVariant(forme.ForceAs<const CreatureLib::Library::SpeciesVariant>());
// If the pokemon is genderless, but it's new evolution is not, we want to set its gender
if (_gender != CreatureLib::Library::Gender::Genderless && _species->GetGenderRate() != -1) {
_gender = _species->GetRandomGender(*rand);
// If we are currently in battle, use the battle random so we can get predictable events.
if (!_battle.IsNull()) {
_gender = _species->GetRandomGender(_battle->GetRandom()->GetRNG());
}
// Else create a new random.
else {
ArbUt::Random rand;
_gender = _species->GetRandomGender(rand);
}
// Else if the new pokemon species is genderless, but the pokemon has a gender, make the Pokemon genderless.
} else if (_species->GetGenderRate() == -1 && _gender != CreatureLib::Library::Gender::Genderless) {
_gender = CreatureLib::Library::Gender::Genderless;
}
_types.clear();
for (auto t : forme->GetTypes()) {
_types.insert(t);
}
_activeTalent =
std::unique_ptr<CreatureLib::Battling::Script>(_library->LoadScript(ScriptCategory::Talent, GetActiveTalent()));
auto currentMaxHealth = GetBoostedStat(PkmnLib::Library::Statistic::HealthPoints);
RecalculateFlatStats();
auto diffHealth = GetBoostedStat(PkmnLib::Library::Statistic::HealthPoints) - currentMaxHealth;
_currentHealth += diffHealth;
if (_currentHealth < 0)
_currentHealth = 0;
// TODO: Learn moves?
// TODO: Event hook
}