Skip to content

Commit 66a66bb

Browse files
committed
NPCBots: CalculateAoeSpots() clean up
1 parent 5892bbe commit 66a66bb

File tree

2 files changed

+46
-64
lines changed

2 files changed

+46
-64
lines changed

src/server/game/AI/NpcBots/bot_ai.cpp

Lines changed: 38 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -5228,9 +5228,8 @@ void bot_ai::CalculateAoeSpots(Unit const* unit, AoeSpotsVec& spots)
52285228
// Ruins of Ahn'Qiraj (AQ20) — Sand Trap avoidance
52295229
else if (unit->GetMapId() == 509)
52305230
{
5231-
static const uint32 GO_SAND_TRAP = 180647; // Sand Trap
52325231
std::list<GameObject*> sandTrapList;
5233-
Bcore::AllGameObjectsWithEntryInRange trapCheck(unit, GO_SAND_TRAP, 60.f);
5232+
Bcore::AllGameObjectsWithEntryInRange trapCheck(unit, GAMEOBJECT_SAND_TRAP, 60.f);
52345233
Bcore::GameObjectListSearcher trapSearcher(unit, sandTrapList, trapCheck);
52355234
Cell::VisitObjects(unit, trapSearcher, 40.f);
52365235

@@ -5245,7 +5244,7 @@ void bot_ai::CalculateAoeSpots(Unit const* unit, AoeSpotsVec& spots)
52455244
else if (unit->GetMapId() == 531)
52465245
{
52475246
static const uint32 AURA_EXPLODE = 804;
5248-
static const std::array<uint32, 2> MutatingBugIds = { 15316u, 15317u };
5247+
static const std::array<uint32, 2> MutatingBugIds = { CREATURE_MUTATING_BUG_1, CREATURE_MUTATING_BUG_2 };
52495248
std::list<Creature*> cList;
52505249
auto bug_check = [](Creature const* c) {
52515250
return c && c->IsAlive() && std::ranges::find(MutatingBugIds, c->GetEntry()) != MutatingBugIds.cend() && c->HasAura(AURA_EXPLODE);
@@ -5261,6 +5260,42 @@ void bot_ai::CalculateAoeSpots(Unit const* unit, AoeSpotsVec& spots)
52615260
spots.emplace_back(*c, radius);
52625261
}
52635262
}
5263+
// The Blood Furnace — Proximity Bombs
5264+
else if (unit->GetMapId() == 542)
5265+
{
5266+
std::list<GameObject*> proximityBombList;
5267+
static const std::array<uint32, 2> ProximityBombIds = { GAMEOBJECT_PROXIMITY_BOMB_N, GAMEOBJECT_PROXIMITY_BOMB_N };
5268+
auto bomb_check = [](GameObject const* go) { return go && std::ranges::find(ProximityBombIds, go->GetEntry()) != ProximityBombIds.cend(); };
5269+
Bcore::GameObjectListSearcher bombSearcher(unit, proximityBombList, bomb_check);
5270+
Cell::VisitObjects(unit, bombSearcher, 40.f);
5271+
5272+
if (!proximityBombList.empty())
5273+
{
5274+
for (GameObject const* go : proximityBombList)
5275+
{
5276+
float radius = 10.0f + go->GetObjectSize() + DEFAULT_COMBAT_REACH * 1.5f;
5277+
spots.emplace_back(*go, radius);
5278+
}
5279+
}
5280+
}
5281+
// Hellfire Ramparts — Liquid Fire puddles
5282+
if (unit->GetMapId() == 543) // Hellfire Ramparts
5283+
{
5284+
std::list<GameObject*> liquidFireList;
5285+
static const std::array<uint32, 3> LiquidFireIds = { GAMEOBJECT_LIQUID_FIRE_1, GAMEOBJECT_LIQUID_FIRE_2, GAMEOBJECT_LIQUID_FIRE_3 };
5286+
auto fire_check = [](GameObject const* go) { return go && std::ranges::find(LiquidFireIds, go->GetEntry()) != LiquidFireIds.cend(); };
5287+
Bcore::GameObjectListSearcher fireSearcher(unit, liquidFireList, fire_check);
5288+
Cell::VisitObjects(unit, fireSearcher, 40.f);
5289+
5290+
if (!liquidFireList.empty())
5291+
{
5292+
for (GameObject const* go : liquidFireList)
5293+
{
5294+
float radius = 10.0f + go->GetObjectSize() + DEFAULT_COMBAT_REACH * 1.5f;
5295+
spots.emplace_back(*go, radius);
5296+
}
5297+
}
5298+
}
52645299
//Aucheai Crypts
52655300
else if (unit->GetMapId() == 558)
52665301
{
@@ -5278,67 +5313,6 @@ void bot_ai::CalculateAoeSpots(Unit const* unit, AoeSpotsVec& spots)
52785313
spots.emplace_back(*creature, radius);
52795314
}
52805315
}
5281-
// Hellfire Ramparts — Liquid Fire puddles
5282-
if (unit->GetMapId() == 543) // Hellfire Ramparts
5283-
{
5284-
// GO entries to avoid
5285-
static constexpr uint32 GO_LIQUID_FIRE_1 = 180125;
5286-
static constexpr uint32 GO_LIQUID_FIRE_2 = 181890;
5287-
static constexpr uint32 GO_LIQUID_FIRE_3 = 182533;
5288-
5289-
auto scanGoEntry = [unit, &spots](uint32 entry, float scanRange, float baseRadius)
5290-
{
5291-
std::list<GameObject*> list;
5292-
Bcore::AllGameObjectsWithEntryInRange check(unit, entry, scanRange);
5293-
Bcore::GameObjectListSearcher<Bcore::AllGameObjectsWithEntryInRange> searcher(unit, list, check);
5294-
Cell::VisitObjects(unit, searcher, scanRange);
5295-
5296-
for (GameObject* go : list)
5297-
{
5298-
if (!go)
5299-
continue;
5300-
5301-
float radius = baseRadius + go->GetObjectSize() + DEFAULT_COMBAT_REACH * 1.2f;
5302-
spots.emplace_back(*go, radius);
5303-
}
5304-
};
5305-
5306-
constexpr float SCAN = 40.f;
5307-
constexpr float BASE = 12.0f;
5308-
5309-
scanGoEntry(GO_LIQUID_FIRE_1, SCAN, BASE);
5310-
scanGoEntry(GO_LIQUID_FIRE_2, SCAN, BASE);
5311-
scanGoEntry(GO_LIQUID_FIRE_3, SCAN, BASE);
5312-
}
5313-
// The Blood Furnace — Proximity Bombs
5314-
else if (unit->GetMapId() == 542)
5315-
{
5316-
static constexpr uint32 GO_PROXIMITY_BOMB_A = 181877;
5317-
static constexpr uint32 GO_PROXIMITY_BOMB_B = 182607;
5318-
5319-
auto scanBombs = [unit, &spots](uint32 entry, float scanRange, float baseRadius)
5320-
{
5321-
std::list<GameObject*> bombs;
5322-
Bcore::AllGameObjectsWithEntryInRange check(unit, entry, scanRange);
5323-
Bcore::GameObjectListSearcher<Bcore::AllGameObjectsWithEntryInRange> searcher(unit, bombs, check);
5324-
Cell::VisitObjects(unit, searcher, scanRange);
5325-
5326-
for (GameObject* go : bombs)
5327-
{
5328-
if (!go)
5329-
continue;
5330-
5331-
float radius = baseRadius + go->GetObjectSize() + DEFAULT_COMBAT_REACH * 1.5f;
5332-
spots.emplace_back(*go, radius);
5333-
}
5334-
};
5335-
5336-
constexpr float SCAN_RANGE = 40.f;
5337-
constexpr float BOMB_BASE_RADIUS = 10.0f;
5338-
5339-
scanBombs(GO_PROXIMITY_BOMB_A, SCAN_RANGE, BOMB_BASE_RADIUS);
5340-
scanBombs(GO_PROXIMITY_BOMB_B, SCAN_RANGE, BOMB_BASE_RADIUS);
5341-
}
53425316
//Magister's Terrace
53435317
else if (unit->GetMapId() == 585)
53445318
{

src/server/game/AI/NpcBots/botcommon.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,8 @@ enum BotCommonValues
9595
CREATURE_ICC_MUTATED_ABOMINATION8 = 38787,
9696
CREATURE_GEARGRINDERS_JUMPBOT = 31784,
9797
//COMMON AOE TRIGGERS
98+
CREATURE_MUTATING_BUG_1 = 15316,
99+
CREATURE_MUTATING_BUG_2 = 15317,
98100
CREATURE_FOCUS_FIRE_N = 18374,
99101
CREATURE_FOCUS_FIRE_H = 20308,
100102
CREATURE_MT_PHOENIX = 24674,
@@ -106,6 +108,12 @@ enum BotCommonValues
106108
CREATURE_EOE_STATIC_FIELD = 30592,
107109
CREATURE_ICC_OOZE_PUDDLE = 37690,
108110
GAMEOBJECT_HOT_COAL = 178164,
111+
GAMEOBJECT_SAND_TRAP = 180647,
112+
GAMEOBJECT_LIQUID_FIRE_1 = 180125,
113+
GAMEOBJECT_LIQUID_FIRE_2 = 181890,
114+
GAMEOBJECT_LIQUID_FIRE_3 = 182533,
115+
GAMEOBJECT_PROXIMITY_BOMB_N = 181877,
116+
GAMEOBJECT_PROXIMITY_BOMB_H = 182607,
109117
//COMMON ENEMY CREATURES
110118
CREATURE_BOSS_EREGOS_N = 27656,
111119
CREATURE_BOSS_EREGOS_H = 31561,

0 commit comments

Comments
 (0)