Skip to content

Commit 4aa1663

Browse files
authored
Merge f17c968 into b5d14f3
2 parents b5d14f3 + f17c968 commit 4aa1663

9 files changed

Lines changed: 37 additions & 20 deletions

File tree

src/game/Object/Player.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21080,6 +21080,9 @@ void Player::SetGroup(Group* group, int8 subgroup)
2108021080
m_group.link(group, this);
2108121081
m_group.setSubGroup((uint8)subgroup);
2108221082
}
21083+
21084+
if (GetPlayerbotAI())
21085+
GetPlayerbotAI()->ResetStrategies();
2108321086
}
2108421087

2108521088
/* Called by WorldSession::HandlePlayerLogin */

src/modules/Bots/playerbot/AiFactory.cpp

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -128,11 +128,6 @@ void AiFactory::AddDefaultCombatStrategies(Player* player, PlayerbotAI* const fa
128128

129129
engine->addStrategies("attack weak", "racials", "chat", "default", "aoe", "potions", "cast time", "conserve mana", "duel", "pvp", NULL);
130130

131-
if (sPlayerbotAIConfig.cautiousDefault)
132-
{
133-
engine->addStrategy("cautious");
134-
}
135-
136131
switch (player->getClass())
137132
{
138133
case CLASS_PRIEST:
@@ -248,7 +243,16 @@ void AiFactory::AddDefaultCombatStrategies(Player* player, PlayerbotAI* const fa
248243
break;
249244
}
250245

251-
if (sRandomPlayerbotMgr.IsRandomBot(player) && !player->GetGroup())
246+
if (player->GetGroup())
247+
{
248+
if (engine->ContainsStrategy(STRATEGY_TYPE_TANK))
249+
engine->ChangeStrategy(sPlayerbotAIConfig.botTankStrategies);
250+
else if (engine->ContainsStrategy(STRATEGY_TYPE_HEAL))
251+
engine->ChangeStrategy(sPlayerbotAIConfig.botHealStrategies);
252+
else
253+
engine->ChangeStrategy(sPlayerbotAIConfig.botDpsStrategies);
254+
}
255+
else if (sRandomPlayerbotMgr.IsRandomBot(player))
252256
{
253257
engine->ChangeStrategy(sPlayerbotAIConfig.randomBotCombatStrategies);
254258
}
@@ -264,11 +268,6 @@ void AiFactory::AddDefaultNonCombatStrategies(Player* player, PlayerbotAI* const
264268
{
265269
int tab = GetPlayerSpecTab(player);
266270

267-
if (sPlayerbotAIConfig.cautiousDefault)
268-
{
269-
nonCombatEngine->addStrategy("cautious");
270-
}
271-
272271
switch (player->getClass()){
273272
case CLASS_PALADIN:
274273
case CLASS_HUNTER:
@@ -289,7 +288,11 @@ void AiFactory::AddDefaultNonCombatStrategies(Player* player, PlayerbotAI* const
289288
nonCombatEngine->addStrategies("nc", "attack weak", "food", "stay", "chat",
290289
"default", "quest", "loot", "gather", "duel", "emote", NULL);
291290

292-
if (sRandomPlayerbotMgr.IsRandomBot(player) && !player->GetGroup())
291+
if (player->GetGroup())
292+
{
293+
nonCombatEngine->ChangeStrategy(sPlayerbotAIConfig.botGroupNonCombatStrategies);
294+
}
295+
else if (sRandomPlayerbotMgr.IsRandomBot(player))
293296
{
294297
nonCombatEngine->ChangeStrategy(sPlayerbotAIConfig.randomBotNonCombatStrategies);
295298
}

src/modules/Bots/playerbot/PlayerbotAI.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1494,6 +1494,10 @@ void PlayerbotAI::WaitForSpellCast(uint32 spellId)
14941494
*/
14951495
void PlayerbotAI::InterruptSpell()
14961496
{
1497+
Spell* autoRepeat = bot->GetCurrentSpell(CURRENT_AUTOREPEAT_SPELL);
1498+
if (autoRepeat)
1499+
bot->InterruptSpell(CURRENT_AUTOREPEAT_SPELL);
1500+
14971501
if (bot->GetCurrentSpell(CURRENT_CHANNELED_SPELL))
14981502
{
14991503
return;

src/modules/Bots/playerbot/PlayerbotAI.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ class PlayerbotAI : public PlayerbotAIBase
138138
bool ContainsStrategy(StrategyType type);
139139
bool HasStrategy(string name, BotState type);
140140
bool HasStrategy(string name) { return HasStrategy(name, currentState); }
141+
BotState GetState() const { return currentState; }
141142
void ResetStrategies();
142143
void ReInitCurrentEngine();
143144
void Reset();

src/modules/Bots/playerbot/PlayerbotAIConfig.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ PlayerbotAIConfig::PlayerbotAIConfig()
6868
logInGroupOnly(false),
6969
logValuesPerTick(false),
7070
fleeingEnabled(false),
71-
cautiousDefault(false),
7271
randomBotMinLevel(0),
7372
randomBotMaxLevel(0),
7473
randomChangeMultiplier(0.0f),
@@ -185,7 +184,6 @@ bool PlayerbotAIConfig::Initialize()
185184
logInGroupOnly = config.GetBoolDefault("AiPlayerbot.LogInGroupOnly", true);
186185
logValuesPerTick = config.GetBoolDefault("AiPlayerbot.LogValuesPerTick", false);
187186
fleeingEnabled = config.GetBoolDefault("AiPlayerbot.FleeingEnabled", true);
188-
cautiousDefault = config.GetBoolDefault("AiPlayerbot.Cautious", false);
189187
randomBotMinLevel = config.GetIntDefault("AiPlayerbot.RandomBotMinLevel", 1);
190188
randomBotMaxLevel = config.GetIntDefault("AiPlayerbot.RandomBotMaxLevel", 255);
191189
randomBotLoginAtStartup = config.GetBoolDefault("AiPlayerbot.RandomBotLoginAtStartup", true);
@@ -196,6 +194,10 @@ bool PlayerbotAIConfig::Initialize()
196194

197195
randomBotCombatStrategies = config.GetStringDefault("AiPlayerbot.RandomBotCombatStrategies", "+dps,+attack weak");
198196
randomBotNonCombatStrategies = config.GetStringDefault("AiPlayerbot.RandomBotNonCombatStrategies", "+grind,+move random,+loot");
197+
botTankStrategies = config.GetStringDefault("AiPlayerbot.BotTankStrategies", "+tank aoe");
198+
botDpsStrategies = config.GetStringDefault("AiPlayerbot.BotDpsStrategies", "+dps assist");
199+
botHealStrategies = config.GetStringDefault("AiPlayerbot.BotHealStrategies", "");
200+
botGroupNonCombatStrategies = config.GetStringDefault("AiPlayerbot.BotGroupNonCombatStrategies", "+follow master,+loot");
199201

200202
commandPrefix = config.GetStringDefault("AiPlayerbot.CommandPrefix", "");
201203

src/modules/Bots/playerbot/PlayerbotAIConfig.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@ class PlayerbotAIConfig
7272
uint32 randomBotTeleLevel; ///< The teleport level for random bots.
7373
bool logInGroupOnly, logValuesPerTick;
7474
bool fleeingEnabled; ///< Indicates if fleeing is enabled for bots.
75-
bool cautiousDefault;
7675
std::string randomBotCombatStrategies, randomBotNonCombatStrategies;
76+
std::string botTankStrategies, botDpsStrategies, botHealStrategies, botGroupNonCombatStrategies;
7777
uint32 randomBotMinLevel, randomBotMaxLevel;
7878
float randomChangeMultiplier;
7979
uint32 specProbability[MAX_CLASSES][3]; ///< Probability of class specs for random bots.

src/modules/Bots/playerbot/aiplayerbot.conf.dist.in

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,6 @@ AiPlayerbot.CommandPrefix = ~
8888
# Bot can flee for enemy
8989
#AiPlayerbot.FleeingEnabled = 1
9090

91-
# Bot avoids pulling aggro during movement by default
92-
#AiPlayerbot.Cautious = 0
93-
9491
# Health/Mana levels
9592
#AiPlayerbot.CriticalHealth = 25
9693
#AiPlayerbot.LowHealth = 45
@@ -108,6 +105,12 @@ AiPlayerbot.CommandPrefix = ~
108105
#AiPlayerbot.RandomBotCombatStrategies = +dps,+attack weak
109106
#AiPlayerbot.RandomBotNonCombatStrategies = +grind,+move random,+loot
110107

108+
# Group strategies (applied by role to all bots when in a group, replacing solo strategies)
109+
#AiPlayerbot.BotTankStrategies = +tank aoe
110+
#AiPlayerbot.BotDpsStrategies = +dps assist
111+
#AiPlayerbot.BotHealStrategies =
112+
#AiPlayerbot.BotGroupNonCombatStrategies = +follow master,+loot
113+
111114
# Create random bot characters automatically
112115
#AiPlayerbot.RandomBotAutoCreate = 1
113116

src/modules/Bots/playerbot/strategy/Engine.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -581,8 +581,6 @@ void Engine::LogAction(const char* format, ...)
581581
{
582582
return;
583583
}
584-
585-
sLog.outDebug("%s %s", bot->GetName(), buf);
586584
}
587585
}
588586

@@ -592,6 +590,8 @@ void Engine::ChangeStrategy(string &names)
592590
vector<string> splitted = split(names, ',');
593591
for (vector<string>::iterator i = splitted.begin(); i != splitted.end(); i++)
594592
{
593+
i->erase(0, i->find_first_not_of(" \t"));
594+
i->erase(i->find_last_not_of(" \t") + 1);
595595
const char* name = i->c_str();
596596
switch (name[0])
597597
{

src/modules/Bots/playerbot/strategy/warlock/TankWarlockStrategy.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ namespace ai
99
public:
1010
TankWarlockStrategy(PlayerbotAI* ai);
1111
virtual string getName() { return "tank"; }
12+
virtual int GetType() { return STRATEGY_TYPE_TANK | STRATEGY_TYPE_RANGED; }
1213

1314
public:
1415
virtual void InitTriggers(std::list<TriggerNode*> &triggers);

0 commit comments

Comments
 (0)