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); }
private void Digimon(Digimon Mon) { packet.WriteUInt(Mon.Model); packet.WriteString(Mon.Name); packet.WriteShort((short)Mon.Size); packet.WriteInt(Mon.EXP); packet.WriteShort((short)Mon.Level); packet.WriteBytes(Mon.Stats.ToArray()); packet.WriteShort(600); //Unknown packet.WriteShort(10); //Unknown packet.WriteInt(Mon.Species); packet.WriteByte((byte)Mon.Forms.Count); for (int i = 0; i < Mon.Forms.Count; i++) { EvolvedForm form = Mon.Forms[i]; form.uByte5 = 0x1d; form.uByte4 = 0x34; form.b128 = 129; form.b0 = 0x95; form.Skill1 = 8; form.Skill2 = 8; packet.WriteBytes(form.ToArray()); } }
/// <summary> /// Switch Mon1 to Mon2 /// </summary> /// <param name="Mon1"></param> /// <param name="Mon2"></param> public DigimonSwitch(short DigimonHandle,byte slot, Digimon Mon1, Digimon Mon2) { packet.Type(1041); packet.WriteShort(DigimonHandle); packet.WriteInt(Mon1.Species); packet.WriteByte(slot); packet.WriteInt(Mon2.Species); packet.WriteByte((byte)Mon2.Level); packet.WriteString(Mon2.Name); packet.WriteShort(Mon2.Size); }
private void Monitor() { while (true) { lock (Tamers) { List <Client> ToRemove = new List <Client>(); foreach (Client Client in Tamers) { if (Client.Tamer.Location.Map != MapId || !Client.m_socket.Connected) { ToRemove.Add(Client); } else { Character Tamer = Client.Tamer; Digimon Partner = Tamer.Partner; for (int i = 0; i < Tamer.DigimonList.Length; i++) { //Check if in battle? if (Tamer.DigimonList[i] == null) { continue; } Digimon digimon = Tamer.DigimonList[i]; //Console.WriteLine("Recovering {0}...", digimon.Name); digimon.Stats.Recover(); } try { Client.Send(new Packets.Game.Status(Tamer.DigimonHandle, Partner.Stats)); } catch { ToRemove.Add(Client); } } } foreach (Client Client in ToRemove) { Tamers.Remove(Client); this.Send(new DespawnPlayer(Client.Tamer.TamerHandle, Client.Tamer.DigimonHandle)); } } Thread.Sleep(30 * 1000); //Sleep 30s } }
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 static Digimon LoadDigimon(uint DigiId) { Digimon digimon = null; try { using (MySqlConnection con = Connect()) { using (MySqlCommand cmd = new MySqlCommand("SELECT * FROM `digimon` WHERE `digimonId` = @id", con)) { cmd.Parameters.AddWithValue("@id", DigiId); using (MySqlDataReader dr = cmd.ExecuteReader()) { if (dr.HasRows) { if (dr.Read()) { digimon = new Digimon(); digimon.DigiId = DigiId; digimon.CharacterId = (int)dr["characterId"]; digimon.Name = (string)dr["digiName"]; digimon.Level = (int)dr["digiLv"]; digimon.Species = (int)dr["digiType"]; digimon.CurrentForm = (int)dr["digiModel"]; digimon.EXP = (int)dr["exp"]; digimon.Size = (short)(int)dr["digiSize"]; digimon.Scale = (int)dr["digiScale"]; digimon.Stats = new DigimonStats(); digimon.Stats.MaxHP = (short)(int)dr["maxHP"]; digimon.Stats.MaxDS = (short)(int)dr["maxDS"]; digimon.Stats.HP = (short)(int)dr["HP"]; digimon.Stats.DS = (short)(int)dr["DS"]; digimon.Stats.DE = (short)(int)dr["DE"]; digimon.Stats.AT = (short)(int)dr["AT"]; digimon.Stats.Intimacy = (short)(int)dr["sync"]; digimon.Stats.HT = (short)(int)dr["HT"]; digimon.Stats.EV = (short)(int)dr["EV"]; digimon.Stats.CR = (short)(int)dr["CR"]; digimon.Stats.MS = (short)(int)dr["MS"]; digimon.Stats.AS = (short)(int)dr["AS"]; BinaryFormatter bf = new BinaryFormatter(); int forms = EvolutionDB.EvolutionList[digimon.Species].Digivolutions; try { using (MemoryStream m = new MemoryStream((byte[])dr["forms"])) digimon.Forms = (EvolvedForms)bf.Deserialize(m); } catch { } if (digimon.Forms.Count != forms) digimon.Forms = new EvolvedForms(forms); } } } } } } catch (Exception e) { Console.WriteLine("Error: GetDigimon({1})\n{0}", e, DigiId); } return digimon; }
public static void SaveDigimon(Digimon digimon) { try { using (MySqlConnection connection = Connect()) { Query qry = new Query(Query.QueryMode.UPDATE, "digimon", new Tuple<string, object>("digimonId", digimon.DigiId)); qry.Add("digiModel", digimon.CurrentForm); qry.Add("digiName", digimon.Name); qry.Add("digiLv", digimon.Level); qry.Add("exp", digimon.EXP); qry.Add("digiSize", digimon.Size); qry.Add("maxHP", digimon.Stats.MaxHP); qry.Add("maxDS", digimon.Stats.MaxDS); qry.Add("HP", digimon.Stats.HP); qry.Add("DS", digimon.Stats.DS); qry.Add("AT", digimon.Stats.AT); qry.Add("DE", digimon.Stats.DE); qry.Add("sync", digimon.Stats.Intimacy); qry.Add("HT", digimon.Stats.HT); qry.Add("EV", digimon.Stats.EV); qry.Add("CR", digimon.Stats.CR); qry.Add("MS", digimon.Stats.MS); qry.Add("forms", digimon.Forms.Serialize()); using (MySqlCommand cmd = qry.GetCommand(connection)) { cmd.ExecuteNonQuery(); } } } catch (Exception e) { Console.WriteLine("Error: GetDigimon({1})\n{0}", e, digimon); } }
public static Digimon GetDigimon(uint DigiId) { Digimon digimon = null; try { using (MySqlConnection mysql = Connect()) using (MySqlCommand cmd = new MySqlCommand( "SELECT * FROM `digimon` WHERE `digimonId` = @id" , mysql)) { cmd.Parameters.AddWithValue("@id", DigiId); using (MySqlDataReader read = cmd.ExecuteReader()) { if (read.HasRows) { if (read.Read()) { digimon = new Digimon(); digimon.DigiId = DigiId; digimon.CharacterId = (int)read["characterId"]; digimon.Name = (string)read["digiName"]; digimon.Level = (int)read["digiLv"]; digimon.Species = (int)read["digiType"]; digimon.CurrentForm = digimon.Species; digimon.Size = (short)(int)read["digiSize"]; digimon.Scale = (int)read["digiScale"]; ResetModel(DigiId, digimon.Species); } } } } } catch (Exception e) { Console.WriteLine("Error: GetDigimon({1})\n{0}", e, DigiId); } return digimon; }
/// <summary> /// Spawns a Partner Digimon /// </summary> /// <param name="Partner"></param> /// <param name="hTamer"></param> public SpawnPlayer(Digimon Partner, short hTamer) { packet.Type(1006); packet.WriteShort(259); packet.WriteByte(0); packet.WriteInt(Partner.Location.PosX); packet.WriteInt(Partner.Location.PosY); 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(0); packet.WriteShort((short)Partner.Stats.MS); packet.WriteShort(hTamer); packet.WriteByte(0xff); packet.WriteInt(0); packet.WriteShort(0); }