/////////////////////////////////////////////////////////////////////////// // Despawn Pet /////////////////////////////////////////////////////////////////////////// public static byte[] PetSpawn(int petid, byte type, pet_obj o) { PacketWriter Writer = new PacketWriter(); Writer.Create(Systems.SERVER_PLAYER_SPAWN_PET); //Select Opcode Writer.DWord(petid); //Pet ID switch (type) { case 1: //Despawn pet Writer.Byte(1); break; case 2: //Rename pet respawn Writer.Byte(5); Writer.Text(o.Petname); break; case 3: //Attack pet respawn for exp info Writer.Byte(3);//Static Writer.LWord(o.exp);//New exp Writer.DWord(o.OwnerID);//Owner id break; } return Writer.GetBytes(); }
public static byte[] AttackPetHGP(pet_obj c) { PacketWriter writer = new PacketWriter(); writer.Create(Systems.SERVER_PET_HGP); writer.DWord(c.UniqueID); writer.Byte(3); writer.Byte(0); writer.Byte(0); return writer.GetBytes(); }
//////////////////////////////////////////////////////////////////////////////////////////////////////////// // Horse Stats //////////////////////////////////////////////////////////////////////////////////////////////////////////// public static byte[] Pet_Information(int id, int model, int hp, int charid, pet_obj o) { PacketWriter Writer = new PacketWriter(); Writer.Create(Systems.SERVER_PET_INFORMATION); //Select opcode Writer.DWord(id); //Horse ID Writer.DWord(model); //Horse Model Writer.DWord(hp); //Horse HP Writer.DWord(hp); //Horse SEC HP Writer.Byte(0); //Static byte ? return Writer.GetBytes(); }
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Close Pets /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// public void ClosePet(int petid, pet_obj o) { try { if (petid == o.UniqueID && o != null) { Send(Packet.PetSpawn(petid, 1, o)); //Below is for icon change from flashing to none flashing in inventory //client.Send(Packet.ChangeStatus(0,6, //Slot here //)); o.DeSpawnMe(); } } catch (Exception ex) { Systems.Debugger.Write(ex); } }
/////////////////////////////////////////////////////////////////////////// // Grab pet information packet /////////////////////////////////////////////////////////////////////////// public static byte[] Pet_Information_grab(pet_obj o, byte slot) { PacketWriter Writer = new PacketWriter(); Writer.Create(Systems.SERVER_PET_INFORMATION); try { ////////////////////////////////////////////////////////////////////////////////////// // Grabpet structure ////////////////////////////////////////////////////////////////////////////////////// Writer.DWord(o.UniqueID); //Unique ID Writer.DWord(o.Model); //Pet Model Writer.DWord(0x00006D); //Settings Writer.DWord(0x00006D); //Settings Writer.DWord(0x000047); //Settings 0x47 grab pet active 0 disabled if (o.Petname != "No name") //############### Writer.Text(o.Petname); // Name region else // Writer.Word(0); //############### Writer.Byte(o.Slots); //Slots count inventory pet ////////////////////////////////////////////////////////////////////////////////////// // Grabpet item inventory ////////////////////////////////////////////////////////////////////////////////////// Systems.MsSQL ms = new Systems.MsSQL("SELECT * FROM char_items WHERE owner='" + o.OwnerID + "' AND pet_storage_id='" + o.UniqueID + "'"); Writer.Byte(ms.Count()); using (System.Data.SqlClient.SqlDataReader reader = ms.Read()) { while (reader.Read()) Item.AddItemPacket(Writer, reader.GetByte(5), reader.GetInt32(2), reader.GetByte(4), reader.GetInt16(6), reader.GetInt32(7), reader.GetInt32(0), reader.GetInt32(9), reader.GetInt32(30)); } ms.Close(); ////////////////////////////////////////////////////////////////////////////////////// // Other ////////////////////////////////////////////////////////////////////////////////////// Writer.DWord(o.OwnerID); //Character ID Writer.Byte(slot); //Slot location of the pet ////////////////////////////////////////////////////////////////////////////////////// } catch (Exception ex) { Console.WriteLine("Pet load error: " + ex); } return Writer.GetBytes(); }
public static byte[] AttackPetStats(pet_obj c,byte slot) { PacketWriter writer = new PacketWriter(); writer.Create(Systems.SERVER_PET_INFORMATION); writer.DWord(c.UniqueID); writer.DWord(c.Model); writer.DWord(0x00000168);//stats writer.DWord(0x00000168);//stats writer.LWord(c.exp);//Experience writer.Byte(c.Level);//Level writer.Word(0);//Angle writer.DWord(0x00000001);//1 = Attack icon enabled, 2 = disabled if (c.Petname != "No name") writer.Text(c.Petname);//Petname else writer.Word(0);//No name writer.Byte(0);//Static perhaps writer.DWord(c.OwnerID);//Owner writer.Byte(slot); return writer.GetBytes(); }
/////////////////////////////////////////////////////////////////////////// // Spawn Pet Objects /////////////////////////////////////////////////////////////////////////// public static byte[] ObjectSpawn(pet_obj o) { PacketWriter Writer = new PacketWriter(); Writer.Create(Systems.SERVER_SOLO_SPAWN); switch (o.Named) { /////////////////////////////////////////////////////////////////////////// // Job transports /////////////////////////////////////////////////////////////////////////// case 4: Writer.DWord(o.Model); //Pet Model id Writer.DWord(o.UniqueID); //Pet Unique id Writer.Byte(o.xSec); //X sector Writer.Byte(o.ySec); //Y sector Writer.Float(Formule.packetx((float)o.x, o.xSec)); //X Writer.Float(o.z); //Z Writer.Float(Formule.packety((float)o.y, o.ySec)); //Y Writer.Word(0); //Angle Writer.Byte(1); //Walking state Writer.Byte(1); //Static Writer.Byte(o.xSec); //X sector Writer.Byte(o.ySec); //Y sector Writer.Word(0); //Static Writer.Word(0); // Writer.Word(0); // Writer.Word(1); Writer.Word(3); Writer.Byte(0); Writer.Float(o.Walk); //Object walking Writer.Float(o.Run); //Object running Writer.Float(o.Zerk); //Object zerk Writer.Byte(0);//new ? Writer.Word(0); // Writer.Text(o.OwnerName); Writer.Word(2); // Writer.DWord(o.OwnerID); //Owner unique id Writer.Byte(4); //Static byte 4 break; case 3: /////////////////////////////////////////////////////////////////////////// // Attack pet main packet /////////////////////////////////////////////////////////////////////////// Writer.DWord(o.Model); Writer.DWord(o.UniqueID); Writer.Byte(o.xSec); Writer.Byte(o.ySec); Writer.Float(Formule.packetx((float)o.x, o.xSec)); Writer.Float(o.z); Writer.Float(Formule.packety((float)o.y, o.ySec)); Writer.Word(0);//angle Writer.Byte(0); Writer.Byte(o.Level);//level Writer.Byte(0); Writer.Word(0);//angle Writer.Byte(1); Writer.Byte(0); Writer.Byte(0); Writer.Byte(2); Writer.Byte(0); Writer.Float(o.Walk); //Object walking Writer.Float(o.Run); //Object running Writer.Float(o.Zerk); //Object zerk Writer.Byte(0);//new ? Writer.Byte(0); Writer.Byte(0); if (o.Named == 1) Writer.Text(o.Petname); else Writer.Word(0); Writer.Text(o.OwnerName); Writer.Byte(0); Writer.Byte(0); Writer.DWord(o.OwnerID); Writer.Byte(1); break; case 2: /////////////////////////////////////////////////////////////////////////// // Grab pet main packet /////////////////////////////////////////////////////////////////////////// Writer.DWord(o.Model); //Pet Model id Writer.DWord(o.UniqueID); //Pet Unique id Writer.Byte(o.xSec); //X sector Writer.Byte(o.ySec); //Y sector Writer.Float(Formule.packetx((float)o.x, o.xSec)); //X Writer.Float(o.z); //Z Writer.Float(Formule.packety((float)o.y, o.ySec)); //Y Writer.Word(0xDC72); //Angle Writer.Byte(0); //Walking state Writer.Byte(1); //Static Writer.Byte(0); //Static Writer.Word(0xDC72); //Angle Writer.Byte(1); //Static Writer.Word(0); // Writer.Byte(0); Writer.Byte(0); Writer.Float(o.Walk); //Object walking Writer.Float(o.Run); //Object running Writer.Float(o.Zerk); //Object zerk Writer.Byte(0);//new ? Writer.Word(0); // if (o.Petname != "No name") Writer.Text(o.Petname); else Writer.Word(0); Writer.Text(o.OwnerName); //Pet owner name Writer.Byte(4); //Static byte 4? Writer.DWord(o.OwnerID); //Owner unique id Writer.Byte(1); //Static byte 1 /////////////////////////////////////////////////////////////////////////// break; default: /////////////////////////////////////////////////////////////////////////// // // Horse // /////////////////////////////////////////////////////////////////////////// Writer.DWord(o.Model); Writer.DWord(o.UniqueID); Writer.Byte(o.xSec); Writer.Byte(o.ySec); Writer.Float(Formule.packetx((float)o.x, o.xSec)); Writer.Float(o.z); Writer.Float(Formule.packety((float)o.y, o.ySec)); Writer.Word(0); Writer.Byte(0); Writer.Byte(1); Writer.Byte(0); Writer.Word(0); Writer.Byte(1); Writer.Word(0); Writer.Byte(0); Writer.Float(o.Speed1); Writer.Float(o.Speed2); Writer.Float(o.Zerk); Writer.Byte(0);//new ? Writer.Word(0); Writer.Byte(1); /////////////////////////////////////////////////////////////////////////// break; } return Writer.GetBytes(); }
bool HandleJobTransport(int ItemID) { try { int model = Global.objectdata.GetItem(Data.ItemBase[ItemID].ObjectName); if (this.Character.Information.Level < Data.ItemBase[ItemID].Level) return true; { model = Global.objectdata.GetItem(Data.ItemBase[ItemID].ObjectName); if (model == 0) return true; } pet_obj o = new pet_obj(); o.Model = model; o.Named = 4; o.Ids = new Global.ID(Global.ID.IDS.Object); o.UniqueID = o.Ids.GetUniqueID; o.x = Character.Position.x; o.z = Character.Position.z; o.y = Character.Position.y; o.xSec = Character.Position.xSec; o.ySec = Character.Position.ySec; o.Hp = Data.ObjectBase[model].HP; o.OwnerID = this.Character.Information.UniqueID; o.OwnerName = Character.Information.Name; this.Character.Transport.Right = true; o.Information = true; //client.Send(Packet.Pet_Information(o.UniqueID, o.Model, o.Hp, Character.Information.CharacterID, o)); Send(Packet.Player_UpToHorse(this.Character.Information.UniqueID, true, o.UniqueID)); Systems.HelperObject.Add(o); this.Character.Transport.Horse = o; return false; } catch (Exception ex) { Systems.Debugger.Write(ex); } return false; }
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Normal Transport /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// bool HandleHorseScroll(int ItemID) { try { int model = Global.objectdata.GetItem(Data.ItemBase[ItemID].ObjectName); if (model == 0) { string extrapath = null; if (this.Character.Information.Level >= 1 && this.Character.Information.Level <= 5) extrapath = "_5"; else if (this.Character.Information.Level >= 6 && this.Character.Information.Level <= 10) extrapath = "_10"; else if (this.Character.Information.Level >= 11 && this.Character.Information.Level <= 20) extrapath = "_20"; else if (this.Character.Information.Level >= 21 && this.Character.Information.Level <= 30) extrapath = "_30"; else if (this.Character.Information.Level >= 31 && this.Character.Information.Level <= 45) extrapath = "_45"; else if (this.Character.Information.Level >= 46 && this.Character.Information.Level <= 60) extrapath = "_60"; else if (this.Character.Information.Level >= 61 && this.Character.Information.Level <= 75) extrapath = "_75"; else if (this.Character.Information.Level >= 76 && this.Character.Information.Level <= 90) extrapath = "_90"; else if (this.Character.Information.Level >= 91 && this.Character.Information.Level <= 105) extrapath = "_105"; else if (this.Character.Information.Level >= 106 && this.Character.Information.Level <= 120) extrapath = "_120"; model = Global.objectdata.GetItem(Data.ItemBase[ItemID].ObjectName + extrapath); if (model == 0) return true; } pet_obj o = new pet_obj(); o.Model = model; o.Ids = new Global.ID(Global.ID.IDS.Object); o.UniqueID = o.Ids.GetUniqueID; o.x = Character.Position.x; o.z = Character.Position.z; o.y = Character.Position.y; o.xSec = Character.Position.xSec; o.ySec = Character.Position.ySec; o.Hp = Data.ObjectBase[model].HP; o.OwnerID = this.Character.Information.UniqueID; o.Speed1 = Data.ObjectBase[model].Speed1; o.Speed2 = Data.ObjectBase[model].Speed2; this.Character.Transport.Right = true; List<int> S = o.SpawnMe(); o.Information = true; client.Send(Packet.Pet_Information(o.UniqueID, o.Model, o.Hp, Character.Information.CharacterID, o)); Send(Packet.SetSpeed(o.UniqueID, o.Speed1, o.Speed2));//Global Speed Update Send(Packet.ChangeStatus(o.UniqueID, 3, 0));// Global Status Send(S, Packet.Player_UpToHorse(this.Character.Information.UniqueID, true, o.UniqueID)); Systems.HelperObject.Add(o); this.Character.Transport.Horse = o; return false; } catch (Exception ex) { Systems.Debugger.Write(ex); } return false; }
//////////////////////////////////////////////////////////////////////////////////////////////////////////// // Pet related item inventory movement //////////////////////////////////////////////////////////////////////////////////////////////////////////// public static byte[] MoveItemPet(int itemid, byte f_slot, byte t_slot,pet_obj o,short info, string action) { PacketWriter Writer = new PacketWriter(); Writer.Create(Systems.SERVER_ITEM_MOVE); switch (action) { case "MOVE_TO_PET": case "MOVE_FROM_PET": Writer.Byte(1); Writer.Byte(o.Slots); Writer.DWord(itemid); Writer.Byte(f_slot); Writer.Byte(t_slot); break; case "MOVE_INSIDE_PET": Writer.Byte(1); Writer.Byte(0x10); Writer.DWord(itemid); Writer.Byte(f_slot); Writer.Byte(t_slot); Writer.Word(info); break; } return Writer.GetBytes(); }
void PetSkill(int skillid, pet_obj o) { PacketWriter writer = new PacketWriter(); writer.Create(Systems.SERVER_ACTION_DATA); /* Will add this later * Packet sniff: * [S -> C][B070] * 01 ................ * 02 30 .0.............. * 47 0F 00 00 G............... * AF FD 1A 03 ................ * 1F 51 03 00 .Q.............. * 93 AA 1A 00 ................ * 01 ................ * 01 ................ * 01 ................ * 93 AA 1A 00 ................ * 00 ................ * 01 0F 00 00 ................ * 00 00 00 00 ................ */ }
void HandleAttackPet(byte slot, int ItemID) { try { //Check if player level is high enough to spawn. if (!CheckItemLevel(Character.Information.Level, ItemID)) { client.Send(Packet.MoveItemError(0x6C, 0x18)); } //If ok we continue to spawn the attack pet. else { //Our sql query MsSQL ms = new MsSQL("SELECT * FROM pets WHERE pet_itemid='" + ItemID + "' AND playerid='" + Character.Information.CharacterID + "'"); //Create new pet object. pet_obj o = new pet_obj(); //Open our data reader using (SqlDataReader reader = ms.Read()) { //Start reading data from the query above. while (reader.Read()) { Character.Attackpet.Uniqueid = reader.GetInt32(11); Character.Attackpet.Spawned = true; o.UniqueID = Character.Attackpet.Uniqueid; o.Model = Global.objectdata.GetItem(Data.ItemBase[ItemID].ObjectName); o.Level = reader.GetByte(13); o.exp = reader.GetInt64(14); o.x = Character.Position.x + rnd.Next(1, 3); o.z = Character.Position.z; o.y = Character.Position.y + rnd.Next(1, 3); o.xSec = Character.Position.xSec; o.ySec = Character.Position.ySec; o.OwnerID = Character.Information.CharacterID; o.OwnerName = Character.Information.Name; o.Walking = Character.Position.Walking; o.Petname = reader.GetString(3); o.Named = 3; o.Run = Character.Speed.RunSpeed; o.Walk = Character.Speed.WalkSpeed; o.Zerk = Character.Speed.BerserkSpeed; } ms.Close(); } //We set our pet active bool, so user cannot spawn multiple. Character.Attackpet.Active = true; o.Information = true; //Set all details above to definitions Character.Attackpet.Details = o; //Global spawn the pet Systems.HelperObject.Add(o); //Spawn ourselfs o.SpawnMe(); //Send then packet required (Pet information block). client.Send(Packet.AttackPetStats(o, slot)); client.Send(Packet.AttackPetHGP(o)); //Update pet status to active (For relog purposes). MsSQL.UpdateData("UPDATE pets SET pet_active='1' WHERE pet_unique='" + Character.Grabpet.Grabpetid + "' AND playerid='" + Character.Information.CharacterID + "'"); } } catch (Exception ex) { Console.WriteLine("Attack pet spawn error : " + ex); } }
void LoadGrabPet() { //Wrap our function inside a catcher try { //Query check MsSQL ms = new MsSQL("SELECT * FROM pets WHERE playerid='" + Character.Information.CharacterID + "' AND pet_active='1'"); //Get active pet count int checkactive = ms.Count(); //If the player has an active grabpet if (checkactive > 0) { //Set new pet object pet_obj o = new pet_obj(); //Create new data reader for mssql using (SqlDataReader reader = ms.Read()) { //While the sql data reader is reading while (reader.Read()) { //Get pet location inside the player inventory string slot = reader.GetString(12); //Check our slot inside the database int slotcheck = MsSQL.GetDataInt("SELECT * FROM char_items WHERE itemnumber='" + slot + "' AND owner='" + Character.Information.CharacterID + "' AND storagetype='0'", "slot"); //Set slot item information (item). Global.slotItem item = GetItem((uint)Character.Information.CharacterID, Convert.ToByte(slotcheck), 0); //Set model information of the pet int model = Global.objectdata.GetItem(Data.ItemBase[item.ID].ObjectName); //Set id for the pet (First database value is always unique). Character.Grabpet.Grabpetid = item.dbID; //Set unique id o.UniqueID = Character.Grabpet.Grabpetid; //Pet object model o.Model = model; //Spawning location of the pet o.x = Character.Position.x + rnd.Next(1, 3); o.z = Character.Position.z; o.y = Character.Position.y + rnd.Next(1, 3); o.xSec = Character.Position.xSec; o.ySec = Character.Position.ySec; //Owner id information o.OwnerID = Character.Information.CharacterID; //Owner name information o.OwnerName = Character.Information.Name; //Set walking state o.Walking = Character.Position.Walking; //Set petname o.Petname = reader.GetString(3); //Set our switch case o.Named = 2; //Set speed of pet (Need to check speed on official). o.Run = Character.Speed.RunSpeed - 3; o.Walk = Character.Speed.WalkSpeed - 3; o.Zerk = Character.Speed.BerserkSpeed - 3; //Set grabpet as active so there cant be double spawns Character.Grabpet.Active = true; //Set object information to true o.Information = true; //Spawn the pet Systems.HelperObject.Add(o); //Set global information for the pet Character.Grabpet.Details = o; //Send the visual packet for details of the pet management client.Send(Packet.Pet_Information_grab(o, Convert.ToByte(slotcheck))); //Spawn o.SpawnMe(); //Update state into database MsSQL.UpdateData("UPDATE pets SET pet_active='1' WHERE pet_unique='" + Character.Grabpet.Grabpetid + "' AND playerid='" + Character.Information.CharacterID + "'"); } //Close sql reader ms.Close(); } //Set state Character.Grabpet.Active = true; } } catch (Exception ex) { Console.WriteLine("Grab pet player load error {0}", ex); Systems.Debugger.Write(ex); } }
/////////////////////////////////////////////////////////////////////////// // Load grabpet /////////////////////////////////////////////////////////////////////////// public void HandleGrabPet(byte slot, int ItemID) { try { //Checks before we continue (Level check). if (!CheckItemLevel(Character.Information.Level, ItemID)) { client.Send(Packet.MoveItemError(0x6C, 0x18)); } //Else we continue else { //Our database query for loading pet information. MsSQL ms = new MsSQL("SELECT * FROM pets WHERE pet_itemid='" + ItemID + "' AND playerid='" + Character.Information.CharacterID + "'"); //Get detailed item information. Global.slotItem item = GetItem((uint)Character.Information.CharacterID, slot, 0); //Get item model information int model = Global.objectdata.GetItem(Data.ItemBase[ItemID].ObjectName); //Create new pet object pet_obj o = new pet_obj(); //Our sql data reader using (SqlDataReader reader = ms.Read()) { //While our reader is open we read all info below. while (reader.Read()) { int itemid = reader.GetInt32(7); Character.Grabpet.Grabpetid = item.dbID; o.UniqueID = Character.Grabpet.Grabpetid; o.Model = model; o.Slots = reader.GetByte(8); o.x = Character.Position.x + rnd.Next(1, 3); o.z = Character.Position.z; o.y = Character.Position.y + rnd.Next(1, 3); o.xSec = Character.Position.xSec; o.ySec = Character.Position.ySec; o.OwnerID = Character.Information.CharacterID; o.OwnerName = Character.Information.Name; o.Walking = Character.Position.Walking; o.Petname = reader.GetString(3); o.Named = 2; o.Run = Character.Speed.RunSpeed; o.Walk = Character.Speed.WalkSpeed; o.Zerk = Character.Speed.BerserkSpeed; } ms.Close(); } //We set our pet active bool, so user cannot spawn multiple. Character.Grabpet.Active = true; o.Information = true; //Set all details above to definitions Character.Grabpet.Details = o; //Global spawn the pet Systems.HelperObject.Add(o); //Spawn ourselfs o.SpawnMe(); //Send then packet required (Pet information block). client.Send(Packet.Pet_Information_grab(o, slot)); //Update pet status to active (For relog purposes). MsSQL.UpdateData("UPDATE pets SET pet_active='1' WHERE pet_unique='" + Character.Grabpet.Grabpetid + "' AND playerid='" + Character.Information.CharacterID + "'"); } } catch (Exception ex) { Console.WriteLine("Grab pet spawn error : " + ex); } }