From 698bc62b477da66387e1a8d7600e1dfb1401d792 Mon Sep 17 00:00:00 2001 From: Deukhoofd Date: Wed, 10 Jun 2020 14:53:03 +0200 Subject: [PATCH] Update CreatureLib. --- src/Battling/Pokemon/Pokemon.cpp | 39 ++++++++++++-------------------- 1 file changed, 14 insertions(+), 25 deletions(-) diff --git a/src/Battling/Pokemon/Pokemon.cpp b/src/Battling/Pokemon/Pokemon.cpp index 16e01fd..0db5c23 100644 --- a/src/Battling/Pokemon/Pokemon.cpp +++ b/src/Battling/Pokemon/Pokemon.cpp @@ -3,36 +3,25 @@ void PkmnLib::Battling::Pokemon::Evolve(ArbUt::BorrowedPtr mon, ArbUt::BorrowedPtr forme) { + // Set species and variant _species = mon.ForceAs(); - _variant = forme.ForceAs(); - - ArbUt::Random* rand; - if (!_battle.IsNull()) { - rand = &_battle->GetRandom()->GetRNG(); - } else { - rand = new ArbUt::Random(); - } + ChangeVariant(forme.ForceAs()); + // 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(_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 }