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

Port From (https://github.com/TrinityCore/TrinityCore/commit/129dd7c9091d3fafc0f5e10b795224bc9418d006)
This commit is contained in:
hondacrx
2020-08-24 11:26:27 -04:00
parent 1b33551fab
commit 08ef556a36
14 changed files with 26 additions and 28 deletions
+2 -2
View File
@@ -437,8 +437,8 @@ namespace Game.AI
public virtual bool IsEscorted() { return false; } public virtual bool IsEscorted() { return false; }
// Called when creature is spawned or respawned // Called when creature appears in the world (spawn, respawn, grid load etc...)
public virtual void JustRespawned() { } public virtual void JustAppeared() { }
public virtual void MovementInform(MovementGeneratorType type, uint id) { } public virtual void MovementInform(MovementGeneratorType type, uint id) { }
@@ -140,7 +140,7 @@ namespace Game.AI
} }
} }
public override void JustRespawned() public override void JustAppeared()
{ {
m_uiEscortState = EscortState.None; m_uiEscortState = EscortState.None;
@@ -147,7 +147,7 @@ namespace Game.AI
} }
} }
public override void JustRespawned() public override void JustAppeared()
{ {
m_uiFollowState = FollowState.None; m_uiFollowState = FollowState.None;
+1 -1
View File
@@ -551,7 +551,7 @@ namespace Game.AI
return false; return false;
} }
public override void JustRespawned() public override void JustAppeared()
{ {
mDespawnTime = 0; mDespawnTime = 0;
mRespawnTime = 0; mRespawnTime = 0;
+1 -1
View File
@@ -661,7 +661,7 @@ namespace Game.Chat.Commands
Map map = player.GetMap(); Map map = player.GetMap();
uint mapId = map.GetId(); uint mapId = map.GetId();
bool showAll = map.IsBattlegroundOrArena() || map.IsDungeon(); bool showAll = map.IsBattlegroundOrArena() || map.IsDungeon();
handler.SendSysMessage("Listing all spawn points in map %u (%s)%s:", mapId, map.GetMapName(), showAll ? "" : " within 5000yd"); handler.SendSysMessage($"Listing all spawn points in map {mapId} ({map.GetMapName()}){(showAll ? "" : " within 5000yd")}:");
foreach (var pair in Global.ObjectMgr.GetAllCreatureData()) foreach (var pair in Global.ObjectMgr.GetAllCreatureData())
{ {
+2 -2
View File
@@ -222,8 +222,8 @@ namespace Game.Chat
} }
// Attempting creature load from DB data // Attempting creature load from DB data
CreatureData data = Global.ObjectMgr.GetCreatureData(lowguid); CreatureData data = Global.ObjectMgr.GetCreatureData(lowguid);
if (data == null) if (data == null)
{ {
handler.SendSysMessage(CypherStrings.CommandCreatguidnotfound, lowguid); handler.SendSysMessage(CypherStrings.CommandCreatguidnotfound, lowguid);
@@ -70,7 +70,7 @@ namespace Game.Entities
//Formation var //Formation var
CreatureGroup m_formation; CreatureGroup m_formation;
bool TriggerJustRespawned; bool triggerJustAppeared;
bool m_respawnCompatibilityMode; bool m_respawnCompatibilityMode;
public uint[] m_spells = new uint[SharedConst.MaxCreatureSpells]; public uint[] m_spells = new uint[SharedConst.MaxCreatureSpells];
+7 -9
View File
@@ -44,6 +44,7 @@ namespace Game.Entities
DefaultMovementType = MovementGeneratorType.Idle; DefaultMovementType = MovementGeneratorType.Idle;
m_regenHealth = true; m_regenHealth = true;
m_meleeDamageSchoolMask = SpellSchoolMask.Normal; m_meleeDamageSchoolMask = SpellSchoolMask.Normal;
triggerJustAppeared = true;
RegenTimer = SharedConst.CreatureRegenInterval; RegenTimer = SharedConst.CreatureRegenInterval;
@@ -378,10 +379,10 @@ namespace Game.Entities
public override void Update(uint diff) public override void Update(uint diff)
{ {
if (IsAIEnabled && TriggerJustRespawned) if (IsAIEnabled && triggerJustAppeared && m_deathState == DeathState.Alive)
{ {
TriggerJustRespawned = false; triggerJustAppeared = false;
GetAI().JustRespawned(); GetAI().JustAppeared();
if (VehicleKit != null) if (VehicleKit != null)
VehicleKit.Reset(); VehicleKit.Reset();
} }
@@ -1736,13 +1737,10 @@ namespace Game.Entities
//Re-initialize reactstate that could be altered by movementgenerators //Re-initialize reactstate that could be altered by movementgenerators
InitializeReactState(); 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
GetAI().Reset(); GetAI().Reset();
TriggerJustRespawned = true;//delay event to next tick so all creatures are created on the map before processing
} triggerJustAppeared = true;
uint poolid = GetSpawnId() != 0 ? Global.PoolMgr.IsPartOfAPool<Creature>(GetSpawnId()) : 0; uint poolid = GetSpawnId() != 0 ? Global.PoolMgr.IsPartOfAPool<Creature>(GetSpawnId()) : 0;
if (poolid != 0) if (poolid != 0)
+2 -2
View File
@@ -16,16 +16,16 @@
*/ */
using Framework.Constants; using Framework.Constants;
using Framework.Dynamic;
using Framework.GameMath; using Framework.GameMath;
using Game.BattleGrounds; using Game.BattleGrounds;
using Game.DataStorage; using Game.DataStorage;
using Game.Maps; using Game.Maps;
using Game.Movement; using Game.Movement;
using Game.Networking.Packets; using Game.Networking.Packets;
using Game.Spells;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using Game.Spells;
using Framework.Dynamic;
namespace Game.Entities namespace Game.Entities
{ {
+1 -1
View File
@@ -784,7 +784,7 @@ namespace Game
Log.outError(LogFilter.ServerLoading, $"Invalid value for Respawn.DynamicMode ({Values[WorldCfg.RespawnDynamicMode]}). Set to 0."); Log.outError(LogFilter.ServerLoading, $"Invalid value for Respawn.DynamicMode ({Values[WorldCfg.RespawnDynamicMode]}). Set to 0.");
Values[WorldCfg.RespawnDynamicMode] = 0; Values[WorldCfg.RespawnDynamicMode] = 0;
} }
Values[WorldCfg.RespawnDynamicEscortNpc] = GetDefaultValue("Respawn.DynamicEscortNPC", true); Values[WorldCfg.RespawnDynamicEscortNpc] = GetDefaultValue("Respawn.DynamicEscortNPC", false);
Values[WorldCfg.RespawnGuidWarnLevel] = GetDefaultValue("Respawn.GuidWarnLevel", 12000000); Values[WorldCfg.RespawnGuidWarnLevel] = GetDefaultValue("Respawn.GuidWarnLevel", 12000000);
if ((int)Values[WorldCfg.RespawnGuidWarnLevel] > 16777215) if ((int)Values[WorldCfg.RespawnGuidWarnLevel] > 16777215)
{ {
@@ -131,9 +131,9 @@ namespace Scripts.Northrend.AzjolNerub.AzjolNerub.KrikthirTheGatewatcher
SummonAdds(); SummonAdds();
} }
public override void JustRespawned() public override void JustAppeared()
{ {
base.JustRespawned(); base.JustAppeared();
SummonAdds(); SummonAdds();
} }
@@ -373,9 +373,9 @@ namespace Scripts.Northrend.AzjolNerub.AzjolNerub.Nadronox
Initialize(); Initialize();
} }
public override void JustRespawned() public override void JustAppeared()
{ {
base.JustRespawned(); base.JustAppeared();
Initialize(); Initialize();
} }
+2 -2
View File
@@ -486,7 +486,7 @@ namespace Scripts.Northrend.Ulduar
_events.ScheduleEvent(Events.Outtro1, 7000); _events.ScheduleEvent(Events.Outtro1, 7000);
} }
public override void JustRespawned() public override void JustAppeared()
{ {
//SetupEncounter(); //SetupEncounter();
} }
@@ -922,7 +922,7 @@ namespace Scripts.Northrend.Ulduar
} }
} }
public override void JustRespawned() public override void JustAppeared()
{ {
SetupEncounter(); SetupEncounter();
} }
+1 -1
View File
@@ -1740,7 +1740,7 @@ Respawn.DynamicMode = 0
# 1 - Enabled # 1 - Enabled
# Default: 0 - Disabled # Default: 0 - Disabled
Respawn.DynamicEscortNPC = 1 Respawn.DynamicEscortNPC = 0
# #
# Respawn.DynamicRateCreature # Respawn.DynamicRateCreature