public List <Actor> LoadZoneNpc(uint zoneId) { string npcListPath = @"" + zoneId.ToString("X"); string fileNamePath = npcListPath + @".npc.xml"; XmlDocument npcFile = new XmlDocument(); string file = GetResourceXmlResource(fileNamePath); List <Actor> zoneNpcs = new List <Actor>(); if (file != "") { try { //get game data tables with actors data DataTable actorsGraphics = GameData.Instance.GetGameData("actorclass_graphic"); DataTable actorsNameIds = GameData.Instance.GetGameData("actorclass"); //prepare xml nodes npcFile.LoadXml(file); var PopulaceStandardList = npcFile.SelectNodes("npc/PopulaceStandard"); //each npc node in xml foreach (XmlNode node in PopulaceStandardList) { //XmlNode node = objNode.SelectSingleNode("PopulaceStandard"); uint classId = Convert.ToUInt32(node.SelectSingleNode("classId").InnerText); uint state = node.SelectSingleNode("state") != null?Convert.ToUInt32(node.SelectSingleNode("state").InnerText) : 0; //TODO: fix this as it is 2 bytes. so far it's alaways 0 so it's ok. ushort animation = node.SelectSingleNode("animation") != null?Convert.ToUInt16(node.SelectSingleNode("animation").InnerText) : (ushort)0; int questIcon = node.SelectSingleNode("questIcon") != null?Convert.ToInt32(node.SelectSingleNode("questIcon").InnerText) : -1; //get table lines with npc info DataRow actorGraphics = actorsGraphics.Select("id = '" + classId + "'")[0]; DataRow actorNameId = actorsNameIds.Select("id = '" + classId + "'")[0]; //Spawn position XmlNode positionNode = node.SelectSingleNode("position"); Position position = new Position { ZoneId = zoneId, X = Convert.ToSingle(positionNode.Attributes["x"].Value), Y = Convert.ToSingle(positionNode.Attributes["y"].Value), Z = Convert.ToSingle(positionNode.Attributes["z"].Value), R = Convert.ToSingle(positionNode.Attributes["r"].Value) }; Face face = new Face { Characteristics = Convert.ToByte(actorGraphics.ItemArray[7]), CharacteristicsColor = Convert.ToByte(actorGraphics.ItemArray[8]), Type = Convert.ToByte(actorGraphics.ItemArray[6]), Ears = Convert.ToByte(actorGraphics.ItemArray[15]), Mouth = Convert.ToByte(actorGraphics.ItemArray[14]), Features = Convert.ToByte(actorGraphics.ItemArray[13]), Nose = Convert.ToByte(actorGraphics.ItemArray[12]), EyeShape = Convert.ToByte(actorGraphics.ItemArray[11]), IrisSize = Convert.ToByte(actorGraphics.ItemArray[10]), EyeBrows = Convert.ToByte(actorGraphics.ItemArray[9]) }; Appearance appearance = new Appearance { BaseModel = Convert.ToUInt32(actorGraphics.ItemArray[1]), Size = Convert.ToUInt32(actorGraphics.ItemArray[2]), MainWeapon = Convert.ToUInt32(actorGraphics.ItemArray[20]), SecondaryWeapon = Convert.ToUInt32(actorGraphics.ItemArray[21]), SPMainWeapon = Convert.ToUInt32(actorGraphics.ItemArray[22]), SPSecondaryWeapon = Convert.ToUInt32(actorGraphics.ItemArray[23]), Throwing = Convert.ToUInt32(actorGraphics.ItemArray[24]), Pack = Convert.ToUInt32(actorGraphics.ItemArray[25]), Pouch = Convert.ToUInt32(actorGraphics.ItemArray[26]), Head = Convert.ToUInt32(actorGraphics.ItemArray[27]), Body = Convert.ToUInt32(actorGraphics.ItemArray[28]), Legs = Convert.ToUInt32(actorGraphics.ItemArray[29]), Hands = Convert.ToUInt32(actorGraphics.ItemArray[30]), Feet = Convert.ToUInt32(actorGraphics.ItemArray[31]), Waist = Convert.ToUInt32(actorGraphics.ItemArray[32]), Neck = Convert.ToUInt32(actorGraphics.ItemArray[33]), RightEar = Convert.ToUInt32(actorGraphics.ItemArray[34]), LeftEar = Convert.ToUInt32(actorGraphics.ItemArray[35]), RightIndex = Convert.ToUInt32(actorGraphics.ItemArray[36]), LeftIndex = Convert.ToUInt32(actorGraphics.ItemArray[37]), RightFinger = Convert.ToUInt32(actorGraphics.ItemArray[38]), LeftFinger = Convert.ToUInt32(actorGraphics.ItemArray[39]) }; SubState subState = new SubState { MotionPack = animation }; //Npc obj PopulaceStandard npc = new PopulaceStandard { ClassId = classId, NameId = Convert.ToInt32(actorNameId.ItemArray[1]), HairStyle = Convert.ToUInt16(actorGraphics.ItemArray[3]), HairHighlightColor = Convert.ToUInt16(actorGraphics.ItemArray[4]), HairColor = Convert.ToUInt16(actorGraphics.ItemArray[16]), SkinColor = Convert.ToUInt16(actorGraphics.ItemArray[17]), EyeColor = Convert.ToUInt16(actorGraphics.ItemArray[18]), Appearance = appearance, Face = face, Position = position, QuestIcon = questIcon, SubState = subState }; zoneNpcs.Add(npc); } } catch (Exception e) { _log.Warning(e.Message); } } return(zoneNpcs); }
public void SetSubState(Socket sender) => SendPacket(sender, ServerOpcode.SetSubState, SubState.ToBytes());