mirror of
https://github.com/mod-playerbots/mod-playerbots
synced 2025-11-29 15:58:20 +08:00
Serveral crashes fix
This commit is contained in:
@@ -128,6 +128,7 @@ void PlayerbotHolder::HandlePlayerBotLoginCallback(PlayerbotLoginQueryHolder con
|
|||||||
allowed = false;
|
allowed = false;
|
||||||
out << "Failure: You are not allowed to control bot " << bot->GetName().c_str();
|
out << "Failure: You are not allowed to control bot " << bot->GetName().c_str();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (allowed && masterSession)
|
if (allowed && masterSession)
|
||||||
{
|
{
|
||||||
Player* player = masterSession->GetPlayer();
|
Player* player = masterSession->GetPlayer();
|
||||||
@@ -145,6 +146,7 @@ void PlayerbotHolder::HandlePlayerBotLoginCallback(PlayerbotLoginQueryHolder con
|
|||||||
out << "Failure: You have added too many bots for this class";
|
out << "Failure: You have added too many bots for this class";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (allowed)
|
if (allowed)
|
||||||
{
|
{
|
||||||
sRandomPlayerbotMgr->OnPlayerLogin(bot);
|
sRandomPlayerbotMgr->OnPlayerLogin(bot);
|
||||||
@@ -1305,7 +1307,7 @@ uint32 PlayerbotHolder::GetPlayerbotsCountByClass(uint32 cls)
|
|||||||
for (PlayerBotMap::const_iterator it = GetPlayerBotsBegin(); it != GetPlayerBotsEnd(); ++it)
|
for (PlayerBotMap::const_iterator it = GetPlayerBotsBegin(); it != GetPlayerBotsEnd(); ++it)
|
||||||
{
|
{
|
||||||
Player* const bot = it->second;
|
Player* const bot = it->second;
|
||||||
if (bot->getClass() == cls)
|
if (bot && bot->IsInWorld() && bot->getClass() == cls)
|
||||||
{
|
{
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -311,7 +311,7 @@ bool ChooseRpgTargetAction::isFollowValid(Player* bot, WorldObject* target)
|
|||||||
bool ChooseRpgTargetAction::isFollowValid(Player* bot, WorldPosition pos)
|
bool ChooseRpgTargetAction::isFollowValid(Player* bot, WorldPosition pos)
|
||||||
{
|
{
|
||||||
PlayerbotAI* botAI = GET_PLAYERBOT_AI(bot);
|
PlayerbotAI* botAI = GET_PLAYERBOT_AI(bot);
|
||||||
Player* master = botAI->GetGroupMaster();
|
Player* gmaster = botAI->GetGroupMaster();
|
||||||
Player* realMaster = botAI->GetMaster();
|
Player* realMaster = botAI->GetMaster();
|
||||||
AiObjectContext* context = botAI->GetAiObjectContext();
|
AiObjectContext* context = botAI->GetAiObjectContext();
|
||||||
|
|
||||||
@@ -327,30 +327,30 @@ bool ChooseRpgTargetAction::isFollowValid(Player* bot, WorldPosition pos)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!master || bot == master)
|
if (!gmaster || bot == gmaster)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (!botAI->HasStrategy("follow", BOT_STATE_NON_COMBAT))
|
if (!botAI->HasStrategy("follow", BOT_STATE_NON_COMBAT))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (bot->GetDistance(master) > sPlayerbotAIConfig->rpgDistance * 2)
|
if (bot->GetDistance(gmaster) > sPlayerbotAIConfig->rpgDistance * 2)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
Formation* formation = AI_VALUE(Formation*, "formation");
|
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)
|
if (!botAI->HasActivePlayerMaster() && distance < 50.0f)
|
||||||
{
|
{
|
||||||
Player* player = master;
|
Player* player = gmaster;
|
||||||
if (!master->isMoving() ||
|
if (gmaster && !gmaster->isMoving() ||
|
||||||
PAI_VALUE(WorldPosition, "last long move").distance(pos) < sPlayerbotAIConfig->reactDistance)
|
PAI_VALUE(WorldPosition, "last long move").distance(pos) < sPlayerbotAIConfig->reactDistance)
|
||||||
return true;
|
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;
|
return false;
|
||||||
|
|
||||||
if (!master->isMoving() && distance < 25.0f)
|
if (!gmaster->isMoving() && distance < 25.0f)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (distance < formation->GetMaxDistance())
|
if (distance < formation->GetMaxDistance())
|
||||||
|
|||||||
@@ -165,16 +165,10 @@ bool SummonAction::SummonUsingNpcs(Player* summoner, Player* player)
|
|||||||
|
|
||||||
bool SummonAction::Teleport(Player* summoner, Player* player)
|
bool SummonAction::Teleport(Player* summoner, Player* player)
|
||||||
{
|
{
|
||||||
Player* master = GetMaster();
|
// Player* master = GetMaster();
|
||||||
// if (master->GetMap() && master->GetMap()->IsDungeon()) {
|
if (!summoner)
|
||||||
// InstanceMap* map = master->GetMap()->ToInstanceMap();
|
return false;
|
||||||
// if (map) {
|
|
||||||
// if (map->CannotEnter(player, true) == Map::CANNOT_ENTER_MAX_PLAYERS) {
|
|
||||||
// botAI->TellError("I can not enter this dungeon");
|
|
||||||
// return false;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
if (player->GetVehicle())
|
if (player->GetVehicle())
|
||||||
{
|
{
|
||||||
botAI->TellError("You cannot summon me while I'm on a vehicle");
|
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
|
->botRepairWhenSummon) // .conf option to repair bot gear when summoned 0 = off, 1 = on
|
||||||
bot->DurabilityRepairAll(false, 1.0f, false);
|
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");
|
botAI->TellError("You cannot summon me while you're in combat");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!master->IsAlive() && !sPlayerbotAIConfig->allowSummonWhenMasterIsDead)
|
if (!summoner->IsAlive() && !sPlayerbotAIConfig->allowSummonWhenMasterIsDead)
|
||||||
{
|
{
|
||||||
botAI->TellError("You cannot summon me while you're dead");
|
botAI->TellError("You cannot summon me while you're dead");
|
||||||
return false;
|
return false;
|
||||||
@@ -218,7 +212,7 @@ bool SummonAction::Teleport(Player* summoner, Player* player)
|
|||||||
|
|
||||||
bool revive =
|
bool revive =
|
||||||
sPlayerbotAIConfig->reviveBotWhenSummoned == 2 ||
|
sPlayerbotAIConfig->reviveBotWhenSummoned == 2 ||
|
||||||
(sPlayerbotAIConfig->reviveBotWhenSummoned == 1 && !master->IsInCombat() && master->IsAlive());
|
(sPlayerbotAIConfig->reviveBotWhenSummoned == 1 && !summoner->IsInCombat() && summoner->IsAlive());
|
||||||
|
|
||||||
if (bot->isDead() && revive)
|
if (bot->isDead() && revive)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user