Pet_Information_grab() 공개 정적인 메소드

public static Pet_Information_grab ( pet_obj o, byte slot ) : byte[]
o pet_obj
slot byte
리턴 byte[]
예제 #1
0
파일: Grabpet.cs 프로젝트: uvbs/DarkEmu
 ///////////////////////////////////////////////////////////////////////////
 // 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);
     }
 }
예제 #2
0
 /////////////////////////////////////////////////////////////////////////////////
 // Load grabpet if active state
 /////////////////////////////////////////////////////////////////////////////////
 #region Grab pet loading
 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);
     }
 }