/// <summary> /// Spawn a PQ NPC <object id> <objective id> <type 1 = 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 PqSpawn(Player plr, ref List <string> values) { int entry = GetInt(ref values); int objective = GetInt(ref values); int type = GetInt(ref values); plr.UpdateWorldPosition(); PQuest_Spawn spawn = 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 spawn.pquest_spawns_ID = Guid.NewGuid().ToString(); spawn.Entry = (uint)entry; spawn.Objective = (uint)objective; spawn.Type = (byte)type; spawn.WorldO = plr._Value.WorldO; spawn.WorldY = plr._Value.WorldY; spawn.WorldZ = plr._Value.WorldZ; spawn.WorldX = plr._Value.WorldX; spawn.ZoneId = plr.Zone.ZoneId; WorldMgr.Database.AddObject(spawn); return(true); }
/// <summary> /// This method allow setting level for selected NPC. /// Works for normal NPC and PQ NPCs :) /// <param name="plr">Player that initiated the command</param> /// <param name="values">List of command arguments (after command name)</param> /// </summary> public static bool NpcLevel(Player plr, ref List <string> values) { Object target = plr.CbtInterface.GetCurrentTarget(); if (target == null) { return(false); } int nPCLevel = GetInt(ref values); Creature creature = target.GetCreature(); creature.Spawn.Level = (byte)nPCLevel; if (creature.PQSpawnId == null) { WorldMgr.Database.SaveObject(creature.Spawn); } else { PQuest_Spawn pQSpawn = WorldMgr.Database.SelectObject <PQuest_Spawn>("pquest_spawns_ID='" + creature.PQSpawnId + "'"); pQSpawn.Level = (byte)nPCLevel; WorldMgr.Database.SaveObject(pQSpawn); } creature.RezUnit(); return(true); }
public static bool NpcPermaAnimScript(Player plr, ref List <string> values) { Object target = plr.CbtInterface.GetCurrentTarget(); if (target == null) { return(false); } int animID = GetInt(ref values); var Out = new PacketOut((byte)Opcodes.F_ANIMATION); Out.WriteUInt16(target.Oid); Out.WriteByte(0); Out.WriteByte(0); Out.WriteUInt16((ushort)animID); plr.DispatchPacket(Out, true); Creature creature = target.GetCreature(); creature.Spawn.Emote = (byte)animID; if (creature.PQSpawnId == null) { WorldMgr.Database.SaveObject(creature.Spawn); } else { PQuest_Spawn pQSpawn = WorldMgr.Database.SelectObject <PQuest_Spawn>("pquest_spawns_ID='" + creature.PQSpawnId + "'"); pQSpawn.Emote = (byte)animID; WorldMgr.Database.SaveObject(pQSpawn); } 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 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); }