Skip to content

Commit 8a931bd

Browse files
committed
NPCBots: Druid: Improve Innervate target selection, fix a bug where DPS+Healer Restoration druid bot would use Tree Form preventing them from using damaging spells
1 parent c121cd3 commit 8a931bd

File tree

1 file changed

+31
-27
lines changed

1 file changed

+31
-27
lines changed

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

+31-27
Original file line numberDiff line numberDiff line change
@@ -1416,18 +1416,14 @@ class druid_bot : public CreatureScript
14161416
{
14171417
if (!IsSpellReady(INNERVATE_1, diff) || Rand() > 25)
14181418
return;
1419-
if (_form != BOT_STANCE_NONE && _form != DRUID_MOONKIN_FORM && _form != DRUID_TREE_FORM &&
1420-
(IsTank() || me->getAttackers().size() > 3))
1419+
if (_form != BOT_STANCE_NONE && _form != DRUID_MOONKIN_FORM && _form != DRUID_TREE_FORM && (IsTank() || me->getAttackers().size() > 3))
14211420
return;
14221421

1423-
static const uint8 minmanaval = 30;
14241422
Unit* iTarget = nullptr;
14251423

1426-
if (master->IsInCombat() && master->GetPowerType() == POWER_MANA &&
1427-
GetManaPCT(master) < minmanaval && !master->GetAuraEffect(SPELL_AURA_PERIODIC_ENERGIZE, SPELLFAMILY_DRUID, 0x0, 0x1000, 0x0))
1424+
if (_isValidInnervateTarget(master))
14281425
iTarget = master;
1429-
else if (me->IsInCombat() && me->GetPowerType() == POWER_MANA &&
1430-
GetManaPCT(me) < minmanaval && !me->GetAuraEffect(SPELL_AURA_PERIODIC_ENERGIZE, SPELLFAMILY_DRUID, 0x0, 0x1000, 0x0))
1426+
else if (_isValidInnervateTarget(me))
14311427
iTarget = me;
14321428

14331429
if (!IAmFree())
@@ -1439,13 +1435,7 @@ class druid_bot : public CreatureScript
14391435
for (BotMap::const_iterator itr = map->begin(); itr != map->end(); ++itr)
14401436
{
14411437
Creature* bot = itr->second;
1442-
if (!bot || !bot->IsInCombat() || !bot->IsAlive() || bot->IsTempBot()) continue;
1443-
if (bot->GetPowerType() != POWER_MANA) continue;
1444-
if (bot->GetBotClass() == BOT_CLASS_HUNTER || bot->GetBotClass() == BOT_CLASS_WARLOCK ||
1445-
bot->GetBotClass() == BOT_CLASS_SPHYNX || bot->GetBotClass() == BOT_CLASS_SPELLBREAKER ||
1446-
bot->GetBotClass() == BOT_CLASS_NECROMANCER) continue;
1447-
if (me->GetExactDist(bot) > 30) continue;
1448-
if (GetManaPCT(bot) < minmanaval && !bot->GetAuraEffect(SPELL_AURA_PERIODIC_ENERGIZE, SPELLFAMILY_DRUID, 0x0, 0x1000, 0x0))
1438+
if (bot && !bot->IsTempBot() && _isValidInnervateTarget(bot))
14491439
{
14501440
iTarget = bot;
14511441
break;
@@ -1459,19 +1449,10 @@ class druid_bot : public CreatureScript
14591449
{
14601450
for (Unit* member : members)
14611451
{
1462-
if (!(i == 0 ? member->IsPlayer() : member->IsNPCBot()) || !member->IsInWorld() || !member->IsInCombat() ||
1463-
!member->IsAlive() || me->GetExactDist(member) > 30 || GetManaPCT(member) > minmanaval ||
1464-
member->GetAuraEffect(SPELL_AURA_PERIODIC_ENERGIZE, SPELLFAMILY_DRUID, 0x0, 0x1000, 0x0))
1452+
if (!(i == 0 ? member->IsPlayer() : member->IsNPCBot()) || !_isValidInnervateTarget(member))
1453+
continue;
1454+
if (i == 1 && member->ToCreature()->IsTempBot())
14651455
continue;
1466-
if (i == 1)
1467-
{
1468-
Creature const* bot = member->ToCreature();
1469-
if (bot->IsTempBot() || bot->GetPowerType() != POWER_MANA ||
1470-
bot->GetBotClass() == BOT_CLASS_HUNTER || bot->GetBotClass() == BOT_CLASS_WARLOCK ||
1471-
bot->GetBotClass() == BOT_CLASS_SPHYNX || bot->GetBotClass() == BOT_CLASS_SPELLBREAKER ||
1472-
bot->GetBotClass() == BOT_CLASS_NECROMANCER)
1473-
continue;
1474-
}
14751456
iTarget = member;
14761457
break;
14771458
}
@@ -2932,6 +2913,29 @@ class druid_bot : public CreatureScript
29322913
}
29332914

29342915
private:
2916+
bool _isValidInnervateTarget(Unit const* unit) const
2917+
{
2918+
if (!unit || unit->GetPowerType() != POWER_MANA || !unit->IsInCombat() || !unit->IsInMap(me) || me->GetExactDist(unit) > 30.f ||
2919+
unit->GetAuraEffect(SPELL_AURA_PERIODIC_ENERGIZE, SPELLFAMILY_DRUID, 0x0, 0x1000, 0x0))
2920+
return false;
2921+
2922+
if (unit->IsNPCBot())
2923+
{
2924+
switch (unit->ToCreature()->GetBotClass())
2925+
{
2926+
case BOT_CLASS_HUNTER: case BOT_CLASS_WARLOCK: case BOT_CLASS_SPHYNX: case BOT_CLASS_SPELLBREAKER: case BOT_CLASS_NECROMANCER:
2927+
return false;
2928+
default:
2929+
break;
2930+
}
2931+
}
2932+
2933+
uint8 mpct = (unit->GetMaxPower(POWER_MANA) - unit->GetPower(POWER_MANA) > me->GetCreateMana() * 2) ? 30 : 3;
2934+
if (GetManaPCT(unit) >= mpct)
2935+
return false;
2936+
2937+
return true;
2938+
}
29352939
static uint32 _baseSpellForShapeshift(BotStances form)
29362940
{
29372941
switch (form)
@@ -2969,7 +2973,7 @@ class druid_bot : public CreatureScript
29692973
if (form == BOT_STANCE_NONE && HasRole(BOT_ROLE_DPS))
29702974
form = (!HasRole(BOT_ROLE_HEAL) && !!GetSpell(_baseSpellForShapeshift(DRUID_MOONKIN_FORM))) ? DRUID_MOONKIN_FORM : BOT_STANCE_NONE;
29712975
if (form == BOT_STANCE_NONE && HasRole(BOT_ROLE_HEAL))
2972-
form = !!GetSpell(_baseSpellForShapeshift(DRUID_TREE_FORM)) ? DRUID_TREE_FORM : BOT_STANCE_NONE;
2976+
form = (!HasRole(BOT_ROLE_DPS) && !!GetSpell(_baseSpellForShapeshift(DRUID_TREE_FORM))) ? DRUID_TREE_FORM : BOT_STANCE_NONE;
29732977
return form;
29742978
}
29752979

0 commit comments

Comments
 (0)