Dynamic Creature/Go spawning
Port From (https://github.com/TrinityCore/TrinityCore/commit/03b125e6d1947258316c931499746696a95aded2)
This commit is contained in:
@@ -201,7 +201,7 @@ namespace Game.Chat
|
||||
if (gameObjectInfo == null)
|
||||
continue;
|
||||
|
||||
handler.SendSysMessage(CypherStrings.GoListChat, guid, entry, guid, gameObjectInfo.name, x, y, z, mapId);
|
||||
handler.SendSysMessage(CypherStrings.GoListChat, guid, entry, guid, gameObjectInfo.name, x, y, z, mapId, "", "");
|
||||
|
||||
++count;
|
||||
} while (result.NextRow());
|
||||
@@ -412,10 +412,10 @@ namespace Game.Chat
|
||||
if (!ulong.TryParse(cValue, out ulong guidLow))
|
||||
return false;
|
||||
|
||||
GameObjectData data = Global.ObjectMgr.GetGOData(guidLow);
|
||||
GameObjectData data = Global.ObjectMgr.GetGameObjectData(guidLow);
|
||||
if (data == null)
|
||||
return false;
|
||||
entry = data.id;
|
||||
entry = data.Id;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -427,15 +427,45 @@ namespace Game.Chat
|
||||
if (gameObjectInfo == null)
|
||||
return false;
|
||||
|
||||
GameObject thisGO = null;
|
||||
if (handler.GetSession().GetPlayer())
|
||||
thisGO = handler.GetSession().GetPlayer().FindNearestGameObject(entry, 30);
|
||||
else if (handler.GetSelectedObject() != null && handler.GetSelectedObject().IsTypeId(TypeId.GameObject))
|
||||
thisGO = handler.GetSelectedObject().ToGameObject();
|
||||
|
||||
GameObjectTypes type = gameObjectInfo.type;
|
||||
uint displayId = gameObjectInfo.displayId;
|
||||
string name = gameObjectInfo.name;
|
||||
uint lootId = gameObjectInfo.GetLootId();
|
||||
|
||||
// If we have a real object, send some info about it
|
||||
if (thisGO != null)
|
||||
{
|
||||
handler.SendSysMessage(CypherStrings.SpawninfoGuidinfo, thisGO.GetGUID().ToString());
|
||||
handler.SendSysMessage(CypherStrings.SpawninfoSpawnidLocation, thisGO.GetSpawnId(), thisGO.GetPositionX(), thisGO.GetPositionY(), thisGO.GetPositionZ());
|
||||
Player player = handler.GetSession().GetPlayer();
|
||||
if (player != null)
|
||||
{
|
||||
Position playerPos = player.GetPosition();
|
||||
float dist = thisGO.GetExactDist(playerPos);
|
||||
handler.SendSysMessage(CypherStrings.SpawninfoDistancefromplayer, dist);
|
||||
}
|
||||
}
|
||||
handler.SendSysMessage(CypherStrings.GoinfoEntry, entry);
|
||||
handler.SendSysMessage(CypherStrings.GoinfoType, type);
|
||||
handler.SendSysMessage(CypherStrings.GoinfoLootid, lootId);
|
||||
handler.SendSysMessage(CypherStrings.GoinfoDisplayid, displayId);
|
||||
WorldObject obj = handler.GetSelectedObject();
|
||||
if (obj != null)
|
||||
{
|
||||
if (obj.IsGameObject() && obj.ToGameObject().GetGameObjectData() != null && obj.ToGameObject().GetGameObjectData().spawnGroupData.groupId != 0)
|
||||
{
|
||||
SpawnGroupTemplateData groupData = obj.ToGameObject().GetGameObjectData().spawnGroupData;
|
||||
handler.SendSysMessage(CypherStrings.SpawninfoGroupId, groupData.name, groupData.groupId, groupData.flags, groupData.isActive);
|
||||
}
|
||||
if (obj.IsGameObject())
|
||||
handler.SendSysMessage(CypherStrings.SpawninfoCompatibilityMode, obj.ToGameObject().GetRespawnCompatibilityMode());
|
||||
}
|
||||
handler.SendSysMessage(CypherStrings.GoinfoName, name);
|
||||
handler.SendSysMessage(CypherStrings.GoinfoSize, gameObjectInfo.size);
|
||||
|
||||
@@ -508,7 +538,7 @@ namespace Game.Chat
|
||||
return false;
|
||||
|
||||
// TODO: is it really necessary to add both the real and DB table guid here ?
|
||||
Global.ObjectMgr.AddGameObjectToGrid(spawnId, Global.ObjectMgr.GetGOData(spawnId));
|
||||
Global.ObjectMgr.AddGameObjectToGrid(spawnId, Global.ObjectMgr.GetGameObjectData(spawnId));
|
||||
handler.SendSysMessage(CypherStrings.GameobjectAdd, objectId, objectInfo.name, spawnId, player.GetPositionX(), player.GetPositionY(), player.GetPositionZ());
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -202,28 +202,17 @@ namespace Game.Chat.Commands
|
||||
if (!ulong.TryParse(id, out ulong guidLow) || guidLow == 0)
|
||||
return false;
|
||||
|
||||
float x, y, z, o;
|
||||
uint mapId;
|
||||
|
||||
// by DB guid
|
||||
GameObjectData goData = Global.ObjectMgr.GetGOData(guidLow);
|
||||
if (goData != null)
|
||||
{
|
||||
x = goData.posX;
|
||||
y = goData.posY;
|
||||
z = goData.posZ;
|
||||
o = goData.orientation;
|
||||
mapId = goData.mapid;
|
||||
}
|
||||
else
|
||||
GameObjectData goData = Global.ObjectMgr.GetGameObjectData(guidLow);
|
||||
if (goData == null)
|
||||
{
|
||||
handler.SendSysMessage(CypherStrings.CommandGoobjnotfound);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!GridDefines.IsValidMapCoord(mapId, x, y, z, o) || Global.ObjectMgr.IsTransportMap(mapId))
|
||||
if (!GridDefines.IsValidMapCoord(goData.spawnPoint) || Global.ObjectMgr.IsTransportMap(goData.spawnPoint.GetMapId()))
|
||||
{
|
||||
handler.SendSysMessage(CypherStrings.InvalidTargetCoord, x, y, mapId);
|
||||
handler.SendSysMessage(CypherStrings.InvalidTargetCoord, goData.spawnPoint.GetPositionX(), goData.spawnPoint.GetPositionY(), goData.spawnPoint.GetMapId());
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -237,7 +226,7 @@ namespace Game.Chat.Commands
|
||||
else
|
||||
player.SaveRecallPosition();
|
||||
|
||||
player.TeleportTo(mapId, x, y, z, o);
|
||||
player.TeleportTo(goData.spawnPoint);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,9 @@
|
||||
using Framework.Constants;
|
||||
using Framework.Database;
|
||||
using Framework.IO;
|
||||
using Game.DataStorage;
|
||||
using Game.Entities;
|
||||
using Game.Maps;
|
||||
using Game.Spells;
|
||||
using System.Collections.Generic;
|
||||
|
||||
@@ -128,11 +130,39 @@ namespace Game.Chat.Commands
|
||||
float y = result.Read<float>(2);
|
||||
float z = result.Read<float>(3);
|
||||
ushort mapId = result.Read<ushort>(4);
|
||||
bool liveFound = false;
|
||||
|
||||
// Get map (only support base map from console)
|
||||
Map thisMap;
|
||||
if (handler.GetSession() != null)
|
||||
handler.SendSysMessage(CypherStrings.CreatureListChat, guid, guid, cInfo.Name, x, y, z, mapId);
|
||||
thisMap = handler.GetSession().GetPlayer().GetMap();
|
||||
else
|
||||
handler.SendSysMessage(CypherStrings.CreatureListConsole, guid, cInfo.Name, x, y, z, mapId);
|
||||
thisMap = Global.MapMgr.FindBaseNonInstanceMap(mapId);
|
||||
|
||||
// If map found, try to find active version of this creature
|
||||
if (thisMap)
|
||||
{
|
||||
var creBounds = thisMap.GetCreatureBySpawnIdStore().LookupByKey(guid);
|
||||
if (!creBounds.Empty())
|
||||
{
|
||||
foreach (var creature in creBounds)
|
||||
{
|
||||
if (handler.GetSession())
|
||||
handler.SendSysMessage(CypherStrings.CreatureListChat, guid, guid, cInfo.Name, x, y, z, mapId, creature.GetGUID().ToString(), creature.IsAlive() ? "*" : " ");
|
||||
else
|
||||
handler.SendSysMessage(CypherStrings.CreatureListConsole, guid, cInfo.Name, x, y, z, mapId, creature.GetGUID().ToString(), creature.IsAlive() ? "*" : " ");
|
||||
}
|
||||
liveFound = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!liveFound)
|
||||
{
|
||||
if (handler.GetSession())
|
||||
handler.SendSysMessage(CypherStrings.CreatureListChat, guid, guid, cInfo.Name, x, y, z, mapId, "", "");
|
||||
else
|
||||
handler.SendSysMessage(CypherStrings.CreatureListConsole, guid, cInfo.Name, x, y, z, mapId, "", "");
|
||||
}
|
||||
}
|
||||
while (result.NextRow());
|
||||
}
|
||||
@@ -495,11 +525,39 @@ namespace Game.Chat.Commands
|
||||
float z = result.Read<float>(3);
|
||||
ushort mapId = result.Read<ushort>(4);
|
||||
uint entry = result.Read<uint>(5);
|
||||
bool liveFound = false;
|
||||
|
||||
// Get map (only support base map from console)
|
||||
Map thisMap;
|
||||
if (handler.GetSession() != null)
|
||||
handler.SendSysMessage(CypherStrings.GoListChat, guid, entry, guid, gInfo.name, x, y, z, mapId);
|
||||
thisMap = handler.GetSession().GetPlayer().GetMap();
|
||||
else
|
||||
handler.SendSysMessage(CypherStrings.GoListConsole, guid, gInfo.name, x, y, z, mapId);
|
||||
thisMap = Global.MapMgr.FindBaseNonInstanceMap(mapId);
|
||||
|
||||
// If map found, try to find active version of this object
|
||||
if (thisMap)
|
||||
{
|
||||
var goBounds = thisMap.GetGameObjectBySpawnIdStore().LookupByKey(guid);
|
||||
if (!goBounds.Empty())
|
||||
{
|
||||
foreach (var go in goBounds)
|
||||
{
|
||||
if (handler.GetSession())
|
||||
handler.SendSysMessage(CypherStrings.GoListChat, guid, entry, guid, gInfo.name, x, y, z, mapId, go.GetGUID(), go.IsSpawned() ? "*" : " ");
|
||||
else
|
||||
handler.SendSysMessage(CypherStrings.GoListConsole, guid, gInfo.name, x, y, z, mapId, go.GetGUID(), go.IsSpawned() ? "*" : " ");
|
||||
}
|
||||
liveFound = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!liveFound)
|
||||
{
|
||||
if (handler.GetSession())
|
||||
handler.SendSysMessage(CypherStrings.GoListChat, guid, entry, guid, gInfo.name, x, y, z, mapId, "", "");
|
||||
else
|
||||
handler.SendSysMessage(CypherStrings.GoListConsole, guid, gInfo.name, x, y, z, mapId, "", "");
|
||||
}
|
||||
}
|
||||
while (result.NextRow());
|
||||
}
|
||||
@@ -509,6 +567,77 @@ namespace Game.Chat.Commands
|
||||
return true;
|
||||
}
|
||||
|
||||
[Command("respawns", RBACPermissions.CommandListRespawns)]
|
||||
static bool HandleListRespawnsCommand(StringArguments args, CommandHandler handler)
|
||||
{
|
||||
// We need a player
|
||||
Player player = handler.GetSession().GetPlayer();
|
||||
if (player == null)
|
||||
return false;
|
||||
|
||||
// And we need a map
|
||||
Map map = player.GetMap();
|
||||
if (map == null)
|
||||
return false;
|
||||
|
||||
uint range = 0;
|
||||
if (!args.Empty())
|
||||
range = args.NextUInt32();
|
||||
|
||||
List<RespawnInfo> respawns = new List<RespawnInfo>();
|
||||
Locale locale = handler.GetSession().GetSessionDbcLocale();
|
||||
string stringOverdue = Global.ObjectMgr.GetCypherString(CypherStrings.ListRespawnsOverdue, locale);
|
||||
string stringCreature = Global.ObjectMgr.GetCypherString(CypherStrings.ListRespawnsCreatures, locale);
|
||||
string stringGameobject = Global.ObjectMgr.GetCypherString(CypherStrings.ListRespawnsGameobjects, locale);
|
||||
|
||||
uint zoneId = player.GetZoneId();
|
||||
if (range != 0)
|
||||
handler.SendSysMessage(CypherStrings.ListRespawnsRange, stringCreature, range);
|
||||
else
|
||||
handler.SendSysMessage(CypherStrings.ListRespawnsZone, stringCreature, GetZoneName(zoneId, handler.GetSessionDbcLocale()), zoneId);
|
||||
handler.SendSysMessage(CypherStrings.ListRespawnsListheader);
|
||||
map.GetRespawnInfo(respawns, SpawnObjectTypeMask.Creature, range != 0 ? 0 : zoneId);
|
||||
foreach (RespawnInfo ri in respawns)
|
||||
{
|
||||
CreatureData data = Global.ObjectMgr.GetCreatureData(ri.spawnId);
|
||||
if (data == null)
|
||||
continue;
|
||||
|
||||
if (range != 0 && !player.IsInDist(data.spawnPoint, range))
|
||||
continue;
|
||||
|
||||
uint gridY = ri.gridId / MapConst.MaxGrids;
|
||||
uint gridX = ri.gridId % MapConst.MaxGrids;
|
||||
|
||||
string respawnTime = ri.respawnTime > Time.UnixTime ? Time.secsToTimeString((ulong)(ri.respawnTime - Time.UnixTime), true) : stringOverdue;
|
||||
handler.SendSysMessage($"{ri.spawnId} | {ri.entry} | [{gridX},{gridY}] | {GetZoneName(ri.zoneId, handler.GetSessionDbcLocale())} ({ri.zoneId}) | {(data.spawnGroupData.isActive ? respawnTime : "inactive")}");
|
||||
}
|
||||
|
||||
respawns.Clear();
|
||||
if (range != 0)
|
||||
handler.SendSysMessage(CypherStrings.ListRespawnsRange, stringGameobject, range);
|
||||
else
|
||||
handler.SendSysMessage(CypherStrings.ListRespawnsZone, stringGameobject, GetZoneName(zoneId, handler.GetSessionDbcLocale()), zoneId);
|
||||
handler.SendSysMessage(CypherStrings.ListRespawnsListheader);
|
||||
map.GetRespawnInfo(respawns, SpawnObjectTypeMask.GameObject, range != 0 ? 0 : zoneId);
|
||||
foreach (RespawnInfo ri in respawns)
|
||||
{
|
||||
GameObjectData data = Global.ObjectMgr.GetGameObjectData(ri.spawnId);
|
||||
if (data == null)
|
||||
continue;
|
||||
|
||||
if (range != 0 && !player.IsInDist(data.spawnPoint, range))
|
||||
continue;
|
||||
|
||||
uint gridY = ri.gridId / MapConst.MaxGrids;
|
||||
uint gridX = ri.gridId % MapConst.MaxGrids;
|
||||
|
||||
string respawnTime = ri.respawnTime > Time.UnixTime ? Time.secsToTimeString((ulong)(ri.respawnTime - Time.UnixTime), true) : stringOverdue;
|
||||
handler.SendSysMessage($"{ri.spawnId} | {ri.entry} | [{gridX},{gridY}] | {GetZoneName(ri.zoneId, handler.GetSessionDbcLocale())} ({ri.zoneId}) | {(data.spawnGroupData.isActive ? respawnTime : "inactive")}");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
[Command("scenes", RBACPermissions.CommandListScenes)]
|
||||
static bool HandleListScenesCommand(StringArguments args, CommandHandler handler)
|
||||
{
|
||||
@@ -531,5 +660,11 @@ namespace Game.Chat.Commands
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static string GetZoneName(uint zoneId, Locale locale)
|
||||
{
|
||||
AreaTableRecord zoneEntry = CliDB.AreaTableStorage.LookupByKey(zoneId);
|
||||
return zoneEntry != null ? zoneEntry.AreaName[locale] : "<unknown zone>";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1260
-1248
File diff suppressed because it is too large
Load Diff
@@ -33,6 +33,41 @@ namespace Game.Chat
|
||||
[CommandGroup("npc", RBACPermissions.CommandNpc)]
|
||||
class NPCCommands
|
||||
{
|
||||
[Command("despawngroup", RBACPermissions.CommandNpcDespawngroup)]
|
||||
static bool HandleNpcDespawnGroup(StringArguments args, CommandHandler handler)
|
||||
{
|
||||
if (args.Empty())
|
||||
return false;
|
||||
|
||||
bool deleteRespawnTimes = false;
|
||||
uint groupId = 0;
|
||||
|
||||
// Decode arguments
|
||||
string arg = args.NextString();
|
||||
while (!arg.IsEmpty())
|
||||
{
|
||||
string thisArg = arg.ToLower();
|
||||
if (thisArg == "removerespawntime")
|
||||
deleteRespawnTimes = true;
|
||||
else if (thisArg.IsEmpty() || !thisArg.IsNumber())
|
||||
return false;
|
||||
else
|
||||
groupId = uint.Parse(thisArg);
|
||||
|
||||
arg = args.NextString();
|
||||
}
|
||||
|
||||
Player player = handler.GetSession().GetPlayer();
|
||||
|
||||
if (!Global.ObjectMgr.SpawnGroupDespawn(groupId, player.GetMap(), deleteRespawnTimes))
|
||||
{
|
||||
handler.SendSysMessage(CypherStrings.SpawngroupBadgroup, groupId);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
[Command("evade", RBACPermissions.CommandNpcEvade)]
|
||||
static bool HandleNpcEvadeCommand(StringArguments args, CommandHandler handler)
|
||||
{
|
||||
@@ -96,13 +131,21 @@ namespace Game.Chat
|
||||
uint nativeid = target.GetNativeDisplayId();
|
||||
uint Entry = target.GetEntry();
|
||||
|
||||
long curRespawnDelay = target.GetRespawnTimeEx() - Time.UnixTime;
|
||||
long curRespawnDelay = target.GetRespawnCompatibilityMode() ? target.GetRespawnTimeEx() - Time.UnixTime : target.GetMap().GetCreatureRespawnTime(target.GetSpawnId()) - Time.UnixTime;
|
||||
if (curRespawnDelay < 0)
|
||||
curRespawnDelay = 0;
|
||||
|
||||
string curRespawnDelayStr = Time.secsToTimeString((ulong)curRespawnDelay, true);
|
||||
string defRespawnDelayStr = Time.secsToTimeString(target.GetRespawnDelay(), true);
|
||||
|
||||
handler.SendSysMessage(CypherStrings.NpcinfoChar, target.GetSpawnId(), target.GetGUID().ToString(), faction, npcflags, Entry, displayid, nativeid);
|
||||
if (target.GetCreatureData() != null && target.GetCreatureData().spawnGroupData.groupId != 0)
|
||||
{
|
||||
SpawnGroupTemplateData groupData = target.GetCreatureData().spawnGroupData;
|
||||
if (groupData != null)
|
||||
handler.SendSysMessage(CypherStrings.SpawninfoGroupId, groupData.name, groupData.groupId, groupData.flags, groupData.isActive);
|
||||
}
|
||||
handler.SendSysMessage(CypherStrings.SpawninfoCompatibilityMode, target.GetRespawnCompatibilityMode());
|
||||
handler.SendSysMessage(CypherStrings.NpcinfoLevel, target.GetLevel());
|
||||
handler.SendSysMessage(CypherStrings.NpcinfoEquipment, target.GetCurrentEquipmentId(), target.GetOriginalEquipmentId());
|
||||
handler.SendSysMessage(CypherStrings.NpcinfoHealth, target.GetCreateHealth(), target.GetMaxHealth(), target.GetHealth());
|
||||
@@ -161,71 +204,60 @@ namespace Game.Chat
|
||||
ulong lowguid;
|
||||
|
||||
Creature creature = handler.GetSelectedCreature();
|
||||
if (!creature)
|
||||
Player player = handler.GetSession().GetPlayer();
|
||||
if (player == null)
|
||||
return false;
|
||||
|
||||
if (creature != null)
|
||||
lowguid = creature.GetSpawnId();
|
||||
else
|
||||
{
|
||||
// number or [name] Shift-click form |color|Hcreature:creature_guid|h[name]|h|r
|
||||
string cId = handler.ExtractKeyFromLink(args, "Hcreature");
|
||||
if (string.IsNullOrEmpty(cId))
|
||||
if (cId.IsEmpty())
|
||||
return false;
|
||||
|
||||
if (!ulong.TryParse(cId, out lowguid))
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// Attempting creature load from DB data
|
||||
CreatureData data = Global.ObjectMgr.GetCreatureData(lowguid);
|
||||
if (data == null)
|
||||
{
|
||||
handler.SendSysMessage(CypherStrings.CommandCreatguidnotfound, lowguid);
|
||||
return false;
|
||||
}
|
||||
|
||||
uint map_id = data.mapid;
|
||||
if (handler.GetSession().GetPlayer().GetMapId() != map_id)
|
||||
{
|
||||
handler.SendSysMessage(CypherStrings.CommandCreatureatsamemap, lowguid);
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
if (data == null)
|
||||
{
|
||||
lowguid = creature.GetSpawnId();
|
||||
handler.SendSysMessage(CypherStrings.CommandCreatguidnotfound, lowguid);
|
||||
return false;
|
||||
}
|
||||
|
||||
float x = handler.GetPlayer().GetPositionX();
|
||||
float y = handler.GetPlayer().GetPositionY();
|
||||
float z = handler.GetPlayer().GetPositionZ();
|
||||
float o = handler.GetPlayer().GetOrientation();
|
||||
|
||||
if (creature)
|
||||
if (player.GetMapId() != data.spawnPoint.GetMapId())
|
||||
{
|
||||
CreatureData data = Global.ObjectMgr.GetCreatureData(creature.GetSpawnId());
|
||||
if (data != null)
|
||||
{
|
||||
data.posX = x;
|
||||
data.posY = y;
|
||||
data.posZ = z;
|
||||
data.orientation = o;
|
||||
}
|
||||
creature.UpdatePosition(x, y, z, o);
|
||||
creature.GetMotionMaster().Initialize();
|
||||
if (creature.IsAlive()) // dead creature will reset movement generator at respawn
|
||||
{
|
||||
creature.SetDeathState(DeathState.JustDied);
|
||||
creature.Respawn();
|
||||
}
|
||||
handler.SendSysMessage(CypherStrings.CommandCreatureatsamemap, lowguid);
|
||||
return false;
|
||||
}
|
||||
|
||||
data.spawnPoint.Relocate(player);
|
||||
|
||||
// update position in DB
|
||||
PreparedStatement stmt = DB.World.GetPreparedStatement(WorldStatements.UPD_CREATURE_POSITION);
|
||||
|
||||
stmt.AddValue(0, x);
|
||||
stmt.AddValue(1, y);
|
||||
stmt.AddValue(2, z);
|
||||
stmt.AddValue(3, o);
|
||||
stmt.AddValue(0, player.GetPositionX());
|
||||
stmt.AddValue(1, player.GetPositionY());
|
||||
stmt.AddValue(2, player.GetPositionZ());
|
||||
stmt.AddValue(3, player.GetOrientation());
|
||||
stmt.AddValue(4, lowguid);
|
||||
|
||||
DB.World.Execute(stmt);
|
||||
|
||||
// respawn selected creature at the new location
|
||||
if (creature)
|
||||
{
|
||||
if (creature.IsAlive())
|
||||
creature.SetDeathState(DeathState.JustDied);
|
||||
creature.Respawn(true);
|
||||
if (!creature.GetRespawnCompatibilityMode())
|
||||
creature.AddObjectToRemoveList();
|
||||
}
|
||||
|
||||
handler.SendSysMessage(CypherStrings.CommandCreaturemoved);
|
||||
return true;
|
||||
}
|
||||
@@ -264,7 +296,7 @@ namespace Game.Chat
|
||||
if (creatureTemplate == null)
|
||||
continue;
|
||||
|
||||
handler.SendSysMessage(CypherStrings.CreatureListChat, guid, guid, creatureTemplate.Name, x, y, z, mapId);
|
||||
handler.SendSysMessage(CypherStrings.CreatureListChat, guid, guid, creatureTemplate.Name, x, y, z, mapId, "", "");
|
||||
|
||||
++count;
|
||||
}
|
||||
@@ -386,6 +418,49 @@ namespace Game.Chat
|
||||
return true;
|
||||
}
|
||||
|
||||
[Command("spawngroup", RBACPermissions.CommandNpcSpawngroup)]
|
||||
static bool HandleNpcSpawnGroup(StringArguments args, CommandHandler handler)
|
||||
{
|
||||
if (args.Empty())
|
||||
return false;
|
||||
|
||||
bool ignoreRespawn = false;
|
||||
bool force = false;
|
||||
uint groupId = 0;
|
||||
|
||||
// Decode arguments
|
||||
string arg = args.NextString();
|
||||
while (!arg.IsEmpty())
|
||||
{
|
||||
string thisArg = arg.ToLower();
|
||||
if (thisArg == "ignorerespawn")
|
||||
ignoreRespawn = true;
|
||||
else if (thisArg == "force")
|
||||
force = true;
|
||||
else if (thisArg.IsEmpty() || !thisArg.IsNumber())
|
||||
return false;
|
||||
else
|
||||
groupId = uint.Parse(thisArg);
|
||||
|
||||
arg = args.NextString();
|
||||
}
|
||||
|
||||
Player player = handler.GetSession().GetPlayer();
|
||||
|
||||
List<WorldObject> creatureList = new List<WorldObject>();
|
||||
if (!Global.ObjectMgr.SpawnGroupSpawn(groupId, player.GetMap(), ignoreRespawn, force, creatureList))
|
||||
{
|
||||
handler.SendSysMessage(CypherStrings.SpawngroupBadgroup, groupId);
|
||||
return false;
|
||||
}
|
||||
|
||||
handler.SendSysMessage(CypherStrings.SpawngroupSpawncount, creatureList.Count);
|
||||
foreach (WorldObject obj in creatureList)
|
||||
handler.SendSysMessage($"{obj.GetName()} ({obj.GetGUID()})");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
[Command("tame", RBACPermissions.CommandNpcTame)]
|
||||
static bool HandleNpcTameCommand(StringArguments args, CommandHandler handler)
|
||||
{
|
||||
@@ -581,13 +656,11 @@ namespace Game.Chat
|
||||
{
|
||||
ulong guid = map.GenerateLowGuid(HighGuid.Creature);
|
||||
CreatureData data = Global.ObjectMgr.NewOrExistCreatureData(guid);
|
||||
data.id = id;
|
||||
data.posX = chr.GetTransOffsetX();
|
||||
data.posY = chr.GetTransOffsetY();
|
||||
data.posZ = chr.GetTransOffsetZ();
|
||||
data.orientation = chr.GetTransOffsetO();
|
||||
data.spawnId = guid;
|
||||
data.Id = id;
|
||||
data.spawnPoint.Relocate(chr.GetTransOffsetX(), chr.GetTransOffsetY(), chr.GetTransOffsetZ(), chr.GetTransOffsetO());
|
||||
// @todo: add phases
|
||||
|
||||
|
||||
Creature _creature = trans.CreateNPCPassenger(guid, data);
|
||||
_creature.SaveToDB((uint)trans.GetGoInfo().MoTransport.SpawnMap, new List<Difficulty>() { map.GetDifficultyID() });
|
||||
|
||||
@@ -607,7 +680,7 @@ namespace Game.Chat
|
||||
// To call _LoadGoods(); _LoadQuests(); CreateTrainerSpells()
|
||||
// current "creature" variable is deleted and created fresh new, otherwise old values might trigger asserts or cause undefined behavior
|
||||
creature.CleanupsBeforeDelete();
|
||||
creature = Creature.CreateCreatureFromDB(db_guid, map);
|
||||
creature = Creature.CreateCreatureFromDB(db_guid, map, true, true);
|
||||
if (!creature)
|
||||
return false;
|
||||
|
||||
@@ -794,7 +867,7 @@ namespace Game.Chat
|
||||
[Command("delete", RBACPermissions.CommandNpcDelete)]
|
||||
static bool HandleNpcDeleteCommand(StringArguments args, CommandHandler handler)
|
||||
{
|
||||
Creature unit = null;
|
||||
Creature creature;
|
||||
|
||||
if (!args.Empty())
|
||||
{
|
||||
@@ -806,21 +879,27 @@ namespace Game.Chat
|
||||
if (!ulong.TryParse(cId, out ulong guidLow) || guidLow == 0)
|
||||
return false;
|
||||
|
||||
unit = handler.GetCreatureFromPlayerMapByDbGuid(guidLow);
|
||||
creature = handler.GetCreatureFromPlayerMapByDbGuid(guidLow);
|
||||
}
|
||||
else
|
||||
unit = handler.GetSelectedCreature();
|
||||
creature = handler.GetSelectedCreature();
|
||||
|
||||
if (!unit || unit.IsPet() || unit.IsTotem())
|
||||
if (!creature || creature.IsPet() || creature.IsTotem())
|
||||
{
|
||||
handler.SendSysMessage(CypherStrings.SelectCreature);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Delete the creature
|
||||
unit.CombatStop();
|
||||
unit.DeleteFromDB();
|
||||
unit.AddObjectToRemoveList();
|
||||
TempSummon summon = creature.ToTempSummon();
|
||||
if (summon != null)
|
||||
summon.UnSummon();
|
||||
else
|
||||
{
|
||||
// Delete the creature
|
||||
creature.CombatStop();
|
||||
creature.DeleteFromDB();
|
||||
creature.AddObjectToRemoveList();
|
||||
}
|
||||
|
||||
handler.SendSysMessage(CypherStrings.CommandDelcreatmessage);
|
||||
|
||||
|
||||
@@ -559,7 +559,7 @@ namespace Game.Chat.Commands
|
||||
creature.Dispose();
|
||||
|
||||
// To call _LoadGoods(); _LoadQuests(); CreateTrainerSpells();
|
||||
creature = Creature.CreateCreatureFromDB(dbGuid, map);
|
||||
creature = Creature.CreateCreatureFromDB(dbGuid, map, true, true);
|
||||
if (!creature)
|
||||
{
|
||||
handler.SendSysMessage(CypherStrings.WaypointVpNotcreated, 1);
|
||||
@@ -779,7 +779,7 @@ namespace Game.Chat.Commands
|
||||
creature.Dispose();
|
||||
|
||||
// To call _LoadGoods(); _LoadQuests(); CreateTrainerSpells();
|
||||
creature = Creature.CreateCreatureFromDB(dbGuid, map);
|
||||
creature = Creature.CreateCreatureFromDB(dbGuid, map, true, true);
|
||||
if (!creature)
|
||||
{
|
||||
handler.SendSysMessage(CypherStrings.WaypointVpNotcreated, id);
|
||||
@@ -844,7 +844,7 @@ namespace Game.Chat.Commands
|
||||
creature.CleanupsBeforeDelete();
|
||||
creature.Dispose();
|
||||
|
||||
creature = Creature.CreateCreatureFromDB(dbGuid, map);
|
||||
creature = Creature.CreateCreatureFromDB(dbGuid, map, true, true);
|
||||
if (!creature)
|
||||
{
|
||||
handler.SendSysMessage(CypherStrings.WaypointVpNotcreated, 1);
|
||||
@@ -899,7 +899,7 @@ namespace Game.Chat.Commands
|
||||
creature.CleanupsBeforeDelete();
|
||||
creature.Dispose();
|
||||
|
||||
creature = Creature.CreateCreatureFromDB(dbGuid, map);
|
||||
creature = Creature.CreateCreatureFromDB(dbGuid, map, true, true);
|
||||
if (!creature)
|
||||
{
|
||||
handler.SendSysMessage(CypherStrings.WaypointNotcreated, 1);
|
||||
|
||||
Reference in New Issue
Block a user