Core/Spawns: Removed ObjectMgr::AddCreatureData and ObjectMgr::AddGameObjectData (old outdoorpvp helpers)
Port From (https://github.com/TrinityCore/TrinityCore/commit/e1eb474531c75cbfcfea65f11e288a381859f8fb)
This commit is contained in:
@@ -3754,57 +3754,6 @@ namespace Game
|
||||
RemoveSpawnDataFromGrid(data);
|
||||
}
|
||||
|
||||
public ulong AddCreatureData(uint entry, uint mapId, Position pos, uint spawntimedelay)
|
||||
{
|
||||
CreatureTemplate cInfo = GetCreatureTemplate(entry);
|
||||
if (cInfo == null)
|
||||
return 0;
|
||||
|
||||
uint level = cInfo.Minlevel == cInfo.Maxlevel ? (uint)cInfo.Minlevel : RandomHelper.URand(cInfo.Minlevel, cInfo.Maxlevel); // Only used for extracting creature base stats
|
||||
CreatureBaseStats stats = GetCreatureBaseStats(level, cInfo.UnitClass);
|
||||
Map map = Global.MapMgr.CreateBaseMap(mapId);
|
||||
if (!map)
|
||||
return 0;
|
||||
|
||||
CreatureLevelScaling scaling = cInfo.GetLevelScaling(map.GetDifficultyID());
|
||||
|
||||
ulong spawnId = GenerateCreatureSpawnId();
|
||||
CreatureData data = NewOrExistCreatureData(spawnId);
|
||||
data.SpawnId = spawnId;
|
||||
data.Id = entry;
|
||||
data.MapId = mapId;
|
||||
data.SpawnPoint.Relocate(pos);
|
||||
data.displayid = 0;
|
||||
data.equipmentId = 0;
|
||||
|
||||
data.spawntimesecs = (int)spawntimedelay;
|
||||
data.WanderDistance = 0;
|
||||
data.currentwaypoint = 0;
|
||||
data.curhealth = (uint)(Global.DB2Mgr.EvaluateExpectedStat(ExpectedStatType.CreatureHealth, level, cInfo.HealthScalingExpansion, scaling.ContentTuningID, (Class)cInfo.UnitClass) * cInfo.ModHealth * cInfo.ModHealthExtra);
|
||||
data.curmana = stats.GenerateMana(cInfo);
|
||||
data.movementType = (byte)cInfo.MovementType;
|
||||
data.SpawnDifficulties.Add(Difficulty.None);
|
||||
data.dbData = false;
|
||||
data.npcflag = (uint)cInfo.Npcflag;
|
||||
data.unit_flags = (uint)cInfo.UnitFlags;
|
||||
data.dynamicflags = cInfo.DynamicFlags;
|
||||
data.spawnGroupData = GetLegacySpawnGroup();
|
||||
|
||||
AddCreatureToGrid(data);
|
||||
|
||||
// We use spawn coords to spawn
|
||||
if (!map.Instanceable() && !map.IsRemovalGrid(data.SpawnPoint))
|
||||
{
|
||||
Creature creature = Creature.CreateCreatureFromDB(spawnId, map, true, true);
|
||||
if (!creature)
|
||||
{
|
||||
Log.outError(LogFilter.Server, "AddCreature: Cannot add creature entry {0} to map", entry);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
return spawnId;
|
||||
}
|
||||
public List<uint> GetCreatureQuestItemList(uint id)
|
||||
{
|
||||
return creatureQuestItemStorage.LookupByKey(id);
|
||||
@@ -4684,49 +4633,6 @@ namespace Game
|
||||
{
|
||||
RemoveSpawnDataFromGrid(data);
|
||||
}
|
||||
public ulong AddGameObjectData(uint entry, uint mapId, Position pos, Quaternion rot, uint spawntimedelay)
|
||||
{
|
||||
GameObjectTemplate goinfo = GetGameObjectTemplate(entry);
|
||||
if (goinfo == null)
|
||||
return 0;
|
||||
|
||||
Map map = Global.MapMgr.CreateBaseMap(mapId);
|
||||
if (map == null)
|
||||
return 0;
|
||||
|
||||
ulong spawnId = GenerateGameObjectSpawnId();
|
||||
GameObjectData data = NewOrExistGameObjectData(spawnId);
|
||||
data.SpawnId = spawnId;
|
||||
data.Id = entry;
|
||||
data.MapId = mapId;
|
||||
data.SpawnPoint.Relocate(pos);
|
||||
data.rotation = rot;
|
||||
data.spawntimesecs = (int)spawntimedelay;
|
||||
data.animprogress = 100;
|
||||
data.SpawnDifficulties.Add(Difficulty.None);
|
||||
data.goState = GameObjectState.Ready;
|
||||
data.artKit = (byte)(goinfo.type == GameObjectTypes.ControlZone ? 21 : 0);
|
||||
data.dbData = false;
|
||||
data.spawnGroupData = GetLegacySpawnGroup();
|
||||
|
||||
AddGameObjectToGrid(data);
|
||||
|
||||
// Spawn if necessary (loaded grids only)
|
||||
// We use spawn coords to spawn
|
||||
if (!map.Instanceable() && map.IsGridLoaded(data.SpawnPoint))
|
||||
{
|
||||
GameObject go = GameObject.CreateGameObjectFromDB(spawnId, map);
|
||||
if (!go)
|
||||
{
|
||||
Log.outError(LogFilter.Server, "AddGameObjectData: cannot add gameobject entry {0} to map", entry);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
Log.outDebug(LogFilter.Maps, $"AddGameObjectData: dbguid:{spawnId} entry:{entry} map:{mapId} pos:{data.SpawnPoint}");
|
||||
|
||||
return spawnId;
|
||||
}
|
||||
|
||||
public GameObjectAddon GetGameObjectAddon(ulong lowguid)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user