Skip to content

Commit 5b51bc3

Browse files
committed
Rogue combat strategy fixes
1 parent 46f8d75 commit 5b51bc3

9 files changed

Lines changed: 157 additions & 20 deletions

src/modules/Bots/playerbot/strategy/rogue/DpsRogueStrategy.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,17 @@ void DpsRogueStrategy::InitTriggers(std::list<TriggerNode*> &triggers)
8585
MeleeCombatStrategy::InitTriggers(triggers);
8686

8787
triggers.push_back(new TriggerNode(
88-
"combo points available",
88+
"slice and dice",
89+
NextAction::array(0, new NextAction("slice and dice", ACTION_HIGH + 3), NULL)));
90+
91+
triggers.push_back(new TriggerNode(
92+
"combo points for target available",
8993
NextAction::array(0, new NextAction("rupture", ACTION_HIGH + 2), NULL)));
9094

95+
triggers.push_back(new TriggerNode(
96+
"expose armor",
97+
NextAction::array(0, new NextAction("expose armor", ACTION_HIGH + 1), NULL)));
98+
9199
triggers.push_back(new TriggerNode(
92100
"medium threat",
93101
NextAction::array(0, new NextAction("vanish", ACTION_HIGH), NULL)));

src/modules/Bots/playerbot/strategy/rogue/GenericRogueNonCombatStrategy.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,7 @@ void GenericRogueNonCombatStrategy::InitTriggers(std::list<TriggerNode*> &trigge
1111
{
1212
NonCombatStrategy::InitTriggers(triggers);
1313

14+
triggers.push_back(new TriggerNode(
15+
"stealth",
16+
NextAction::array(0, new NextAction("stealth", ACTION_NORMAL), NULL)));
1417
}

src/modules/Bots/playerbot/strategy/rogue/RogueActions.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,4 +60,10 @@ namespace ai
6060
public:
6161
CastKickOnEnemyHealerAction(PlayerbotAI* ai) : CastSpellOnEnemyHealerAction(ai, "kick") {}
6262
};
63+
64+
class CastStealthAction : public CastBuffSpellAction
65+
{
66+
public:
67+
CastStealthAction(PlayerbotAI* ai) : CastBuffSpellAction(ai, "stealth") {}
68+
};
6369
}

src/modules/Bots/playerbot/strategy/rogue/RogueAiObjectContext.cpp

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#include "RogueAiObjectContext.h"
66
#include "DpsRogueStrategy.h"
77
#include "GenericRogueNonCombatStrategy.h"
8-
#include "../generic/PullStrategy.h"
8+
#include "RogueAmbushStrategy.h"
99
#include "../NamedObjectContext.h"
1010

1111
using namespace ai;
@@ -30,7 +30,7 @@ namespace ai
3030
private:
3131
static Strategy* dps(PlayerbotAI* ai) { return new DpsRogueStrategy(ai); }
3232
static Strategy* nc(PlayerbotAI* ai) { return new GenericRogueNonCombatStrategy(ai); }
33-
static Strategy* pull(PlayerbotAI* ai) { return new PullStrategy(ai, "shoot"); }
33+
static Strategy* pull(PlayerbotAI* ai) { return new RogueAmbushStrategy(ai); }
3434
};
3535
};
3636
};
@@ -51,6 +51,8 @@ namespace ai
5151
creators["slice and dice"] = &TriggerFactoryInternal::slice_and_dice;
5252
creators["expose armor"] = &TriggerFactoryInternal::expose_armor;
5353
creators["kick on enemy healer"] = &TriggerFactoryInternal::kick_on_enemy_healer;
54+
creators["combo points for target available"] = &TriggerFactoryInternal::combo_points_for_target_available;
55+
creators["stealth"] = &TriggerFactoryInternal::stealth;
5456

5557
}
5658

@@ -60,6 +62,8 @@ namespace ai
6062
static Trigger* slice_and_dice(PlayerbotAI* ai) { return new SliceAndDiceTrigger(ai); }
6163
static Trigger* expose_armor(PlayerbotAI* ai) { return new ExposeArmorTrigger(ai); }
6264
static Trigger* kick_on_enemy_healer(PlayerbotAI* ai) { return new KickInterruptEnemyHealerSpellTrigger(ai); }
65+
static Trigger* combo_points_for_target_available(PlayerbotAI* ai) { return new ComboPointsForTargetAvailableTrigger(ai); }
66+
static Trigger* stealth(PlayerbotAI* ai) { return new StealthTrigger(ai); }
6367
};
6468
};
6569
};
@@ -90,6 +94,10 @@ namespace ai
9094
creators["backstab"] = &AiObjectContextInternal::backstab;
9195
creators["expose armor"] = &AiObjectContextInternal::expose_armor;
9296
creators["kick on enemy healer"] = &AiObjectContextInternal::kick_on_enemy_healer;
97+
creators["sap"] = &AiObjectContextInternal::sap;
98+
creators["garrote"] = &AiObjectContextInternal::garrote;
99+
creators["cheap shot"] = &AiObjectContextInternal::cheap_shot;
100+
creators["stealth"] = &AiObjectContextInternal::stealth;
93101
}
94102

95103
private:
@@ -107,6 +115,10 @@ namespace ai
107115
static Action* backstab(PlayerbotAI* ai) { return new CastBackstabAction(ai); }
108116
static Action* expose_armor(PlayerbotAI* ai) { return new CastExposeArmorAction(ai); }
109117
static Action* kick_on_enemy_healer(PlayerbotAI* ai) { return new CastKickOnEnemyHealerAction(ai); }
118+
static Action* sap(PlayerbotAI* ai) { return new CastSapAction(ai); }
119+
static Action* garrote(PlayerbotAI* ai) { return new CastGarroteAction(ai); }
120+
static Action* cheap_shot(PlayerbotAI* ai) { return new CastCheapShotAction(ai); }
121+
static Action* stealth(PlayerbotAI* ai) { return new CastStealthAction(ai); }
110122
};
111123
};
112124
};
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#pragma once
2+
3+
#include "../Strategy.h"
4+
5+
namespace ai
6+
{
7+
class RogueAmbushStrategy : public Strategy
8+
{
9+
public:
10+
RogueAmbushStrategy(PlayerbotAI* ai) : Strategy(ai) {}
11+
virtual string getName() { return "pull"; }
12+
13+
virtual NextAction** getDefaultActions()
14+
{
15+
// Stealth first; once stealthed, cheap shot moves to target (via reach melee
16+
// prerequisite) and opens. End pull fires once combat begins.
17+
return NextAction::array(0,
18+
new NextAction("stealth", 105.0f),
19+
new NextAction("cheap shot", 104.0f),
20+
new NextAction("end pull", 103.0f),
21+
new NextAction("sinister strike", 100.0f),
22+
NULL);
23+
}
24+
};
25+
}

src/modules/Bots/playerbot/strategy/rogue/RogueComboActions.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ namespace ai
99

1010
virtual bool isUseful()
1111
{
12-
return CastMeleeSpellAction::isUseful() && AI_VALUE2(uint8, "combo", "self target") < 5;
12+
return CastMeleeSpellAction::isUseful() && AI_VALUE2(uint8, "combo", "current target") < 5;
1313
}
1414
};
1515

src/modules/Bots/playerbot/strategy/rogue/RogueFinishingActions.h

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,34 +2,45 @@
22

33
namespace ai
44
{
5-
class CastEviscerateAction : public CastMeleeSpellAction
5+
class CastFinishingMoveAction : public CastMeleeSpellAction
66
{
77
public:
8-
CastEviscerateAction(PlayerbotAI* ai) : CastMeleeSpellAction(ai, "eviscerate") {}
8+
CastFinishingMoveAction(PlayerbotAI* ai, string name) : CastMeleeSpellAction(ai, name) {}
9+
10+
virtual bool isUseful()
11+
{
12+
return CastMeleeSpellAction::isUseful() && AI_VALUE2(uint8, "combo", "current target") >= 1;
13+
}
14+
};
15+
16+
class CastEviscerateAction : public CastFinishingMoveAction
17+
{
18+
public:
19+
CastEviscerateAction(PlayerbotAI* ai) : CastFinishingMoveAction(ai, "eviscerate") {}
920
};
1021

11-
class CastSliceAndDiceAction : public CastMeleeSpellAction
22+
class CastSliceAndDiceAction : public CastFinishingMoveAction
1223
{
1324
public:
14-
CastSliceAndDiceAction(PlayerbotAI* ai) : CastMeleeSpellAction(ai, "slice and dice") {}
25+
CastSliceAndDiceAction(PlayerbotAI* ai) : CastFinishingMoveAction(ai, "slice and dice") {}
1526
};
1627

17-
class CastExposeArmorAction : public CastMeleeSpellAction
28+
class CastExposeArmorAction : public CastFinishingMoveAction
1829
{
1930
public:
20-
CastExposeArmorAction(PlayerbotAI* ai) : CastMeleeSpellAction(ai, "expose armor") {}
31+
CastExposeArmorAction(PlayerbotAI* ai) : CastFinishingMoveAction(ai, "expose armor") {}
2132
};
2233

23-
class CastRuptureAction : public CastMeleeSpellAction
34+
class CastRuptureAction : public CastFinishingMoveAction
2435
{
2536
public:
26-
CastRuptureAction(PlayerbotAI* ai) : CastMeleeSpellAction(ai, "rupture") {}
37+
CastRuptureAction(PlayerbotAI* ai) : CastFinishingMoveAction(ai, "rupture") {}
2738
};
2839

29-
class CastKidneyShotAction : public CastMeleeSpellAction
40+
class CastKidneyShotAction : public CastFinishingMoveAction
3041
{
3142
public:
32-
CastKidneyShotAction(PlayerbotAI* ai) : CastMeleeSpellAction(ai, "kidney shot") {}
43+
CastKidneyShotAction(PlayerbotAI* ai) : CastFinishingMoveAction(ai, "kidney shot") {}
3344
};
3445

3546
}

src/modules/Bots/playerbot/strategy/rogue/RogueOpeningActions.h

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,38 @@
22

33
namespace ai
44
{
5-
class CastSapAction : public CastMeleeSpellAction
5+
class CastStealthedOpeningAction : public CastMeleeSpellAction
66
{
77
public:
8-
CastSapAction(PlayerbotAI* ai) : CastMeleeSpellAction(ai, "sap") {}
8+
CastStealthedOpeningAction(PlayerbotAI* ai, string name) : CastMeleeSpellAction(ai, name) {}
9+
10+
virtual bool isUseful()
11+
{
12+
return CastMeleeSpellAction::isUseful() && ai->HasAura("stealth", ai->GetBot());
13+
}
914
};
1015

11-
class CastGarroteAction : public CastMeleeSpellAction
16+
class CastSapAction : public CastStealthedOpeningAction
1217
{
1318
public:
14-
CastGarroteAction(PlayerbotAI* ai) : CastMeleeSpellAction(ai, "garrote") {}
19+
CastSapAction(PlayerbotAI* ai) : CastStealthedOpeningAction(ai, "sap") {}
1520
};
1621

22+
class CastGarroteAction : public CastStealthedOpeningAction
23+
{
24+
public:
25+
CastGarroteAction(PlayerbotAI* ai) : CastStealthedOpeningAction(ai, "garrote") {}
26+
27+
virtual bool isUseful()
28+
{
29+
return CastStealthedOpeningAction::isUseful() && AI_VALUE2(bool, "behind", "current target");
30+
}
31+
};
1732

18-
class CastCheapShotAction : public CastMeleeSpellAction
33+
class CastCheapShotAction : public CastStealthedOpeningAction
1934
{
2035
public:
21-
CastCheapShotAction(PlayerbotAI* ai) : CastMeleeSpellAction(ai, "cheap shot") {}
36+
CastCheapShotAction(PlayerbotAI* ai) : CastStealthedOpeningAction(ai, "cheap shot") {}
2237
};
2338

2439
}

src/modules/Bots/playerbot/strategy/rogue/RogueTriggers.h

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,61 @@ namespace ai
3333
public:
3434
KickInterruptEnemyHealerSpellTrigger(PlayerbotAI* ai) : InterruptEnemyHealerTrigger(ai, "kick") {}
3535
};
36+
37+
class StealthTrigger : public Trigger
38+
{
39+
public:
40+
StealthTrigger(PlayerbotAI* ai) : Trigger(ai, "stealth") {}
41+
42+
virtual bool IsActive()
43+
{
44+
Unit* target = AI_VALUE(Unit*, "current target");
45+
if (!target && !bot->IsInCombat() && ai->HasAura("stealth", bot))
46+
bot->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH);
47+
return target && !ai->HasAura("stealth", bot);
48+
}
49+
};
50+
51+
class ComboPointsForTargetAvailableTrigger : public Trigger
52+
{
53+
public:
54+
ComboPointsForTargetAvailableTrigger(PlayerbotAI* ai)
55+
: Trigger(ai, "combo points for target available"), m_threshold(2) {}
56+
57+
virtual bool IsActive()
58+
{
59+
Unit* target = AI_VALUE(Unit*, "current target");
60+
if (!target)
61+
return false;
62+
63+
ObjectGuid guid = target->GetObjectGuid();
64+
if (guid != m_lastTargetGuid)
65+
{
66+
m_lastTargetGuid = guid;
67+
m_threshold = 2;
68+
}
69+
70+
uint8 combo = AI_VALUE2(uint8, "combo", "current target");
71+
if (combo >= m_threshold)
72+
{
73+
m_threshold = nextThreshold(target);
74+
return true;
75+
}
76+
return false;
77+
}
78+
79+
private:
80+
uint8 m_threshold;
81+
ObjectGuid m_lastTargetGuid;
82+
83+
uint8 nextThreshold(Unit* target)
84+
{
85+
Creature* creature = dynamic_cast<Creature*>(target);
86+
if (creature && creature->GetCreatureInfo() &&
87+
creature->GetCreatureInfo()->Rank > CREATURE_ELITE_NORMAL)
88+
return 3 + urand(0, 2); // 3, 4, or 5
89+
else
90+
return 1 + urand(0, 1); // 1 or 2
91+
}
92+
};
3693
}

0 commit comments

Comments
 (0)