mirror of
https://github.com/mod-playerbots/mod-playerbots
synced 2025-11-29 15:58:20 +08:00
Run clang-format
This commit is contained in:
@@ -1,14 +1,16 @@
|
||||
/*
|
||||
* Copyright (C) 2016+ AzerothCore <www.azerothcore.org>, released under GNU GPL v2 license, you may redistribute it and/or modify it under version 2 of the License, or (at your option), any later version.
|
||||
* Copyright (C) 2016+ AzerothCore <www.azerothcore.org>, released under GNU GPL v2 license, you may redistribute it
|
||||
* and/or modify it under version 2 of the License, or (at your option), any later version.
|
||||
*/
|
||||
|
||||
#include "ReviveFromCorpseAction.h"
|
||||
|
||||
#include "Event.h"
|
||||
#include "FleeManager.h"
|
||||
#include "GameGraveyard.h"
|
||||
#include "MapMgr.h"
|
||||
#include "Playerbots.h"
|
||||
#include "PlayerbotFactory.h"
|
||||
#include "Playerbots.h"
|
||||
#include "RandomPlayerbotMgr.h"
|
||||
#include "ServerFacade.h"
|
||||
|
||||
@@ -21,7 +23,8 @@ bool ReviveFromCorpseAction::Execute(Event event)
|
||||
WorldPacket& p = event.getPacket();
|
||||
if (!p.empty() && p.GetOpcode() == CMSG_RECLAIM_CORPSE && master && !corpse && bot->IsAlive())
|
||||
{
|
||||
if (sServerFacade->IsDistanceLessThan(AI_VALUE2(float, "distance", "master target"), sPlayerbotAIConfig->farDistance))
|
||||
if (sServerFacade->IsDistanceLessThan(AI_VALUE2(float, "distance", "master target"),
|
||||
sPlayerbotAIConfig->farDistance))
|
||||
{
|
||||
if (!botAI->HasStrategy("follow", BOT_STATE_NON_COMBAT))
|
||||
{
|
||||
@@ -35,13 +38,15 @@ bool ReviveFromCorpseAction::Execute(Event event)
|
||||
if (!corpse)
|
||||
return false;
|
||||
|
||||
// if (corpse->GetGhostTime() + bot->GetCorpseReclaimDelay(corpse->GetType() == CORPSE_RESURRECTABLE_PVP) > time(nullptr))
|
||||
// if (corpse->GetGhostTime() + bot->GetCorpseReclaimDelay(corpse->GetType() == CORPSE_RESURRECTABLE_PVP) >
|
||||
// time(nullptr))
|
||||
// return false;
|
||||
|
||||
if (master)
|
||||
{
|
||||
if (!GET_PLAYERBOT_AI(master) && master->isDead() && master->GetCorpse()
|
||||
&& sServerFacade->IsDistanceLessThan(AI_VALUE2(float, "distance", "master target"), sPlayerbotAIConfig->farDistance))
|
||||
if (!GET_PLAYERBOT_AI(master) && master->isDead() && master->GetCorpse() &&
|
||||
sServerFacade->IsDistanceLessThan(AI_VALUE2(float, "distance", "master target"),
|
||||
sPlayerbotAIConfig->farDistance))
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -55,7 +60,8 @@ bool ReviveFromCorpseAction::Execute(Event event)
|
||||
}
|
||||
}
|
||||
|
||||
LOG_DEBUG("playerbots", "Bot {} {}:{} <{}> revives at body", bot->GetGUID().ToString().c_str(), bot->GetTeamId() == TEAM_ALLIANCE ? "A" : "H", bot->GetLevel(), bot->GetName().c_str());
|
||||
LOG_DEBUG("playerbots", "Bot {} {}:{} <{}> revives at body", bot->GetGUID().ToString().c_str(),
|
||||
bot->GetTeamId() == TEAM_ALLIANCE ? "A" : "H", bot->GetLevel(), bot->GetName().c_str());
|
||||
|
||||
bot->GetMotionMaster()->Clear();
|
||||
bot->StopMoving();
|
||||
@@ -80,8 +86,8 @@ bool FindCorpseAction::Execute(Event event)
|
||||
// if (master)
|
||||
// {
|
||||
// if (!GET_PLAYERBOT_AI(master) &&
|
||||
// sServerFacade->IsDistanceLessThan(AI_VALUE2(float, "distance", "master target"), sPlayerbotAIConfig->farDistance))
|
||||
// return false;
|
||||
// sServerFacade->IsDistanceLessThan(AI_VALUE2(float, "distance", "master target"),
|
||||
// sPlayerbotAIConfig->farDistance)) return false;
|
||||
// }
|
||||
|
||||
uint32 dCount = AI_VALUE(uint32, "death count");
|
||||
@@ -91,7 +97,8 @@ bool FindCorpseAction::Execute(Event event)
|
||||
if (dCount >= 5)
|
||||
{
|
||||
// LOG_INFO("playerbots", "Bot {} {}:{} <{}>: died too many times, was revived and teleported",
|
||||
// bot->GetGUID().ToString().c_str(), bot->GetTeamId() == TEAM_ALLIANCE ? "A" : "H", bot->GetLevel(), bot->GetName().c_str());
|
||||
// bot->GetGUID().ToString().c_str(), bot->GetTeamId() == TEAM_ALLIANCE ? "A" : "H", bot->GetLevel(),
|
||||
// bot->GetName().c_str());
|
||||
context->GetValue<uint32>("death count")->Set(0);
|
||||
// sRandomPlayerbotMgr->RandomTeleportForLevel(bot);
|
||||
sRandomPlayerbotMgr->Revive(bot);
|
||||
@@ -110,21 +117,21 @@ bool FindCorpseAction::Execute(Event event)
|
||||
|
||||
bool moveToMaster = master && master != bot && masterPos.fDist(corpsePos) < reclaimDist;
|
||||
|
||||
//Should we ressurect? If so, return false.
|
||||
// Should we ressurect? If so, return false.
|
||||
if (corpseDist < reclaimDist)
|
||||
{
|
||||
if (moveToMaster) //We are near master.
|
||||
if (moveToMaster) // We are near master.
|
||||
{
|
||||
if (botPos.fDist(masterPos) < sPlayerbotAIConfig->spellDistance)
|
||||
return false;
|
||||
}
|
||||
else if (deadTime > 8 * MINUTE) //We have walked too long already.
|
||||
else if (deadTime > 8 * MINUTE) // We have walked too long already.
|
||||
return false;
|
||||
else
|
||||
{
|
||||
GuidVector units = AI_VALUE(GuidVector, "possible targets no los");
|
||||
|
||||
if (botPos.getUnitsAggro(units, bot) == 0) //There are no mobs near.
|
||||
if (botPos.getUnitsAggro(units, bot) == 0) // There are no mobs near.
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -149,13 +156,14 @@ bool FindCorpseAction::Execute(Event event)
|
||||
}
|
||||
}
|
||||
|
||||
//Actual mobing part.
|
||||
// Actual mobing part.
|
||||
bool moved = false;
|
||||
|
||||
if (!botAI->AllowActivity(ALL_ACTIVITY))
|
||||
{
|
||||
uint32 delay = sServerFacade->GetDistance2d(bot, corpse) / bot->GetSpeed(MOVE_RUN); //Time a bot would take to travel to it's corpse.
|
||||
delay = std::min(delay, uint32(10 * MINUTE)); //Cap time to get to corpse at 10 minutes.
|
||||
uint32 delay = sServerFacade->GetDistance2d(bot, corpse) /
|
||||
bot->GetSpeed(MOVE_RUN); // Time a bot would take to travel to it's corpse.
|
||||
delay = std::min(delay, uint32(10 * MINUTE)); // Cap time to get to corpse at 10 minutes.
|
||||
|
||||
if (deadTime > delay)
|
||||
{
|
||||
@@ -163,7 +171,7 @@ bool FindCorpseAction::Execute(Event event)
|
||||
bot->TeleportTo(moveToPos.getMapId(), moveToPos.getX(), moveToPos.getY(), moveToPos.getZ(), 0);
|
||||
}
|
||||
|
||||
moved = true;
|
||||
moved = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -171,9 +179,10 @@ bool FindCorpseAction::Execute(Event event)
|
||||
moved = true;
|
||||
else
|
||||
{
|
||||
if (deadTime < 10 * MINUTE && dCount < 5) // Look for corpse up to 30 minutes.
|
||||
if (deadTime < 10 * MINUTE && dCount < 5) // Look for corpse up to 30 minutes.
|
||||
{
|
||||
moved = MoveTo(moveToPos.getMapId(), moveToPos.getX(), moveToPos.getY(), moveToPos.getZ(), false, false);
|
||||
moved =
|
||||
MoveTo(moveToPos.getMapId(), moveToPos.getX(), moveToPos.getY(), moveToPos.getZ(), false, false);
|
||||
}
|
||||
|
||||
if (!moved)
|
||||
@@ -215,7 +224,7 @@ GraveyardStruct const* SpiritHealerAction::GetGrave(bool startZone)
|
||||
return ClosestGrave;
|
||||
}
|
||||
}
|
||||
else if(startZone && AI_VALUE(uint8, "durability"))
|
||||
else if (startZone && AI_VALUE(uint8, "durability"))
|
||||
{
|
||||
TravelTarget* travelTarget = AI_VALUE(TravelTarget*, "travel target");
|
||||
|
||||
@@ -226,9 +235,11 @@ GraveyardStruct const* SpiritHealerAction::GetGrave(bool startZone)
|
||||
{
|
||||
uint32 areaId = 0;
|
||||
uint32 zoneId = 0;
|
||||
sMapMgr->GetZoneAndAreaId(bot->GetPhaseMask(), zoneId, areaId, travelPos.getMapId(), travelPos.getX(), travelPos.getY(), travelPos.getZ());
|
||||
ClosestGrave = sGraveyard->GetClosestGraveyard(travelPos.getMapId(), travelPos.getX(), travelPos.getY(), travelPos.getZ(), bot->GetTeamId(),
|
||||
areaId, zoneId, bot->getClass() == CLASS_DEATH_KNIGHT);
|
||||
sMapMgr->GetZoneAndAreaId(bot->GetPhaseMask(), zoneId, areaId, travelPos.getMapId(), travelPos.getX(),
|
||||
travelPos.getY(), travelPos.getZ());
|
||||
ClosestGrave = sGraveyard->GetClosestGraveyard(travelPos.getMapId(), travelPos.getX(), travelPos.getY(),
|
||||
travelPos.getZ(), bot->GetTeamId(), areaId, zoneId,
|
||||
bot->getClass() == CLASS_DEATH_KNIGHT);
|
||||
|
||||
if (ClosestGrave)
|
||||
return ClosestGrave;
|
||||
@@ -239,9 +250,9 @@ GraveyardStruct const* SpiritHealerAction::GetGrave(bool startZone)
|
||||
std::vector<uint32> races;
|
||||
|
||||
if (bot->GetTeamId() == TEAM_ALLIANCE)
|
||||
races = { RACE_HUMAN, RACE_DWARF, RACE_GNOME, RACE_NIGHTELF };
|
||||
races = {RACE_HUMAN, RACE_DWARF, RACE_GNOME, RACE_NIGHTELF};
|
||||
else
|
||||
races = { RACE_ORC, RACE_TROLL, RACE_TAUREN, RACE_UNDEAD_PLAYER };
|
||||
races = {RACE_ORC, RACE_TROLL, RACE_TAUREN, RACE_UNDEAD_PLAYER};
|
||||
|
||||
float graveDistance = -1;
|
||||
|
||||
@@ -257,9 +268,11 @@ GraveyardStruct const* SpiritHealerAction::GetGrave(bool startZone)
|
||||
|
||||
uint32 areaId = 0;
|
||||
uint32 zoneId = 0;
|
||||
sMapMgr->GetZoneAndAreaId(bot->GetPhaseMask(), zoneId, areaId, info->mapId, info->positionX, info->positionY, info->positionZ);
|
||||
sMapMgr->GetZoneAndAreaId(bot->GetPhaseMask(), zoneId, areaId, info->mapId, info->positionX,
|
||||
info->positionY, info->positionZ);
|
||||
|
||||
NewGrave = sGraveyard->GetClosestGraveyard(info->mapId, info->positionX, info->positionY, info->positionZ, bot->GetTeamId(), areaId, zoneId, cls == CLASS_DEATH_KNIGHT);
|
||||
NewGrave = sGraveyard->GetClosestGraveyard(info->mapId, info->positionX, info->positionY, info->positionZ,
|
||||
bot->GetTeamId(), areaId, zoneId, cls == CLASS_DEATH_KNIGHT);
|
||||
if (!NewGrave)
|
||||
continue;
|
||||
|
||||
@@ -290,7 +303,8 @@ bool SpiritHealerAction::Execute(Event event)
|
||||
uint32 dCount = AI_VALUE(uint32, "death count");
|
||||
int64 deadTime = time(nullptr) - corpse->GetGhostTime();
|
||||
|
||||
GraveyardStruct const* ClosestGrave = GetGrave(dCount > 10 || deadTime > 15 * MINUTE || AI_VALUE(uint8, "durability") < 10);
|
||||
GraveyardStruct const* ClosestGrave =
|
||||
GetGrave(dCount > 10 || deadTime > 15 * MINUTE || AI_VALUE(uint8, "durability") < 10);
|
||||
|
||||
if (bot->GetDistance2d(ClosestGrave->x, ClosestGrave->y) < sPlayerbotAIConfig->sightDistance)
|
||||
{
|
||||
@@ -300,8 +314,8 @@ bool SpiritHealerAction::Execute(Event event)
|
||||
Unit* unit = botAI->GetUnit(*i);
|
||||
if (unit && unit->HasFlag(UNIT_NPC_FLAGS, 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());
|
||||
LOG_DEBUG("playerbots", "Bot {} {}:{} <{}> revives at spirit healer", bot->GetGUID().ToString().c_str(),
|
||||
bot->GetTeamId() == TEAM_ALLIANCE ? "A" : "H", bot->GetLevel(), bot->GetName());
|
||||
PlayerbotChatHandler ch(bot);
|
||||
bot->ResurrectPlayer(0.5f);
|
||||
bot->SpawnCorpseBones();
|
||||
@@ -339,14 +353,11 @@ bool SpiritHealerAction::Execute(Event event)
|
||||
return bot->TeleportTo(ClosestGrave->Map, ClosestGrave->x, ClosestGrave->y, ClosestGrave->z, 0.f);
|
||||
}
|
||||
|
||||
LOG_INFO("playerbots", "Bot {} {}:{} <{}> can't find a spirit healer",
|
||||
bot->GetGUID().ToString().c_str(), bot->GetTeamId() == TEAM_ALLIANCE ? "A" : "H", bot->GetLevel(), bot->GetName().c_str());
|
||||
LOG_INFO("playerbots", "Bot {} {}:{} <{}> can't find a spirit healer", bot->GetGUID().ToString().c_str(),
|
||||
bot->GetTeamId() == TEAM_ALLIANCE ? "A" : "H", bot->GetLevel(), bot->GetName().c_str());
|
||||
|
||||
botAI->TellError("Cannot find any spirit healer nearby");
|
||||
return false;
|
||||
}
|
||||
|
||||
bool SpiritHealerAction::isUseful()
|
||||
{
|
||||
return bot->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_GHOST);
|
||||
}
|
||||
bool SpiritHealerAction::isUseful() { return bot->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_GHOST); }
|
||||
|
||||
Reference in New Issue
Block a user