Skip to content

Commit e5cb8dc

Browse files
authored
Update ImbueAction.cpp
1 parent 467b63b commit e5cb8dc

1 file changed

Lines changed: 31 additions & 34 deletions

File tree

src/strategy/actions/ImbueAction.cpp

Lines changed: 31 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
*/
55

66
#include "ImbueAction.h"
7-
87
#include "Event.h"
98
#include "Playerbots.h"
109

@@ -15,60 +14,59 @@ bool ImbueWithPoisonAction::Execute(Event event)
1514
if (bot->IsInCombat())
1615
return false;
1716

18-
// remove stealth
1917
if (bot->HasAura(SPELL_AURA_MOD_STEALTH))
2018
bot->RemoveAurasByType(SPELL_AURA_MOD_STEALTH);
2119

2220
if (bot->getStandState() != UNIT_STAND_STATE_STAND)
2321
bot->SetStandState(UNIT_STAND_STATE_STAND);
2422

25-
static const std::vector<uint32_t> prioritizedInstantPoisons = {
23+
static const std::vector<uint32_t> prioritizedInstantPoisons =
24+
{
2625
INSTANT_POISON_IX, INSTANT_POISON_VIII, INSTANT_POISON_VII, INSTANT_POISON_VI, INSTANT_POISON_V, INSTANT_POISON_IV,
2726
INSTANT_POISON_III, INSTANT_POISON_II, INSTANT_POISON
2827
};
2928

30-
static const std::vector<uint32_t> prioritizedDeadlyPoisons = {
29+
static const std::vector<uint32_t> prioritizedDeadlyPoisons =
30+
{
3131
DEADLY_POISON_IX, DEADLY_POISON_VIII, DEADLY_POISON_VII, DEADLY_POISON_VI, DEADLY_POISON_V, DEADLY_POISON_IV,
3232
DEADLY_POISON_III, DEADLY_POISON_II, DEADLY_POISON
3333
};
3434

35-
// Check if we have any deadly or instant poisons
3635
Item* deadlyPoison = nullptr;
3736
for (auto id : prioritizedDeadlyPoisons)
3837
{
3938
deadlyPoison = botAI->FindConsumable(id);
40-
if (deadlyPoison) break;
39+
if (deadlyPoison)
40+
break;
4141
}
4242

4343
Item* instantPoison = nullptr;
4444
for (auto id : prioritizedInstantPoisons)
4545
{
4646
instantPoison = botAI->FindConsumable(id);
47-
if (instantPoison) break;
47+
if (instantPoison)
48+
break;
4849
}
4950

51+
bool appliedPoison = false;
52+
5053
// Mainhand
5154
Item* poison = nullptr;
5255
Item* weapon = bot->GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_MAINHAND);
5356
if (weapon && weapon->GetEnchantmentId(TEMP_ENCHANTMENT_SLOT) == 0)
5457
{
5558
if (instantPoison && deadlyPoison)
56-
{
5759
poison = instantPoison;
58-
}
5960
else if (deadlyPoison)
60-
{
6161
poison = deadlyPoison;
62-
}
6362
else if (instantPoison)
64-
{
6563
poison = instantPoison;
66-
}
6764

6865
if (poison)
6966
{
7067
botAI->ImbueItem(poison, EQUIPMENT_SLOT_MAINHAND);
7168
botAI->SetNextCheckDelay(5);
69+
appliedPoison = true;
7270
}
7371
}
7472

@@ -78,46 +76,39 @@ bool ImbueWithPoisonAction::Execute(Event event)
7876
if (weapon && weapon->GetEnchantmentId(TEMP_ENCHANTMENT_SLOT) == 0)
7977
{
8078
if (deadlyPoison && instantPoison)
81-
{
8279
poison = deadlyPoison;
83-
}
8480
else if (instantPoison)
85-
{
8681
poison = instantPoison;
87-
}
8882
else if (deadlyPoison)
89-
{
9083
poison = deadlyPoison;
91-
}
9284

9385
if (poison)
9486
{
9587
botAI->ImbueItem(poison, EQUIPMENT_SLOT_OFFHAND);
9688
botAI->SetNextCheckDelay(5);
89+
appliedPoison = true;
9790
}
9891
}
9992

100-
return true;
93+
return appliedPoison;
10194
}
10295

103-
// Search and apply stone to weapons
10496
ImbueWithStoneAction::ImbueWithStoneAction(PlayerbotAI* botAI) : Action(botAI, "apply stone") {}
10597

10698
bool ImbueWithStoneAction::Execute(Event event)
10799
{
108100
if (bot->IsInCombat())
109101
return false;
110102

111-
// remove stealth
112103
if (bot->HasAura(SPELL_AURA_MOD_STEALTH))
113104
bot->RemoveAurasByType(SPELL_AURA_MOD_STEALTH);
114105

115-
// hp check
116106
if (bot->getStandState() != UNIT_STAND_STATE_STAND)
117107
bot->SetStandState(UNIT_STAND_STATE_STAND);
118108

119-
// Search and apply stone to weapons
120-
// Mainhand ...
109+
bool appliedStone = false;
110+
111+
// Mainhand
121112
Item* stone = nullptr;
122113
Item* weapon = bot->GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_MAINHAND);
123114
if (weapon && weapon->GetEnchantmentId(TEMP_ENCHANTMENT_SLOT) == 0)
@@ -127,10 +118,11 @@ bool ImbueWithStoneAction::Execute(Event event)
127118
{
128119
botAI->ImbueItem(stone, EQUIPMENT_SLOT_MAINHAND);
129120
botAI->SetNextCheckDelay(5);
121+
appliedStone = true;
130122
}
131123
}
132124

133-
//... and offhand
125+
// Offhand
134126
weapon = bot->GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_OFFHAND);
135127
if (weapon && weapon->GetEnchantmentId(TEMP_ENCHANTMENT_SLOT) == 0)
136128
{
@@ -139,29 +131,28 @@ bool ImbueWithStoneAction::Execute(Event event)
139131
{
140132
botAI->ImbueItem(stone, EQUIPMENT_SLOT_OFFHAND);
141133
botAI->SetNextCheckDelay(5);
134+
appliedStone = true;
142135
}
143136
}
144137

145-
return true;
138+
return appliedStone;
146139
}
147140

148-
// Search and apply oil to weapons
149141
ImbueWithOilAction::ImbueWithOilAction(PlayerbotAI* botAI) : Action(botAI, "apply oil") {}
150142

151143
bool ImbueWithOilAction::Execute(Event event)
152144
{
153145
if (bot->IsInCombat())
154146
return false;
155147

156-
// remove stealth
157148
if (bot->HasAura(SPELL_AURA_MOD_STEALTH))
158149
bot->RemoveAurasByType(SPELL_AURA_MOD_STEALTH);
159150

160-
// hp check
161151
if (bot->getStandState() != UNIT_STAND_STATE_STAND)
162152
bot->SetStandState(UNIT_STAND_STATE_STAND);
163153

164-
// Search and apply oil to weapons
154+
bool appliedOil = false;
155+
165156
Item* oil = nullptr;
166157
Item* weapon = bot->GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_MAINHAND);
167158
if (weapon && weapon->GetEnchantmentId(TEMP_ENCHANTMENT_SLOT) == 0)
@@ -171,13 +162,15 @@ bool ImbueWithOilAction::Execute(Event event)
171162
{
172163
botAI->ImbueItem(oil, EQUIPMENT_SLOT_MAINHAND);
173164
botAI->SetNextCheckDelay(5);
165+
appliedOil = true;
174166
}
175167
}
176168

177-
return true;
169+
return appliedOil;
178170
}
179171

180-
static const uint32 uPrioritizedHealingItemIds[19] = {
172+
static const uint32 uPrioritizedHealingItemIds[19] =
173+
{
181174
HEALTHSTONE,
182175
FEL_REGENERATION_POTION,
183176
SUPER_HEALING_POTION,
@@ -207,13 +200,16 @@ bool TryEmergencyAction::Execute(Event event)
207200
if ((botAI->IsHeal(bot)) && (bot->GetPowerPct(POWER_MANA) > 20))
208201
return false;
209202

203+
bool usedHealingItem = false;
204+
210205
// If bot does not have aggro: use bandage instead of potion/stone/crystal
211206
if ((!AI_VALUE(uint8, "my attacker count")) && !bot->HasAura(11196)) // Recently bandaged
212207
{
213208
if (Item* bandage = botAI->FindBandage())
214209
{
215210
botAI->ImbueItem(bandage, bot);
216211
botAI->SetNextCheckDelay(8);
212+
usedHealingItem = true;
217213
}
218214
}
219215

@@ -223,8 +219,9 @@ bool TryEmergencyAction::Execute(Event event)
223219
if (Item* healthItem = botAI->FindConsumable(uPrioritizedHealingItemIds[i]))
224220
{
225221
botAI->ImbueItem(healthItem);
222+
usedHealingItem = true;
226223
}
227224
}
228225

229-
return true;
226+
return usedHealingItem;
230227
}

0 commit comments

Comments
 (0)