void LoadTransport()
 {
     //Wrap our function inside a catcher
     try
     {
         //If the player has an active transport
         if (Character.Transport.Right)
         {
             //Set pet object information
             WorldMgr.pet_obj o = Character.Transport.Horse;
             //Set bools for transport
             Character.Transport.Spawned           = true;
             Character.Transport.Horse.Information = true;
             //Send packet for detailed transport information
             client.Send(Packet.Pet_Information(o.UniqueID, o.Model, o.Hp, Character.Information.CharacterID, o));
             //Send player visual onto horse
             Send(Packet.Player_UpToHorse(Character.Information.UniqueID, true, o.UniqueID));
             //Set speed state
             Character.Transport.Horse.Speedsend();
             Character.Transport.Horse.statussend();
         }
     }
     catch (Exception ex)
     {
         Log.Exception(ex);
     }
 }
        //###########################################################################################
        // Data
        //###########################################################################################
        public void Teleport_Data()
        {
            try
            {
                if (Character.Teleport)
                {
                    StopBerserkTimer();
                    CheckCharStats(Character);
                    client.Send(Packet.StartPlayerLoad());
                    client.Send(Packet.CharacterDataLoad(Character));

                    client.Send(Packet.EndPlayerLoad());
                    client.Send(Packet.PlayerUnknowPack(Character.Information.UniqueID));
                    client.Send(Packet.UnknownPacket());
                    SavePlayerPosition();


                    if (Character.Action.MonsterID.Count > 0)
                    {
                        Character.Action.MonsterID.Clear();
                    }
                    if (Character.Transport.Right)
                    {
                        WorldMgr.pet_obj o = Character.Transport.Horse;
                        Character.Transport.Spawned           = true;
                        Character.Transport.Horse.Information = true;
                        Send(Packet.Player_UpToHorse(Character.Information.UniqueID, true, o.UniqueID));
                    }
                    if (Character.Attackpet.Active)
                    {
                        WorldMgr.pet_obj o = Character.Attackpet.Details;
                        //ObjData.slotItem item =
                        //client.Send(Packet.Pet_Information_grab(o, slot));
                    }
                    if (Character.Grabpet.Active)
                    {
                        //WorldMgr.pet_obj o = Character.Grabpet.Details;
                        //client.Send(Packet.Pet_Information_grab(o, slot));
                    }
                    ObjectSpawnCheck();
                    Character.Teleport = false;
                }
            }
            catch (Exception ex)
            {
                Log.Exception(ex);
                Console.WriteLine(ex);
            }
        }
Ejemplo n.º 3
0
 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 // Close Pets
 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 public void ClosePet(int petid, WorldMgr.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)
     {
         Log.Exception(ex);
     }
 }
Ejemplo n.º 4
0
        bool HandleJobTransport(int ItemID)
        {
            try
            {
                int model = ObjData.objectdata.GetItem(ObjData.Manager.ItemBase[ItemID].ObjectName);
                if (Character.Information.Level < ObjData.Manager.ItemBase[ItemID].Level)
                {
                    return(true);
                }

                {
                    model = ObjData.objectdata.GetItem(ObjData.Manager.ItemBase[ItemID].ObjectName);
                    if (model == 0)
                    {
                        return(true);
                    }
                }
                WorldMgr.pet_obj o = new WorldMgr.pet_obj();
                o.Model     = model;
                o.Named     = 4;
                o.Ids       = new GenerateUniqueID(GenerateUniqueID.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        = ObjData.Manager.ObjectBase[model].HP;
                o.OwnerID   = Character.Information.UniqueID;
                o.OwnerName = Character.Information.Name;
                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(Character.Information.UniqueID, true, o.UniqueID));
                Helpers.Manager.HelperObject.Add(o);
                Character.Transport.Horse = o;
                return(false);
            }
            catch (Exception ex)
            {
                Log.Exception(ex);
            }
            return(false);
        }
 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
             DB ms = new DB("SELECT * FROM pets WHERE pet_itemid='" + ItemID + "' AND playerid='" + Character.Information.CharacterID + "'");
             //Create new pet object.
             WorldMgr.pet_obj o = new WorldMgr.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                     = ObjData.objectdata.GetItem(ObjData.Manager.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
             Helpers.Manager.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).
             DB.query("UPDATE pets SET pet_active='1' WHERE pet_unique='" + Character.Grabpet.Grabpetid + "' AND playerid='" + Character.Information.CharacterID + "'");
         }
     }
     catch (Exception ex)
     {
         Log.Exception(ex);
     }
 }
Ejemplo n.º 6
0
 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
             DB ms = new DB("SELECT * FROM pets WHERE pet_itemid='" + ItemID + "' AND playerid='" + Character.Information.CharacterID + "'");
             //Create new pet object.
             WorldMgr.pet_obj o = new WorldMgr.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     = ObjData.objectdata.GetItem(ObjData.Manager.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
             Helpers.Manager.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).
             DB.query("UPDATE pets SET pet_active='1' WHERE pet_unique='" + Character.Grabpet.Grabpetid + "' AND playerid='" + Character.Information.CharacterID + "'");
         }
     }
     catch (Exception ex)
     {
         Log.Exception(ex);
     }
 }
 void LoadGrabPet()
 {
     //Wrap our function inside a catcher
     try
     {
         //Query check
         DB ms = new DB("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
             WorldMgr.pet_obj o = new WorldMgr.pet_obj();
             //Create new data reader for DB
             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 = Convert.ToInt32(DB.GetData("SELECT * FROM char_items WHERE itemnumber='" + slot + "' AND owner='" + Character.Information.CharacterID + "' AND storagetype='0'", "slot"));
                     //Set slot item information (item).
                     ObjData.slotItem item = GetItem((uint)Character.Information.CharacterID, Convert.ToByte(slotcheck), 0);
                     //Set model information of the pet
                     int model = ObjData.item_database.GetItem(ObjData.Manager.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
                     Helpers.Manager.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
                     DB.query("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)
     {
         Log.Exception(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.
             DB ms = new DB("SELECT * FROM pets WHERE pet_itemid='" + ItemID + "' AND playerid='" + Character.Information.CharacterID + "'");
             //Get detailed item information.
             ObjData.slotItem item = GetItem((uint)Character.Information.CharacterID, slot, 0);
             //Get item model information
             int model = ObjData.objectdata.GetItem(ObjData.Manager.ItemBase[ItemID].ObjectName);
             //Create new pet object
             WorldMgr.pet_obj o = new WorldMgr.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
             Helpers.Manager.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).
             DB.query("UPDATE pets SET pet_active='1' WHERE pet_unique='" + Character.Grabpet.Grabpetid + "' AND playerid='" + Character.Information.CharacterID + "'");
         }
     }
     catch (Exception ex)
     {
         Log.Exception(ex);
     }
 }
        bool HandleJobTransport(int ItemID)
        {
            try
            {
                int model = ObjData.objectdata.GetItem(ObjData.Manager.ItemBase[ItemID].ObjectName);
                if (Character.Information.Level < ObjData.Manager.ItemBase[ItemID].Level) return true;

                {
                    model = ObjData.objectdata.GetItem(ObjData.Manager.ItemBase[ItemID].ObjectName);
                    if (model == 0) return true;
                }
                WorldMgr.pet_obj o = new WorldMgr.pet_obj();
                o.Model = model;
                o.Named = 4;
                o.Ids = new GenerateUniqueID(GenerateUniqueID.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 = ObjData.Manager.ObjectBase[model].HP;
                o.OwnerID = Character.Information.UniqueID;
                o.OwnerName = Character.Information.Name;
                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(Character.Information.UniqueID, true, o.UniqueID));
                Helpers.Manager.HelperObject.Add(o);
                Character.Transport.Horse = o;
                return false;
            }
            catch (Exception ex)
            {
                Log.Exception(ex);
            }
            return false;
        }
        ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        // Normal Transport
        ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        bool HandleHorseScroll(int ItemID)
        {
            try
            {
                int model = ObjData.objectdata.GetItem(ObjData.Manager.ItemBase[ItemID].ObjectName);
                if (model == 0)
                {
                    string extrapath = null;
                    if (Character.Information.Level >= 1 && Character.Information.Level <= 5)
                        extrapath = "_5";
                    else if (Character.Information.Level >= 6 && Character.Information.Level <= 10)
                        extrapath = "_10";
                    else if (Character.Information.Level >= 11 && Character.Information.Level <= 20)
                        extrapath = "_20";
                    else if (Character.Information.Level >= 21 && Character.Information.Level <= 30)
                        extrapath = "_30";
                    else if (Character.Information.Level >= 31 && Character.Information.Level <= 45)
                        extrapath = "_45";
                    else if (Character.Information.Level >= 46 && Character.Information.Level <= 60)
                        extrapath = "_60";
                    else if (Character.Information.Level >= 61 && Character.Information.Level <= 75)
                        extrapath = "_75";
                    else if (Character.Information.Level >= 76 && Character.Information.Level <= 90)
                        extrapath = "_90";
                    else if (Character.Information.Level >= 91 && Character.Information.Level <= 105)
                        extrapath = "_105";
                    else if (Character.Information.Level >= 106 && Character.Information.Level <= 120)
                        extrapath = "_120";
                    model = ObjData.objectdata.GetItem(ObjData.Manager.ItemBase[ItemID].ObjectName + extrapath);
                    if (model == 0) return true;
                }
                WorldMgr.pet_obj o = new WorldMgr.pet_obj();
                o.Model = model;
                o.Ids = new GenerateUniqueID(GenerateUniqueID.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 = ObjData.Manager.ObjectBase[model].HP;
                o.OwnerID = Character.Information.UniqueID;
                o.Speed1 = ObjData.Manager.ObjectBase[model].Speed1;
                o.Speed2 = ObjData.Manager.ObjectBase[model].Speed2;
                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(Character.Information.UniqueID, true, o.UniqueID));

                Helpers.Manager.HelperObject.Add(o);
                Character.Transport.Horse = o;
                return false;
            }
            catch (Exception ex)
            {
                Log.Exception(ex);
            }
            return false;
        }
 ///////////////////////////////////////////////////////////////////////////
 // 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.
             DB ms = new DB("SELECT * FROM pets WHERE pet_itemid='" + ItemID + "' AND playerid='" + Character.Information.CharacterID + "'");
             //Get detailed item information.
             ObjData.slotItem item = GetItem((uint)Character.Information.CharacterID, slot, 0);
             //Get item model information
             int model = ObjData.objectdata.GetItem(ObjData.Manager.ItemBase[ItemID].ObjectName);
             //Create new pet object
             WorldMgr.pet_obj o = new WorldMgr.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
             Helpers.Manager.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).
             DB.query("UPDATE pets SET pet_active='1' WHERE pet_unique='" + Character.Grabpet.Grabpetid + "' AND playerid='" + Character.Information.CharacterID + "'");
         }
     }
     catch (Exception ex)
     {
         Log.Exception(ex);
     }
 }
Ejemplo n.º 12
0
        ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        // Normal Transport
        ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        bool HandleHorseScroll(int ItemID)
        {
            try
            {
                int model = ObjData.objectdata.GetItem(ObjData.Manager.ItemBase[ItemID].ObjectName);
                if (model == 0)
                {
                    string extrapath = null;
                    if (Character.Information.Level >= 1 && Character.Information.Level <= 5)
                    {
                        extrapath = "_5";
                    }
                    else if (Character.Information.Level >= 6 && Character.Information.Level <= 10)
                    {
                        extrapath = "_10";
                    }
                    else if (Character.Information.Level >= 11 && Character.Information.Level <= 20)
                    {
                        extrapath = "_20";
                    }
                    else if (Character.Information.Level >= 21 && Character.Information.Level <= 30)
                    {
                        extrapath = "_30";
                    }
                    else if (Character.Information.Level >= 31 && Character.Information.Level <= 45)
                    {
                        extrapath = "_45";
                    }
                    else if (Character.Information.Level >= 46 && Character.Information.Level <= 60)
                    {
                        extrapath = "_60";
                    }
                    else if (Character.Information.Level >= 61 && Character.Information.Level <= 75)
                    {
                        extrapath = "_75";
                    }
                    else if (Character.Information.Level >= 76 && Character.Information.Level <= 90)
                    {
                        extrapath = "_90";
                    }
                    else if (Character.Information.Level >= 91 && Character.Information.Level <= 105)
                    {
                        extrapath = "_105";
                    }
                    else if (Character.Information.Level >= 106 && Character.Information.Level <= 120)
                    {
                        extrapath = "_120";
                    }
                    model = ObjData.objectdata.GetItem(ObjData.Manager.ItemBase[ItemID].ObjectName + extrapath);
                    if (model == 0)
                    {
                        return(true);
                    }
                }
                WorldMgr.pet_obj o = new WorldMgr.pet_obj();
                o.Model    = model;
                o.Ids      = new GenerateUniqueID(GenerateUniqueID.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       = ObjData.Manager.ObjectBase[model].HP;
                o.OwnerID  = Character.Information.UniqueID;
                o.Speed1   = ObjData.Manager.ObjectBase[model].Speed1;
                o.Speed2   = ObjData.Manager.ObjectBase[model].Speed2;
                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(Character.Information.UniqueID, true, o.UniqueID));

                Helpers.Manager.HelperObject.Add(o);
                Character.Transport.Horse = o;
                return(false);
            }
            catch (Exception ex)
            {
                Log.Exception(ex);
            }
            return(false);
        }
 void LoadGrabPet()
 {
     //Wrap our function inside a catcher
     try
     {
         //Query check
         DB ms = new DB("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
             WorldMgr.pet_obj o = new WorldMgr.pet_obj();
             //Create new data reader for DB
             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 = Convert.ToInt32(DB.GetData("SELECT * FROM char_items WHERE itemnumber='" + slot + "' AND owner='" + Character.Information.CharacterID + "' AND storagetype='0'", "slot"));
                     //Set slot item information (item).
                     ObjData.slotItem item = GetItem((uint)Character.Information.CharacterID, Convert.ToByte(slotcheck), 0);
                     //Set model information of the pet
                     int model = ObjData.item_database.GetItem(ObjData.Manager.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
                     Helpers.Manager.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
                     DB.query("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)
     {
         Log.Exception(ex);
     }
 }