public static void AddNpc(string[] args, WorldClass session) { var pChar = session.Character; int creatureId = CommandParser.Read <int>(args, 1); Creature creature = DataMgr.FindCreature(creatureId); if (creature != null) { ChatMessageValues chatMessage = new ChatMessageValues(0, ""); CreatureSpawn spawn = new CreatureSpawn() { Guid = CreatureSpawn.GetLastGuid() + 1, Id = creatureId, Creature = creature, Position = pChar.Position, Map = pChar.Map }; if (spawn.AddToDB()) { chatMessage.Message = "Spawn successfully added."; spawn.AddToWorld(); ChatHandler.SendMessage(ref session, chatMessage); } else { chatMessage.Message = "Spawn can't be added."; ChatHandler.SendMessage(ref session, chatMessage); } } }
public static void HandleQueryCreature(ref PacketReader packet, WorldClass session) { var id = packet.Read <int>(); PacketWriter queryCreatureResponse = new PacketWriter(ServerMessage.QueryCreatureResponse); BitPack BitPack = new BitPack(queryCreatureResponse); queryCreatureResponse.WriteInt32(id); var creature = DataMgr.FindCreature(id); var hasData = (creature != null); BitPack.Write(hasData); if (hasData) { var stats = creature.Stats; BitPack.Write(0, 11); BitPack.Write(stats.QuestItemId.Count, 22); BitPack.Write(stats.IconName.Length + 1, 6); BitPack.Write(stats.RacialLeader); for (int i = 0; i < 8; i++) { if (i == 0) { BitPack.Write(stats.Name.Length + 1, 11); } else { BitPack.Write(0, 11); } } BitPack.Write(stats.SubName.Length != 0 ? stats.SubName.Length + 1 : 0, 11); BitPack.Flush(); queryCreatureResponse.WriteInt32(stats.Family); queryCreatureResponse.WriteInt32(stats.ExpansionRequired); queryCreatureResponse.WriteInt32(stats.Type); if (stats.SubName != "") { queryCreatureResponse.WriteCString(stats.SubName); } queryCreatureResponse.WriteInt32(stats.DisplayInfoId[0]); queryCreatureResponse.WriteInt32(stats.DisplayInfoId[3]); foreach (var v in stats.QuestItemId) { queryCreatureResponse.WriteInt32(v); } queryCreatureResponse.WriteCString(stats.Name); if (stats.IconName != "") { queryCreatureResponse.WriteCString(stats.IconName); } foreach (var v in stats.Flag) { queryCreatureResponse.WriteInt32(v); } queryCreatureResponse.WriteFloat(stats.HealthModifier); queryCreatureResponse.WriteInt32(stats.Rank); queryCreatureResponse.WriteInt32(stats.QuestKillNpcId[0]); queryCreatureResponse.WriteInt32(stats.QuestKillNpcId[1]); queryCreatureResponse.WriteFloat(stats.PowerModifier); queryCreatureResponse.WriteInt32(stats.MovementInfoId); queryCreatureResponse.WriteInt32(stats.DisplayInfoId[1]); queryCreatureResponse.WriteInt32(stats.DisplayInfoId[2]); } else { Log.Message(LogType.Debug, "Creature (Id: {0}) not found.", id); } session.Send(ref queryCreatureResponse); }