diff --git a/src/PlayerbotMgr.cpp b/src/PlayerbotMgr.cpp index 491e93ec..d1b92d7a 100644 --- a/src/PlayerbotMgr.cpp +++ b/src/PlayerbotMgr.cpp @@ -128,6 +128,7 @@ void PlayerbotHolder::HandlePlayerBotLoginCallback(PlayerbotLoginQueryHolder con allowed = false; out << "Failure: You are not allowed to control bot " << bot->GetName().c_str(); } + if (allowed && masterSession) { Player* player = masterSession->GetPlayer(); @@ -145,6 +146,7 @@ void PlayerbotHolder::HandlePlayerBotLoginCallback(PlayerbotLoginQueryHolder con out << "Failure: You have added too many bots for this class"; } } + if (allowed) { sRandomPlayerbotMgr->OnPlayerLogin(bot); @@ -1305,7 +1307,7 @@ uint32 PlayerbotHolder::GetPlayerbotsCountByClass(uint32 cls) for (PlayerBotMap::const_iterator it = GetPlayerBotsBegin(); it != GetPlayerBotsEnd(); ++it) { Player* const bot = it->second; - if (bot->getClass() == cls) + if (bot && bot->IsInWorld() && bot->getClass() == cls) { count++; } diff --git a/src/strategy/actions/ChooseRpgTargetAction.cpp b/src/strategy/actions/ChooseRpgTargetAction.cpp index dfd1cef5..4b00cfe5 100644 --- a/src/strategy/actions/ChooseRpgTargetAction.cpp +++ b/src/strategy/actions/ChooseRpgTargetAction.cpp @@ -311,7 +311,7 @@ bool ChooseRpgTargetAction::isFollowValid(Player* bot, WorldObject* target) bool ChooseRpgTargetAction::isFollowValid(Player* bot, WorldPosition pos) { PlayerbotAI* botAI = GET_PLAYERBOT_AI(bot); - Player* master = botAI->GetGroupMaster(); + Player* gmaster = botAI->GetGroupMaster(); Player* realMaster = botAI->GetMaster(); AiObjectContext* context = botAI->GetAiObjectContext(); @@ -327,30 +327,30 @@ bool ChooseRpgTargetAction::isFollowValid(Player* bot, WorldPosition pos) return false; } - if (!master || bot == master) + if (!gmaster || bot == gmaster) return true; if (!botAI->HasStrategy("follow", BOT_STATE_NON_COMBAT)) return true; - if (bot->GetDistance(master) > sPlayerbotAIConfig->rpgDistance * 2) + if (bot->GetDistance(gmaster) > sPlayerbotAIConfig->rpgDistance * 2) return false; Formation* formation = AI_VALUE(Formation*, "formation"); - float distance = master->GetDistance2d(pos.getX(), pos.getY()); + float distance = gmaster->GetDistance2d(pos.getX(), pos.getY()); if (!botAI->HasActivePlayerMaster() && distance < 50.0f) { - Player* player = master; - if (!master->isMoving() || + Player* player = gmaster; + if (gmaster && !gmaster->isMoving() || PAI_VALUE(WorldPosition, "last long move").distance(pos) < sPlayerbotAIConfig->reactDistance) return true; } - if ((inDungeon || !master->HasPlayerFlag(PLAYER_FLAGS_RESTING)) && realMaster == master && distance > 5.0f) + if ((inDungeon || !gmaster->HasPlayerFlag(PLAYER_FLAGS_RESTING)) && realMaster == gmaster && distance > 5.0f) return false; - if (!master->isMoving() && distance < 25.0f) + if (!gmaster->isMoving() && distance < 25.0f) return true; if (distance < formation->GetMaxDistance()) diff --git a/src/strategy/actions/UseMeetingStoneAction.cpp b/src/strategy/actions/UseMeetingStoneAction.cpp index 0c0b7285..f5d61b01 100644 --- a/src/strategy/actions/UseMeetingStoneAction.cpp +++ b/src/strategy/actions/UseMeetingStoneAction.cpp @@ -165,16 +165,10 @@ bool SummonAction::SummonUsingNpcs(Player* summoner, Player* player) bool SummonAction::Teleport(Player* summoner, Player* player) { - Player* master = GetMaster(); - // if (master->GetMap() && master->GetMap()->IsDungeon()) { - // InstanceMap* map = master->GetMap()->ToInstanceMap(); - // if (map) { - // if (map->CannotEnter(player, true) == Map::CANNOT_ENTER_MAX_PLAYERS) { - // botAI->TellError("I can not enter this dungeon"); - // return false; - // } - // } - // } + // Player* master = GetMaster(); + if (!summoner) + return false; + if (player->GetVehicle()) { botAI->TellError("You cannot summon me while I'm on a vehicle"); @@ -197,13 +191,13 @@ bool SummonAction::Teleport(Player* summoner, Player* player) ->botRepairWhenSummon) // .conf option to repair bot gear when summoned 0 = off, 1 = on bot->DurabilityRepairAll(false, 1.0f, false); - if (master->IsInCombat() && !sPlayerbotAIConfig->allowSummonInCombat) + if (summoner->IsInCombat() && !sPlayerbotAIConfig->allowSummonInCombat) { botAI->TellError("You cannot summon me while you're in combat"); return false; } - if (!master->IsAlive() && !sPlayerbotAIConfig->allowSummonWhenMasterIsDead) + if (!summoner->IsAlive() && !sPlayerbotAIConfig->allowSummonWhenMasterIsDead) { botAI->TellError("You cannot summon me while you're dead"); return false; @@ -218,7 +212,7 @@ bool SummonAction::Teleport(Player* summoner, Player* player) bool revive = sPlayerbotAIConfig->reviveBotWhenSummoned == 2 || - (sPlayerbotAIConfig->reviveBotWhenSummoned == 1 && !master->IsInCombat() && master->IsAlive()); + (sPlayerbotAIConfig->reviveBotWhenSummoned == 1 && !summoner->IsInCombat() && summoner->IsAlive()); if (bot->isDead() && revive) {