Compare commits

...

3 Commits

Author SHA1 Message Date
kadeshar
85c7009fe1
Codestyle fix (#1797)
Warning:
Dont change this PR as draft to make it testable


DONT REVIEW UNTIL Codestyle C++ workflow dont pass
2025-11-05 21:10:17 +01:00
Keleborn
ce51191e8f
Fix. Leave group actions (#1774)
Fix for issue #1768 where the bot master was not getting reset. 
I also cleaned up leave group action to focus up function scope.
I moved the resets from #612 to the actual leaving function.

Disclosure: LLMs were NOT used in authoring this PR.

Test cases to consider for testers.
1. Master disbands group with random bots. Bots should go about their
business.
2. If you can dual box, create a raid where two real player both invite
random bots. One player leaves group, their bots should also leave.
(edge case, if a random bot that is supposed to leave the group becomes
leader they may disband the whole group.
2025-11-05 15:38:14 +01:00
Crow
d02d61e690
Implement Magtheridon strategy (#1721)
I'm marking this as a draft for now because I haven't done a detailed
review of the code, but I'm posting it now in case anybody wants to give
it a try.

Here's what the strategy (should) do.

### **Channeler Phase**

While you can probably AoE down all five Hellfire Channelers, that's
more dicey with IP nerfs and it's no fun, so the strategy takes what
would have still been considered an aggressive approach back in the day
by (1) assigning the Main Tank to the first Channeler, (2) having
Hunters misdirect two more Channelers to the MT, and (3) one Off Tank
picking up each of the fourth and fifth Channelers and dragging them out
of Shadow Volley Range from the main group. Sometimes the pull gets a
little wonky and one of the OTs might end up with one of the Channelers
that was intended for the MT, but it should work out in the end.

DPS will move through Channelers from Square -> Star -> Circle ->
Diamond -> Triangle. Once Square, Star, and Circle are down, the MT will
go sit by Magtheridon and wait for him to become active instead of
helping with the last two Channelers. I could have made the MT help with
the fourth Channeler too, but it's not needed, and positioning to pick
up Magtheridon after the third Channeler is a failsafe for low DPS
groups that aren't able to get four down before Magtheridon breaks free.

The top priority for Warlocks is to banish/fear the Burning Abyssals,
and they will continue to do so even after Magtheridon becomes active
(you are not supposed to kill the Abyssals; they have a gazillion HP and
automatically despawn after a minute). Their next priority is to put
Curse of Tongues on the Channelers.

### **Magtheridon Positioning**

The MT will pick up Magtheridon and pull him (moving backwards because
Magtheridon kind of hits like a bus) to a position up against the far
wall. Ranged DPS will spread out from a point roughly in the center of
the room, and Healers will spread out from a point that is a little
closer to Magtheridon. I have not built in aoe avoidance (except for
cube clickers, see below) because the general avoid aoe strategy seems
to work fine for this fight.

### **Clicking Manticron Cubes**

Now, the fun part. Bots will be assigned to clicking cubes by standard
group selection order (reverse join order), but assignment is done via
two passes. The first pass will look to select five ranged DPS bots that
are _not_ Warlocks. This is because Warlocks may still be needed to keep
Abyssals banished/feared and because Warlocks of all three specs put out
by far the most damage of all ranged DPS at level 70 in pre-raid/T4
gear. If there are not five non-Warlock ranged DPS bots available, then
the logic goes to the second pass, which can pick any bot that is not a
Tank.

Cube clicking works on a timer:

1. 48 seconds after Magtheridon breaks free, assigned cube clickers move
near their cubes (but a few yards outside of interact distance). During
this time, they should move around still to avoid Debris (by maintaining
distance from the triggering NPC) and Conflagration (by maintaining
distance from the triggering gameobject). Blast Nova is on a 54.35s to
55.4s timer, and I found 48s to always be ample time to get to the
cubes, but YMMV so this is a good thing to test. Going to a cube too
early not only takes away DPS but also risks more hazards appearing
on/around the cube that will then cause problems when the cube needs to
be clicked.
2. Blast Nova is a 2s cast, followed by a 10s channel (if not
interrupted by the cubes). As soon as the cast begins, bots will move
into interaction range and click the cube. Well, there is a randomized
delay between 200ms (about the fastest possible human reaction time to
visual stimuli) and 1500ms. It didn’t happen to me in a few runs, but it
may be possible that the delay causes the raid to eat one tick of Blast
Nova (I’m not sure if the first blast comes as soon as the channel
starts). Again, another good thing to test, but also one tick is not
going to kill anybody, and it’s arguably good to introduce some degree
of imperfection.
3. Once Blast Nova stops channeling (i.e., all five cubes have been
clicked and channeled simultaneously), bots will interrupt their cube
clicking and go back to regularly scheduled activities. Again, I’ve
introduced a randomized delay, this time between 200ms and 3000ms. Note
that bots can easily be perfect at this—if I don’t do the randomized
delay, they click and let go so fast that you can barely even see the
beams appear. It’s so atrocious for immersion that I consider the lack
of any randomization to be totally unacceptable for this strategy.
4. 48s after Blast Nova, bots will go back to their near-cube positions,
rinse and repeat.

If an assigned cube clicker dies, another bot should be immediately
assigned. All bots in the raid track the same timer so the new bot
should step into the prior bot’s shoes. Of course, if Blast Nova is
about to go off and a clicker dies next to a cube, you’re probably
wiping because I didn’t assign backups to stand in place. That’s too
much of a dad guild-level strategy even for me.

And that’s about it. Figuring out the cubes was a tremendous pain in the
ass, but I’ve really enjoyed the learning process.

---------

Co-authored-by: bash <31279994+hermensbas@users.noreply.github.com>
2025-11-05 14:53:16 +01:00
166 changed files with 2131 additions and 722 deletions

View File

@ -14,7 +14,7 @@ jobs:
triage:
runs-on: ubuntu-latest
name: C++
if: github.repository == 'mod-playerbots/mod-playerbots' && !github.event.pull_request.draft
if: github.event.pull_request.draft == false
steps:
- uses: actions/checkout@v4
- name: Setup python

2
code_format.sh Executable file → Normal file
View File

@ -15,4 +15,4 @@ for file in $cpp_files; do
$CLANG_FORMAT_PATH -i $file
done
echo "All .cpp or .h files have been formatted."
echo "All .cpp or .h files have been formatted."

View File

@ -413,10 +413,12 @@ void AiFactory::AddDefaultCombatStrategies(Player* player, PlayerbotAI* const fa
break;
}
if (PlayerbotAI::IsTank(player, true)) {
if (PlayerbotAI::IsTank(player, true))
{
engine->addStrategy("tank face", false);
}
if (PlayerbotAI::IsMelee(player, true) && PlayerbotAI::IsDps(player, true)) {
if (PlayerbotAI::IsMelee(player, true) && PlayerbotAI::IsDps(player, true))
{
engine->addStrategy("behind", false);
}
if (PlayerbotAI::IsHeal(player, true))
@ -706,7 +708,9 @@ void AiFactory::AddDefaultNonCombatStrategies(Player* player, PlayerbotAI* const
// {
// // nonCombatEngine->addStrategy("travel");
// nonCombatEngine->addStrategy("rpg");
// } else {
// }
// else
// {
// nonCombatEngine->addStrategy("move random");
// }

View File

@ -70,7 +70,7 @@ bool BroadcastHelper::BroadcastToChannelWithGlobalChance(PlayerbotAI* ai, std::s
return false;
}
for (const auto& pair : toChannels)
for (auto const& pair : toChannels)
{
uint32 roll = urand(1, 100);
uint32 chance = pair.second;
@ -166,7 +166,7 @@ bool BroadcastHelper::BroadcastToChannelWithGlobalChance(PlayerbotAI* ai, std::s
return false;
}
bool BroadcastHelper::BroadcastLootingItem(PlayerbotAI* ai, Player* bot, const ItemTemplate *proto)
bool BroadcastHelper::BroadcastLootingItem(PlayerbotAI* ai, Player* bot, ItemTemplate const* proto)
{
if (!sPlayerbotAIConfig->enableBroadcasts)
return false;
@ -410,7 +410,6 @@ bool BroadcastHelper::BroadcastQuestUpdateComplete(PlayerbotAI* ai, Player* bot,
placeholders["%my_race"] = ai->GetChatHelper()->FormatRace(bot->getRace());
placeholders["%my_level"] = std::to_string(bot->GetLevel());
return BroadcastToChannelWithGlobalChance(
ai,
BOT_TEXT2("broadcast_quest_update_complete", placeholders),

View File

@ -373,7 +373,7 @@ private:
bool ParseSpecPrefix(const std::string& message, std::string& specPrefix, std::string& rest)
{
std::string msgLower = ToLower(message);
for (const auto& entry : specTabNames)
for (auto const& entry : specTabNames)
{
std::string prefix = "@" + entry.second;
if (msgLower.find(ToLower(prefix)) == 0)
@ -555,7 +555,7 @@ public:
const float radius = 100.0f;
GuidVector npcs = botAI->GetAiObjectContext()->GetValue<GuidVector>("nearest npcs")->Get();
bool match = false;
for (const auto& guid : npcs)
for (auto const& guid : npcs)
{
Creature* c = botAI->GetCreature(guid);
if (!c)

View File

@ -329,9 +329,11 @@ ItemWithRandomProperty ChatHelper::parseItemWithRandomProperty(std::string const
while (currentPos < text.length()) {
size_t nextColon = text.find(':', currentPos);
if (nextColon == std::string::npos) {
if (nextColon == std::string::npos)
{
size_t hTag = text.find("|h", currentPos);
if (hTag != std::string::npos) {
if (hTag != std::string::npos)
{
params.push_back(text.substr(currentPos, hTag - currentPos));
}
break;
@ -341,7 +343,8 @@ ItemWithRandomProperty ChatHelper::parseItemWithRandomProperty(std::string const
currentPos = nextColon + 1;
}
if (params.size() >= 6) {
if (params.size() >= 6)
{
res.randomPropertyId = atoi(params[5].c_str());
}

View File

@ -1067,7 +1067,7 @@ void GuildTaskMgr::SendCompletionMessage(Player* player, std::string const verb)
void GuildTaskMgr::CheckKillTaskInternal(Player* player, Unit* victim)
{
ObjectGuid::LowType owner = player->GetGUID().GetCounter();
if (victim->GetTypeId() != TYPEID_UNIT)
if (victim->IsCreature())
return;
Creature* creature = reinterpret_cast<Creature*>(victim);

View File

@ -355,7 +355,7 @@ void PlayerbotAI::UpdateAI(uint32 elapsed, bool minimal)
}
// Update the bot's group status (moved to helper function)
UpdateAIGroupMembership();
UpdateAIGroupAndMaster();
// Update internal AI
UpdateAIInternal(elapsed, minimal);
@ -363,47 +363,60 @@ void PlayerbotAI::UpdateAI(uint32 elapsed, bool minimal)
}
// Helper function for UpdateAI to check group membership and handle removal if necessary
void PlayerbotAI::UpdateAIGroupMembership()
void PlayerbotAI::UpdateAIGroupAndMaster()
{
if (!bot || !bot->GetGroup())
if (!bot)
return;
Group* group = bot->GetGroup();
// If bot is not in group verify that for is RandomBot before clearing master and resetting.
if (!group)
{
if (master && sRandomPlayerbotMgr->IsRandomBot(bot))
{
SetMaster(nullptr);
Reset(true);
ResetStrategies();
}
return;
}
if (bot->InBattleground() && bot->GetBattleground()->GetBgTypeID() != BATTLEGROUND_AV)
return;
Group* group = bot->GetGroup();
PlayerbotAI* botAI = GET_PLAYERBOT_AI(bot);
if (!botAI)
return;
if (!bot->InBattleground() && !bot->inRandomLfgDungeon() && !group->isLFGGroup())
PlayerbotAI* masterBotAI = nullptr;
if (master)
masterBotAI = GET_PLAYERBOT_AI(master);
if (!master || (masterBotAI && !masterBotAI->IsRealPlayer()))
{
Player* leader = group->GetLeader();
if (leader && leader != bot) // Ensure the leader is valid and not the bot itself
Player* newMaster = FindNewMaster();
if (newMaster)
{
PlayerbotAI* leaderAI = GET_PLAYERBOT_AI(leader);
if (leaderAI && !leaderAI->IsRealPlayer())
master = newMaster;
botAI->SetMaster(newMaster);
botAI->ResetStrategies();
if (!bot->InBattleground())
{
LeaveOrDisbandGroup();
botAI->ChangeStrategy("+follow", BOT_STATE_NON_COMBAT);
if (botAI->GetMaster() == botAI->GetGroupMaster())
botAI->TellMaster("Hello, I follow you!");
else
botAI->TellMaster(!urand(0, 2) ? "Hello!" : "Hi!");
}
else
{
// we're in a battleground, stay with the pack and focus on objective
botAI->ChangeStrategy("-follow", BOT_STATE_NON_COMBAT);
}
}
}
else if (group->isLFGGroup())
{
bool hasRealPlayer = false;
// Iterate over all group members to check if at least one is a real player
for (GroupReference* ref = group->GetFirstMember(); ref; ref = ref->next())
{
Player* member = ref->GetSource();
if (!member)
continue;
PlayerbotAI* memberAI = GET_PLAYERBOT_AI(member);
if (memberAI && !memberAI->IsRealPlayer())
continue;
hasRealPlayer = true;
break;
}
if (!hasRealPlayer)
{
else if (!newMaster && !bot->InBattleground())
LeaveOrDisbandGroup();
}
}
}
@ -792,7 +805,6 @@ void PlayerbotAI::LeaveOrDisbandGroup()
WorldPacket* packet = new WorldPacket(CMSG_GROUP_DISBAND);
bot->GetSession()->QueuePacket(packet);
ResetStrategies();
}
bool PlayerbotAI::IsAllowedCommand(std::string const text)
@ -1301,7 +1313,6 @@ void PlayerbotAI::DoNextAction(bool min)
return;
}
// Change engine if just died
bool isBotAlive = bot->IsAlive();
if (currentEngine != engines[BOT_STATE_DEAD] && !isBotAlive)
@ -1361,92 +1372,6 @@ void PlayerbotAI::DoNextAction(bool min)
Group* group = bot->GetGroup();
PlayerbotAI* masterBotAI = nullptr;
if (master)
masterBotAI = GET_PLAYERBOT_AI(master);
// Test BG master set
if ((!master || (masterBotAI && !masterBotAI->IsRealPlayer())) && group)
{
PlayerbotAI* botAI = GET_PLAYERBOT_AI(bot);
if (!botAI)
{
return;
}
// Ideally we want to have the leader as master.
Player* newMaster = botAI->GetGroupMaster();
Player* playerMaster = nullptr;
// Are there any non-bot players in the group?
if (!newMaster || GET_PLAYERBOT_AI(newMaster))
{
for (GroupReference* gref = group->GetFirstMember(); gref; gref = gref->next())
{
Player* member = gref->GetSource();
if (!member || member == bot || member == newMaster || !member->IsInWorld() ||
!member->IsInSameRaidWith(bot))
continue;
PlayerbotAI* memberBotAI = GET_PLAYERBOT_AI(member);
if (memberBotAI)
{
if (memberBotAI->IsRealPlayer() && !bot->InBattleground())
playerMaster = member;
continue;
}
// Same BG checks (optimize checking conditions here)
if (bot->InBattleground() && bot->GetBattleground() &&
bot->GetBattleground()->GetBgTypeID() == BATTLEGROUND_AV && !GET_PLAYERBOT_AI(member) &&
member->InBattleground() && bot->GetMapId() == member->GetMapId())
{
// Skip if same BG but same subgroup or lower level
if (!group->SameSubGroup(bot, member) || member->GetLevel() < bot->GetLevel())
continue;
// Follow real player only if higher honor points
uint32 honorpts = member->GetHonorPoints();
if (bot->GetHonorPoints() && honorpts < bot->GetHonorPoints())
continue;
playerMaster = member;
continue;
}
if (bot->InBattleground())
continue;
newMaster = member;
break;
}
}
if (!newMaster && playerMaster)
newMaster = playerMaster;
if (newMaster && (!master || master != newMaster) && bot != newMaster)
{
master = newMaster;
botAI->SetMaster(newMaster);
botAI->ResetStrategies();
if (!bot->InBattleground())
{
botAI->ChangeStrategy("+follow", BOT_STATE_NON_COMBAT);
if (botAI->GetMaster() == botAI->GetGroupMaster())
botAI->TellMaster("Hello, I follow you!");
else
botAI->TellMaster(!urand(0, 2) ? "Hello!" : "Hi!");
}
else
{
// we're in a battleground, stay with the pack and focus on objective
botAI->ChangeStrategy("-follow", BOT_STATE_NON_COMBAT);
}
}
}
if (master && master->IsInWorld())
{
@ -1517,23 +1442,25 @@ void PlayerbotAI::ApplyInstanceStrategies(uint32 mapId, bool tellMaster)
switch (mapId)
{
case 249:
strategyName = "onyxia"; // Onyxia's Lair
strategyName = "onyxia"; // Onyxia's Lair
break;
case 409:
strategyName = "mc"; // Molten Core
strategyName = "mc"; // Molten Core
break;
case 469:
strategyName = "bwl"; // Blackwing Lair
strategyName = "bwl"; // Blackwing Lair
break;
case 509:
strategyName = "aq20"; // Ruins of Ahn'Qiraj
strategyName = "aq20"; // Ruins of Ahn'Qiraj
break;
case 532:
strategyName = "karazhan"; // Karazhan
break;
case 533:
strategyName = "naxx"; // Naxxramas
strategyName = "naxx"; // Naxxramas
break;
case 544:
strategyName = "magtheridon"; // Magtheridon's Lair
case 565:
strategyName = "gruulslair"; // Gruul's Lair
break;
@ -3170,8 +3097,10 @@ bool PlayerbotAI::CanCastSpell(uint32 spellid, Unit* target, bool checkHasSpell,
SpellCastResult result = spell->CheckCast(true);
delete spell;
// if (!sPlayerbotAIConfig->logInGroupOnly || (bot->GetGroup() && HasRealPlayerMaster())) {
// if (result != SPELL_FAILED_NOT_READY && result != SPELL_CAST_OK) {
// if (!sPlayerbotAIConfig->logInGroupOnly || (bot->GetGroup() && HasRealPlayerMaster()))
// {
// if (result != SPELL_FAILED_NOT_READY && result != SPELL_CAST_OK)
// {
// LOG_DEBUG("playerbots", "CanCastSpell - target name: {}, spellid: {}, bot name: {}, result: {}",
// target->GetName(), spellid, bot->GetName(), result);
// }
@ -3194,7 +3123,6 @@ bool PlayerbotAI::CanCastSpell(uint32 spellid, Unit* target, bool checkHasSpell,
default:
if (!sPlayerbotAIConfig->logInGroupOnly || (bot->GetGroup() && HasRealPlayerMaster()))
{
// if (result != SPELL_FAILED_NOT_READY && result != SPELL_CAST_OK) {
LOG_DEBUG("playerbots",
"CanCastSpell Check Failed. - target name: {}, spellid: {}, bot name: {}, result: {}",
target->GetName(), spellid, bot->GetName(), result);
@ -3377,7 +3305,8 @@ bool PlayerbotAI::CastSpell(uint32 spellId, Unit* target, Item* itemTarget)
if (bot->IsFlying() || bot->HasUnitState(UNIT_STATE_IN_FLIGHT))
{
// if (!sPlayerbotAIConfig->logInGroupOnly || (bot->GetGroup() && HasRealPlayerMaster())) {
// if (!sPlayerbotAIConfig->logInGroupOnly || (bot->GetGroup() && HasRealPlayerMaster()))
// {
// LOG_DEBUG("playerbots", "Spell cast is flying - target name: {}, spellid: {}, bot name: {}}",
// target->GetName(), spellId, bot->GetName());
// }
@ -3422,7 +3351,8 @@ bool PlayerbotAI::CastSpell(uint32 spellId, Unit* target, Item* itemTarget)
{
bot->GetTradeData()->SetSpell(spellId);
delete spell;
// if (!sPlayerbotAIConfig->logInGroupOnly || (bot->GetGroup() && HasRealPlayerMaster())) {
// if (!sPlayerbotAIConfig->logInGroupOnly || (bot->GetGroup() && HasRealPlayerMaster()))
// {
// LOG_DEBUG("playerbots", "Spell cast no item - target name: {}, spellid: {}, bot name: {}",
// target->GetName(), spellId, bot->GetName());
// }
@ -3491,7 +3421,8 @@ bool PlayerbotAI::CastSpell(uint32 spellId, Unit* target, Item* itemTarget)
// spell->m_targets.SetUnitTarget(target);
// SpellCastResult spellSuccess = spell->CheckCast(true);
// if (!sPlayerbotAIConfig->logInGroupOnly || (bot->GetGroup() && HasRealPlayerMaster())) {
// if (!sPlayerbotAIConfig->logInGroupOnly || (bot->GetGroup() && HasRealPlayerMaster()))
// {
// LOG_DEBUG("playerbots", "Spell cast result - target name: {}, spellid: {}, bot name: {}, result: {}",
// target->GetName(), spellId, bot->GetName(), spellSuccess);
// }
@ -3502,7 +3433,8 @@ bool PlayerbotAI::CastSpell(uint32 spellId, Unit* target, Item* itemTarget)
if (result != SPELL_CAST_OK)
{
// if (!sPlayerbotAIConfig->logInGroupOnly || (bot->GetGroup() && HasRealPlayerMaster())) {
// if (!sPlayerbotAIConfig->logInGroupOnly || (bot->GetGroup() && HasRealPlayerMaster()))
// {
// LOG_DEBUG("playerbots", "Spell cast failed. - target name: {}, spellid: {}, bot name: {}, result: {}",
// target->GetName(), spellId, bot->GetName(), result);
// }
@ -3569,7 +3501,8 @@ bool PlayerbotAI::CastSpell(uint32 spellId, Unit* target, Item* itemTarget)
// {
// spell->cancel();
// delete spell;
// if (!sPlayerbotAIConfig->logInGroupOnly || (bot->GetGroup() && HasRealPlayerMaster())) {
// if (!sPlayerbotAIConfig->logInGroupOnly || (bot->GetGroup() && HasRealPlayerMaster()))
// {
// LOG_DEBUG("playerbots", "Spell cast loot - target name: {}, spellid: {}, bot name: {}",
// target->GetName(), spellId, bot->GetName());
// }
@ -4133,6 +4066,50 @@ bool IsAlliance(uint8 race)
race == RACE_DRAENEI;
}
Player* PlayerbotAI::FindNewMaster()
{
// Ideally we want to have the leader as master.
Group* group = bot->GetGroup();
// Only allow real players as masters unless in battleground.
if (!group)
return nullptr;
Player* groupLeader = GetGroupMaster();
PlayerbotAI* leaderBotAI = GET_PLAYERBOT_AI(groupLeader);
if (!leaderBotAI || leaderBotAI->IsRealPlayer())
return groupLeader;
// Find the real player in group
for (GroupReference* gref = group->GetFirstMember(); gref; gref = gref->next())
{
Player* member = gref->GetSource();
if (!member || member == bot || !member->IsInWorld() ||
!member->IsInSameRaidWith(bot))
continue;
PlayerbotAI* memberBotAI = GET_PLAYERBOT_AI(member);
if ((!memberBotAI || memberBotAI->IsRealPlayer()) && !bot->InBattleground())
return member;
if (bot->InBattleground() && bot->GetBattleground() &&
bot->GetBattleground()->GetBgTypeID() == BATTLEGROUND_AV && !GET_PLAYERBOT_AI(member) &&
member->InBattleground() && bot->GetMapId() == member->GetMapId())
{
// Skip if same BG but same subgroup or lower level
if (!group->SameSubGroup(bot, member) || member->GetLevel() < bot->GetLevel())
continue;
// Follow real player only if higher honor points
uint32 honorpts = member->GetHonorPoints();
if (bot->GetHonorPoints() && honorpts < bot->GetHonorPoints())
continue;
return member;
}
}
return nullptr;
}
bool PlayerbotAI::HasRealPlayerMaster()
{
if (master)
@ -4756,7 +4733,6 @@ uint32 PlayerbotAI::GetEquipGearScore(Player* player)
sum += gearScore[i];
}
if (count)
{
uint32 res = uint32(sum / count);
@ -5293,7 +5269,7 @@ Item* PlayerbotAI::FindOpenableItem() const
return FindItemInInventory(
[this](ItemTemplate const* itemTemplate) -> bool
{
return (itemTemplate->Flags & ITEM_FLAG_HAS_LOOT) &&
return itemTemplate->HasFlag(ITEM_FLAG_HAS_LOOT) &&
(itemTemplate->LockID == 0 || !this->bot->GetItemByEntry(itemTemplate->ItemId)->IsLocked());
});
}
@ -5444,7 +5420,7 @@ Item* PlayerbotAI::FindOilFor(Item* weapon) const
if (prioritizedOils)
{
for (const auto& id : *prioritizedOils)
for (auto const& id : *prioritizedOils)
{
oil = FindConsumable(id);
if (oil)

View File

@ -529,6 +529,7 @@ public:
Player* GetBot() { return bot; }
Player* GetMaster() { return master; }
Player* FindNewMaster();
// Checks if the bot is really a player. Players always have themselves as master.
bool IsRealPlayer() { return master ? (master == bot) : false; }
@ -611,7 +612,7 @@ private:
static void _fillGearScoreData(Player* player, Item* item, std::vector<uint32>* gearScore, uint32& twoHandScore,
bool mixed = false);
bool IsTellAllowed(PlayerbotSecurityLevel securityLevel = PLAYERBOT_SECURITY_ALLOW_ALL);
void UpdateAIGroupMembership();
void UpdateAIGroupAndMaster();
Item* FindItemInInventory(std::function<bool(ItemTemplate const*)> checkItem) const;
void HandleCommands();
void HandleCommand(uint32 type, const std::string& text, Player& fromPlayer, const uint32 lang = LANG_UNIVERSAL);

View File

@ -1736,7 +1736,8 @@ PlayerbotAI* PlayerbotsMgr::GetPlayerbotAI(Player* player)
{
return nullptr;
}
// if (player->GetSession()->isLogingOut() || player->IsDuringRemoveFromWorld()) {
// if (player->GetSession()->isLogingOut() || player->IsDuringRemoveFromWorld())
// {
// return nullptr;
// }
auto itr = _playerbotsAIMap.find(player->GetGUID());

View File

@ -982,7 +982,7 @@ void RandomItemMgr::BuildItemInfoCache()
continue;
}
if (proto->Flags & ITEM_FLAG_DEPRECATED)
if (proto->HasFlag(ITEM_FLAG_DEPRECATED))
{
itemForTest.insert(proto->ItemId);
continue;
@ -1072,10 +1072,10 @@ void RandomItemMgr::BuildItemInfoCache()
// cacheInfo.team = TEAM_NEUTRAL;
// // check faction
// if (proto->Flags2 & ITEM_FLAG2_FACTION_HORDE)
// if (proto->HasFlag2(ITEM_FLAG2_FACTION_HORDE))
// cacheInfo.team = TEAM_HORDE;
// if (proto->Flags2 & ITEM_FLAG2_FACTION_ALLIANCE)
// if (proto->HasFlag2(ITEM_FLAG2_FACTION_ALLIANCE))
// cacheInfo.team = TEAM_ALLIANCE;
// if (cacheInfo.team == TEAM_NEUTRAL && proto->AllowableRace > 1 && proto->AllowableRace < 8388607)
@ -1099,7 +1099,7 @@ void RandomItemMgr::BuildItemInfoCache()
// // check item source
// if (proto->Flags & ITEM_FLAG_NO_DISENCHANT)
// if (proto->HasFlag(ITEM_FLAG_NO_DISENCHANT))
// {
// cacheInfo.source = ITEM_SOURCE_PVP;
// LOG_DEBUG("playerbots", "Item: {}, source: PvP Reward", proto->ItemId);
@ -1367,7 +1367,7 @@ uint32 RandomItemMgr::CalculateStatWeight(uint8 playerclass, uint8 spec, ItemTem
}
// check item spells
for (const auto& spellData : proto->Spells)
for (auto const& spellData : proto->Spells)
{
// no spell
if (!spellData.SpellId)
@ -2374,7 +2374,6 @@ void RandomItemMgr::BuildPotionCache()
if (proto->Duration & 0x80000000)
continue;
if (proto->AllowableClass != -1)
continue;

View File

@ -633,7 +633,7 @@ void RandomPlayerbotMgr::AssignAccountTypes()
uint32 existingRndBotAccounts = 0;
uint32 existingAddClassAccounts = 0;
for (const auto& [accountId, accountType] : currentAssignments)
for (auto const& [accountId, accountType] : currentAssignments)
{
if (accountType == 1) existingRndBotAccounts++;
else if (accountType == 2) existingAddClassAccounts++;
@ -688,7 +688,7 @@ void RandomPlayerbotMgr::AssignAccountTypes()
}
// Populate filtered account lists with ALL accounts of each type
for (const auto& [accountId, accountType] : currentAssignments)
for (auto const& [accountId, accountType] : currentAssignments)
{
if (accountType == 1) rndBotTypeAccounts.push_back(accountId);
else if (accountType == 2) addClassTypeAccounts.push_back(accountId);
@ -798,7 +798,7 @@ uint32 RandomPlayerbotMgr::AddRandomBots()
std::vector<CharacterInfo> allianceChars;
std::vector<CharacterInfo> hordeChars;
for (const auto& charInfo : allCharacters)
for (auto const& charInfo : allCharacters)
{
if (IsAlliance(charInfo.rRace))
allianceChars.push_back(charInfo);
@ -832,7 +832,7 @@ uint32 RandomPlayerbotMgr::AddRandomBots()
};
// PHASE 1: Log-in Alliance bots up to allowedAllianceCount
for (const auto& charInfo : allianceChars)
for (auto const& charInfo : allianceChars)
{
if (!allowedAllianceCount)
break;
@ -845,7 +845,7 @@ uint32 RandomPlayerbotMgr::AddRandomBots()
}
// PHASE 2: Log-in Horde bots up to maxAllowedBotCount
for (const auto& charInfo : hordeChars)
for (auto const& charInfo : hordeChars)
{
if (!maxAllowedBotCount)
break;
@ -855,7 +855,7 @@ uint32 RandomPlayerbotMgr::AddRandomBots()
}
// PHASE 3: If maxAllowedBotCount wasn't reached, log-in more Alliance bots
for (const auto& charInfo : allianceChars)
for (auto const& charInfo : allianceChars)
{
if (!maxAllowedBotCount)
break;
@ -1248,7 +1248,7 @@ void RandomPlayerbotMgr::CheckBgQueue()
void RandomPlayerbotMgr::LogBattlegroundInfo()
{
for (const auto& queueTypePair : BattlegroundData)
for (auto const& queueTypePair : BattlegroundData)
{
uint8 queueType = queueTypePair.first;
@ -1256,7 +1256,7 @@ void RandomPlayerbotMgr::LogBattlegroundInfo()
if (uint8 type = BattlegroundMgr::BGArenaType(queueTypeId))
{
for (const auto& bracketIdPair : queueTypePair.second)
for (auto const& bracketIdPair : queueTypePair.second)
{
auto& bgInfo = bracketIdPair.second;
if (bgInfo.minLevel == 0)
@ -1306,7 +1306,7 @@ void RandomPlayerbotMgr::LogBattlegroundInfo()
break;
}
for (const auto& bracketIdPair : queueTypePair.second)
for (auto const& bracketIdPair : queueTypePair.second)
{
auto& bgInfo = bracketIdPair.second;
if (bgInfo.minLevel == 0)
@ -1576,7 +1576,7 @@ bool RandomPlayerbotMgr::ProcessBot(Player* bot)
{
idleBot = true;
}
if (idleBot)
{
// randomize
@ -1704,7 +1704,6 @@ void RandomPlayerbotMgr::RandomTeleport(Player* bot, std::vector<WorldLocation>&
return;
}
PerformanceMonitorOperation* pmo = sPerformanceMonitor->start(PERF_MON_RNDBOT, "RandomTeleportByLocations");
std::shuffle(std::begin(tlocs), std::end(tlocs), RandomEngine::Instance());
@ -2256,7 +2255,7 @@ void RandomPlayerbotMgr::RandomTeleportForLevel(Player* bot)
// Pick a weighted city randomly, then a random banker in that city
// then teleport to that banker
CityId selectedCity = weightedCities[urand(0, weightedCities.size() - 1)];
const auto& bankers = cityToBankers.at(selectedCity);
auto const& bankers = cityToBankers.at(selectedCity);
uint32 selectedBankerEntry = bankers[urand(0, bankers.size() - 1)];
auto locIt = bankerEntryToLocation.find(selectedBankerEntry);
if (locIt != bankerEntryToLocation.end())

View File

@ -56,7 +56,7 @@ Unit* ServerFacade::GetChaseTarget(Unit* target)
MovementGenerator* movementGen = target->GetMotionMaster()->top();
if (movementGen && movementGen->GetMovementGeneratorType() == CHASE_MOTION_TYPE)
{
if (target->GetTypeId() == TYPEID_PLAYER)
if (target->IsPlayer())
{
return static_cast<ChaseMovementGenerator<Player> const*>(movementGen)->GetTarget();
}

View File

@ -480,7 +480,7 @@ std::string const WorldPosition::getAreaName(bool fullName, bool zoneName)
std::set<Transport*> WorldPosition::getTransports(uint32 entry)
{
/*
if(!entry)
if (!entry)
return getMap()->m_transports;
else
{
@ -488,7 +488,7 @@ std::set<Transport*> WorldPosition::getTransports(uint32 entry)
std::set<Transport*> transports;
/*
for (auto transport : getMap()->m_transports)
if(transport->GetEntry() == entry)
if (transport->GetEntry() == entry)
transports.insert(transport);
return transports;
@ -1272,7 +1272,7 @@ std::string const RpgTravelDestination::getTitle()
{
std::ostringstream out;
if(entry > 0)
if (entry > 0)
out << "rpg npc ";
out << " " << ChatHelper::FormatWorldEntry(entry);
@ -2076,7 +2076,6 @@ void TravelMgr::LoadQuestTravelTable()
continue;
}
if (r.role == 0)
{
container->questGivers.push_back(loc);
@ -2591,7 +2590,7 @@ void TravelMgr::LoadQuestTravelTable()
//if (data->displayId == 3015)
// pos.setZ(pos.getZ() + 6.0f);
//else if(data->displayId == 3031)
//else if (data->displayId == 3031)
// pos.setZ(pos.getZ() - 17.0f);
if (prevNode)

View File

@ -180,7 +180,7 @@ uint32 TravelNodePath::getPrice()
if (!taxiPath)
return 0;
return taxiPath->price;
}
@ -470,7 +470,6 @@ bool TravelNode::cropUselessLinks()
for (auto& firstLink : getLinks())
{
TravelNode* firstNode = firstLink.first;
float firstLength = firstLink.second.getDistance();
for (auto& secondLink : getLinks())
@ -1302,7 +1301,7 @@ TravelNodeRoute TravelNodeMap::getRoute(TravelNode* start, TravelNode* goal, Pla
return TravelNodeRoute(path);
}
for (const auto& link : *currentNode->dataNode->getLinks()) // for each successor n' of n
for (auto const& link : *currentNode->dataNode->getLinks()) // for each successor n' of n
{
TravelNode* linkNode = link.first;
float linkCost = link.second->getCost(bot, currentNode->currentGold);
@ -1351,7 +1350,7 @@ TravelNodeRoute TravelNodeMap::getRoute(WorldPosition startPos, WorldPosition en
std::vector<WorldPosition> newStartPath;
std::vector<TravelNode*> startNodes = m_nodes, endNodes = m_nodes;
if(!startNodes.size() || !endNodes.size())
if (!startNodes.size() || !endNodes.size())
return TravelNodeRoute();
// Partial sort to get the closest 5 nodes at the begin of the array.
@ -1902,7 +1901,7 @@ void TravelNodeMap::generateTransportNodes()
// if (data->displayId == 3015)
// pos.setZ(pos.getZ() + 6.0f);
// else if(data->displayId == 3031)
// else if (data->displayId == 3031)
// pos.setZ(pos.getZ() - 17.0f);
if (prevNode)

View File

@ -180,7 +180,7 @@ void PlayerbotFactory::Init()
continue;
}
if (proto->Flags & ITEM_FLAG_UNIQUE_EQUIPPABLE)
if (proto->HasFlag(ITEM_FLAG_UNIQUE_EQUIPPABLE))
{
continue;
}
@ -1391,7 +1391,7 @@ bool PlayerbotFactory::CanEquipArmor(ItemTemplate const* proto)
// for (uint8 j = 0; j < MAX_ITEM_PROTO_STATS; ++j)
// {
// // for ItemStatValue != 0
// if(!proto->ItemStat[j].ItemStatValue)
// if (!proto->ItemStat[j].ItemStatValue)
// continue;
// AddItemStats(proto->ItemStat[j].ItemStatType, sp, ap, tank);
@ -1600,7 +1600,8 @@ void Shuffle(std::vector<uint32>& items)
// bool noItem = false;
// uint32 quality = urand(ITEM_QUALITY_UNCOMMON, ITEM_QUALITY_EPIC);
// uint32 attempts = 10;
// if (urand(0, 100) < 100 * sPlayerbotAIConfig->randomGearLoweringChance && quality > ITEM_QUALITY_NORMAL) {
// if (urand(0, 100) < 100 * sPlayerbotAIConfig->randomGearLoweringChance && quality > ITEM_QUALITY_NORMAL)
// {
// quality--;
// }
// // current item;
@ -1705,7 +1706,8 @@ void PlayerbotFactory::InitEquipment(bool incremental, bool second_chance)
if (incremental && !sPlayerbotAIConfig->incrementalGearInit)
return;
if (level < 5) {
if (level < 5)
{
// original items
if (CharStartOutfitEntry const* oEntry = GetCharStartOutfitEntry(bot->getRace(), bot->getClass(), bot->getGender()))
{
@ -1734,7 +1736,8 @@ void PlayerbotFactory::InitEquipment(bool incremental, bool second_chance)
continue;
}
if (bot->HasItemCount(itemId, count)) {
if (bot->HasItemCount(itemId, count))
{
continue;
}
@ -2771,7 +2774,8 @@ void PlayerbotFactory::InitTalents(uint32 specNo)
void PlayerbotFactory::InitTalentsByTemplate(uint32 specTab)
{
// if (sPlayerbotAIConfig->parsedSpecLinkOrder[bot->getClass()][specNo][80].size() == 0) {
// if (sPlayerbotAIConfig->parsedSpecLinkOrder[bot->getClass()][specNo][80].size() == 0)
// {
// return;
// }
uint32 cls = bot->getClass();

View File

@ -97,7 +97,7 @@ float StatsWeightCalculator::CalculateItem(uint32 itemId, int32 randomPropertyId
// Use player level as effective item level for heirlooms - Quality EPIC
// Else - Blend with item quality and level for normal items
if (proto->Quality == ITEM_QUALITY_HEIRLOOM)
weight_ *= PlayerbotFactory::CalcMixedGearScore(lvl, ITEM_QUALITY_EPIC);
weight_ *= PlayerbotFactory::CalcMixedGearScore(lvl, ITEM_QUALITY_EPIC);
else
weight_ *= PlayerbotFactory::CalcMixedGearScore(proto->ItemLevel, proto->Quality);

View File

@ -39,6 +39,8 @@
#include "raids/blackwinglair/RaidBwlTriggerContext.h"
#include "raids/karazhan/RaidKarazhanActionContext.h"
#include "raids/karazhan/RaidKarazhanTriggerContext.h"
#include "raids/magtheridon/RaidMagtheridonActionContext.h"
#include "raids/magtheridon/RaidMagtheridonTriggerContext.h"
#include "raids/gruulslair/RaidGruulsLairActionContext.h"
#include "raids/gruulslair/RaidGruulsLairTriggerContext.h"
#include "raids/naxxramas/RaidNaxxActionContext.h"
@ -113,6 +115,7 @@ void AiObjectContext::BuildSharedActionContexts(SharedNamedObjectContextList<Act
actionContexts.Add(new RaidMcActionContext());
actionContexts.Add(new RaidBwlActionContext());
actionContexts.Add(new RaidKarazhanActionContext());
actionContexts.Add(new RaidMagtheridonActionContext());
actionContexts.Add(new RaidGruulsLairActionContext());
actionContexts.Add(new RaidNaxxActionContext());
actionContexts.Add(new RaidOsActionContext());
@ -147,6 +150,7 @@ void AiObjectContext::BuildSharedTriggerContexts(SharedNamedObjectContextList<Tr
triggerContexts.Add(new RaidMcTriggerContext());
triggerContexts.Add(new RaidBwlTriggerContext());
triggerContexts.Add(new RaidKarazhanTriggerContext());
triggerContexts.Add(new RaidMagtheridonTriggerContext());
triggerContexts.Add(new RaidGruulsLairTriggerContext());
triggerContexts.Add(new RaidNaxxTriggerContext());
triggerContexts.Add(new RaidOsTriggerContext());

View File

@ -77,7 +77,8 @@ Engine::~Engine(void)
// for (std::map<std::string, Strategy*>::iterator i = strategies.begin(); i != strategies.end(); i++)
// {
// Strategy* strategy = i->second;
// if (strategy) {
// if (strategy)
// {
// delete strategy;
// }
// }
@ -402,7 +403,6 @@ void Engine::addStrategiesNoInit(std::string first, ...)
va_end(vl);
}
bool Engine::removeStrategy(std::string const name, bool init)
{
std::map<std::string, Strategy*>::iterator i = strategies.find(name);

View File

@ -148,7 +148,7 @@ public:
void Add(NamedObjectContext<T>* context)
{
contexts.push_back(context);
for (const auto& iter : context->creators)
for (auto const& iter : context->creators)
creators[iter.first] = iter.second;
}
};
@ -294,7 +294,7 @@ public:
void Add(NamedObjectFactory<T>* context)
{
factories.push_back(context);
for (const auto& iter : context->creators)
for (auto const& iter : context->creators)
creators[iter.first] = iter.second;
}

View File

@ -161,17 +161,21 @@ bool AttackAction::Attack(Unit* target, bool with_pet /*true*/)
bot->Attack(target, shouldMelee);
/* prevent pet dead immediately in group */
// if (bot->GetMap()->IsDungeon() && bot->GetGroup() && !target->IsInCombat()) {
// if (bot->GetMap()->IsDungeon() && bot->GetGroup() && !target->IsInCombat())
// {
// with_pet = false;
// }
// if (Pet* pet = bot->GetPet())
// {
// if (with_pet) {
// if (with_pet)
// {
// pet->SetReactState(REACT_DEFENSIVE);
// pet->SetTarget(target->GetGUID());
// pet->GetCharmInfo()->SetIsCommandAttack(true);
// pet->AI()->AttackStart(target);
// } else {
// }
// else
// {
// pet->SetReactState(REACT_PASSIVE);
// pet->GetCharmInfo()->SetIsCommandFollow(true);
// pet->GetCharmInfo()->IsReturning();

View File

@ -176,4 +176,3 @@ void AutoMaintenanceOnLevelupAction::AutoUpgradeEquip()
factory.InitEquipment(true);
}
}

View File

@ -17,7 +17,7 @@ bool BankAction::Execute(Event event)
for (GuidVector::iterator i = npcs.begin(); i != npcs.end(); i++)
{
Unit* npc = botAI->GetUnit(*i);
if (!npc || !npc->HasFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_BANKER))
if (!npc || !npc->HasNpcFlag(UNIT_NPC_FLAG_BANKER))
continue;
return ExecuteBank(text, npc);

View File

@ -1894,13 +1894,13 @@ bool BGTactics::selectObjective(bool reset)
bool isDefender = role < defendersProhab;
bool isAdvanced = !isDefender && role > 8;
const auto& attackObjectives =
auto const& attackObjectives =
(team == TEAM_HORDE) ? AV_AttackObjectives_Horde : AV_AttackObjectives_Alliance;
const auto& defendObjectives =
auto const& defendObjectives =
(team == TEAM_HORDE) ? AV_DefendObjectives_Horde : AV_DefendObjectives_Alliance;
uint32 destroyedNodes = 0;
for (const auto& [nodeId, _] : defendObjectives)
for (auto const& [nodeId, _] : defendObjectives)
if (av->GetAVNodeInfo(nodeId).State == POINT_DESTROYED)
destroyedNodes++;
@ -2000,7 +2000,7 @@ bool BGTactics::selectObjective(bool reset)
std::vector<GameObject*> contestedObjectives;
std::vector<GameObject*> availableObjectives;
for (const auto& [nodeId, goId] : defendObjectives)
for (auto const& [nodeId, goId] : defendObjectives)
{
const BG_AV_NodeInfo& node = av->GetAVNodeInfo(nodeId);
if (node.State == POINT_DESTROYED)
@ -2026,7 +2026,7 @@ bool BGTactics::selectObjective(bool reset)
if (!BgObjective)
{
uint32 towersDown = 0;
for (const auto& [nodeId, _] : attackObjectives)
for (auto const& [nodeId, _] : attackObjectives)
if (av->GetAVNodeInfo(nodeId).State == POINT_DESTROYED)
towersDown++;
@ -2053,7 +2053,7 @@ bool BGTactics::selectObjective(bool reset)
{
std::vector<GameObject*> candidates;
for (const auto& [nodeId, goId] : attackObjectives)
for (auto const& [nodeId, goId] : attackObjectives)
{
const BG_AV_NodeInfo& node = av->GetAVNodeInfo(nodeId);
GameObject* go = bg->GetBGObject(goId);
@ -2105,13 +2105,13 @@ bool BGTactics::selectObjective(bool reset)
Position objPos = BgObjective->GetPosition();
Optional<uint8> linkedNodeId;
for (const auto& [nodeId, goId] : attackObjectives)
for (auto const& [nodeId, goId] : attackObjectives)
if (bg->GetBGObject(goId) == BgObjective)
linkedNodeId = nodeId;
if (!linkedNodeId)
{
for (const auto& [nodeId, goId] : defendObjectives)
for (auto const& [nodeId, goId] : defendObjectives)
if (bg->GetBGObject(goId) == BgObjective)
linkedNodeId = nodeId;
}
@ -2543,7 +2543,7 @@ bool BGTactics::selectObjective(bool reset)
float bestDist = FLT_MAX;
uint32 bestTrigger = 0;
for (const auto& [nodeId, _, areaTrigger] : EY_AttackObjectives)
for (auto const& [nodeId, _, areaTrigger] : EY_AttackObjectives)
{
if (!IsOwned(nodeId))
continue;
@ -2610,7 +2610,7 @@ bool BGTactics::selectObjective(bool reset)
// --- PRIORITY 2: Nearby unowned contested node ---
if (!foundObjective)
{
for (const auto& [nodeId, _, __] : EY_AttackObjectives)
for (auto const& [nodeId, _, __] : EY_AttackObjectives)
{
if (IsOwned(nodeId))
continue;
@ -2711,7 +2711,7 @@ bool BGTactics::selectObjective(bool reset)
if (!foundObjective && strategy == EY_STRATEGY_FLAG_FOCUS)
{
bool ownsAny = false;
for (const auto& [nodeId, _, __] : EY_AttackObjectives)
for (auto const& [nodeId, _, __] : EY_AttackObjectives)
{
if (IsOwned(nodeId))
{
@ -2739,7 +2739,7 @@ bool BGTactics::selectObjective(bool reset)
float bestDist = FLT_MAX;
Optional<uint32> bestNode;
for (const auto& [nodeId, _, __] : EY_AttackObjectives)
for (auto const& [nodeId, _, __] : EY_AttackObjectives)
{
if (IsOwned(nodeId))
continue;
@ -2974,7 +2974,7 @@ bool BGTactics::selectObjective(bool reset)
uint32 len = end(IC_AttackObjectives) - begin(IC_AttackObjectives);
for (uint32 i = 0; i < len; i++)
{
const auto& objective =
auto const& objective =
IC_AttackObjectives[(i + role) %
len]; // use role to determine which objective checked first
if (isleOfConquestBG->GetICNodePoint(objective.first).nodeState != NODE_STATE_CONTROLLED_H)
@ -3126,7 +3126,7 @@ bool BGTactics::selectObjective(bool reset)
uint32 len = end(IC_AttackObjectives) - begin(IC_AttackObjectives);
for (uint32 i = 0; i < len; i++)
{
const auto& objective =
auto const& objective =
IC_AttackObjectives[(i + role) %
len]; // use role to determine which objective checked first
if (isleOfConquestBG->GetICNodePoint(objective.first).nodeState != NODE_STATE_CONTROLLED_H)

View File

@ -370,7 +370,7 @@ bool CheckMountStateAction::TryPreferredMount(Player* master) const
bool CheckMountStateAction::TryRandomMountFiltered(const std::map<int32, std::vector<uint32>>& spells, int32 masterSpeed) const
{
for (const auto& pair : spells)
for (auto const& pair : spells)
{
int32 currentSpeed = pair.first;
@ -378,7 +378,7 @@ bool CheckMountStateAction::TryRandomMountFiltered(const std::map<int32, std::ve
continue;
// Pick a random mount from the candidate group.
const auto& ids = pair.second;
auto const& ids = pair.second;
if (!ids.empty())
{
// Required here as otherwise bots won't mount in BG's due to them constant moving

View File

@ -120,7 +120,6 @@ void ChooseTravelTargetAction::getNewTarget(TravelTarget* newTarget, TravelTarge
}
}
//Continue current target. 90% chance
if (!foundTarget && urand(1, 100) > 10)
{
@ -673,7 +672,7 @@ bool ChooseTravelTargetAction::SetExploreTarget(TravelTarget* target)
//271 south shore
//35 booty bay
//380 The Barrens The Crossroads
if(((ExploreTravelDestination * )activeTarget)->getAreaId() == 380)
if (((ExploreTravelDestination * )activeTarget)->getAreaId() == 380)
{
activePoints.push_back(activeTarget->getPoints(true)[0]);
}

View File

@ -58,7 +58,6 @@ bool DropQuestAction::Execute(Event event)
return true;
}
bool CleanQuestLogAction::Execute(Event event)
{
Player* requester = event.getOwner() ? event.getOwner() : GetMaster();
@ -165,7 +164,6 @@ bool CleanQuestLogAction::Execute(Event event)
return true;
}
void CleanQuestLogAction::DropQuestType(uint8& numQuest, uint8 wantNum, bool isGreen, bool hasProgress, bool isComplete)
{
std::vector<uint8> slots;

View File

@ -837,8 +837,8 @@ uint32 TalkAction::GetRandomEmote(Unit* unit, bool textEmote)
types.push_back(TEXT_EMOTE_TALKEX);
types.push_back(TEXT_EMOTE_TALKQ);
if (unit && (unit->HasFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_TRAINER) ||
unit->HasFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_QUESTGIVER)))
if (unit && (unit->HasNpcFlag(UNIT_NPC_FLAG_TRAINER) ||
unit->HasNpcFlag(UNIT_NPC_FLAG_QUESTGIVER)))
{
types.push_back(TEXT_EMOTE_SALUTE);
}
@ -864,8 +864,8 @@ uint32 TalkAction::GetRandomEmote(Unit* unit, bool textEmote)
types.push_back(EMOTE_ONESHOT_EXCLAMATION);
types.push_back(EMOTE_ONESHOT_QUESTION);
if (unit && (unit->HasFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_TRAINER) ||
unit->HasFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_QUESTGIVER)))
if (unit && (unit->HasNpcFlag(UNIT_NPC_FLAG_TRAINER) ||
unit->HasNpcFlag(UNIT_NPC_FLAG_QUESTGIVER)))
{
types.push_back(EMOTE_ONESHOT_SALUTE);
}

View File

@ -328,7 +328,6 @@ void EquipAction::EquipItem(Item* item)
botAI->TellMaster(out);
}
bool EquipUpgradesAction::Execute(Event event)
{
if (!sPlayerbotAIConfig->autoEquipUpgradeLoot && !sRandomPlayerbotMgr->IsRandomBot(bot))
@ -357,9 +356,12 @@ bool EquipUpgradesAction::Execute(Event event)
int32 randomProperty = item->GetItemRandomPropertyId();
uint32 itemId = item->GetTemplate()->ItemId;
std::string itemUsageParam;
if (randomProperty != 0) {
if (randomProperty != 0)
{
itemUsageParam = std::to_string(itemId) + "," + std::to_string(randomProperty);
} else {
}
else
{
itemUsageParam = std::to_string(itemId);
}
ItemUsage usage = AI_VALUE2(ItemUsage, "item usage", itemUsageParam);
@ -388,9 +390,12 @@ bool EquipUpgradeAction::Execute(Event event)
int32 randomProperty = item->GetItemRandomPropertyId();
uint32 itemId = item->GetTemplate()->ItemId;
std::string itemUsageParam;
if (randomProperty != 0) {
if (randomProperty != 0)
{
itemUsageParam = std::to_string(itemId) + "," + std::to_string(randomProperty);
} else {
}
else
{
itemUsageParam = std::to_string(itemId);
}
ItemUsage usage = AI_VALUE2(ItemUsage, "item usage", itemUsageParam);

View File

@ -61,7 +61,7 @@ namespace ai::buff
return false;
if (SpellInfo const* info = sSpellMgr->GetSpellInfo(spellId))
{
{
for (int i = 0; i < MAX_SPELL_REAGENTS; ++i)
{
if (info->Reagent[i] > 0)

View File

@ -29,7 +29,6 @@ namespace ai::buff
// Returns false if the spellId is invalid.
bool HasRequiredReagents(Player* bot, uint32 spellId);
// Applies the "switch to group buff" policy if: the bot is in a group of size x+,
// the group variant is known/useful, and reagents are available. Otherwise, returns baseName.
// If announceOnMissing == true and reagents are missing, calls the 'announce' callback

View File

@ -190,8 +190,8 @@ CastEnchantItemAction::CastEnchantItemAction(PlayerbotAI* botAI, std::string con
bool CastEnchantItemAction::isPossible()
{
// if (!CastSpellAction::isPossible()) {
// if (!CastSpellAction::isPossible())
// {
// botAI->TellMasterNoFacing("Impossible: " + spell);
// return false;
// }
@ -364,7 +364,8 @@ bool UseTrinketAction::UseTrinket(Item* item)
for (int i = 0; i < MAX_SPELL_EFFECTS; i++)
{
const SpellEffectInfo& effectInfo = spellInfo->Effects[i];
if (effectInfo.Effect == SPELL_EFFECT_APPLY_AURA) {
if (effectInfo.Effect == SPELL_EFFECT_APPLY_AURA)
{
applyAura = true;
break;
}

View File

@ -193,7 +193,7 @@ bool GuildManageNearbyAction::Execute(Event event)
if (guild->GetMemberSize() > 1000)
return false;
if ( (guild->GetRankRights(botMember->GetRankId()) & GR_RIGHT_INVITE) == 0)
if ((guild->GetRankRights(botMember->GetRankId()) & GR_RIGHT_INVITE) == 0)
continue;
if (player->GetGuildIdInvited())

View File

@ -11,8 +11,11 @@
bool LeaveGroupAction::Execute(Event event)
{
Player* master = event.getOwner();
return Leave(master);
Player* player = event.getOwner();
if (player == botAI->GetMaster())
return Leave();
return false;
}
bool PartyCommandAction::Execute(Event event)
@ -26,13 +29,21 @@ bool PartyCommandAction::Execute(Event event)
if (operation != PARTY_OP_LEAVE)
return false;
// Only leave if master has left the party, and randombot cannot set new master.
Player* master = GetMaster();
if (master && member == master->GetName())
return Leave(bot);
botAI->Reset();
{
if (sRandomPlayerbotMgr->IsRandomBot(bot))
{
Player* newMaster = botAI->FindNewMaster();
if (newMaster || bot->InBattleground())
{
botAI->SetMaster(newMaster);
return false;
}
}
return Leave();
}
return false;
}
@ -42,17 +53,17 @@ bool UninviteAction::Execute(Event event)
if (p.GetOpcode() == CMSG_GROUP_UNINVITE)
{
p.rpos(0);
std::string membername;
p >> membername;
std::string memberName;
p >> memberName;
// player not found
if (!normalizePlayerName(membername))
if (!normalizePlayerName(memberName))
{
return false;
}
if (bot->GetName() == membername)
return Leave(bot);
if (bot->GetName() == memberName)
return Leave();
}
if (p.GetOpcode() == CMSG_GROUP_UNINVITE_GUID)
@ -62,50 +73,29 @@ bool UninviteAction::Execute(Event event)
p >> guid;
if (bot->GetGUID() == guid)
return Leave(bot);
return Leave();
}
botAI->Reset();
return false;
}
bool LeaveGroupAction::Leave(Player* player)
bool LeaveGroupAction::Leave()
{
if (player &&
!botAI &&
!botAI->GetSecurity()->CheckLevelFor(PLAYERBOT_SECURITY_INVITE, false, player))
if (!botAI)
return false;
bool aiMaster = GET_PLAYERBOT_AI(botAI->GetMaster()) != nullptr;
botAI->TellMaster("Goodbye!", PLAYERBOT_SECURITY_TALK);
bool randomBot = sRandomPlayerbotMgr->IsRandomBot(bot);
bool shouldStay = randomBot && bot->GetGroup() && player == bot;
if (!shouldStay)
{
botAI->LeaveOrDisbandGroup();
}
if (randomBot)
{
GET_PLAYERBOT_AI(bot)->SetMaster(nullptr);
}
if (!aiMaster)
botAI->ResetStrategies(!randomBot);
botAI->Reset();
Player* master = botAI -> GetMaster();
if (master)
botAI->TellMaster("Goodbye!", PLAYERBOT_SECURITY_TALK);
botAI->LeaveOrDisbandGroup();
return true;
}
bool LeaveFarAwayAction::Execute(Event event)
{
// allow bot to leave party when they want
return Leave(botAI->GetGroupMaster());
return Leave();
}
bool LeaveFarAwayAction::isUseful()
@ -165,7 +155,5 @@ bool LeaveFarAwayAction::isUseful()
return true;
}
botAI->Reset();
return false;
}

View File

@ -18,7 +18,7 @@ public:
bool Execute(Event event) override;
virtual bool Leave(Player* player);
virtual bool Leave();
};
class PartyCommandAction : public LeaveGroupAction

View File

@ -16,7 +16,6 @@
using namespace lfg;
bool LfgJoinAction::Execute(Event event) { return JoinLFG(); }
uint32 LfgJoinAction::GetRoles()
@ -113,7 +112,7 @@ bool LfgJoinAction::JoinLFG()
dungeon->TypeID != LFG_TYPE_HEROIC && dungeon->TypeID != LFG_TYPE_RAID))
continue;
const auto& botLevel = bot->GetLevel();
auto const& botLevel = bot->GetLevel();
/*LFG_TYPE_RANDOM on classic is 15-58 so bot over level 25 will never queue*/
if (dungeon->MinLevel && (botLevel < dungeon->MinLevel || botLevel > dungeon->MaxLevel) ||
@ -180,7 +179,6 @@ bool LfgRoleCheckAction::Execute(Event event)
// if (currentRoles == newRoles)
// return false;
WorldPacket* packet = new WorldPacket(CMSG_LFG_SET_ROLES);
*packet << (uint8)newRoles;
bot->GetSession()->QueuePacket(packet);
@ -267,7 +265,6 @@ bool LfgAcceptAction::Execute(Event event)
return false;
}
bool LfgLeaveAction::Execute(Event event)
{
// Don't leave if lfg strategy enabled

View File

@ -41,9 +41,12 @@ bool LootRollAction::Execute(Event event)
continue;
std::string itemUsageParam;
if (randomProperty != 0) {
if (randomProperty != 0)
{
itemUsageParam = std::to_string(itemId) + "," + std::to_string(randomProperty);
} else {
}
else
{
itemUsageParam = std::to_string(itemId);
}
ItemUsage usage = AI_VALUE2(ItemUsage, "item usage", itemUsageParam);
@ -120,7 +123,6 @@ bool LootRollAction::Execute(Event event)
return false;
}
RollVote LootRollAction::CalculateRollVote(ItemTemplate const* proto)
{
std::ostringstream out;

View File

@ -248,7 +248,7 @@ bool MovementAction::MoveTo(uint32 mapId, float x, float y, float z, bool idle,
// bot->CastStop();
// botAI->InterruptSpell();
// }
MotionMaster& mm = *bot->GetMotionMaster();
// No ground pathfinding if the bot/master are flying => allow true 3D (Z) movement
auto isFlying = [](Unit* u){ return u && (u->HasUnitMovementFlag(MOVEMENTFLAG_FLYING) || u->IsInFlight()); };
@ -530,7 +530,8 @@ bool MovementAction::MoveTo(uint32 mapId, float x, float y, float z, bool idle,
// {
// AI_VALUE(LastMovement&, "last area trigger").lastAreaTrigger = entry;
// }
// else {
// else
// {
// LOG_DEBUG("playerbots", "!entry");
// return bot->TeleportTo(movePosition.getMapId(), movePosition.getX(), movePosition.getY(),
// movePosition.getZ(), movePosition.getO(), 0);
@ -876,7 +877,8 @@ bool MovementAction::ReachCombatTo(Unit* target, float distance)
deltaAngle -= 2.0f * M_PI; // -PI..PI
// if target is moving forward and moving far away, predict the position
bool behind = fabs(deltaAngle) > M_PI_2;
if (target->HasUnitMovementFlag(MOVEMENTFLAG_FORWARD) && behind) {
if (target->HasUnitMovementFlag(MOVEMENTFLAG_FORWARD) && behind)
{
float predictDis = std::min(3.0f, target->GetObjectSize() * 2);
tx += cos(target->GetOrientation()) * predictDis;
ty += sin(target->GetOrientation()) * predictDis;
@ -1009,7 +1011,8 @@ bool MovementAction::IsMovingAllowed()
return false;
}
// if (bot->HasUnitMovementFlag(MOVEMENTFLAG_FALLING)) {
// if (bot->HasUnitMovementFlag(MOVEMENTFLAG_FALLING))
// {
// return false;
// }
return bot->GetMotionMaster()->GetCurrentMovementGeneratorType() != FLIGHT_MOTION_TYPE;
@ -1094,9 +1097,12 @@ void MovementAction::UpdateMovementState()
wasMovementRestricted = isCurrentlyRestricted;
// Temporary speed increase in group
// if (botAI->HasRealPlayerMaster()) {
// if (botAI->HasRealPlayerMaster())
// {
// bot->SetSpeedRate(MOVE_RUN, 1.1f);
// } else {
// }
// else
// {
// bot->SetSpeedRate(MOVE_RUN, 1.0f);
// }
// check if target is not reachable (from Vmangos)
@ -1105,7 +1111,7 @@ void MovementAction::UpdateMovementState()
// {
// if (Unit* pTarget = sServerFacade->GetChaseTarget(bot))
// {
// if (!bot->IsWithinMeleeRange(pTarget) && pTarget->GetTypeId() == TYPEID_UNIT)
// if (!bot->IsWithinMeleeRange(pTarget) && pTarget->IsCreature())
// {
// float angle = bot->GetAngle(pTarget);
// float distance = 5.0f;
@ -1721,7 +1727,8 @@ bool MovementAction::MoveInside(uint32 mapId, float x, float y, float z, float d
// float MovementAction::SearchBestGroundZForPath(float x, float y, float z, bool generatePath, float range, bool
// normal_only, float step)
// {
// if (!generatePath) {
// if (!generatePath)
// {
// return z;
// }
// float min_length = 100000.0f;
@ -1732,10 +1739,12 @@ bool MovementAction::MoveInside(uint32 mapId, float x, float y, float z, float d
// modified_z = bot->GetMapWaterOrGroundLevel(x, y, z + delta);
// PathGenerator gen(bot);
// gen.CalculatePath(x, y, modified_z);
// if (gen.GetPathType() == PATHFIND_NORMAL && gen.getPathLength() < min_length) {
// if (gen.GetPathType() == PATHFIND_NORMAL && gen.getPathLength() < min_length)
// {
// min_length = gen.getPathLength();
// current_z = modified_z;
// if (abs(current_z - z) < 0.5f) {
// if (abs(current_z - z) < 0.5f)
// {
// return current_z;
// }
// }
@ -1744,10 +1753,12 @@ bool MovementAction::MoveInside(uint32 mapId, float x, float y, float z, float d
// modified_z = bot->GetMapWaterOrGroundLevel(x, y, z + delta);
// PathGenerator gen(bot);
// gen.CalculatePath(x, y, modified_z);
// if (gen.GetPathType() == PATHFIND_NORMAL && gen.getPathLength() < min_length) {
// if (gen.GetPathType() == PATHFIND_NORMAL && gen.getPathLength() < min_length)
// {
// min_length = gen.getPathLength();
// current_z = modified_z;
// if (abs(current_z - z) < 0.5f) {
// if (abs(current_z - z) < 0.5f)
// {
// return current_z;
// }
// }
@ -1756,18 +1767,22 @@ bool MovementAction::MoveInside(uint32 mapId, float x, float y, float z, float d
// modified_z = bot->GetMapWaterOrGroundLevel(x, y, z + delta);
// PathGenerator gen(bot);
// gen.CalculatePath(x, y, modified_z);
// if (gen.GetPathType() == PATHFIND_NORMAL && gen.getPathLength() < min_length) {
// if (gen.GetPathType() == PATHFIND_NORMAL && gen.getPathLength() < min_length)
// {
// min_length = gen.getPathLength();
// current_z = modified_z;
// if (abs(current_z - z) < 0.5f) {
// if (abs(current_z - z) < 0.5f)
// {
// return current_z;
// }
// }
// }
// if (current_z == INVALID_HEIGHT && normal_only) {
// if (current_z == INVALID_HEIGHT && normal_only)
// {
// return INVALID_HEIGHT;
// }
// if (current_z == INVALID_HEIGHT && !normal_only) {
// if (current_z == INVALID_HEIGHT && !normal_only)
// {
// return z;
// }
// return current_z;
@ -2818,7 +2833,7 @@ bool MoveAwayFromCreatureAction::Execute(Event event)
// Find all creatures with the specified Id
std::vector<Unit*> creatures;
for (const auto& guid : targets)
for (auto const& guid : targets)
{
Unit* unit = botAI->GetUnit(guid);
if (unit && (alive && unit->IsAlive()) && unit->GetEntry() == creatureId)

View File

@ -119,7 +119,6 @@ protected:
int moveInterval;
};
class CombatFormationMoveAction : public MovementAction
{
public:

View File

@ -47,16 +47,16 @@ bool DrinkAction::Execute(Event event)
return UseItemAction::Execute(event);
}
bool DrinkAction::isUseful()
{
return UseItemAction::isUseful() &&
bool DrinkAction::isUseful()
{
return UseItemAction::isUseful() &&
AI_VALUE2(bool, "has mana", "self target") &&
AI_VALUE2(uint8, "mana", "self target") < 100;
}
bool DrinkAction::isPossible()
{
return !bot->IsInCombat() &&
return !bot->IsInCombat() &&
!bot->IsMounted() &&
!botAI->HasAnyAuraOf(GetTarget(), "dire bear form", "bear form", "cat form", "travel form",
"aquatic form","flight form", "swift flight form", nullptr) &&
@ -102,15 +102,15 @@ bool EatAction::Execute(Event event)
return UseItemAction::Execute(event);
}
bool EatAction::isUseful()
{
return UseItemAction::isUseful() &&
bool EatAction::isUseful()
{
return UseItemAction::isUseful() &&
AI_VALUE2(uint8, "health", "self target") < 100;
}
bool EatAction::isPossible()
{
return !bot->IsInCombat() &&
return !bot->IsInCombat() &&
!bot->IsMounted() &&
!botAI->HasAnyAuraOf(GetTarget(), "dire bear form", "bear form", "cat form", "travel form",
"aquatic form","flight form", "swift flight form", nullptr) &&

View File

@ -48,7 +48,7 @@ bool QuestAction::Execute(Event event)
// Check the nearest NPCs
GuidVector npcs = AI_VALUE(GuidVector, "nearest npcs");
for (const auto& npc : npcs)
for (auto const& npc : npcs)
{
Unit* unit = botAI->GetUnit(npc);
if (unit && bot->GetDistance(unit) <= INTERACTION_DISTANCE)
@ -59,7 +59,7 @@ bool QuestAction::Execute(Event event)
// Checks the nearest game objects
GuidVector gos = AI_VALUE(GuidVector, "nearest game objects");
for (const auto& go : gos)
for (auto const& go : gos)
{
GameObject* gameobj = botAI->GetGameObject(go);
if (gameobj && bot->GetDistance(gameobj) <= INTERACTION_DISTANCE)
@ -359,7 +359,7 @@ bool QuestUpdateAddItemAction::Execute(Event event)
uint32 availableItemsCount = botAI->GetInventoryItemsCountWithId(itemId);
placeholders["%quest_obj_available"] = std::to_string(availableItemsCount);
for (const auto& pair : botAI->GetCurrentQuestsRequiringItemId(itemId))
for (auto const& pair : botAI->GetCurrentQuestsRequiringItemId(itemId))
{
placeholders["%quest_link"] = chat->FormatQuest(pair.first);
uint32 requiredItemsCount = pair.second;

View File

@ -49,7 +49,7 @@ class QuestUpdateAddItemAction : public Action
{
public:
QuestUpdateAddItemAction(PlayerbotAI* ai) : Action(ai, "quest update add item") {}
bool Execute(Event event) override;;
bool Execute(Event event) override;
};
class QuestUpdateFailedAction : public Action
@ -70,7 +70,7 @@ class QuestItemPushResultAction : public Action
{
public:
QuestItemPushResultAction(PlayerbotAI* ai) : Action(ai, "quest item push result") {}
bool Execute(Event event) override;;
bool Execute(Event event) override;
};
#endif

View File

@ -128,7 +128,7 @@ bool AutoReleaseSpiritAction::HandleBattlegroundSpiritHealer()
GuidVector npcs = NearestNpcsValue(botAI, bgRange);
Unit* spiritHealer = nullptr;
for (const auto& guid : npcs)
for (auto const& guid : npcs)
{
Unit* unit = botAI->GetUnit(guid);
if (unit && unit->IsFriendlyTo(bot) && unit->IsSpiritService())

View File

@ -12,24 +12,7 @@
#include "GridNotifiersImpl.h"
#include "Playerbots.h"
#include "ServerFacade.h"
class AnyGameObjectInObjectRangeCheck
{
public:
AnyGameObjectInObjectRangeCheck(WorldObject const* obj, float range) : i_obj(obj), i_range(range) {}
WorldObject const& GetFocusObject() const { return *i_obj; }
bool operator()(GameObject* go)
{
if (go && i_obj->IsWithinDistInMap(go, i_range) && go->isSpawned() && go->GetGOInfo())
return true;
return false;
}
private:
WorldObject const* i_obj;
float i_range;
};
#include "NearestGameObjects.h"
bool RevealGatheringItemAction::Execute(Event event)
{

View File

@ -314,7 +314,7 @@ bool SpiritHealerAction::Execute(Event event)
for (GuidVector::iterator i = npcs.begin(); i != npcs.end(); i++)
{
Unit* unit = botAI->GetUnit(*i);
if (unit && unit->HasFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_SPIRITHEALER))
if (unit && unit->HasNpcFlag(UNIT_NPC_FLAG_SPIRITHEALER))
{
LOG_DEBUG("playerbots", "Bot {} {}:{} <{}> revives at spirit healer", bot->GetGUID().ToString().c_str(),
bot->GetTeamId() == TEAM_ALLIANCE ? "A" : "H", bot->GetLevel(), bot->GetName());

View File

@ -50,7 +50,6 @@ bool RpgAction::SetNextRpgAction()
std::vector<uint32> relevances;
std::vector<TriggerNode*> triggerNodes;
for (auto& strategy : botAI->GetAiObjectContext()->GetSupportedStrategies())
{
if (strategy.find("rpg") == std::string::npos)

View File

@ -195,7 +195,7 @@ void ChatReplyAction::ChatReplyDo(Player* bot, uint32& type, uint32& guid1, uint
}
ChatChannelSource chatChannelSource = GET_PLAYERBOT_AI(bot)->GetChatChannelSource(bot, type, chanName);
if ( (msg.starts_with("LFG") || msg.starts_with("LFM")) && HandleLFGQuestsReply(bot, chatChannelSource, msg, name))
if ((msg.starts_with("LFG") || msg.starts_with("LFM")) && HandleLFGQuestsReply(bot, chatChannelSource, msg, name))
{
return;
}

View File

@ -24,7 +24,7 @@ bool SetHomeAction::Execute(Event event)
}
if (Unit* unit = botAI->GetUnit(selection))
if (unit->HasFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_INNKEEPER))
if (unit->HasNpcFlag(UNIT_NPC_FLAG_INNKEEPER))
{
if (isRpgAction)
{

View File

@ -120,7 +120,8 @@ void SuggestWhatToDoAction::grindMaterials()
for (std::map<std::string, double>::iterator i = categories.begin(); i != categories.end(); ++i)
{
if (urand(0, 10) < 3) {
if (urand(0, 10) < 3)
{
std::string name = i->first;
double multiplier = i->second;

View File

@ -81,7 +81,7 @@ bool TameAction::Execute(Event event)
std::ostringstream oss;
oss << "Available pet families: ";
size_t count = 0;
for (const auto& name : normalFamilies)
for (auto const& name : normalFamilies)
{
if (count++ != 0)
oss << ", ";
@ -93,7 +93,7 @@ bool TameAction::Execute(Event event)
oss << " | ";
oss << "Exotic: ";
count = 0;
for (const auto& name : exoticFamilies)
for (auto const& name : exoticFamilies)
{
if (count++ != 0)
oss << ", ";

View File

@ -18,4 +18,3 @@ public:
};
#endif

View File

@ -15,7 +15,7 @@ bool TradeAction::Execute(Event event)
std::string const text = event.getParam();
// If text starts with any excluded prefix, don't process it further.
for (const auto& prefix : sPlayerbotAIConfig->tradeActionExcludedPrefixes)
for (auto const& prefix : sPlayerbotAIConfig->tradeActionExcludedPrefixes)
{
if (text.find(prefix) == 0)
return false;

View File

@ -172,7 +172,7 @@ bool MaintenanceAction::Execute(Event event)
PlayerbotFactory factory(bot, bot->GetLevel());
if (!botAI->IsAlt())
{
{
factory.InitAttunementQuests();
factory.InitBags(false);
factory.InitAmmo();
@ -194,7 +194,7 @@ bool MaintenanceAction::Execute(Event event)
if (bot->GetLevel() >= sPlayerbotAIConfig->minEnchantingBotLevel)
factory.ApplyEnchantAndGemsNew();
}
else
else
{
if (sPlayerbotAIConfig->altMaintenanceAttunementQs)
factory.InitAttunementQuests();

View File

@ -9,6 +9,7 @@
#include "Event.h"
#include "GridNotifiers.h"
#include "GridNotifiersImpl.h"
#include "NearestGameObjects.h"
#include "PlayerbotAIConfig.h"
#include "Playerbots.h"
#include "PositionValue.h"
@ -54,24 +55,6 @@ bool UseMeetingStoneAction::Execute(Event event)
return Teleport(master, bot);
}
class AnyGameObjectInObjectRangeCheck
{
public:
AnyGameObjectInObjectRangeCheck(WorldObject const* obj, float range) : i_obj(obj), i_range(range) {}
WorldObject const& GetFocusObject() const { return *i_obj; }
bool operator()(GameObject* go)
{
if (go && i_obj->IsWithinDistInMap(go, i_range) && go->isSpawned() && go->GetGOInfo())
return true;
return false;
}
private:
WorldObject const* i_obj;
float i_range;
};
bool SummonAction::Execute(Event event)
{
Player* master = GetMaster();
@ -134,7 +117,7 @@ bool SummonAction::SummonUsingNpcs(Player* summoner, Player* player)
for (Unit* unit : targets)
{
if (unit && unit->HasFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_INNKEEPER))
if (unit && unit->HasNpcFlag(UNIT_NPC_FLAG_INNKEEPER))
{
if (!player->HasItemCount(6948, 1, false))
{
@ -242,7 +225,7 @@ bool SummonAction::Teleport(Player* summoner, Player* player)
}
}
if(summoner != player)
if (summoner != player)
botAI->TellError("Not enough place to summon");
return false;
}

View File

@ -97,4 +97,3 @@ std::vector<uint32> WorldBuffAction::NeedWorldBuffs(Unit* unit)
return retVec;
}

View File

@ -15,7 +15,6 @@ bool XpGainAction::Execute(Event event)
{
context->GetValue<uint32>("death count")->Set(0);
WorldPacket p(event.getPacket()); // (8+4+1+4+8)
ObjectGuid guid;
// uint32 xpgain;

View File

@ -43,7 +43,7 @@ bool CastRaiseDeadAction::Execute(Event event)
return false;
}
uint32 spellId = AI_VALUE2(uint32, "spell id", spell);
// const SpellInfo *spellInfo = sSpellMgr->GetSpellInfo(spellId);
// SpellInfo const *spellInfo = sSpellMgr->GetSpellInfo(spellId);
bot->AddSpellCooldown(spellId, 0, 3 * 60 * 1000);
return true;
}
}

View File

@ -311,7 +311,6 @@ public:
CastEnrageAction(PlayerbotAI* ai) : CastBuffSpellAction(ai, "enrage") {}
};
class CastRejuvenationOnNotFullAction : public HealPartyMemberAction
{
public:

View File

@ -35,8 +35,6 @@ Bronjahm, Devourer of Souls
*/
class DungeonStrategyContext : public NamedObjectContext<Strategy>
{
public:
@ -84,8 +82,6 @@ class DungeonStrategyContext : public NamedObjectContext<Strategy>
static Strategy* wotlk_toc(PlayerbotAI* botAI) { return new WotlkDungeonToCStrategy(botAI); }
// NYI from here down
static Strategy* wotlk_hor(PlayerbotAI* botAI) { return new WotlkDungeonUKStrategy(botAI); }
};
#endif

View File

@ -18,5 +18,4 @@
#include "trialofthechampion/TrialOfTheChampionTriggerContext.h"
// #include "hallsofreflection/HallsOfReflectionTriggerContext.h"
#endif

View File

@ -2,7 +2,6 @@
#include "AzjolNerubActions.h"
#include "AzjolNerubStrategy.h"
bool AttackWebWrapAction::isUseful() { return !botAI->IsHeal(bot); }
bool AttackWebWrapAction::Execute(Event event)
{

View File

@ -1,7 +1,6 @@
#include "AzjolNerubStrategy.h"
#include "AzjolNerubMultipliers.h"
void WotlkDungeonANStrategy::InitTriggers(std::vector<TriggerNode*> &triggers)
{
// Krik'thir the Gatewatcher

View File

@ -5,7 +5,6 @@
#include "AiObjectContext.h"
#include "Strategy.h"
class WotlkDungeonANStrategy : public Strategy
{
public:

View File

@ -3,7 +3,6 @@
#include "AiObject.h"
#include "AiObjectContext.h"
bool KrikthirWebWrapTrigger::IsActive()
{
if (!botAI->IsDps(bot)) { return false; }

View File

@ -2,7 +2,6 @@
#include "CullingOfStratholmeActions.h"
#include "CullingOfStratholmeStrategy.h"
bool ExplodeGhoulSpreadAction::Execute(Event event)
{
Unit* boss = AI_VALUE2(Unit*, "find target", "salramm the fleshcrafter");
@ -32,7 +31,7 @@ bool EpochStackAction::isUseful()
// Hunter bots will try and melee in between ranged attacks, or just melee entirely at 5 as they are in range.
// 7.5 or 8.0 solves this for this boss.
// Unfortunately at this range the boss will charge. So I guess just don't stack as a hunter..
// if(bot->getClass() == CLASS_HUNTER)
// if (bot->getClass() == CLASS_HUNTER)
// {
// return AI_VALUE2(float, "distance", "current target") > 7.5f;
// }
@ -45,7 +44,7 @@ bool EpochStackAction::Execute(Event event)
if (!boss) { return false; }
float maxMovement = 10.0f;
// if(bot->getClass() == CLASS_HUNTER)
// if (bot->getClass() == CLASS_HUNTER)
// {
// return Move(bot->GetAngle(boss), fmin(bot->GetExactDist2d(boss) - 6.5f, maxMovement));
// }

View File

@ -1,7 +1,6 @@
#include "CullingOfStratholmeStrategy.h"
#include "CullingOfStratholmeMultipliers.h"
void WotlkDungeonCoSStrategy::InitTriggers(std::vector<TriggerNode*> &triggers)
{
// Meathook

View File

@ -5,7 +5,6 @@
#include "AiObjectContext.h"
#include "Strategy.h"
class WotlkDungeonCoSStrategy : public Strategy
{
public:

View File

@ -3,7 +3,6 @@
#include "AiObject.h"
#include "AiObjectContext.h"
bool ExplodeGhoulTrigger::IsActive()
{
Unit* boss = AI_VALUE2(Unit*, "find target", "salramm the fleshcrafter");

View File

@ -2,7 +2,6 @@
#include "DrakTharonKeepActions.h"
#include "DrakTharonKeepStrategy.h"
bool CorpseExplodeSpreadAction::Execute(Event event)
{
Unit* boss = AI_VALUE2(Unit*, "find target", "trollgore");

View File

@ -1,7 +1,6 @@
#include "DrakTharonKeepStrategy.h"
#include "DrakTharonKeepMultipliers.h"
void WotlkDungeonDTKStrategy::InitTriggers(std::vector<TriggerNode*> &triggers)
{
// Trollgore

View File

@ -5,7 +5,6 @@
#include "AiObjectContext.h"
#include "Strategy.h"
class WotlkDungeonDTKStrategy : public Strategy
{
public:

View File

@ -3,7 +3,6 @@
#include "AiObject.h"
#include "AiObjectContext.h"
bool CorpseExplodeTrigger::IsActive()
{
Unit* boss = AI_VALUE2(Unit*, "find target", "trollgore");

View File

@ -17,7 +17,6 @@ bool MoveFromBronjahmAction::Execute(Event event)
return false;
}
bool AttackCorruptedSoulFragmentAction::Execute(Event event)
{
Unit* currentTarget = AI_VALUE(Unit*, "current target");
@ -52,7 +51,6 @@ bool AttackCorruptedSoulFragmentAction::Execute(Event event)
return false;
}
bool BronjahmGroupPositionAction::Execute(Event event)
{
Unit* boss = AI_VALUE2(Unit*, "find target", "bronjahm");
@ -165,5 +163,3 @@ bool DevourerOfSoulsAction::Execute(Event event)
return false;
}

View File

@ -6,7 +6,6 @@
#include "ForgeOfSoulsTriggers.h"
#include "ForgeOfSoulsActions.h"
float BronjahmMultiplier::GetValue(Action* action) {
Unit* boss = AI_VALUE2(Unit *, "find target", "bronjahm");
if (!boss)

View File

@ -20,5 +20,4 @@ public:
float GetValue(Action* action) override;
};
#endif

View File

@ -1,7 +1,6 @@
#include "GundrakStrategy.h"
#include "GundrakMultipliers.h"
void WotlkDungeonGDStrategy::InitTriggers(std::vector<TriggerNode*> &triggers)
{
// Moorabi

View File

@ -5,7 +5,6 @@
#include "AiObjectContext.h"
#include "Strategy.h"
class WotlkDungeonGDStrategy : public Strategy
{
public:

View File

@ -126,7 +126,7 @@ bool LokenStackAction::isUseful()
// Minimum hunter range is 5, but values too close to this seem to cause issues..
// Hunter bots will try and melee in between ranged attacks, or just melee entirely at 5 as they are in range.
// 6.5 or 7.0 solves this for this boss.
if(bot->getClass() == CLASS_HUNTER)
if (bot->getClass() == CLASS_HUNTER)
{
return AI_VALUE2(float, "distance", "current target") > 6.5f;
}
@ -141,7 +141,7 @@ bool LokenStackAction::Execute(Event event)
float maxMovement = 10.0f;
if (!boss->HasUnitState(UNIT_STATE_CASTING))
{
if(bot->getClass() == CLASS_HUNTER)
if (bot->getClass() == CLASS_HUNTER)
{
return Move(bot->GetAngle(boss), fmin(bot->GetExactDist2d(boss) - 6.5f, maxMovement));
}
@ -152,7 +152,6 @@ bool LokenStackAction::Execute(Event event)
return false;
}
bool AvoidLightningNovaAction::Execute(Event event)
{
Unit* boss = AI_VALUE2(Unit*, "find target", "loken");

View File

@ -123,4 +123,3 @@ float LokenMultiplier::GetValue(Action* action)
return 1.0f; // Default multiplier value for other cases.
}

View File

@ -1,7 +1,6 @@
#include "HallsOfLightningStrategy.h"
#include "HallsOfLightningMultipliers.h"
void WotlkDungeonHoLStrategy::InitTriggers(std::vector<TriggerNode*> &triggers)
{
// General Bjarngrim

View File

@ -5,7 +5,6 @@
#include "AiObjectContext.h"
#include "Strategy.h"
class WotlkDungeonHoLStrategy : public Strategy
{
public:

View File

@ -1,7 +1,6 @@
#include "HallsOfStoneStrategy.h"
#include "HallsOfStoneMultipliers.h"
void WotlkDungeonHoSStrategy::InitTriggers(std::vector<TriggerNode*> &triggers)
{
// Maiden of Grief

View File

@ -5,7 +5,6 @@
#include "AiObjectContext.h"
#include "Strategy.h"
class WotlkDungeonHoSStrategy : public Strategy
{
public:

View File

@ -94,4 +94,3 @@ float OrmorokMultiplier::GetValue(Action* action)
}
return 1.0f;
}

View File

@ -1,7 +1,6 @@
#include "NexusStrategy.h"
#include "NexusMultipliers.h"
void WotlkDungeonNexStrategy::InitTriggers(std::vector<TriggerNode*> &triggers)
{
// Horde Commander (Alliance N)/Commander Kolurg (Alliance H)

View File

@ -5,7 +5,6 @@
#include "AiObjectContext.h"
#include "Strategy.h"
class WotlkDungeonNexStrategy : public Strategy
{
public:

View File

@ -40,7 +40,7 @@ float OccFlyingMultiplier::GetValue(Action* action)
float UromMultiplier::GetValue(Action* action)
{
if(GetPhaseByCurrentPosition(bot) < 3)
if (GetPhaseByCurrentPosition(bot) < 3)
{
Unit* target = action->GetTarget();
if (target && target->GetEntry() == NPC_MAGE_LORD_UROM)

View File

@ -1,7 +1,6 @@
#include "OculusStrategy.h"
#include "OculusMultipliers.h"
void WotlkDungeonOccStrategy::InitTriggers(std::vector<TriggerNode*> &triggers)
{
// Drakos the Interrogator

View File

@ -5,7 +5,6 @@
#include "AiObjectContext.h"
#include "Strategy.h"
class WotlkDungeonOccStrategy : public Strategy
{
public:

View File

@ -2,7 +2,6 @@
#include "OldKingdomActions.h"
#include "OldKingdomStrategy.h"
bool AttackNadoxGuardianAction::Execute(Event event)
{
Unit* target = AI_VALUE2(Unit*, "find target", "ahn'kahar guardian");

View File

@ -1,7 +1,6 @@
#include "OldKingdomStrategy.h"
#include "OldKingdomMultipliers.h"
void WotlkDungeonOKStrategy::InitTriggers(std::vector<TriggerNode*> &triggers)
{
// Elder Nadox

View File

@ -5,7 +5,6 @@
#include "AiObjectContext.h"
#include "Strategy.h"
class WotlkDungeonOKStrategy : public Strategy
{
public:

View File

@ -3,7 +3,6 @@
#include "AiObject.h"
#include "AiObjectContext.h"
bool NadoxGuardianTrigger::IsActive()
{
if (botAI->IsHeal(bot)) { return false; }

View File

@ -136,7 +136,6 @@ bool IckAndKrickAction::PoisonNova(bool poisonNova, Unit* boss)
return false;
}
bool IckAndKrickAction::ExplosiveBarrage(bool explosiveBarrage, Unit* boss)
{
std::vector<Unit*> orbs;

View File

@ -5,8 +5,6 @@
#include "MovementActions.h"
#include "PitOfSaronTriggers.h"
float IckAndKrickMultiplier::GetValue(Action* action)
{
Unit* boss = AI_VALUE2(Unit*, "find target", "ick");

View File

@ -20,5 +20,4 @@ public:
float GetValue(Action* action) override;
};
#endif

View File

@ -9,7 +9,6 @@
#include "GenericActions.h"
#include <fstream>
bool ToCLanceAction::Execute(Event event)
{
// If already has lance equipped, do nothing

View File

@ -1,7 +1,6 @@
#include "TrialOfTheChampionStrategy.h"
#include "TrialOfTheChampionMultipliers.h"
void WotlkDungeonToCStrategy::InitTriggers(std::vector<TriggerNode*> &triggers)
{
triggers.push_back(new TriggerNode("toc lance",

Some files were not shown because too many files have changed in this diff Show More