Core/Scripts: dynamic_spawning follow-up, I had forgotten JustRespawned existed.

- Rename JustRespawned to JustAppeared, which better matches its behavior anyway.
- Properly invoke JustAppeared for new (re-)spawns - fixes #20111.
- Fix Thaddius script to work with dynamic_spawning (mostly unrelated to the above) - Feugen/Stalagg should really be a summon group, but I don't have time to fix that right now.
- Fix default value for DynamicEscortNPC to match worldserver.conf.dist.

(cherry picked from commit 184c45cfe0fbe4f3e4fb701f0f99994df98bdc8a)
This commit is contained in:
Treeston
2020-08-22 20:10:42 +02:00
committed by Shauren
parent 521a950f9c
commit 129dd7c909
24 changed files with 52 additions and 89 deletions
+2 -2
View File
@@ -121,8 +121,8 @@ class TC_GAME_API CreatureAI : public UnitAI
virtual bool IsEscorted() const { return false; }
// Called when creature is spawned or respawned
virtual void JustRespawned() { }
// Called when creature appears in the world (spawn, respawn, grid load etc...)
virtual void JustAppeared() { }
// Called at waypoint reached or point movement finished
virtual void MovementInform(uint32 /*type*/, uint32 /*id*/) { }
@@ -149,7 +149,7 @@ void npc_escortAI::JustDied(Unit* /*killer*/)
}
}
void npc_escortAI::JustRespawned()
void npc_escortAI::JustAppeared()
{
m_uiEscortState = STATE_ESCORT_NONE;
@@ -64,7 +64,7 @@ struct TC_GAME_API npc_escortAI : public ScriptedAI
void JustDied(Unit*) override;
void JustRespawned() override;
void JustAppeared() override;
void ReturnToLastPoint();
@@ -144,7 +144,7 @@ void FollowerAI::JustDied(Unit* /*killer*/)
}
}
void FollowerAI::JustRespawned()
void FollowerAI::JustAppeared()
{
m_uiFollowState = STATE_FOLLOW_NONE;
@@ -52,7 +52,7 @@ class TC_GAME_API FollowerAI : public ScriptedAI
void JustDied(Unit*) override;
void JustRespawned() override;
void JustAppeared() override;
void UpdateAI(uint32) override; //the "internal" update, calls UpdateFollowerAI()
virtual void UpdateFollowerAI(uint32); //used when it's needed to add code in update (abilities, scripted events, etc)
+1 -1
View File
@@ -565,7 +565,7 @@ bool SmartAI::AssistPlayerInCombatAgainst(Unit* who)
return false;
}
void SmartAI::JustRespawned()
void SmartAI::JustAppeared()
{
mDespawnTime = 0;
mRespawnTime = 0;
+1 -1
View File
@@ -71,7 +71,7 @@ class TC_GAME_API SmartAI : public CreatureAI
bool IsEscortInvokerInRange();
// Called when creature is spawned or respawned
void JustRespawned() override;
void JustAppeared() override;
// Called at reaching home after evade, InitializeAI(), EnterEvadeMode() for resetting variables
void JustReachedHome() override;
+7 -11
View File
@@ -287,7 +287,7 @@ _pickpocketLootRestore(0), m_corpseRemoveTime(0), m_respawnTime(0),
m_respawnDelay(300), m_corpseDelay(60), m_respawnradius(0.0f), m_boundaryCheckTime(2500), m_combatPulseTime(0), m_combatPulseDelay(0), m_reactState(REACT_AGGRESSIVE),
m_defaultMovementType(IDLE_MOTION_TYPE), m_spawnId(UI64LIT(0)), m_equipmentId(0), m_originalEquipmentId(0), m_AlreadyCallAssistance(false),
m_AlreadySearchedAssistance(false), m_regenHealth(true), m_cannotReachTarget(false), m_cannotReachTimer(0), m_AI_locked(false), m_meleeDamageSchoolMask(SPELL_SCHOOL_MASK_NORMAL),
m_originalEntry(0), m_homePosition(), m_transportHomePosition(), m_creatureInfo(nullptr), m_creatureData(nullptr), m_waypointID(0), m_path_id(0), m_formation(nullptr), m_respawnCompatibilityMode(false), m_focusSpell(nullptr), m_focusDelay(0), m_shouldReacquireTarget(false), m_suppressedOrientation(0.0f),
m_originalEntry(0), m_homePosition(), m_transportHomePosition(), m_creatureInfo(nullptr), m_creatureData(nullptr), m_waypointID(0), m_path_id(0), m_formation(nullptr), m_triggerJustAppeared(true), m_respawnCompatibilityMode(false), m_focusSpell(nullptr), m_focusDelay(0), m_shouldReacquireTarget(false), m_suppressedOrientation(0.0f),
_lastDamagedTime(0)
{
m_regenTimer = CREATURE_REGEN_INTERVAL;
@@ -301,7 +301,6 @@ _lastDamagedTime(0)
m_CombatDistance = 0;//MELEE_RANGE;
ResetLootMode(); // restore default loot mode
m_TriggerJustRespawned = false;
m_isTempWorldObject = false;
}
@@ -633,10 +632,10 @@ bool Creature::UpdateEntry(uint32 entry, CreatureData const* data /*= nullptr*/,
void Creature::Update(uint32 diff)
{
if (IsAIEnabled && m_TriggerJustRespawned)
if (IsAIEnabled && m_triggerJustAppeared && m_deathState == ALIVE)
{
m_TriggerJustRespawned = false;
AI()->JustRespawned();
m_triggerJustAppeared = false;
AI()->JustAppeared();
if (m_vehicleKit)
m_vehicleKit->Reset();
}
@@ -2075,13 +2074,10 @@ void Creature::Respawn(bool force)
//Re-initialize reactstate that could be altered by movementgenerators
InitializeReactState();
//Call AI respawn virtual function//Call AI respawn virtual function
if (IsAIEnabled)
{
//reset the AI to be sure no dirty or uninitialized values will be used till next tick
if (IsAIEnabled) // reset the AI to be sure no dirty or uninitialized values will be used till next tick
AI()->Reset();
m_TriggerJustRespawned = true;//delay event to next tick so all creatures are created on the map before processing
}
m_triggerJustAppeared = true;
uint32 poolid = GetSpawnId() ? sPoolMgr->IsPartOfAPool<Creature>(GetSpawnId()) : 0;
if (poolid)
+1 -1
View File
@@ -406,7 +406,7 @@ class TC_GAME_API Creature : public Unit, public GridObject<Creature>, public Ma
//Formation var
CreatureGroup* m_formation;
bool m_TriggerJustRespawned;
bool m_triggerJustAppeared;
bool m_respawnCompatibilityMode;
/* Spell focus system */
+1 -1
View File
@@ -1361,7 +1361,7 @@ void World::LoadConfigSettings(bool reload)
TC_LOG_ERROR("server.loading", "Invalid value for Respawn.DynamicMode (%u). Set to 0.", m_int_configs[CONFIG_RESPAWN_DYNAMICMODE]);
m_int_configs[CONFIG_RESPAWN_DYNAMICMODE] = 0;
}
m_bool_configs[CONFIG_RESPAWN_DYNAMIC_ESCORTNPC] = sConfigMgr->GetBoolDefault("Respawn.DynamicEscortNPC", true);
m_bool_configs[CONFIG_RESPAWN_DYNAMIC_ESCORTNPC] = sConfigMgr->GetBoolDefault("Respawn.DynamicEscortNPC", false);
m_int_configs[CONFIG_RESPAWN_GUIDWARNLEVEL] = sConfigMgr->GetIntDefault("Respawn.GuidWarnLevel", 12000000);
if (m_int_configs[CONFIG_RESPAWN_GUIDWARNLEVEL] > 16777215)
{
@@ -107,7 +107,7 @@ class npc_av_marshal_or_warmaster : public CreatureScript
events.ScheduleEvent(EVENT_CHECK_RESET, 5000);
}
void JustRespawned() override
void JustAppeared() override
{
Reset();
}
@@ -71,7 +71,7 @@ public:
events.ScheduleEvent(EVENT_RANDOM_YELL, urand(20 * IN_MILLISECONDS, 30 * IN_MILLISECONDS)); //20 to 30 seconds
}
void JustRespawned() override
void JustAppeared() override
{
Reset();
Talk(SAY_RESPAWN);
@@ -186,7 +186,7 @@ public:
Talk(YELL_KILL);
}
void JustRespawned() override
void JustAppeared() override
{
Talk(YELL_BIRTH);
}
@@ -297,9 +297,9 @@ public:
Initialize();
}
void JustRespawned() override
void JustAppeared() override
{
BossAI::JustRespawned();
BossAI::JustAppeared();
Initialize();
}
@@ -163,9 +163,9 @@ class boss_krik_thir : public CreatureScript
SummonAdds();
}
void JustRespawned() override
void JustAppeared() override
{
BossAI::JustRespawned();
BossAI::JustAppeared();
SummonAdds();
}
@@ -567,7 +567,7 @@ class npc_halion_controller : public CreatureScript
_twilightDamageTaken = 0;
}
void JustRespawned() override
void JustAppeared() override
{
if (!_instance->GetGuidData(DATA_HALION).IsEmpty() || _instance->GetBossState(DATA_GENERAL_ZARITHRIAN) != DONE)
return;
@@ -445,7 +445,7 @@ struct BloodPrincesBossAI : public BossAI
{
_spawnHealth = 1;
if (!me->isDead())
JustRespawned();
JustAppeared();
}
void Reset() override
@@ -493,7 +493,7 @@ struct BloodPrincesBossAI : public BossAI
}
}
void JustRespawned() override
void JustAppeared() override
{
if (Creature* controller = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_BLOOD_PRINCES_CONTROL)))
if (controller->AI()->GetData(DATA_INTRO) != DATA_INTRO_DONE)
@@ -690,9 +690,9 @@ class npc_spinestalker : public CreatureScript
}
}
void JustRespawned() override
void JustAppeared() override
{
ScriptedAI::JustRespawned();
ScriptedAI::JustAppeared();
_instance->SetGuidData(DATA_SINDRAGOSA_FROSTWYRMS, ObjectGuid::Create<HighGuid::Creature>(631, me->GetEntry(), me->GetSpawnId())); // this cannot be in Reset because reset also happens on evade
}
@@ -827,9 +827,9 @@ class npc_rimefang : public CreatureScript
}
}
void JustRespawned() override
void JustAppeared() override
{
ScriptedAI::JustRespawned();
ScriptedAI::JustAppeared();
_instance->SetGuidData(DATA_SINDRAGOSA_FROSTWYRMS, ObjectGuid::Create<HighGuid::Creature>(631, me->GetEntry(), me->GetSpawnId())); // this cannot be in Reset because reset also happens on evade
}
@@ -993,9 +993,9 @@ class npc_sindragosa_trash : public CreatureScript
Initialize();
}
void JustRespawned() override
void JustAppeared() override
{
ScriptedAI::JustRespawned();
ScriptedAI::JustAppeared();
// Increase add count
if (me->GetEntry() == NPC_FROSTWING_WHELP)
@@ -31,15 +31,12 @@ enum Phases
PHASE_NOT_ENGAGED = 1,
PHASE_PETS,
PHASE_TRANSITION,
PHASE_THADDIUS,
PHASE_RESETTING
PHASE_THADDIUS
};
enum AIActions
{
ACTION_RESET_ENCOUNTER_TIMER = -1, // sent from instance AI
ACTION_BEGIN_RESET_ENCOUNTER = 0, // sent from thaddius to pets to trigger despawn and encounter reset
ACTION_RESET_ENCOUNTER, // sent from thaddius to pets to trigger respawn and full reset
ACTION_FEUGEN_DIED, // sent from respective pet to thaddius to indicate death
ACTION_STALAGG_DIED, // ^
ACTION_FEUGEN_RESET, // pet to thaddius
@@ -171,9 +168,6 @@ struct boss_thaddius : public BossAI
{
events.SetPhase(PHASE_NOT_ENGAGED);
SetCombatMovement(false);
// initialize everything properly, and ensure that the coils are loaded by the time we initialize
BeginResetEncounter(true);
}
}
@@ -204,9 +198,9 @@ struct boss_thaddius : public BossAI
return false;
}
void JustRespawned() override
void JustAppeared() override
{
if (events.IsInPhase(PHASE_RESETTING))
if (instance->GetBossState(BOSS_THADDIUS) != DONE)
ResetEncounter();
}
@@ -225,22 +219,13 @@ struct boss_thaddius : public BossAI
{
switch (action)
{
case ACTION_RESET_ENCOUNTER_TIMER:
if (events.IsInPhase(PHASE_RESETTING))
ResetEncounter();
break;
case ACTION_FEUGEN_RESET:
case ACTION_STALAGG_RESET:
if (!events.IsInPhase(PHASE_NOT_ENGAGED) && !events.IsInPhase(PHASE_RESETTING))
if (!events.IsInPhase(PHASE_NOT_ENGAGED))
BeginResetEncounter();
break;
case ACTION_FEUGEN_AGGRO:
case ACTION_STALAGG_AGGRO:
if (events.IsInPhase(PHASE_RESETTING))
{
BeginResetEncounter();
return;
}
if (!events.IsInPhase(PHASE_NOT_ENGAGED))
return;
events.SetPhase(PHASE_PETS);
@@ -306,29 +291,24 @@ struct boss_thaddius : public BossAI
events.ScheduleEvent(EVENT_TRANSITION_3, Seconds(14), 0, PHASE_TRANSITION);
}
void BeginResetEncounter(bool initial = false)
void BeginResetEncounter()
{
if (instance->GetBossState(BOSS_THADDIUS) == DONE)
return;
if (events.IsInPhase(PHASE_RESETTING))
return;
// remove polarity shift debuffs on reset
instance->DoRemoveAurasDueToSpellOnPlayers(SPELL_POSITIVE_CHARGE_APPLY);
instance->DoRemoveAurasDueToSpellOnPlayers(SPELL_NEGATIVE_CHARGE_APPLY);
me->DespawnOrUnsummon();
me->SetRespawnTime(initial ? 5 : 30);
me->DespawnOrUnsummon(0, Seconds(30));
me->AddUnitFlag(UnitFlags(UNIT_FLAG_NOT_SELECTABLE | UNIT_FLAG_STUNNED));
me->SetImmuneToPC(true);
events.SetPhase(PHASE_RESETTING);
me->setActive(false);
if (Creature* feugen = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_FEUGEN)))
feugen->AI()->DoAction(ACTION_BEGIN_RESET_ENCOUNTER);
if (Creature* stalagg = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_STALAGG)))
stalagg->AI()->DoAction(ACTION_BEGIN_RESET_ENCOUNTER);
me->setActive(false);
}
void ResetEncounter()
@@ -340,10 +320,9 @@ struct boss_thaddius : public BossAI
events.SetPhase(PHASE_NOT_ENGAGED);
me->SetReactState(REACT_PASSIVE);
if (Creature* feugen = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_FEUGEN)))
feugen->AI()->DoAction(ACTION_RESET_ENCOUNTER);
if (Creature* stalagg = ObjectAccessor::GetCreature(*me, instance->GetGuidData(DATA_STALAGG)))
stalagg->AI()->DoAction(ACTION_RESET_ENCOUNTER);
// @todo these guys should really be moved to a summon group - this is merely a hack to make them work in dynamic_spawning
instance->instance->RemoveRespawnTime(SPAWN_TYPE_CREATURE, 130958, true); // Stalagg
instance->instance->RemoveRespawnTime(SPAWN_TYPE_CREATURE, 130959, true); // Feugen
}
void UpdateAI(uint32 diff) override
@@ -515,7 +494,7 @@ public:
{
if (GameObject* coil = myCoilGO())
coil->SetGoState(GO_STATE_READY);
me->DespawnOrUnsummon();
me->DespawnOrUnsummon(0, Hours(24*7)); // will be force respawned by thaddius
me->setActive(false);
}
@@ -532,9 +511,6 @@ public:
case ACTION_BEGIN_RESET_ENCOUNTER:
BeginResetEncounter();
break;
case ACTION_RESET_ENCOUNTER:
ResetEncounter();
break;
case ACTION_STALAGG_REVIVING_FX:
break;
case ACTION_STALAGG_REVIVED:
@@ -559,7 +535,7 @@ public:
break;
case ACTION_TRANSITION:
me->KillSelf(); // true death
me->DespawnOrUnsummon();
me->DespawnOrUnsummon(0, Hours(24*7));
if (Creature* coil = myCoil())
{
@@ -781,16 +757,10 @@ public:
{
if (GameObject* coil = myCoilGO())
coil->SetGoState(GO_STATE_READY);
me->DespawnOrUnsummon();
me->DespawnOrUnsummon(0, Hours(24*7)); // will be force respawned by thaddius
me->setActive(false);
}
void ResetEncounter()
{
me->Respawn(true);
Initialize();
}
void DoAction(int32 action) override
{
switch (action)
@@ -798,9 +768,6 @@ public:
case ACTION_BEGIN_RESET_ENCOUNTER:
BeginResetEncounter();
break;
case ACTION_RESET_ENCOUNTER:
ResetEncounter();
break;
case ACTION_FEUGEN_REVIVING_FX:
break;
case ACTION_FEUGEN_REVIVED:
@@ -827,7 +794,7 @@ public:
break;
case ACTION_TRANSITION:
me->KillSelf(); // true death this time around
me->DespawnOrUnsummon();
me->DespawnOrUnsummon(0, Hours(24*7));
if (Creature* coil = myCoil())
{
@@ -212,7 +212,7 @@ public:
me->CastSpell(me, SPELL_ICE_PRISON, true);
}
void JustRespawned() override
void JustAppeared() override
{
Reset();
}
@@ -924,7 +924,7 @@ public:
me->CastSpell(me, STORM_VISUAL, true);
}
void JustRespawned() override
void JustAppeared() override
{
Reset();
}
@@ -736,7 +736,7 @@ public:
instance->SetGuidData(DATA_LEOTHERAS_EVENT_STARTER, who->GetGUID());
}
void JustRespawned() override
void JustAppeared() override
{
AddedBanish = false;
Reset();
@@ -81,7 +81,7 @@ class boss_doomlord_kazzak : public CreatureScript
_events.ScheduleEvent(EVENT_BERSERK, 180000);
}
void JustRespawned() override
void JustAppeared() override
{
Talk(SAY_INTRO);
}
+1 -1
View File
@@ -1855,7 +1855,7 @@ Respawn.DynamicMode = 0
# 1 - Enabled
# Default: 0 - Disabled
Respawn.DynamicEscortNPC = 1
Respawn.DynamicEscortNPC = 0
#
# Respawn.DynamicRateCreature