diff --git a/src/strategy/rpg/NewRpgBaseAction.cpp b/src/strategy/rpg/NewRpgBaseAction.cpp index 5e71c5c5..9af540dc 100644 --- a/src/strategy/rpg/NewRpgBaseAction.cpp +++ b/src/strategy/rpg/NewRpgBaseAction.cpp @@ -1060,6 +1060,13 @@ bool NewRpgBaseAction::RandomChangeStatus(std::vector candidateSta probSum += sPlayerbotAIConfig->RpgStatusProbWeight[status]; } } + // Safety check. Default to "rest" if all RPG weights = 0 + if (availableStatus.empty() || probSum == 0) + { + botAI->rpgInfo.ChangeToRest(); + bot->SetStandState(UNIT_STAND_STATE_SIT); + return true; + } uint32 rand = urand(1, probSum); uint32 accumulate = 0; NewRpgStatus chosenStatus = RPG_STATUS_END; @@ -1218,4 +1225,4 @@ bool NewRpgBaseAction::CheckRpgStatusAvailable(NewRpgStatus status) return false; } return false; -} \ No newline at end of file +}