/// <summary> /// Sets armor piece color <slotIndex (0=all), pri_tint, sec_tint (from tintpalette_equipment.csv)> /// </summary> /// <param name="plr">Player that initiated the command</param> /// <param name="values">List of command arguments (after command name)</param> /// <returns>True if command was correctly handled, false if operation was canceled</returns> public static bool NpcTint(Player plr, ref List <string> values) { Object target = plr.CbtInterface.GetCurrentTarget(); if (target == null || !target.IsCreature()) { return(false); } int slotIndex = GetInt(ref values); int pri = GetInt(ref values); int sec = GetInt(ref values); var creature = target.GetCreature(); foreach (var item in creature.ItmInterface.Items.Where(e => e != null && e.SlotId != 0)) { if (slotIndex != 0 && item.SlotId != slotIndex) { continue; } item._PrimaryColor = (ushort)pri; item._SecondaryColor = (ushort)sec; item.CreatureItem.PrimaryColor = (ushort)pri; item.CreatureItem.SecondaryColor = (ushort)sec; WorldMgr.Database.SaveObject(item.CreatureItem); } WorldMgr.Database.ForceSave(); creature.ItmInterface.SendEquipped(null); return(true); }
/// <summary> /// Delete the target <(0=World,1=Database)> /// </summary> /// <param name="plr">Player that initiated the command</param> /// <param name="values">List of command arguments (after command name)</param> /// <returns>True if command was correctly handled, false if operation was canceled</returns> public static bool NpcRemove(Player plr, ref List <string> values) { Object obj = GetObjectTarget(plr); if (!obj.IsCreature()) { return(false); } int database = GetInt(ref values); obj.Dispose(); if (database > 0) { Creature_spawn spawn = obj.GetCreature().Spawn; WorldMgr.Database.DeleteObject(spawn); GMCommandLog log = new GMCommandLog(); log.PlayerName = plr.Name; log.AccountId = (uint)plr.Client._Account.AccountId; log.Command = "REMOVE CREATURE " + spawn.Entry + " " + spawn.Guid + " AT " + spawn.ZoneId + " " + spawn.WorldX + " " + spawn.WorldY; log.Date = DateTime.Now; CharMgr.Database.AddObject(log); } plr.SendClientMessage("NPC REMOVE: Removed " + obj.GetCreature().Spawn.Guid); return(true); }
/// <summary> /// Changes the current faction of selected Unit (byte Faction) /// </summary> /// <param name="plr">Player that initiated the command</param> /// <param name="values">List of command arguments (after command name)</param> /// <returns>True if command was correctly handled, false if operation was canceled</returns> public static bool ModifyFaction(Player plr, ref List <string> values) { byte faction = (byte)GetInt(ref values); byte save = (byte)(values.Count > 0 ? GetInt(ref values) : 0); Object obj = GetObjectTarget(plr); RegionMgr region = obj.Region; ushort zoneId = obj.Zone.ZoneId; obj.RemoveFromWorld(); obj.GetUnit().SetFaction(faction); region.AddObject(obj.GetUnit(), zoneId, true); if (save > 0) { if (obj.IsCreature()) { Creature crea = obj.GetCreature(); crea.Spawn.Faction = faction; WorldMgr.Database.SaveObject(crea.Spawn); } } return(true); }
/// <summary> /// Move target to my position /// </summary> /// <param name="plr">Player that initiated the command</param> /// <param name="values">List of command arguments (after command name)</param> /// <returns>True if command was correctly handled, false if operation was canceled</returns> public static bool NpcCome(Player plr, ref List <string> values) { Object target = plr.CbtInterface.GetCurrentTarget(); if (target == null || !target.IsCreature()) { return(false); } target.GetCreature().MvtInterface.Move(plr.WorldPosition); return(true); }
public static bool NpcChangeSpawnPlace(Player plr, ref List <string> values) { Object target = plr.CbtInterface.GetCurrentTarget(); if (target == null && !target.IsCreature()) { return(false); } target.GetCreature().MvtInterface.Move(plr.WorldPosition); Creature creature = target.GetCreature(); if (creature != null) { plr.UpdateWorldPosition(); if (creature.PQSpawnId == null) { creature.Spawn.Dirty = true; creature.Spawn.WorldX = plr._Value.WorldX; creature.Spawn.WorldY = plr._Value.WorldY; creature.Spawn.WorldZ = plr._Value.WorldZ; creature.Spawn.WorldO = plr._Value.WorldO; WorldMgr.Database.SaveObject(creature.Spawn); } else { PQuest_Spawn pQSpawn = WorldMgr.Database.SelectObject <PQuest_Spawn>("pquest_spawns_ID='" + creature.PQSpawnId + "'"); pQSpawn.Dirty = true; pQSpawn.WorldX = plr._Value.WorldX; pQSpawn.WorldY = plr._Value.WorldY; pQSpawn.WorldZ = plr._Value.WorldZ; pQSpawn.WorldO = plr._Value.WorldO; WorldMgr.Database.SaveObject(pQSpawn); } } return(false); }
/// <summary> /// Converts selected Object to a Instance spawn <objective id> /// </summary> /// <param name="plr">Player that initiated the command</param> /// <param name="values">List of command arguments (after command name)</param> /// <returns>True if command was correctly handled, false if operation was canceled</returns> public static bool InstanceConvert(Player plr, ref List <string> values) { //<BossId> <spawngroup> <realm> int bossId = GetInt(ref values); int spawngroup = GetInt(ref values); int realm = GetInt(ref values); //creatures only atm Object obj = GetObjectTarget(plr); if (!obj.IsCreature()) { return(false); } obj.Dispose(); Creature_spawn spawn = obj.GetCreature().Spawn; WorldMgr.Database.DeleteObject(spawn); Instance_Spawn newSpawn = new Instance_Spawn(); newSpawn.Instance_spawns_ID = Guid.NewGuid().ToString(); newSpawn.Entry = spawn.Entry; newSpawn.WorldO = (ushort)spawn.WorldO; newSpawn.WorldY = spawn.WorldY; newSpawn.WorldZ = spawn.WorldZ; newSpawn.WorldX = spawn.WorldX; newSpawn.ZoneID = (ushort)spawn.ZoneId; newSpawn.Emote = spawn.Emote; newSpawn.Level = spawn.Level; newSpawn.SpawnGroupID = (uint)spawngroup; newSpawn.ConnectedbossId = (uint)bossId; newSpawn.Realm = (byte)realm; WorldMgr.Database.AddObject(newSpawn); return(true); }
/// <summary> /// Converts selected Object to a PQ spawn <objective id> /// </summary> /// <param name="plr">Player that initiated the command</param> /// <param name="values">List of command arguments (after command name)</param> /// <returns>True if command was correctly handled, false if operation was canceled</returns> public static bool PqConvert(Player plr, ref List <string> values) { int objective = GetInt(ref values); int type = GetInt(ref values); //creatures only atm Object obj = GetObjectTarget(plr); switch (type) { case 1: if (!obj.IsCreature()) { return(false); } obj.Dispose(); Creature_spawn spawn = obj.GetCreature().Spawn; WorldMgr.Database.DeleteObject(spawn); PQuest_Spawn newSpawn = new PQuest_Spawn(); //Added pquest_spawns_ID here as it is required to correctly save it to DB after this field was //added in PQuest_spawn.cs newSpawn.pquest_spawns_ID = Guid.NewGuid().ToString(); newSpawn.Entry = spawn.Entry; newSpawn.Objective = (uint)objective; newSpawn.Type = 1; // npc newSpawn.WorldO = spawn.WorldO; newSpawn.WorldY = spawn.WorldY; newSpawn.WorldZ = spawn.WorldZ; newSpawn.WorldX = spawn.WorldX; newSpawn.ZoneId = spawn.ZoneId; newSpawn.Emote = spawn.Emote; newSpawn.Level = spawn.Level; WorldMgr.Database.AddObject(newSpawn); break; case 2: if (!obj.IsGameObject()) { return(false); } obj.Dispose(); GameObject_spawn gospawn = obj.GetGameObject().Spawn; WorldMgr.Database.DeleteObject(gospawn); PQuest_Spawn newSpawngo = new PQuest_Spawn(); newSpawngo.pquest_spawns_ID = Guid.NewGuid().ToString(); newSpawngo.Entry = gospawn.Entry; newSpawngo.Objective = (uint)objective; newSpawngo.Type = 2; // go newSpawngo.WorldO = gospawn.WorldO; newSpawngo.WorldY = gospawn.WorldY; newSpawngo.WorldZ = gospawn.WorldZ; newSpawngo.WorldX = gospawn.WorldX; newSpawngo.ZoneId = gospawn.ZoneId; newSpawngo.Unks = gospawn.Unks; WorldMgr.Database.AddObject(newSpawngo); break; case 3: if (!obj.IsGameObject()) { return(false); } GameObject_spawn gointspawn = obj.GetGameObject().Spawn; PQuest_Spawn newSpawnintgo = new PQuest_Spawn(); newSpawnintgo.pquest_spawns_ID = Guid.NewGuid().ToString(); newSpawnintgo.Entry = ((GameObject)obj).Spawn.Guid; newSpawnintgo.Objective = (uint)objective; newSpawnintgo.Type = 3; // change interaction of a spawned go WorldMgr.Database.AddObject(newSpawnintgo); break; } return(true); }
/// <summary> /// Move a keep npc /// </summary> /// <param name="plr">Player that initiated the command</param> /// <param name="values">List of command arguments (after command name)</param> /// <returns>True if command was correctly handled, false if operation was canceled</returns> public static bool MoveKeepSpawn(Player plr, ref List <string> values) { Object obj = GetObjectTarget(plr); if (!obj.IsCreature()) { return(false); } Creature creature = (Creature)obj; var selectedEntry = creature.Entry; var oldX = creature.WorldPosition.X; var oldY = creature.WorldPosition.Y; var oldZ = creature.WorldPosition.Z; var oldO = creature.Heading; var keep = plr.Region.Campaign.GetClosestKeep(plr.WorldPosition, (ushort)plr.ZoneId); plr.SendClientMessage(keep.Info.Name); KeepNpcCreature keepNpcCreature = null; if (keep.Realm == Realms.REALMS_REALM_DESTRUCTION) { keepNpcCreature = keep.Creatures.SingleOrDefault(x => x.Info.DestroId == selectedEntry && x.Info.X == oldX); } if (keep.Realm == Realms.REALMS_REALM_ORDER) { keepNpcCreature = keep.Creatures.SingleOrDefault(x => x.Info.OrderId == selectedEntry && x.Info.X == oldX); } if (keepNpcCreature == null) { plr.SendClientMessage($"Could not locate selected target"); return(true); } keepNpcCreature.Info.X = plr.WorldPosition.X; keepNpcCreature.Info.Y = plr.WorldPosition.Y; keepNpcCreature.Info.Z = plr.WorldPosition.Z; keepNpcCreature.Info.O = plr.Oid; keepNpcCreature.Info.WaypointGUID = Convert.ToInt32(values[0]); var sql = $"UPDATE war_world.keep_creatures " + $"SET X={keepNpcCreature.Info.X}, Y={keepNpcCreature.Info.Y}, Z = {keepNpcCreature.Info.Z}, O={keepNpcCreature.Info.O}, " + $"WaypointGUID = {keepNpcCreature.Info.WaypointGUID} " + $"where KeepId = {keep.Info.KeepId} and X={oldX} and Y={oldY} and Z={oldZ}"; WorldMgr.Database.ExecuteNonQuery(sql); keepNpcCreature.Creature.X = plr.WorldPosition.X; keepNpcCreature.Creature.Y = plr.WorldPosition.Y; plr.SendClientMessage($"Moved keep creature to new position"); GMCommandLog log = new GMCommandLog(); log.PlayerName = plr.Name; log.AccountId = (uint)plr.Client._Account.AccountId; log.Command = "MOVE KEEP CREATURE " + selectedEntry + " " + " AT " + keepNpcCreature.Info.ZoneId + " " + plr._Value.WorldX + " " + plr._Value.WorldY; log.Date = DateTime.Now; CharMgr.Database.AddObject(log); return(true); }