mirror of
https://github.com/liyunfan1223/azerothcore-wotlk.git
synced 2026-08-07 15:28:02 +00:00
fix(DB/SAI): Move Unworthy Initiate behavior on SmartAI. (#25514)
This commit is contained in:
@@ -314,286 +314,7 @@ public:
|
||||
|
||||
enum UnworthyInitiate
|
||||
{
|
||||
SPELL_SOUL_PRISON_CHAIN = 54612,
|
||||
SPELL_DK_INITIATE_VISUAL = 51519,
|
||||
|
||||
SPELL_ICY_TOUCH = 52372,
|
||||
SPELL_PLAGUE_STRIKE = 52373,
|
||||
SPELL_BLOOD_STRIKE = 52374,
|
||||
SPELL_DEATH_COIL = 52375,
|
||||
|
||||
SAY_EVENT_START = 0,
|
||||
SAY_EVENT_ATTACK = 1,
|
||||
|
||||
EVENT_ICY_TOUCH = 1,
|
||||
EVENT_PLAGUE_STRIKE = 2,
|
||||
EVENT_BLOOD_STRIKE = 3,
|
||||
EVENT_DEATH_COIL = 4
|
||||
};
|
||||
|
||||
enum UnworthyInitiatePhase
|
||||
{
|
||||
PHASE_CHAINED,
|
||||
PHASE_TO_EQUIP,
|
||||
PHASE_EQUIPING,
|
||||
PHASE_TO_ATTACK,
|
||||
PHASE_ATTACKING,
|
||||
};
|
||||
|
||||
uint32 acherus_soul_prison[12] =
|
||||
{
|
||||
191577,
|
||||
191580,
|
||||
191581,
|
||||
191582,
|
||||
191583,
|
||||
191584,
|
||||
191585,
|
||||
191586,
|
||||
191587,
|
||||
191588,
|
||||
191589,
|
||||
191590
|
||||
};
|
||||
|
||||
//uint32 acherus_unworthy_initiate[5] =
|
||||
//{
|
||||
// 29519,
|
||||
// 29520,
|
||||
// 29565,
|
||||
// 29566,
|
||||
// 29567
|
||||
//};
|
||||
|
||||
class npc_unworthy_initiate : public CreatureScript
|
||||
{
|
||||
public:
|
||||
npc_unworthy_initiate() : CreatureScript("npc_unworthy_initiate") { }
|
||||
|
||||
CreatureAI* GetAI(Creature* creature) const override
|
||||
{
|
||||
return new npc_unworthy_initiateAI(creature);
|
||||
}
|
||||
|
||||
struct npc_unworthy_initiateAI : public ScriptedAI
|
||||
{
|
||||
npc_unworthy_initiateAI(Creature* creature) : ScriptedAI(creature)
|
||||
{
|
||||
me->SetReactState(REACT_PASSIVE);
|
||||
if (!me->GetCurrentEquipmentId())
|
||||
me->SetCurrentEquipmentId(me->GetOriginalEquipmentId());
|
||||
}
|
||||
|
||||
ObjectGuid playerGUID;
|
||||
UnworthyInitiatePhase phase;
|
||||
uint32 wait_timer;
|
||||
float anchorX, anchorY;
|
||||
ObjectGuid anchorGUID;
|
||||
|
||||
EventMap events;
|
||||
|
||||
void Reset() override
|
||||
{
|
||||
anchorGUID.Clear();
|
||||
phase = PHASE_CHAINED;
|
||||
events.Reset();
|
||||
me->SetFaction(FACTION_CREATURE);
|
||||
me->SetImmuneToPC(true);
|
||||
me->SetUInt32Value(UNIT_FIELD_BYTES_1, 8);
|
||||
me->LoadEquipment(0, true);
|
||||
}
|
||||
|
||||
void JustEngagedWith(Unit* /*who*/) override
|
||||
{
|
||||
events.ScheduleEvent(EVENT_ICY_TOUCH, 1s, GCD_CAST);
|
||||
events.ScheduleEvent(EVENT_PLAGUE_STRIKE, 3s, GCD_CAST);
|
||||
events.ScheduleEvent(EVENT_BLOOD_STRIKE, 2s, GCD_CAST);
|
||||
events.ScheduleEvent(EVENT_DEATH_COIL, 5s, GCD_CAST);
|
||||
}
|
||||
|
||||
void MovementInform(uint32 type, uint32 id) override
|
||||
{
|
||||
if (type != POINT_MOTION_TYPE)
|
||||
return;
|
||||
|
||||
if (id == 1)
|
||||
{
|
||||
wait_timer = 5000;
|
||||
me->LoadEquipment(1);
|
||||
me->CastSpell(me, SPELL_DK_INITIATE_VISUAL, true);
|
||||
|
||||
if (Player* starter = ObjectAccessor::GetPlayer(*me, playerGUID))
|
||||
Talk(SAY_EVENT_ATTACK, starter);
|
||||
|
||||
phase = PHASE_TO_ATTACK;
|
||||
}
|
||||
}
|
||||
|
||||
void EventStart(Creature* anchor, Player* target)
|
||||
{
|
||||
wait_timer = 5000;
|
||||
phase = PHASE_TO_EQUIP;
|
||||
|
||||
me->SetUInt32Value(UNIT_FIELD_BYTES_1, 0);
|
||||
me->RemoveAurasDueToSpell(SPELL_SOUL_PRISON_CHAIN);
|
||||
|
||||
float z;
|
||||
anchor->GetContactPoint(me, anchorX, anchorY, z, 1.0f);
|
||||
|
||||
playerGUID = target->GetGUID();
|
||||
Talk(SAY_EVENT_START, target);
|
||||
}
|
||||
|
||||
void UpdateAI(uint32 diff) override
|
||||
{
|
||||
switch (phase)
|
||||
{
|
||||
case PHASE_CHAINED:
|
||||
if (!anchorGUID)
|
||||
{
|
||||
if (Creature* anchor = me->FindNearestCreature(29521, 30))
|
||||
{
|
||||
anchor->AI()->SetGUID(me->GetGUID());
|
||||
anchor->CastSpell(me, SPELL_SOUL_PRISON_CHAIN, true);
|
||||
anchorGUID = anchor->GetGUID();
|
||||
}
|
||||
|
||||
float dist = 99.0f;
|
||||
GameObject* prison = nullptr;
|
||||
|
||||
for (uint8 i = 0; i < 12; ++i)
|
||||
{
|
||||
if (GameObject* temp_prison = me->FindNearestGameObject(acherus_soul_prison[i], 100))
|
||||
{
|
||||
if (me->IsWithinDist(temp_prison, dist, false))
|
||||
{
|
||||
dist = me->GetDistance2d(temp_prison);
|
||||
prison = temp_prison;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Must check for loot state as out of order updates will reset
|
||||
// the prison gameobject during spawn causing invalid state
|
||||
if (prison && prison->getLootState() != GO_NOT_READY)
|
||||
prison->ResetDoorOrButton();
|
||||
}
|
||||
break;
|
||||
case PHASE_TO_EQUIP:
|
||||
if (wait_timer)
|
||||
{
|
||||
if (wait_timer > diff)
|
||||
wait_timer -= diff;
|
||||
else
|
||||
{
|
||||
me->GetMotionMaster()->MovePoint(1, anchorX, anchorY, me->GetPositionZ());
|
||||
//LOG_DEBUG("scripts.ai", "npc_unworthy_initiateAI: move to {} {} {}", anchorX, anchorY, me->GetPositionZ());
|
||||
phase = PHASE_EQUIPING;
|
||||
wait_timer = 0;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case PHASE_TO_ATTACK:
|
||||
if (wait_timer)
|
||||
{
|
||||
if (wait_timer > diff)
|
||||
wait_timer -= diff;
|
||||
else
|
||||
{
|
||||
me->SetFaction(FACTION_MONSTER);
|
||||
me->SetImmuneToPC(false);
|
||||
phase = PHASE_ATTACKING;
|
||||
|
||||
if (Player* target = ObjectAccessor::GetPlayer(*me, playerGUID))
|
||||
AttackStart(target);
|
||||
wait_timer = 0;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case PHASE_ATTACKING:
|
||||
if (!UpdateVictim())
|
||||
return;
|
||||
|
||||
events.Update(diff);
|
||||
|
||||
while (uint32 eventId = events.ExecuteEvent())
|
||||
{
|
||||
switch (eventId)
|
||||
{
|
||||
case EVENT_ICY_TOUCH:
|
||||
DoCastVictim(SPELL_ICY_TOUCH);
|
||||
events.DelayEvents(1s, GCD_CAST);
|
||||
events.ScheduleEvent(EVENT_ICY_TOUCH, 5s, GCD_CAST);
|
||||
break;
|
||||
case EVENT_PLAGUE_STRIKE:
|
||||
DoCastVictim(SPELL_PLAGUE_STRIKE);
|
||||
events.DelayEvents(1s, GCD_CAST);
|
||||
events.ScheduleEvent(EVENT_PLAGUE_STRIKE, 5s, GCD_CAST);
|
||||
break;
|
||||
case EVENT_BLOOD_STRIKE:
|
||||
DoCastVictim(SPELL_BLOOD_STRIKE);
|
||||
events.DelayEvents(1s, GCD_CAST);
|
||||
events.ScheduleEvent(EVENT_BLOOD_STRIKE, 5s, GCD_CAST);
|
||||
break;
|
||||
case EVENT_DEATH_COIL:
|
||||
DoCastVictim(SPELL_DEATH_COIL);
|
||||
events.DelayEvents(1s, GCD_CAST);
|
||||
events.ScheduleEvent(EVENT_DEATH_COIL, 5s, GCD_CAST);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
DoMeleeAttackIfReady();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
class npc_unworthy_initiate_anchor : public CreatureScript
|
||||
{
|
||||
public:
|
||||
npc_unworthy_initiate_anchor() : CreatureScript("npc_unworthy_initiate_anchor") { }
|
||||
|
||||
CreatureAI* GetAI(Creature* creature) const override
|
||||
{
|
||||
return new npc_unworthy_initiate_anchorAI(creature);
|
||||
}
|
||||
|
||||
struct npc_unworthy_initiate_anchorAI : public PassiveAI
|
||||
{
|
||||
npc_unworthy_initiate_anchorAI(Creature* creature) : PassiveAI(creature) {}
|
||||
|
||||
ObjectGuid prisonerGUID;
|
||||
|
||||
void SetGUID(ObjectGuid const& guid, int32 /*id*/) override
|
||||
{
|
||||
if (!prisonerGUID)
|
||||
prisonerGUID = guid;
|
||||
}
|
||||
|
||||
ObjectGuid GetGUID(int32 /*id*/) const override
|
||||
{
|
||||
return prisonerGUID;
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
class go_acherus_soul_prison : public GameObjectScript
|
||||
{
|
||||
public:
|
||||
go_acherus_soul_prison() : GameObjectScript("go_acherus_soul_prison") { }
|
||||
|
||||
bool OnGossipHello(Player* player, GameObject* go) override
|
||||
{
|
||||
if (Creature* anchor = go->FindNearestCreature(29521, 15))
|
||||
if (ObjectGuid prisonerGUID = anchor->AI()->GetGUID())
|
||||
if (Creature* prisoner = ObjectAccessor::GetCreature(*player, prisonerGUID))
|
||||
CAST_AI(npc_unworthy_initiate::npc_unworthy_initiateAI, prisoner->AI())->EventStart(anchor, player);
|
||||
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
class spell_death_knight_initiate_visual : public SpellScript
|
||||
@@ -732,9 +453,6 @@ void AddSC_the_scarlet_enclave_c1()
|
||||
RegisterSpellScript(spell_q12698_the_gift_that_keeps_on_giving);
|
||||
new npc_scarlet_ghoul();
|
||||
new npc_dkc1_gothik();
|
||||
new npc_unworthy_initiate();
|
||||
new npc_unworthy_initiate_anchor();
|
||||
new go_acherus_soul_prison();
|
||||
RegisterSpellScript(spell_death_knight_initiate_visual);
|
||||
RegisterSpellScript(spell_lich_king_whisper);
|
||||
RegisterSpellScript(spell_lich_king_vo_blocker);
|
||||
|
||||
Reference in New Issue
Block a user