示例#1
0
        /////////////////////////////////////////////////////////////////////////////////
        // Move item to exchange slot (Will come when fixing exchange system).
        /////////////////////////////////////////////////////////////////////////////////
        void ItemMoveToExhangePage(byte f_slot)
        {
            #region Move to exchange
            try
            {
                Systems sys = GetPlayer(Character.Network.TargetID);
                if (Character.Network.Exchange.ItemList.Count < 12 && sys.GetFreeSlotMax() > (byte)Character.Network.Exchange.ItemList.Count)
                {
                    Global.slotItem newitem = GetItem((uint)Character.Information.CharacterID, f_slot, 0);

                    LoadBluesid(newitem.dbID);
                    if (newitem.Amount <= Data.ItemBase[newitem.ID].Max_Stack)
                    {
                        Character.Network.Exchange.ItemList.Add(newitem);

                        client.Send(Packet.Exchange_ItemPacket(this.Character.Information.UniqueID, this.Character.Network.Exchange.ItemList, true));
                        sys.Send(Packet.Exchange_ItemPacket(sys.Character.Information.UniqueID, sys.Character.Network.Exchange.ItemList, true));

                        client.Send(Packet.Exchange_ItemSlot(4, f_slot));
                        sys.Send(Packet.Exchange_ItemSlot(4, f_slot));
                    }
                    else
                    {
                        return;
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Exchange add item error: {0}", ex);
            }
            #endregion
        }
示例#2
0
文件: BuyPack.cs 项目: uvbs/DarkEmu
        public slotItem Get(byte index)
        {
            slotItem ret = item[index];

            item.Remove(ret);
            return(ret);
        }
示例#3
0
        public static byte[] AlchemyResponse(bool isSuccess, Global.slotItem sItem, byte type, byte totalblue)
        {
            PacketWriter Writer = new PacketWriter();

            Writer.Create(Systems.SERVER_ALCHEMY);
            Writer.Byte(1);
            Writer.Byte(2);
            Writer.Bool(isSuccess);
            Writer.Byte(sItem.Slot);
            if (!isSuccess)
            {
                Writer.Byte(0);
            }
            Writer.DWord(0);
            Writer.DWord(sItem.ID);
            Writer.Byte(sItem.PlusValue);
            Writer.LWord(0);
            Writer.DWord(sItem.Durability);
            Writer.Byte(Data.ItemBlue[sItem.dbID].totalblue);
            for (int i = 0; i <= Data.ItemBlue[sItem.dbID].totalblue - 1; i++)
            {
                Writer.DWord(Data.MagicOptions.Find(mg => (mg.Name == Convert.ToString(Data.ItemBlue[sItem.dbID].blue[i]))).ID);
                Writer.DWord(Data.ItemBlue[sItem.dbID].blueamount[i]);
            }
            Writer.Word(1);
            Writer.Word(2);
            Writer.Word(3);

            return(Writer.GetBytes());
        }
示例#4
0
 /////////////////////////////////////////////////////////////////////////////////
 // Get degree information
 /////////////////////////////////////////////////////////////////////////////////
 public int GetItemDegree(Global.slotItem item)
 {
     try
     {
         if (1 <= Data.ItemBase[item.ID].Level && Data.ItemBase[item.ID].Level < 8)
         {
             return(1);
         }
         else if (8 <= Data.ItemBase[item.ID].Level && Data.ItemBase[item.ID].Level < 16)
         {
             return(2);
         }
         else if (16 <= Data.ItemBase[item.ID].Level && Data.ItemBase[item.ID].Level < 24)
         {
             return(3);
         }
         else if (24 <= Data.ItemBase[item.ID].Level && Data.ItemBase[item.ID].Level < 32)
         {
             return(4);
         }
         else if (32 <= Data.ItemBase[item.ID].Level && Data.ItemBase[item.ID].Level < 42)
         {
             return(5);
         }
         else if (42 <= Data.ItemBase[item.ID].Level && Data.ItemBase[item.ID].Level < 52)
         {
             return(6);
         }
         else if (52 <= Data.ItemBase[item.ID].Level && Data.ItemBase[item.ID].Level < 64)
         {
             return(7);
         }
         else if (64 <= Data.ItemBase[item.ID].Level && Data.ItemBase[item.ID].Level < 76)
         {
             return(8);
         }
         else if (76 <= Data.ItemBase[item.ID].Level && Data.ItemBase[item.ID].Level < 90)
         {
             return(9);
         }
         else if (90 <= Data.ItemBase[item.ID].Level && Data.ItemBase[item.ID].Level < 101)
         {
             return(10);
         }
         else if (101 <= Data.ItemBase[item.ID].Level && Data.ItemBase[item.ID].Level < 110)
         {
             return(11);
         }
         else
         {
             return(1);
         }
     }
     catch (Exception ex)
     {
         Systems.Debugger.Write(ex);
     }
     return(1);
 }
示例#5
0
        /////////////////////////////////////////////////////////////////////////////////
        // Move from exchange to inventory (Will come when fixing exchange system).
        /////////////////////////////////////////////////////////////////////////////////
        void ItemMoveExchangeToInv(byte f_slot)
        {
            #region From exchange to inventory
            Global.slotItem wannadeleteitem = Character.Network.Exchange.ItemList[f_slot];
            Character.Network.Exchange.ItemList.Remove(wannadeleteitem);

            client.Send(Packet.Exchange_ItemPacket(this.Character.Information.UniqueID, this.Character.Network.Exchange.ItemList, true));
            client.Send(Packet.Exchange_ItemSlot(5, f_slot));
            #endregion
        }
示例#6
0
 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 // Update Player Slot / Do not remove item
 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 void HandleUpdateSlotn(byte slot, Global.slotItem item, int packet)
 {
     try
     {
         client.Send(Packet.Player_HandleUpdateSlot(slot, (ushort)item.Amount, packet));
         Send(Packet.Player_HandleEffect(Character.Information.UniqueID, item.ID));
     }
     catch (Exception ex)
     {
         Systems.Debugger.Write(ex);
     }
 }
示例#7
0
 /////////////////////////////////////////////////////////////////////////////////
 // Move From Storage To Inventory
 /////////////////////////////////////////////////////////////////////////////////
 void Player_MoveStorageItemToInv(byte f_slot, byte t_slot, int o_id)
 {
     #region Move from storage to inv
     try
     {
         //Check if the user isnt in any state/action that we will not allow.
         if (!Character.State.Die || !Character.Stall.Stallactive || !Character.Alchemy.working || !Character.Position.Walking)
         {
             //Normal storage
             if (!Character.Network.Guild.UsingStorage)
             {
                 //Get free slots of player inventory
                 byte freeslot = GetFreeSlot();
                 //Get item information the one that user selected to move.
                 Global.slotItem item = GetItem((uint)Player.ID, f_slot, 1);
                 //Cannot drag and drop onto equip slots.
                 if (t_slot < 13)
                 {
                     return;
                 }
                 //Update database information
                 MsSQL.UpdateData("UPDATE char_items SET itemnumber='item" + t_slot + "',slot='" + t_slot + "',storagetype='0', owner=" + Character.Information.CharacterID + " WHERE storageacc='" + Player.ID + "' AND id='" + item.dbID + "'");
                 //Send visual packet
                 client.Send(Packet.MoveItem(3, f_slot, t_slot, 0, 0, "MOVE_FROM_STORAGE"));
             }
             //Guild storage
             else
             {
                 //Get free slots of player inventory
                 byte freeslot = GetFreeSlot();
                 //Get item information the one that user selected to move.
                 Global.slotItem item = GetItem((uint)Player.ID, f_slot, 3);
                 //Cannot drag and drop onto equip slots.
                 if (t_slot < 13)
                 {
                     return;
                 }
                 //Update database information
                 MsSQL.UpdateData("UPDATE char_items SET itemnumber='item" + t_slot + "',slot='" + t_slot + "',storagetype='0', owner=" + Character.Information.CharacterID + " WHERE guild_storage_id='" + Character.Network.Guild.Guildid + "' AND id='" + item.dbID + "'");
                 //Send visual packet
                 client.Send(Packet.MoveItem(3, f_slot, t_slot, 0, 0, "MOVE_FROM_GUILD_STORAGE"));
             }
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine("Move item from storage error: {0}", ex);
         Systems.Debugger.Write(ex);
     }
     //Save player information
     SavePlayerInfo();
     #endregion
 }
示例#8
0
        /////////////////////////////////////////////////////////////////////////////////
        // Get Slot Item Information
        /////////////////////////////////////////////////////////////////////////////////
        static Global.slotItem GetItem(uint id, byte slot, int type)
        {
            #region Slot item info

            try
            {
                if (id != 0)
                {
                    Global.slotItem slotItem = new Global.slotItem();
                    int             row      = type;

                    MsSQL ms;
                    if (row == 1)
                    {
                        ms = new MsSQL("SELECT * FROM char_items WHERE itemnumber='item" + slot + "' AND storageacc='" + id + "' AND storagetype='" + row + "' AND slot='" + slot + "'");
                    }
                    else if (row == 3)
                    {
                        ms = new MsSQL("SELECT * FROM char_items WHERE itemnumber='item" + slot + "' AND storagetype='" + row + "' AND slot='" + slot + "'");
                    }
                    else
                    {
                        ms = new MsSQL("SELECT * FROM char_items WHERE itemnumber='item" + slot + "' AND owner='" + id + "' AND storagetype='" + row + "' AND slot='" + slot + "'");
                    }

                    using (System.Data.SqlClient.SqlDataReader reader = ms.Read())
                    {
                        while (reader.Read())
                        {
                            slotItem.dbID       = reader.GetInt32(0);
                            slotItem.ID         = reader.GetInt32(2);
                            slotItem.PlusValue  = reader.GetByte(4);
                            slotItem.Amount     = reader.GetInt16(6);
                            slotItem.Durability = reader.GetInt32(7);
                            slotItem.Slot       = slot;
                            LoadBluesid(slotItem.dbID);
                        }
                    }
                    ms.Close();
                    return(slotItem);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Data item load error {0}", ex);
                Systems.Debugger.Write(ex);
            }
            return(null);

            #endregion
        }
示例#9
0
 /////////////////////////////////////////////////////////////////////////////////
 // Update Item Count
 /////////////////////////////////////////////////////////////////////////////////
 void ItemUpdateAmount(Global.slotItem sItem, int owner)
 {
     #region Item Update Amount
     if (sItem.Amount <= 0)
     {
         MsSQL.UpdateData("delete from char_items where slot='" + sItem.Slot + "' AND owner='" + owner + "'");
     }
     else
     {
         MsSQL.InsertData("UPDATE char_items SET quantity='" + Math.Abs(sItem.Amount) + "' WHERE slot='" + sItem.Slot + "' AND owner='" + owner + "'");
     }
     client.Send(Packet.ItemUpdate_Quantity(sItem.Slot, sItem.Amount));
     #endregion
 }
示例#10
0
文件: Grabpet.cs 项目: uvbs/DarkEmu
 ///////////////////////////////////////////////////////////////////////////
 // Move item from pet
 ///////////////////////////////////////////////////////////////////////////
 void MoveItemFromPet(int itemid, byte f_slot, byte t_slot)
 {
     try
     {
         Global.slotItem item = GetItem((uint)Character.Information.CharacterID, f_slot, 2);
         MsSQL.UpdateData("UPDATE char_items SET itemnumber='item" + t_slot + "',slot='" + t_slot + "',storagetype='0',pet_storage_id='0' WHERE owner='" + Character.Information.CharacterID + "' AND id='" + item.dbID + "'");
         client.Send(Packet.MoveItemPet(itemid, f_slot, t_slot, Character.Grabpet.Details, 0, "MOVE_FROM_PET"));
     }
     catch (Exception ex)
     {
         Console.WriteLine("Move item from pet error: " + ex);
         Systems.Debugger.Write(ex);
     }
 }
示例#11
0
        /////////////////////////////////////////////////////////////////////////////////
        // Check Armor Type
        /////////////////////////////////////////////////////////////////////////////////
        public static bool CheckArmorType(int FromItemID, int uid)
        {
            #region Armor Type

            Global.item_database.ArmorType[] SameType = new Global.item_database.ArmorType[6];
            for (byte i = 0; i <= 5; i++)
            {
                Global.slotItem env = GetItem((uint)uid, i, 0);
                if (env.ID != 0)
                {
                    SameType[i] = Data.ItemBase[env.ID].Type;
                }
            }
            if (SameType != null)
            {
                if ((Data.ItemBase[FromItemID].Type == Global.item_database.ArmorType.ARMOR && SameType.Count(st => (st == Global.item_database.ArmorType.GARMENT)) > 0))
                {
                    return(false);
                }
                else if (Data.ItemBase[FromItemID].Type == Global.item_database.ArmorType.PROTECTOR && SameType.Count(st => (st == Global.item_database.ArmorType.GARMENT)) > 0)
                {
                    return(false);
                }
                else if (Data.ItemBase[FromItemID].Type == Global.item_database.ArmorType.HEAVY && SameType.Count(st => (st == Global.item_database.ArmorType.ROBE)) > 0)
                {
                    return(false);
                }
                else if (Data.ItemBase[FromItemID].Type == Global.item_database.ArmorType.LIGHT && SameType.Count(st => (st == Global.item_database.ArmorType.ROBE)) > 0)
                {
                    return(false);
                }
                else if (Data.ItemBase[FromItemID].Type == Global.item_database.ArmorType.GARMENT && ((SameType.Count(st => (st == Global.item_database.ArmorType.ARMOR)) > 0) || (SameType.Count(st => (st == Global.item_database.ArmorType.PROTECTOR)) > 0)))
                {
                    return(false);
                }
                else if (Data.ItemBase[FromItemID].Type == Global.item_database.ArmorType.ROBE && ((SameType.Count(st => (st == Global.item_database.ArmorType.HEAVY)) > 0) || (SameType.Count(st => (st == Global.item_database.ArmorType.LIGHT)) > 0)))
                {
                    return(false);
                }
                return(true);
            }
            return(true);

            #endregion
        }
示例#12
0
 public void Add(slotItem objects)
 {
     if (item.Count < 5)
     {
         item.Add(objects);
     }
     else
     {
         if (item.Count >= 5)
         {
             item[0] = item[1];
             item[1] = item[2];
             item[2] = item[3];
             item[3] = item[4];
             item[4] = objects;
         }
     }
 }
示例#13
0
文件: BuyPack.cs 项目: uvbs/DarkEmu
 public void Add(slotItem objects)
 {
     if (item.Count < 5)
     {
         item.Add(objects);
     }
     else
     {
         if (item.Count >= 5)
         {
             item[0] = item[1];
             item[1] = item[2];
             item[2] = item[3];
             item[3] = item[4];
             item[4] = objects;
         }
     }
 }
示例#14
0
        /////////////////////////////////////////////////////////////////////////////////
        // Arrow Item Check
        /////////////////////////////////////////////////////////////////////////////////
        bool ItemCheckArrow()
        {
            #region Check Arrow
            MsSQL ms = new MsSQL("SELECT * FROM char_items WHERE owner='" + Character.Information.CharacterID + "' AND slot >= '13' AND slot <= '" + Character.Information.Slots + "' AND inavatar='0' AND itemid='62' AND storagetype='0'");
            if (ms.Count() == 0)
            {
                ms = new MsSQL("SELECT * FROM char_items WHERE owner='" + Character.Information.CharacterID + "' AND slot >= '13' AND slot <= '" + Character.Information.Slots + "' AND inavatar='0' AND itemid='3823' AND storagetype='0'");
            }
            else if (ms.Count() == 0)
            {
                ms = new MsSQL("SELECT * FROM char_items WHERE owner='" + Character.Information.CharacterID + "' AND slot >= '13' AND slot <= '" + Character.Information.Slots + "' AND inavatar='0' AND itemid='10302' AND storagetype='0'");
            }
            else if (ms.Count() == 0)
            {
                ms = new MsSQL("SELECT * FROM char_items WHERE owner='" + Character.Information.CharacterID + "' AND slot >= '13' AND slot <= '" + Character.Information.Slots + "' AND inavatar='0' AND itemid='10487' AND storagetype='0'");
            }
            if (ms.Count() == 0)
            {
                return(false);
            }
            else
            {
                Global.slotItem items = null;
                using (System.Data.SqlClient.SqlDataReader reader = ms.Read())
                {
                    while (reader.Read())
                    {
                        items = ConvertToItem(reader.GetInt32(2), reader.GetByte(5), reader.GetInt16(6), 1);
                    }
                }
                ms.Close();
                MsSQL.InsertData("UPDATE char_items SET itemnumber='item" + 7 + "',slot='" + 7 + "' WHERE itemnumber='" + "item" + items.Slot + "' AND owner='" + Character.Information.CharacterID + "' AND itemid='" + items.ID + "'");
                client.Send(Packet.MoveItem(0, items.Slot, 7, items.Amount, 0, "MOVE_INSIDE_INVENTORY"));

                Character.Information.Item.sAmount = items.Amount;
                Character.Information.Item.sID     = items.ID;
                ;
                return(true);
            }
            #endregion
        }
示例#15
0
 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 // Monster Masks Base
 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 void MonsterMasks(int itemid, byte slot)
 {
     try
     {
         //Load Mask Info
         Global.slotItem item    = GetItem((uint)Character.Information.CharacterID, slot, 0);
         int             skillid = 7126;
         SpecialBuff(skillid);
         //Load Model Info From Database
         int modelid = MsSQL.GetDataInt("SELECT modelid FROM char_items WHERE slot='" + slot + "' AND owner='" + Character.Information.CharacterID + "'", "modelid");
         //Create send to list
         List <int> To = Character.Spawn;
         //Transform the player
         Send(To, Packet.Transform(modelid, Character.Information.UniqueID));
     }
     catch (Exception ex)
     {
         Console.WriteLine("Monster Mask Usage error : {0}", ex);
         Systems.Debugger.Write(ex);
     }
 }
示例#16
0
 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 // Update Player Slot / Remove item
 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 void HandleUpdateSlot(byte slot, Global.slotItem item, int packet)
 {
     try
     {
         item.Amount--;
         client.Send(Packet.Player_HandleUpdateSlot(slot, (ushort)item.Amount, packet));
         if (item.Amount > 0)
         {
             MsSQL.UpdateData("UPDATE char_items SET quantity='" + Math.Abs(item.Amount) + "' WHERE owner='" + Character.Information.CharacterID + "' AND itemnumber='item" + item.Slot + "' AND id='" + item.dbID + "'");
         }
         else
         {
             MsSQL.UpdateData("delete from char_items where id='" + item.dbID + "'");
         }
         //Need to be defined per item type (potion or private item)
         Send(Packet.Player_HandleEffect(Character.Information.UniqueID, item.ID));
     }
     catch (Exception ex)
     {
         Systems.Debugger.Write(ex);
     }
 }
示例#17
0
文件: Grabpet.cs 项目: uvbs/DarkEmu
        ///////////////////////////////////////////////////////////////////////////
        // Move inside pet
        ///////////////////////////////////////////////////////////////////////////
        void MovePetToPet(int itemid, byte f_slot, byte t_slot, short info)
        {
            try
            {
                Global.slotItem itemfrom = GetItem((uint)Character.Information.CharacterID, f_slot, 2);
                Global.slotItem itemto   = GetItem((uint)Character.Information.CharacterID, t_slot, 2);

                if (itemto.ID != 0)
                {
                    MsSQL.InsertData("UPDATE char_items SET itemnumber='item" + t_slot + "',slot='" + t_slot + "' WHERE id='" + itemfrom.dbID + "' AND owner='" + Character.Information.CharacterID + "' AND pet_storage_id='" + Character.Grabpet.Grabpetid + "'");
                    MsSQL.InsertData("UPDATE char_items SET itemnumber='item" + f_slot + "',slot='" + f_slot + "' WHERE id='" + itemto.dbID + "' AND owner='" + Character.Information.CharacterID + "' AND pet_storage_id='" + Character.Grabpet.Grabpetid + "'");
                }
                else
                {
                    MsSQL.InsertData("UPDATE char_items SET itemnumber='item" + t_slot + "',slot='" + t_slot + "' WHERE id='" + itemfrom.dbID + "' AND owner='" + Character.Information.CharacterID + "' AND pet_storage_id='" + Character.Grabpet.Grabpetid + "'");
                }
                client.Send(Packet.MoveItemPet(itemid, t_slot, f_slot, Character.Grabpet.Details, info, "MOVE_INSIDE_PET"));
            }
            catch (Exception ex)
            {
                Console.WriteLine("Move item from inside pet inventory: " + ex);
                Systems.Debugger.Write(ex);
            }
        }
示例#18
0
        //##########################################
        // Item gender change
        //##########################################
        public void HandleItemChange(int itemid, byte slot, byte target_slot)
        {
            try
            {
                //Get information for the current item
                Global.slotItem iteminfo = GetItem((uint)Character.Information.CharacterID, target_slot, 0);
                Global.slotItem toolinfo = GetItem((uint)Character.Information.CharacterID, slot, 0);
                //Get item name
                string itemname = Data.ItemBase[iteminfo.ID].Name;

                //Checks before continuing (degree item).
                if (Data.ItemBase[toolinfo.ID].Name.Contains("_01"))
                {
                    if (Data.ItemBase[iteminfo.ID].Degree > 3)
                    {
                        return;
                    }
                }
                else if (Data.ItemBase[toolinfo.ID].Name.Contains("_02"))
                {
                    if (Data.ItemBase[iteminfo.ID].Degree > 6 && Data.ItemBase[iteminfo.ID].Degree < 8)
                    {
                        return;
                    }
                }
                else if (Data.ItemBase[toolinfo.ID].Name.Contains("_03"))
                {
                    if (Data.ItemBase[iteminfo.ID].Degree > 9 && Data.ItemBase[iteminfo.ID].Degree < 6)
                    {
                        return;
                    }
                }
                else if (Data.ItemBase[toolinfo.ID].Name.Contains("_04"))
                {
                    if (Data.ItemBase[iteminfo.ID].Degree > 12 && Data.ItemBase[iteminfo.ID].Degree < 10)
                    {
                        return;
                    }
                }
                //Rename the item to the opposite gender for getting the new id
                if (itemname.Contains("_M_"))
                {
                    itemname = itemname.Replace("_M_", "_W_");
                }
                else if (itemname.Contains("_W_"))
                {
                    itemname = itemname.Replace("_W_", "_M_");
                }
                //Return the new itemid value
                iteminfo.ID = GetGenderItem(itemname);
                //Send 1st packet
                client.Send(Packet.ChangeItemQ(target_slot, iteminfo.ID));
                //Remove the gender change item visually (amount).
                HandleUpdateSlotChange(target_slot, iteminfo, iteminfo.ID);
                //Need to refactor the packets for item move will do that later
                client.Send(Packet.MoveItem(target_slot, slot, 0, 0, 0, "MOVE_GENDER_CHANGE"));
                //Need to check refresh info for the item. (Rest works).
            }
            catch (Exception ex)
            {
                Console.WriteLine("Item gender change error {0}", ex);
                Systems.Debugger.Write(ex);
            }
        }
示例#19
0
文件: Stall.cs 项目: uvbs/DarkEmu
        public void StallMain()
        {
            try
            {
                PacketReader Reader = new PacketReader(PacketInformation.buffer);
                byte         Type   = Reader.Byte();

                //Item edit
                if (Type == 1)
                {
                    if (Character.Network.Stall.isOpened)
                    {
                        return;
                    }
                    byte stallslot = Reader.Byte();
                    Reader.Skip(2);
                    ulong price = Reader.UInt64();
                    if (price <= 999999999)
                    {
                        int StallItemIndex = Character.Network.Stall.ItemList.FindIndex(i => (i.stallSlot == stallslot));
                        Character.Network.Stall.ItemList[StallItemIndex].price = price;

                        Character.Network.Stall.Send(Packet.StallModifyItem(stallslot, price));
                    }
                    else
                    {
                        return;
                    }
                }
                //Add an item
                else if (Type == 2)
                {
                    if (Character.Network.Stall.isOpened)
                    {
                        return;
                    }
                    byte  stallslot = Reader.Byte();
                    byte  invpos    = Reader.Byte();
                    short quantity  = Reader.Int16();
                    ulong price     = Reader.UInt64();

                    Global.slotItem uItemID = GetItem((uint)Character.Information.CharacterID, invpos, 0);

                    //Disable item mall items in stalls for now.
                    if (Data.ItemBase[uItemID.ID].Etctype == Global.item_database.EtcType.GLOBALCHAT ||
                        Data.ItemBase[uItemID.ID].Type == Global.item_database.ArmorType.AVATAR ||
                        Data.ItemBase[uItemID.ID].Type == Global.item_database.ArmorType.AVATARHAT ||
                        Data.ItemBase[uItemID.ID].Type == Global.item_database.ArmorType.AVATARATTACH
                        )
                    {
                        return;
                    }

                    if (quantity <= Data.ItemBase[uItemID.ID].Max_Stack)
                    {
                        stall.stallItem StallItem = new stall.stallItem();
                        LoadBluesid(uItemID.dbID);
                        StallItem.stallSlot = stallslot;
                        StallItem.price     = price;
                        StallItem.Item      = (GetItem((uint)Character.Information.CharacterID, invpos, 0));

                        if (Character.Network.Stall.ItemList.Exists((get => get.Item.dbID == StallItem.Item.dbID)))
                        {
                            return;
                        }

                        Character.Network.Stall.ItemList.Add(StallItem);
                        Character.Network.Stall.Send(Packet.StallItemMain(Character.Network.Stall.ItemList));
                    }
                    else
                    {
                        return;
                    }
                }
                //Item pulling out
                else if (Type == 3)
                {
                    if (Character.Network.Stall.isOpened)
                    {
                        return;
                    }
                    byte stallslot = Reader.Byte();

                    //remove stallItem from stall
                    Character.Network.Stall.ItemList.Remove(Character.Network.Stall.ItemList.Find(i => (i.stallSlot == stallslot)));
                    Character.Network.Stall.Send(Packet.StallItemMain(Character.Network.Stall.ItemList));
                }
                //Stall modify state
                else if (Type == 5)
                {
                    byte State = Reader.Byte();
                    Character.Network.Stall.isOpened = (State == 1) ? true : false;

                    Character.Network.Stall.Send(Packet.StallSetState(State));
                }
                //Set Welcome msg
                else if (Type == 6)
                {
                    if (Character.Network.Stall.isOpened)
                    {
                        return;
                    }
                    short length = Reader.Int16();
                    Character.Network.Stall.WelcomeMsg = Reader.Text3();
                    //Console.WriteLine("New Welcome msg:" + welcome);
                    Character.Network.Stall.Send(Packet.StallWelcome(Character.Network.Stall.WelcomeMsg));
                }
                //Set StallName
                else if (Type == 7)
                {
                    string stallname = Reader.Text3();
                    Send(Packet.StallNameGlobal(Character.Information.UniqueID, stallname));
                    Character.Network.Stall.Send(Packet.StallName(stallname));
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Additem Stall error: {0}", ex);
            }
        }
示例#20
0
文件: ItemUsage.cs 项目: uvbs/DarkEmu
        void Handle()
        {
            try
            {
                //Read packet information
                PacketReader Reader = new PacketReader(PacketInformation.buffer);
                byte         iSlot  = Reader.Byte();
                //Get global item information
                Global.slotItem uItemID = GetItem((uint)Character.Information.CharacterID, iSlot, 0);
                //Checks before continuing
                if (uItemID.ID != 0 || !Character.State.Die)
                {
                    //###########################################################################################
                    // Grabpets
                    //###########################################################################################
                    #region Pets (PET OBJECTS)

                    // Grabpets
                    #region Grabpets
                    if (Data.ItemBase[uItemID.ID].Pettype == Global.item_database.PetType.GRABPET)
                    {
                        //Check if we have pet active allready.
                        if (!Character.Grabpet.Active && Character.Action.MonsterID.Count == 0)
                        {
                            //If not active , add new pet object.
                            HandleGrabPet(iSlot, uItemID.ID);
                            //Need to change this to active effect on slot.
                            HandleUpdateSlotn(iSlot, uItemID, Reader.Int32());
                        }
                    }
                    #endregion
                    // Attackpets
                    #region Attackpets
                    else if (Data.ItemBase[uItemID.ID].Pettype == Global.item_database.PetType.ATTACKPET)
                    {
                        //Check if we have pet active allready.
                        if (!Character.Attackpet.Active && Character.Action.MonsterID.Count == 0 || !Character.Attackpet.Active && Character.Action.MonsterID == null)
                        {
                            //If not active , add new pet object.
                            if (!Character.Attackpet.Active)
                            {
                                HandleUpdateSlotn(iSlot, uItemID, Reader.Int32());
                                HandleAttackPet(iSlot, uItemID.ID);
                                client.Send(Packet.Update2(iSlot));
                                client.Send(Packet.ChangeStatus(Character.Information.UniqueID, 5, 0));
                            }
                        }
                    }
                    #endregion
                    #endregion
                    // Horses (NOTE: Detail error messages per if statement (if level, summoned etc).
                    #region Horses
                    if (Data.ItemBase[uItemID.ID].Pettype == Global.item_database.PetType.TRANSPORT)
                    {
                        //Checks before we continue
                        if (!Character.Stall.Stallactive && !Character.Transport.Right && Character.Action.MonsterID.Count == 0 && !Character.State.Sitting && !Character.Information.Scroll)
                        {
                            //Check if level is high enough
                            if (this.Character.Information.Level >= Data.ItemBase[uItemID.ID].Level)
                            {
                                HandleUpdateSlot(iSlot, uItemID, Reader.Int32());
                                HandleHorseScroll(uItemID.ID);
                            }
                            //Else
                            else
                            {
                                client.Send(Packet.IngameMessages(SERVER_PLAYER_UPTOHORSE, IngameMessages.UIIT_MSG_COSPETERR_CANT_PETSUM_HIGHLEVEL));
                            }
                        }
                    }
                    #endregion
                    // Special transport
                    #region Special transport
                    else if (Data.ItemBase[uItemID.ID].Pettype == Global.item_database.PetType.ATTACKPET)
                    {
                    }
                    #endregion
                    // Job Transport
                    #region Job Transport
                    else if (Data.ItemBase[uItemID.ID].Pettype == Global.item_database.PetType.JOBTRANSPORT)
                    {
                        //HandleJobTransport(uItemID.ID);
                    }
                    #endregion
                    //###########################################################################################
                    // Potions
                    //###########################################################################################
                    #region Potions
                    #region HP potion
                    if (Data.ItemBase[uItemID.ID].Etctype == Global.item_database.EtcType.HP_POTION && Data.ItemBase[uItemID.ID].Etctype != Global.item_database.EtcType.HPSTATPOTION)
                    {
                        HandlePotion(1, uItemID.ID);
                        HandleUpdateSlot(iSlot, uItemID, Reader.Int32());
                    }
                    else if (Data.ItemBase[uItemID.ID].Name.Contains("_HP_") && Data.ItemBase[uItemID.ID].Name.Contains("_SUPERSET_"))
                    {
                        HandlePotion(1, uItemID.ID);
                        HandleUpdateSlot(iSlot, uItemID, Reader.Int32());
                    }
                    #endregion
                    #region HP STAT Potions
                    else if (Data.ItemBase[uItemID.ID].Etctype != Global.item_database.EtcType.HP_POTION && Data.ItemBase[uItemID.ID].Etctype == Global.item_database.EtcType.HPSTATPOTION)
                    {
                    }
                    #endregion
                    #region MP potions
                    else if (Data.ItemBase[uItemID.ID].Etctype == Global.item_database.EtcType.MP_POTION && Data.ItemBase[uItemID.ID].Etctype != Global.item_database.EtcType.MPSTATPOTION)
                    {
                        HandlePotion(2, uItemID.ID);
                        HandleUpdateSlot(iSlot, uItemID, Reader.Int32());
                    }
                    else if (Data.ItemBase[uItemID.ID].Name.Contains("_MP_") && Data.ItemBase[uItemID.ID].Name.Contains("_SUPERSET_"))
                    {
                        HandlePotion(1, uItemID.ID);
                        HandleUpdateSlot(iSlot, uItemID, Reader.Int32());
                    }
                    #endregion
                    #region HP STAT Potions
                    else if (Data.ItemBase[uItemID.ID].Etctype != Global.item_database.EtcType.HP_POTION && Data.ItemBase[uItemID.ID].Etctype == Global.item_database.EtcType.MPSTATPOTION)
                    {
                    }
                    #endregion
                    #region Vigor potions

                    /*
                     *  else if (Data.ItemBase[uItemID.ID].Etctype == Global.item_database.EtcType.VIGOR_POTION)
                     *  {
                     *      HandlePotion(5, uItemID.ID);
                     *      HandleUpdateSlot(iSlot, uItemID, Reader.Int32());
                     *  }
                     */
                    else if (Data.ItemBase[uItemID.ID].Name.Contains("ITEM_ETC_ALL_"))
                    {
                        HandlePotion(5, uItemID.ID);
                        HandleUpdateSlot(iSlot, uItemID, Reader.Int32());
                    }
                    #endregion
                    #region Speed potions
                    else if (Data.ItemBase[uItemID.ID].Etctype == Global.item_database.EtcType.SPEED_POTION)
                    {
                        if (Character.Speed.DefaultSpeed == Character.Speed.RunSpeed ||
                            Character.Speed.DefaultSpeed + Character.Speed.Updateded[20] != Character.Speed.RunSpeed && Character.Information.Berserking)
                        {
                            this.SpecialBuff(Data.ItemBase[uItemID.ID].SkillID);
                            HandleUpdateSlot(iSlot, uItemID, Reader.UInt16());
                        }
                    }
                    #endregion
                    #region Berserk Potion
                    else if (Data.ItemBase[uItemID.ID].Etctype == Global.item_database.EtcType.BERSERKPOTION)
                    {
                        if (Character.Information.BerserkBar < 5)
                        {
                            if (Character.Information.Berserking == false)
                            {
                                this.Character.Information.BerserkBar = 5;
                                client.Send(Packet.InfoUpdate(4, 0, Character.Information.BerserkBar));
                                HandleUpdateSlot(iSlot, uItemID, Reader.Int32());
                            }
                        }
                    }
                    #endregion
                    #endregion
                    //###########################################################################################
                    // Tickets
                    //###########################################################################################
                    #region Tickets
                    //Forgotten world
                    #region Forgotten world
                    else if (Data.ItemBase[uItemID.ID].Ticket == Global.item_database.Tickets.DUNGEON_FORGOTTEN_WORLD)
                    {
                        //Must add check if user location currently is forgotten world.
                        //Must add level check of portal.
                        ForgottenWorld(uItemID.ID);
                        HandleUpdateSlot(iSlot, uItemID, Reader.Int32());
                    }
                    #endregion
                    #endregion
                    //###########################################################################################
                    // Global chat
                    //###########################################################################################
                    #region Global Chat
                    else if (Data.ItemBase[uItemID.ID].Etctype == Global.item_database.EtcType.GLOBALCHAT)
                    {
                        HandleUpdateSlot(iSlot, uItemID, Reader.Int32());
                        byte   something = Reader.Byte();
                        string text      = Reader.Text3();
                        Reader.Close();
                        SendAll(Packet.ChatPacket(6, 0, text, Character.Information.Name));
                    }
                    #endregion
                    //###########################################################################################
                    // Stall decoration
                    //###########################################################################################
                    #region Stall decoration
                    else if (Data.ItemBase[uItemID.ID].Etctype == Global.item_database.EtcType.STALLDECORATION)
                    {
                        StallDeco(uItemID.ID, iSlot);
                        HandleUpdateSlot(iSlot, uItemID, Reader.Int32());
                    }
                    #endregion
                    //###########################################################################################
                    // Monster masks
                    //###########################################################################################
                    #region Monster masks
                    else if (Data.ItemBase[uItemID.ID].Etctype == Global.item_database.EtcType.MONSTERMASK)
                    {
                        //If character monster mask isnt enabled allready.
                        if (!Character.Transformed)
                        {
                            if (Character.Information.Level >= Data.ItemBase[uItemID.ID].Level)
                            {
                                //Load Mask
                                MonsterMasks(uItemID.ID, iSlot);
                                HandleUpdateSlot(iSlot, uItemID, Reader.Int32());
                            }
                            else
                            {
                                //Send msg level to low
                            }
                        }
                        else
                        {
                            //Send msg allready in use
                        }
                    }
                    #endregion
                    //###########################################################################################
                    // Return scrolls
                    //###########################################################################################
                    #region Return scrolls
                    else if (Data.ItemBase[uItemID.ID].Etctype == Global.item_database.EtcType.RETURNSCROLL && Data.ItemBase[uItemID.ID].Etctype != Global.item_database.EtcType.REVERSESCROLL)
                    {
                        if (Character.Information.Scroll)
                        {
                            return;
                        }
                        if (Timer.Movement != null)
                        {
                            Timer.Movement.Dispose();
                            Character.Position.Walking = false;
                        }
                        HandleReturnScroll(uItemID.ID);
                        HandleUpdateSlot(iSlot, uItemID, Reader.Int32());
                    }
                    #endregion
                    //###########################################################################################
                    // Reverse scrolls
                    //###########################################################################################
                    #region Reverse scrolls
                    else if (Data.ItemBase[uItemID.ID].Etctype == Global.item_database.EtcType.REVERSESCROLL)
                    {
                        if (Character.Information.Scroll)
                        {
                            return;
                        }
                        if (Character.Position.Walking)
                        {
                            return;
                        }
                        //Read item id
                        int itemid = Reader.Int32();
                        //Our switch byte
                        byte type = Reader.Byte();
                        //locations for reverse
                        int locid = 0;
                        if (type == 7)
                        {
                            locid = Reader.Int32();
                        }
                        //Start our handle
                        HandleReverse(itemid, type, locid);
                        //Update slot
                        HandleUpdateSlot(iSlot, uItemID, itemid);
                    }
                    #endregion
                    //###########################################################################################
                    // Thief scrolls
                    //###########################################################################################
                    #region Thief scrolls
                    else if (Data.ItemBase[uItemID.ID].Etctype == Global.item_database.EtcType.BANDITSCROLL)
                    {
                        if (Character.Information.Scroll)
                        {
                            return;
                        }
                        HandleThiefScroll(uItemID.ID);
                        HandleUpdateSlot(iSlot, uItemID, Reader.Int32());
                    }
                    #endregion
                    //###########################################################################################
                    // Summon scrolls
                    //###########################################################################################
                    #region Summon scrolls
                    else if (Data.ItemBase[uItemID.ID].Etctype == Global.item_database.EtcType.SUMMONSCROLL)
                    {
                        HandleSummon(Character.Information.Level);
                        HandleUpdateSlot(iSlot, uItemID, Reader.Int32());
                    }
                    #endregion
                    //###########################################################################################
                    // Skin change scrolls
                    //###########################################################################################
                    #region Skin change scrolls
                    else if (Data.ItemBase[uItemID.ID].Etctype == Global.item_database.EtcType.CHANGESKIN)
                    {
                        HandleUpdateSlot(iSlot, uItemID, Reader.Int32());
                        int skinmodel = Reader.Int32();
                        HandleSkinScroll(skinmodel, uItemID.ID);
                    }
                    #endregion
                    //###########################################################################################
                    // Item change tool
                    //###########################################################################################
                    #region Skin change scrolls
                    else if (Data.ItemBase[uItemID.ID].Etctype == Global.item_database.EtcType.ITEMCHANGETOOL)
                    {
                        int  itemid     = Reader.Int32();
                        byte targetslot = Reader.Byte();
                        //Make sure the item target is not equiped.
                        if (targetslot < 13)
                        {
                            return;
                        }
                        //Continue
                        HandleUpdateSlot(iSlot, uItemID, itemid);
                        HandleItemChange(uItemID.ID, iSlot, targetslot);
                    }
                    #endregion
                    //###########################################################################################
                    // Dungeon items
                    //###########################################################################################
                    #region Forgotten world
                    else if (Data.ItemBase[uItemID.ID].Ticket == Global.item_database.Tickets.DUNGEON_FORGOTTEN_WORLD)
                    {
                        HandleUpdateSlot(iSlot, uItemID, Reader.Int32());
                        ForgottenWorld(uItemID.ID);
                    }
                    #endregion
                    //###########################################################################################
                    // Inventory expansion
                    //###########################################################################################
                    #region Inventory expansion
                    else if (Data.ItemBase[uItemID.ID].Etctype == Global.item_database.EtcType.INVENTORYEXPANSION)
                    {
                        HandleInventoryExp(uItemID.ID);
                        HandleUpdateSlot(iSlot, uItemID, Reader.Int32());
                    }
                    #endregion
                    //###########################################################################################
                    // Warehouse expansion
                    //###########################################################################################
                    #region Warehouse expansion
                    else if (Data.ItemBase[uItemID.ID].Etctype == Global.item_database.EtcType.WAREHOUSE)
                    {
                        HandleWareHouse(uItemID.ID);
                        HandleUpdateSlot(iSlot, uItemID, Reader.Int32());
                    }
                    #endregion
                    //###########################################################################################
                    // Guild related
                    //###########################################################################################
                    #region Guild Icon
                    else if (Data.ItemBase[uItemID.ID].Etctype == Global.item_database.EtcType.GUILD_ICON)
                    {
                        HandleRegisterIcon();
                    }
                    #endregion
                    //###########################################################################################
                    // Non coded types
                    //###########################################################################################
                    else
                    {
                        //Need to make message in progress or such
                        Console.WriteLine("Non Coded Item ID: " + Data.ItemBase[uItemID.ID].ID + " Name: " + Data.ItemBase[uItemID.ID].Name + "");
                    }
                }
                // Close our packet reader
                Reader.Close();
            }
            catch (Exception ex)
            {
                Console.WriteLine("Item usage error {0}", ex);
                Systems.Debugger.Write(ex);
            }
        }
示例#21
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);
     }
 }
示例#22
0
 /////////////////////////////////////////////////////////////////////////////////
 // Move item to storage
 /////////////////////////////////////////////////////////////////////////////////
 void Player_MoveItemToStorage(byte f_slot, byte t_slot, int o_id)
 {
     #region Move item to storage
     try
     {
         //Check if the user isnt in any state/action that we will not allow.
         if (Character.State.Die)
         {
             return;
         }
         if (Character.Stall.Stallactive)
         {
             return;
         }
         if (Character.Alchemy.working)
         {
             return;
         }
         if (Character.Position.Walking)
         {
             return;
         }
         //Normal storage
         if (!Character.Network.Guild.UsingStorage)
         {
             //Get item information
             Global.slotItem item = GetItem((uint)Character.Information.CharacterID, f_slot, 0);
             //Get storage price of the item
             int storageprice = Data.ItemBase[item.ID].Storage_price;
             //Set amount if its only 1
             if (item.Amount == 0)
             {
                 item.Amount = 1;
             }
             //Multiply the price, per amount
             storageprice *= item.Amount;
             //Anti hack check make sure that the owner of the item is correct
             int ownerid = Convert.ToInt32(MsSQL.GetData("SELECT * FROM char_items WHERE id='" + item.dbID + "'", "owner"));
             //Check if the owner really owns the item.
             if (ownerid == Character.Information.CharacterID)
             {
                 //Make sure the stack count is equal or lower then max stack amount
                 if (item.Amount <= Data.ItemBase[item.ID].Max_Stack)
                 {
                     //If the user has enough gold (Equally or higher to storage price).
                     if (Character.Information.Gold >= storageprice)
                     {
                         //Set character gold
                         Character.Information.Gold -= storageprice;
                         //Send update packet for gold
                         client.Send(Packet.UpdateGold(Character.Information.Gold));
                         //Update mssql database information
                         MsSQL.UpdateData("UPDATE char_items SET itemnumber='item" + t_slot + "',slot='" + t_slot + "',storagetype='1' WHERE storageacc='" + Player.ID + "' AND id='" + item.dbID + "'");
                         //Send visual move packet to player
                         client.Send(Packet.MoveItem(2, f_slot, t_slot, 0, 0, "MOVE_TO_STORAGE"));
                         //Save the player gold
                         SaveGold();
                     }
                     //If the user does not have enough gold
                     else
                     {
                         client.Send(Packet.IngameMessages(SERVER_ITEM_MOVE, IngameMessages.UIIT_MSG_STRGERR_NOT_ENOUGH_GOLD));
                     }
                 }
                 //This should not happen but if the stack is to high.
                 else
                 {
                     return;
                 }
             }
             //If the player is not the item owner (Hacking attempt).
             else
             {
                 Disconnect("ban");
                 Console.WriteLine("Autobanned user: "******" Due to hacking");
             }
         }
         //Guild storage
         else
         {
             //Get item information
             Global.slotItem item = GetItem((uint)Character.Information.CharacterID, f_slot, 0);
             //Get storage price of the item
             int storageprice = Data.ItemBase[item.ID].Storage_price;
             //Set amount if its only 1
             if (item.Amount == 0)
             {
                 item.Amount = 1;
             }
             //Multiply the price, per amount
             storageprice *= item.Amount;
             //Anti hack check make sure that the owner of the item is correct
             int ownerid = Convert.ToInt32(MsSQL.GetData("SELECT * FROM char_items WHERE id='" + item.dbID + "'", "owner"));
             //Check if the owner really owns the item.
             if (ownerid == Character.Information.CharacterID)
             {
                 //Make sure the stack count is equal or lower then max stack amount
                 if (item.Amount <= Data.ItemBase[item.ID].Max_Stack)
                 {
                     //If the user has enough gold (Equally or higher to storage price).
                     if (Character.Information.Gold >= storageprice)
                     {
                         //Set character gold
                         Character.Information.Gold -= storageprice;
                         //Send update packet for gold
                         client.Send(Packet.UpdateGold(Character.Information.Gold));
                         //Update mssql database information
                         MsSQL.UpdateData("UPDATE char_items SET itemnumber='item" + t_slot + "',slot='" + t_slot + "',storagetype='3' ,guild_storage_id='" + Character.Network.Guild.Guildid + "' WHERE id='" + item.dbID + "'");
                         //Send visual move packet to player
                         client.Send(Packet.MoveItem(2, f_slot, t_slot, 0, 0, "MOVE_TO_GUILD_STORAGE"));
                         //Save the player gold
                         SaveGold();
                     }
                     //If the user does not have enough gold
                     else
                     {
                         client.Send(Packet.IngameMessages(SERVER_ITEM_MOVE, IngameMessages.UIIT_MSG_STRGERR_NOT_ENOUGH_GOLD));
                     }
                 }
                 //This should not happen but if the stack is to high.
                 else
                 {
                     return;
                 }
             }
             //If the player is not the item owner (Hacking attempt).
             else
             {
                 Disconnect("ban");
                 Console.WriteLine("Autobanned user: "******" Due to hacking");
             }
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine("Storage move error : {0}", ex);
         Systems.Debugger.Write(ex);
     }
     //Save player information
     SavePlayerInfo();
     #endregion
 }
示例#23
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);
     }
 }
示例#24
0
 void HandleUpdateSlotChange(byte slot, Global.slotItem item, int packet)
 {
     MsSQL.UpdateData("UPDATE char_items SET itemid='" + packet + "' WHERE owner='" + Character.Information.CharacterID + "' AND itemnumber='item" + item.Slot + "' AND id='" + item.dbID + "'");
     //Need to be defined per item type (potion or private item)
     Send(Packet.Player_HandleEffect(Character.Information.UniqueID, item.ID));
 }
示例#25
0
        /////////////////////////////////////////////////////////////////////////////////
        // Move inside Storages
        /////////////////////////////////////////////////////////////////////////////////
        void ItemMoveInStorage(byte fromSlot, byte toSlot, short quantity)
        {
            #region Move Inside Storage
            try
            {
                //Get item information of selected item
                Global.slotItem fromItem = GetItem((uint)Character.Information.CharacterID, fromSlot, 1);
                //Check item where we are moving to
                Global.slotItem toItem = GetItem((uint)Character.Information.CharacterID, toSlot, 1);
                //If the slot where we are moving to has an item

                //Check what type of storage we use.
                int storagetype = 1;
                //Set storage type
                if (Character.Network.Guild.UsingStorage)
                {
                    storagetype = 3;
                }
                if (!Character.Network.Guild.UsingStorage)
                {
                    if (toItem.ID != 0)
                    {
                        //Visual packet
                        client.Send(Packet.MoveItem(0, toSlot, fromSlot, quantity, 0, "MOVE_INSIDE_STORAGE"));
                        //First we update database with the 2 items (From item).
                        MsSQL.UpdateData("UPDATE char_items SET itemnumber='item" + toSlot + "',slot='" + toSlot + "' WHERE itemnumber='" + "item" + fromSlot + "' AND owner='" + Player.ID + "' AND itemid='" + fromItem.ID + "' AND id='" + fromItem.dbID + "' AND storagetype='" + storagetype + "'");
                        //To item database update
                        MsSQL.UpdateData("UPDATE char_items SET itemnumber='item" + fromSlot + "',slot='" + fromSlot + "' WHERE itemnumber='" + "item" + toSlot + "' AND owner='" + Player.ID + "' AND itemid='" + toItem.ID + "' AND id='" + toItem.dbID + "' AND storagetype='" + storagetype + "'");
                    }
                    else
                    {
                        client.Send(Packet.MoveItem(0, fromSlot, toSlot, quantity, 0, "MOVE_INSIDE_STORAGE"));
                        MsSQL.UpdateData("UPDATE char_items SET itemnumber='item" + toSlot + "',slot='" + toSlot + "' WHERE itemnumber='" + "item" + fromSlot + "' AND owner='" + Player.ID + "' AND itemid='" + fromItem.ID + "' AND storagetype='" + storagetype + "'");
                    }
                }
                //Guild storage
                else
                {
                    fromItem = GetItem((uint)Character.Information.CharacterID, fromSlot, 3);
                    //Check item where we are moving to
                    toItem = GetItem((uint)Character.Information.CharacterID, toSlot, 3);

                    if (toItem.ID != 0)
                    {
                        //Visual packet
                        client.Send(Packet.MoveItem(0, toSlot, fromSlot, quantity, 0, "MOVE_INSIDE_GUILD_STORAGE"));
                        //First we update database with the 2 items (From item).
                        MsSQL.UpdateData("UPDATE char_items SET itemnumber='item" + toSlot + "',slot='" + toSlot + "' WHERE itemnumber='" + "item" + fromSlot + "' AND guild_storage_id='" + Character.Network.Guild.Guildid + "' AND itemid='" + fromItem.ID + "' AND id='" + fromItem.dbID + "' AND storagetype='" + storagetype + "'");
                        //To item database update
                        MsSQL.UpdateData("UPDATE char_items SET itemnumber='item" + fromSlot + "',slot='" + fromSlot + "' WHERE itemnumber='" + "item" + toSlot + "' AND guild_storage_id='" + Character.Network.Guild.Guildid + "' AND itemid='" + toItem.ID + "' AND id='" + toItem.dbID + "' AND storagetype='" + storagetype + "'");
                    }
                    else
                    {
                        client.Send(Packet.MoveItem(0, fromSlot, toSlot, quantity, 0, "MOVE_INSIDE_GUILD_STORAGE"));
                        MsSQL.UpdateData("UPDATE char_items SET itemnumber='item" + toSlot + "',slot='" + toSlot + "' WHERE itemnumber='" + "item" + fromSlot + "' AND guild_storage_id='" + Character.Network.Guild.Guildid + "' AND itemid='" + fromItem.ID + "' AND storagetype='" + storagetype + "'");
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Move inside storage error {0}", ex);
                Systems.Debugger.Write(ex);
            }
            //Save player information
            SavePlayerInfo();
            #endregion
        }
示例#26
0
        /////////////////////////////////////////////////////////////////////////////////
        // Create stones
        /////////////////////////////////////////////////////////////////////////////////
        public void AlchemyCreateStone()
        {
            try
            {
                //Open packet reader
                PacketReader reader       = new PacketReader(PacketInformation.buffer);
                byte         type         = reader.Byte();
                byte         type1        = reader.Byte();
                byte         type2        = reader.Byte();
                byte         tabletslot   = reader.Byte();
                byte         elementslot1 = reader.Byte();
                byte         elementslot2 = reader.Byte();
                byte         elementslot3 = reader.Byte();
                byte         elementslot4 = reader.Byte();
                reader.Close();

                //Tablet information
                Global.slotItem tabletslotitem = GetItem((uint)Character.Information.CharacterID, tabletslot, 0);

                //Get stone information equaly to the tablet
                int stone = GetStoneFromTablet(tabletslotitem.ID);

                //Earth element information
                Global.slotItem element1slotitem = GetItem((uint)Character.Information.CharacterID, elementslot1, 0);
                //Water element information
                Global.slotItem element2slotitem = GetItem((uint)Character.Information.CharacterID, elementslot2, 0);
                //Fire element information
                Global.slotItem element3slotitem = GetItem((uint)Character.Information.CharacterID, elementslot3, 0);
                //Wind element information
                Global.slotItem element4slotitem = GetItem((uint)Character.Information.CharacterID, elementslot4, 0);

                //Check if the requirements are ok (Extra check amount).
                if (element1slotitem.Amount < Data.ItemBase[tabletslotitem.ID].EARTH_ELEMENTS_AMOUNT_REQ)
                {
                    return;
                }
                if (element2slotitem.Amount < Data.ItemBase[tabletslotitem.ID].WATER_ELEMENTS_AMOUNT_REQ)
                {
                    return;
                }
                if (element3slotitem.Amount < Data.ItemBase[tabletslotitem.ID].FIRE_ELEMENTS_AMOUNT_REQ)
                {
                    return;
                }
                if (element2slotitem.Amount < Data.ItemBase[tabletslotitem.ID].WIND_ELEMENTS_AMOUNT_REQ)
                {
                    return;
                }

                //Check if the requirements are ok (Extra check element name).
                if (Data.ItemBase[element1slotitem.ID].Name != Data.ItemBase[tabletslotitem.ID].EARTH_ELEMENTS_NAME)
                {
                    return;
                }
                if (Data.ItemBase[element2slotitem.ID].Name != Data.ItemBase[tabletslotitem.ID].WATER_ELEMENTS_NAME)
                {
                    return;
                }
                if (Data.ItemBase[element3slotitem.ID].Name != Data.ItemBase[tabletslotitem.ID].FIRE_ELEMENTS_NAME)
                {
                    return;
                }
                if (Data.ItemBase[element4slotitem.ID].Name != Data.ItemBase[tabletslotitem.ID].WIND_ELEMENTS_NAME)
                {
                    return;
                }

                //Update amount of elements
                element1slotitem.Amount -= (short)Data.ItemBase[tabletslotitem.ID].EARTH_ELEMENTS_AMOUNT_REQ;
                element2slotitem.Amount -= (short)Data.ItemBase[tabletslotitem.ID].WATER_ELEMENTS_AMOUNT_REQ;
                element3slotitem.Amount -= (short)Data.ItemBase[tabletslotitem.ID].FIRE_ELEMENTS_AMOUNT_REQ;
                element4slotitem.Amount -= (short)Data.ItemBase[tabletslotitem.ID].WIND_ELEMENTS_AMOUNT_REQ;

                ItemUpdateAmount(element1slotitem, Character.Information.CharacterID);
                ItemUpdateAmount(element2slotitem, Character.Information.CharacterID);
                ItemUpdateAmount(element3slotitem, Character.Information.CharacterID);
                ItemUpdateAmount(element4slotitem, Character.Information.CharacterID);

                //Update amount of tablet
                tabletslotitem.Amount -= 1;
                ItemUpdateAmount(tabletslotitem, Character.Information.CharacterID);

                //Send alchemy packet
                client.Send(Packet.StoneCreation(tabletslot));

                //Check for new free slots in inventory
                byte freeslot = GetFreeSlot();
                //Update database and insert new item
                AddItem(stone, 1, freeslot, Character.Information.CharacterID, 0);
                //Send visual packet add stone (creation works, just need to check why it sends 2x same packet).
                client.Send(Packet.GainElements(freeslot, stone, 1));
            }
            catch (Exception ex)
            {
                Console.WriteLine("Stone creation error {0}", ex);
                Systems.Debugger.Write(ex);
            }
        }
示例#27
0
        /////////////////////////////////////////////////////////////////////////////////
        // Get Slot Item Information
        /////////////////////////////////////////////////////////////////////////////////
        static Global.slotItem GetItem(uint id, byte slot, int type)
        {
            #region Slot item info

            try
            {
                if (id != 0)
                {
                    Global.slotItem slotItem = new Global.slotItem();
                    int row = type;

                    MsSQL ms;
                    if (row == 1)
                    {
                        ms = new MsSQL("SELECT * FROM char_items WHERE itemnumber='item" + slot + "' AND storageacc='" + id + "' AND storagetype='" + row + "' AND slot='" + slot + "'");
                    }
                    else if (row == 3)
                    {
                        ms = new MsSQL("SELECT * FROM char_items WHERE itemnumber='item" + slot + "' AND storagetype='" + row + "' AND slot='" + slot + "'");
                    }
                    else
                    {
                        ms = new MsSQL("SELECT * FROM char_items WHERE itemnumber='item" + slot + "' AND owner='" + id + "' AND storagetype='" + row + "' AND slot='" + slot + "'");
                    }

                    using (System.Data.SqlClient.SqlDataReader reader = ms.Read())
                    {
                        while (reader.Read())
                        {
                            slotItem.dbID = reader.GetInt32(0);
                            slotItem.ID = reader.GetInt32(2);
                            slotItem.PlusValue = reader.GetByte(4);
                            slotItem.Amount = reader.GetInt16(6);
                            slotItem.Durability = reader.GetInt32(7);
                            slotItem.Slot = slot;
                            LoadBluesid(slotItem.dbID);
                        }
                    }
                    ms.Close();
                    return slotItem;
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Data item load error {0}", ex);
                Systems.Debugger.Write(ex);
            }
            return null;
            #endregion
        }
示例#28
0
 /////////////////////////////////////////////////////////////////////////////////
 // Slot update packet
 /////////////////////////////////////////////////////////////////////////////////
 void GetUpdateSlot(Global.slotItem item, byte toSlot, int toItemID, short quantity)
 {
     #region Send item move packet
     client.Send(Packet.MoveItem(0, item.Slot, toSlot, quantity, 0, "MOVE_INSIDE_INVENTORY"));
     #endregion
 }
示例#29
0
        /////////////////////////////////////////////////////////////////////////////////
        // Item destruction with alchemy
        /////////////////////////////////////////////////////////////////////////////////
        public void BreakItem()
        {
            try
            {
                //Checks before we continue
                if (Character.Stall.Stallactive || Character.Action.nAttack || Character.Action.sAttack || Character.Alchemy.working)
                {
                    return;
                }
                //Set bool
                Character.Alchemy.working = true;
                //TODO: Timer for alchemy start / end
                PacketReader reader        = new PacketReader(PacketInformation.buffer);
                byte         rondorequired = reader.Byte();
                byte         slot          = reader.Byte();
                reader.Close();


                //Get our item information (item)
                Global.slotItem item = GetItem((uint)Character.Information.CharacterID, slot, 0);

                //Get our degree information
                byte itemdegree = Data.ItemBase[item.ID].Degree;

                //First we get our elements (Same degree as weapon)
                //This should return 4 items
                //Add check rondo count if high enough.
                Character.Alchemy.Elementlist = GetDegreeElements(item.ID, Character);
                //Check if the item has any blues on it.
                if (Data.ItemBlue[item.dbID].totalblue != 0)
                {
                    Character.Alchemy.StonesList = GetStonesDegree(item.ID, Character);
                }

                //Check current free slots of the player
                byte slotcheck = GetFreeSlot();
                //If slot amount is lower then 4 return
                //Slots free must be 6 i believe because of stones (TODO: Check info official).
                if (slotcheck < 4)
                {
                    //Send error message inventory full ...
                    return;
                }
                //Player has enough slots so we continue adding the new items
                else
                {
                    //Update rondo quantity
                    Character.Information.InventorylistSlot = GetPlayerItems(Character);
                    foreach (byte e in Character.Information.InventorylistSlot)
                    {
                        //Set slotitem
                        Global.slotItem itemrondoinfo = GetItem((uint)Character.Information.CharacterID, e, 0);
                        if (itemrondoinfo.ID != 0)
                        {
                            if (Data.ItemBase[itemrondoinfo.ID].Etctype == Global.item_database.EtcType.DESTROYER_RONDO)
                            {
                                //Update amount
                                itemrondoinfo.Amount -= rondorequired;
                                ItemUpdateAmount(itemrondoinfo, Character.Information.CharacterID);
                            }
                        }
                    }
                    //Clean our list
                    Character.Information.InventorylistSlot.Clear();
                    //Remove the item used in dissembling (Query).
                    MsSQL.DeleteData("DELETE FROM char_items WHERE id='" + item.dbID + "' AND owner='" + Character.Information.CharacterID + "'");
                    //Remove the item used in dissembling (Visual).
                    ItemUpdateAmount(item, Character.Information.CharacterID);
                    //Send packet #2
                    client.Send(Packet.DestroyItem());
                    //Repeat for each element in our list.
                    foreach (int e in Character.Alchemy.Elementlist)
                    {
                        if (e != 0)
                        {
                            //TODO: Make detailed randoms
                            //Make random add count for the elements
                            //NOTE: Check what item has what element on destruction. if pk2 contains or not.
                            int elementamount = 0;

                            #region Amounts
                            if (Data.ItemBase[item.ID].Degree == 1)
                            {
                                elementamount = rnd.Next(1, 60);
                            }
                            else if (Data.ItemBase[item.ID].Degree == 2)
                            {
                                elementamount = rnd.Next(1, 90);
                            }
                            else if (Data.ItemBase[item.ID].Degree == 3)
                            {
                                elementamount = rnd.Next(1, 120);
                            }
                            else if (Data.ItemBase[item.ID].Degree == 4)
                            {
                                elementamount = rnd.Next(1, 150);
                            }
                            else if (Data.ItemBase[item.ID].Degree == 5)
                            {
                                elementamount = rnd.Next(1, 200);
                            }
                            else if (Data.ItemBase[item.ID].Degree == 6)
                            {
                                elementamount = rnd.Next(1, 250);
                            }
                            else if (Data.ItemBase[item.ID].Degree == 7)
                            {
                                elementamount = rnd.Next(1, 300);
                            }
                            else if (Data.ItemBase[item.ID].Degree == 8)
                            {
                                elementamount = rnd.Next(1, 375);
                            }
                            else if (Data.ItemBase[item.ID].Degree == 9)
                            {
                                elementamount = rnd.Next(1, 450);
                            }
                            else if (Data.ItemBase[item.ID].Degree == 10)
                            {
                                elementamount = rnd.Next(1, 600);
                            }
                            else if (Data.ItemBase[item.ID].Degree == 11)
                            {
                                elementamount = rnd.Next(1, 800);
                            }
                            #endregion

                            int stoneamount = 0;

                            #region Stones
                            if (Data.ItemBlue[item.dbID].totalblue != 0)
                            {
                                if (Data.ItemBlue[item.dbID].totalblue == 1)
                                {
                                    stoneamount = rnd.Next(0, 1);
                                }
                                else if (Data.ItemBlue[item.dbID].totalblue == 2)
                                {
                                    stoneamount = rnd.Next(0, 2);
                                }
                            }
                            #endregion

                            slotcheck = GetFreeSlot();
                            //Stack items todo
                            AddItem(Data.ItemBase[e].ID, 10, slotcheck, Character.Information.CharacterID, 0);
                            client.Send(Packet.GainElements(slotcheck, Data.ItemBase[e].ID, (short)elementamount));
                        }
                    }
                    //Clear created list content.
                    Character.Alchemy.Elementlist.Clear();
                }
                //Reset bool
                Character.Alchemy.working = false;
            }
            catch (Exception ex)
            {
                Console.WriteLine("Alchemy error destroyer {0}", ex);
            }
        }