/// <summary> /// Spawn an npc +Keep /// </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 NpcKeepSpawn(Player plr, ref List <string> values) { var destroId = values[0]; var orderId = values[1]; Creature_proto proto = null; Creature_proto protoOrder = null; if (destroId == "0") { plr.SendClientMessage("NPC SPAWN: Setting Destro Id -> 0"); } else { proto = CreatureService.GetCreatureProto(Convert.ToUInt32(destroId)); if (proto == null) { proto = WorldMgr.Database.SelectObject <Creature_proto>("Entry=" + destroId); if (proto != null) { plr.SendClientMessage("NPC SPAWN: Npc Entry is valid but npc stats are empty. No sniff data about this npc"); } else { plr.SendClientMessage("NPC SPAWN: Invalid npc entry(" + destroId + ")"); } return(false); } } if (orderId == "0") { plr.SendClientMessage("NPC SPAWN: Setting Order Id -> 0"); } else { protoOrder = CreatureService.GetCreatureProto(Convert.ToUInt32(orderId)); if (protoOrder == null) { protoOrder = WorldMgr.Database.SelectObject <Creature_proto>("Entry=" + orderId); if (protoOrder != null) { plr.SendClientMessage("NPC SPAWN: Npc Entry is valid but npc stats are empty. No sniff data about this npc"); } else { plr.SendClientMessage("NPC SPAWN: Invalid npc entry(" + orderId + ")"); } return(false); } } plr.UpdateWorldPosition(); //Creature_spawn spawn = new Creature_spawn { Guid = (uint)CreatureService.GenerateCreatureSpawnGUID() }; //spawn.BuildFromProto(proto); //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; //spawn.Enabled = 1; //WorldMgr.Database.AddObject(spawn); var kc = new Keep_Creature(); kc.ZoneId = plr.Zone.ZoneId; kc.DestroId = Convert.ToUInt32(destroId); kc.OrderId = Convert.ToUInt32(orderId); kc.IsPatrol = false; var keep = plr.Region.Campaign.GetClosestKeep(plr.WorldPosition, (ushort)plr.ZoneId); kc.KeepId = keep.Info.KeepId; kc.KeepLord = false; kc.X = plr._Value.WorldX; kc.Y = plr._Value.WorldY; kc.Z = plr._Value.WorldZ; kc.O = plr._Value.WorldO; kc.WaypointGUID = 0; kc.Dirty = true; WorldMgr.Database.AddObject(kc); WorldMgr.Database.ForceSave(); plr.SendClientMessage("Created keep creature"); GMCommandLog log = new GMCommandLog(); log.PlayerName = plr.Name; log.AccountId = (uint)plr.Client._Account.AccountId; log.Command = "SPAWN KEEP CREATURE " + kc.ZoneId + " " + plr._Value.WorldX + " " + plr._Value.WorldY; log.Date = DateTime.Now; CharMgr.Database.AddObject(log); return(true); }
public KeepNpcCreature(RegionMgr region, Keep_Creature info, BattleFrontKeep keep) { Region = region; Info = info; Keep = keep; }