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.
This commit is contained in:
Treeston
2017-08-06 16:07:15 +02:00
parent dbda060ae7
commit 184c45cfe0
25 changed files with 54 additions and 91 deletions

View File

@@ -134,8 +134,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*/) { }

View File

@@ -150,7 +150,7 @@ void npc_escortAI::JustDied(Unit* /*killer*/)
}
}
void npc_escortAI::JustRespawned()
void npc_escortAI::JustAppeared()
{
m_uiEscortState = STATE_ESCORT_NONE;

View File

@@ -65,7 +65,7 @@ struct TC_GAME_API npc_escortAI : public ScriptedAI
void JustDied(Unit*) override;
void JustRespawned() override;
void JustAppeared() override;
void ReturnToLastPoint();

View File

@@ -145,7 +145,7 @@ void FollowerAI::JustDied(Unit* /*killer*/)
}
}
void FollowerAI::JustRespawned()
void FollowerAI::JustAppeared()
{
m_uiFollowState = STATE_FOLLOW_NONE;

View File

@@ -53,7 +53,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)

View File

@@ -566,7 +566,7 @@ bool SmartAI::AssistPlayerInCombatAgainst(Unit* who)
return false;
}
void SmartAI::JustRespawned()
void SmartAI::JustAppeared()
{
mDespawnTime = 0;
mDespawnState = 0;

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;

View File

@@ -239,7 +239,7 @@ m_lootRecipient(), m_lootRecipientGroup(0), _pickpocketLootRestore(0), m_corpseR
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(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;
@@ -254,7 +254,6 @@ _lastDamagedTime(0)
m_CombatDistance = 0;//MELEE_RANGE;
ResetLootMode(); // restore default loot mode
m_TriggerJustRespawned = false;
m_isTempWorldObject = false;
}
@@ -578,10 +577,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();
}
@@ -1907,13 +1906,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)

View File

@@ -407,7 +407,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 */

View File

@@ -1258,7 +1258,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)
{

View File

@@ -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();
}

View File

@@ -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);

View File

@@ -186,7 +186,7 @@ public:
Talk(YELL_KILL);
}
void JustRespawned() override
void JustAppeared() override
{
Talk(YELL_BIRTH);
}

View File

@@ -188,12 +188,12 @@ public:
Initialize();
}
void JustRespawned() override
void JustAppeared() override
{
_IsByOutrunner = false;
spawnId = 0;
npc_escortAI::JustRespawned();
npc_escortAI::JustAppeared();
}
void EnterCombat(Unit* who) override

View File

@@ -297,9 +297,9 @@ public:
Initialize();
}
void JustRespawned() override
void JustAppeared() override
{
BossAI::JustRespawned();
BossAI::JustAppeared();
Initialize();
}

View File

@@ -163,9 +163,9 @@ class boss_krik_thir : public CreatureScript
SummonAdds();
}
void JustRespawned() override
void JustAppeared() override
{
BossAI::JustRespawned();
BossAI::JustAppeared();
SummonAdds();
}

View File

@@ -566,7 +566,7 @@ class npc_halion_controller : public CreatureScript
_twilightDamageTaken = 0;
}
void JustRespawned() override
void JustAppeared() override
{
if (_instance->GetGuidData(DATA_HALION) || _instance->GetBossState(DATA_GENERAL_ZARITHRIAN) != DONE)
return;

View File

@@ -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)

View File

@@ -688,9 +688,9 @@ class npc_spinestalker : public CreatureScript
}
}
void JustRespawned() override
void JustAppeared() override
{
ScriptedAI::JustRespawned();
ScriptedAI::JustAppeared();
_instance->SetData(DATA_SINDRAGOSA_FROSTWYRMS, me->GetSpawnId()); // this cannot be in Reset because reset also happens on evade
}
@@ -825,9 +825,9 @@ class npc_rimefang : public CreatureScript
}
}
void JustRespawned() override
void JustAppeared() override
{
ScriptedAI::JustRespawned();
ScriptedAI::JustAppeared();
_instance->SetData(DATA_SINDRAGOSA_FROSTWYRMS, me->GetSpawnId()); // this cannot be in Reset because reset also happens on evade
}
@@ -991,9 +991,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)

View File

@@ -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->SetFlag(UNIT_FIELD_FLAGS, 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())
{

View File

@@ -211,7 +211,7 @@ public:
me->CastSpell(me, SPELL_ICE_PRISON, true);
}
void JustRespawned() override
void JustAppeared() override
{
Reset();
}

View File

@@ -924,7 +924,7 @@ public:
me->CastSpell(me, STORM_VISUAL, true);
}
void JustRespawned() override
void JustAppeared() override
{
Reset();
}

View File

@@ -738,7 +738,7 @@ public:
instance->SetGuidData(DATA_LEOTHERAS_EVENT_STARTER, who->GetGUID());
}
void JustRespawned() override
void JustAppeared() override
{
AddedBanish = false;
Reset();

View File

@@ -83,7 +83,7 @@ class boss_doomlord_kazzak : public CreatureScript
_events.ScheduleEvent(EVENT_BERSERK, 180000);
}
void JustRespawned() override
void JustAppeared() override
{
Talk(SAY_INTRO);
}

View File

@@ -1793,7 +1793,7 @@ Respawn.DynamicMode = 0
# 1 - Enabled
# Default: 0 - Disabled
Respawn.DynamicEscortNPC = 1
Respawn.DynamicEscortNPC = 0
#
# Respawn.DynamicRateCreature