mirror of
https://github.com/mod-playerbots/mod-playerbots.git
synced 2026-01-25 22:46:25 +00:00
[HOT FIX] MS build issues regarding folder / command lenght usage or rc.exe (#2038)
This commit is contained in:
174
src/Ai/Base/Value/GroupValues.cpp
Normal file
174
src/Ai/Base/Value/GroupValues.cpp
Normal file
@@ -0,0 +1,174 @@
|
||||
/*
|
||||
* Copyright (C) 2016+ AzerothCore <www.azerothcore.org>, released under GNU AGPL v3 license, you may redistribute it
|
||||
* and/or modify it under version 3 of the License, or (at your option), any later version.
|
||||
*/
|
||||
|
||||
#include "GroupValues.h"
|
||||
|
||||
#include "Playerbots.h"
|
||||
#include "ServerFacade.h"
|
||||
|
||||
GuidVector GroupMembersValue::Calculate()
|
||||
{
|
||||
GuidVector members;
|
||||
|
||||
Group* group = bot->GetGroup();
|
||||
if (group)
|
||||
{
|
||||
for (GroupReference* ref = group->GetFirstMember(); ref; ref = ref->next())
|
||||
{
|
||||
members.push_back(ref->GetSource()->GetGUID());
|
||||
}
|
||||
}
|
||||
else
|
||||
members.push_back(bot->GetGUID());
|
||||
|
||||
return members;
|
||||
}
|
||||
|
||||
bool IsFollowingPartyValue::Calculate()
|
||||
{
|
||||
if (botAI->GetGroupLeader() == bot)
|
||||
return true;
|
||||
|
||||
if (botAI->HasStrategy("follow", BOT_STATE_NON_COMBAT))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
};
|
||||
|
||||
bool IsNearLeaderValue::Calculate()
|
||||
{
|
||||
Player* groupLeader = botAI->GetGroupLeader();
|
||||
|
||||
if (!groupLeader)
|
||||
return false;
|
||||
|
||||
if (groupLeader == bot)
|
||||
return true;
|
||||
|
||||
return sServerFacade->GetDistance2d(bot, botAI->GetGroupLeader()) < sPlayerbotAIConfig->sightDistance;
|
||||
}
|
||||
|
||||
bool BoolANDValue::Calculate()
|
||||
{
|
||||
std::vector<std::string> values = split(getQualifier(), ',');
|
||||
|
||||
for (auto value : values)
|
||||
{
|
||||
if (!AI_VALUE(bool, value))
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
uint32 GroupBoolCountValue::Calculate()
|
||||
{
|
||||
uint32 count = 0;
|
||||
|
||||
for (ObjectGuid guid : AI_VALUE(GuidVector, "group members"))
|
||||
{
|
||||
Player* player = ObjectAccessor::FindPlayer(guid);
|
||||
|
||||
if (!player)
|
||||
continue;
|
||||
|
||||
if (player->GetMapId() != bot->GetMapId())
|
||||
continue;
|
||||
|
||||
if (!GET_PLAYERBOT_AI(player))
|
||||
continue;
|
||||
|
||||
if (PAI_VALUE2(bool, "and", getQualifier()))
|
||||
return count++;
|
||||
}
|
||||
|
||||
return count;
|
||||
};
|
||||
|
||||
bool GroupBoolANDValue::Calculate()
|
||||
{
|
||||
for (ObjectGuid guid : AI_VALUE(GuidVector, "group members"))
|
||||
{
|
||||
Player* player = ObjectAccessor::FindPlayer(guid);
|
||||
|
||||
if (!player)
|
||||
continue;
|
||||
|
||||
if (player->GetMapId() != bot->GetMapId())
|
||||
continue;
|
||||
|
||||
if (!GET_PLAYERBOT_AI(player))
|
||||
continue;
|
||||
|
||||
if (!PAI_VALUE2(bool, "and", getQualifier()))
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
bool GroupBoolORValue::Calculate()
|
||||
{
|
||||
for (ObjectGuid guid : AI_VALUE(GuidVector, "group members"))
|
||||
{
|
||||
Player* player = ObjectAccessor::FindPlayer(guid);
|
||||
|
||||
if (!player)
|
||||
continue;
|
||||
|
||||
if (player->GetMapId() != bot->GetMapId())
|
||||
continue;
|
||||
|
||||
if (!GET_PLAYERBOT_AI(player))
|
||||
continue;
|
||||
|
||||
if (PAI_VALUE2(bool, "and", getQualifier()))
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
||||
|
||||
bool GroupReadyValue::Calculate()
|
||||
{
|
||||
bool inDungeon = !WorldPosition(bot).isOverworld();
|
||||
|
||||
for (ObjectGuid guid : AI_VALUE(GuidVector, "group members"))
|
||||
{
|
||||
Player* member = ObjectAccessor::FindPlayer(guid);
|
||||
|
||||
if (!member)
|
||||
continue;
|
||||
|
||||
if (inDungeon) // In dungeons all following members need to be alive before continueing.
|
||||
{
|
||||
PlayerbotAI* memberAi = GET_PLAYERBOT_AI(member);
|
||||
|
||||
bool isFollowing = memberAi ? memberAi->HasStrategy("follow", BOT_STATE_NON_COMBAT) : true;
|
||||
|
||||
if (!member->IsAlive() && isFollowing)
|
||||
return false;
|
||||
}
|
||||
|
||||
// We only wait for members that are in range otherwise we might be waiting for bots stuck in dead loops
|
||||
// forever.
|
||||
if (botAI->GetGroupLeader() &&
|
||||
sServerFacade->GetDistance2d(member, botAI->GetGroupLeader()) > sPlayerbotAIConfig->sightDistance)
|
||||
continue;
|
||||
|
||||
if (member->GetHealthPct() < sPlayerbotAIConfig->almostFullHealth)
|
||||
return false;
|
||||
|
||||
if (!member->GetPower(POWER_MANA))
|
||||
continue;
|
||||
|
||||
float mana = (static_cast<float>(member->GetPower(POWER_MANA)) / member->GetMaxPower(POWER_MANA)) * 100;
|
||||
|
||||
if (mana < sPlayerbotAIConfig->mediumMana)
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
Reference in New Issue
Block a user