/// <summary> /// Spawns a Tamer /// </summary> /// <param name="Tamer"></param> public SpawnPlayer(Character Tamer) { packet.Type(1006); packet.WriteShort(259); packet.WriteByte(0); packet.WriteInt(Tamer.Location.PosX); packet.WriteInt(Tamer.Location.PosY); packet.WriteUInt(Tamer.intHandle); packet.WriteInt(Tamer.Location.PosX); packet.WriteInt(Tamer.Location.PosY); packet.WriteString(Tamer.Name); packet.WriteByte((byte)Tamer.Level); packet.WriteUInt(0); packet.WriteShort((short)Tamer.MS); packet.WriteByte(0xff); for (int i = 0; i < 9; i++) packet.WriteBytes(Tamer.Equipment.ToArray()); packet.WriteInt(0); packet.WriteInt(0); packet.WriteShort(Tamer.DigimonHandle); packet.WriteInt(0); packet.WriteInt(0); }
public UpdateStats(Character Tamer, Digimon Partner, byte uByte) { packet.Type(1043); packet.WriteShort((short)Tamer.MaxHP); packet.WriteShort((short)Tamer.MaxDS); packet.WriteShort((short)Tamer.HP); packet.WriteShort((short)Tamer.DS); packet.WriteShort((short)Tamer.AT); packet.WriteShort((short)Tamer.DE); packet.WriteByte(uByte); packet.WriteShort((short)Tamer.MS); packet.WriteShort(Partner.Stats.MaxHP); packet.WriteShort(Partner.Stats.MaxDS); packet.WriteShort(Partner.Stats.HP); packet.WriteShort(Partner.Stats.DS); packet.WriteShort(Partner.Stats.Intimacy); packet.WriteShort(Partner.Stats.AT); packet.WriteShort(Partner.Stats.DE); packet.WriteShort(Partner.Stats.CR); packet.WriteShort(Partner.Stats.AS); packet.WriteShort(Partner.Stats.EV); packet.WriteShort(Partner.Stats.HT); packet.WriteShort(8000); }
public static void MakeHandles(Character Tamer, uint time_t) { Tamer.intHandle = (uint)(Tamer.ProperModel + Rand.Next(1,255)); for (int i = 0; i < Tamer.DigimonList.Length; i++) { if (Tamer.DigimonList[i] == null) continue; Digimon mon = Tamer.DigimonList[i]; mon.Model = GetModel(mon.ProperModel()); } Tamer.DigimonHandle = Tamer.Partner.Handle; }
/// <summary> /// Found with ChatType Unknown /// </summary> /// <param name="chatType"></param> /// <param name="message"></param> public BaseChat(ChatType chatType, Character Speaker, string message) { packet.Type(1006); packet.WriteShort((short)chatType); packet.WriteByte(0); packet.WriteShort(Speaker.TamerHandle); packet.WriteInt(Speaker.Location.PosX); packet.WriteInt(Speaker.Location.PosY); packet.WriteShort(267); //Another Chattype packet.WriteString(Speaker.Name); packet.WriteString(message); packet.WriteByte(0); }
public SpawnPlayer(Character Tamer, Digimon Partner) { packet.Type(1006); packet.WriteShort(513); packet.WriteByte(0); packet.WriteInt(Partner.Location.PosX); packet.WriteInt(Partner.Location.PosY); //Start Tamer Structure packet.WriteUInt(Partner.Model); packet.WriteInt(Partner.Location.PosX); packet.WriteInt(Partner.Location.PosY); packet.WriteString(Partner.Name); packet.WriteShort(Partner.Size); packet.WriteByte((byte)Partner.Level); packet.WriteUInt(Partner.Model); //Related to riding mode packet.WriteShort(Partner.Stats.MS); packet.WriteShort(Tamer.TamerHandle); packet.WriteByte(0xff); packet.WriteInt(0); packet.WriteInt(Tamer.Location.PosX); packet.WriteInt(Tamer.Location.PosY); packet.WriteUInt(Tamer.intHandle); packet.WriteInt(Tamer.Location.PosX); packet.WriteInt(Tamer.Location.PosY); packet.WriteString(Tamer.Name); packet.WriteByte((byte)Tamer.Level); packet.WriteUInt(Tamer.intHandle); packet.WriteShort((short)Tamer.MS); packet.WriteByte(0xff); for (int i = 0; i < 9; i++) packet.WriteBytes(Tamer.Equipment[i].ToArray()); packet.WriteInt(0); packet.WriteInt(0); packet.WriteShort(Tamer.DigimonHandle); packet.WriteByte(0); packet.WriteShort(0); packet.WriteShort(0); packet.WriteShort(0); packet.WriteByte(0); //packet.WriteShort(Tamer.DigimonHandle); //packet.WriteInt(Partner.Location.PosX); //packet.WriteInt(Partner.Location.PosY); //packet.WriteByte(0); }
public MovePlayer(Character Tamer) { Digimon Partner = Tamer.Partner; packet.Type(0x3ee); packet.WriteShort(0x205); packet.WriteByte(0); packet.WriteShort(Tamer.TamerHandle); packet.WriteInt(Tamer.Location.PosX); packet.WriteInt(Tamer.Location.PosY); packet.WriteShort(Tamer.DigimonHandle); packet.WriteInt(Partner.Location.PosX); packet.WriteInt(Partner.Location.PosY); packet.WriteByte(0); }
public DigimonStats Default(Character Tamer, int Sync, int Size) { DigimonStats Stats = new DigimonStats(); Stats.MaxHP = (short)(Math.Min(Math.Floor((decimal)HP * ((ushort)Size / 10000)) + Math.Floor((decimal)Tamer.HP * (Sync / 100)), short.MaxValue)); Stats.HP = (short)(Math.Min(Math.Floor((decimal)HP * ((ushort)Size / 10000)) + Math.Floor((decimal)Tamer.HP * (Sync / 100)), short.MaxValue)); Stats.MaxDS = (short)(Math.Min(Math.Floor((decimal)DS * ((ushort)Size / 10000)) + Math.Floor((decimal)Tamer.DS * (Sync / 100)), short.MaxValue)); Stats.DS = (short)(Math.Max(Math.Floor((decimal)DS * ((ushort)Size / 10000)) + Math.Floor((decimal)Tamer.DS * (Sync / 100)), short.MaxValue)); Stats.DE = (short)(Math.Min(Math.Floor((decimal)DE * ((ushort)Size / 10000)) + Math.Floor((decimal)Tamer.DE * (Sync / 100)), short.MaxValue)); Stats.MS = (short)(Math.Min(Math.Floor((decimal)MS * ((ushort)Size / 10000)) + Math.Floor((decimal)Tamer.MS * (Sync / 100)), short.MaxValue)); Stats.CR = (short)(Math.Min(Math.Floor((decimal)CR * ((ushort)Size / 10000)), short.MaxValue)); Stats.AT = (short)(Math.Min(Math.Floor((decimal)AT * ((ushort)Size / 10000)) + Math.Floor((decimal)Tamer.AT * (Sync / 100)), short.MaxValue)); Stats.EV = EV; Stats.uStat = uStat; Stats.HT = HT; Stats.Intimacy = (short)Sync; return Stats; }
public static void LoadTamer(Client client) { int lastChar = -1, charId = -1; try { using (MySqlConnection con = Connect()) using (MySqlCommand cmd = new MySqlCommand("SELECT * FROM `acct` WHERE `accountId` = @acct", con)) { cmd.Parameters.AddWithValue("@acct", client.AccountID); using (MySqlDataReader dr = cmd.ExecuteReader(System.Data.CommandBehavior.SingleRow)) { if (dr.HasRows && dr.Read()) { lastChar = (int)dr["lastChar"]; if (lastChar != -1) { charId = (int)dr[string.Format("char{0}", lastChar + 1)]; } } } } if (lastChar != -1) { using (MySqlConnection con = Connect()) using (MySqlCommand cmd = new MySqlCommand("SELECT * FROM `chars` WHERE `characterId` = @char", Connect())) { cmd.Parameters.AddWithValue("@char", charId); using (MySqlDataReader dr = cmd.ExecuteReader(System.Data.CommandBehavior.SingleRow)) { if (dr.HasRows && dr.Read()) { Character tamer = new Character(); tamer.CharacterId = Convert.ToUInt32((int)dr["characterId"]); tamer.AccountId = Convert.ToUInt32((int)dr["accountId"]); tamer.Model = (CharacterModel)(int)dr["charModel"]; tamer.Name = (string)dr["charName"]; tamer.Level = (int)dr["charLv"]; tamer.InventorySize = (int)dr["inventoryLimit"]; tamer.StorageSize = (int)dr["storageLimit"]; tamer.ArchiveSize = (int)dr["archiveLimit"]; tamer.Location = new Helpers.Position((int)dr["map"], (int)dr["x"], (int)dr["y"]); tamer.MaxHP = (int)dr["maxHP"]; tamer.MaxDS = (int)dr["maxDS"]; tamer.HP = (int)dr["HP"]; tamer.DS = (int)dr["DS"]; tamer.AT = (int)dr["AT"]; tamer.DE = (int)dr["DE"]; tamer.EXP = (int)dr["experience"]; tamer.MS = (int)dr["MS"]; tamer.Fatigue = (int)dr["Fatigue"]; tamer.Starter = (int)dr["starter"]; tamer.Money = (int)dr["money"]; //Incubator tamer.Incubator = (int)dr["incubator"]; tamer.IncubatorLevel = (int)dr["incubatorLevel"]; if (tamer.Incubator == 0) tamer.IncubatorLevel = 0; try { tamer.Inventory = ItemList.Deserialize((byte[])dr["inventory"]); } catch { tamer.Inventory = new ItemList(63); } try { tamer.Equipment = ItemList.Deserialize((byte[])dr["equipment"]); } catch { tamer.Equipment = new ItemList(27); } try { tamer.Storage = ItemList.Deserialize((byte[])dr["storage"]); } catch { tamer.Storage = new ItemList(70); } try { tamer.Quests = QuestList.Deserialize((byte[])dr["quests"]); } catch { tamer.Quests = new QuestList(); }; try { BinaryFormatter f = new BinaryFormatter(); using (MemoryStream m = new MemoryStream((byte[])dr["archive"])) tamer.ArchivedDigimon = (uint[])f.Deserialize(m); } catch { tamer.ArchivedDigimon = new uint[40]; } Digimon partner = LoadDigimon((uint)(int)dr["partner"]); tamer.Partner = partner; tamer.Partner.Location = tamer.Location.Clone(); ; if (dr["mercenary1"] != DBNull.Value) { int mercId = (int)dr["mercenary1"]; Digimon merc = LoadDigimon((uint)mercId); tamer.DigimonList[1] = merc; } if (dr["mercenary2"] != DBNull.Value) { int mercId = (int)dr["mercenary2"]; Digimon merc = LoadDigimon((uint)mercId); tamer.DigimonList[2] = merc; } client.Tamer = tamer; } } } } } catch (Exception e) { Console.WriteLine(e); } }
public static List<Character> GetCharacters(uint AcctId) { List<Character> chars = new List<Character>(); try { using (MySqlCommand cmd = new MySqlCommand( "SELECT * FROM `chars` WHERE `accountId` = @id" , Connect())) { cmd.Parameters.AddWithValue("@id", AcctId); using(MySqlDataReader dr = cmd.ExecuteReader()) { if (dr.HasRows) { while (dr.Read()) { Character Tamer = new Character(); Tamer.AccountId = AcctId; Tamer.CharacterId = Convert.ToUInt32((int)dr["characterId"]); ; Tamer.Model = (CharacterModel)(int)dr["charModel"]; Tamer.Name = (string)dr["charName"]; Tamer.Level = (int)dr["charLv"]; Tamer.Location = new Helpers.Position((short)(int)dr["map"], (int)dr["x"], (int)dr["y"]); Tamer.Partner = GetDigimon((uint)(int)dr["partner"]); if (dr["mercenary1"] != DBNull.Value) { int mercId = (int)dr["mercenary1"]; Digimon merc = GetDigimon((uint)mercId); Tamer.DigimonList[1] = merc; } if (dr["mercenary2"] != DBNull.Value) { int mercId = (int)dr["mercenary2"]; Digimon merc = GetDigimon((uint)mercId); Tamer.DigimonList[2] = merc; } try { BinaryFormatter f = new BinaryFormatter(); using (MemoryStream m = new MemoryStream((byte[])dr["archive"])) { Tamer.ArchivedDigimon = (uint[])f.Deserialize(m); } for (int i = 0; i < Tamer.ArchivedDigimon.Length; i++) { if (Tamer.ArchivedDigimon[i] != 0) { Digimon digi = GetDigimon(Tamer.ArchivedDigimon[i]); ResetModel(digi.DigiId, digi.Species); } } } catch { Tamer.ArchivedDigimon = new uint[40]; } try { Tamer.Equipment = ItemList.Deserialize((byte[])dr["equipment"]); } catch { Tamer.Equipment = new ItemList(27); } chars.Add(Tamer); } } } } } catch (Exception e) { Console.WriteLine("Error: GetCharacters\n{0}", e); } return chars; }
public CharInfo(Character Tamer) { packet.Type(1003); packet.WriteInt(Tamer.Location.PosX); //X packet.WriteInt(Tamer.Location.PosY); //Y packet.WriteUInt(Tamer.intHandle); packet.WriteString(Tamer.Name); packet.WriteInt(Tamer.Money); packet.WriteInt(0); packet.WriteShort((short)Tamer.InventorySize); packet.WriteShort((short)Tamer.StorageSize); packet.WriteInt(Tamer.EXP); packet.WriteShort((short)Tamer.Level); packet.WriteShort((short)Tamer.MaxHP); packet.WriteShort((short)Tamer.MaxDS); packet.WriteShort((short)Tamer.HP); packet.WriteShort((short)Tamer.DS); packet.WriteShort((short)Tamer.Fatigue); packet.WriteShort((short)Tamer.AT); packet.WriteShort((short)Tamer.DE); packet.WriteShort((short)Tamer.MS); packet.WriteBytes(Tamer.Equipment.ToArray()); packet.WriteBytes(Tamer.Inventory.ToArray()); packet.WriteBytes(Tamer.Storage.ToArray()); packet.WriteBytes(new byte[384]); //Unknown. packet.WriteBytes(Tamer.Quests.ToArray()); packet.WriteInt(Tamer.Incubator); packet.WriteInt(Tamer.IncubatorLevel); Digimon(Tamer.Partner); int Mons = 1; for (int i = 1; i < 3; i++) { if (Tamer.DigimonList[i] != null) { Mons++; packet.WriteByte((byte)i); Digimon(Tamer.DigimonList[i]); } } packet.WriteByte(99); packet.WriteInt(1); //Channel packet.WriteShort(128); packet.WriteBytes(new byte[194]); packet.WriteByte((byte)Mons); packet.WriteInt(0); packet.WriteInt(0); packet.WriteByte(99); packet.WriteBytes(new byte[130]); packet.WriteByte(0); packet.WriteBytes(new byte[20]); packet.WriteInt(1); packet.WriteInt(0); packet.WriteShort(18000); packet.WriteShort(0); packet.WriteShort(7200); packet.WriteShort(0); packet.WriteShort(1); packet.WriteShort(0); packet.WriteShort(0); packet.WriteShort(18000); packet.WriteShort(0); }