Core/Entities: Created factory methods to create new areatriggers, creatures and gameobjects
This commit is contained in:
@@ -672,24 +672,20 @@ namespace Game.BattleFields
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
CreatureTemplate cinfo = Global.ObjectMgr.GetCreatureTemplate(entry);
|
if (Global.ObjectMgr.GetCreatureTemplate(entry) == null)
|
||||||
if (cinfo == null)
|
|
||||||
{
|
{
|
||||||
Log.outError(LogFilter.Battlefield, "Battlefield:SpawnCreature: entry {0} does not exist.", entry);
|
Log.outError(LogFilter.Battlefield, "Battlefield:SpawnCreature: entry {0} does not exist.", entry);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
float x, y, z, o;
|
Creature creature = Creature.CreateCreature(entry, map, pos);
|
||||||
pos.GetPosition(out x, out y, out z, out o);
|
if (!creature)
|
||||||
|
|
||||||
Creature creature = new Creature();
|
|
||||||
if (!creature.Create(map.GenerateLowGuid(HighGuid.Creature), map, entry, x, y, z, o))
|
|
||||||
{
|
{
|
||||||
Log.outError(LogFilter.Battlefield, "Battlefield:SpawnCreature: Can't create creature entry: {0}", entry);
|
Log.outError(LogFilter.Battlefield, "Battlefield:SpawnCreature: Can't create creature entry: {0}", entry);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
creature.SetHomePosition(x, y, z, o);
|
creature.SetHomePosition(pos);
|
||||||
|
|
||||||
// Set creature in world
|
// Set creature in world
|
||||||
map.AddToMap(creature);
|
map.AddToMap(creature);
|
||||||
@@ -706,16 +702,15 @@ namespace Game.BattleFields
|
|||||||
if (!map)
|
if (!map)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
GameObjectTemplate goInfo = Global.ObjectMgr.GetGameObjectTemplate(entry);
|
if (Global.ObjectMgr.GetGameObjectTemplate(entry) == null)
|
||||||
if (goInfo == null)
|
|
||||||
{
|
{
|
||||||
Log.outError(LogFilter.Battlefield, "Battlefield.SpawnGameObject: GameObject template {0} not found in database! Battlefield not created!", entry);
|
Log.outError(LogFilter.Battlefield, "Battlefield.SpawnGameObject: GameObject template {0} not found in database! Battlefield not created!", entry);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create gameobject
|
// Create gameobject
|
||||||
GameObject go = new GameObject();
|
GameObject go = GameObject.CreateGameObject(entry, map, pos, rotation, 255, GameObjectState.Ready);
|
||||||
if (!go.Create(entry, map, pos, rotation, 255, GameObjectState.Ready))
|
if (!go)
|
||||||
{
|
{
|
||||||
Log.outError(LogFilter.Battlefield, "Battlefield:SpawnGameObject: Cannot create gameobject template {1}! Battlefield not created!", entry);
|
Log.outError(LogFilter.Battlefield, "Battlefield:SpawnGameObject: Cannot create gameobject template {1}! Battlefield not created!", entry);
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -1331,8 +1331,8 @@ namespace Game.BattleGrounds
|
|||||||
// Must be created this way, adding to godatamap would add it to the base map of the instance
|
// Must be created this way, adding to godatamap would add it to the base map of the instance
|
||||||
// and when loading it (in go.LoadFromDB()), a new guid would be assigned to the object, and a new object would be created
|
// and when loading it (in go.LoadFromDB()), a new guid would be assigned to the object, and a new object would be created
|
||||||
// So we must create it specific for this instance
|
// So we must create it specific for this instance
|
||||||
GameObject go = new GameObject();
|
GameObject go = GameObject.CreateGameObject(entry, GetBgMap(), new Position(x, y, z, o), rotation, 255, goState);
|
||||||
if (!go.Create(entry, GetBgMap(), new Position(x, y, z, o), rotation, 100, goState))
|
if (!go)
|
||||||
{
|
{
|
||||||
Log.outError(LogFilter.Battleground, "Battleground.AddObject: cannot create gameobject (entry: {0}) for BG (map: {1}, instance id: {2})!", entry, m_MapId, m_InstanceID);
|
Log.outError(LogFilter.Battleground, "Battleground.AddObject: cannot create gameobject (entry: {0}) for BG (map: {1}, instance id: {2})!", entry, m_MapId, m_InstanceID);
|
||||||
return false;
|
return false;
|
||||||
@@ -1435,6 +1435,13 @@ namespace Game.BattleGrounds
|
|||||||
if (!map)
|
if (!map)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
|
if (Global.ObjectMgr.GetCreatureTemplate(entry) == null)
|
||||||
|
{
|
||||||
|
Log.outError(LogFilter.Battleground, $"Battleground.AddCreature: creature template (entry: {entry}) does not exist for BG (map: {m_MapId}, instance id: {m_InstanceID})!");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (transport)
|
if (transport)
|
||||||
{
|
{
|
||||||
Creature transCreature = transport.SummonPassenger(entry, new Position(x, y, z, o), TempSummonType.ManualDespawn);
|
Creature transCreature = transport.SummonPassenger(entry, new Position(x, y, z, o), TempSummonType.ManualDespawn);
|
||||||
@@ -1447,26 +1454,17 @@ namespace Game.BattleGrounds
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
Creature creature = new Creature();
|
Position pos = new Position(x, y, z, o);
|
||||||
if (!creature.Create(map.GenerateLowGuid(HighGuid.Creature), map, entry, x, y, z, o))
|
|
||||||
|
Creature creature = Creature.CreateCreature(entry, map, pos);
|
||||||
|
if (!creature)
|
||||||
{
|
{
|
||||||
Log.outError(LogFilter.Battleground, "Battleground.AddCreature: cannot create creature (entry: {0}) for BG (map: {1}, instance id: {2})!",
|
Log.outError(LogFilter.Battleground, "Battleground.AddCreature: cannot create creature (entry: {0}) for BG (map: {1}, instance id: {2})!",
|
||||||
entry, m_MapId, m_InstanceID);
|
entry, m_MapId, m_InstanceID);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
creature.SetHomePosition(x, y, z, o);
|
creature.SetHomePosition(pos);
|
||||||
|
|
||||||
CreatureTemplate cinfo = Global.ObjectMgr.GetCreatureTemplate(entry);
|
|
||||||
if (cinfo == null)
|
|
||||||
{
|
|
||||||
Log.outError(LogFilter.Battleground, "Battleground.AddCreature: creature template (entry: {0}) does not exist for BG (map: {1}, instance id: {2})!",
|
|
||||||
entry, m_MapId, m_InstanceID);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
// Force using DB speeds
|
|
||||||
creature.SetSpeed(UnitMoveType.Walk, cinfo.SpeedWalk);
|
|
||||||
creature.SetSpeed(UnitMoveType.Run, cinfo.SpeedRun);
|
|
||||||
|
|
||||||
if (!map.AddToMap(creature))
|
if (!map.AddToMap(creature))
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -938,13 +938,14 @@ namespace Game.Chat
|
|||||||
if (vehicleRecord == null)
|
if (vehicleRecord == null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
Creature creature = new Creature();
|
|
||||||
|
|
||||||
Map map = handler.GetSession().GetPlayer().GetMap();
|
Map map = handler.GetSession().GetPlayer().GetMap();
|
||||||
if (!creature.Create(map.GenerateLowGuid(HighGuid.Vehicle), map, entry, x, y, z, o, null, id))
|
Position pos = new Position(x, y, z, o);
|
||||||
|
|
||||||
|
Creature creature = Creature.CreateCreature(entry, map, pos, id);
|
||||||
|
if (!creature)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
map.AddToMap(creature.ToCreature());
|
map.AddToMap(creature);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -473,10 +473,8 @@ namespace Game.Chat
|
|||||||
Player player = handler.GetPlayer();
|
Player player = handler.GetPlayer();
|
||||||
Map map = player.GetMap();
|
Map map = player.GetMap();
|
||||||
|
|
||||||
GameObject obj = new GameObject();
|
GameObject obj = GameObject.CreateGameObject(objectInfo.entry, map, player, new Quaternion(Matrix3.fromEulerAnglesZYX(player.GetOrientation(), 0.0f, 0.0f)), 255, GameObjectState.Ready);
|
||||||
|
if (!obj)
|
||||||
Quaternion rotation = new Quaternion(Matrix3.fromEulerAnglesZYX(player.GetOrientation(), 0.0f, 0.0f));
|
|
||||||
if (!obj.Create(objectInfo.entry, map, player, rotation, 255, GameObjectState.Ready))
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
obj.CopyPhaseFrom(player);
|
obj.CopyPhaseFrom(player);
|
||||||
@@ -491,7 +489,8 @@ namespace Game.Chat
|
|||||||
ulong spawnId = obj.GetSpawnId();
|
ulong spawnId = obj.GetSpawnId();
|
||||||
|
|
||||||
// this will generate a new guid if the object is in an instance
|
// this will generate a new guid if the object is in an instance
|
||||||
if (!obj.LoadGameObjectFromDB(spawnId, map))
|
obj = GameObject.CreateGameObjectFromDB(spawnId, map);
|
||||||
|
if (!obj)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// TODO: is it really necessary to add both the real and DB table guid here ?
|
// TODO: is it really necessary to add both the real and DB table guid here ?
|
||||||
|
|||||||
@@ -1094,10 +1094,6 @@ namespace Game.Chat
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
Player chr = handler.GetSession().GetPlayer();
|
Player chr = handler.GetSession().GetPlayer();
|
||||||
float x = chr.GetPositionX();
|
|
||||||
float y = chr.GetPositionY();
|
|
||||||
float z = chr.GetPositionZ();
|
|
||||||
float o = chr.GetOrientation();
|
|
||||||
Map map = chr.GetMap();
|
Map map = chr.GetMap();
|
||||||
|
|
||||||
Transport trans = chr.GetTransport();
|
Transport trans = chr.GetTransport();
|
||||||
@@ -1119,8 +1115,8 @@ namespace Game.Chat
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Creature creature = new Creature();
|
Creature creature = Creature.CreateCreature(id, map, chr.GetPosition());
|
||||||
if (!creature.Create(map.GenerateLowGuid(HighGuid.Creature), map, id, x, y, z, o))
|
if (!creature)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
creature.CopyPhaseFrom(chr);
|
creature.CopyPhaseFrom(chr);
|
||||||
@@ -1131,8 +1127,8 @@ namespace Game.Chat
|
|||||||
// To call _LoadGoods(); _LoadQuests(); CreateTrainerSpells()
|
// To call _LoadGoods(); _LoadQuests(); CreateTrainerSpells()
|
||||||
// current "creature" variable is deleted and created fresh new, otherwise old values might trigger asserts or cause undefined behavior
|
// current "creature" variable is deleted and created fresh new, otherwise old values might trigger asserts or cause undefined behavior
|
||||||
creature.CleanupsBeforeDelete();
|
creature.CleanupsBeforeDelete();
|
||||||
creature = new Creature();
|
creature = Creature.CreateCreatureFromDB(db_guid, map);
|
||||||
if (!creature.LoadCreatureFromDB(db_guid, map))
|
if (!creature)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
Global.ObjectMgr.AddCreatureToGrid(db_guid, Global.ObjectMgr.GetCreatureData(db_guid));
|
Global.ObjectMgr.AddCreatureToGrid(db_guid, Global.ObjectMgr.GetCreatureData(db_guid));
|
||||||
|
|||||||
@@ -545,31 +545,42 @@ namespace Game.Chat.Commands
|
|||||||
target.AddObjectToRemoveList();
|
target.AddObjectToRemoveList();
|
||||||
|
|
||||||
// re-create
|
// re-create
|
||||||
Creature wpCreature = new Creature();
|
Creature creature = Creature.CreateCreature(1, map, chr.GetPosition());
|
||||||
if (!wpCreature.Create(map.GenerateLowGuid(HighGuid.Creature), map, 1, chr.GetPositionX(), chr.GetPositionY(), chr.GetPositionZ(), chr.GetOrientation()))
|
if (!creature)
|
||||||
{
|
{
|
||||||
wpCreature.CopyPhaseFrom(chr);
|
handler.SendSysMessage(CypherStrings.WaypointVpNotcreated, 1);
|
||||||
wpCreature.SaveToDB(map.GetId(), 1ul << (int)map.GetSpawnMode());
|
return false;
|
||||||
// To call _LoadGoods(); _LoadQuests(); CreateTrainerSpells();
|
|
||||||
/// @todo Should we first use "Create" then use "LoadFromDB"?
|
|
||||||
if (!wpCreature.LoadCreatureFromDB(wpCreature.GetSpawnId(), map))
|
|
||||||
{
|
|
||||||
handler.SendSysMessage(CypherStrings.WaypointVpNotcreated, 1);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
stmt = DB.World.GetPreparedStatement(WorldStatements.UPD_WAYPOINT_DATA_POSITION);
|
|
||||||
stmt.AddValue(0, chr.GetPositionX());
|
|
||||||
stmt.AddValue(1, chr.GetPositionY());
|
|
||||||
stmt.AddValue(2, chr.GetPositionZ());
|
|
||||||
stmt.AddValue(3, pathid);
|
|
||||||
stmt.AddValue(4, point);
|
|
||||||
DB.World.Execute(stmt);
|
|
||||||
|
|
||||||
handler.SendSysMessage(CypherStrings.WaypointChanged);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
creature.CopyPhaseFrom(chr);
|
||||||
|
creature.SaveToDB(map.GetId(), 1ul << (int)map.GetSpawnMode());
|
||||||
|
|
||||||
|
ulong dbGuid = creature.GetSpawnId();
|
||||||
|
|
||||||
|
// current "wpCreature" variable is deleted and created fresh new, otherwise old values might trigger asserts or cause undefined behavior
|
||||||
|
creature.CleanupsBeforeDelete();
|
||||||
|
creature.Dispose();
|
||||||
|
|
||||||
|
// To call _LoadGoods(); _LoadQuests(); CreateTrainerSpells();
|
||||||
|
creature = Creature.CreateCreatureFromDB(dbGuid, map);
|
||||||
|
if (!creature)
|
||||||
|
{
|
||||||
|
handler.SendSysMessage(CypherStrings.WaypointVpNotcreated, 1);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
stmt = DB.World.GetPreparedStatement(WorldStatements.UPD_WAYPOINT_DATA_POSITION);
|
||||||
|
stmt.AddValue(0, chr.GetPositionX());
|
||||||
|
stmt.AddValue(1, chr.GetPositionY());
|
||||||
|
stmt.AddValue(2, chr.GetPositionZ());
|
||||||
|
stmt.AddValue(3, pathid);
|
||||||
|
stmt.AddValue(4, point);
|
||||||
|
DB.World.Execute(stmt);
|
||||||
|
|
||||||
|
handler.SendSysMessage(CypherStrings.WaypointChanged);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
} // move
|
} // move
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(arg_str))
|
if (string.IsNullOrEmpty(arg_str))
|
||||||
{
|
{
|
||||||
@@ -752,27 +763,27 @@ namespace Game.Chat.Commands
|
|||||||
|
|
||||||
Player chr = handler.GetSession().GetPlayer();
|
Player chr = handler.GetSession().GetPlayer();
|
||||||
Map map = chr.GetMap();
|
Map map = chr.GetMap();
|
||||||
float o = chr.GetOrientation();
|
Position pos = new Position(x, y, z, chr.GetOrientation());
|
||||||
|
|
||||||
Creature wpCreature = new Creature();
|
Creature creature = Creature.CreateCreature(id, map, pos);
|
||||||
if (!wpCreature.Create(map.GenerateLowGuid(HighGuid.Creature), map, id, x, y, z, o))
|
if (!creature)
|
||||||
{
|
{
|
||||||
handler.SendSysMessage(CypherStrings.WaypointVpNotcreated, id);
|
handler.SendSysMessage(CypherStrings.WaypointVpNotcreated, id);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
wpCreature.CopyPhaseFrom(chr);
|
creature.CopyPhaseFrom(chr);
|
||||||
wpCreature.SaveToDB(map.GetId(), 1ul << (int)map.GetSpawnMode());
|
creature.SaveToDB(map.GetId(), 1ul << (int)map.GetSpawnMode());
|
||||||
|
|
||||||
// Set "wpguid" column to the visual waypoint
|
ulong dbGuid = creature.GetSpawnId();
|
||||||
stmt = DB.World.GetPreparedStatement(WorldStatements.UPD_WAYPOINT_DATA_WPGUID);
|
|
||||||
stmt.AddValue(0, wpCreature.GetSpawnId());
|
// current "wpCreature" variable is deleted and created fresh new, otherwise old values might trigger asserts or cause undefined behavior
|
||||||
stmt.AddValue(1, pathid);
|
creature.CleanupsBeforeDelete();
|
||||||
stmt.AddValue(2, point);
|
creature.Dispose();
|
||||||
DB.World.Execute(stmt);
|
|
||||||
|
|
||||||
// To call _LoadGoods(); _LoadQuests(); CreateTrainerSpells();
|
// To call _LoadGoods(); _LoadQuests(); CreateTrainerSpells();
|
||||||
if (!wpCreature.LoadCreatureFromDB(wpCreature.GetSpawnId(), map))
|
creature = Creature.CreateCreatureFromDB(dbGuid, map);
|
||||||
|
if (!creature)
|
||||||
{
|
{
|
||||||
handler.SendSysMessage(CypherStrings.WaypointVpNotcreated, id);
|
handler.SendSysMessage(CypherStrings.WaypointVpNotcreated, id);
|
||||||
return false;
|
return false;
|
||||||
@@ -780,10 +791,17 @@ namespace Game.Chat.Commands
|
|||||||
|
|
||||||
if (target)
|
if (target)
|
||||||
{
|
{
|
||||||
wpCreature.SetDisplayId(target.GetDisplayId());
|
creature.SetDisplayId(target.GetDisplayId());
|
||||||
wpCreature.SetObjectScale(0.5f);
|
creature.SetObjectScale(0.5f);
|
||||||
wpCreature.SetLevel(Math.Min(point, SharedConst.StrongMaxLevel));
|
creature.SetLevel(Math.Min(point, SharedConst.StrongMaxLevel));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Set "wpguid" column to the visual waypoint
|
||||||
|
stmt = DB.World.GetPreparedStatement(WorldStatements.UPD_WAYPOINT_DATA_WPGUID);
|
||||||
|
stmt.AddValue(0, creature.GetSpawnId());
|
||||||
|
stmt.AddValue(1, pathid);
|
||||||
|
stmt.AddValue(2, point);
|
||||||
|
DB.World.Execute(stmt);
|
||||||
}
|
}
|
||||||
while (result.NextRow());
|
while (result.NextRow());
|
||||||
|
|
||||||
@@ -808,25 +826,31 @@ namespace Game.Chat.Commands
|
|||||||
float x = result.Read<float>(0);
|
float x = result.Read<float>(0);
|
||||||
float y = result.Read<float>(1);
|
float y = result.Read<float>(1);
|
||||||
float z = result.Read<float>(2);
|
float z = result.Read<float>(2);
|
||||||
uint id = 1;
|
|
||||||
|
|
||||||
Player chr = handler.GetSession().GetPlayer();
|
Player chr = handler.GetSession().GetPlayer();
|
||||||
float o = chr.GetOrientation();
|
|
||||||
Map map = chr.GetMap();
|
Map map = chr.GetMap();
|
||||||
|
Position pos = new Position(x, y, z, chr.GetOrientation());
|
||||||
|
|
||||||
Creature creature = new Creature();
|
Creature creature = Creature.CreateCreature(1, map, pos);
|
||||||
if (!creature.Create(map.GenerateLowGuid(HighGuid.Creature), map, id, x, y, z, o))
|
if (!creature)
|
||||||
{
|
{
|
||||||
handler.SendSysMessage(CypherStrings.WaypointVpNotcreated, id);
|
handler.SendSysMessage(CypherStrings.WaypointVpNotcreated, 1);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
creature.CopyPhaseFrom(chr);
|
creature.CopyPhaseFrom(chr);
|
||||||
creature.SaveToDB(map.GetId(), 1ul << (int)map.GetSpawnMode());
|
creature.SaveToDB(map.GetId(), 1ul << (int)map.GetSpawnMode());
|
||||||
|
|
||||||
if (!creature.LoadCreatureFromDB(creature.GetSpawnId(), map))
|
ulong dbGuid = creature.GetSpawnId();
|
||||||
|
|
||||||
|
// current "creature" variable is deleted and created fresh new, otherwise old values might trigger asserts or cause undefined behavior
|
||||||
|
creature.CleanupsBeforeDelete();
|
||||||
|
creature.Dispose();
|
||||||
|
|
||||||
|
creature = Creature.CreateCreatureFromDB(dbGuid, map);
|
||||||
|
if (!creature)
|
||||||
{
|
{
|
||||||
handler.SendSysMessage(CypherStrings.WaypointVpNotcreated, id);
|
handler.SendSysMessage(CypherStrings.WaypointVpNotcreated, 1);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -857,24 +881,31 @@ namespace Game.Chat.Commands
|
|||||||
float y = result.Read<float>(1);
|
float y = result.Read<float>(1);
|
||||||
float z = result.Read<float>(2);
|
float z = result.Read<float>(2);
|
||||||
float o = result.Read<float>(3);
|
float o = result.Read<float>(3);
|
||||||
uint id = 1;
|
|
||||||
|
|
||||||
Player chr = handler.GetSession().GetPlayer();
|
Player chr = handler.GetSession().GetPlayer();
|
||||||
Map map = chr.GetMap();
|
Map map = chr.GetMap();
|
||||||
|
Position pos = new Position(x, y, z, o);
|
||||||
|
|
||||||
Creature creature = new Creature();
|
Creature creature = Creature.CreateCreature(1, map, pos);
|
||||||
if (!creature.Create(map.GenerateLowGuid(HighGuid.Creature), map, id, x, y, z, o))
|
if (!creature)
|
||||||
{
|
{
|
||||||
handler.SendSysMessage(CypherStrings.WaypointNotcreated, id);
|
handler.SendSysMessage(CypherStrings.WaypointNotcreated, 1);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
creature.CopyPhaseFrom(chr);
|
creature.CopyPhaseFrom(chr);
|
||||||
creature.SaveToDB(map.GetId(), 1ul << (int)map.GetSpawnMode());
|
creature.SaveToDB(map.GetId(), 1ul << (int)map.GetSpawnMode());
|
||||||
|
|
||||||
if (!creature.LoadCreatureFromDB(creature.GetSpawnId(), map))
|
ulong dbGuid = creature.GetSpawnId();
|
||||||
|
|
||||||
|
// current "creature" variable is deleted and created fresh new, otherwise old values might trigger asserts or cause undefined behavior
|
||||||
|
creature.CleanupsBeforeDelete();
|
||||||
|
creature.Dispose();
|
||||||
|
|
||||||
|
creature = Creature.CreateCreatureFromDB(dbGuid, map);
|
||||||
|
if (!creature)
|
||||||
{
|
{
|
||||||
handler.SendSysMessage(CypherStrings.WaypointNotcreated, id);
|
handler.SendSysMessage(CypherStrings.WaypointNotcreated, 1);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -283,8 +283,6 @@ namespace Game.DataStorage
|
|||||||
foreach (var entry in TaxiPathNodeStorage.Values)
|
foreach (var entry in TaxiPathNodeStorage.Values)
|
||||||
TaxiPathNodesByPath[entry.PathID][entry.NodeIndex] = entry;
|
TaxiPathNodesByPath[entry.PathID][entry.NodeIndex] = entry;
|
||||||
|
|
||||||
TaxiPathNodeStorage = null;
|
|
||||||
|
|
||||||
foreach (var node in TaxiNodesStorage.Values)
|
foreach (var node in TaxiNodesStorage.Values)
|
||||||
{
|
{
|
||||||
if (!node.Flags.HasAnyFlag(TaxiNodeFlags.Alliance | TaxiNodeFlags.Horde))
|
if (!node.Flags.HasAnyFlag(TaxiNodeFlags.Alliance | TaxiNodeFlags.Horde))
|
||||||
|
|||||||
@@ -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;
|
_targetGuid = target ? target.GetGUID() : ObjectGuid.Empty;
|
||||||
_aurEff = aurEff;
|
_aurEff = aurEff;
|
||||||
|
|||||||
@@ -720,7 +720,35 @@ namespace Game.Entities
|
|||||||
GetMotionMaster().Initialize();
|
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);
|
SetMap(map);
|
||||||
|
|
||||||
@@ -1281,83 +1309,6 @@ namespace Game.Entities
|
|||||||
return true;
|
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)
|
public override void SetCanDualWield(bool value)
|
||||||
{
|
{
|
||||||
base.SetCanDualWield(value);
|
base.SetCanDualWield(value);
|
||||||
@@ -2914,7 +2865,84 @@ namespace Game.Entities
|
|||||||
|
|
||||||
public override bool LoadFromDB(ulong spawnId, Map map)
|
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(); }
|
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);
|
Contract.Assert(map);
|
||||||
SetMap(map);
|
SetMap(map);
|
||||||
@@ -167,34 +189,34 @@ namespace Game.Entities
|
|||||||
m_stationaryPosition.Relocate(pos);
|
m_stationaryPosition.Relocate(pos);
|
||||||
if (!IsPositionValid())
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
SetZoneScript();
|
SetZoneScript();
|
||||||
if (m_zoneScript != null)
|
if (m_zoneScript != null)
|
||||||
{
|
{
|
||||||
name_id = m_zoneScript.GetGameObjectEntry(m_spawnId, name_id);
|
entry = m_zoneScript.GetGameObjectEntry(m_spawnId, entry);
|
||||||
if (name_id == 0)
|
if (entry == 0)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
GameObjectTemplate goinfo = Global.ObjectMgr.GetGameObjectTemplate(name_id);
|
GameObjectTemplate goInfo = Global.ObjectMgr.GetGameObjectTemplate(entry);
|
||||||
if (goinfo == null)
|
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;
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
ObjectGuid guid;
|
ObjectGuid guid;
|
||||||
if (goinfo.type != GameObjectTypes.Transport)
|
if (goInfo.type != GameObjectTypes.Transport)
|
||||||
guid = ObjectGuid.Create(HighGuid.GameObject, map.GetId(), goinfo.entry, map.GenerateLowGuid(HighGuid.GameObject));
|
guid = ObjectGuid.Create(HighGuid.GameObject, map.GetId(), goInfo.entry, map.GenerateLowGuid(HighGuid.GameObject));
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
guid = ObjectGuid.Create(HighGuid.Transport, map.GenerateLowGuid(HighGuid.Transport));
|
guid = ObjectGuid.Create(HighGuid.Transport, map.GenerateLowGuid(HighGuid.Transport));
|
||||||
@@ -203,12 +225,12 @@ namespace Game.Entities
|
|||||||
|
|
||||||
_Create(guid);
|
_Create(guid);
|
||||||
|
|
||||||
m_goInfo = goinfo;
|
m_goInfo = goInfo;
|
||||||
m_goTemplateAddon = Global.ObjectMgr.GetGameObjectTemplateAddon(name_id);
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -222,7 +244,7 @@ namespace Game.Entities
|
|||||||
|
|
||||||
SetParentRotation(parentRotation);
|
SetParentRotation(parentRotation);
|
||||||
|
|
||||||
SetObjectScale(goinfo.size);
|
SetObjectScale(goInfo.size);
|
||||||
|
|
||||||
if (m_goTemplateAddon != null)
|
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
|
// 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();
|
m_model = CreateModel();
|
||||||
// GAMEOBJECT_BYTES_1, index at 0, 1, 2 and 3
|
// GAMEOBJECT_BYTES_1, index at 0, 1, 2 and 3
|
||||||
SetGoType(goinfo.type);
|
SetGoType(goInfo.type);
|
||||||
m_prevGoState = go_state;
|
m_prevGoState = goState;
|
||||||
SetGoState(go_state);
|
SetGoState(goState);
|
||||||
SetGoArtKit((byte)artKit);
|
SetGoArtKit((byte)artKit);
|
||||||
|
|
||||||
switch (goinfo.type)
|
switch (goInfo.type)
|
||||||
{
|
{
|
||||||
case GameObjectTypes.FishingHole:
|
case GameObjectTypes.FishingHole:
|
||||||
SetGoAnimProgress(animprogress);
|
SetGoAnimProgress(animProgress);
|
||||||
m_goValue.FishingHole.MaxOpens = RandomHelper.URand(GetGoInfo().FishingHole.minRestock, GetGoInfo().FishingHole.maxRestock);
|
m_goValue.FishingHole.MaxOpens = RandomHelper.URand(GetGoInfo().FishingHole.minRestock, GetGoInfo().FishingHole.maxRestock);
|
||||||
break;
|
break;
|
||||||
case GameObjectTypes.DestructibleBuilding:
|
case GameObjectTypes.DestructibleBuilding:
|
||||||
m_goValue.Building.Health = 20000;//goinfo.DestructibleBuilding.intactNumHits + goinfo.DestructibleBuilding.damagedNumHits;
|
m_goValue.Building.Health = 20000;//goinfo.DestructibleBuilding.intactNumHits + goinfo.DestructibleBuilding.damagedNumHits;
|
||||||
m_goValue.Building.MaxHealth = m_goValue.Building.Health;
|
m_goValue.Building.MaxHealth = m_goValue.Building.Health;
|
||||||
SetGoAnimProgress(255);
|
SetGoAnimProgress(255);
|
||||||
SetUInt32Value(GameObjectFields.ParentRotation, goinfo.DestructibleBuilding.DestructibleModelRec);
|
SetUInt32Value(GameObjectFields.ParentRotation, goInfo.DestructibleBuilding.DestructibleModelRec);
|
||||||
break;
|
break;
|
||||||
case GameObjectTypes.Transport:
|
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();
|
m_goValue.Transport.PathProgress = Time.GetMSTime();
|
||||||
if (m_goValue.Transport.AnimationInfo.Path != null)
|
if (m_goValue.Transport.AnimationInfo.Path != null)
|
||||||
m_goValue.Transport.PathProgress -= m_goValue.Transport.PathProgress % GetTransportPeriod(); // align to period
|
m_goValue.Transport.PathProgress -= m_goValue.Transport.PathProgress % GetTransportPeriod(); // align to period
|
||||||
m_goValue.Transport.CurrentSeg = 0;
|
m_goValue.Transport.CurrentSeg = 0;
|
||||||
m_goValue.Transport.StateUpdateTimer = 0;
|
m_goValue.Transport.StateUpdateTimer = 0;
|
||||||
m_goValue.Transport.StopFrames = new List<uint>();
|
m_goValue.Transport.StopFrames = new List<uint>();
|
||||||
if (goinfo.Transport.Timeto2ndfloor > 0)
|
if (goInfo.Transport.Timeto2ndfloor > 0)
|
||||||
m_goValue.Transport.StopFrames.Add(goinfo.Transport.Timeto2ndfloor);
|
m_goValue.Transport.StopFrames.Add(goInfo.Transport.Timeto2ndfloor);
|
||||||
if (goinfo.Transport.Timeto3rdfloor > 0)
|
if (goInfo.Transport.Timeto3rdfloor > 0)
|
||||||
m_goValue.Transport.StopFrames.Add(goinfo.Transport.Timeto3rdfloor);
|
m_goValue.Transport.StopFrames.Add(goInfo.Transport.Timeto3rdfloor);
|
||||||
if (goinfo.Transport.Timeto4thfloor > 0)
|
if (goInfo.Transport.Timeto4thfloor > 0)
|
||||||
m_goValue.Transport.StopFrames.Add(goinfo.Transport.Timeto4thfloor);
|
m_goValue.Transport.StopFrames.Add(goInfo.Transport.Timeto4thfloor);
|
||||||
if (goinfo.Transport.Timeto5thfloor > 0)
|
if (goInfo.Transport.Timeto5thfloor > 0)
|
||||||
m_goValue.Transport.StopFrames.Add(goinfo.Transport.Timeto5thfloor);
|
m_goValue.Transport.StopFrames.Add(goInfo.Transport.Timeto5thfloor);
|
||||||
if (goinfo.Transport.Timeto6thfloor > 0)
|
if (goInfo.Transport.Timeto6thfloor > 0)
|
||||||
m_goValue.Transport.StopFrames.Add(goinfo.Transport.Timeto6thfloor);
|
m_goValue.Transport.StopFrames.Add(goInfo.Transport.Timeto6thfloor);
|
||||||
if (goinfo.Transport.Timeto7thfloor > 0)
|
if (goInfo.Transport.Timeto7thfloor > 0)
|
||||||
m_goValue.Transport.StopFrames.Add(goinfo.Transport.Timeto7thfloor);
|
m_goValue.Transport.StopFrames.Add(goInfo.Transport.Timeto7thfloor);
|
||||||
if (goinfo.Transport.Timeto8thfloor > 0)
|
if (goInfo.Transport.Timeto8thfloor > 0)
|
||||||
m_goValue.Transport.StopFrames.Add(goinfo.Transport.Timeto8thfloor);
|
m_goValue.Transport.StopFrames.Add(goInfo.Transport.Timeto8thfloor);
|
||||||
if (goinfo.Transport.Timeto9thfloor > 0)
|
if (goInfo.Transport.Timeto9thfloor > 0)
|
||||||
m_goValue.Transport.StopFrames.Add(goinfo.Transport.Timeto9thfloor);
|
m_goValue.Transport.StopFrames.Add(goInfo.Transport.Timeto9thfloor);
|
||||||
if (goinfo.Transport.Timeto10thfloor > 0)
|
if (goInfo.Transport.Timeto10thfloor > 0)
|
||||||
m_goValue.Transport.StopFrames.Add(goinfo.Transport.Timeto10thfloor);
|
m_goValue.Transport.StopFrames.Add(goInfo.Transport.Timeto10thfloor);
|
||||||
|
|
||||||
if (goinfo.Transport.startOpen != 0)
|
if (goInfo.Transport.startOpen != 0)
|
||||||
SetTransportState(GameObjectState.TransportStopped, goinfo.Transport.startOpen - 1);
|
SetTransportState(GameObjectState.TransportStopped, goInfo.Transport.startOpen - 1);
|
||||||
else
|
else
|
||||||
SetTransportState(GameObjectState.TransportActive);
|
SetTransportState(GameObjectState.TransportActive);
|
||||||
|
|
||||||
SetGoAnimProgress(animprogress);
|
SetGoAnimProgress(animProgress);
|
||||||
break;
|
break;
|
||||||
case GameObjectTypes.FishingNode:
|
case GameObjectTypes.FishingNode:
|
||||||
SetUInt32Value(GameObjectFields.Level, 1);
|
SetUInt32Value(GameObjectFields.Level, 1);
|
||||||
SetGoAnimProgress(255);
|
SetGoAnimProgress(255);
|
||||||
break;
|
break;
|
||||||
case GameObjectTypes.Trap:
|
case GameObjectTypes.Trap:
|
||||||
if (goinfo.Trap.stealthed != 0)
|
if (goInfo.Trap.stealthed != 0)
|
||||||
{
|
{
|
||||||
m_stealth.AddFlag(StealthType.Trap);
|
m_stealth.AddFlag(StealthType.Trap);
|
||||||
m_stealth.AddValue(StealthType.Trap, 70);
|
m_stealth.AddValue(StealthType.Trap, 70);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (goinfo.Trap.stealthAffected != 0)
|
if (goInfo.Trap.stealthAffected != 0)
|
||||||
{
|
{
|
||||||
m_invisibility.AddFlag(InvisibilityType.Trap);
|
m_invisibility.AddFlag(InvisibilityType.Trap);
|
||||||
m_invisibility.AddValue(InvisibilityType.Trap, 300);
|
m_invisibility.AddValue(InvisibilityType.Trap, 300);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
SetGoAnimProgress(animprogress);
|
SetGoAnimProgress(animProgress);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -340,14 +362,14 @@ namespace Game.Entities
|
|||||||
uint linkedEntry = GetGoInfo().GetLinkedGameObjectEntry();
|
uint linkedEntry = GetGoInfo().GetLinkedGameObjectEntry();
|
||||||
if (linkedEntry != 0)
|
if (linkedEntry != 0)
|
||||||
{
|
{
|
||||||
GameObject linkedGO = new GameObject();
|
GameObject linkedGo = CreateGameObject(linkedEntry, map, pos, rotation, 255, GameObjectState.Ready);
|
||||||
if (linkedGO.Create(linkedEntry, map, pos, rotation, 255, GameObjectState.Ready))
|
if (linkedGo != null)
|
||||||
{
|
{
|
||||||
SetLinkedTrap(linkedGO);
|
SetLinkedTrap(linkedGo);
|
||||||
map.AddToMap(linkedGO);
|
map.AddToMap(linkedGo);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
linkedGO.Dispose();
|
linkedGo.Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -907,10 +929,9 @@ namespace Game.Entities
|
|||||||
DB.World.Execute(stmt);
|
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);
|
GameObjectData data = Global.ObjectMgr.GetGOData(spawnId);
|
||||||
|
|
||||||
if (data == null)
|
if (data == null)
|
||||||
{
|
{
|
||||||
Log.outError(LogFilter.Maps, "Gameobject (SpawnId: {0}) not found in table `gameobject`, can't load. ", spawnId);
|
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();
|
Map map = GetMap();
|
||||||
GameObject go = new GameObject();
|
GameObject go = GameObject.CreateGameObject(entry, map, pos, rotation, 255, GameObjectState.Ready);
|
||||||
if (!go.Create(entry, map, pos, rotation, 255, GameObjectState.Ready))
|
if (!go)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
go.CopyPhaseFrom(this);
|
go.CopyPhaseFrom(this);
|
||||||
|
|||||||
@@ -309,9 +309,9 @@ namespace Game.Entities
|
|||||||
public Creature CreateNPCPassenger(ulong guid, CreatureData data)
|
public Creature CreateNPCPassenger(ulong guid, CreatureData data)
|
||||||
{
|
{
|
||||||
Map map = GetMap();
|
Map map = GetMap();
|
||||||
Creature creature = new Creature();
|
|
||||||
|
|
||||||
if (!creature.LoadCreatureFromDB(guid, map, false))
|
Creature creature = Creature.CreateCreatureFromDB(guid, map, false);
|
||||||
|
if (!creature)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
float x = data.posX;
|
float x = data.posX;
|
||||||
@@ -359,9 +359,9 @@ namespace Game.Entities
|
|||||||
GameObject CreateGOPassenger(ulong guid, GameObjectData data)
|
GameObject CreateGOPassenger(ulong guid, GameObjectData data)
|
||||||
{
|
{
|
||||||
Map map = GetMap();
|
Map map = GetMap();
|
||||||
GameObject go = new GameObject();
|
|
||||||
|
|
||||||
if (!go.LoadGameObjectFromDB(guid, map, false))
|
GameObject go = CreateGameObjectFromDB(guid, map, false);
|
||||||
|
if (!go)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
float x = data.posX;
|
float x = data.posX;
|
||||||
|
|||||||
@@ -1189,11 +1189,7 @@ namespace Game
|
|||||||
Map map = Global.MapMgr.CreateBaseMap(data.mapid);
|
Map map = Global.MapMgr.CreateBaseMap(data.mapid);
|
||||||
// We use spawn coords to spawn
|
// We use spawn coords to spawn
|
||||||
if (!map.Instanceable() && map.IsGridLoaded(data.posX, data.posY))
|
if (!map.Instanceable() && map.IsGridLoaded(data.posX, data.posY))
|
||||||
{
|
Creature.CreateCreatureFromDB(guid, map);
|
||||||
Creature creature = new Creature();
|
|
||||||
Log.outDebug(LogFilter.Misc, "Spawning creature {0}", guid.ToString());
|
|
||||||
creature.LoadCreatureFromDB(guid, map);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1217,11 +1213,11 @@ namespace Game
|
|||||||
// We use current coords to unspawn, not spawn coords since creature can have changed grid
|
// We use current coords to unspawn, not spawn coords since creature can have changed grid
|
||||||
if (!map.Instanceable() && map.IsGridLoaded(data.posX, data.posY))
|
if (!map.Instanceable() && map.IsGridLoaded(data.posX, data.posY))
|
||||||
{
|
{
|
||||||
GameObject pGameobject = new GameObject();
|
GameObject pGameobject = GameObject.CreateGameObjectFromDB(guid, map, false);
|
||||||
Log.outDebug(LogFilter.Misc, "Spawning gameobject {0}", guid.ToString());
|
|
||||||
/// @todo find out when it is add to map
|
/// @todo find out when it is add to map
|
||||||
if (pGameobject.LoadGameObjectFromDB(guid, map, false))
|
if (pGameobject)
|
||||||
{
|
{
|
||||||
|
/// @todo find out when it is add to map
|
||||||
if (pGameobject.isSpawnedByDefault())
|
if (pGameobject.isSpawnedByDefault())
|
||||||
map.AddToMap(pGameobject);
|
map.AddToMap(pGameobject);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -707,9 +707,8 @@ namespace Game.Garrisons
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
Position pos = PacketInfo.PlotPos;
|
GameObject go = GameObject.CreateGameObject(entry, map, PacketInfo.PlotPos, Quaternion.WAxis, 255, GameObjectState.Ready);
|
||||||
GameObject go = new GameObject();
|
if (!go)
|
||||||
if (!go.Create(entry, map, pos, Quaternion.WAxis, 255, GameObjectState.Active))
|
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
if (BuildingInfo.CanActivate() && BuildingInfo.PacketInfo.HasValue && !BuildingInfo.PacketInfo.Value.Active)
|
if (BuildingInfo.CanActivate() && BuildingInfo.PacketInfo.HasValue && !BuildingInfo.PacketInfo.Value.Active)
|
||||||
@@ -718,8 +717,8 @@ namespace Game.Garrisons
|
|||||||
if (finalizeInfo != null)
|
if (finalizeInfo != null)
|
||||||
{
|
{
|
||||||
Position pos2 = finalizeInfo.factionInfo[faction].Pos;
|
Position pos2 = finalizeInfo.factionInfo[faction].Pos;
|
||||||
GameObject finalizer = new GameObject();
|
GameObject finalizer = GameObject.CreateGameObject(finalizeInfo.factionInfo[faction].GameObjectId, map, pos2, Quaternion.WAxis, 255, GameObjectState.Ready);
|
||||||
if (finalizer.Create(finalizeInfo.factionInfo[faction].GameObjectId, map, pos2, Quaternion.WAxis, 255, GameObjectState.Ready))
|
if (finalizer)
|
||||||
{
|
{
|
||||||
// set some spell id to make the object delete itself after use
|
// set some spell id to make the object delete itself after use
|
||||||
finalizer.SetSpellId(finalizer.GetGoInfo().Goober.spell);
|
finalizer.SetSpellId(finalizer.GetGoInfo().Goober.spell);
|
||||||
|
|||||||
@@ -3451,8 +3451,8 @@ namespace Game
|
|||||||
// We use spawn coords to spawn
|
// We use spawn coords to spawn
|
||||||
if (!map.Instanceable() && !map.IsRemovalGrid(x, y))
|
if (!map.Instanceable() && !map.IsRemovalGrid(x, y))
|
||||||
{
|
{
|
||||||
Creature creature = new Creature();
|
Creature creature = Creature.CreateCreatureFromDB(guid, map);
|
||||||
if (!creature.LoadCreatureFromDB(guid, map))
|
if (!creature)
|
||||||
{
|
{
|
||||||
Log.outError(LogFilter.Server, "AddCreature: Cannot add creature entry {0} to map", entry);
|
Log.outError(LogFilter.Server, "AddCreature: Cannot add creature entry {0} to map", entry);
|
||||||
return 0;
|
return 0;
|
||||||
@@ -4290,8 +4290,8 @@ namespace Game
|
|||||||
// We use spawn coords to spawn
|
// We use spawn coords to spawn
|
||||||
if (!map.Instanceable() && map.IsGridLoaded(x, y))
|
if (!map.Instanceable() && map.IsGridLoaded(x, y))
|
||||||
{
|
{
|
||||||
GameObject go = new GameObject();
|
GameObject go = GameObject.CreateGameObjectFromDB(guid, map);
|
||||||
if (!go.LoadGameObjectFromDB(guid, map))
|
if (!go)
|
||||||
{
|
{
|
||||||
Log.outError(LogFilter.Server, "AddGOData: cannot add gameobject entry {0} to map", entry);
|
Log.outError(LogFilter.Server, "AddGOData: cannot add gameobject entry {0} to map", entry);
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@@ -869,12 +869,7 @@ namespace Game
|
|||||||
Map map = Global.MapMgr.CreateBaseMap(data.mapid);
|
Map map = Global.MapMgr.CreateBaseMap(data.mapid);
|
||||||
// We use spawn coords to spawn
|
// We use spawn coords to spawn
|
||||||
if (!map.Instanceable() && map.IsGridLoaded(data.posX, data.posY))
|
if (!map.Instanceable() && map.IsGridLoaded(data.posX, data.posY))
|
||||||
{
|
Creature.CreateCreatureFromDB(obj.guid, map);
|
||||||
Creature creature = new Creature();
|
|
||||||
if (!creature.LoadCreatureFromDB(obj.guid, map))
|
|
||||||
return;
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "GameObject":
|
case "GameObject":
|
||||||
@@ -888,13 +883,11 @@ namespace Game
|
|||||||
// We use current coords to unspawn, not spawn coords since creature can have changed grid
|
// We use current coords to unspawn, not spawn coords since creature can have changed grid
|
||||||
if (!map.Instanceable() && map.IsGridLoaded(data_.posX, data_.posY))
|
if (!map.Instanceable() && map.IsGridLoaded(data_.posX, data_.posY))
|
||||||
{
|
{
|
||||||
GameObject pGameobject = new GameObject();
|
GameObject go = GameObject.CreateGameObjectFromDB(obj.guid, map, false);
|
||||||
if (!pGameobject.LoadGameObjectFromDB(obj.guid, map, false))
|
if (go)
|
||||||
return;
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
if (pGameobject.isSpawnedByDefault())
|
if (go.isSpawnedByDefault())
|
||||||
map.AddToMap(pGameobject);
|
map.AddToMap(go);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5944,9 +5944,7 @@ namespace Game.Spells
|
|||||||
|
|
||||||
if (apply)
|
if (apply)
|
||||||
{
|
{
|
||||||
AreaTrigger areaTrigger = new AreaTrigger();
|
AreaTrigger areaTrigger = AreaTrigger.CreateAreaTrigger((uint)GetMiscValue(), GetCaster(), target, GetSpellInfo(), target, GetBase().GetDuration(), GetBase().GetSpellXSpellVisualId(), ObjectGuid.Empty, this);
|
||||||
if (!areaTrigger.CreateAreaTrigger((uint)GetMiscValue(), GetCaster(), target, GetSpellInfo(), target, GetBase().GetDuration(), GetBase().GetSpellXSpellVisualId(), ObjectGuid.Empty, this))
|
|
||||||
areaTrigger.Dispose();
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -2840,10 +2840,6 @@ namespace Game.Spells
|
|||||||
if (effectHandleMode != SpellEffectHandleMode.Hit)
|
if (effectHandleMode != SpellEffectHandleMode.Hit)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
uint gameobject_id = (uint)effectInfo.MiscValue;
|
|
||||||
|
|
||||||
GameObject pGameObj = new GameObject();
|
|
||||||
|
|
||||||
WorldObject target = focusObject;
|
WorldObject target = focusObject;
|
||||||
if (target == null)
|
if (target == null)
|
||||||
target = m_caster;
|
target = m_caster;
|
||||||
@@ -2855,34 +2851,37 @@ namespace Game.Spells
|
|||||||
m_caster.GetClosePoint(out x, out y, out z, SharedConst.DefaultWorldObjectSize);
|
m_caster.GetClosePoint(out x, out y, out z, SharedConst.DefaultWorldObjectSize);
|
||||||
|
|
||||||
Map map = target.GetMap();
|
Map map = target.GetMap();
|
||||||
|
|
||||||
|
Position pos = new Position(x, y, z, target.GetOrientation());
|
||||||
Quaternion rotation = new Quaternion(Matrix3.fromEulerAnglesZYX(target.GetOrientation(), 0.0f, 0.0f));
|
Quaternion rotation = new Quaternion(Matrix3.fromEulerAnglesZYX(target.GetOrientation(), 0.0f, 0.0f));
|
||||||
if (!pGameObj.Create(gameobject_id, map, new Position(x, y, z, target.GetOrientation()), rotation, 255, GameObjectState.Ready))
|
GameObject go = GameObject.CreateGameObject((uint)effectInfo.MiscValue, map, pos, rotation, 255, GameObjectState.Ready);
|
||||||
|
if (!go)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
pGameObj.CopyPhaseFrom(m_caster);
|
go.CopyPhaseFrom(m_caster);
|
||||||
|
|
||||||
int duration = m_spellInfo.CalcDuration(m_caster);
|
int duration = m_spellInfo.CalcDuration(m_caster);
|
||||||
|
|
||||||
pGameObj.SetRespawnTime(duration > 0 ? duration / Time.InMilliseconds : 0);
|
go.SetRespawnTime(duration > 0 ? duration / Time.InMilliseconds : 0);
|
||||||
pGameObj.SetSpellId(m_spellInfo.Id);
|
go.SetSpellId(m_spellInfo.Id);
|
||||||
|
|
||||||
ExecuteLogEffectSummonObject(effIndex, pGameObj);
|
ExecuteLogEffectSummonObject(effIndex, go);
|
||||||
|
|
||||||
// Wild object not have owner and check clickable by players
|
// Wild object not have owner and check clickable by players
|
||||||
map.AddToMap(pGameObj);
|
map.AddToMap(go);
|
||||||
|
|
||||||
if (pGameObj.GetGoType() == GameObjectTypes.FlagDrop)
|
if (go.GetGoType() == GameObjectTypes.FlagDrop)
|
||||||
{
|
{
|
||||||
Player player = m_caster.ToPlayer();
|
Player player = m_caster.ToPlayer();
|
||||||
if (player != null)
|
if (player != null)
|
||||||
{
|
{
|
||||||
Battleground bg = player.GetBattleground();
|
Battleground bg = player.GetBattleground();
|
||||||
if (bg)
|
if (bg)
|
||||||
bg.SetDroppedFlagGUID(pGameObj.GetGUID(), (player.GetTeam() == Team.Alliance ? TeamId.Horde : TeamId.Alliance));
|
bg.SetDroppedFlagGUID(go.GetGUID(), (player.GetTeam() == Team.Alliance ? TeamId.Horde : TeamId.Alliance));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GameObject linkedTrap = pGameObj.GetLinkedTrap();
|
GameObject linkedTrap = go.GetLinkedTrap();
|
||||||
if (linkedTrap)
|
if (linkedTrap)
|
||||||
{
|
{
|
||||||
linkedTrap.CopyPhaseFrom(m_caster);
|
linkedTrap.CopyPhaseFrom(m_caster);
|
||||||
@@ -3506,10 +3505,7 @@ namespace Game.Spells
|
|||||||
}
|
}
|
||||||
|
|
||||||
//CREATE DUEL FLAG OBJECT
|
//CREATE DUEL FLAG OBJECT
|
||||||
GameObject pGameObj = new GameObject();
|
Map map = m_caster.GetMap();
|
||||||
|
|
||||||
int gameobject_id = effectInfo.MiscValue;
|
|
||||||
|
|
||||||
Position pos = new Position()
|
Position pos = new Position()
|
||||||
{
|
{
|
||||||
posX = m_caster.GetPositionX() + (unitTarget.GetPositionX() - m_caster.GetPositionX()) / 2,
|
posX = m_caster.GetPositionX() + (unitTarget.GetPositionX() - m_caster.GetPositionX()) / 2,
|
||||||
@@ -3517,29 +3513,29 @@ namespace Game.Spells
|
|||||||
posZ = m_caster.GetPositionZ(),
|
posZ = m_caster.GetPositionZ(),
|
||||||
Orientation = m_caster.GetOrientation()
|
Orientation = m_caster.GetOrientation()
|
||||||
};
|
};
|
||||||
|
|
||||||
Map map = m_caster.GetMap();
|
|
||||||
Quaternion rotation = new Quaternion(Matrix3.fromEulerAnglesZYX(pos.GetOrientation(), 0.0f, 0.0f));
|
Quaternion rotation = new Quaternion(Matrix3.fromEulerAnglesZYX(pos.GetOrientation(), 0.0f, 0.0f));
|
||||||
if (!pGameObj.Create((uint)gameobject_id, map, pos, rotation, 0, GameObjectState.Ready))
|
|
||||||
|
GameObject go = GameObject.CreateGameObject((uint)effectInfo.MiscValue, map, pos, rotation, 0, GameObjectState.Ready);
|
||||||
|
if (!go)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
pGameObj.CopyPhaseFrom(m_caster);
|
go.CopyPhaseFrom(m_caster);
|
||||||
|
|
||||||
pGameObj.SetUInt32Value(GameObjectFields.Faction, m_caster.getFaction());
|
go.SetUInt32Value(GameObjectFields.Faction, m_caster.getFaction());
|
||||||
pGameObj.SetUInt32Value(GameObjectFields.Level, m_caster.getLevel() + 1);
|
go.SetUInt32Value(GameObjectFields.Level, m_caster.getLevel() + 1);
|
||||||
int duration = m_spellInfo.CalcDuration(m_caster);
|
int duration = m_spellInfo.CalcDuration(m_caster);
|
||||||
pGameObj.SetRespawnTime(duration > 0 ? duration / Time.InMilliseconds : 0);
|
go.SetRespawnTime(duration > 0 ? duration / Time.InMilliseconds : 0);
|
||||||
pGameObj.SetSpellId(m_spellInfo.Id);
|
go.SetSpellId(m_spellInfo.Id);
|
||||||
|
|
||||||
ExecuteLogEffectSummonObject(effIndex, pGameObj);
|
ExecuteLogEffectSummonObject(effIndex, go);
|
||||||
|
|
||||||
m_caster.AddGameObject(pGameObj);
|
m_caster.AddGameObject(go);
|
||||||
map.AddToMap(pGameObj);
|
map.AddToMap(go);
|
||||||
//END
|
//END
|
||||||
|
|
||||||
// Send request
|
// Send request
|
||||||
DuelRequested packet = new DuelRequested();
|
DuelRequested packet = new DuelRequested();
|
||||||
packet.ArbiterGUID = pGameObj.GetGUID();
|
packet.ArbiterGUID = go.GetGUID();
|
||||||
packet.RequestedByGUID = caster.GetGUID();
|
packet.RequestedByGUID = caster.GetGUID();
|
||||||
packet.RequestedByWowAccount = caster.GetSession().GetAccountGUID();
|
packet.RequestedByWowAccount = caster.GetSession().GetAccountGUID();
|
||||||
|
|
||||||
@@ -3563,8 +3559,8 @@ namespace Game.Spells
|
|||||||
duel2.isMounted = (GetSpellInfo().Id == 62875); // Mounted Duel
|
duel2.isMounted = (GetSpellInfo().Id == 62875); // Mounted Duel
|
||||||
target.duel = duel2;
|
target.duel = duel2;
|
||||||
|
|
||||||
caster.SetGuidValue(PlayerFields.DuelArbiter, pGameObj.GetGUID());
|
caster.SetGuidValue(PlayerFields.DuelArbiter, go.GetGUID());
|
||||||
target.SetGuidValue(PlayerFields.DuelArbiter, pGameObj.GetGUID());
|
target.SetGuidValue(PlayerFields.DuelArbiter, go.GetGUID());
|
||||||
|
|
||||||
Global.ScriptMgr.OnPlayerDuelRequest(target, caster);
|
Global.ScriptMgr.OnPlayerDuelRequest(target, caster);
|
||||||
}
|
}
|
||||||
@@ -3836,7 +3832,6 @@ namespace Game.Spells
|
|||||||
if (effectHandleMode != SpellEffectHandleMode.Hit)
|
if (effectHandleMode != SpellEffectHandleMode.Hit)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
uint go_id = (uint)effectInfo.MiscValue;
|
|
||||||
byte slot = (byte)(effectInfo.Effect - SpellEffectName.SummonObjectSlot1);
|
byte slot = (byte)(effectInfo.Effect - SpellEffectName.SummonObjectSlot1);
|
||||||
ObjectGuid guid = m_caster.m_ObjectSlot[slot];
|
ObjectGuid guid = m_caster.m_ObjectSlot[slot];
|
||||||
if (!guid.IsEmpty())
|
if (!guid.IsEmpty())
|
||||||
@@ -3852,8 +3847,6 @@ namespace Game.Spells
|
|||||||
m_caster.m_ObjectSlot[slot].Clear();
|
m_caster.m_ObjectSlot[slot].Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
GameObject go = new GameObject();
|
|
||||||
|
|
||||||
float x, y, z;
|
float x, y, z;
|
||||||
// If dest location if present
|
// If dest location if present
|
||||||
if (m_targets.HasDst())
|
if (m_targets.HasDst())
|
||||||
@@ -3863,8 +3856,10 @@ namespace Game.Spells
|
|||||||
m_caster.GetClosePoint(out x, out y, out z, SharedConst.DefaultWorldObjectSize);
|
m_caster.GetClosePoint(out x, out y, out z, SharedConst.DefaultWorldObjectSize);
|
||||||
|
|
||||||
Map map = m_caster.GetMap();
|
Map map = m_caster.GetMap();
|
||||||
|
Position pos = new Position(x, y, z, m_caster.GetOrientation());
|
||||||
Quaternion rotation = new Quaternion(Matrix3.fromEulerAnglesZYX(m_caster.GetOrientation(), 0.0f, 0.0f));
|
Quaternion rotation = new Quaternion(Matrix3.fromEulerAnglesZYX(m_caster.GetOrientation(), 0.0f, 0.0f));
|
||||||
if (!go.Create(go_id, map, new Position(x, y, z, m_caster.GetOrientation()), rotation, 255, GameObjectState.Ready))
|
GameObject go = GameObject.CreateGameObject((uint)effectInfo.MiscValue, map, pos, rotation, 255, GameObjectState.Ready);
|
||||||
|
if (!go)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
go.CopyPhaseFrom(m_caster);
|
go.CopyPhaseFrom(m_caster);
|
||||||
@@ -4548,14 +4543,13 @@ namespace Game.Spells
|
|||||||
if (goinfo.type == GameObjectTypes.Ritual)
|
if (goinfo.type == GameObjectTypes.Ritual)
|
||||||
m_caster.GetPosition(out fx, out fy, out fz);
|
m_caster.GetPosition(out fx, out fy, out fz);
|
||||||
|
|
||||||
GameObject pGameObj = new GameObject();
|
|
||||||
|
|
||||||
Position pos = new Position(fx, fy, fz, m_caster.GetOrientation());
|
Position pos = new Position(fx, fy, fz, m_caster.GetOrientation());
|
||||||
Quaternion rotation = new Quaternion(Matrix3.fromEulerAnglesZYX(m_caster.GetOrientation(), 0.0f, 0.0f));
|
Quaternion rotation = new Quaternion(Matrix3.fromEulerAnglesZYX(m_caster.GetOrientation(), 0.0f, 0.0f));
|
||||||
if (!pGameObj.Create(name_id, cMap, pos, rotation, 255, GameObjectState.Ready))
|
GameObject go = GameObject.CreateGameObject(name_id, cMap, pos, rotation, 255, GameObjectState.Ready);
|
||||||
|
if (!go)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
pGameObj.CopyPhaseFrom(m_caster);
|
go.CopyPhaseFrom(m_caster);
|
||||||
|
|
||||||
int duration = m_spellInfo.CalcDuration(m_caster);
|
int duration = m_spellInfo.CalcDuration(m_caster);
|
||||||
|
|
||||||
@@ -4563,11 +4557,11 @@ namespace Game.Spells
|
|||||||
{
|
{
|
||||||
case GameObjectTypes.FishingNode:
|
case GameObjectTypes.FishingNode:
|
||||||
{
|
{
|
||||||
pGameObj.SetFaction(m_caster.getFaction());
|
go.SetFaction(m_caster.getFaction());
|
||||||
ObjectGuid bobberGuid = pGameObj.GetGUID();
|
ObjectGuid bobberGuid = go.GetGUID();
|
||||||
// client requires fishing bobber guid in channel object slot 0 to be usable
|
// client requires fishing bobber guid in channel object slot 0 to be usable
|
||||||
m_caster.SetDynamicStructuredValue(UnitDynamicFields.ChannelObjects, 0, bobberGuid);
|
m_caster.SetDynamicStructuredValue(UnitDynamicFields.ChannelObjects, 0, bobberGuid);
|
||||||
m_caster.AddGameObject(pGameObj); // will removed at spell cancel
|
m_caster.AddGameObject(go); // will removed at spell cancel
|
||||||
|
|
||||||
// end time of range when possible catch fish (FISHING_BOBBER_READY_TIME..GetDuration(m_spellInfo))
|
// end time of range when possible catch fish (FISHING_BOBBER_READY_TIME..GetDuration(m_spellInfo))
|
||||||
// start time == fish-FISHING_BOBBER_READY_TIME (0..GetDuration(m_spellInfo)-FISHING_BOBBER_READY_TIME)
|
// start time == fish-FISHING_BOBBER_READY_TIME (0..GetDuration(m_spellInfo)-FISHING_BOBBER_READY_TIME)
|
||||||
@@ -4587,13 +4581,13 @@ namespace Game.Spells
|
|||||||
{
|
{
|
||||||
if (m_caster.IsTypeId(TypeId.Player))
|
if (m_caster.IsTypeId(TypeId.Player))
|
||||||
{
|
{
|
||||||
pGameObj.AddUniqueUse(m_caster.ToPlayer());
|
go.AddUniqueUse(m_caster.ToPlayer());
|
||||||
m_caster.AddGameObject(pGameObj); // will be removed at spell cancel
|
m_caster.AddGameObject(go); // will be removed at spell cancel
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case GameObjectTypes.DuelArbiter: // 52991
|
case GameObjectTypes.DuelArbiter: // 52991
|
||||||
m_caster.AddGameObject(pGameObj);
|
m_caster.AddGameObject(go);
|
||||||
break;
|
break;
|
||||||
case GameObjectTypes.FishingHole:
|
case GameObjectTypes.FishingHole:
|
||||||
case GameObjectTypes.Chest:
|
case GameObjectTypes.Chest:
|
||||||
@@ -4601,16 +4595,16 @@ namespace Game.Spells
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
pGameObj.SetRespawnTime(duration > 0 ? duration / Time.InMilliseconds : 0);
|
go.SetRespawnTime(duration > 0 ? duration / Time.InMilliseconds : 0);
|
||||||
pGameObj.SetOwnerGUID(m_caster.GetGUID());
|
go.SetOwnerGUID(m_caster.GetGUID());
|
||||||
pGameObj.SetSpellId(m_spellInfo.Id);
|
go.SetSpellId(m_spellInfo.Id);
|
||||||
|
|
||||||
ExecuteLogEffectSummonObject(effIndex, pGameObj);
|
ExecuteLogEffectSummonObject(effIndex, go);
|
||||||
|
|
||||||
Log.outDebug(LogFilter.Spells, "AddObject at SpellEfects.cpp EffectTransmitted");
|
Log.outDebug(LogFilter.Spells, "AddObject at SpellEfects.cpp EffectTransmitted");
|
||||||
|
|
||||||
cMap.AddToMap(pGameObj);
|
cMap.AddToMap(go);
|
||||||
GameObject linkedTrap = pGameObj.GetLinkedTrap();
|
GameObject linkedTrap = go.GetLinkedTrap();
|
||||||
if (linkedTrap != null)
|
if (linkedTrap != null)
|
||||||
{
|
{
|
||||||
linkedTrap.CopyPhaseFrom(m_caster);
|
linkedTrap.CopyPhaseFrom(m_caster);
|
||||||
@@ -5401,9 +5395,7 @@ namespace Game.Spells
|
|||||||
uint triggerEntry = (uint)effectInfo.MiscValue;
|
uint triggerEntry = (uint)effectInfo.MiscValue;
|
||||||
|
|
||||||
int duration = GetSpellInfo().CalcDuration(GetCaster());
|
int duration = GetSpellInfo().CalcDuration(GetCaster());
|
||||||
AreaTrigger areaTrigger = new AreaTrigger();
|
AreaTrigger.CreateAreaTrigger((uint)effectInfo.MiscValue, GetCaster(), null, GetSpellInfo(), destTarget.GetPosition(), duration, m_SpellVisual, m_castId);
|
||||||
if (!areaTrigger.CreateAreaTrigger((uint)effectInfo.MiscValue, GetCaster(), null, GetSpellInfo(), destTarget.GetPosition(), duration, m_SpellVisual, m_castId))
|
|
||||||
areaTrigger.Dispose();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[SpellEffectHandler(SpellEffectName.RemoveTalent)]
|
[SpellEffectHandler(SpellEffectName.RemoveTalent)]
|
||||||
|
|||||||
@@ -143,8 +143,8 @@ namespace Scripts.Northrend.Nexus.EyeOfEternity
|
|||||||
// There is no other way afaik...
|
// There is no other way afaik...
|
||||||
void SpawnGameObject(uint entry, Position pos)
|
void SpawnGameObject(uint entry, Position pos)
|
||||||
{
|
{
|
||||||
GameObject go = new GameObject();
|
GameObject go = GameObject.CreateGameObject(entry, instance, pos, Quaternion.WAxis, 255, GameObjectState.Ready);
|
||||||
if (go.Create(entry, instance, pos, Quaternion.WAxis, 255, GameObjectState.Ready))
|
if (go)
|
||||||
instance.AddToMap(go);
|
instance.AddToMap(go);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user