public static void Process(ReceivablePacket packet) { // Server information. long objectId = packet.ReadLong(); CharacterDataHolder npcTemplate = NpcData.GetNpc(packet.ReadInt()); CharacterDataHolder characterData = new CharacterDataHolder(); characterData.SetX(packet.ReadFloat()); characterData.SetY(packet.ReadFloat()); characterData.SetZ(packet.ReadFloat()); characterData.SetHeading(packet.ReadFloat()); characterData.SetCurrentHp(packet.ReadLong()); // Client information. characterData.SetName(npcTemplate.GetName()); characterData.SetRace(npcTemplate.GetRace()); characterData.SetHeight(npcTemplate.GetHeight()); characterData.SetBelly(npcTemplate.GetBelly());; characterData.SetHairType(npcTemplate.GetHairType()); characterData.SetHairColor(npcTemplate.GetHairColor()); characterData.SetSkinColor(npcTemplate.GetSkinColor()); characterData.SetEyeColor(npcTemplate.GetEyeColor()); characterData.SetHeadItem(npcTemplate.GetHeadItem()); characterData.SetChestItem(npcTemplate.GetChestItem()); characterData.SetLegsItem(npcTemplate.GetLegsItem()); characterData.SetHandsItem(npcTemplate.GetHandsItem()); characterData.SetFeetItem(npcTemplate.GetFeetItem()); characterData.SetLeftHandItem(npcTemplate.GetLeftHandItem()); characterData.SetRightHandItem(npcTemplate.GetRightHandItem()); characterData.SetMaxHp(npcTemplate.GetMaxHp()); characterData.SetTargetable(npcTemplate.IsTargetable()); WorldManager.Instance.UpdateObject(objectId, characterData); }
public static void Notify(ReceivablePacket packet) { long objectId = packet.ReadLong(); CharacterDataHolder characterData = new CharacterDataHolder(); characterData.SetName(packet.ReadString()); characterData.SetRace((byte)packet.ReadByte()); characterData.SetHeight(packet.ReadFloat()); characterData.SetBelly(packet.ReadFloat()); characterData.SetHairType((byte)packet.ReadByte()); characterData.SetHairColor(packet.ReadInt()); characterData.SetSkinColor(packet.ReadInt()); characterData.SetEyeColor(packet.ReadInt()); characterData.SetHeadItem(packet.ReadInt()); characterData.SetChestItem(packet.ReadInt()); characterData.SetLegsItem(packet.ReadInt()); characterData.SetHandsItem(packet.ReadInt()); characterData.SetFeetItem(packet.ReadInt()); characterData.SetLeftHandItem(packet.ReadInt()); characterData.SetRightHandItem(packet.ReadInt()); characterData.SetX(packet.ReadFloat()); characterData.SetY(packet.ReadFloat()); characterData.SetZ(packet.ReadFloat()); characterData.SetHeading(packet.ReadFloat()); WorldManager.Instance.UpdateObject(objectId, characterData); }
public static void Notify(ReceivablePacket packet) { // Get player list size. int listSize = packet.ReadByte(); // Read the data. List <CharacterDataHolder> characterList = new List <CharacterDataHolder>(listSize); for (int i = 0; i < listSize; i++) { CharacterDataHolder characterData = new CharacterDataHolder(); characterData.SetName(packet.ReadString()); characterData.SetSlot((byte)packet.ReadByte()); characterData.SetSelected(packet.ReadByte() == 1 ? true : false); characterData.SetRace((byte)packet.ReadByte()); characterData.SetHeight(packet.ReadFloat()); characterData.SetBelly(packet.ReadFloat()); characterData.SetHairType(packet.ReadByte()); characterData.SetHairColor(packet.ReadInt()); characterData.SetSkinColor(packet.ReadInt()); characterData.SetEyeColor(packet.ReadInt()); characterData.SetHeadItem(packet.ReadInt()); characterData.SetChestItem(packet.ReadInt()); characterData.SetLegsItem(packet.ReadInt()); characterData.SetHandsItem(packet.ReadInt()); characterData.SetFeetItem(packet.ReadInt()); characterData.SetLeftHandItem(packet.ReadInt()); characterData.SetRightHandItem(packet.ReadInt()); characterData.SetX(packet.ReadFloat()); characterData.SetY(packet.ReadFloat()); characterData.SetZ(packet.ReadFloat()); characterData.SetHeading(packet.ReadFloat()); characterData.SetExperience(packet.ReadLong()); characterData.SetCurrentHp(packet.ReadLong()); characterData.SetMaxHp(packet.ReadLong()); characterData.SetCurrentMp(packet.ReadLong()); characterData.SetMaxMp(packet.ReadLong()); characterData.SetAccessLevel((byte)packet.ReadByte()); characterList.Add(characterData); } // Send the data. MainManager.Instance.SetCharacterList(characterList); // Enable player selection. CharacterSelectionManager.Instance.SetWaitingServer(false); }
private void Start() { Instance = this; TextAsset data = Resources.Load("data/NpcData") as TextAsset; string[] lines = Regex.Split(data.text, "\r\n|\n\r|\n|\r"); for (int i = 0; i < lines.Length; i++) { string line = lines[i]; if (line.StartsWith("#")) { continue; } string[] values = line.Split(';'); if (values.Length < 18) { continue; } CharacterDataHolder holder = new CharacterDataHolder(); holder.SetName(values[1]); holder.SetRace(byte.Parse(values[2])); holder.SetHeight(float.Parse(values[3], CultureInfo.InvariantCulture)); holder.SetBelly(float.Parse(values[4], CultureInfo.InvariantCulture)); holder.SetHairType(int.Parse(values[5])); holder.SetHairColor(int.Parse(values[6])); holder.SetSkinColor(int.Parse(values[7])); holder.SetEyeColor(int.Parse(values[8])); holder.SetHeadItem(int.Parse(values[9])); holder.SetChestItem(int.Parse(values[10])); holder.SetHandsItem(int.Parse(values[11])); holder.SetLegsItem(int.Parse(values[12])); holder.SetFeetItem(int.Parse(values[13])); holder.SetRightHandItem(int.Parse(values[14])); holder.SetLeftHandItem(int.Parse(values[15])); holder.SetMaxHp(int.Parse(values[16])); holder.SetTargetable(bool.Parse(values[17])); NPCS.Add(int.Parse(values[0]), holder); } }
public void BellyChange(float val) { dna["belly"].Set(val); avatar.BuildCharacter(); dataHolder.SetBelly(val); }
private static readonly string VISIBLE_ITEMS_QUERY = "SELECT * FROM character_items WHERE owner=@owner AND slot_id>'0' AND slot_id<'8' ORDER BY slot_id ASC"; // Visible equipment slots are 1 to 7. public CharacterSelectionInfoResult(string accountName) { // Local data. List <CharacterDataHolder> characterList = new List <CharacterDataHolder>(); // Get data from database. try { MySqlConnection con = DatabaseManager.GetConnection(); MySqlCommand cmd = new MySqlCommand(CHARACTER_QUERY, con); cmd.Parameters.AddWithValue("account", accountName); MySqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { CharacterDataHolder characterData = new CharacterDataHolder(); string name = reader.GetString("name"); characterData.SetName(name); characterData.SetSlot((byte)reader.GetInt16("slot")); // TODO: Remove cast? characterData.SetSelected(reader.GetBoolean("selected")); characterData.SetRace((byte)reader.GetInt16("race")); // TODO: Remove cast? characterData.SetHeight(reader.GetFloat("height")); characterData.SetBelly(reader.GetFloat("belly")); characterData.SetHairType((byte)reader.GetInt16("hair_type")); // TODO: Remove cast? characterData.SetHairColor(reader.GetInt32("hair_color")); characterData.SetSkinColor(reader.GetInt32("skin_color")); characterData.SetEyeColor(reader.GetInt32("eye_color")); characterData.SetX(reader.GetFloat("x")); characterData.SetY(reader.GetFloat("y")); characterData.SetZ(reader.GetFloat("z")); characterData.SetHeading(reader.GetFloat("heading")); characterData.SetExperience(reader.GetInt64("experience")); characterData.SetHp(reader.GetInt64("hp")); characterData.SetMp(reader.GetInt64("mp")); characterData.SetAccessLevel((byte)reader.GetInt16("access_level")); // TODO: Remove cast? // Also get items for this character. try { MySqlConnection con2 = DatabaseManager.GetConnection(); MySqlCommand cmd2 = new MySqlCommand(VISIBLE_ITEMS_QUERY, con2); cmd2.Parameters.AddWithValue("owner", name); MySqlDataReader reader2 = cmd2.ExecuteReader(); while (reader2.Read()) { int slotId = reader2.GetInt32("slot_id"); int itemId = reader2.GetInt32("item_id"); switch (slotId) { case 1: characterData.SetHeadItem(itemId); break; case 2: characterData.SetChestItem(itemId); break; case 3: characterData.SetLegsItem(itemId); break; case 4: characterData.SetHandsItem(itemId); break; case 5: characterData.SetFeetItem(itemId); break; case 6: characterData.SetLeftHandItem(itemId); break; case 7: characterData.SetRightHandItem(itemId); break; } } con2.Close(); } catch (Exception e) { LogManager.Log(e.ToString()); } // Add gathered data to character list. characterList.Add(characterData); } con.Close(); } catch (Exception e) { LogManager.Log(e.ToString()); } // Send the data. WriteShort(2); // Packet id. WriteByte(characterList.Count); foreach (CharacterDataHolder characterData in characterList) { WriteString(characterData.GetName()); WriteByte(characterData.GetSlot()); WriteByte(characterData.IsSelected() ? 1 : 0); WriteByte(characterData.GetRace()); WriteFloat(characterData.GetHeight()); WriteFloat(characterData.GetBelly()); WriteByte(characterData.GetHairType()); WriteInt(characterData.GetHairColor()); WriteInt(characterData.GetSkinColor()); WriteInt(characterData.GetEyeColor()); WriteInt(characterData.GetHeadItem()); WriteInt(characterData.GetChestItem()); WriteInt(characterData.GetLegsItem()); WriteInt(characterData.GetHandsItem()); WriteInt(characterData.GetFeetItem()); WriteInt(characterData.GetLeftHandItem()); WriteInt(characterData.GetRightHandItem()); WriteFloat(characterData.GetX()); WriteFloat(characterData.GetY()); WriteFloat(characterData.GetZ()); WriteFloat(characterData.GetHeading()); WriteLong(characterData.GetExperience()); WriteLong(characterData.GetHp()); WriteLong(characterData.GetMp()); WriteByte(characterData.GetAccessLevel()); } }