fix(Scripts/Netherstorm): Rewrite Phase Hunter AI (#19401)

* Update zone_netherstorm.cpp

* Update zone_netherstorm.cpp

* db
This commit is contained in:
Gultask
2024-07-14 12:27:32 -03:00
committed by GitHub
parent 5694c0499c
commit 8eb7b24670
2 changed files with 21 additions and 134 deletions

View File

@@ -580,137 +580,6 @@ public:
}
};
/*######
## npc_phase_hunter
######*/
enum PhaseHunterData
{
QUEST_RECHARGING_THE_BATTERIES = 10190,
NPC_PHASE_HUNTER_ENTRY = 18879,
NPC_DRAINED_PHASE_HUNTER_ENTRY = 19595,
EMOTE_WEAK = 0,
// Spells
SPELL_RECHARGING_BATTERY = 34219,
SPELL_PHASE_SLIP = 36574,
SPELL_MANA_BURN = 13321,
SPELL_MATERIALIZE = 34804,
SPELL_DE_MATERIALIZE = 34814,
};
class npc_phase_hunter : public CreatureScript
{
public:
npc_phase_hunter() : CreatureScript("npc_phase_hunter") { }
CreatureAI* GetAI(Creature* creature) const override
{
return new npc_phase_hunterAI(creature);
}
struct npc_phase_hunterAI : public ScriptedAI
{
npc_phase_hunterAI(Creature* creature) : ScriptedAI(creature) { }
bool Weak;
bool Materialize;
bool Drained;
uint8 WeakPercent;
ObjectGuid PlayerGUID;
uint32 ManaBurnTimer;
void Reset() override
{
Weak = false;
Materialize = false;
Drained = false;
WeakPercent = 25 + (rand() % 16); // 25-40
PlayerGUID.Clear();
ManaBurnTimer = 5000 + (rand() % 3 * 1000); // 5-8 sec cd
if (me->GetEntry() == NPC_DRAINED_PHASE_HUNTER_ENTRY)
me->UpdateEntry(NPC_PHASE_HUNTER_ENTRY);
}
void JustEngagedWith(Unit* who) override
{
if (who->GetTypeId() == TYPEID_PLAYER)
PlayerGUID = who->GetGUID();
}
//void SpellHit(Unit* /*caster*/, SpellInfo const* /*spell*/)
//{
// DoCast(me, SPELL_DE_MATERIALIZE);
//}
void UpdateAI(uint32 diff) override
{
if (!Materialize)
{
DoCast(me, SPELL_MATERIALIZE);
Materialize = true;
}
if (me->HasAuraType(SPELL_AURA_MOD_DECREASE_SPEED) || me->HasUnitState(UNIT_STATE_ROOT)) // if the mob is rooted/slowed by spells eg.: Entangling Roots, Frost Nova, Hamstring, Crippling Poison, etc. => remove it
DoCast(me, SPELL_PHASE_SLIP);
if (!UpdateVictim())
return;
// some code to cast spell Mana Burn on random target which has mana
if (ManaBurnTimer <= diff)
{
std::list<HostileReference*> AggroList = me->GetThreatMgr().GetThreatList();
std::list<Unit*> UnitsWithMana;
for (std::list<HostileReference*>::const_iterator itr = AggroList.begin(); itr != AggroList.end(); ++itr)
{
if (Unit* unit = ObjectAccessor::GetUnit(*me, (*itr)->getUnitGuid()))
{
if (unit->GetCreateMana() > 0)
UnitsWithMana.push_back(unit);
}
}
if (!UnitsWithMana.empty())
{
DoCast(Acore::Containers::SelectRandomContainerElement(UnitsWithMana), SPELL_MANA_BURN);
ManaBurnTimer = 8000 + (rand() % 10 * 1000); // 8-18 sec cd
}
else
ManaBurnTimer = 3500;
}
else ManaBurnTimer -= diff;
if (Player* player = ObjectAccessor::GetPlayer(*me, PlayerGUID)) // start: support for quest 10190
{
if (!Weak && HealthBelowPct(WeakPercent)
&& player->GetQuestStatus(QUEST_RECHARGING_THE_BATTERIES) == QUEST_STATUS_INCOMPLETE)
{
Talk(EMOTE_WEAK);
Weak = true;
}
if (Weak && !Drained && me->HasAura(SPELL_RECHARGING_BATTERY))
{
Drained = true;
int32 uHpPct = int32(me->GetHealthPct());
me->SetHealth(me->CountPctFromMaxHealth(uHpPct));
me->LowerPlayerDamageReq(me->GetMaxHealth() - me->GetHealth());
me->SetInCombatWith(player);
}
} // end: support for quest 10190
DoMeleeAttackIfReady();
}
};
};
/*######
## npc_bessy
######*/
@@ -911,6 +780,12 @@ public:
}
};
enum PhaseHunterData
{
NPC_PHASE_HUNTER_ENTRY = 18879,
NPC_DRAINED_PHASE_HUNTER_ENTRY = 19595
};
class spell_q10190_battery_recharging_blaster : public SpellScript
{
PrepareSpellScript(spell_q10190_battery_recharging_blaster);
@@ -918,7 +793,7 @@ class spell_q10190_battery_recharging_blaster : public SpellScript
SpellCastResult CheckCast()
{
if (Unit* target = GetExplTargetUnit())
if (target->GetHealthPct() <= 25.0f)
if (target->GetHealthPct() <= 35.0f)
return SPELL_CAST_OK;
return SPELL_FAILED_BAD_TARGETS;
@@ -941,7 +816,7 @@ class spell_q10190_battery_recharging_blaster_aura : public AuraScript
if (Creature* phasehunter = GetTarget()->ToCreature())
if (phasehunter->GetEntry() == NPC_PHASE_HUNTER_ENTRY)
phasehunter->UpdateEntry(NPC_DRAINED_PHASE_HUNTER_ENTRY);
phasehunter->UpdateEntry(NPC_DRAINED_PHASE_HUNTER_ENTRY, nullptr, false);
}
void Register() override
@@ -989,7 +864,6 @@ void AddSC_netherstorm()
// Theirs
new npc_commander_dawnforge();
new at_commander_dawnforge();
new npc_phase_hunter();
new npc_bessy();
new npc_maxx_a_million_escort();
RegisterSpellAndAuraScriptPair(spell_q10190_battery_recharging_blaster, spell_q10190_battery_recharging_blaster_aura);