Core/Entities: Created factory methods to create new areatriggers, creatures and gameobjects
This commit is contained in:
@@ -75,7 +75,16 @@ namespace Game.Entities
|
||||
}
|
||||
}
|
||||
|
||||
public bool CreateAreaTrigger(uint spellMiscId, Unit caster, Unit target, SpellInfo spell, Position pos, int duration, uint spellXSpellVisualId, ObjectGuid castId = default(ObjectGuid), AuraEffect aurEff = null)
|
||||
public static AreaTrigger CreateAreaTrigger(uint spellMiscId, Unit caster, Unit target, SpellInfo spell, Position pos, int duration, uint spellXSpellVisualId, ObjectGuid castId = default(ObjectGuid), AuraEffect aurEff = null)
|
||||
{
|
||||
AreaTrigger at = new AreaTrigger();
|
||||
if (!at.Create(spellMiscId, caster, target, spell, pos, duration, spellXSpellVisualId, castId, aurEff))
|
||||
return null;
|
||||
|
||||
return at;
|
||||
}
|
||||
|
||||
bool Create(uint spellMiscId, Unit caster, Unit target, SpellInfo spell, Position pos, int duration, uint spellXSpellVisualId, ObjectGuid castId, AuraEffect aurEff)
|
||||
{
|
||||
_targetGuid = target ? target.GetGUID() : ObjectGuid.Empty;
|
||||
_aurEff = aurEff;
|
||||
|
||||
@@ -720,7 +720,35 @@ namespace Game.Entities
|
||||
GetMotionMaster().Initialize();
|
||||
}
|
||||
|
||||
public bool Create(ulong guidlow, Map map, uint entry, float x, float y, float z, float ang, CreatureData data = null, uint vehId = 0)
|
||||
public static Creature CreateCreature(uint entry, Map map, Position pos, uint vehId = 0)
|
||||
{
|
||||
CreatureTemplate cInfo = Global.ObjectMgr.GetCreatureTemplate(entry);
|
||||
if (cInfo == null)
|
||||
return null;
|
||||
|
||||
ulong lowGuid;
|
||||
if (vehId != 0 || cInfo.VehicleId != 0)
|
||||
lowGuid = map.GenerateLowGuid(HighGuid.Vehicle);
|
||||
else
|
||||
lowGuid = map.GenerateLowGuid(HighGuid.Creature);
|
||||
|
||||
Creature creature = new Creature();
|
||||
if (!creature.Create(lowGuid, map, entry, pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), pos.GetOrientation(), null, vehId))
|
||||
return null;
|
||||
|
||||
return creature;
|
||||
}
|
||||
|
||||
public static Creature CreateCreatureFromDB(ulong spawnId, Map map, bool addToMap = true, bool allowDuplicate = false)
|
||||
{
|
||||
Creature creature = new Creature();
|
||||
if (!creature.LoadCreatureFromDB(spawnId, map, addToMap, allowDuplicate))
|
||||
return null;
|
||||
|
||||
return creature;
|
||||
}
|
||||
|
||||
public bool Create(ulong guidlow, Map map, uint entry, float x, float y, float z, float ang, CreatureData data, uint vehId)
|
||||
{
|
||||
SetMap(map);
|
||||
|
||||
@@ -1281,83 +1309,6 @@ namespace Game.Entities
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool LoadCreatureFromDB(ulong spawnId, Map map, bool addToMap = true, bool allowDuplicate = false)
|
||||
{
|
||||
if (!allowDuplicate)
|
||||
{
|
||||
// If an alive instance of this spawnId is already found, skip creation
|
||||
// If only dead instance(s) exist, despawn them and spawn a new (maybe also dead) version
|
||||
var creatureBounds = map.GetCreatureBySpawnIdStore().LookupByKey(spawnId);
|
||||
List<Creature> despawnList = new List<Creature>();
|
||||
|
||||
foreach (var creature in creatureBounds)
|
||||
{
|
||||
if (creature.IsAlive())
|
||||
{
|
||||
Log.outDebug(LogFilter.Maps, "Would have spawned {0} but {1} already exists", spawnId, creature.GetGUID().ToString());
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
despawnList.Add(creature);
|
||||
Log.outDebug(LogFilter.Maps, "Despawned dead instance of spawn {0} ({1})", spawnId, creature.GetGUID().ToString());
|
||||
}
|
||||
}
|
||||
|
||||
foreach (Creature despawnCreature in despawnList)
|
||||
{
|
||||
despawnCreature.AddObjectToRemoveList();
|
||||
}
|
||||
}
|
||||
|
||||
CreatureData data = Global.ObjectMgr.GetCreatureData(spawnId);
|
||||
if (data == null)
|
||||
{
|
||||
Log.outError(LogFilter.Sql, "Creature (GUID: {0}) not found in table `creature`, can't load. ", spawnId);
|
||||
return false;
|
||||
}
|
||||
|
||||
m_spawnId = spawnId;
|
||||
m_creatureData = data;
|
||||
if (!Create(map.GenerateLowGuid(HighGuid.Creature), map, data.id, data.posX, data.posY, data.posZ, data.orientation, data))
|
||||
return false;
|
||||
|
||||
//We should set first home position, because then AI calls home movement
|
||||
SetHomePosition(data.posX, data.posY, data.posZ, data.orientation);
|
||||
|
||||
m_respawnradius = data.spawndist;
|
||||
|
||||
m_respawnDelay = data.spawntimesecs;
|
||||
m_deathState = DeathState.Alive;
|
||||
|
||||
m_respawnTime = GetMap().GetCreatureRespawnTime(m_spawnId);
|
||||
|
||||
// Is the creature script objecting to us spawning? If yes, delay by one second (then re-check in ::Update)
|
||||
if (m_respawnTime == 0 && !Global.ScriptMgr.CanSpawn(spawnId, GetEntry(), GetCreatureTemplate(), GetCreatureData(), map))
|
||||
m_respawnTime = Time.UnixTime + 1;
|
||||
|
||||
if (m_respawnTime != 0) // respawn on Update
|
||||
{
|
||||
m_deathState = DeathState.Dead;
|
||||
if (CanFly())
|
||||
{
|
||||
float tz = map.GetHeight(GetPhases(), data.posX, data.posY, data.posZ, true, MapConst.MaxFallDistance);
|
||||
if (data.posZ - tz > 0.1f && GridDefines.IsValidMapCoord(tz))
|
||||
Relocate(data.posX, data.posY, tz);
|
||||
}
|
||||
}
|
||||
|
||||
SetSpawnHealth();
|
||||
|
||||
m_defaultMovementType = (MovementGeneratorType)data.movementType;
|
||||
|
||||
loot.SetGUID(ObjectGuid.Create(HighGuid.LootObject, data.mapid, data.id, GetMap().GenerateLowGuid(HighGuid.LootObject)));
|
||||
|
||||
if (addToMap && !GetMap().AddToMap(this))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void SetCanDualWield(bool value)
|
||||
{
|
||||
base.SetCanDualWield(value);
|
||||
@@ -2914,7 +2865,84 @@ namespace Game.Entities
|
||||
|
||||
public override bool LoadFromDB(ulong spawnId, Map map)
|
||||
{
|
||||
return LoadCreatureFromDB(spawnId, map, false);
|
||||
return LoadCreatureFromDB(spawnId, map, false, false);
|
||||
}
|
||||
|
||||
public bool LoadCreatureFromDB(ulong spawnId, Map map, bool addToMap, bool allowDuplicate)
|
||||
{
|
||||
if (!allowDuplicate)
|
||||
{
|
||||
// If an alive instance of this spawnId is already found, skip creation
|
||||
// If only dead instance(s) exist, despawn them and spawn a new (maybe also dead) version
|
||||
var creatureBounds = map.GetCreatureBySpawnIdStore().LookupByKey(spawnId);
|
||||
List<Creature> despawnList = new List<Creature>();
|
||||
|
||||
foreach (var creature in creatureBounds)
|
||||
{
|
||||
if (creature.IsAlive())
|
||||
{
|
||||
Log.outDebug(LogFilter.Maps, "Would have spawned {0} but {1} already exists", spawnId, creature.GetGUID().ToString());
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
despawnList.Add(creature);
|
||||
Log.outDebug(LogFilter.Maps, "Despawned dead instance of spawn {0} ({1})", spawnId, creature.GetGUID().ToString());
|
||||
}
|
||||
}
|
||||
|
||||
foreach (Creature despawnCreature in despawnList)
|
||||
{
|
||||
despawnCreature.AddObjectToRemoveList();
|
||||
}
|
||||
}
|
||||
|
||||
CreatureData data = Global.ObjectMgr.GetCreatureData(spawnId);
|
||||
if (data == null)
|
||||
{
|
||||
Log.outError(LogFilter.Sql, "Creature (GUID: {0}) not found in table `creature`, can't load. ", spawnId);
|
||||
return false;
|
||||
}
|
||||
|
||||
m_spawnId = spawnId;
|
||||
m_creatureData = data;
|
||||
if (!Create(map.GenerateLowGuid(HighGuid.Creature), map, data.id, data.posX, data.posY, data.posZ, data.orientation, data, 0))
|
||||
return false;
|
||||
|
||||
//We should set first home position, because then AI calls home movement
|
||||
SetHomePosition(data.posX, data.posY, data.posZ, data.orientation);
|
||||
|
||||
m_respawnradius = data.spawndist;
|
||||
|
||||
m_respawnDelay = data.spawntimesecs;
|
||||
m_deathState = DeathState.Alive;
|
||||
|
||||
m_respawnTime = GetMap().GetCreatureRespawnTime(m_spawnId);
|
||||
|
||||
// Is the creature script objecting to us spawning? If yes, delay by one second (then re-check in ::Update)
|
||||
if (m_respawnTime == 0 && !Global.ScriptMgr.CanSpawn(spawnId, GetEntry(), GetCreatureTemplate(), GetCreatureData(), map))
|
||||
m_respawnTime = Time.UnixTime + 1;
|
||||
|
||||
if (m_respawnTime != 0) // respawn on Update
|
||||
{
|
||||
m_deathState = DeathState.Dead;
|
||||
if (CanFly())
|
||||
{
|
||||
float tz = map.GetHeight(GetPhases(), data.posX, data.posY, data.posZ, true, MapConst.MaxFallDistance);
|
||||
if (data.posZ - tz > 0.1f && GridDefines.IsValidMapCoord(tz))
|
||||
Relocate(data.posX, data.posY, tz);
|
||||
}
|
||||
}
|
||||
|
||||
SetSpawnHealth();
|
||||
|
||||
m_defaultMovementType = (MovementGeneratorType)data.movementType;
|
||||
|
||||
loot.SetGUID(ObjectGuid.Create(HighGuid.LootObject, data.mapid, data.id, GetMap().GenerateLowGuid(HighGuid.LootObject)));
|
||||
|
||||
if (addToMap && !GetMap().AddToMap(this))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool hasLootRecipient() { return !m_lootRecipient.IsEmpty() || !m_lootRecipientGroup.IsEmpty(); }
|
||||
|
||||
@@ -158,7 +158,29 @@ namespace Game.Entities
|
||||
}
|
||||
}
|
||||
|
||||
public bool Create(uint name_id, Map map, Position pos, Quaternion rotation, uint animprogress, GameObjectState go_state, uint artKit = 0)
|
||||
public static GameObject CreateGameObject(uint entry, Map map, Position pos, Quaternion rotation, uint animProgress, GameObjectState goState, uint artKit = 0)
|
||||
{
|
||||
GameObjectTemplate goInfo = Global.ObjectMgr.GetGameObjectTemplate(entry);
|
||||
if (goInfo == null)
|
||||
return null;
|
||||
|
||||
GameObject go = new GameObject();
|
||||
if (!go.Create(entry, map, pos, rotation, animProgress, goState, artKit))
|
||||
return null;
|
||||
|
||||
return go;
|
||||
}
|
||||
|
||||
public static GameObject CreateGameObjectFromDB(ulong spawnId, Map map, bool addToMap = true)
|
||||
{
|
||||
GameObject go = new GameObject();
|
||||
if (!go.LoadGameObjectFromDB(spawnId, map, addToMap))
|
||||
return null;
|
||||
|
||||
return go;
|
||||
}
|
||||
|
||||
bool Create(uint entry, Map map, Position pos, Quaternion rotation, uint animProgress, GameObjectState goState, uint artKit)
|
||||
{
|
||||
Contract.Assert(map);
|
||||
SetMap(map);
|
||||
@@ -167,34 +189,34 @@ namespace Game.Entities
|
||||
m_stationaryPosition.Relocate(pos);
|
||||
if (!IsPositionValid())
|
||||
{
|
||||
Log.outError(LogFilter.Server, "Gameobject (Spawn id: {0} Entry: {1}) not created. Suggested coordinates isn't valid (X: {2} Y: {3})", GetSpawnId(), name_id, pos.GetPositionX(), pos.GetPositionY());
|
||||
Log.outError(LogFilter.Server, "Gameobject (Spawn id: {0} Entry: {1}) not created. Suggested coordinates isn't valid (X: {2} Y: {3})", GetSpawnId(), entry, pos.GetPositionX(), pos.GetPositionY());
|
||||
return false;
|
||||
}
|
||||
|
||||
SetZoneScript();
|
||||
if (m_zoneScript != null)
|
||||
{
|
||||
name_id = m_zoneScript.GetGameObjectEntry(m_spawnId, name_id);
|
||||
if (name_id == 0)
|
||||
entry = m_zoneScript.GetGameObjectEntry(m_spawnId, entry);
|
||||
if (entry == 0)
|
||||
return false;
|
||||
}
|
||||
|
||||
GameObjectTemplate goinfo = Global.ObjectMgr.GetGameObjectTemplate(name_id);
|
||||
if (goinfo == null)
|
||||
GameObjectTemplate goInfo = Global.ObjectMgr.GetGameObjectTemplate(entry);
|
||||
if (goInfo == null)
|
||||
{
|
||||
Log.outError(LogFilter.Sql, "Gameobject (Spawn id: {0} Entry: {1}) not created: non-existing entry in `gameobject_template`. Map: {2} (X: {3} Y: {4} Z: {5})", GetSpawnId(), name_id, map.GetId(), pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ());
|
||||
Log.outError(LogFilter.Sql, "Gameobject (Spawn id: {0} Entry: {1}) not created: non-existing entry in `gameobject_template`. Map: {2} (X: {3} Y: {4} Z: {5})", GetSpawnId(), entry, map.GetId(), pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ());
|
||||
return false;
|
||||
}
|
||||
|
||||
if (goinfo.type == GameObjectTypes.MapObjTransport)
|
||||
if (goInfo.type == GameObjectTypes.MapObjTransport)
|
||||
{
|
||||
Log.outError(LogFilter.Sql, "Gameobject (Spawn id: {0} Entry: {1}) not created: gameobject type GAMEOBJECT_TYPE_MAP_OBJ_TRANSPORT cannot be manually created.", GetSpawnId(), name_id);
|
||||
Log.outError(LogFilter.Sql, "Gameobject (Spawn id: {0} Entry: {1}) not created: gameobject type GAMEOBJECT_TYPE_MAP_OBJ_TRANSPORT cannot be manually created.", GetSpawnId(), entry);
|
||||
return false;
|
||||
}
|
||||
|
||||
ObjectGuid guid;
|
||||
if (goinfo.type != GameObjectTypes.Transport)
|
||||
guid = ObjectGuid.Create(HighGuid.GameObject, map.GetId(), goinfo.entry, map.GenerateLowGuid(HighGuid.GameObject));
|
||||
if (goInfo.type != GameObjectTypes.Transport)
|
||||
guid = ObjectGuid.Create(HighGuid.GameObject, map.GetId(), goInfo.entry, map.GenerateLowGuid(HighGuid.GameObject));
|
||||
else
|
||||
{
|
||||
guid = ObjectGuid.Create(HighGuid.Transport, map.GenerateLowGuid(HighGuid.Transport));
|
||||
@@ -203,12 +225,12 @@ namespace Game.Entities
|
||||
|
||||
_Create(guid);
|
||||
|
||||
m_goInfo = goinfo;
|
||||
m_goTemplateAddon = Global.ObjectMgr.GetGameObjectTemplateAddon(name_id);
|
||||
m_goInfo = goInfo;
|
||||
m_goTemplateAddon = Global.ObjectMgr.GetGameObjectTemplateAddon(entry);
|
||||
|
||||
if (goinfo.type >= GameObjectTypes.Max)
|
||||
if (goInfo.type >= GameObjectTypes.Max)
|
||||
{
|
||||
Log.outError(LogFilter.Sql, "Gameobject (Spawn id: {0} Entry: {1}) not created: non-existing GO type '{2}' in `gameobject_template`. It will crash client if created.", GetSpawnId(), name_id, goinfo.type);
|
||||
Log.outError(LogFilter.Sql, "Gameobject (Spawn id: {0} Entry: {1}) not created: non-existing GO type '{2}' in `gameobject_template`. It will crash client if created.", GetSpawnId(), entry, goInfo.type);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -222,7 +244,7 @@ namespace Game.Entities
|
||||
|
||||
SetParentRotation(parentRotation);
|
||||
|
||||
SetObjectScale(goinfo.size);
|
||||
SetObjectScale(goInfo.size);
|
||||
|
||||
if (m_goTemplateAddon != null)
|
||||
{
|
||||
@@ -236,85 +258,85 @@ namespace Game.Entities
|
||||
}
|
||||
}
|
||||
|
||||
SetEntry(goinfo.entry);
|
||||
SetEntry(goInfo.entry);
|
||||
|
||||
// set name for logs usage, doesn't affect anything ingame
|
||||
SetName(goinfo.name);
|
||||
SetName(goInfo.name);
|
||||
|
||||
SetDisplayId(goinfo.displayId);
|
||||
SetDisplayId(goInfo.displayId);
|
||||
|
||||
m_model = CreateModel();
|
||||
// GAMEOBJECT_BYTES_1, index at 0, 1, 2 and 3
|
||||
SetGoType(goinfo.type);
|
||||
m_prevGoState = go_state;
|
||||
SetGoState(go_state);
|
||||
SetGoType(goInfo.type);
|
||||
m_prevGoState = goState;
|
||||
SetGoState(goState);
|
||||
SetGoArtKit((byte)artKit);
|
||||
|
||||
switch (goinfo.type)
|
||||
switch (goInfo.type)
|
||||
{
|
||||
case GameObjectTypes.FishingHole:
|
||||
SetGoAnimProgress(animprogress);
|
||||
SetGoAnimProgress(animProgress);
|
||||
m_goValue.FishingHole.MaxOpens = RandomHelper.URand(GetGoInfo().FishingHole.minRestock, GetGoInfo().FishingHole.maxRestock);
|
||||
break;
|
||||
case GameObjectTypes.DestructibleBuilding:
|
||||
m_goValue.Building.Health = 20000;//goinfo.DestructibleBuilding.intactNumHits + goinfo.DestructibleBuilding.damagedNumHits;
|
||||
m_goValue.Building.MaxHealth = m_goValue.Building.Health;
|
||||
SetGoAnimProgress(255);
|
||||
SetUInt32Value(GameObjectFields.ParentRotation, goinfo.DestructibleBuilding.DestructibleModelRec);
|
||||
SetUInt32Value(GameObjectFields.ParentRotation, goInfo.DestructibleBuilding.DestructibleModelRec);
|
||||
break;
|
||||
case GameObjectTypes.Transport:
|
||||
m_goValue.Transport.AnimationInfo = Global.TransportMgr.GetTransportAnimInfo(goinfo.entry);
|
||||
m_goValue.Transport.AnimationInfo = Global.TransportMgr.GetTransportAnimInfo(goInfo.entry);
|
||||
m_goValue.Transport.PathProgress = Time.GetMSTime();
|
||||
if (m_goValue.Transport.AnimationInfo.Path != null)
|
||||
m_goValue.Transport.PathProgress -= m_goValue.Transport.PathProgress % GetTransportPeriod(); // align to period
|
||||
m_goValue.Transport.CurrentSeg = 0;
|
||||
m_goValue.Transport.StateUpdateTimer = 0;
|
||||
m_goValue.Transport.StopFrames = new List<uint>();
|
||||
if (goinfo.Transport.Timeto2ndfloor > 0)
|
||||
m_goValue.Transport.StopFrames.Add(goinfo.Transport.Timeto2ndfloor);
|
||||
if (goinfo.Transport.Timeto3rdfloor > 0)
|
||||
m_goValue.Transport.StopFrames.Add(goinfo.Transport.Timeto3rdfloor);
|
||||
if (goinfo.Transport.Timeto4thfloor > 0)
|
||||
m_goValue.Transport.StopFrames.Add(goinfo.Transport.Timeto4thfloor);
|
||||
if (goinfo.Transport.Timeto5thfloor > 0)
|
||||
m_goValue.Transport.StopFrames.Add(goinfo.Transport.Timeto5thfloor);
|
||||
if (goinfo.Transport.Timeto6thfloor > 0)
|
||||
m_goValue.Transport.StopFrames.Add(goinfo.Transport.Timeto6thfloor);
|
||||
if (goinfo.Transport.Timeto7thfloor > 0)
|
||||
m_goValue.Transport.StopFrames.Add(goinfo.Transport.Timeto7thfloor);
|
||||
if (goinfo.Transport.Timeto8thfloor > 0)
|
||||
m_goValue.Transport.StopFrames.Add(goinfo.Transport.Timeto8thfloor);
|
||||
if (goinfo.Transport.Timeto9thfloor > 0)
|
||||
m_goValue.Transport.StopFrames.Add(goinfo.Transport.Timeto9thfloor);
|
||||
if (goinfo.Transport.Timeto10thfloor > 0)
|
||||
m_goValue.Transport.StopFrames.Add(goinfo.Transport.Timeto10thfloor);
|
||||
if (goInfo.Transport.Timeto2ndfloor > 0)
|
||||
m_goValue.Transport.StopFrames.Add(goInfo.Transport.Timeto2ndfloor);
|
||||
if (goInfo.Transport.Timeto3rdfloor > 0)
|
||||
m_goValue.Transport.StopFrames.Add(goInfo.Transport.Timeto3rdfloor);
|
||||
if (goInfo.Transport.Timeto4thfloor > 0)
|
||||
m_goValue.Transport.StopFrames.Add(goInfo.Transport.Timeto4thfloor);
|
||||
if (goInfo.Transport.Timeto5thfloor > 0)
|
||||
m_goValue.Transport.StopFrames.Add(goInfo.Transport.Timeto5thfloor);
|
||||
if (goInfo.Transport.Timeto6thfloor > 0)
|
||||
m_goValue.Transport.StopFrames.Add(goInfo.Transport.Timeto6thfloor);
|
||||
if (goInfo.Transport.Timeto7thfloor > 0)
|
||||
m_goValue.Transport.StopFrames.Add(goInfo.Transport.Timeto7thfloor);
|
||||
if (goInfo.Transport.Timeto8thfloor > 0)
|
||||
m_goValue.Transport.StopFrames.Add(goInfo.Transport.Timeto8thfloor);
|
||||
if (goInfo.Transport.Timeto9thfloor > 0)
|
||||
m_goValue.Transport.StopFrames.Add(goInfo.Transport.Timeto9thfloor);
|
||||
if (goInfo.Transport.Timeto10thfloor > 0)
|
||||
m_goValue.Transport.StopFrames.Add(goInfo.Transport.Timeto10thfloor);
|
||||
|
||||
if (goinfo.Transport.startOpen != 0)
|
||||
SetTransportState(GameObjectState.TransportStopped, goinfo.Transport.startOpen - 1);
|
||||
if (goInfo.Transport.startOpen != 0)
|
||||
SetTransportState(GameObjectState.TransportStopped, goInfo.Transport.startOpen - 1);
|
||||
else
|
||||
SetTransportState(GameObjectState.TransportActive);
|
||||
|
||||
SetGoAnimProgress(animprogress);
|
||||
SetGoAnimProgress(animProgress);
|
||||
break;
|
||||
case GameObjectTypes.FishingNode:
|
||||
SetUInt32Value(GameObjectFields.Level, 1);
|
||||
SetGoAnimProgress(255);
|
||||
break;
|
||||
case GameObjectTypes.Trap:
|
||||
if (goinfo.Trap.stealthed != 0)
|
||||
if (goInfo.Trap.stealthed != 0)
|
||||
{
|
||||
m_stealth.AddFlag(StealthType.Trap);
|
||||
m_stealth.AddValue(StealthType.Trap, 70);
|
||||
}
|
||||
|
||||
if (goinfo.Trap.stealthAffected != 0)
|
||||
if (goInfo.Trap.stealthAffected != 0)
|
||||
{
|
||||
m_invisibility.AddFlag(InvisibilityType.Trap);
|
||||
m_invisibility.AddValue(InvisibilityType.Trap, 300);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
SetGoAnimProgress(animprogress);
|
||||
SetGoAnimProgress(animProgress);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -340,14 +362,14 @@ namespace Game.Entities
|
||||
uint linkedEntry = GetGoInfo().GetLinkedGameObjectEntry();
|
||||
if (linkedEntry != 0)
|
||||
{
|
||||
GameObject linkedGO = new GameObject();
|
||||
if (linkedGO.Create(linkedEntry, map, pos, rotation, 255, GameObjectState.Ready))
|
||||
GameObject linkedGo = CreateGameObject(linkedEntry, map, pos, rotation, 255, GameObjectState.Ready);
|
||||
if (linkedGo != null)
|
||||
{
|
||||
SetLinkedTrap(linkedGO);
|
||||
map.AddToMap(linkedGO);
|
||||
SetLinkedTrap(linkedGo);
|
||||
map.AddToMap(linkedGo);
|
||||
}
|
||||
else
|
||||
linkedGO.Dispose();
|
||||
linkedGo.Dispose();
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -907,10 +929,9 @@ namespace Game.Entities
|
||||
DB.World.Execute(stmt);
|
||||
}
|
||||
|
||||
public bool LoadGameObjectFromDB(ulong spawnId, Map map, bool addToMap = true)
|
||||
bool LoadGameObjectFromDB(ulong spawnId, Map map, bool addToMap)
|
||||
{
|
||||
GameObjectData data = Global.ObjectMgr.GetGOData(spawnId);
|
||||
|
||||
if (data == null)
|
||||
{
|
||||
Log.outError(LogFilter.Maps, "Gameobject (SpawnId: {0}) not found in table `gameobject`, can't load. ", spawnId);
|
||||
|
||||
@@ -2043,8 +2043,8 @@ namespace Game.Entities
|
||||
}
|
||||
|
||||
Map map = GetMap();
|
||||
GameObject go = new GameObject();
|
||||
if (!go.Create(entry, map, pos, rotation, 255, GameObjectState.Ready))
|
||||
GameObject go = GameObject.CreateGameObject(entry, map, pos, rotation, 255, GameObjectState.Ready);
|
||||
if (!go)
|
||||
return null;
|
||||
|
||||
go.CopyPhaseFrom(this);
|
||||
|
||||
@@ -309,9 +309,9 @@ namespace Game.Entities
|
||||
public Creature CreateNPCPassenger(ulong guid, CreatureData data)
|
||||
{
|
||||
Map map = GetMap();
|
||||
Creature creature = new Creature();
|
||||
|
||||
if (!creature.LoadCreatureFromDB(guid, map, false))
|
||||
Creature creature = Creature.CreateCreatureFromDB(guid, map, false);
|
||||
if (!creature)
|
||||
return null;
|
||||
|
||||
float x = data.posX;
|
||||
@@ -359,9 +359,9 @@ namespace Game.Entities
|
||||
GameObject CreateGOPassenger(ulong guid, GameObjectData data)
|
||||
{
|
||||
Map map = GetMap();
|
||||
GameObject go = new GameObject();
|
||||
|
||||
if (!go.LoadGameObjectFromDB(guid, map, false))
|
||||
GameObject go = CreateGameObjectFromDB(guid, map, false);
|
||||
if (!go)
|
||||
return null;
|
||||
|
||||
float x = data.posX;
|
||||
|
||||
Reference in New Issue
Block a user