Run clang-format

This commit is contained in:
Yunfan Li
2024-08-04 10:23:36 +08:00
parent 44da167492
commit 53611c9040
835 changed files with 35085 additions and 31861 deletions

View File

@@ -1,13 +1,15 @@
/*
* 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 "RpgSubActions.h"
#include "ChooseRpgTargetAction.h"
#include "GuildCreateActions.h"
#include "EmoteAction.h"
#include "Formations.h"
#include "GossipDef.h"
#include "GuildCreateActions.h"
#include "LastMovementValue.h"
#include "MovementActions.h"
#include "Playerbots.h"
@@ -45,15 +47,9 @@ void RpgHelper::AfterExecute(bool doDelay, bool waitForGroup)
setFacing(guidP());
}
GuidPosition RpgHelper::guidP()
{
return AI_VALUE(GuidPosition, "rpg target");
}
GuidPosition RpgHelper::guidP() { return AI_VALUE(GuidPosition, "rpg target"); }
ObjectGuid RpgHelper::guid()
{
return (ObjectGuid)guidP();
}
ObjectGuid RpgHelper::guid() { return (ObjectGuid)guidP(); }
bool RpgHelper::InRange()
{
@@ -62,7 +58,7 @@ bool RpgHelper::InRange()
void RpgHelper::setFacingTo(GuidPosition guidPosition)
{
bot->SetFacingTo(guidPosition.getAngleTo(bot)+ static_cast<float>(M_PI));
bot->SetFacingTo(guidPosition.getAngleTo(bot) + static_cast<float>(M_PI));
}
void RpgHelper::setFacing(GuidPosition guidPosition)
@@ -73,9 +69,9 @@ void RpgHelper::setFacing(GuidPosition guidPosition)
if (guidPosition.IsPlayer())
return;
// Unit* unit = guidPosition.GetUnit();
// Unit* unit = guidPosition.GetUnit();
// unit->SetFacingTo(unit->GetAngle(bot));
// unit->SetFacingTo(unit->GetAngle(bot));
}
void RpgHelper::setDelay(bool waitForGroup)
@@ -86,15 +82,9 @@ void RpgHelper::setDelay(bool waitForGroup)
botAI->SetNextCheckDelay(sPlayerbotAIConfig->rpgDelay / 5);
}
bool RpgSubAction::isPossible()
{
return rpg->guidP() && rpg->guidP().GetWorldObject();
}
bool RpgSubAction::isPossible() { return rpg->guidP() && rpg->guidP().GetWorldObject(); }
bool RpgSubAction::isUseful()
{
return rpg->InRange();
}
bool RpgSubAction::isUseful() { return rpg->InRange(); }
bool RpgSubAction::Execute(Event event)
{
@@ -103,20 +93,11 @@ bool RpgSubAction::Execute(Event event)
return doAction;
}
std::string const RpgSubAction::ActionName()
{
return "none";
}
std::string const RpgSubAction::ActionName() { return "none"; }
Event RpgSubAction::ActionEvent(Event event)
{
return event;
}
Event RpgSubAction::ActionEvent(Event event) { return event; }
bool RpgStayAction::isUseful()
{
return rpg->InRange() && !botAI->HasRealPlayerMaster();
}
bool RpgStayAction::isUseful() { return rpg->InRange() && !botAI->HasRealPlayerMaster(); }
bool RpgStayAction::Execute(Event event)
{
@@ -126,10 +107,7 @@ bool RpgStayAction::Execute(Event event)
return true;
}
bool RpgWorkAction::isUseful()
{
return rpg->InRange() && !botAI->HasRealPlayerMaster();
}
bool RpgWorkAction::isUseful() { return rpg->InRange() && !botAI->HasRealPlayerMaster(); }
bool RpgWorkAction::Execute(Event event)
{
@@ -138,10 +116,7 @@ bool RpgWorkAction::Execute(Event event)
return true;
}
bool RpgEmoteAction::isUseful()
{
return rpg->InRange() && !botAI->HasRealPlayerMaster();
}
bool RpgEmoteAction::isUseful() { return rpg->InRange() && !botAI->HasRealPlayerMaster(); }
bool RpgEmoteAction::Execute(Event event)
{
@@ -165,10 +140,7 @@ bool RpgCancelAction::Execute(Event event)
return true;
}
bool RpgTaxiAction::isUseful()
{
return rpg->InRange() && !botAI->HasRealPlayerMaster();
}
bool RpgTaxiAction::isUseful() { return rpg->InRange() && !botAI->HasRealPlayerMaster(); }
bool RpgTaxiAction::Execute(Event event)
{
@@ -177,7 +149,8 @@ bool RpgTaxiAction::Execute(Event event)
WorldPacket emptyPacket;
bot->GetSession()->HandleCancelMountAuraOpcode(emptyPacket);
uint32 node = sObjectMgr->GetNearestTaxiNode(guidP.getX(), guidP.getY(), guidP.getZ(), guidP.getMapId(), bot->GetTeamId());
uint32 node =
sObjectMgr->GetNearestTaxiNode(guidP.getX(), guidP.getY(), guidP.getZ(), guidP.getMapId(), bot->GetTeamId());
std::vector<uint32> nodes;
for (uint32 i = 0; i < sTaxiPathStore.GetNumRows(); ++i)
@@ -209,18 +182,19 @@ bool RpgTaxiAction::Execute(Event event)
Creature* flightMaster = bot->GetNPCIfCanInteractWith(guidP, UNIT_NPC_FLAG_FLIGHTMASTER);
if (!flightMaster)
{
LOG_ERROR("playerbots", "Bot {} cannot talk to flightmaster ({} location available)", bot->GetName(), nodes.size());
LOG_ERROR("playerbots", "Bot {} cannot talk to flightmaster ({} location available)", bot->GetName(),
nodes.size());
return false;
}
if (!bot->ActivateTaxiPathTo({ entry->from, entry->to }, flightMaster, 0))
if (!bot->ActivateTaxiPathTo({entry->from, entry->to}, flightMaster, 0))
{
LOG_ERROR("playerbots", "Bot {} cannot fly {} ({} location available)", bot->GetName(), path, nodes.size());
return false;
}
LOG_INFO("playerbots", "Bot {} <{}> is flying from {} to {} ({} location available)",
bot->GetGUID().ToString().c_str(), bot->GetName(), nodeFrom->name[0], nodeTo->name[0], nodes.size());
bot->GetGUID().ToString().c_str(), bot->GetName(), nodeFrom->name[0], nodeTo->name[0], nodes.size());
bot->SetMoney(money);
@@ -233,7 +207,8 @@ bool RpgDiscoverAction::Execute(Event event)
{
GuidPosition guidP = rpg->guidP();
uint32 node = sObjectMgr->GetNearestTaxiNode(guidP.getX(), guidP.getY(), guidP.getZ(), guidP.getMapId(), bot->GetTeamId());
uint32 node =
sObjectMgr->GetNearestTaxiNode(guidP.getX(), guidP.getY(), guidP.getZ(), guidP.getMapId(), bot->GetTeamId());
if (!node)
return false;
@@ -245,10 +220,7 @@ bool RpgDiscoverAction::Execute(Event event)
return bot->GetSession()->SendLearnNewTaxiNode(flightMaster);
}
std::string const RpgStartQuestAction::ActionName()
{
return "accept all quests";
}
std::string const RpgStartQuestAction::ActionName() { return "accept all quests"; }
Event RpgStartQuestAction::ActionEvent(Event event)
{
@@ -258,10 +230,7 @@ Event RpgStartQuestAction::ActionEvent(Event event)
return Event("rpg action", p);
}
std::string const RpgEndQuestAction::ActionName()
{
return "talk to quest giver";
}
std::string const RpgEndQuestAction::ActionName() { return "talk to quest giver"; }
Event RpgEndQuestAction::ActionEvent(Event event)
{
@@ -271,35 +240,17 @@ Event RpgEndQuestAction::ActionEvent(Event event)
return Event("rpg action", p);
}
std::string const RpgBuyAction::ActionName()
{
return "buy";
}
std::string const RpgBuyAction::ActionName() { return "buy"; }
Event RpgBuyAction::ActionEvent(Event event)
{
return Event("rpg action", "vendor");
}
Event RpgBuyAction::ActionEvent(Event event) { return Event("rpg action", "vendor"); }
std::string const RpgSellAction::ActionName()
{
return "sell";
}
std::string const RpgSellAction::ActionName() { return "sell"; }
Event RpgSellAction::ActionEvent(Event event)
{
return Event("rpg action", "vendor");
}
Event RpgSellAction::ActionEvent(Event event) { return Event("rpg action", "vendor"); }
std::string const RpgRepairAction::ActionName()
{
return "repair";
}
std::string const RpgRepairAction::ActionName() { return "repair"; }
std::string const RpgTrainAction::ActionName()
{
return "trainer";
}
std::string const RpgTrainAction::ActionName() { return "trainer"; }
bool RpgHealAction::Execute(Event event)
{
@@ -311,59 +262,44 @@ bool RpgHealAction::Execute(Event event)
retVal = botAI->DoSpecificAction("lesser heal on party", Event(), true);
break;
case CLASS_DRUID:
retVal=botAI->DoSpecificAction("healing touch on party", Event(), true);
retVal = botAI->DoSpecificAction("healing touch on party", Event(), true);
break;
case CLASS_PALADIN:
retVal=botAI->DoSpecificAction("holy light on party", Event(), true);
retVal = botAI->DoSpecificAction("holy light on party", Event(), true);
break;
case CLASS_SHAMAN:
retVal=botAI->DoSpecificAction("healing wave on party", Event(), true);
retVal = botAI->DoSpecificAction("healing wave on party", Event(), true);
break;
}
return retVal;
}
std::string const RpgHomeBindAction::ActionName()
{
return "home";
}
std::string const RpgHomeBindAction::ActionName() { return "home"; }
std::string const RpgQueueBgAction::ActionName()
{
SET_AI_VALUE(uint32, "bg type", (uint32) AI_VALUE(BattlegroundTypeId, "rpg bg type"));
SET_AI_VALUE(uint32, "bg type", (uint32)AI_VALUE(BattlegroundTypeId, "rpg bg type"));
return "free bg join";
}
std::string const RpgBuyPetitionAction::ActionName()
{
return "buy petition";
}
std::string const RpgBuyPetitionAction::ActionName() { return "buy petition"; }
std::string const RpgUseAction::ActionName()
{
return "use";
}
std::string const RpgUseAction::ActionName() { return "use"; }
Event RpgUseAction::ActionEvent(Event event)
{
return Event("rpg action", chat->FormatWorldobject(rpg->guidP().GetWorldObject()));
}
std::string const RpgSpellAction::ActionName()
{
return "cast random spell";
}
std::string const RpgSpellAction::ActionName() { return "cast random spell"; }
Event RpgSpellAction::ActionEvent(Event event)
{
return Event("rpg action", chat->FormatWorldobject(rpg->guidP().GetWorldObject()));
}
std::string const RpgCraftAction::ActionName()
{
return "craft random item";
}
std::string const RpgCraftAction::ActionName() { return "craft random item"; }
Event RpgCraftAction::ActionEvent(Event event)
{
@@ -379,11 +315,12 @@ std::vector<Item*> RpgTradeUsefulAction::CanGiveItems(GuidPosition guidPosition)
if (botAI->HasActivePlayerMaster() || !GET_PLAYERBOT_AI(player))
return giveItems;
std::vector<ItemUsage> myUsages = { ITEM_USAGE_NONE , ITEM_USAGE_VENDOR, ITEM_USAGE_AH, ITEM_USAGE_DISENCHANT };
std::vector<ItemUsage> myUsages = {ITEM_USAGE_NONE, ITEM_USAGE_VENDOR, ITEM_USAGE_AH, ITEM_USAGE_DISENCHANT};
for (auto& myUsage : myUsages)
{
std::vector<Item*> myItems = AI_VALUE2(std::vector<Item*>, "inventory items", "usage " + std::to_string(myUsage));
std::vector<Item*> myItems =
AI_VALUE2(std::vector<Item*>, "inventory items", "usage " + std::to_string(myUsage));
std::reverse(myItems.begin(), myItems.end());
for (auto& item : myItems)
@@ -433,13 +370,18 @@ bool RpgTradeUsefulAction::Execute(Event event)
if (bot->GetTradeData() && bot->GetTradeData()->HasItem(item->GetGUID()))
{
if (bot->GetGroup() && bot->GetGroup()->IsMember(guidP) && botAI->HasRealPlayerMaster())
botAI->TellMasterNoFacing("You can use this " + chat->FormatItem(item->GetTemplate()) + " better than me, " + guidP.GetPlayer()->GetName() /*chat->FormatWorldobject(guidP.GetPlayer())*/ + ".");
botAI->TellMasterNoFacing(
"You can use this " + chat->FormatItem(item->GetTemplate()) + " better than me, " +
guidP.GetPlayer()->GetName() /*chat->FormatWorldobject(guidP.GetPlayer())*/ + ".");
else
bot->Say("You can use this " + chat->FormatItem(item->GetTemplate()) + " better than me, " + player->GetName() /*chat->FormatWorldobject(player)*/ + ".", (bot->GetTeamId() == TEAM_ALLIANCE ? LANG_COMMON : LANG_ORCISH));
bot->Say("You can use this " + chat->FormatItem(item->GetTemplate()) + " better than me, " +
player->GetName() /*chat->FormatWorldobject(player)*/ + ".",
(bot->GetTeamId() == TEAM_ALLIANCE ? LANG_COMMON : LANG_ORCISH));
if (!urand(0, 4) || items.size() < 2)
{
//bot->Say("End trade with" + chat->FormatWorldobject(player), (bot->GetTeamId() == TEAM_ALLIANCE ? LANG_COMMON : LANG_ORCISH));
// bot->Say("End trade with" + chat->FormatWorldobject(player), (bot->GetTeamId() == TEAM_ALLIANCE ?
// LANG_COMMON : LANG_ORCISH));
WorldPacket p;
uint32 status = TRADE_STATUS_TRADE_ACCEPT;
p << status;
@@ -447,7 +389,8 @@ bool RpgTradeUsefulAction::Execute(Event event)
}
}
else
bot->Say("Start trade with" + chat->FormatWorldobject(player), (bot->GetTeamId() == TEAM_ALLIANCE ? LANG_COMMON : LANG_ORCISH));
bot->Say("Start trade with" + chat->FormatWorldobject(player),
(bot->GetTeamId() == TEAM_ALLIANCE ? LANG_COMMON : LANG_ORCISH));
botAI->SetNextCheckDelay(sPlayerbotAIConfig->rpgDelay);
return true;
@@ -482,10 +425,10 @@ bool RpgDuelAction::Execute(Event event)
if (!player)
return false;
return botAI->DoSpecificAction("cast custom spell", Event("rpg action", chat->FormatWorldobject(player) + " 7266"), true);
return botAI->DoSpecificAction("cast custom spell", Event("rpg action", chat->FormatWorldobject(player) + " 7266"),
true);
}
bool RpgMountAnimAction::isUseful()
{
return AI_VALUE2(bool, "mounted", "self target") && !AI_VALUE2(bool, "moving", "self target");