fix(Scripts/ZulAman): Harrison Jones gong event RP with taskscheduler (#20713)

This commit is contained in:
Jelle Meeus
2024-11-24 15:39:19 +01:00
committed by GitHub
parent 4aa70c4dba
commit 6e0e5a6939
2 changed files with 144 additions and 142 deletions

View File

@@ -323,31 +323,23 @@ enum Spells
SPELL_COSMETIC_SPEAR_THROW = 43647
};
enum Events
enum Phases
{
GONG_EVENT_1 = 1,
GONG_EVENT_2 = 2,
GONG_EVENT_3 = 3,
GONG_EVENT_4 = 4,
GONG_EVENT_5 = 5,
GONG_EVENT_6 = 6,
GONG_EVENT_7 = 7,
GONG_EVENT_8 = 8,
GONG_EVENT_9 = 9,
GONG_EVENT_10 = 10,
GONG_EVENT_11 = 11
PHASE_GONG = 0,
PHASE_GATE_CLOSED = 1,
PHASE_GATE_OPENED = 2
};
enum Actions
{
ACTION_COMPLETE_EVENT_3 = 0,
ACTION_COMPLETE_GONG_RITUAL = 0
};
enum Waypoints
{
HARRISON_MOVE_1 = 860440,
HARRISON_MOVE_2 = 860441,
HARRISON_MOVE_3 = 860442
HARRISON_MOVE_1 = 2435800,
HARRISON_MOVE_2 = 2435801,
HARRISON_MOVE_3 = 2435802
};
enum DisplayIds
@@ -379,9 +371,8 @@ struct npc_harrison_jones : public ScriptedAI
void Reset() override
{
_gongEvent = 0;
_gongTimer = 0;
uiTargetGUID.Clear();
_phase = PHASE_GONG;
me->RemoveUnitFlag(UNIT_FLAG_NOT_SELECTABLE);
}
void JustEngagedWith(Unit* /*who*/) override { }
@@ -394,8 +385,10 @@ struct npc_harrison_jones : public ScriptedAI
me->SetFacingToObject(player);
me->RemoveNpcFlag(UNIT_NPC_FLAG_GOSSIP);
Talk(SAY_HARRISON_0);
_gongEvent = GONG_EVENT_1;
_gongTimer = 4000;
scheduler.Schedule(2s, [this](TaskContext /*task*/)
{
me->GetMotionMaster()->MovePath(HARRISON_MOVE_1, false);
});
}
}
@@ -403,12 +396,16 @@ struct npc_harrison_jones : public ScriptedAI
{
if (spell->Id == SPELL_COSMETIC_SPEAR_THROW)
{
me->RemoveAllAuras();
me->RemoveAllAuras(); // remove stealth
me->SetEntry(NPC_HARRISON_JONES_2);
me->SetDisplayId(MODEL_HARRISON_JONES_2);
me->SetTarget();
me->SetByteValue(UNIT_FIELD_BYTES_1, UNIT_BYTES_1_OFFSET_STAND_STATE, UNIT_STAND_STATE_DEAD);
me->SetDynamicFlag(UNIT_DYNFLAG_DEAD);
me->SetUnitFlag(UNIT_FLAG_NOT_SELECTABLE);
me->PlayDistanceSound(1332); // human male death
me->HandleEmoteCommand(EMOTE_ONESHOT_WOUND_CRITICAL);
me->StopMoving();
scheduler.Schedule(1s, [this](TaskContext /*task*/)
{
me->SetStandState(UNIT_STAND_STATE_DEAD);
});
_instance->StorePersistentData(DATA_TIMED_RUN, 21);
_instance->DoAction(ACTION_START_TIMED_RUN);
me->DespawnOrUnsummon(3min+30s, 0s);
@@ -417,132 +414,103 @@ struct npc_harrison_jones : public ScriptedAI
void DoAction(int32 action) override
{
if (action == ACTION_COMPLETE_EVENT_3)
if (action == ACTION_COMPLETE_GONG_RITUAL)
{
me->GetMap()->ToInstanceMap()->PermBindAllPlayers();
_gongEvent = GONG_EVENT_4;
_gongTimer = 0;
_phase = PHASE_GATE_CLOSED;
me->RemoveAura(SPELL_BANGING_THE_GONG);
me->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID + 0, uint32(0));
if (GameObject* gong = _instance->GetGameObject(DATA_STRANGE_GONG))
gong->SetGameObjectFlag(GO_FLAG_NOT_SELECTABLE);
// Players are Now Saved to instance at SPECIAL (Player should be notified?)
scheduler.Schedule(500ms, [this](TaskContext /*task*/)
{
me->GetMotionMaster()->MovePath(HARRISON_MOVE_2, false);
});
}
}
void OpenMassiveGateAndCallGuards()
{
if (GameObject* gate = _instance->GetGameObject(DATA_MASSIVE_GATE))
{
gate->AllowSaveToDB(true);
gate->SetGoState(GO_STATE_ACTIVE);
}
std::list<Creature*> targetList;
GetCreatureListWithEntryInGrid(targetList, me, NPC_AMANISHI_GUARDIAN, 26.0f);
if (!targetList.empty())
{
for (auto const& creature : targetList)
{
if (creature)
{
creature->SetImmuneToPC(true);
creature->SetReactState(REACT_PASSIVE);
if (creature->GetPositionX() > 120)
{
creature->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID + 0, uint32(WEAPON_SPEAR));
creature->AI()->SetData(0, 1);
}
else
creature->AI()->SetData(0, 2);
}
}
}
}
void MovementInform(uint32 type, uint32 id) override
{
// at gong
if (type == WAYPOINT_MOTION_TYPE && id == 2 && _phase == PHASE_GONG)
{
if (GameObject* gong = _instance->GetGameObject(DATA_STRANGE_GONG))
me->SetFacingToObject(gong);
scheduler.Schedule(2s, [this](TaskContext /*task*/)
{
Talk(SAY_HARRISON_1);
}).Schedule(7s, [this](TaskContext /*task*/)
{
DoCastSelf(SPELL_BANGING_THE_GONG);
me->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID + 0, uint32(WEAPON_MACE));
me->SetFacingTo(5.9696f);
if (GameObject* gong = _instance->GetGameObject(DATA_STRANGE_GONG))
gong->RemoveGameObjectFlag(GO_FLAG_NOT_SELECTABLE);
});
}
// to the massive gate
else if (type == WAYPOINT_MOTION_TYPE && id == 1 && _phase == PHASE_GATE_CLOSED)
{
me->SetEntry(NPC_HARRISON_JONES_1);
Talk(SAY_HARRISON_2);
}
// at massive gate
else if (type == WAYPOINT_MOTION_TYPE && id == 2 && _phase == PHASE_GATE_CLOSED)
{
me->SetUInt32Value(UNIT_NPC_EMOTESTATE, EMOTE_STATE_USE_STANDING);
Talk(SAY_HARRISON_3);
scheduler.Schedule(8s, [this](TaskContext /*task*/)
{
OpenMassiveGateAndCallGuards();
_phase = PHASE_GATE_OPENED;
}).Schedule(10s, [this](TaskContext /*task*/)
{
DoCastSelf(SPELL_STEALTH);
me->SetUInt32Value(UNIT_NPC_EMOTESTATE, EMOTE_ONESHOT_NONE);
me->GetMotionMaster()->MovePath(HARRISON_MOVE_3, false);
});
}
}
void UpdateAI(uint32 diff) override
{
if (_gongEvent)
{
if (_gongTimer <= diff)
{
switch (_gongEvent)
{
case GONG_EVENT_1:
me->GetMotionMaster()->MovePath(HARRISON_MOVE_1, false);
_gongEvent = GONG_EVENT_2;
_gongTimer = 12000;
break;
case GONG_EVENT_2:
me->SetFacingTo(6.235659f);
Talk(SAY_HARRISON_1);
DoCastSelf(SPELL_BANGING_THE_GONG);
me->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID + 0, uint32(WEAPON_MACE));
me->SetSheath(SHEATH_STATE_MELEE);
_gongEvent = GONG_EVENT_3;
_gongTimer = 4000;
break;
case GONG_EVENT_3:
if (GameObject* gong = _instance->GetGameObject(DATA_STRANGE_GONG))
gong->RemoveGameObjectFlag(GO_FLAG_NOT_SELECTABLE);
break;
case GONG_EVENT_4:
me->RemoveAura(SPELL_BANGING_THE_GONG);
if (GameObject* gong = _instance->GetGameObject(DATA_STRANGE_GONG))
gong->SetGameObjectFlag(GO_FLAG_NOT_SELECTABLE);
// Players are Now Saved to instance at SPECIAL (Player should be notified?)
me->GetMotionMaster()->MovePath(HARRISON_MOVE_2, false);
_gongEvent = GONG_EVENT_5;
_gongTimer = 5000;
break;
case GONG_EVENT_5:
me->SetEntry(NPC_HARRISON_JONES_1);
me->SetDisplayId(MODEL_HARRISON_JONES_1);
Talk(SAY_HARRISON_2);
_gongTimer = 12000;
_gongEvent = GONG_EVENT_6;
break;
case GONG_EVENT_6:
me->SetUInt32Value(UNIT_NPC_EMOTESTATE, EMOTE_STATE_USE_STANDING);
Talk(SAY_HARRISON_3);
_gongTimer = 7000;
_gongEvent = GONG_EVENT_7;
break;
case GONG_EVENT_7:
if (!uiTargetGUID)
{
std::list<Creature*> targetList;
GetCreatureListWithEntryInGrid(targetList, me, NPC_AMANISHI_GUARDIAN, 26.0f);
if (!targetList.empty())
{
for (auto const& creature : targetList)
{
if (creature)
{
creature->SetImmuneToPC(true);
creature->SetReactState(REACT_PASSIVE);
if (creature->GetPositionX() > 120)
{
creature->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID + 0, uint32(WEAPON_SPEAR));
creature->AI()->SetData(0, 1);
}
else
creature->AI()->SetData(0, 2);
}
}
}
}
if (GameObject* gate = _instance->GetGameObject(DATA_MASSIVE_GATE))
{
gate->AllowSaveToDB(true);
gate->SetGoState(GO_STATE_ACTIVE);
}
_gongTimer = 2000;
_gongEvent = GONG_EVENT_8;
break;
case GONG_EVENT_8:
DoCastSelf(SPELL_STEALTH);
me->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID + 0, uint32(0));
me->SetUInt32Value(UNIT_NPC_EMOTESTATE, EMOTE_ONESHOT_NONE);
me->GetMotionMaster()->MovePath(HARRISON_MOVE_3, false);
_gongTimer = 1000;
_gongEvent = 0;
break;
case GONG_EVENT_9:
me->GetMotionMaster()->MovePoint(0, 120.687f, 1674.0f, 42.0217f);
_gongTimer = 12000;
_gongEvent = GONG_EVENT_10;
break;
case GONG_EVENT_10:
me->SetFacingTo(1.59044f);
_gongEvent = 11;
_gongTimer = 6000;
break;
case GONG_EVENT_11:
me->SetNpcFlag(UNIT_NPC_FLAG_GOSSIP);
_gongEvent = 0;
_gongTimer = 1000;
break;
}
}
else
_gongTimer -= diff;
}
scheduler.Update(diff);
}
private:
InstanceScript* _instance;
uint8 _gongEvent;
uint32 _gongTimer;
ObjectGuid uiTargetGUID;
uint32 _phase;
};
class spell_ritual_of_power : public SpellScript
@@ -553,7 +521,7 @@ class spell_ritual_of_power : public SpellScript
{
if (InstanceScript* instance = GetCaster()->GetInstanceScript())
if (Creature* creature = instance->GetCreature(DATA_HARRISON_JONES))
creature->AI()->DoAction(ACTION_COMPLETE_EVENT_3);
creature->AI()->DoAction(ACTION_COMPLETE_GONG_RITUAL);
}
void Register() override