mirror of
https://github.com/mod-playerbots/mod-playerbots
synced 2025-11-29 15:58:20 +08:00
Compare commits
4 Commits
hermensbas
...
hermensbas
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b71d97b9fc | ||
|
|
3d28a81508 | ||
|
|
bcd6f5bc06 | ||
|
|
15f138aab0 |
@@ -4214,19 +4214,6 @@ bool PlayerbotAI::AllowActive(ActivityType activityType)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// only keep updating till initializing time has completed,
|
|
||||||
// which prevents unneeded expensive GameTime calls.
|
|
||||||
if (_isBotInitializing)
|
|
||||||
{
|
|
||||||
_isBotInitializing = GameTime::GetUptime().count() < sPlayerbotAIConfig->maxRandomBots * 0.11;
|
|
||||||
|
|
||||||
// no activity allowed during bot initialization
|
|
||||||
if (_isBotInitializing)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// General exceptions
|
// General exceptions
|
||||||
if (activityType == PACKET_ACTIVITY)
|
if (activityType == PACKET_ACTIVITY)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -611,7 +611,6 @@ private:
|
|||||||
Item* FindItemInInventory(std::function<bool(ItemTemplate const*)> checkItem) const;
|
Item* FindItemInInventory(std::function<bool(ItemTemplate const*)> checkItem) const;
|
||||||
void HandleCommands();
|
void HandleCommands();
|
||||||
void HandleCommand(uint32 type, const std::string& text, Player& fromPlayer, const uint32 lang = LANG_UNIVERSAL);
|
void HandleCommand(uint32 type, const std::string& text, Player& fromPlayer, const uint32 lang = LANG_UNIVERSAL);
|
||||||
bool _isBotInitializing = false;
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Player* bot;
|
Player* bot;
|
||||||
|
|||||||
@@ -108,7 +108,7 @@ public:
|
|||||||
"|cffcccccchttps://github.com/liyunfan1223/mod-playerbots|r");
|
"|cffcccccchttps://github.com/liyunfan1223/mod-playerbots|r");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sPlayerbotAIConfig->enabled || sPlayerbotAIConfig->randomBotAutologin)
|
/*if (sPlayerbotAIConfig->enabled || sPlayerbotAIConfig->randomBotAutologin)
|
||||||
{
|
{
|
||||||
std::string roundedTime =
|
std::string roundedTime =
|
||||||
std::to_string(std::ceil((sPlayerbotAIConfig->maxRandomBots * 0.11 / 60) * 10) / 10.0);
|
std::to_string(std::ceil((sPlayerbotAIConfig->maxRandomBots * 0.11 / 60) * 10) / 10.0);
|
||||||
@@ -117,7 +117,7 @@ public:
|
|||||||
ChatHandler(player->GetSession()).SendSysMessage(
|
ChatHandler(player->GetSession()).SendSysMessage(
|
||||||
"|cff00ff00Playerbots:|r bot initialization at server startup takes about '"
|
"|cff00ff00Playerbots:|r bot initialization at server startup takes about '"
|
||||||
+ roundedTime + "' minutes.");
|
+ roundedTime + "' minutes.");
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -209,16 +209,30 @@ public:
|
|||||||
|
|
||||||
void OnPlayerGiveXP(Player* player, uint32& amount, Unit* /*victim*/, uint8 /*xpSource*/) override
|
void OnPlayerGiveXP(Player* player, uint32& amount, Unit* /*victim*/, uint8 /*xpSource*/) override
|
||||||
{
|
{
|
||||||
if (!player->GetSession()->IsBot())
|
// early return
|
||||||
return;
|
if (sPlayerbotAIConfig->randomBotXPRate == 1.0 || !player)
|
||||||
|
|
||||||
if (!sRandomPlayerbotMgr->IsRandomBot(player))
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (sPlayerbotAIConfig->randomBotXPRate != 1.0)
|
// no XP multiplier, when player is no bot.
|
||||||
|
if (!player->GetSession()->IsBot() || !sRandomPlayerbotMgr->IsRandomBot(player))
|
||||||
|
return;
|
||||||
|
|
||||||
|
// no XP multiplier, when bot has group where leader is a real player.
|
||||||
|
if (Group* group = player->GetGroup())
|
||||||
{
|
{
|
||||||
amount = static_cast<uint32>(std::round(static_cast<float>(amount) * sPlayerbotAIConfig->randomBotXPRate));
|
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));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -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)
|
||||||
|
continue;
|
||||||
|
|
||||||
if (proto->ItemLevel < 60)
|
if (proto->Flags & ITEM_FLAG_UNIQUE_EQUIPPABLE)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (proto->Flags & ITEM_FLAG_UNIQUE_EQUIPPABLE)
|
|
||||||
{
|
|
||||||
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,14 +1020,16 @@ 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
|
||||||
PlayerInfo const* info = sObjectMgr->GetPlayerInfo(bot->getRace(), bot->getClass());
|
if (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;
|
||||||
if (!bot->HasSkill(skillId))
|
if (!bot->HasSkill(skillId))
|
||||||
continue;
|
continue;
|
||||||
bot->SetSkill(skillId, 0, 0, 0);
|
bot->SetSkill(skillId, 0, 0, 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user