diff --git a/src/Battling/Models/Creature.cpp b/src/Battling/Models/Creature.cpp index f582d5b..b404020 100644 --- a/src/Battling/Models/Creature.cpp +++ b/src/Battling/Models/Creature.cpp @@ -37,6 +37,22 @@ namespace CreatureLib::Battling { AssertNotNull(variant); _species = species; ChangeVariant(variant); + + // If the creature is genderless, but it's new species is not, we want to set its gender + if (_gender != CreatureLib::Library::Gender::Genderless && _species->GetGenderRate() != -1) { + // 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 species is genderless, but the creature has a gender, make the creature genderless. + else if (_species->GetGenderRate() == -1 && _gender != CreatureLib::Library::Gender::Genderless) { + _gender = CreatureLib::Library::Gender::Genderless; + } } void Creature::ChangeVariant(const ArbUt::BorrowedPtr& variant) {