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,8 +1,10 @@
/*
* 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 "CheckMountStateAction.h"
#include "BattlegroundWS.h"
#include "Event.h"
#include "PlayerbotAI.h"
@@ -12,18 +14,23 @@
bool CheckMountStateAction::Execute(Event event)
{
bool noattackers = AI_VALUE2(bool, "combat", "self target") ? (AI_VALUE(uint8, "attacker count") > 0 ? false : true) : true;
bool noattackers =
AI_VALUE2(bool, "combat", "self target") ? (AI_VALUE(uint8, "attacker count") > 0 ? false : true) : true;
bool enemy = AI_VALUE(Unit*, "enemy player target");
// ignore grind target in BG or bots will dismount near any creature (eg: the rams in AV)
bool dps = (AI_VALUE(Unit*, "dps target") || (!bot->InBattleground() && AI_VALUE(Unit*, "grind target")));
bool fartarget = (enemy && sServerFacade->IsDistanceGreaterThan(AI_VALUE2(float, "distance", "enemy player target"), 40.0f)) ||
bool fartarget =
(enemy && sServerFacade->IsDistanceGreaterThan(AI_VALUE2(float, "distance", "enemy player target"), 40.0f)) ||
(dps && sServerFacade->IsDistanceGreaterThan(AI_VALUE2(float, "distance", "dps target"), 50.0f));
bool attackdistance = false;
bool chasedistance = false;
float attack_distance = 35.0f;
if (PlayerbotAI::IsMelee(bot)) {
if (PlayerbotAI::IsMelee(bot))
{
attack_distance = 10.0f;
} else {
}
else
{
attack_distance = 40.0f;
}
if (enemy)
@@ -31,11 +38,15 @@ bool CheckMountStateAction::Execute(Event event)
if (dps || enemy)
{
attackdistance = (enemy || dps) && sServerFacade->IsDistanceLessThan(AI_VALUE2(float, "distance", "current target"), attack_distance);
chasedistance = enemy && sServerFacade->IsDistanceGreaterThan(AI_VALUE2(float, "distance", "enemy player target"), 45.0f) && AI_VALUE2(bool, "moving", "enemy player target");
attackdistance = (enemy || dps) && sServerFacade->IsDistanceLessThan(
AI_VALUE2(float, "distance", "current target"), attack_distance);
chasedistance =
enemy && sServerFacade->IsDistanceGreaterThan(AI_VALUE2(float, "distance", "enemy player target"), 45.0f) &&
AI_VALUE2(bool, "moving", "enemy player target");
}
if (bot->IsMounted() && attackdistance) {
if (bot->IsMounted() && attackdistance)
{
WorldPacket emptyPacket;
bot->GetSession()->HandleCancelMountAuraOpcode(emptyPacket);
return true;
@@ -48,7 +59,8 @@ bool CheckMountStateAction::Execute(Event event)
return false;
// bool farFromMaster = sServerFacade->GetDistance2d(bot, master) > sPlayerbotAIConfig->sightDistance;
if (master->IsMounted() && !bot->IsMounted() && noattackers && !attackdistance && !bot->IsInCombat() && botAI->GetState() != BOT_STATE_COMBAT)
if (master->IsMounted() && !bot->IsMounted() && noattackers && !attackdistance && !bot->IsInCombat() &&
botAI->GetState() != BOT_STATE_COMBAT)
{
return Mount();
}
@@ -59,7 +71,8 @@ bool CheckMountStateAction::Execute(Event event)
bot->GetSession()->HandleCancelMountAuraOpcode(emptyPacket);
return true;
}
// if (!bot->IsMounted() && (chasedistance || (farFromMaster && botAI->HasStrategy("follow", BOT_STATE_NON_COMBAT))) && !bot->IsInCombat() && !dps)
// if (!bot->IsMounted() && (chasedistance || (farFromMaster && botAI->HasStrategy("follow",
// BOT_STATE_NON_COMBAT))) && !bot->IsInCombat() && !dps)
// return Mount();
// if (!bot->IsFlying() && ((!farFromMaster && !master->IsMounted()) || attackdistance) && bot->IsMounted())
@@ -73,17 +86,20 @@ bool CheckMountStateAction::Execute(Event event)
}
// For random bots
if (!bot->InBattleground() && !master) {
if (!bot->IsMounted() && noattackers && !attackdistance && !bot->IsInCombat()) {
if (!bot->InBattleground() && !master)
{
if (!bot->IsMounted() && noattackers && !attackdistance && !bot->IsInCombat())
{
return Mount();
}
}
if (bot->InBattleground() && !attackdistance && (noattackers || fartarget) && !bot->IsInCombat() && !bot->IsMounted())
if (bot->InBattleground() && !attackdistance && (noattackers || fartarget) && !bot->IsInCombat() &&
!bot->IsMounted())
{
if (bot->GetBattlegroundTypeId() == BATTLEGROUND_WS)
{
BattlegroundWS *bg = (BattlegroundWS*)botAI->GetBot()->GetBattleground();
BattlegroundWS* bg = (BattlegroundWS*)botAI->GetBot()->GetBattleground();
if (bot->HasAura(23333) || bot->HasAura(23335))
{
return false;
@@ -97,11 +113,13 @@ bool CheckMountStateAction::Execute(Event event)
// {
// if (AI_VALUE(GuidPosition, "rpg target"))
// {
// if (sServerFacade->IsDistanceGreaterThan(AI_VALUE2(float, "distance", "rpg target"), sPlayerbotAIConfig->farDistance) && noattackers && !dps && !enemy)
// if (sServerFacade->IsDistanceGreaterThan(AI_VALUE2(float, "distance", "rpg target"),
// sPlayerbotAIConfig->farDistance) && noattackers && !dps && !enemy)
// return Mount();
// }
// if (((!AI_VALUE(GuidVector, "possible rpg targets").empty()) && noattackers && !dps && !enemy) && urand(0, 100) > 50)
// if (((!AI_VALUE(GuidVector, "possible rpg targets").empty()) && noattackers && !dps && !enemy) && urand(0,
// 100) > 50)
// return Mount();
// }
@@ -175,8 +193,8 @@ bool CheckMountStateAction::Mount()
// bot->GetMotionMaster()->MoveIdle();
}
Player* master = GetMaster();
botAI->RemoveShapeshift();
Player* master = GetMaster();
botAI->RemoveShapeshift();
botAI->RemoveAura("tree of life");
int32 masterSpeed = 59;
SpellInfo const* masterSpell = nullptr;
@@ -213,7 +231,7 @@ bool CheckMountStateAction::Mount()
bool hasSwiftMount = false;
//std::map<int32, std::vector<uint32> > spells;
// std::map<int32, std::vector<uint32> > spells;
std::map<uint32, std::map<int32, std::vector<uint32>>> allSpells;
for (PlayerSpellMap::iterator itr = bot->GetSpellMap().begin(); itr != bot->GetSpellMap().end(); ++itr)
{
@@ -226,16 +244,20 @@ bool CheckMountStateAction::Mount()
continue;
int32 effect = std::max(spellInfo->Effects[1].BasePoints, spellInfo->Effects[2].BasePoints);
//if (effect < masterSpeed)
//continue;
// if (effect < masterSpeed)
// continue;
uint32 index = (spellInfo->Effects[1].ApplyAuraName == SPELL_AURA_MOD_INCREASE_MOUNTED_FLIGHT_SPEED ||
spellInfo->Effects[2].ApplyAuraName == SPELL_AURA_MOD_INCREASE_MOUNTED_FLIGHT_SPEED) ? 1 : 0;
spellInfo->Effects[2].ApplyAuraName == SPELL_AURA_MOD_INCREASE_MOUNTED_FLIGHT_SPEED)
? 1
: 0;
if (index == 0 && std::max(spellInfo->Effects[EFFECT_1].BasePoints, spellInfo->Effects[EFFECT_2].BasePoints) > 59)
if (index == 0 &&
std::max(spellInfo->Effects[EFFECT_1].BasePoints, spellInfo->Effects[EFFECT_2].BasePoints) > 59)
hasSwiftMount = true;
if (index == 1 && std::max(spellInfo->Effects[EFFECT_1].BasePoints, spellInfo->Effects[EFFECT_2].BasePoints) > 149)
if (index == 1 &&
std::max(spellInfo->Effects[EFFECT_1].BasePoints, spellInfo->Effects[EFFECT_2].BasePoints) > 149)
hasSwiftMount = true;
allSpells[index][effect].push_back(spellId);
@@ -245,7 +267,9 @@ bool CheckMountStateAction::Mount()
if (masterSpell)
{
masterMountType = (masterSpell->Effects[1].ApplyAuraName == SPELL_AURA_MOD_INCREASE_MOUNTED_FLIGHT_SPEED ||
masterSpell->Effects[2].ApplyAuraName == SPELL_AURA_MOD_INCREASE_MOUNTED_FLIGHT_SPEED) ? 1 : 0;
masterSpell->Effects[2].ApplyAuraName == SPELL_AURA_MOD_INCREASE_MOUNTED_FLIGHT_SPEED)
? 1
: 0;
}
std::map<int32, std::vector<uint32>>& spells = allSpells[masterMountType];
@@ -260,10 +284,12 @@ bool CheckMountStateAction::Mount()
if (!spellInfo)
continue;
if (masterMountType == 0 && masterSpeed > 59 && std::max(spellInfo->Effects[EFFECT_1].BasePoints, spellInfo->Effects[EFFECT_2].BasePoints) < 99)
if (masterMountType == 0 && masterSpeed > 59 &&
std::max(spellInfo->Effects[EFFECT_1].BasePoints, spellInfo->Effects[EFFECT_2].BasePoints) < 99)
spells[59].clear();
if (masterMountType == 1 && masterSpeed > 149 && std::max(spellInfo->Effects[EFFECT_1].BasePoints, spellInfo->Effects[EFFECT_2].BasePoints) < 279)
if (masterMountType == 1 && masterSpeed > 149 &&
std::max(spellInfo->Effects[EFFECT_1].BasePoints, spellInfo->Effects[EFFECT_2].BasePoints) < 279)
spells[149].clear();
}
}
@@ -276,8 +302,8 @@ bool CheckMountStateAction::Mount()
if (index >= ids.size())
continue;
return botAI->CastSpell(ids[index], bot);;
return botAI->CastSpell(ids[index], bot);
;
}
std::vector<Item*> items = AI_VALUE2(std::vector<Item*>, "inventory items", "mount");