Compare commits

..

1 Commits

Author SHA1 Message Date
bash
4f3a28bcbd nullptr exception 2025-08-10 17:51:46 +02:00
2 changed files with 23 additions and 37 deletions

View File

@@ -209,31 +209,17 @@ public:
void OnPlayerGiveXP(Player* player, uint32& amount, Unit* /*victim*/, uint8 /*xpSource*/) override void OnPlayerGiveXP(Player* player, uint32& amount, Unit* /*victim*/, uint8 /*xpSource*/) override
{ {
// early return if (!player->GetSession()->IsBot())
if (sPlayerbotAIConfig->randomBotXPRate == 1.0 || !player)
return; return;
// no XP multiplier, when player is no bot. if (!sRandomPlayerbotMgr->IsRandomBot(player))
if (!player->GetSession()->IsBot() || !sRandomPlayerbotMgr->IsRandomBot(player))
return; return;
// no XP multiplier, when bot has group where leader is a real player. if (sPlayerbotAIConfig->randomBotXPRate != 1.0)
if (Group* group = player->GetGroup())
{ {
Player* leader = group->GetLeader();
if (leader && leader != player)
{
if (PlayerbotAI* leaderBotAI = GET_PLAYERBOT_AI(leader))
{
if (leaderBotAI->HasRealPlayerMaster())
return;
}
}
}
// otherwise apply bot XP multiplier.
amount = static_cast<uint32>(std::round(static_cast<float>(amount) * sPlayerbotAIConfig->randomBotXPRate)); amount = static_cast<uint32>(std::round(static_cast<float>(amount) * sPlayerbotAIConfig->randomBotXPRate));
} }
}
}; };
class PlayerbotsMiscScript : public MiscScript class PlayerbotsMiscScript : public MiscScript

View File

@@ -164,15 +164,16 @@ void PlayerbotFactory::Init()
{ {
continue; continue;
} }
ItemTemplate const* proto = sObjectMgr->GetItemTemplate(gemId);
ItemTemplate const* proto = sObjectMgr->GetItemTemplate(gemId);
if (proto) {
if (proto->ItemLevel < 60) if (proto->ItemLevel < 60)
continue; continue;
if (proto->Flags & ITEM_FLAG_UNIQUE_EQUIPPABLE) if (proto->Flags & ITEM_FLAG_UNIQUE_EQUIPPABLE)
{
continue; continue;
} }
if (sRandomItemMgr->IsTestItem(gemId)) if (sRandomItemMgr->IsTestItem(gemId))
continue; continue;
@@ -180,9 +181,11 @@ void PlayerbotFactory::Init()
{ {
continue; continue;
} }
// LOG_INFO("playerbots", "Add {} to enchantment gems", gemId); // LOG_INFO("playerbots", "Add {} to enchantment gems", gemId);
enchantGemIdCache.push_back(gemId); enchantGemIdCache.push_back(gemId);
} }
LOG_INFO("playerbots", "Loading {} enchantment gems", enchantGemIdCache.size()); LOG_INFO("playerbots", "Loading {} enchantment gems", enchantGemIdCache.size());
} }
@@ -1017,10 +1020,8 @@ void PlayerbotFactory::ClearSkills()
} }
bot->SetUInt32Value(PLAYER_SKILL_INDEX(0), 0); bot->SetUInt32Value(PLAYER_SKILL_INDEX(0), 0);
bot->SetUInt32Value(PLAYER_SKILL_INDEX(1), 0); bot->SetUInt32Value(PLAYER_SKILL_INDEX(1), 0);
// unlearn default race/class skills // unlearn default race/class skills
if (PlayerInfo const* info = sObjectMgr->GetPlayerInfo(bot->getRace(), bot->getClass())) PlayerInfo const* info = sObjectMgr->GetPlayerInfo(bot->getRace(), bot->getClass());
{
for (PlayerCreateInfoSkills::const_iterator itr = info->skills.begin(); itr != info->skills.end(); ++itr) for (PlayerCreateInfoSkills::const_iterator itr = info->skills.begin(); itr != info->skills.end(); ++itr)
{ {
uint32 skillId = itr->SkillId; uint32 skillId = itr->SkillId;
@@ -1028,7 +1029,6 @@ void PlayerbotFactory::ClearSkills()
continue; continue;
bot->SetSkill(skillId, 0, 0, 0); bot->SetSkill(skillId, 0, 0, 0);
} }
}
} }
void PlayerbotFactory::ClearEverything() void PlayerbotFactory::ClearEverything()