refactor(Core): DespawnOrUnsummon (#23141)

This commit is contained in:
天鹭
2025-10-13 14:36:23 +08:00
committed by GitHub
parent 8e2e30328f
commit 53238a68d3
148 changed files with 363 additions and 366 deletions

View File

@@ -67,7 +67,7 @@ public:
summons.DespawnAll();
if (InstanceScript* pInstance = me->GetInstanceScript())
if (pInstance->GetData(DATA_GUARDIANTIME_EVENT) == 0)
me->DespawnOrUnsummon(500);
me->DespawnOrUnsummon(500ms);
me->SummonCreature(NPC_TIME_RIFT, 2337.6f, 1270.0f, 132.95f, 2.79f);
me->SummonCreature(NPC_GUARDIAN_OF_TIME, 2319.3f, 1267.7f, 132.8f, 1.0f);
@@ -93,11 +93,11 @@ public:
{
if (cr->GetEntry() == NPC_TIME_RIFT)
{
cr->DespawnOrUnsummon(1000);
cr->DespawnOrUnsummon(1s);
}
else
{
cr->DespawnOrUnsummon(5000);
cr->DespawnOrUnsummon(5s);
cr->RemoveAllAuras();
cr->AI()->Talk(SAY_THANKS);
}
@@ -120,7 +120,7 @@ public:
{
Talk(SAY_FAIL);
summons.DespawnAll();
me->DespawnOrUnsummon(500);
me->DespawnOrUnsummon(500ms);
}
}

View File

@@ -80,7 +80,7 @@ public:
if (finished)
{
Talk(SAY_OUTRO);
me->DespawnOrUnsummon(20000);
me->DespawnOrUnsummon(20s);
}
}

View File

@@ -547,7 +547,7 @@ public:
if (Creature* stalker = me->SummonCreature(NPC_INVIS_TARGET, 2026.469f, 1287.088f, 143.596f, 1.37f, TEMPSUMMON_TIMED_DESPAWN, 14000))
{
me->SetFacingToObject(stalker);
stalker->DespawnOrUnsummon(500);
stalker->DespawnOrUnsummon(500ms);
}
break;
// Reached first cityman
@@ -861,7 +861,7 @@ public:
if (Creature* stalker = me->SummonCreature(NPC_INVIS_TARGET, 2081.447f, 1287.770f, 141.3241f, 1.37f, TEMPSUMMON_TIMED_DESPAWN, 10000))
{
me->SetFacingToObject(stalker);
stalker->DespawnOrUnsummon(500);
stalker->DespawnOrUnsummon(500ms);
}
Talk(SAY_PHASE205);
ScheduleNextEvent(currentEvent, 4s);
@@ -1343,7 +1343,7 @@ void npc_arthas::npc_arthasAI::SpawnTimeRift()
if (Creature* cr = me->SummonCreature(/*entry*/(uint32)RiftAndSpawnsLocations[timeRiftId][i][0], RiftAndSpawnsLocations[timeRiftId][0][1], RiftAndSpawnsLocations[timeRiftId][0][2], RiftAndSpawnsLocations[timeRiftId][0][3], RiftAndSpawnsLocations[timeRiftId][0][4]))
{
if (cr->GetEntry() == NPC_TIME_RIFT)
cr->DespawnOrUnsummon(10000);
cr->DespawnOrUnsummon(10s);
else // x, y, z (0 is entry)
{
// first infinite
@@ -1538,7 +1538,7 @@ public:
if (me->GetDistance(2400, 1200, 135) > 20.0f && data >= COS_PROGRESS_FINISHED_CITY_INTRO)
{
if (data >= COS_PROGRESS_KILLED_SALRAMM)
me->DespawnOrUnsummon(500);
me->DespawnOrUnsummon(500ms);
else
InfectMe(3000);
}

View File

@@ -307,7 +307,7 @@ public:
if (Creature* cr = instance->SummonCreature(NPC_CHROMIE_MIDDLE, pos))
{
cr->SetVisible(false);
cr->DespawnOrUnsummon(1000);
cr->DespawnOrUnsummon(1s);
sCreatureTextMgr->SendChat(cr, textId, player, CHAT_MSG_ADDON, LANG_ADDON, TEXT_RANGE_MAP);
}
}

View File

@@ -382,7 +382,7 @@ public:
if (Creature* horse = me->FindNearestCreature(NPC_SKARLOC_MOUNT, 10.0f))
{
horse->GetMotionMaster()->MovePoint(0, 2501.15f, 572.14f, 54.13f);
horse->DespawnOrUnsummon(30 * IN_MILLISECONDS);
horse->DespawnOrUnsummon(30s);
}
Talk(SAY_EMOTE_HORSE);
SetEscortPaused(true);

View File

@@ -143,7 +143,7 @@ public:
case NPC_INFINITE_EXECUTIONER_2:
case NPC_INFINITE_VANQUISHER:
case NPC_INFINITE_VANQUISHER_2:
creature->DespawnOrUnsummon(1);
creature->DespawnOrUnsummon(1ms);
break;
default:
break;

View File

@@ -109,7 +109,7 @@ struct npc_medivh_bm : public ScriptedAI
{
if (summon->GetEntry() == NPC_DP_CRYSTAL_STALKER)
{
summon->DespawnOrUnsummon(25000);
summon->DespawnOrUnsummon(25s);
summon->CastSpell(summon, RAND(SPELL_BANISH_PURPLE, SPELL_BANISH_GREEN), true);
summon->GetMotionMaster()->MoveSplinePath(&_airArray);
}
@@ -199,19 +199,19 @@ struct npc_medivh_bm : public ScriptedAI
events.ScheduleEvent(EVENT_OUTRO_3, 2s);
break;
case EVENT_OUTRO_3:
SummonOrcs(-2046.158f, -3.0f, 37000, 30000, true);
SummonOrcs(-2046.158f, -3.0f, 37s, 30000, true);
events.ScheduleEvent(EVENT_OUTRO_4, 2s);
break;
case EVENT_OUTRO_4:
SummonOrcs(-2055.97f, -2.0f, 33000, 28000, false);
SummonOrcs(-2055.97f, -2.0f, 33s, 28000, false);
events.ScheduleEvent(EVENT_OUTRO_5, 2s);
break;
case EVENT_OUTRO_5:
SummonOrcs(-2064.0f, -1.5f, 29000, 26000, false);
SummonOrcs(-2064.0f, -1.5f, 29s, 26000, false);
events.ScheduleEvent(EVENT_OUTRO_6, 2s);
break;
case EVENT_OUTRO_6:
SummonOrcs(-2074.35f, -0.1f, 26000, 24000, false);
SummonOrcs(-2074.35f, -0.1f, 26s, 24000, false);
events.ScheduleEvent(EVENT_OUTRO_7, 7s);
break;
case EVENT_OUTRO_7:
@@ -228,7 +228,7 @@ struct npc_medivh_bm : public ScriptedAI
}
}
void SummonOrcs(float x, float y, uint32 duration, uint32 homeTime, bool first)
void SummonOrcs(float x, float y, Milliseconds duration, uint32 homeTime, bool first)
{
for (uint8 i = 0; i < 6; ++i)
{
@@ -236,7 +236,7 @@ struct npc_medivh_bm : public ScriptedAI
{
cr->GetMotionMaster()->MovePoint(0, (first && i == 3) ? x + 2.0f : x, cr->GetPositionY() + y, cr->GetMapHeight(x, cr->GetPositionY() + y, cr->GetPositionZ(), true));
cr->m_Events.AddEvent(new NpcRunToHome(*cr), cr->m_Events.CalculateTime(homeTime + urand(0, 2000)));
cr->DespawnOrUnsummon(duration + urand(0, 2000));
cr->DespawnOrUnsummon(duration + randtime(0ms, 2s));
}
}
}
@@ -355,7 +355,7 @@ struct npc_time_rift : public NullCreatureAI
{
if (creature->GetGUID() == _riftKeeperGUID)
{
me->DespawnOrUnsummon(0);
me->DespawnOrUnsummon(0ms);
}
}

View File

@@ -58,7 +58,7 @@ public:
case NPC_HIGHBORNE_SUMMONER:
if (_pylonsState == ALL_PYLONS_OFF)
{
creature->DespawnOrUnsummon(5000);
creature->DespawnOrUnsummon(5s);
}
else
{

View File

@@ -115,7 +115,7 @@ public:
void JustDied(Unit* /*killer*/) override
{
me->DespawnOrUnsummon(5000);
me->DespawnOrUnsummon(5s);
}
void sQuestAccept(Player* /*player*/, Quest const* quest) override

View File

@@ -231,7 +231,7 @@ struct npc_buru_egg : public ScriptedAI
}
}
me->DespawnOrUnsummon(5000);
me->DespawnOrUnsummon(5s);
}
void UpdateAI(uint32 /*diff*/) override { }

View File

@@ -310,7 +310,7 @@ public:
me->RemoveDynamicFlag(UNIT_DYNFLAG_LOOTABLE);
DoFinalSpell();
Talk(EMOTE_DEVOURED);
me->DespawnOrUnsummon(3000);
me->DespawnOrUnsummon(3s);
return;
}

View File

@@ -170,7 +170,7 @@ struct boss_ouro : public BossAI
}
}
me->DespawnOrUnsummon(1000);
me->DespawnOrUnsummon(1s);
}
void CastGroundRupture()
@@ -273,7 +273,7 @@ struct boss_ouro : public BossAI
if (me->GetThreatMgr().GetThreatList().empty())
{
DoCastSelf(SPELL_OURO_SUBMERGE_VISUAL);
me->DespawnOrUnsummon(1000);
me->DespawnOrUnsummon(1s);
instance->SetBossState(DATA_OURO, FAIL);
if (GameObject* base = me->FindNearestGameObject(GO_SANDWORM_BASE, 200.f))
base->DespawnOrUnsummon();
@@ -334,7 +334,7 @@ struct npc_dirt_mound : ScriptedAI
scheduler.Schedule(30s, [this](TaskContext /*context*/)
{
DoCastSelf(SPELL_SUMMON_SCARABS, true);
me->DespawnOrUnsummon(1000);
me->DespawnOrUnsummon(1s);
})
.Schedule(100ms, [this](TaskContext context)
{

View File

@@ -418,7 +418,7 @@ public:
if (Creature* mastersEye = instance->GetCreature(DATA_MASTERS_EYE))
{
mastersEye->AI()->Talk(EMOTE_MASTERS_EYE_AT, player);
mastersEye->DespawnOrUnsummon(11000);
mastersEye->DespawnOrUnsummon(11s);
mastersEye->m_Events.AddEventAtOffset([mastersEye, player]()
{
mastersEye->SetFacingToObject(player);

View File

@@ -474,7 +474,7 @@ struct npc_ahnqiraji_critter : public ScriptedAI
{
if (me->GetEntry() == NPC_QIRAJI_SCORPION)
{
me->DespawnOrUnsummon(5 * IN_MILLISECONDS);
me->DespawnOrUnsummon(5s);
}
}

View File

@@ -176,25 +176,25 @@ public:
if (Creature* weegli = ObjectAccessor::GetCreature(*me, instance->GetGuidData(NPC_WEEGLI)))
{
weegli->CastSpell(weegli, SPELL_BLYS_BAND_ESCAPE);
weegli->DespawnOrUnsummon(10000);
weegli->DespawnOrUnsummon(10s);
}
if (Creature* raven = ObjectAccessor::GetCreature(*me, instance->GetGuidData(NPC_RAVEN)))
{
raven->CastSpell(raven, SPELL_BLYS_BAND_ESCAPE);
raven->DespawnOrUnsummon(10000);
raven->DespawnOrUnsummon(10s);
}
if (Creature* oro = ObjectAccessor::GetCreature(*me, instance->GetGuidData(NPC_ORO)))
{
oro->CastSpell(oro, SPELL_BLYS_BAND_ESCAPE);
oro->DespawnOrUnsummon(10000);
oro->DespawnOrUnsummon(10s);
}
if (Creature* murta = ObjectAccessor::GetCreature(*me, instance->GetGuidData(NPC_MURTA)))
{
murta->CastSpell(murta, SPELL_BLYS_BAND_ESCAPE);
murta->DespawnOrUnsummon(10000);
murta->DespawnOrUnsummon(10s);
}
DoCastSelf(SPELL_BLYS_BAND_ESCAPE);
me->DespawnOrUnsummon(10000);
me->DespawnOrUnsummon(10s);
Porthome_Timer = 156000; //set timer back so that the event doesn't keep triggering
}
else
@@ -436,7 +436,7 @@ public:
case 1:
me->GetMotionMaster()->MovePoint(2, 1871.18f, 1100.f, 8.88f);
Talk(SAY_WEEGLI_OUT_OF_HERE);
me->DespawnOrUnsummon(8000);
me->DespawnOrUnsummon(8s);
instance->SetData(DATA_PYRAMID, PYRAMID_GATES_DESTROYED);
destroyingDoor = false;
break;

View File

@@ -463,7 +463,7 @@ public:
_events.Reset();
_events.ScheduleEvent(EVENT_CHECK_FOLLOWING, 1s);
player->KilledMonsterCredit(NPC_CAPTURED_RABID_THISTLE_BEAR);
me->DespawnOrUnsummon(240000);
me->DespawnOrUnsummon(240s);
}
}
}

View File

@@ -474,7 +474,7 @@ public:
else if (spell->Id == SPELL_KODO_KOMBO_GOSSIP)
{
me->SetNpcFlag(UNIT_NPC_FLAG_GOSSIP);
me->DespawnOrUnsummon(60000);
me->DespawnOrUnsummon(60s);
}
}
};

View File

@@ -300,11 +300,11 @@ public:
for (uint8 i = 0; i < 6; ++i) // unsummon challengers
if (AffrayChallenger[i])
if (Creature* creature = ObjectAccessor::GetCreature((*me), AffrayChallenger[i]))
creature->DespawnOrUnsummon(1);
creature->DespawnOrUnsummon(1ms);
if (BigWill) // unsummon bigWill
if (Creature* creature = ObjectAccessor::GetCreature((*me), BigWill))
creature->DespawnOrUnsummon(1);
creature->DespawnOrUnsummon(1ms);
}
void MoveInLineOfSight(Unit* who) override

View File

@@ -486,7 +486,7 @@ public:
if (Creature* guard = me->GetMap()->GetCreature(_guardEluneGUID))
{
guard->GetMotionMaster()->MovePoint(0, wingThicketLocations[2].m_positionX, wingThicketLocations[2].m_positionY, wingThicketLocations[2].m_positionZ);
guard->DespawnOrUnsummon(4000);
guard->DespawnOrUnsummon(4s);
}
break;
case SAY_PRIESTESS_ALTAR_20:
@@ -494,7 +494,7 @@ public:
if (Creature* priestess = me->GetMap()->GetCreature(_firstPriestessGUID))
{
priestess->GetMotionMaster()->MovePoint(0, wingThicketLocations[0].m_positionX, wingThicketLocations[0].m_positionY, wingThicketLocations[0].m_positionZ);
priestess->DespawnOrUnsummon(4000);
priestess->DespawnOrUnsummon(4s);
}
break;
case SAY_PRIESTESS_ALTAR_21:
@@ -502,7 +502,7 @@ public:
if (Creature* priestess = me->GetMap()->GetCreature(_secondPriestessGUID))
{
priestess->GetMotionMaster()->MovePoint(0, wingThicketLocations[1].m_positionX, wingThicketLocations[1].m_positionY, wingThicketLocations[1].m_positionZ);
priestess->DespawnOrUnsummon(4000);
priestess->DespawnOrUnsummon(4s);
}
break;
case DATA_EVENT_END:
@@ -526,7 +526,7 @@ public:
player->GroupEventHappens(QUEST_GUARDIANS_ALTAR, me);
Talk(SAY_RANSHALLA_END_2, player);
}
me->DespawnOrUnsummon(4000);
me->DespawnOrUnsummon(4s);
break;
}
}