Resolve most warnings - PlayerbotAI (#1025)

Resolve most warnings - PlayerbotAI

---------

Co-authored-by: blinkysc <37940565+blinkysc@users.noreply.github.com>
This commit is contained in:
SaW
2025-03-01 14:19:07 +01:00
committed by GitHub
parent fbfcbbcddc
commit 9fbf60d812
6 changed files with 74 additions and 105 deletions

View File

@@ -16,7 +16,7 @@ uint8 BroadcastHelper::GetLocale()
return locale; return locale;
} }
bool BroadcastHelper::BroadcastTest(PlayerbotAI* ai, Player* bot) bool BroadcastHelper::BroadcastTest(PlayerbotAI* ai, Player* /* bot */)
{ {
//return something to ignore the logic //return something to ignore the logic
return false; return false;
@@ -609,7 +609,7 @@ bool BroadcastHelper::BroadcastLevelup(PlayerbotAI* ai, Player* bot)
return false; return false;
} }
bool BroadcastHelper::BroadcastGuildMemberPromotion(PlayerbotAI* ai, Player* bot, Player* player) bool BroadcastHelper::BroadcastGuildMemberPromotion(PlayerbotAI* ai, Player* /* bot */, Player* player)
{ {
if (!sPlayerbotAIConfig->enableBroadcasts) if (!sPlayerbotAIConfig->enableBroadcasts)
return false; return false;
@@ -627,7 +627,7 @@ bool BroadcastHelper::BroadcastGuildMemberPromotion(PlayerbotAI* ai, Player* bot
return false; return false;
} }
bool BroadcastHelper::BroadcastGuildMemberDemotion(PlayerbotAI* ai, Player* bot, Player* player) bool BroadcastHelper::BroadcastGuildMemberDemotion(PlayerbotAI* ai, Player* /* bot */, Player* player)
{ {
if (urand(1, sPlayerbotAIConfig->broadcastChanceMaxValue) <= sPlayerbotAIConfig->broadcastChanceGuildManagement) if (urand(1, sPlayerbotAIConfig->broadcastChanceMaxValue) <= sPlayerbotAIConfig->broadcastChanceGuildManagement)
{ {
@@ -643,7 +643,7 @@ bool BroadcastHelper::BroadcastGuildMemberDemotion(PlayerbotAI* ai, Player* bot,
return false; return false;
} }
bool BroadcastHelper::BroadcastGuildGroupOrRaidInvite(PlayerbotAI* ai, Player* bot, Player* player, Group* group) bool BroadcastHelper::BroadcastGuildGroupOrRaidInvite(PlayerbotAI* ai, Player* /* bot */, Player* player, Group* group)
{ {
if (!sPlayerbotAIConfig->enableBroadcasts) if (!sPlayerbotAIConfig->enableBroadcasts)
return false; return false;

View File

@@ -483,7 +483,7 @@ GuidVector ChatHelper::parseGameobjects(std::string const text)
break; break;
std::string const entryC = text.substr(pos, endPos - pos); // get std::string const within window i.e entry std::string const entryC = text.substr(pos, endPos - pos); // get std::string const within window i.e entry
uint32 entry = atol(entryC.c_str()); // convert ascii to float //uint32 entry = atol(entryC.c_str()); // convert ascii to float
ObjectGuid lootCurrent = ObjectGuid(guid); ObjectGuid lootCurrent = ObjectGuid(guid);

View File

@@ -168,7 +168,7 @@ public:
bool Apply(ItemTemplate const* proto) override bool Apply(ItemTemplate const* proto) override
{ {
uint32* tradeSkills = PlayerbotFactory::tradeSkills; //uint32* tradeSkills = PlayerbotFactory::tradeSkills;
for (uint32 i = 0; i < 13; ++i) for (uint32 i = 0; i < 13; ++i)
{ {
@@ -546,7 +546,7 @@ bool GuildTaskMgr::IsGuildTaskItem(uint32 itemId, uint32 guildId)
} }
std::map<uint32, uint32> GuildTaskMgr::GetTaskValues(uint32 owner, std::string const type, std::map<uint32, uint32> GuildTaskMgr::GetTaskValues(uint32 owner, std::string const type,
uint32* validIn /* = nullptr */) [[maybe_unused]] uint32* validIn /* = nullptr */)
{ {
std::map<uint32, uint32> results; std::map<uint32, uint32> results;
@@ -571,10 +571,10 @@ std::map<uint32, uint32> GuildTaskMgr::GetTaskValues(uint32 owner, std::string c
} while (result->NextRow()); } while (result->NextRow());
} }
return std::move(results); return results;
} }
uint32 GuildTaskMgr::GetTaskValue(uint32 owner, uint32 guildId, std::string const type, uint32* validIn /* = nullptr */) uint32 GuildTaskMgr::GetTaskValue(uint32 owner, uint32 guildId, std::string const type, [[maybe_unused]] uint32* validIn /* = nullptr */)
{ {
uint32 value = 0; uint32 value = 0;
@@ -622,7 +622,7 @@ uint32 GuildTaskMgr::SetTaskValue(uint32 owner, uint32 guildId, std::string cons
return value; return value;
} }
bool GuildTaskMgr::HandleConsoleCommand(ChatHandler* handler, char const* args) bool GuildTaskMgr::HandleConsoleCommand(ChatHandler* /* handler */, char const* args)
{ {
if (!sPlayerbotAIConfig->guildTaskEnabled) if (!sPlayerbotAIConfig->guildTaskEnabled)
{ {

View File

@@ -1002,7 +1002,7 @@ void PlayerbotAI::HandleBotOutgoingPacket(WorldPacket const& packet)
{ {
p.rpos(0); p.rpos(0);
uint8 msgtype, chatTag; uint8 msgtype, chatTag;
uint32 lang, textLen, nameLen, unused; uint32 lang, textLen, unused;
ObjectGuid guid1, guid2; ObjectGuid guid1, guid2;
std::string name = ""; std::string name = "";
std::string chanName = ""; std::string chanName = "";
@@ -1041,14 +1041,13 @@ void PlayerbotAI::HandleBotOutgoingPacket(WorldPacket const& packet)
{ {
time_t lastChat = GetAiObjectContext()->GetValue<time_t>("last said", "chat")->Get(); time_t lastChat = GetAiObjectContext()->GetValue<time_t>("last said", "chat")->Get();
bool isPaused = time(0) < lastChat; bool isPaused = time(0) < lastChat;
bool shouldReply = false;
bool isFromFreeBot = false; bool isFromFreeBot = false;
sCharacterCache->GetCharacterNameByGuid(guid1, name); sCharacterCache->GetCharacterNameByGuid(guid1, name);
uint32 accountId = sCharacterCache->GetCharacterAccountIdByGuid(guid1); uint32 accountId = sCharacterCache->GetCharacterAccountIdByGuid(guid1);
isFromFreeBot = sPlayerbotAIConfig->IsInRandomAccountList(accountId); isFromFreeBot = sPlayerbotAIConfig->IsInRandomAccountList(accountId);
bool isMentioned = message.find(bot->GetName()) != std::string::npos; bool isMentioned = message.find(bot->GetName()) != std::string::npos;
ChatChannelSource chatChannelSource = GetChatChannelSource(bot, msgtype, chanName); // ChatChannelSource chatChannelSource = GetChatChannelSource(bot, msgtype, chanName);
// random bot speaks, chat CD // random bot speaks, chat CD
if (isFromFreeBot && isPaused) if (isFromFreeBot && isPaused)
@@ -1102,8 +1101,8 @@ void PlayerbotAI::HandleBotOutgoingPacket(WorldPacket const& packet)
} }
QueueChatResponse( QueueChatResponse(
std::move(ChatQueuedReply{msgtype, guid1.GetCounter(), guid2.GetCounter(), message, chanName, ChatQueuedReply{msgtype, guid1.GetCounter(), guid2.GetCounter(), message, chanName,
name, time(nullptr) + urand(inCombat ? 10 : 5, inCombat ? 25 : 15)})); name, time(nullptr) + urand(inCombat ? 10 : 5, inCombat ? 25 : 15)});
GetAiObjectContext()->GetValue<time_t>("last said", "chat")->Set(time(0) + urand(5, 25)); GetAiObjectContext()->GetValue<time_t>("last said", "chat")->Set(time(0) + urand(5, 25));
return; return;
} }
@@ -1136,7 +1135,7 @@ void PlayerbotAI::HandleBotOutgoingPacket(WorldPacket const& packet)
bot->StopMoving(); bot->StopMoving();
bot->GetMotionMaster()->Clear(); bot->GetMotionMaster()->Clear();
Unit* currentTarget = GetAiObjectContext()->GetValue<Unit*>("current target")->Get(); // Unit* currentTarget = GetAiObjectContext()->GetValue<Unit*>("current target")->Get();
bot->GetMotionMaster()->MoveKnockbackFromForPlayer(bot->GetPositionX() - vcos, bot->GetPositionY() - vsin, bot->GetMotionMaster()->MoveKnockbackFromForPlayer(bot->GetPositionX() - vcos, bot->GetPositionY() - vsin,
horizontalSpeed, verticalSpeed); horizontalSpeed, verticalSpeed);
@@ -1277,7 +1276,7 @@ void PlayerbotAI::DoNextAction(bool min)
bot->GetMotionMaster()->MoveIdle(); bot->GetMotionMaster()->MoveIdle();
// Death Count to prevent skeleton piles // Death Count to prevent skeleton piles
Player* master = GetMaster(); // warning here - whipowill // Player* master = GetMaster(); // warning here - whipowill
if (!HasActivePlayerMaster() && !bot->InBattleground()) if (!HasActivePlayerMaster() && !bot->InBattleground())
{ {
uint32 dCount = aiObjectContext->GetValue<uint32>("death count")->Get(); uint32 dCount = aiObjectContext->GetValue<uint32>("death count")->Get();
@@ -1555,7 +1554,7 @@ void PlayerbotAI::ApplyInstanceStrategies(uint32 mapId, bool tellMaster)
if (tellMaster && !strategyName.empty()) if (tellMaster && !strategyName.empty())
{ {
std::ostringstream out; std::ostringstream out;
out << "Add " << strategyName << " instance strategy"; out << "Added " << strategyName << " instance strategy";
TellMasterNoFacing(out.str()); TellMasterNoFacing(out.str());
} }
} }
@@ -1710,7 +1709,7 @@ bool PlayerbotAI::IsCaster(Player* player, bool bySpec)
return IsRanged(player, bySpec) && player->getClass() != CLASS_HUNTER; return IsRanged(player, bySpec) && player->getClass() != CLASS_HUNTER;
} }
bool PlayerbotAI::IsCombo(Player* player, bool bySpec) bool PlayerbotAI::IsCombo(Player* player)
{ {
// int tab = AiFactory::GetPlayerSpecTab(player); // int tab = AiFactory::GetPlayerSpecTab(player);
return player->getClass() == CLASS_ROGUE || return player->getClass() == CLASS_ROGUE ||
@@ -1727,7 +1726,6 @@ bool PlayerbotAI::IsHealAssistantOfIndex(Player* player, int index)
return false; return false;
} }
Group::MemberSlotList const& slots = group->GetMemberSlots();
int counter = 0; int counter = 0;
for (GroupReference* ref = group->GetFirstMember(); ref; ref = ref->next()) for (GroupReference* ref = group->GetFirstMember(); ref; ref = ref->next())
@@ -1759,7 +1757,6 @@ bool PlayerbotAI::IsRangedDpsAssistantOfIndex(Player* player, int index)
return false; return false;
} }
Group::MemberSlotList const& slots = group->GetMemberSlots();
int counter = 0; int counter = 0;
for (GroupReference* ref = group->GetFirstMember(); ref; ref = ref->next()) for (GroupReference* ref = group->GetFirstMember(); ref; ref = ref->next())
@@ -1805,7 +1802,6 @@ int32 PlayerbotAI::GetGroupSlotIndex(Player* player)
{ {
return -1; return -1;
} }
Group::MemberSlotList const& slots = group->GetMemberSlots();
int counter = 0; int counter = 0;
for (GroupReference* ref = group->GetFirstMember(); ref; ref = ref->next()) for (GroupReference* ref = group->GetFirstMember(); ref; ref = ref->next())
{ {
@@ -1830,7 +1826,6 @@ int32 PlayerbotAI::GetRangedIndex(Player* player)
{ {
return -1; return -1;
} }
Group::MemberSlotList const& slots = group->GetMemberSlots();
int counter = 0; int counter = 0;
for (GroupReference* ref = group->GetFirstMember(); ref; ref = ref->next()) for (GroupReference* ref = group->GetFirstMember(); ref; ref = ref->next())
{ {
@@ -1858,7 +1853,6 @@ int32 PlayerbotAI::GetClassIndex(Player* player, uint8 cls)
{ {
return -1; return -1;
} }
Group::MemberSlotList const& slots = group->GetMemberSlots();
int counter = 0; int counter = 0;
for (GroupReference* ref = group->GetFirstMember(); ref; ref = ref->next()) for (GroupReference* ref = group->GetFirstMember(); ref; ref = ref->next())
{ {
@@ -1885,7 +1879,6 @@ int32 PlayerbotAI::GetRangedDpsIndex(Player* player)
{ {
return -1; return -1;
} }
Group::MemberSlotList const& slots = group->GetMemberSlots();
int counter = 0; int counter = 0;
for (GroupReference* ref = group->GetFirstMember(); ref; ref = ref->next()) for (GroupReference* ref = group->GetFirstMember(); ref; ref = ref->next())
{ {
@@ -1913,7 +1906,6 @@ int32 PlayerbotAI::GetMeleeIndex(Player* player)
{ {
return -1; return -1;
} }
Group::MemberSlotList const& slots = group->GetMemberSlots();
int counter = 0; int counter = 0;
for (GroupReference* ref = group->GetFirstMember(); ref; ref = ref->next()) for (GroupReference* ref = group->GetFirstMember(); ref; ref = ref->next())
{ {
@@ -2070,8 +2062,10 @@ bool PlayerbotAI::IsMainTank(Player* player)
{ {
return IsTank(player); return IsTank(player);
} }
ObjectGuid mainTank = ObjectGuid(); ObjectGuid mainTank = ObjectGuid();
Group::MemberSlotList const& slots = group->GetMemberSlots(); Group::MemberSlotList const& slots = group->GetMemberSlots();
for (Group::member_citerator itr = slots.begin(); itr != slots.end(); ++itr) for (Group::member_citerator itr = slots.begin(); itr != slots.end(); ++itr)
{ {
if (itr->flags & MEMBER_FLAG_MAINTANK) if (itr->flags & MEMBER_FLAG_MAINTANK)
@@ -2123,7 +2117,6 @@ bool PlayerbotAI::IsAssistTankOfIndex(Player* player, int index)
{ {
return false; return false;
} }
Group::MemberSlotList const& slots = group->GetMemberSlots();
int counter = 0; int counter = 0;
for (GroupReference* ref = group->GetFirstMember(); ref; ref = ref->next()) for (GroupReference* ref = group->GetFirstMember(); ref; ref = ref->next())
{ {
@@ -2714,8 +2707,6 @@ bool PlayerbotAI::HasAura(uint32 spellId, Unit const* unit)
// return false; // return false;
} }
// SAW
Aura* PlayerbotAI::GetAura(std::string const name, Unit* unit, bool checkIsOwner, bool checkDuration, int checkStack) Aura* PlayerbotAI::GetAura(std::string const name, Unit* unit, bool checkIsOwner, bool checkDuration, int checkStack)
{ {
if (!unit) if (!unit)
@@ -2883,7 +2874,7 @@ bool PlayerbotAI::CanCastSpell(uint32 spellid, Unit* target, bool checkHasSpell,
if (!itemTarget) if (!itemTarget)
{ {
bool positiveSpell = spellInfo->IsPositive(); // bool positiveSpell = spellInfo->IsPositive();
// if (positiveSpell && bot->IsHostileTo(target)) // if (positiveSpell && bot->IsHostileTo(target))
// return false; // return false;
@@ -2986,7 +2977,7 @@ bool PlayerbotAI::CanCastSpell(uint32 spellid, Unit* target, bool checkHasSpell,
} }
} }
bool PlayerbotAI::CanCastSpell(uint32 spellid, GameObject* goTarget, uint8 effectMask, bool checkHasSpell) bool PlayerbotAI::CanCastSpell(uint32 spellid, GameObject* goTarget, bool checkHasSpell)
{ {
if (!spellid) if (!spellid)
return false; return false;
@@ -3012,16 +3003,6 @@ bool PlayerbotAI::CanCastSpell(uint32 spellid, GameObject* goTarget, uint8 effec
if (CastingTime > 0 && bot->isMoving()) if (CastingTime > 0 && bot->isMoving())
return false; return false;
bool damage = false;
for (int32 i = EFFECT_0; i <= EFFECT_2; i++)
{
if (spellInfo->Effects[i].Effect == SPELL_EFFECT_SCHOOL_DAMAGE)
{
damage = true;
break;
}
}
if (sServerFacade->GetDistance2d(bot, goTarget) > sPlayerbotAIConfig->sightDistance) if (sServerFacade->GetDistance2d(bot, goTarget) > sPlayerbotAIConfig->sightDistance)
return false; return false;
@@ -3054,7 +3035,7 @@ bool PlayerbotAI::CanCastSpell(uint32 spellid, GameObject* goTarget, uint8 effec
return false; return false;
} }
bool PlayerbotAI::CanCastSpell(uint32 spellid, float x, float y, float z, uint8 effectMask, bool checkHasSpell, bool PlayerbotAI::CanCastSpell(uint32 spellid, float x, float y, float z, bool checkHasSpell,
Item* itemTarget) Item* itemTarget)
{ {
if (!spellid) if (!spellid)
@@ -3333,7 +3314,7 @@ bool PlayerbotAI::CastSpell(uint32 spellId, float x, float y, float z, Item* ite
// aiObjectContext->GetValue<LastMovement&>("last movement")->Get().Set(nullptr); // aiObjectContext->GetValue<LastMovement&>("last movement")->Get().Set(nullptr);
// aiObjectContext->GetValue<time_t>("stay time")->Set(0); // aiObjectContext->GetValue<time_t>("stay time")->Set(0);
MotionMaster& mm = *bot->GetMotionMaster(); // MotionMaster& mm = *bot->GetMotionMaster();
if (bot->IsFlying() || bot->HasUnitState(UNIT_STATE_IN_FLIGHT)) if (bot->IsFlying() || bot->HasUnitState(UNIT_STATE_IN_FLIGHT))
return false; return false;
@@ -3377,7 +3358,7 @@ bool PlayerbotAI::CastSpell(uint32 spellId, float x, float y, float z, Item* ite
} }
else if (spellInfo->Targets & TARGET_FLAG_DEST_LOCATION) else if (spellInfo->Targets & TARGET_FLAG_DEST_LOCATION)
{ {
WorldLocation aoe = aiObjectContext->GetValue<WorldLocation>("aoe position")->Get(); // WorldLocation aoe = aiObjectContext->GetValue<WorldLocation>("aoe position")->Get();
targets.SetDst(x, y, z, 0.f); targets.SetDst(x, y, z, 0.f);
} }
else if (spellInfo->Targets & TARGET_FLAG_SOURCE_LOCATION) else if (spellInfo->Targets & TARGET_FLAG_SOURCE_LOCATION)
@@ -3866,7 +3847,7 @@ Player* PlayerbotAI::GetGroupMaster()
return master; return master;
} }
uint32 PlayerbotAI::GetFixedBotNumer(BotTypeNumber typeNumber, uint32 maxNum, float cyclePerMin) uint32 PlayerbotAI::GetFixedBotNumer(uint32 maxNum, float cyclePerMin)
{ {
uint32 randseed = rand32(); // Seed random number uint32 randseed = rand32(); // Seed random number
uint32 randnum = bot->GetGUID().GetCounter() + randseed; // Semi-random but fixed number for each bot. uint32 randnum = bot->GetGUID().GetCounter() + randseed; // Semi-random but fixed number for each bot.
@@ -3897,7 +3878,7 @@ enum GrouperType
GrouperType PlayerbotAI::GetGrouperType() GrouperType PlayerbotAI::GetGrouperType()
{ {
uint32 grouperNumber = GetFixedBotNumer(BotTypeNumber::GROUPER_TYPE_NUMBER, 100, 0); uint32 grouperNumber = GetFixedBotNumer(100, 0);
if (grouperNumber < 20 && !HasRealPlayerMaster()) if (grouperNumber < 20 && !HasRealPlayerMaster())
return GrouperType::SOLO; return GrouperType::SOLO;
@@ -3919,7 +3900,7 @@ GrouperType PlayerbotAI::GetGrouperType()
GuilderType PlayerbotAI::GetGuilderType() GuilderType PlayerbotAI::GetGuilderType()
{ {
uint32 grouperNumber = GetFixedBotNumer(BotTypeNumber::GUILDER_TYPE_NUMBER, 100, 0); uint32 grouperNumber = GetFixedBotNumer(100, 0);
if (grouperNumber < 20 && !HasRealPlayerMaster()) if (grouperNumber < 20 && !HasRealPlayerMaster())
return GuilderType::SOLO; return GuilderType::SOLO;
@@ -4140,7 +4121,7 @@ bool PlayerbotAI::AllowActive(ActivityType activityType)
for (GroupReference* gref = group->GetFirstMember(); gref; gref = gref->next()) for (GroupReference* gref = group->GetFirstMember(); gref; gref = gref->next())
{ {
Player* member = gref->GetSource(); Player* member = gref->GetSource();
if (!member || !member->IsInWorld() && member->GetMapId() != bot->GetMapId()) if ((!member || !member->IsInWorld()) && member->GetMapId() != bot->GetMapId())
{ {
continue; continue;
} }
@@ -4243,9 +4224,8 @@ bool PlayerbotAI::AllowActive(ActivityType activityType)
mod = AutoScaleActivity(mod); mod = AutoScaleActivity(mod);
} }
uint32 ActivityNumber = uint32 ActivityNumber = GetFixedBotNumer(100,
GetFixedBotNumer(BotTypeNumber::ACTIVITY_TYPE_NUMBER, 100, sPlayerbotAIConfig->botActiveAlone * static_cast<float>(mod) / 100 * 0.01f);
sPlayerbotAIConfig->botActiveAlone * static_cast<float>(mod) / 100 * 0.01f);
return ActivityNumber <= return ActivityNumber <=
(sPlayerbotAIConfig->botActiveAlone * mod) / (sPlayerbotAIConfig->botActiveAlone * mod) /
@@ -4304,7 +4284,7 @@ void PlayerbotAI::RemoveShapeshift()
RemoveAura("moonkin form"); RemoveAura("moonkin form");
RemoveAura("travel form"); RemoveAura("travel form");
RemoveAura("cat form"); RemoveAura("cat form");
RemoveAura("flight form"); RemoveAura("flight form"); bot->RemoveAura(33943); // The latter added for now as RemoveAura("flight form") currently does not work.
RemoveAura("swift flight form"); RemoveAura("swift flight form");
RemoveAura("aquatic form"); RemoveAura("aquatic form");
RemoveAura("ghost wolf"); RemoveAura("ghost wolf");
@@ -4492,7 +4472,7 @@ uint32 PlayerbotAI::GetMixedGearScore(Player* player, bool withBags, bool withBa
} }
std::sort(topGearScore.begin(), topGearScore.end(), [&](const uint32 lhs, const uint32 rhs) { return lhs > rhs; }); std::sort(topGearScore.begin(), topGearScore.end(), [&](const uint32 lhs, const uint32 rhs) { return lhs > rhs; });
uint32 sum = 0; uint32 sum = 0;
for (int i = 0; i < std::min((uint32)topGearScore.size(), topN); i++) for (uint32 i = 0; i < std::min((uint32)topGearScore.size(), topN); i++)
{ {
sum += topGearScore[i]; sum += topGearScore[i];
} }
@@ -5203,7 +5183,7 @@ std::vector<std::pair<const Quest*, uint32>> PlayerbotAI::GetCurrentQuestsRequir
if (!questId) if (!questId)
continue; continue;
QuestStatus status = bot->GetQuestStatus(questId); // QuestStatus status = bot->GetQuestStatus(questId);
const Quest* quest = sObjectMgr->GetQuestTemplate(questId); const Quest* quest = sObjectMgr->GetQuestTemplate(questId);
for (uint8 i = 0; i < std::size(quest->RequiredItemId); ++i) for (uint8 i = 0; i < std::size(quest->RequiredItemId); ++i)
{ {
@@ -5257,13 +5237,11 @@ void PlayerbotAI::ImbueItem(Item* item, uint32 targetFlag, ObjectGuid targetGUID
ObjectGuid item_guid = item->GetGUID(); ObjectGuid item_guid = item->GetGUID();
uint32 spellId = 0; uint32 spellId = 0;
uint8 spell_index = 0;
for (uint8 i = 0; i < MAX_ITEM_PROTO_SPELLS; ++i) for (uint8 i = 0; i < MAX_ITEM_PROTO_SPELLS; ++i)
{ {
if (item->GetTemplate()->Spells[i].SpellId > 0) if (item->GetTemplate()->Spells[i].SpellId > 0)
{ {
spellId = item->GetTemplate()->Spells[i].SpellId; spellId = item->GetTemplate()->Spells[i].SpellId;
spell_index = i;
break; break;
} }
} }
@@ -5410,7 +5388,7 @@ bool PlayerbotAI::EqualLowercaseName(std::string s1, std::string s2)
{ {
return false; return false;
} }
for (int i = 0; i < s1.length(); i++) for (std::string::size_type i = 0; i < s1.length(); i++)
{ {
if (tolower(s1[i]) != tolower(s2[i])) if (tolower(s1[i]) != tolower(s2[i]))
{ {
@@ -5933,16 +5911,17 @@ uint32 PlayerbotAI::GetReactDelay()
return base; return base;
bool inBG = bot->InBattleground() || bot->InArena(); bool inBG = bot->InBattleground() || bot->InArena();
if (sPlayerbotAIConfig->fastReactInBG && inBG) if (sPlayerbotAIConfig->fastReactInBG && inBG)
return base; return base;
bool inCombat = bot->IsInCombat(); bool inCombat = bot->IsInCombat();
if (!inCombat) if (!inCombat)
return base * 10.0f; return base * 10;
else if (inCombat) else if (inCombat)
return base * 2.5f; return static_cast<uint32>(base * 2.5f);
return base; return base;
} }
@@ -5952,40 +5931,30 @@ uint32 PlayerbotAI::GetReactDelay()
if (HasRealPlayerMaster()) if (HasRealPlayerMaster())
return base; return base;
float multiplier = 1.0f;
bool inBG = bot->InBattleground() || bot->InArena(); bool inBG = bot->InBattleground() || bot->InArena();
if (inBG) if (inBG)
{ {
if (bot->IsInCombat() || currentState == BOT_STATE_COMBAT) if (bot->IsInCombat() || currentState == BOT_STATE_COMBAT)
{ {
multiplier = sPlayerbotAIConfig->fastReactInBG ? 2.5f : 5.0f; return static_cast<uint32>(base * (sPlayerbotAIConfig->fastReactInBG ? 2.5f : 5.0f));
return base * multiplier;
} }
else else
{ {
multiplier = sPlayerbotAIConfig->fastReactInBG ? 1.0f : 10.0f; return static_cast<uint32>(base * (sPlayerbotAIConfig->fastReactInBG ? 1.0f : 10.0f));
return base * multiplier;
} }
} }
// When in combat, return 5 times the base // When in combat, return 5 times the base
if (bot->IsInCombat() || currentState == BOT_STATE_COMBAT) if (bot->IsInCombat() || currentState == BOT_STATE_COMBAT)
{ return base * 5;
multiplier = 5.0f;
return base * multiplier;
}
// When not resting, return 10-30 times the base // When not resting, return 10-30 times the base
if (!bot->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_RESTING)) if (!bot->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_RESTING))
{ return base * urand(10, 30);
multiplier = urand(10, 30);
return base * multiplier;
}
// In other cases, return 20-200 times the base // In other cases, return 20-200 times the base
multiplier = urand(20, 200); return base * urand(20, 200);
return base * multiplier;
} }
void PlayerbotAI::PetFollow() void PlayerbotAI::PetFollow()

View File

@@ -409,8 +409,8 @@ public:
static bool IsRanged(Player* player, bool bySpec = false); static bool IsRanged(Player* player, bool bySpec = false);
static bool IsMelee(Player* player, bool bySpec = false); static bool IsMelee(Player* player, bool bySpec = false);
static bool IsCaster(Player* player, bool bySpec = false); static bool IsCaster(Player* player, bool bySpec = false);
static bool IsCombo(Player* player, bool bySpec = false);
static bool IsRangedDps(Player* player, bool bySpec = false); static bool IsRangedDps(Player* player, bool bySpec = false);
static bool IsCombo(Player* player);
static bool IsMainTank(Player* player); static bool IsMainTank(Player* player);
static uint32 GetGroupTankNum(Player* player); static uint32 GetGroupTankNum(Player* player);
bool IsAssistTank(Player* player); bool IsAssistTank(Player* player);
@@ -485,8 +485,8 @@ public:
virtual bool HasAuraToDispel(Unit* player, uint32 dispelType); virtual bool HasAuraToDispel(Unit* player, uint32 dispelType);
bool CanCastSpell(uint32 spellid, Unit* target, bool checkHasSpell = true, Item* itemTarget = nullptr, bool CanCastSpell(uint32 spellid, Unit* target, bool checkHasSpell = true, Item* itemTarget = nullptr,
Item* castItem = nullptr); Item* castItem = nullptr);
bool CanCastSpell(uint32 spellid, GameObject* goTarget, uint8 effectMask, bool checkHasSpell = true); bool CanCastSpell(uint32 spellid, GameObject* goTarget, bool checkHasSpell = true);
bool CanCastSpell(uint32 spellid, float x, float y, float z, uint8 effectMask, bool checkHasSpell = true, bool CanCastSpell(uint32 spellid, float x, float y, float z, bool checkHasSpell = true,
Item* itemTarget = nullptr); Item* itemTarget = nullptr);
bool HasAura(uint32 spellId, Unit const* player); bool HasAura(uint32 spellId, Unit const* player);
@@ -522,7 +522,7 @@ public:
bool IsAlt(); bool IsAlt();
Player* GetGroupMaster(); Player* GetGroupMaster();
// Returns a semi-random (cycling) number that is fixed for each bot. // Returns a semi-random (cycling) number that is fixed for each bot.
uint32 GetFixedBotNumer(BotTypeNumber typeNumber, uint32 maxNum = 100, float cyclePerMin = 1); uint32 GetFixedBotNumer(uint32 maxNum = 100, float cyclePerMin = 1);
GrouperType GetGrouperType(); GrouperType GetGrouperType();
GuilderType GetGuilderType(); GuilderType GetGuilderType();
bool HasPlayerNearby(WorldPosition* pos, float range = sPlayerbotAIConfig->reactDistance); bool HasPlayerNearby(WorldPosition* pos, float range = sPlayerbotAIConfig->reactDistance);

View File

@@ -48,49 +48,49 @@ public:
} }
private: private:
static ActionNode* blessing_of_sanctuary(PlayerbotAI* ai) static ActionNode* blessing_of_sanctuary(PlayerbotAI* /* ai */)
{ {
return new ActionNode("blessing of sanctuary", return new ActionNode("blessing of sanctuary",
/*P*/ nullptr, /*P*/ nullptr,
/*A*/ nullptr, /*A*/ nullptr,
/*C*/ nullptr); /*C*/ nullptr);
} }
static ActionNode* blessing_of_kings(PlayerbotAI* ai) static ActionNode* blessing_of_kings(PlayerbotAI* /* ai */)
{ {
return new ActionNode("blessing of kings", return new ActionNode("blessing of kings",
/*P*/ nullptr, /*P*/ nullptr,
/*A*/ nullptr, /*A*/ nullptr,
/*C*/ nullptr); /*C*/ nullptr);
} }
static ActionNode* blessing_of_wisdom(PlayerbotAI* ai) static ActionNode* blessing_of_wisdom(PlayerbotAI* /* ai */)
{ {
return new ActionNode("blessing of wisdom", return new ActionNode("blessing of wisdom",
/*P*/ nullptr, /*P*/ nullptr,
/*A*/ nullptr, /*A*/ nullptr,
/*C*/ nullptr); /*C*/ nullptr);
} }
static ActionNode* blessing_of_kings_on_party(PlayerbotAI* ai) static ActionNode* blessing_of_kings_on_party(PlayerbotAI* /* ai */)
{ {
return new ActionNode("blessing of kings on party", return new ActionNode("blessing of kings on party",
/*P*/ nullptr, /*P*/ nullptr,
/*A*/ nullptr, /*A*/ nullptr,
/*C*/ nullptr); /*C*/ nullptr);
} }
static ActionNode* blessing_of_wisdom_on_party(PlayerbotAI* ai) static ActionNode* blessing_of_wisdom_on_party(PlayerbotAI* /* ai */)
{ {
return new ActionNode("blessing of wisdom on party", return new ActionNode("blessing of wisdom on party",
/*P*/ nullptr, /*P*/ nullptr,
/*A*/ nullptr, /*A*/ nullptr,
/*C*/ nullptr); /*C*/ nullptr);
} }
static ActionNode* retribution_aura(PlayerbotAI* ai) static ActionNode* retribution_aura(PlayerbotAI* /* ai */)
{ {
return new ActionNode("retribution aura", return new ActionNode("retribution aura",
/*P*/ nullptr, /*P*/ nullptr,
/*A*/ NextAction::array(0, new NextAction("devotion aura"), nullptr), /*A*/ NextAction::array(0, new NextAction("devotion aura"), nullptr),
/*C*/ nullptr); /*C*/ nullptr);
} }
static ActionNode* lay_on_hands(PlayerbotAI* ai) static ActionNode* lay_on_hands(PlayerbotAI* /* ai */)
{ {
return new ActionNode("lay on hands", return new ActionNode("lay on hands",
/*P*/ nullptr, /*P*/ nullptr,
@@ -98,7 +98,7 @@ private:
// NextAction("flash of light"), NULL), // NextAction("flash of light"), NULL),
/*C*/ nullptr); /*C*/ nullptr);
} }
static ActionNode* lay_on_hands_on_party(PlayerbotAI* ai) static ActionNode* lay_on_hands_on_party(PlayerbotAI* /* ai */)
{ {
return new ActionNode("lay on hands on party", return new ActionNode("lay on hands on party",
/*P*/ nullptr, /*P*/ nullptr,
@@ -112,133 +112,133 @@ private:
// /*A*/ NextAction::array(0, new NextAction("seal of justice"), NULL), // /*A*/ NextAction::array(0, new NextAction("seal of justice"), NULL),
// /*C*/ NULL); // /*C*/ NULL);
// } // }
static ActionNode* cleanse_poison(PlayerbotAI* ai) static ActionNode* cleanse_poison(PlayerbotAI* /* ai */)
{ {
return new ActionNode("cleanse poison", return new ActionNode("cleanse poison",
/*P*/ nullptr, /*P*/ nullptr,
/*A*/ NextAction::array(0, new NextAction("purify poison"), nullptr), /*A*/ NextAction::array(0, new NextAction("purify poison"), nullptr),
/*C*/ nullptr); /*C*/ nullptr);
} }
static ActionNode* cleanse_magic(PlayerbotAI* ai) static ActionNode* cleanse_magic(PlayerbotAI* /* ai */)
{ {
return new ActionNode("cleanse magic", return new ActionNode("cleanse magic",
/*P*/ nullptr, /*P*/ nullptr,
/*A*/ nullptr, /*A*/ nullptr,
/*C*/ nullptr); /*C*/ nullptr);
} }
static ActionNode* cleanse_disease(PlayerbotAI* ai) static ActionNode* cleanse_disease(PlayerbotAI* /* ai */)
{ {
return new ActionNode("cleanse disease", return new ActionNode("cleanse disease",
/*P*/ nullptr, /*P*/ nullptr,
/*A*/ NextAction::array(0, new NextAction("purify disease"), nullptr), /*A*/ NextAction::array(0, new NextAction("purify disease"), nullptr),
/*C*/ nullptr); /*C*/ nullptr);
} }
static ActionNode* cleanse_poison_on_party(PlayerbotAI* ai) static ActionNode* cleanse_poison_on_party(PlayerbotAI* /* ai */)
{ {
return new ActionNode("cleanse poison on party", return new ActionNode("cleanse poison on party",
/*P*/ nullptr, /*P*/ nullptr,
/*A*/ NextAction::array(0, new NextAction("purify poison on party"), nullptr), /*A*/ NextAction::array(0, new NextAction("purify poison on party"), nullptr),
/*C*/ nullptr); /*C*/ nullptr);
} }
static ActionNode* cleanse_disease_on_party(PlayerbotAI* ai) static ActionNode* cleanse_disease_on_party(PlayerbotAI* /* ai */)
{ {
return new ActionNode("cleanse disease on party", return new ActionNode("cleanse disease on party",
/*P*/ nullptr, /*P*/ nullptr,
/*A*/ NextAction::array(0, new NextAction("purify disease on party"), nullptr), /*A*/ NextAction::array(0, new NextAction("purify disease on party"), nullptr),
/*C*/ nullptr); /*C*/ nullptr);
} }
static ActionNode* seal_of_wisdom(PlayerbotAI* ai) static ActionNode* seal_of_wisdom(PlayerbotAI* /* ai */)
{ {
return new ActionNode ("seal of wisdom", return new ActionNode ("seal of wisdom",
/*P*/ NULL, /*P*/ NULL,
/*A*/ NextAction::array(0, new NextAction("seal of righteousness"), NULL), /*A*/ NextAction::array(0, new NextAction("seal of righteousness"), NULL),
/*C*/ NULL); /*C*/ NULL);
} }
static ActionNode* seal_of_justice(PlayerbotAI* ai) static ActionNode* seal_of_justice(PlayerbotAI* /* ai */)
{ {
return new ActionNode("seal of justice", return new ActionNode("seal of justice",
/*P*/ nullptr, /*P*/ nullptr,
/*A*/ NextAction::array(0, new NextAction("seal of righteousness"), nullptr), /*A*/ NextAction::array(0, new NextAction("seal of righteousness"), nullptr),
/*C*/ nullptr); /*C*/ nullptr);
} }
static ActionNode* hand_of_reckoning(PlayerbotAI* ai) static ActionNode* hand_of_reckoning(PlayerbotAI* /* ai */)
{ {
return new ActionNode("hand of reckoning", return new ActionNode("hand of reckoning",
/*P*/ nullptr, /*P*/ nullptr,
/*A*/ NextAction::array(0, new NextAction("righteous defense"), nullptr), /*A*/ NextAction::array(0, new NextAction("righteous defense"), nullptr),
/*C*/ nullptr); /*C*/ nullptr);
} }
static ActionNode* righteous_defense(PlayerbotAI* ai) static ActionNode* righteous_defense(PlayerbotAI* /* ai */)
{ {
return new ActionNode("righteous defense", return new ActionNode("righteous defense",
/*P*/ nullptr, /*P*/ nullptr,
/*A*/ NextAction::array(0, new NextAction("avenger's shield"), nullptr), /*A*/ NextAction::array(0, new NextAction("avenger's shield"), nullptr),
/*C*/ nullptr); /*C*/ nullptr);
} }
static ActionNode* avengers_shield(PlayerbotAI* ai) static ActionNode* avengers_shield(PlayerbotAI* /* ai */)
{ {
return new ActionNode("avenger's shield", return new ActionNode("avenger's shield",
/*P*/ nullptr, /*P*/ nullptr,
/*A*/ NextAction::array(0, new NextAction("judgement of wisdom"), nullptr), /*A*/ NextAction::array(0, new NextAction("judgement of wisdom"), nullptr),
/*C*/ nullptr); /*C*/ nullptr);
} }
static ActionNode* divine_sacrifice(PlayerbotAI* ai) static ActionNode* divine_sacrifice(PlayerbotAI* /* ai */)
{ {
return new ActionNode("divine sacrifice", return new ActionNode("divine sacrifice",
/*P*/ nullptr, /*P*/ nullptr,
/*A*/ nullptr, /*A*/ nullptr,
/*C*/ NextAction::array(0, new NextAction("cancel divine sacrifice"), nullptr)); /*C*/ NextAction::array(0, new NextAction("cancel divine sacrifice"), nullptr));
} }
static ActionNode* judgement_of_wisdom(PlayerbotAI* ai) static ActionNode* judgement_of_wisdom(PlayerbotAI* /* ai */)
{ {
return new ActionNode("judgement of wisdom", return new ActionNode("judgement of wisdom",
/*P*/ nullptr, /*P*/ nullptr,
/*A*/ NextAction::array(0, new NextAction("judgement of light"), nullptr), /*A*/ NextAction::array(0, new NextAction("judgement of light"), nullptr),
/*C*/ nullptr); /*C*/ nullptr);
} }
static ActionNode* judgement(PlayerbotAI* ai) static ActionNode* judgement(PlayerbotAI* /* ai */)
{ {
return new ActionNode("judgement", return new ActionNode("judgement",
/*P*/ nullptr, /*P*/ nullptr,
/*A*/ nullptr, /*A*/ nullptr,
/*C*/ nullptr); /*C*/ nullptr);
} }
static ActionNode* divine_shield(PlayerbotAI* ai) static ActionNode* divine_shield(PlayerbotAI* /* ai */)
{ {
return new ActionNode("divine shield", return new ActionNode("divine shield",
/*P*/ nullptr, /*P*/ nullptr,
/*A*/ NextAction::array(0, new NextAction("divine protection"), nullptr), /*A*/ NextAction::array(0, new NextAction("divine protection"), nullptr),
/*C*/ nullptr); /*C*/ nullptr);
} }
static ActionNode* flash_of_light(PlayerbotAI* ai) static ActionNode* flash_of_light(PlayerbotAI* /* ai */)
{ {
return new ActionNode("flash of light", return new ActionNode("flash of light",
/*P*/ nullptr, /*P*/ nullptr,
/*A*/ NextAction::array(0, new NextAction("holy light"), nullptr), /*A*/ NextAction::array(0, new NextAction("holy light"), nullptr),
/*C*/ nullptr); /*C*/ nullptr);
} }
static ActionNode* flash_of_light_on_party(PlayerbotAI* ai) static ActionNode* flash_of_light_on_party(PlayerbotAI* /* ai */)
{ {
return new ActionNode("flash of light on party", return new ActionNode("flash of light on party",
/*P*/ nullptr, /*P*/ nullptr,
/*A*/ NextAction::array(0, new NextAction("holy light on party"), nullptr), /*A*/ NextAction::array(0, new NextAction("holy light on party"), nullptr),
/*C*/ nullptr); /*C*/ nullptr);
} }
static ActionNode* holy_wrath(PlayerbotAI* ai) static ActionNode* holy_wrath(PlayerbotAI* /* ai */)
{ {
return new ActionNode("holy wrath", return new ActionNode("holy wrath",
/*P*/ nullptr, /*P*/ nullptr,
/*A*/ nullptr, /*A*/ nullptr,
/*C*/ nullptr); /*C*/ nullptr);
} }
static ActionNode* hammer_of_wrath(PlayerbotAI* ai) static ActionNode* hammer_of_wrath(PlayerbotAI* /* ai */)
{ {
return new ActionNode("hammer of wrath", return new ActionNode("hammer of wrath",
/*P*/ nullptr, /*P*/ nullptr,
/*A*/ nullptr, /*A*/ nullptr,
/*C*/ nullptr); /*C*/ nullptr);
} }
static ActionNode* seal_of_command(PlayerbotAI* ai) static ActionNode* seal_of_command(PlayerbotAI* /* ai */)
{ {
return new ActionNode("seal of command", return new ActionNode("seal of command",
/*P*/ nullptr, /*P*/ nullptr,