diff --git a/src/Battling/Library/MiscLibrary.cpp b/src/Battling/Library/MiscLibrary.cpp index 35459ee..39f0605 100644 --- a/src/Battling/Library/MiscLibrary.cpp +++ b/src/Battling/Library/MiscLibrary.cpp @@ -34,5 +34,7 @@ CreatureLib::Battling::MiscLibrary::ReplacementAttack(Creature* user, CreatureIn auto sideTarget = 0; if (user->GetBattleSide()->GetSideIndex() == 0) sideTarget = 1; - return new AttackTurnChoice(user, GetReplacementAttack(), target); + auto side = user->GetBattle()->GetSides()[sideTarget]; + auto random_mon = side->GetRandomCreatureIndex(); + return new AttackTurnChoice(user, GetReplacementAttack(), CreatureIndex(side->GetSideIndex(), random_mon)); } diff --git a/src/Battling/Models/BattleSide.cpp b/src/Battling/Models/BattleSide.cpp index d686f7d..f7c415e 100644 --- a/src/Battling/Models/BattleSide.cpp +++ b/src/Battling/Models/BattleSide.cpp @@ -68,3 +68,7 @@ void BattleSide::GetActiveScripts(std::vector& scripts) { scripts.emplace_back(&_volatile); _battle->GetActiveScripts(scripts); } +uint8_t BattleSide::GetRandomCreatureIndex() { + // TODO: Consider adding parameter to only get index for available creatures. + return _battle->GetRandom()->Get(_creaturesPerSide); +} diff --git a/src/Battling/Models/BattleSide.hpp b/src/Battling/Models/BattleSide.hpp index 4f6e67e..2dada24 100644 --- a/src/Battling/Models/BattleSide.hpp +++ b/src/Battling/Models/BattleSide.hpp @@ -79,6 +79,8 @@ namespace CreatureLib::Battling { bool HasFled() { return _hasFled; } void MarkAsFled() { _hasFled = true; } + + uint8_t GetRandomCreatureIndex(); }; }