feat(Core/Unit): Implement DoCastRandomTarget() helper (#8876)

This commit is contained in:
Skjalf
2021-11-05 07:47:08 -03:00
committed by GitHub
parent e0fc4ab866
commit d80f7d467d
3 changed files with 15 additions and 4 deletions

View File

@@ -205,6 +205,19 @@ void UnitAI::DoCastAOE(uint32 spellId, bool triggered)
me->CastSpell((Unit*)nullptr, spellId, triggered);
}
void UnitAI::DoCastRandomTarget(uint32 spellId, uint32 threatTablePosition, float dist, bool playerOnly, bool triggered)
{
if (!triggered && me->HasUnitState(UNIT_STATE_CASTING))
{
return;
}
if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, threatTablePosition, dist, playerOnly))
{
me->CastSpell(target, spellId, triggered);
}
}
#define UPDATE_TARGET(a) {if (AIInfo->target<a) AIInfo->target=a;}
void UnitAI::FillAISpellInfo()

View File

@@ -300,6 +300,7 @@ public:
void DoCastToAllHostilePlayers(uint32 spellid, bool triggered = false);
void DoCastVictim(uint32 spellId, bool triggered = false);
void DoCastAOE(uint32 spellId, bool triggered = false);
void DoCastRandomTarget(uint32 spellId, uint32 threatTablePosition = 0, float dist = 0.0f, bool playerOnly = true, bool triggered = false);
float DoGetSpellMaxRange(uint32 spellId, bool positive = false);

View File

@@ -201,10 +201,7 @@ public:
events.ScheduleEvent(EVENT_FLAME_BREAK, 10 * IN_MILLISECONDS);
break;
case EVENT_IMMOLATE:
if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 100, true))
{
DoCast(target, SPELL_IMMOLATE);
}
DoCastRandomTarget(SPELL_IMMOLATE, 0, 100.0f);
events.ScheduleEvent(EVENT_IMMOLATE, 8 * IN_MILLISECONDS);
break;
case EVENT_TERRIFYING_ROAR: