Наследование: WearableInstance, ISpecialistInstance
        public static ItemInstance CreateItemInstance(short vnum)
        {
            ItemInstance iteminstance = new ItemInstance()
            {
                ItemVNum = vnum, Amount = 1
            };

            if (iteminstance.Item != null)
            {
                switch (iteminstance.Item.Type)
                {
                case (byte)InventoryType.Wear:
                    if (iteminstance.Item.ItemType == (byte)ItemType.Specialist)
                    {
                        iteminstance = new SpecialistInstance()
                        {
                            ItemVNum = vnum, SpLevel = 1, Amount = 1
                        };
                    }
                    else
                    {
                        iteminstance = new WearableInstance()
                        {
                            ItemVNum = vnum, Amount = 1
                        };
                    }
                    break;
                }
            }
            return(iteminstance);
        }
Пример #2
0
        public static ItemInstance InstantiateItemInstance(short vnum, long ownerId, byte amount = 1)
        {
            ItemInstance newItem = new ItemInstance()
            {
                ItemVNum = vnum, Amount = amount, CharacterId = ownerId
            };

            if (newItem.Item != null)
            {
                switch (newItem.Item.Type)
                {
                case InventoryType.Equipment:
                    if (newItem.Item.ItemType == ItemType.Specialist)
                    {
                        newItem = new SpecialistInstance()
                        {
                            ItemVNum = vnum, SpLevel = 1, Amount = amount
                        };
                    }
                    else
                    {
                        newItem = new WearableInstance()
                        {
                            ItemVNum = vnum, Amount = amount
                        };
                    }
                    break;
                }
            }

            // set default itemType
            newItem.Type = newItem.Item.Type;

            return(newItem);
        }
Пример #3
0
        public override void Use(ClientSession Session, ref Inventory Inv)
        {
            switch (Effect)
            {
            case 650:     //wings

                if (Session.Character.UseSp)
                {
                    Item iteminfo = ServerManager.GetItem(Inv.ItemInstance.ItemVNum);
                    SpecialistInstance specialistInstance = Session.Character.EquipmentList.LoadBySlotAndType <SpecialistInstance>((byte)EquipmentType.Sp, (byte)InventoryType.Equipment);
                    specialistInstance.Design       = (byte)iteminfo.EffectValue; // change item design in instance
                    Session.Character.MorphUpgrade2 = iteminfo.EffectValue;       // change item design in session
                    Session.Client.SendPacket(Session.Character.GenerateCMode());
                    Session.Client.SendPacket(Session.Character.GenerateStat());
                    Session.Client.SendPacket(Session.Character.GenerateStatChar());
                    Inv.ItemInstance.Amount--;     // subtract item amount
                    if (Inv.ItemInstance.Amount > 0)
                    {
                        Session.Client.SendPacket(Session.Character.GenerateInventoryAdd(Inv.ItemInstance.ItemVNum, Inv.ItemInstance.Amount, Inv.Type, Inv.Slot, 0, 0, 0, 0));
                    }
                    else
                    {
                        Session.Character.InventoryList.DeleteFromSlotAndType(Inv.Slot, Inv.Type);
                        Session.Client.SendPacket(Session.Character.GenerateInventoryAdd(-1, 0, Inv.Type, Inv.Slot, 0, 0, 0, 0));
                    }
                }
                else
                {
                    Session.Client.SendPacket(Session.Character.GenerateMsg(Language.Instance.GetMessageFromKey("NO_SP"), 0));
                }
                break;

            default:
                //Item iteminfo = ServerManager.GetItem(Inv.ItemInstance.ItemVNum);
                //if (iteminfo.Morph != 0 && iteminfo.Speed != 0)
                //{
                //    if (Session.Character.IsVehicled == false)
                //    {
                //        Session.Client.SendPacket($"delay 3000 3 #u_i^1^{Session.Character.CharacterId}^{Inv.Type}^{Inv.Slot}^2");
                //        Session.Character.IsVehicled = true;
                //        Session.Client.SendPacket("pinit 0");
                //        Session.CurrentMap?.Broadcast(Session.Character.GenerateCMode());
                //        // change speed
                //        Session.Client.SendPacket(Session.Character.GenerateCond());
                //    }
                //    else
                //    {
                //        Session.Client.SendPacket("pinit 0");
                //        Session.CurrentMap?.Broadcast(Session.Character.GenerateCMode());
                //        // revert speed change
                //        Session.Client.SendPacket(Session.Character.GenerateCond());
                //    }
                //}
                Logger.Log.Warn(String.Format(Language.Instance.GetMessageFromKey("NO_HANDLER_ITEM"), this.GetType().ToString()));
                break;
            }
        }
Пример #4
0
        public string GenerateStashPacket()
        {
            string packet = $"{Slot}.{ItemVNum}.{(byte)Item.Type}";

            switch (Item.Type)
            {
            case InventoryType.Equipment:
                return(packet + $".{Amount}.{Rare}.{Upgrade}");

            case InventoryType.Specialist:
                SpecialistInstance sp = this as SpecialistInstance;
                return(packet + $".{Upgrade}.{sp?.SpStoneUpgrade ?? 0}.0");

            default:
                return(packet + $".{Amount}.0.0");
            }
        }
Пример #5
0
        public void PerfectSP(ClientSession Session, UpgradeProtection protect)
        {
            short[] upsuccess = { 50, 40, 30, 20, 10 };

            int[]   goldprice  = { 5000, 10000, 20000, 50000, 100000 };
            short[] stoneprice = { 1, 2, 3, 4, 5 };
            short   stonevnum;
            byte    upmode = 1;

            switch (this.Item.Morph)
            {
            case 2:
                stonevnum = 2514;
                break;

            case 6:
                stonevnum = 2514;
                break;

            case 9:
                stonevnum = 2514;
                break;

            case 12:
                stonevnum = 2514;
                break;

            case 3:
                stonevnum = 2515;
                break;

            case 4:
                stonevnum = 2515;
                break;

            case 14:
                stonevnum = 2515;
                break;

            case 5:
                stonevnum = 2516;
                break;

            case 11:
                stonevnum = 2516;
                break;

            case 15:
                stonevnum = 2516;
                break;

            case 10:
                stonevnum = 2517;
                break;

            case 13:
                stonevnum = 2517;
                break;

            case 7:
                stonevnum = 2517;
                break;

            case 17:
                stonevnum = 2518;
                break;

            case 18:
                stonevnum = 2518;
                break;

            case 19:
                stonevnum = 2518;
                break;

            case 20:
                stonevnum = 2519;
                break;

            case 21:
                stonevnum = 2519;
                break;

            case 22:
                stonevnum = 2519;
                break;

            case 23:
                stonevnum = 2520;
                break;

            case 24:
                stonevnum = 2520;
                break;

            case 25:
                stonevnum = 2520;
                break;

            case 26:
                stonevnum = 2521;
                break;

            case 27:
                stonevnum = 2521;
                break;

            case 28:
                stonevnum = 2521;
                break;

            default:
                return;
            }
            if (this.SpStoneUpgrade > 99)
            {
                return;
            }
            else if (this.SpStoneUpgrade > 80)
            {
                upmode = 5;
            }
            else if (this.SpStoneUpgrade > 60)
            {
                upmode = 4;
            }
            else if (this.SpStoneUpgrade > 40)
            {
                upmode = 3;
            }
            else if (this.SpStoneUpgrade > 20)
            {
                upmode = 2;
            }

            if (this.IsFixed)
            {
                return;
            }
            if (Session.Character.Gold < goldprice[upmode - 1])
            {
                return;
            }
            if (Session.Character.Inventory.CountItem(stonevnum) < stoneprice[upmode - 1])
            {
                return;
            }

            SpecialistInstance specialist = Session.Character.Inventory.LoadByItemInstance <SpecialistInstance>(this.Id);

            int rnd = _random.Next(100);

            if (rnd <= upsuccess[upmode - 1])
            {
                byte type = (byte)_random.Next(16), count = 1;
                if (upmode == 4)
                {
                    count = 2;
                }
                if (upmode == 5)
                {
                    count = (byte)_random.Next(3, 6);
                }

                ServerManager.Instance.Broadcast(Session.Character.GenerateEff(3005), Session.Character.MapX, Session.Character.MapY);

                if (type < 3)
                {
                    specialist.SpDamage += count;
                    Session.SendPacket(Session.Character.GenerateSay(String.Format(Language.Instance.GetMessageFromKey("PERFECTSP_SUCCESS"), Language.Instance.GetMessageFromKey("PERFECTSP_ATTACK"), count), 12));
                    Session.SendPacket(Session.Character.GenerateMsg(String.Format(Language.Instance.GetMessageFromKey("PERFECTSP_SUCCESS"), Language.Instance.GetMessageFromKey("PERFECTSP_ATTACK"), count), 0));
                }
                else if (type < 6)
                {
                    specialist.SpDefence += count;
                    Session.SendPacket(Session.Character.GenerateSay(String.Format(Language.Instance.GetMessageFromKey("PERFECTSP_SUCCESS"), Language.Instance.GetMessageFromKey("PERFECTSP_DEFENSE"), count), 12));
                    Session.SendPacket(Session.Character.GenerateMsg(String.Format(Language.Instance.GetMessageFromKey("PERFECTSP_SUCCESS"), Language.Instance.GetMessageFromKey("PERFECTSP_DEFENSE"), count), 0));
                }
                else if (type < 9)
                {
                    specialist.SpElement += count;
                    Session.SendPacket(Session.Character.GenerateSay(String.Format(Language.Instance.GetMessageFromKey("PERFECTSP_SUCCESS"), Language.Instance.GetMessageFromKey("PERFECTSP_ELEMENT"), count), 12));
                    Session.SendPacket(Session.Character.GenerateMsg(String.Format(Language.Instance.GetMessageFromKey("PERFECTSP_SUCCESS"), Language.Instance.GetMessageFromKey("PERFECTSP_ELEMENT"), count), 0));
                }
                else if (type < 12)
                {
                    specialist.SpHP += count;
                    Session.SendPacket(Session.Character.GenerateSay(String.Format(Language.Instance.GetMessageFromKey("PERFECTSP_SUCCESS"), Language.Instance.GetMessageFromKey("PERFECTSP_HPMP"), count), 12));
                    Session.SendPacket(Session.Character.GenerateMsg(String.Format(Language.Instance.GetMessageFromKey("PERFECTSP_SUCCESS"), Language.Instance.GetMessageFromKey("PERFECTSP_HPMP"), count), 0));
                }
                else if (type == 12)
                {
                    specialist.SpFire += count;
                    Session.SendPacket(Session.Character.GenerateSay(String.Format(Language.Instance.GetMessageFromKey("PERFECTSP_SUCCESS"), Language.Instance.GetMessageFromKey("PERFECTSP_FIRE"), count), 12));
                    Session.SendPacket(Session.Character.GenerateMsg(String.Format(Language.Instance.GetMessageFromKey("PERFECTSP_SUCCESS"), Language.Instance.GetMessageFromKey("PERFECTSP_FIRE"), count), 0));
                }
                else if (type == 13)
                {
                    specialist.SpWater += count;
                    Session.SendPacket(Session.Character.GenerateSay(String.Format(Language.Instance.GetMessageFromKey("PERFECTSP_SUCCESS"), Language.Instance.GetMessageFromKey("PERFECTSP_WATER"), count), 12));
                    Session.SendPacket(Session.Character.GenerateMsg(String.Format(Language.Instance.GetMessageFromKey("PERFECTSP_SUCCESS"), Language.Instance.GetMessageFromKey("PERFECTSP_WATER"), count), 0));
                }
                else if (type == 14)
                {
                    specialist.SpLight += count;
                    Session.SendPacket(Session.Character.GenerateSay(String.Format(Language.Instance.GetMessageFromKey("PERFECTSP_SUCCESS"), Language.Instance.GetMessageFromKey("PERFECTSP_LIGHT"), count), 12));
                    Session.SendPacket(Session.Character.GenerateMsg(String.Format(Language.Instance.GetMessageFromKey("PERFECTSP_SUCCESS"), Language.Instance.GetMessageFromKey("PERFECTSP_LIGHT"), count), 0));
                }
                else if (type == 15)
                {
                    specialist.SpDark += count;
                    Session.SendPacket(Session.Character.GenerateSay(String.Format(Language.Instance.GetMessageFromKey("PERFECTSP_SUCCESS"), Language.Instance.GetMessageFromKey("PERFECTSP_SHADOW"), count), 12));
                    Session.SendPacket(Session.Character.GenerateMsg(String.Format(Language.Instance.GetMessageFromKey("PERFECTSP_SUCCESS"), Language.Instance.GetMessageFromKey("PERFECTSP_SHADOW"), count), 0));
                }
                specialist.SpStoneUpgrade++;
            }
            else
            {
                Session.SendPacket(Session.Character.GenerateSay(Language.Instance.GetMessageFromKey("PERFECTSP_FAILURE"), 11));
                Session.SendPacket(Session.Character.GenerateMsg(Language.Instance.GetMessageFromKey("PERFECTSP_FAILURE"), 0));
            }
            Session.Character.Gold -= goldprice[upmode - 1];
            Session.SendPacket(Session.Character.GenerateGold());
            Session.Character.Inventory.RemoveItemAmount(stonevnum, stoneprice[upmode - 1]);
            Session.SendPacket("shop_end 1");
        }
Пример #6
0
        public override void Use(ClientSession session, ref ItemInstance inv, bool delay = false, string[] packetsplit = null)
        {
            switch (Effect)
            {
            // sp point potions
            case 150:
            case 151:
                session.Character.SpAdditionPoint += EffectValue;
                if (session.Character.SpAdditionPoint > 1000000)
                {
                    session.Character.SpAdditionPoint = 1000000;
                }
                session.SendPacket(session.Character.GenerateMsg(String.Format(Language.Instance.GetMessageFromKey("SP_POINTSADDED"), EffectValue), 0));
                session.Character.Inventory.RemoveItemAmountFromInventory(1, inv.Id);
                session.SendPacket(session.Character.GenerateSpPoint());
                break;

            case 204:
                session.Character.SpPoint         += EffectValue;
                session.Character.SpAdditionPoint += EffectValue * 3;
                if (session.Character.SpAdditionPoint > 1000000)
                {
                    session.Character.SpAdditionPoint = 1000000;
                }
                if (session.Character.SpPoint > 10000)
                {
                    session.Character.SpPoint = 10000;
                }
                session.SendPacket(session.Character.GenerateMsg(String.Format(Language.Instance.GetMessageFromKey("SP_POINTSADDEDBOTH"), EffectValue, EffectValue * 3), 0));
                session.Character.Inventory.RemoveItemAmountFromInventory(1, inv.Id);
                session.SendPacket(session.Character.GenerateSpPoint());
                break;

            // wings
            case 650:
                SpecialistInstance specialistInstance = session.Character.Inventory.LoadBySlotAndType <SpecialistInstance>((byte)EquipmentType.Sp, InventoryType.Wear);
                if (session.Character.UseSp && specialistInstance != null)
                {
                    if (!delay)
                    {
                        session.SendPacket($"qna #u_i^1^{session.Character.CharacterId}^{(byte)inv.Type}^{inv.Slot}^3 {Language.Instance.GetMessageFromKey("ASK_WINGS_CHANGE")}");
                    }
                    else
                    {
                        specialistInstance.Design       = (byte)EffectValue;
                        session.Character.MorphUpgrade2 = EffectValue;
                        session.CurrentMap?.Broadcast(session.Character.GenerateCMode());
                        session.SendPacket(session.Character.GenerateStat());
                        session.SendPacket(session.Character.GenerateStatChar());
                        session.Character.Inventory.RemoveItemAmountFromInventory(1, inv.Id);
                    }
                }
                else
                {
                    session.SendPacket(session.Character.GenerateMsg(Language.Instance.GetMessageFromKey("NO_SP"), 0));
                }
                break;

            // presentation messages
            case 203:
                if (this != null && !session.Character.IsVehicled)
                {
                    if (!delay)
                    {
                        session.SendPacket(session.Character.GenerateGuri(10, 2, 1));
                    }
                }
                break;

            // magic lamps
            case 651:
                if (!session.Character.Inventory.GetAllItems().Where(i => i.Type == InventoryType.Wear).Any())
                {
                    if (!delay)
                    {
                        session.SendPacket($"qna #u_i^1^{session.Character.CharacterId}^{(byte)inv.Type}^{inv.Slot}^3 {Language.Instance.GetMessageFromKey("ASK_USE")}");
                    }
                    else
                    {
                        session.Character.ChangeSex();
                        session.Character.Inventory.RemoveItemAmountFromInventory(1, inv.Id);
                    }
                }
                else
                {
                    session.SendPacket(session.Character.GenerateMsg(Language.Instance.GetMessageFromKey("EQ_NOT_EMPTY"), 0));
                }
                break;

            // vehicles
            case 1000:
                if (Morph > 0)
                {
                    if (!delay && !session.Character.IsVehicled)
                    {
                        if (session.Character.IsSitting)
                        {
                            session.Character.IsSitting = false;
                            session.CurrentMap?.Broadcast(session.Character.GenerateRest());
                        }
                        session.SendPacket(session.Character.GenerateDelay(3000, 3, $"#u_i^1^{session.Character.CharacterId}^{(byte)inv.Type}^{inv.Slot}^2"));
                    }
                    else
                    {
                        if (!session.Character.IsVehicled)
                        {
                            session.Character.Speed         = Speed;
                            session.Character.IsVehicled    = true;
                            session.Character.VehicleSpeed  = Speed;
                            session.Character.MorphUpgrade  = 0;
                            session.Character.MorphUpgrade2 = 0;
                            session.Character.Morph         = Morph + (byte)session.Character.Gender;
                            session.CurrentMap?.Broadcast(session.Character.GenerateEff(196), session.Character.MapX, session.Character.MapY);
                            session.CurrentMap?.Broadcast(session.Character.GenerateCMode());
                            session.SendPacket(session.Character.GenerateCond());
                        }
                        else
                        {
                            session.Character.RemoveVehicle();
                        }
                    }
                }
                break;

            case 69:
                session.Character.Reput += ReputPrice;
                session.SendPacket(session.Character.GenerateFd());
                session.Character.Inventory.RemoveItemAmountFromInventory(1, inv.Id);
                break;

            default:
                Logger.Log.Warn(String.Format(Language.Instance.GetMessageFromKey("NO_HANDLER_ITEM"), this.GetType().ToString()));
                break;
            }
        }
Пример #7
0
        public override void Use(ClientSession session, ref ItemInstance inv, bool delay = false,
                                 string[] packetsplit = null)
        {
            S_RaidBoxItem rand_item;

            switch (Effect)
            {
            case 0:
                if (VNum == 302)
                {
                    BoxInstance raidBox = session.Character.Inventory.LoadBySlotAndType <BoxInstance>(inv.Slot,
                                                                                                      InventoryType.Equipment);
                    ItemInstance newInv;
                    byte         numberOfItem = 1;
                    switch (raidBox.Design)
                    {
                    case 1:         //XYXY
                        rand_item    = generateRandomRaidBoxItem(xyxy_loots);
                        numberOfItem = rand_item.amount;
                        newInv       = session.Character.Inventory.AddNewToInventory(rand_item.itemvnum,
                                                                                     rand_item.amount);
                        break;

                    case 2:         //CASTRA
                        rand_item    = generateRandomRaidBoxItem(castra_loots);
                        numberOfItem = rand_item.amount;
                        newInv       = session.Character.Inventory.AddNewToInventory(rand_item.itemvnum,
                                                                                     rand_item.amount);
                        break;

                    case 3:         //JACK
                        rand_item    = generateRandomRaidBoxItem(jack_loots);
                        numberOfItem = rand_item.amount;
                        newInv       = session.Character.Inventory.AddNewToInventory(rand_item.itemvnum,
                                                                                     rand_item.amount);
                        break;

                    case 4:         //SLADE
                        rand_item    = generateRandomRaidBoxItem(slade_loots);
                        numberOfItem = rand_item.amount;
                        newInv       = session.Character.Inventory.AddNewToInventory(rand_item.itemvnum,
                                                                                     rand_item.amount);
                        break;

                    case 9:         //IBRAHIM
                        rand_item    = generateRandomRaidBoxItem(ibra_loots);
                        numberOfItem = rand_item.amount;
                        newInv       = session.Character.Inventory.AddNewToInventory(rand_item.itemvnum,
                                                                                     rand_item.amount);
                        break;

                    case 13:         //KERTOS
                        rand_item    = generateRandomRaidBoxItem(kertos_loots);
                        numberOfItem = rand_item.amount;
                        newInv       = session.Character.Inventory.AddNewToInventory(rand_item.itemvnum,
                                                                                     rand_item.amount);
                        break;

                    case 14:         //VALAKUS
                        rand_item    = generateRandomRaidBoxItem(valakus_loots);
                        numberOfItem = rand_item.amount;
                        newInv       = session.Character.Inventory.AddNewToInventory(rand_item.itemvnum,
                                                                                     rand_item.amount);
                        break;

                    case 15:         //GRENIGAS
                        rand_item    = generateRandomRaidBoxItem(grenigas_loots);
                        numberOfItem = rand_item.amount;
                        newInv       = session.Character.Inventory.AddNewToInventory(rand_item.itemvnum,
                                                                                     rand_item.amount);
                        break;

                    case 16:         //DRACO
                        rand_item    = generateRandomRaidBoxItem(draco_loots);
                        numberOfItem = rand_item.amount;
                        newInv       = session.Character.Inventory.AddNewToInventory(rand_item.itemvnum,
                                                                                     rand_item.amount);
                        break;

                    case 17:         //GLAGLA
                        rand_item    = generateRandomRaidBoxItem(glagla_loots);
                        numberOfItem = rand_item.amount;
                        newInv       = session.Character.Inventory.AddNewToInventory(rand_item.itemvnum,
                                                                                     rand_item.amount);
                        break;

                    default:         //CUBY
                        rand_item    = generateRandomRaidBoxItem(cuby_loots);
                        numberOfItem = rand_item.amount;
                        newInv       = session.Character.Inventory.AddNewToInventory(rand_item.itemvnum,
                                                                                     rand_item.amount);
                        break;
                    }
                    if (newInv != null)
                    {
                        dynamic raidBoxItem;
                        if (newInv.Type == InventoryType.Equipment)
                        {
                            if (newInv.Item.EquipmentSlot == EquipmentType.Armor ||
                                newInv.Item.EquipmentSlot == EquipmentType.MainWeapon ||
                                newInv.Item.EquipmentSlot == EquipmentType.SecondaryWeapon)
                            {
                                newInv.Rare = raidBox.Rare;
                                if (newInv.ItemVNum == 4905 || newInv.ItemVNum == 4902 || newInv.ItemVNum == 4908 ||
                                    newInv.ItemVNum == 4917 || newInv.ItemVNum == 4914 || newInv.ItemVNum == 4934 ||
                                    newInv.ItemVNum == 4926 || newInv.ItemVNum == 4920 || newInv.ItemVNum == 4923)
                                {
                                    newInv.Upgrade = 10;
                                }
                            }
                            if (newInv.Item.EquipmentSlot == EquipmentType.Sp)
                            {
                                raidBoxItem =
                                    session.Character.Inventory.LoadBySlotAndType <SpecialistInstance>(newInv.Slot,
                                                                                                       newInv.Type);
                            }
                            else
                            {
                                raidBoxItem =
                                    session.Character.Inventory.LoadBySlotAndType <WearableInstance>(newInv.Slot,
                                                                                                     newInv.Type);
                            }
                            if (raidBoxItem != null &&
                                (raidBoxItem.Item.EquipmentSlot == EquipmentType.Armor ||
                                 raidBoxItem.Item.EquipmentSlot == EquipmentType.MainWeapon ||
                                 raidBoxItem.Item.EquipmentSlot == EquipmentType.SecondaryWeapon))
                            {
                                raidBoxItem.SetRarityPoint();
                            }
                        }
                        else
                        {
                            raidBoxItem = session.Character.Inventory.LoadBySlotAndType <ItemInstance>(newInv.Slot,
                                                                                                       newInv.Type);
                        }

                        short slot = inv.Slot;
                        if (slot != -1)
                        {
                            session.SendPacket($"rdi {raidBoxItem.Item.VNum} {numberOfItem}");
                            session.SendPacket(
                                session.Character.GenerateSay(
                                    $"{Language.Instance.GetMessageFromKey("ITEM_ACQUIRED")}: {raidBoxItem.Item.Name} x {rand_item.amount}",
                                    12));
                            session.SendPacket(session.Character.GenerateInventoryAdd(raidBoxItem.ItemVNum,
                                                                                      newInv.Amount, raidBoxItem.Type, newInv.Slot, raidBoxItem.Rare, 0, newInv.Upgrade, 0));
                            session.Character.Inventory.RemoveItemAmountFromInventory(1, raidBox.Id);
                        }
                    }
                }
                break;

            case 69:
                if (EffectValue == 1 || EffectValue == 2)
                {
                    BoxInstance box = session.Character.Inventory.LoadBySlotAndType <BoxInstance>(inv.Slot,
                                                                                                  InventoryType.Equipment);
                    if (box != null)
                    {
                        if (box.HoldingVNum == 0)
                        {
                            session.SendPacket($"wopen 44 {inv.Slot}");
                        }
                        else
                        {
                            ItemInstance newInv = session.Character.Inventory.AddNewToInventory(box.HoldingVNum);
                            if (newInv != null)
                            {
                                SpecialistInstance specialist =
                                    session.Character.Inventory.LoadBySlotAndType <SpecialistInstance>(newInv.Slot,
                                                                                                       newInv.Type);

                                if (specialist != null)
                                {
                                    specialist.SlDamage       = box.SlDamage;
                                    specialist.SlDefence      = box.SlDefence;
                                    specialist.SlElement      = box.SlElement;
                                    specialist.SlHP           = box.SlHP;
                                    specialist.SpDamage       = box.SpDamage;
                                    specialist.SpDark         = box.SpDark;
                                    specialist.SpDefence      = box.SpDefence;
                                    specialist.SpElement      = box.SpElement;
                                    specialist.SpFire         = box.SpFire;
                                    specialist.SpHP           = box.SpHP;
                                    specialist.SpLevel        = box.SpLevel;
                                    specialist.SpLight        = box.SpLight;
                                    specialist.SpStoneUpgrade = box.SpStoneUpgrade;
                                    specialist.SpWater        = box.SpWater;
                                    specialist.Upgrade        = box.Upgrade;
                                    specialist.XP             = box.XP;
                                }

                                short Slot = inv.Slot;
                                if (Slot != -1)
                                {
                                    session.SendPacket(
                                        session.Character.GenerateSay(
                                            $"{Language.Instance.GetMessageFromKey("ITEM_ACQUIRED")}: {specialist.Item.Name} + {specialist.Upgrade}",
                                            12));
                                    session.SendPacket(session.Character.GenerateInventoryAdd(specialist.ItemVNum,
                                                                                              newInv.Amount, specialist.Type, newInv.Slot, 0, 0, specialist.Upgrade, 0));
                                    session.Character.Inventory.RemoveItemAmountFromInventory(1, box.Id);
                                }
                            }
                            else
                            {
                                session.SendPacket(
                                    session.Character.GenerateMsg(
                                        Language.Instance.GetMessageFromKey("NOT_ENOUGH_PLACE"), 0));
                            }
                        }
                    }
                }
                if (EffectValue == 3)
                {
                    BoxInstance box = session.Character.Inventory.LoadBySlotAndType <BoxInstance>(inv.Slot,
                                                                                                  InventoryType.Equipment);
                    if (box != null)
                    {
                        if (box.HoldingVNum == 0)
                        {
                            session.SendPacket($"guri 26 0 {inv.Slot}");
                        }
                        else
                        {
                            ItemInstance newInv = session.Character.Inventory.AddNewToInventory(box.HoldingVNum);
                            if (newInv != null)
                            {
                                WearableInstance fairy =
                                    session.Character.Inventory.LoadBySlotAndType <WearableInstance>(newInv.Slot,
                                                                                                     newInv.Type);

                                if (fairy != null)
                                {
                                    fairy.ElementRate = box.ElementRate;
                                }

                                short Slot = inv.Slot;
                                if (Slot != -1)
                                {
                                    session.SendPacket(
                                        session.Character.GenerateSay(
                                            $"{Language.Instance.GetMessageFromKey("ITEM_ACQUIRED")}: {fairy.Item.Name} ({fairy.ElementRate}%)",
                                            12));
                                    session.SendPacket(session.Character.GenerateInventoryAdd(fairy.ItemVNum,
                                                                                              newInv.Amount, fairy.Type, newInv.Slot, 0, 0, fairy.Upgrade, 0));
                                    session.Character.Inventory.RemoveItemAmountFromInventory(1, box.Id);
                                }
                            }
                            else
                            {
                                session.SendPacket(
                                    session.Character.GenerateMsg(
                                        Language.Instance.GetMessageFromKey("NOT_ENOUGH_PLACE"), 0));
                            }
                        }
                    }
                }
                if (EffectValue == 4)
                {
                    BoxInstance box = session.Character.Inventory.LoadBySlotAndType <BoxInstance>(inv.Slot,
                                                                                                  InventoryType.Equipment);
                    if (box != null)
                    {
                        if (box.HoldingVNum == 0)
                        {
                            session.SendPacket($"guri 24 0 {inv.Slot}");
                        }
                        else
                        {
                            ItemInstance newInv = session.Character.Inventory.AddNewToInventory(box.HoldingVNum);
                            if (newInv != null)
                            {
                                short Slot = inv.Slot;
                                if (Slot != -1)
                                {
                                    session.SendPacket(
                                        session.Character.GenerateSay(
                                            $"{Language.Instance.GetMessageFromKey("ITEM_ACQUIRED")}: {newInv.Item.Name} x 1)",
                                            12));
                                    session.SendPacket(session.Character.GenerateInventoryAdd(newInv.ItemVNum,
                                                                                              newInv.Amount, newInv.Type, newInv.Slot, 0, 0, newInv.Upgrade, 0));
                                    session.Character.Inventory.RemoveItemAmountFromInventory(1, box.Id);
                                }
                            }
                            else
                            {
                                session.SendPacket(
                                    session.Character.GenerateMsg(
                                        Language.Instance.GetMessageFromKey("NOT_ENOUGH_PLACE"), 0));
                            }
                        }
                    }
                }

                break;

            default:
                Logger.Log.Warn(string.Format(Language.Instance.GetMessageFromKey("NO_HANDLER_ITEM"), GetType()));
                break;
            }
        }
Пример #8
0
        public override void Use(ClientSession Session, ref ItemInstance Inv, bool DelayUsed = false, string[] packetsplit = null)
        {
            if (EffectValue != 0)
            {
                if (Session.Character.IsSitting)
                {
                    Session.Character.IsSitting = false;
                    Session.SendPacket(Session.Character.GenerateRest());
                }
                Session.SendPacket(Session.Character.GenerateGuri(12, 1, EffectValue));
            }
            else if (EffectValue == 0)
            {
                if (packetsplit != null)
                {
                    byte  TypeEquip = 0;
                    short SlotEquip = -1;

                    if (byte.TryParse(packetsplit[8], out TypeEquip) && short.TryParse(packetsplit[9], out SlotEquip))
                    {
                        if (Session.Character.IsSitting)
                        {
                            Session.Character.IsSitting = false;
                            Session.SendPacket(Session.Character.GenerateRest());
                        }
                        if (DelayUsed)
                        {
                            bool isUsed = false;
                            switch (Inv.ItemVNum)
                            {
                            case 1219:
                                WearableInstance equip = Session.Character.Inventory.LoadBySlotAndType <WearableInstance>(SlotEquip, (Domain.InventoryType)TypeEquip);
                                if (equip != null && equip.IsFixed)
                                {
                                    equip.IsFixed = false;
                                    Session.SendPacket(Session.Character.GenerateEff(3003));
                                    Session.SendPacket(Session.Character.GenerateGuri(17, 1, SlotEquip));
                                    Session.SendPacket(Session.Character.GenerateSay(Language.Instance.GetMessageFromKey("ITEM_UNFIXED"), 12));
                                    isUsed = true;
                                }
                                break;

                            case 1365:
                                SpecialistInstance specialist = Session.Character.Inventory.LoadBySlotAndType <SpecialistInstance>(SlotEquip, (Domain.InventoryType)TypeEquip);
                                if (specialist != null && specialist.Rare == -2)
                                {
                                    specialist.Rare = 0;
                                    Session.SendPacket(Session.Character.GenerateMsg(Language.Instance.GetMessageFromKey("SP_RESURRECTED"), 0));
                                    Session.CurrentMap?.Broadcast(Session.Character.GenerateGuri(13, 1, 1), Session.Character.MapX, Session.Character.MapY);
                                    Session.Character.SpPoint = 10000;
                                    Session.SendPacket(Session.Character.GenerateSpPoint());
                                    Session.SendPacket(Session.Character.GenerateInventoryAdd(specialist.ItemVNum, 1, (Domain.InventoryType)TypeEquip, SlotEquip, specialist.Rare, specialist.Design, specialist.Upgrade, 0));
                                    isUsed = true;
                                }
                                break;
                            }

                            switch (Inv.ItemVNum)
                            {
                            case 9039:
                                SpecialistInstance specialist = Session.Character.Inventory.LoadBySlotAndType <SpecialistInstance>(SlotEquip, (Domain.InventoryType)TypeEquip);
                                if (specialist != null && specialist.Rare == -2)
                                {
                                    specialist.Rare = 0;
                                    Session.SendPacket(Session.Character.GenerateMsg(Language.Instance.GetMessageFromKey("SP_RESURRECTED"), 0));
                                    Session.CurrentMap?.Broadcast(Session.Character.GenerateGuri(13, 1, 1), Session.Character.MapX, Session.Character.MapY);
                                    Session.Character.SpPoint = 10000;
                                    Session.SendPacket(Session.Character.GenerateSpPoint());
                                    Session.SendPacket(Session.Character.GenerateInventoryAdd(specialist.ItemVNum, 1, (Domain.InventoryType)TypeEquip, SlotEquip, specialist.Rare, specialist.Design, specialist.Upgrade, 0));
                                    isUsed = true;
                                }
                                break;
                            }

                            if (!isUsed)
                            {
                                Session.SendPacket(Session.Character.GenerateSay(Language.Instance.GetMessageFromKey("ITEM_IS_NOT_FIXED"), 11));
                            }
                            else
                            {
                                Inv.Amount--;
                                if (Inv.Amount > 0)
                                {
                                    Session.SendPacket(Session.Character.GenerateInventoryAdd(Inv.ItemVNum, Inv.Amount, Inv.Type, Inv.Slot, 0, 0, 0, 0));
                                }
                                else
                                {
                                    Session.Character.Inventory.DeleteFromSlotAndType(Inv.Slot, Inv.Type);
                                    Session.SendPacket(Session.Character.GenerateInventoryAdd(-1, 0, Inv.Type, Inv.Slot, 0, 0, 0, 0));
                                }
                            }
                        }
                        else
                        {
                            Session.SendPacket($"qna #u_i^1^{Session.Character.CharacterId}^{(byte)Inv.Type}^{Inv.Slot}^0^1^{TypeEquip}^{SlotEquip} {Language.Instance.GetMessageFromKey("QNA_ITEM")}");
                        }
                    }
                }
            }
            else
            {
                Logger.Log.Warn(String.Format(Language.Instance.GetMessageFromKey("NO_HANDLER_ITEM"), this.GetType().ToString()));
            }
        }
        public override void Use(ClientSession session, ref ItemInstance inv, bool delay = false, string[] packetsplit = null)
        {
            switch (Effect)
            {
            // sp point potions
            case 150:
            case 151:
                session.Character.SpAdditionPoint += EffectValue;
                if (session.Character.SpAdditionPoint > 1000000)
                {
                    session.Character.SpAdditionPoint = 1000000;
                }
                session.SendPacket(session.Character.GenerateMsg(string.Format(Language.Instance.GetMessageFromKey("SP_POINTSADDED"), EffectValue), 0));
                session.Character.Inventory.RemoveItemAmountFromInventory(1, inv.Id);
                session.SendPacket(session.Character.GenerateSpPoint());
                break;

            case 204:
                session.Character.SpPoint         += EffectValue;
                session.Character.SpAdditionPoint += EffectValue * 3;
                if (session.Character.SpAdditionPoint > 1000000)
                {
                    session.Character.SpAdditionPoint = 1000000;
                }
                if (session.Character.SpPoint > 10000)
                {
                    session.Character.SpPoint = 10000;
                }
                session.SendPacket(session.Character.GenerateMsg(string.Format(Language.Instance.GetMessageFromKey("SP_POINTSADDEDBOTH"), EffectValue, EffectValue * 3), 0));
                session.Character.Inventory.RemoveItemAmountFromInventory(1, inv.Id);
                session.SendPacket(session.Character.GenerateSpPoint());
                break;

            /*********************************\
            **             Sceaux            **
            ***********************************
            ** VNUM :
            ** - 1127 : Cuby
            ** - 1128 : Ginseng
            ** - 1129 : Castra
            ** - 1130 : Jack
            ** - 1131 : Slade
            \**********************************/
            case 301:
                // Delete item
                //session.Character.Inventory.RemoveItemAmountFromInventory(1, inv.Id);
                // Create raid
                Raid raid = new Raid();
                raid.JoinRaid(session);
                session.SendPacket($"raid 2 {session.Character.CharacterId}");
                session.SendPacket($"raid 0 {session.Character.CharacterId}");
                session.SendPacket("raid 1 1");
                session.SendPacket(raid.GenerateRdlst());
                session.SendPacket($"say 1 {session.Character.CharacterId} 10 Tu es chef de raid à présent. Invite des membres.");
                session.SendPacket($"msg 0 Tu es chef de raid à présent. Invite des membres.");
                ServerManager.Instance.AddRaid(raid);
                break;

            // Divorce letter
            case 6969:     // this is imaginary number I = √(-1)
                break;

            // Cupid's arrow
            case 34:     // this is imaginary number I = √(-1)
                break;

            // wings
            case 650:
                SpecialistInstance specialistInstance = session.Character.Inventory.LoadBySlotAndType <SpecialistInstance>((byte)EquipmentType.Sp, InventoryType.Wear);
                if (session.Character.UseSp && specialistInstance != null)
                {
                    if (!delay)
                    {
                        session.SendPacket($"qna #u_i^1^{session.Character.CharacterId}^{(byte)inv.Type}^{inv.Slot}^3 {Language.Instance.GetMessageFromKey("ASK_WINGS_CHANGE")}");
                    }
                    else
                    {
                        specialistInstance.Design       = (byte)EffectValue;
                        session.Character.MorphUpgrade2 = EffectValue;
                        session.CurrentMap?.Broadcast(session.Character.GenerateCMode());
                        session.SendPacket(session.Character.GenerateStat());
                        session.SendPacket(session.Character.GenerateStatChar());
                        session.Character.Inventory.RemoveItemAmountFromInventory(1, inv.Id);
                    }
                }
                else
                {
                    session.SendPacket(session.Character.GenerateMsg(Language.Instance.GetMessageFromKey("NO_SP"), 0));
                }
                break;

            // presentation messages
            case 203:
                if (!session.Character.IsVehicled)
                {
                    if (!delay)
                    {
                        session.SendPacket(session.Character.GenerateGuri(10, 2, 1));
                    }
                }
                break;

            // magic lamps
            case 651:
                if (session.Character.Inventory.GetAllItems().All(i => i.Type != InventoryType.Wear))
                {
                    if (!delay)
                    {
                        session.SendPacket($"qna #u_i^1^{session.Character.CharacterId}^{(byte)inv.Type}^{inv.Slot}^3 {Language.Instance.GetMessageFromKey("ASK_USE")}");
                    }
                    else
                    {
                        session.Character.ChangeSex();
                        session.Character.Inventory.RemoveItemAmountFromInventory(1, inv.Id);
                    }
                }
                else
                {
                    session.SendPacket(session.Character.GenerateMsg(Language.Instance.GetMessageFromKey("EQ_NOT_EMPTY"), 0));
                }
                break;

            // vehicles
            case 1000:
                if (Morph > 0)
                {
                    if (!delay && !session.Character.IsVehicled)
                    {
                        if (session.Character.IsSitting)
                        {
                            session.Character.IsSitting = false;
                            session.CurrentMap?.Broadcast(session.Character.GenerateRest());
                        }
                        session.SendPacket(session.Character.GenerateDelay(3000, 3, $"#u_i^1^{session.Character.CharacterId}^{(byte)inv.Type}^{inv.Slot}^2"));
                    }
                    else
                    {
                        if (!session.Character.IsVehicled)
                        {
                            session.Character.Speed         = Speed;
                            session.Character.IsVehicled    = true;
                            session.Character.VehicleSpeed  = Speed;
                            session.Character.MorphUpgrade  = 0;
                            session.Character.MorphUpgrade2 = 0;
                            session.Character.Morph         = Morph + (byte)session.Character.Gender;
                            session.CurrentMap?.Broadcast(session.Character.GenerateEff(196), session.Character.MapX, session.Character.MapY);
                            session.CurrentMap?.Broadcast(session.Character.GenerateCMode());
                            session.SendPacket(session.Character.GenerateCond());
                        }
                        else
                        {
                            session.Character.RemoveVehicle();
                        }
                    }
                }
                break;

            case 69:
                session.Character.Reput += ReputPrice;
                session.SendPacket(session.Character.GenerateFd());
                session.Character.Inventory.RemoveItemAmountFromInventory(1, inv.Id);
                break;

            default:
                Logger.Log.Warn(string.Format(Language.Instance.GetMessageFromKey("NO_HANDLER_ITEM"), GetType()));
                Logger.Log.Warn($"ID : {Effect}");
                break;
            }
        }
Пример #10
0
        public override void Use(ClientSession session, ref ItemInstance inv, byte Option = 0, string[] packetsplit = null)
        {
            if (Effect == 0)
            {
                if (EffectValue != 0)
                {
                    if (session.Character.IsSitting)
                    {
                        session.Character.IsSitting = false;
                        session.SendPacket(session.Character.GenerateRest());
                    }
                    session.SendPacket(UserInterfaceHelper.Instance.GenerateGuri(12, 1, session.Character.CharacterId, EffectValue));
                }
                else if (EffectValue == 0)
                {
                    if (packetsplit == null || packetsplit.Length <= 9)
                    {
                        return;
                    }
                    if (!byte.TryParse(packetsplit[8], out byte TypeEquip) || !short.TryParse(packetsplit[9], out short SlotEquip))
                    {
                        return;
                    }
                    if (session.Character.IsSitting)
                    {
                        session.Character.IsSitting = false;
                        session.SendPacket(session.Character.GenerateRest());
                    }
                    if (Option != 0)
                    {
                        bool isUsed = false;
                        switch (inv.ItemVNum)
                        {
                        case 1219:
                            WearableInstance equip = session.Character.Inventory.LoadBySlotAndType <WearableInstance>(SlotEquip, (InventoryType)TypeEquip);
                            if (equip != null && equip.IsFixed)
                            {
                                equip.IsFixed = false;
                                session.SendPacket(session.Character.GenerateEff(3003));
                                session.SendPacket(UserInterfaceHelper.Instance.GenerateGuri(17, 1, session.Character.CharacterId, SlotEquip));
                                session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("ITEM_UNFIXED"), 12));
                                isUsed = true;
                            }
                            break;

                        case 1365:
                        case 9039:
                            SpecialistInstance specialist = session.Character.Inventory.LoadBySlotAndType <SpecialistInstance>(SlotEquip, (InventoryType)TypeEquip);
                            if (specialist != null && specialist.Rare == -2)
                            {
                                specialist.Rare = 0;
                                session.SendPacket(UserInterfaceHelper.Instance.GenerateMsg(Language.Instance.GetMessageFromKey("SP_RESURRECTED"), 0));
                                session.SendPacket(UserInterfaceHelper.Instance.GenerateGuri(13, 1, session.Character.CharacterId, 1));
                                session.Character.SpPoint = 10000;
                                if (session.Character.SpPoint > 10000)
                                {
                                    session.Character.SpPoint = 10000;
                                }
                                session.SendPacket(session.Character.GenerateSpPoint());
                                session.SendPacket(specialist.GenerateInventoryAdd());
                                isUsed = true;
                            }
                            break;
                        }
                        if (!isUsed)
                        {
                            session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("ITEM_IS_NOT_FIXED"), 11));
                        }
                        else
                        {
                            session.Character.Inventory.RemoveItemAmountFromInventory(1, inv.Id);
                        }
                    }
                    else
                    {
                        session.SendPacket($"qna #u_i^1^{session.Character.CharacterId}^{(byte)inv.Type}^{inv.Slot}^0^1^{TypeEquip}^{SlotEquip} {Language.Instance.GetMessageFromKey("QNA_ITEM")}");
                    }
                }
            }
            else
            {
                Logger.Log.Warn(string.Format(Language.Instance.GetMessageFromKey("NO_HANDLER_ITEM"), GetType()));
            }
        }
Пример #11
0
        public override void Use(ClientSession session, ref ItemInstance inv, bool delay = false, string[] packetsplit = null)
        {
            switch (Effect)
            {
            // sp point potions
            case 150:
            case 151:
                session.Character.SpAdditionPoint += EffectValue;
                if (session.Character.SpAdditionPoint > 1000000)
                {
                    session.Character.SpAdditionPoint = 1000000;
                }
                session.SendPacket(session.Character.GenerateMsg(string.Format(Language.Instance.GetMessageFromKey("SP_POINTSADDED"), EffectValue), 0));
                session.Character.Inventory.RemoveItemAmountFromInventory(1, inv.Id);
                session.SendPacket(session.Character.GenerateSpPoint());
                break;

            case 204:
                session.Character.SpPoint         += EffectValue;
                session.Character.SpAdditionPoint += EffectValue * 3;
                if (session.Character.SpAdditionPoint > 1000000)
                {
                    session.Character.SpAdditionPoint = 1000000;
                }
                if (session.Character.SpPoint > 10000)
                {
                    session.Character.SpPoint = 10000;
                }
                session.SendPacket(session.Character.GenerateMsg(string.Format(Language.Instance.GetMessageFromKey("SP_POINTSADDEDBOTH"), EffectValue, EffectValue * 3), 0));
                session.Character.Inventory.RemoveItemAmountFromInventory(1, inv.Id);
                session.SendPacket(session.Character.GenerateSpPoint());
                break;

            //Atk/Def/HP/Exp potions
            case 6600:
                switch (EffectValue)
                {
                case 1:
                    IndicatorBase buff1 = new Buff.Indicators.Item.AttackPotion(session.Character.Level);
                    session.CurrentMapInstance?.Broadcast(session.Character.GenerateEff(203));
                    session.Character.Buff.Add(buff1);
                    break;

                case 2:
                    IndicatorBase buff2 = new Buff.Indicators.Item.DefensePotion(session.Character.Level);
                    session.CurrentMapInstance?.Broadcast(session.Character.GenerateEff(203));
                    session.Character.Buff.Add(buff2);
                    break;

                case 3:
                    IndicatorBase buff3 = new Buff.Indicators.Item.EnergyPotion(session.Character.Level);
                    session.CurrentMapInstance?.Broadcast(session.Character.GenerateEff(203));
                    session.Character.Buff.Add(buff3);
                    break;

                case 4:
                    IndicatorBase buff4 = new Buff.Indicators.Item.ExperiencePotion(session.Character.Level);
                    session.CurrentMapInstance?.Broadcast(session.Character.GenerateEff(203));
                    session.Character.Buff.Add(buff4);
                    break;
                }
                session.Character.Inventory.RemoveItemAmountFromInventory(1, inv.Id);
                break;

            // Divorce letter
            case 6969:     // this is imaginary number I = √(-1)
                break;

            // Cupid's arrow
            case 34:     // this is imaginary number I = √(-1)
                break;

            case 570:
                if (session.Character.Faction == EffectValue)
                {
                    return;
                }
                session.SendPacket(session.Character.Family == null
                        ? $"qna #guri^750^{EffectValue} {Language.Instance.GetMessageFromKey($"ASK_CHANGE_FACTION{EffectValue}")}"
                        : session.Character.GenerateMsg(Language.Instance.GetMessageFromKey("IN_FAMILY"), 0));
                break;

            // wings
            case 650:
                SpecialistInstance specialistInstance = session.Character.Inventory.LoadBySlotAndType <SpecialistInstance>((byte)EquipmentType.Sp, InventoryType.Wear);
                if (session.Character.UseSp && specialistInstance != null)
                {
                    if (!delay)
                    {
                        session.SendPacket($"qna #u_i^1^{session.Character.CharacterId}^{(byte)inv.Type}^{inv.Slot}^3 {Language.Instance.GetMessageFromKey("ASK_WINGS_CHANGE")}");
                    }
                    else
                    {
                        specialistInstance.Design       = (byte)EffectValue;
                        session.Character.MorphUpgrade2 = EffectValue;
                        session.CurrentMapInstance?.Broadcast(session.Character.GenerateCMode());
                        session.SendPacket(session.Character.GenerateStat());
                        session.SendPacket(session.Character.GenerateStatChar());
                        session.Character.Inventory.RemoveItemAmountFromInventory(1, inv.Id);
                    }
                }
                else
                {
                    session.SendPacket(session.Character.GenerateMsg(Language.Instance.GetMessageFromKey("NO_SP"), 0));
                }
                break;

            // presentation messages
            case 203:
                if (!session.Character.IsVehicled)
                {
                    if (!delay)
                    {
                        session.SendPacket(session.Character.GenerateGuri(10, 2, 1));
                    }
                }
                break;

            // magic lamps
            case 651:
                if (session.Character.Inventory.GetAllItems().All(i => i.Type != InventoryType.Wear))
                {
                    if (!delay)
                    {
                        session.SendPacket($"qna #u_i^1^{session.Character.CharacterId}^{(byte)inv.Type}^{inv.Slot}^3 {Language.Instance.GetMessageFromKey("ASK_USE")}");
                    }
                    else
                    {
                        session.Character.ChangeSex();
                        session.Character.Inventory.RemoveItemAmountFromInventory(1, inv.Id);
                    }
                }
                else
                {
                    session.SendPacket(session.Character.GenerateMsg(Language.Instance.GetMessageFromKey("EQ_NOT_EMPTY"), 0));
                }
                break;

            // vehicles
            case 1000:
                if (Morph > 0)
                {
                    if (!delay && !session.Character.IsVehicled)
                    {
                        if (session.Character.IsSitting)
                        {
                            session.Character.IsSitting = false;
                            session.CurrentMapInstance?.Broadcast(session.Character.GenerateRest());
                        }
                        session.SendPacket(session.Character.GenerateDelay(3000, 3, $"#u_i^1^{session.Character.CharacterId}^{(byte)inv.Type}^{inv.Slot}^2"));
                    }
                    else
                    {
                        if (!session.Character.IsVehicled && delay)
                        {
                            session.Character.Speed         = Speed;
                            session.Character.IsVehicled    = true;
                            session.Character.VehicleSpeed  = Speed;
                            session.Character.MorphUpgrade  = 0;
                            session.Character.MorphUpgrade2 = 0;
                            session.Character.Morph         = Morph + (byte)session.Character.Gender;
                            session.CurrentMapInstance?.Broadcast(session.Character.GenerateEff(196), session.Character.MapX, session.Character.MapY);
                            session.CurrentMapInstance?.Broadcast(session.Character.GenerateCMode());
                            session.SendPacket(session.Character.GenerateCond());
                            session.Character.LastSpeedChange = DateTime.Now;
                        }
                        else if (session.Character.IsVehicled)
                        {
                            session.Character.RemoveVehicle();
                        }
                    }
                }
                break;

            case 1002:
                if (EffectValue == 69)
                {
                    int rnd = ServerManager.RandomNumber(0, 1000);
                    if (rnd < 5)
                    {
                        short[] vnums  = { 5560, 5591, 4099, 907, 1160, 4705, 4706, 4707, 4708, 4709, 4710, 4711, 4712, 4713, 4714, 4715, 4716 };
                        byte[]  counts = { 1, 1, 1, 1, 10, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 };
                        int     item   = ServerManager.RandomNumber(0, 17);

                        session.Character.GiftAdd(vnums[item], counts[item]);
                    }
                    else if (rnd < 30)
                    {
                        short[] vnums = { 361, 362, 363, 366, 367, 368, 371, 372, 373 };
                        session.Character.GiftAdd(vnums[ServerManager.RandomNumber(0, 9)], 1);
                    }
                    else
                    {
                        short[] vnums  = { 1161, 2282, 1030, 1244, 1218, 5369, 1012, 1363, 1364, 2160, 2173, 5959, 5983, 2514, 2515, 2516, 2517, 2518, 2519, 2520, 2521, 1685, 1686, 5087, 5203, 2418, 2310, 2303, 2169, 2280, 5892, 5893, 5894, 5895, 5896, 5897, 5898, 5899, 5332, 5105, 2161, 2162 };
                        byte[]  counts = { 10, 10, 20, 5, 1, 1, 99, 1, 1, 5, 5, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 5, 20, 20, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 };
                        int     item   = ServerManager.RandomNumber(0, 42);
                        session.Character.GiftAdd(vnums[item], counts[item]);
                    }
                    session.Character.Inventory.RemoveItemAmountFromInventory(1, inv.Id);
                }
                else
                {
                    if (session.HasCurrentMapInstance)
                    {
                        if (session.CurrentMapInstance.Map.MapTypes.All(m => m.MapTypeId != (short)MapTypeEnum.Act4))
                        {
                            short[] vnums = { 1386, 1387, 1388, 1389, 1390, 1391, 1392, 1393, 1394, 1395, 1396, 1397, 1398, 1399, 1400, 1401, 1402, 1403, 1404, 1405 };
                            short   vnum  = vnums[ServerManager.RandomNumber(0, 20)];

                            NpcMonster npcmonster = ServerManager.GetNpc(vnum);
                            if (npcmonster == null)
                            {
                                return;
                            }
                            // ReSharper disable once PossibleNullReferenceException HasCurrentMapInstance NullCheck
                            MapMonster monster = new MapMonster {
                                MonsterVNum = vnum, MapY = session.Character.MapY, MapX = session.Character.MapX, MapId = session.Character.MapInstance.Map.MapId, Position = (byte)session.Character.Direction, IsMoving = true, MapMonsterId = session.CurrentMapInstance.GetNextMonsterId(), ShouldRespawn = false
                            };
                            monster.Initialize(session.CurrentMapInstance);
                            monster.StartLife();
                            session.CurrentMapInstance.AddMonster(monster);
                            session.CurrentMapInstance.Broadcast(monster.GenerateIn3());
                            session.Character.Inventory.RemoveItemAmountFromInventory(1, inv.Id);
                        }
                    }
                }
                break;

            case 69:
                session.Character.Reput += ReputPrice;
                session.SendPacket(session.Character.GenerateFd());
                session.Character.Inventory.RemoveItemAmountFromInventory(1, inv.Id);
                break;

            case 1003:
                if (!session.Character.StaticBonusList.Any(s => s.StaticBonusType == StaticBonusType.BazaarMedalGold || s.StaticBonusType == StaticBonusType.BazaarMedalSilver))
                {
                    session.Character.StaticBonusList.Add(new StaticBonusDTO {
                        CharacterId = session.Character.CharacterId, DateEnd = DateTime.Now.AddDays(EffectValue), StaticBonusType = StaticBonusType.BazaarMedalGold
                    });
                    session.Character.Inventory.RemoveItemAmountFromInventory(1, inv.Id);
                    session.SendPacket(session.Character.GenerateSay(string.Format(Language.Instance.GetMessageFromKey("EFFECT_ACTIVATED"), Name), 12));
                }
                break;

            case 1004:
                if (!session.Character.StaticBonusList.Any(s => s.StaticBonusType == StaticBonusType.BazaarMedalGold || s.StaticBonusType == StaticBonusType.BazaarMedalGold))
                {
                    session.Character.StaticBonusList.Add(new StaticBonusDTO {
                        CharacterId = session.Character.CharacterId, DateEnd = DateTime.Now.AddDays(EffectValue), StaticBonusType = StaticBonusType.BazaarMedalSilver
                    });
                    session.Character.Inventory.RemoveItemAmountFromInventory(1, inv.Id);
                    session.SendPacket(session.Character.GenerateSay(string.Format(Language.Instance.GetMessageFromKey("EFFECT_ACTIVATED"), Name), 12));
                }
                break;

            case 1005:
                if (session.Character.StaticBonusList.All(s => s.StaticBonusType != StaticBonusType.BackPack))
                {
                    session.Character.StaticBonusList.Add(new StaticBonusDTO {
                        CharacterId = session.Character.CharacterId, DateEnd = DateTime.Now.AddDays(EffectValue), StaticBonusType = StaticBonusType.BackPack
                    });
                    session.Character.Inventory.RemoveItemAmountFromInventory(1, inv.Id);
                    session.SendPacket(session.Character.GenerateExts());
                    session.SendPacket(session.Character.GenerateSay(string.Format(Language.Instance.GetMessageFromKey("EFFECT_ACTIVATED"), Name), 12));
                }
                break;

            default:
                Logger.Log.Warn(string.Format(Language.Instance.GetMessageFromKey("NO_HANDLER_ITEM"), GetType()));
                break;
            }
        }
Пример #12
0
        public string GenerateSlInfo(SpecialistInstance inventoryItem, int type)
        {
            int freepoint = CharacterHelper.SPPoint(inventoryItem.SpLevel, inventoryItem.Upgrade) - inventoryItem.SlDamage - inventoryItem.SlHP - inventoryItem.SlElement - inventoryItem.SlDefence;

            int slElement = CharacterHelper.SlPoint(inventoryItem.SlElement, 2);
            int slHp = CharacterHelper.SlPoint(inventoryItem.SlHP, 3);
            int slDefence = CharacterHelper.SlPoint(inventoryItem.SlDefence, 1);
            int slHit = CharacterHelper.SlPoint(inventoryItem.SlDamage, 0);

            string skill = String.Empty;
            List<CharacterSkill> skillsSp = new List<CharacterSkill>();
            foreach (Skill ski in ServerManager.GetAllSkill().Where(ski => ski.Class == inventoryItem.Item.Morph + 31 && ski.LevelMinimum <= inventoryItem.SpLevel))
            {
                skillsSp.Add(new CharacterSkill() { SkillVNum = ski.SkillVNum, CharacterId = CharacterId });
            }
            byte spdestroyed = 0;
            if (inventoryItem.Rare == -2)
            {
                spdestroyed = 1;
            }
            if (!skillsSp.Any())
            {
                skill = "-1";
            }
            short firstskillvnum = skillsSp[0].SkillVNum;

            for (int i = 1; i < 11; i++)
            {
                if (skillsSp.Count >= i + 1)
                {
                    if (skillsSp[i].SkillVNum <= firstskillvnum + 10)
                        skill += $"{skillsSp[i].SkillVNum}.";
                }
            }

            // 10 9 8 '0 0 0 0'<- bonusdamage bonusarmor bonuselement bonushpmp its after upgrade and
            // 3 first values are not important
            skill = skill.TrimEnd('.');
            return $"slinfo {type} {inventoryItem.ItemVNum} {inventoryItem.Item.Morph} {inventoryItem.SpLevel} {inventoryItem.Item.LevelJobMinimum} {inventoryItem.Item.ReputationMinimum} 0 0 0 0 0 0 0 {inventoryItem.Item.SpType} {inventoryItem.Item.FireResistance} {inventoryItem.Item.WaterResistance} {inventoryItem.Item.LightResistance} {inventoryItem.Item.DarkResistance} {inventoryItem.XP} {CharacterHelper.SPXPData[inventoryItem.SpLevel - 1]} {skill} {inventoryItem.TransportId} {freepoint} {slHit} {slDefence} {slElement} {slHp} {inventoryItem.Upgrade} 0 0 {spdestroyed} 0 0 0 0 {inventoryItem.SpStoneUpgrade} {inventoryItem.SpDamage} {inventoryItem.SpDefence} {inventoryItem.SpElement} {inventoryItem.SpHP} {inventoryItem.SpFire} {inventoryItem.SpWater} {inventoryItem.SpLight} {inventoryItem.SpDark}";
        }
Пример #13
0
 public string GeneratePslInfo(SpecialistInstance inventoryItem, int type)
 {
     // 1235.3 1237.4 1239.5 <= skills SkillVNum.Grade
     return $"pslinfo {inventoryItem.Item.VNum} {inventoryItem.Item.Element} {inventoryItem.Item.ElementRate} {inventoryItem.Item.LevelJobMinimum} {inventoryItem.Item.Speed} {inventoryItem.Item.FireResistance} {inventoryItem.Item.WaterResistance} {inventoryItem.Item.LightResistance} {inventoryItem.Item.DarkResistance} 0.0 0.0 0.0";
 }
Пример #14
0
        public override void Use(ClientSession session, ref ItemInstance inv, byte Option = 0, string[] packetsplit = null)
        {
            inv.Item.BCards.ForEach(c => c.ApplyBCards(session.Character));

            switch (Effect)
            {
            // sp point potions
            case 150:
            case 151:
                session.Character.SpAdditionPoint += EffectValue;
                if (session.Character.SpAdditionPoint > 1000000)
                {
                    session.Character.SpAdditionPoint = 1000000;
                }
                session.SendPacket(UserInterfaceHelper.Instance.GenerateMsg(string.Format(Language.Instance.GetMessageFromKey("SP_POINTSADDED"), EffectValue), 0));
                session.Character.Inventory.RemoveItemAmountFromInventory(1, inv.Id);
                session.SendPacket(session.Character.GenerateSpPoint());
                break;

            case 204:
                session.Character.SpPoint         += EffectValue;
                session.Character.SpAdditionPoint += EffectValue * 3;
                if (session.Character.SpAdditionPoint > 1000000)
                {
                    session.Character.SpAdditionPoint = 1000000;
                }
                if (session.Character.SpPoint > 10000)
                {
                    session.Character.SpPoint = 10000;
                }
                session.SendPacket(UserInterfaceHelper.Instance.GenerateMsg(string.Format(Language.Instance.GetMessageFromKey("SP_POINTSADDEDBOTH"), EffectValue, EffectValue * 3), 0));
                session.Character.Inventory.RemoveItemAmountFromInventory(1, inv.Id);
                session.SendPacket(session.Character.GenerateSpPoint());
                break;

            case 301:
                if (ServerManager.Instance.IsCharacterMemberOfGroup(session.Character.CharacterId))
                {
                    //TODO you are in group
                    return;
                }
                ItemInstance raidSeal = session.Character.Inventory.LoadBySlotAndType <ItemInstance>(inv.Slot, InventoryType.Main);
                session.Character.Inventory.RemoveItemAmountFromInventory(1, raidSeal.Id);

                ScriptedInstance raid = ServerManager.Instance.Raids.FirstOrDefault(s => s.RequieredItems.Any(obj => obj.VNum == raidSeal.ItemVNum)).GetClone();
                if (raid != null)
                {
                    Group group = new Group(GroupType.Team);
                    group.Raid = raid;
                    group.JoinGroup(session.Character.CharacterId);
                    ServerManager.Instance.AddGroup(group);
                    session.SendPacket(UserInterfaceHelper.Instance.GenerateMsg(string.Format(Language.Instance.GetMessageFromKey("YOU_ARE_RAID_CHIEF"), session.Character.Name), 0));
                    session.SendPacket(session.Character.GenerateSay(string.Format(Language.Instance.GetMessageFromKey("YOU_ARE_RAID_CHIEF"), session.Character.Name), 10));
                    if (session.Character.Level > raid.LevelMaximum || session.Character.Level < raid.LevelMinimum)
                    {
                        session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("RAID_LEVEL_INCORRECT"), 10));
                    }
                    session.SendPacket(session.Character.GenerateRaid(2, false));
                    session.SendPacket(session.Character.GenerateRaid(0, false));
                    session.SendPacket(session.Character.GenerateRaid(1, false));
                    session.SendPacket(group.GenerateRdlst());
                }
                break;

            case 305:
                Mate mate = session.Character.Mates.FirstOrDefault(s => s.MateTransportId == int.Parse(packetsplit[3]));
                if (mate != null && EffectValue == mate.NpcMonsterVNum && mate.Skin == 0)
                {
                    mate.Skin = Morph;
                    session.SendPacket(mate.GenerateCMode(mate.Skin));
                    session.Character.Inventory.RemoveItemAmountFromInventory(1, inv.Id);
                }
                break;

            //Atk/Def/HP/Exp potions
            case 6600:
                session.Character.Inventory.RemoveItemAmountFromInventory(1, inv.Id);
                break;

            case 208:
                session.Character.Inventory.RemoveItemAmountFromInventory(1, inv.Id);
                session.Character.AddStaticBuff(new StaticBuffDTO()
                {
                    CardId = 121
                });
                break;

            // Divorce letter
            case 6969:     // this is imaginary number I = √(-1)
                break;

            // Cupid's arrow
            case 34:     // this is imaginary number I = √(-1)
                break;

            case 570:
                if (session.Character.Faction == EffectValue)
                {
                    return;
                }
                session.SendPacket(session.Character.Family == null
                        ? $"qna #guri^750^{EffectValue} {Language.Instance.GetMessageFromKey($"ASK_CHANGE_FACTION{EffectValue}")}"
                        : UserInterfaceHelper.Instance.GenerateMsg(Language.Instance.GetMessageFromKey("IN_FAMILY"),
                                                                   0));
                break;

            // wings
            case 650:
                SpecialistInstance specialistInstance = session.Character.Inventory.LoadBySlotAndType <SpecialistInstance>((byte)EquipmentType.Sp, InventoryType.Wear);
                if (session.Character.UseSp && specialistInstance != null)
                {
                    if (Option == 0)
                    {
                        session.SendPacket($"qna #u_i^1^{session.Character.CharacterId}^{(byte)inv.Type}^{inv.Slot}^3 {Language.Instance.GetMessageFromKey("ASK_WINGS_CHANGE")}");
                    }
                    else
                    {
                        specialistInstance.Design       = (byte)EffectValue;
                        session.Character.MorphUpgrade2 = EffectValue;
                        session.CurrentMapInstance?.Broadcast(session.Character.GenerateCMode());
                        session.SendPacket(session.Character.GenerateStat());
                        session.SendPacket(session.Character.GenerateStatChar());
                        session.Character.Inventory.RemoveItemAmountFromInventory(1, inv.Id);
                    }
                }
                else
                {
                    session.SendPacket(
                        UserInterfaceHelper.Instance.GenerateMsg(Language.Instance.GetMessageFromKey("NO_SP"), 0));
                }
                break;

            // presentation messages
            case 203:
                if (!session.Character.IsVehicled)
                {
                    if (Option == 0)
                    {
                        session.SendPacket(UserInterfaceHelper.Instance.GenerateGuri(10, 2, session.Character.CharacterId, 1));
                    }
                }
                break;

            // magic lamps
            case 651:
                if (session.Character.Inventory.GetAllItems().All(i => i.Type != InventoryType.Wear))
                {
                    if (Option == 0)
                    {
                        session.SendPacket($"qna #u_i^1^{session.Character.CharacterId}^{(byte)inv.Type}^{inv.Slot}^3 {Language.Instance.GetMessageFromKey("ASK_USE")}");
                    }
                    else
                    {
                        session.Character.ChangeSex();
                        session.Character.Inventory.RemoveItemAmountFromInventory(1, inv.Id);
                    }
                }
                else
                {
                    session.SendPacket(UserInterfaceHelper.Instance.GenerateMsg(Language.Instance.GetMessageFromKey("EQ_NOT_EMPTY"), 0));
                }
                break;

            // vehicles
            case 1000:
                if (Morph > 0)
                {
                    if (Option == 0 && !session.Character.IsVehicled)
                    {
                        if (session.Character.IsSitting)
                        {
                            session.Character.IsSitting = false;
                            session.CurrentMapInstance?.Broadcast(session.Character.GenerateRest());
                        }
                        session.Character.LastDelay = DateTime.Now;
                        session.SendPacket(UserInterfaceHelper.Instance.GenerateDelay(3000, 3, $"#u_i^1^{session.Character.CharacterId}^{(byte)inv.Type}^{inv.Slot}^2"));
                    }
                    else
                    {
                        if (!session.Character.IsVehicled && Option != 0)
                        {
                            DateTime delay = DateTime.Now.AddSeconds(-4);
                            if (session.Character.LastDelay > delay && session.Character.LastDelay < delay.AddSeconds(2))
                            {
                                session.Character.Speed         = Speed;
                                session.Character.IsVehicled    = true;
                                session.Character.VehicleSpeed  = Speed;
                                session.Character.MorphUpgrade  = 0;
                                session.Character.MorphUpgrade2 = 0;
                                session.Character.Morph         = Morph + (byte)session.Character.Gender;
                                session.CurrentMapInstance?.Broadcast(session.Character.GenerateEff(196), session.Character.MapX, session.Character.MapY);
                                session.CurrentMapInstance?.Broadcast(session.Character.GenerateCMode());
                                session.SendPacket(session.Character.GenerateCond());
                                session.Character.LastSpeedChange = DateTime.Now;
                            }
                        }
                        else if (session.Character.IsVehicled)
                        {
                            session.Character.RemoveVehicle();
                        }
                    }
                }
                break;

            case 1002:
                if (EffectValue == 69)
                {
                    int rnd = ServerManager.Instance.RandomNumber(0, 1000);
                    if (rnd < 5)
                    {
                        short[] vnums =
                        {
                            5560, 5591, 4099, 907, 1160, 4705, 4706, 4707, 4708, 4709, 4710, 4711, 4712, 4713, 4714,
                            4715, 4716
                        };
                        byte[] counts = { 1, 1, 1, 1, 10, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 };
                        int    item   = ServerManager.Instance.RandomNumber(0, 17);

                        session.Character.GiftAdd(vnums[item], counts[item]);
                    }
                    else if (rnd < 30)
                    {
                        short[] vnums = { 361, 362, 363, 366, 367, 368, 371, 372, 373 };
                        session.Character.GiftAdd(vnums[ServerManager.Instance.RandomNumber(0, 9)], 1);
                    }
                    else
                    {
                        short[] vnums =
                        {
                            1161, 2282, 1030, 1244, 1218, 5369, 1012, 1363, 1364, 2160, 2173, 5959, 5983, 2514,
                            2515, 2516, 2517, 2518, 2519, 2520, 2521, 1685, 1686, 5087, 5203, 2418, 2310, 2303,
                            2169, 2280, 5892, 5893, 5894, 5895, 5896, 5897, 5898, 5899, 5332, 5105, 2161, 2162
                        };
                        byte[] counts =
                        {
                            10, 10, 20, 5, 1, 1, 99, 1, 1, 5, 5, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 5, 20,
                            20,  1,  1, 1, 1, 1,  1, 1, 1, 1, 1, 1, 1, 1, 1
                        };
                        int item = ServerManager.Instance.RandomNumber(0, 42);
                        session.Character.GiftAdd(vnums[item], counts[item]);
                    }
                    session.Character.Inventory.RemoveItemAmountFromInventory(1, inv.Id);
                }
                else
                {
                    if (session.HasCurrentMapInstance)
                    {
                        if (session.CurrentMapInstance.Map.MapTypes.All(m => m.MapTypeId != (short)MapTypeEnum.Act4))
                        {
                            short[] vnums =
                            {
                                1386, 1387, 1388, 1389, 1390, 1391, 1392, 1393, 1394, 1395, 1396, 1397, 1398, 1399,
                                1400, 1401, 1402, 1403, 1404, 1405
                            };
                            short vnum = vnums[ServerManager.Instance.RandomNumber(0, 20)];

                            NpcMonster npcmonster = ServerManager.Instance.GetNpc(vnum);
                            if (npcmonster == null)
                            {
                                return;
                            }
                            MapMonster monster = new MapMonster
                            {
                                MonsterVNum   = vnum,
                                MapY          = session.Character.MapY,
                                MapX          = session.Character.MapX,
                                MapId         = session.Character.MapInstance.Map.MapId,
                                Position      = (byte)session.Character.Direction,
                                IsMoving      = true,
                                MapMonsterId  = session.CurrentMapInstance.GetNextMonsterId(),
                                ShouldRespawn = false
                            };
                            monster.Initialize(session.CurrentMapInstance);
                            session.CurrentMapInstance.AddMonster(monster);
                            session.CurrentMapInstance.Broadcast(monster.GenerateIn());
                            session.Character.Inventory.RemoveItemAmountFromInventory(1, inv.Id);
                        }
                    }
                }
                break;

            case 69:
                session.Character.Reput += ReputPrice;
                session.SendPacket(session.Character.GenerateFd());
                session.Character.Inventory.RemoveItemAmountFromInventory(1, inv.Id);
                break;

            case 1003:
                if (!session.Character.StaticBonusList.Any(s => s.StaticBonusType == StaticBonusType.BazaarMedalGold || s.StaticBonusType == StaticBonusType.BazaarMedalSilver))
                {
                    session.Character.StaticBonusList.Add(new StaticBonusDTO
                    {
                        CharacterId     = session.Character.CharacterId,
                        DateEnd         = DateTime.Now.AddDays(EffectValue),
                        StaticBonusType = StaticBonusType.BazaarMedalGold
                    });
                    session.Character.Inventory.RemoveItemAmountFromInventory(1, inv.Id);
                    session.SendPacket(session.Character.GenerateSay(string.Format(Language.Instance.GetMessageFromKey("EFFECT_ACTIVATED"), Name), 12));
                }
                break;

            case 1004:
                if (!session.Character.StaticBonusList.Any(s => s.StaticBonusType == StaticBonusType.BazaarMedalGold || s.StaticBonusType == StaticBonusType.BazaarMedalGold))
                {
                    session.Character.StaticBonusList.Add(new StaticBonusDTO
                    {
                        CharacterId     = session.Character.CharacterId,
                        DateEnd         = DateTime.Now.AddDays(EffectValue),
                        StaticBonusType = StaticBonusType.BazaarMedalSilver
                    });
                    session.Character.Inventory.RemoveItemAmountFromInventory(1, inv.Id);
                    session.SendPacket(session.Character.GenerateSay(string.Format(Language.Instance.GetMessageFromKey("EFFECT_ACTIVATED"), Name), 12));
                }
                break;

            case 1005:
                if (session.Character.StaticBonusList.All(s => s.StaticBonusType != StaticBonusType.BackPack))
                {
                    session.Character.StaticBonusList.Add(new StaticBonusDTO
                    {
                        CharacterId     = session.Character.CharacterId,
                        DateEnd         = DateTime.Now.AddDays(EffectValue),
                        StaticBonusType = StaticBonusType.BackPack
                    });
                    session.Character.Inventory.RemoveItemAmountFromInventory(1, inv.Id);
                    session.SendPacket(session.Character.GenerateExts());
                    session.SendPacket(session.Character.GenerateSay(string.Format(Language.Instance.GetMessageFromKey("EFFECT_ACTIVATED"), Name), 12));
                }
                break;

            case 1006:
                if (Option == 0)
                {
                    session.SendPacket($"qna #u_i^1^{session.Character.CharacterId}^{(byte)inv.Type}^{inv.Slot}^2 {Language.Instance.GetMessageFromKey("ASK_PET_MAX")}");
                }
                else
                {
                    if (session.Character.MaxMateCount < 30)
                    {
                        session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("GET_PET_PLACES"), 10));
                        session.SendPacket(session.Character.GenerateScpStc());
                        session.Character.Inventory.RemoveItemAmountFromInventory(1, inv.Id);
                    }
                }
                break;

            case 1007:
                if (session.Character.StaticBonusList.All(s => s.StaticBonusType != StaticBonusType.PetBasket))
                {
                    session.Character.StaticBonusList.Add(new StaticBonusDTO
                    {
                        CharacterId     = session.Character.CharacterId,
                        DateEnd         = DateTime.Now.AddDays(EffectValue),
                        StaticBonusType = StaticBonusType.PetBasket
                    });
                    session.Character.Inventory.RemoveItemAmountFromInventory(1, inv.Id);
                    session.SendPacket(session.Character.GenerateExts());
                    session.SendPacket("ib 1278 1");
                    session.SendPacket(session.Character.GenerateSay(string.Format(Language.Instance.GetMessageFromKey("EFFECT_ACTIVATED"), Name), 12));
                }
                break;

            case 1008:
                if (session.Character.StaticBonusList.All(s => s.StaticBonusType != StaticBonusType.PetBackPack))
                {
                    session.Character.StaticBonusList.Add(new StaticBonusDTO
                    {
                        CharacterId     = session.Character.CharacterId,
                        DateEnd         = DateTime.Now.AddDays(EffectValue),
                        StaticBonusType = StaticBonusType.PetBackPack
                    });
                    session.Character.Inventory.RemoveItemAmountFromInventory(1, inv.Id);
                    session.SendPacket(session.Character.GenerateExts());
                    session.SendPacket(session.Character.GenerateSay(string.Format(Language.Instance.GetMessageFromKey("EFFECT_ACTIVATED"), Name), 12));
                }
                break;

            default:
                Logger.Log.Warn(string.Format(Language.Instance.GetMessageFromKey("NO_HANDLER_ITEM"), GetType()));
                break;
            }
        }
Пример #15
0
        public override void Use(ClientSession Session, ref ItemInstance inventory, bool DelayUsed = false, string[] packetsplit = null)
        {
            switch (Effect)
            {
            // wings
            case 650:
                SpecialistInstance specialistInstance = Session.Character.Inventory.LoadBySlotAndType <SpecialistInstance>((byte)EquipmentType.Sp, InventoryType.Wear);
                if (Session.Character.UseSp && specialistInstance != null)
                {
                    if (!DelayUsed)
                    {
                        Session.SendPacket($"qna #u_i^1^{Session.Character.CharacterId}^{(byte)inventory.Type}^{inventory.Slot}^3 {Language.Instance.GetMessageFromKey("ASK_WINGS_CHANGE")}");
                    }
                    else
                    {
                        specialistInstance.Design       = (byte)EffectValue;
                        Session.Character.MorphUpgrade2 = EffectValue;
                        Session.CurrentMap?.Broadcast(Session.Character.GenerateCMode());
                        Session.SendPacket(Session.Character.GenerateStat());
                        Session.SendPacket(Session.Character.GenerateStatChar());

                        inventory.Amount--;
                        if (inventory.Amount > 0)
                        {
                            Session.SendPacket(Session.Character.GenerateInventoryAdd(inventory.ItemVNum, inventory.Amount, inventory.Type, inventory.Slot, 0, 0, 0, 0));
                        }
                        else
                        {
                            Session.Character.Inventory.DeleteFromSlotAndType(inventory.Slot, inventory.Type);
                            Session.SendPacket(Session.Character.GenerateInventoryAdd(-1, 0, inventory.Type, inventory.Slot, 0, 0, 0, 0));
                        }
                    }
                }
                else
                {
                    Session.SendPacket(Session.Character.GenerateMsg(Language.Instance.GetMessageFromKey("NO_SP"), 0));
                }
                break;

            // presentation messages
            case 203:
                if (this != null && !Session.Character.IsVehicled)
                {
                    if (!DelayUsed)
                    {
                        Session.SendPacket(Session.Character.GenerateGuri(10, 2, 1));
                    }
                }
                break;

            // magic lamps
            case 651:
                if (!Session.Character.Inventory.Where(i => i.Type == InventoryType.Wear).Any())
                {
                    if (!DelayUsed)
                    {
                        Session.SendPacket($"qna #u_i^1^{Session.Character.CharacterId}^{(byte)inventory.Type}^{inventory.Slot}^3 {Language.Instance.GetMessageFromKey("ASK_USE")}");
                    }
                    else
                    {
                        Session.Character.ChangeSex();
                        inventory.Amount--;
                        if (inventory.Amount > 0)
                        {
                            Session.SendPacket(Session.Character.GenerateInventoryAdd(inventory.ItemVNum, inventory.Amount, inventory.Type, inventory.Slot, 0, 0, 0, 0));
                        }
                        else
                        {
                            Session.Character.Inventory.DeleteFromSlotAndType(inventory.Slot, inventory.Type);
                            Session.SendPacket(Session.Character.GenerateInventoryAdd(-1, 0, inventory.Type, inventory.Slot, 0, 0, 0, 0));
                        }
                    }
                }
                else
                {
                    Session.SendPacket(Session.Character.GenerateMsg(Language.Instance.GetMessageFromKey("EQ_NOT_EMPTY"), 0));
                }
                break;

            // vehicles
            case 1000:
                SpecialistInstance sp = Session.Character.Inventory.LoadBySlotAndType <SpecialistInstance>((byte)EquipmentType.Sp, InventoryType.Wear);
                if (!DelayUsed && !Session.Character.IsVehicled)
                {
                    if (Session.Character.IsSitting)
                    {
                        Session.Character.IsSitting = false;
                        Session.CurrentMap?.Broadcast(Session.Character.GenerateRest());
                    }
                    Session.SendPacket(Session.Character.GenerateDelay(3000, 3, $"#u_i^1^{Session.Character.CharacterId}^{(byte)inventory.Type}^{inventory.Slot}^2"));
                }
                else
                {
                    if (!Session.Character.IsVehicled)
                    {
                        Session.Character.IsVehicled    = true;
                        Session.Character.MorphUpgrade  = 0;
                        Session.Character.MorphUpgrade2 = 0;
                        Session.Character.Morph         = Morph + Session.Character.Gender;
                        Session.Character.Speed         = Speed;
                        Session.CurrentMap?.Broadcast(Session.Character.GenerateEff(196), Session.Character.MapX, Session.Character.MapY);
                        Session.CurrentMap?.Broadcast(Session.Character.GenerateCMode());
                        Session.SendPacket(Session.Character.GenerateCond());
                    }
                    else
                    {
                        Session.Character.RemoveVehicle();
                    }
                }
                break;

            default:
                Logger.Log.Warn(String.Format(Language.Instance.GetMessageFromKey("NO_HANDLER_ITEM"), this.GetType().ToString()));
                break;
            }
        }
Пример #16
0
        public override void Use(ClientSession session, ref ItemInstance inv, bool delay = false, string[] packetsplit = null)
        {
            switch (Effect)
            {
            case 69:
                if (EffectValue == 1 || EffectValue == 2)
                {
                    BoxInstance box = session.Character.Inventory.LoadBySlotAndType <BoxInstance>(inv.Slot, InventoryType.Equipment);
                    if (box != null)
                    {
                        if (box.HoldingVNum == 0)
                        {
                            session.SendPacket($"wopen 44 {inv.Slot}");
                        }
                        else
                        {
                            ItemInstance newInv = session.Character.Inventory.AddNewToInventory(box.HoldingVNum);
                            if (newInv != null)
                            {
                                SpecialistInstance specialist = session.Character.Inventory.LoadBySlotAndType <SpecialistInstance>(newInv.Slot, newInv.Type);

                                if (specialist != null)
                                {
                                    specialist.SlDamage       = box.SlDamage;
                                    specialist.SlDefence      = box.SlDefence;
                                    specialist.SlElement      = box.SlElement;
                                    specialist.SlHP           = box.SlHP;
                                    specialist.SpDamage       = box.SpDamage;
                                    specialist.SpDark         = box.SpDark;
                                    specialist.SpDefence      = box.SpDefence;
                                    specialist.SpElement      = box.SpElement;
                                    specialist.SpFire         = box.SpFire;
                                    specialist.SpHP           = box.SpHP;
                                    specialist.SpLevel        = box.SpLevel;
                                    specialist.SpLight        = box.SpLight;
                                    specialist.SpStoneUpgrade = box.SpStoneUpgrade;
                                    specialist.SpWater        = box.SpWater;
                                    specialist.Upgrade        = box.Upgrade;
                                    specialist.XP             = box.XP;
                                }

                                short Slot = inv.Slot;
                                if (Slot != -1)
                                {
                                    session.SendPacket(session.Character.GenerateSay($"{Language.Instance.GetMessageFromKey("ITEM_ACQUIRED")}: {specialist.Item.Name} + {specialist.Upgrade}", 12));
                                    session.SendPacket(session.Character.GenerateInventoryAdd(specialist.ItemVNum, newInv.Amount, specialist.Type, newInv.Slot, 0, 0, specialist.Upgrade, 0));
                                    session.Character.Inventory.RemoveItemAmountFromInventory(1, box.Id);
                                }
                            }
                            else
                            {
                                session.SendPacket(session.Character.GenerateMsg(Language.Instance.GetMessageFromKey("NOT_ENOUGH_PLACE"), 0));
                            }
                        }
                    }
                }
                if (EffectValue == 3)
                {
                    BoxInstance box = session.Character.Inventory.LoadBySlotAndType <BoxInstance>(inv.Slot, InventoryType.Equipment);
                    if (box != null)
                    {
                        if (box.HoldingVNum == 0)
                        {
                            session.SendPacket($"guri 26 0 {inv.Slot}");
                        }
                        else
                        {
                            ItemInstance newInv = session.Character.Inventory.AddNewToInventory(box.HoldingVNum);
                            if (newInv != null)
                            {
                                WearableInstance fairy = session.Character.Inventory.LoadBySlotAndType <WearableInstance>(newInv.Slot, newInv.Type);

                                if (fairy != null)
                                {
                                    fairy.ElementRate = box.ElementRate;
                                }

                                short Slot = inv.Slot;
                                if (Slot != -1)
                                {
                                    session.SendPacket(session.Character.GenerateSay($"{Language.Instance.GetMessageFromKey("ITEM_ACQUIRED")}: {fairy.Item.Name} ({fairy.ElementRate}%)", 12));
                                    session.SendPacket(session.Character.GenerateInventoryAdd(fairy.ItemVNum, newInv.Amount, fairy.Type, newInv.Slot, 0, 0, fairy.Upgrade, 0));
                                    session.Character.Inventory.RemoveItemAmountFromInventory(1, box.Id);
                                }
                            }
                            else
                            {
                                session.SendPacket(session.Character.GenerateMsg(Language.Instance.GetMessageFromKey("NOT_ENOUGH_PLACE"), 0));
                            }
                        }
                    }
                }
                if (EffectValue == 4)
                {
                    BoxInstance box = session.Character.Inventory.LoadBySlotAndType <BoxInstance>(inv.Slot, InventoryType.Equipment);
                    if (box != null)
                    {
                        if (box.HoldingVNum == 0)
                        {
                            session.SendPacket($"guri 24 0 {inv.Slot}");
                        }
                        else
                        {
                            ItemInstance newInv = session.Character.Inventory.AddNewToInventory(box.HoldingVNum);
                            if (newInv != null)
                            {
                                short Slot = inv.Slot;
                                if (Slot != -1)
                                {
                                    session.SendPacket(session.Character.GenerateSay($"{Language.Instance.GetMessageFromKey("ITEM_ACQUIRED")}: {newInv.Item.Name} x 1)", 12));
                                    session.SendPacket(session.Character.GenerateInventoryAdd(newInv.ItemVNum, newInv.Amount, newInv.Type, newInv.Slot, 0, 0, newInv.Upgrade, 0));
                                    session.Character.Inventory.RemoveItemAmountFromInventory(1, box.Id);
                                }
                            }
                            else
                            {
                                session.SendPacket(session.Character.GenerateMsg(Language.Instance.GetMessageFromKey("NOT_ENOUGH_PLACE"), 0));
                            }
                        }
                    }
                }

                break;

            default:
                Logger.Log.Warn(string.Format(Language.Instance.GetMessageFromKey("NO_HANDLER_ITEM"), GetType()));
                break;
            }
        }
Пример #17
0
        public override void Use(ClientSession session, ref ItemInstance inv, byte Option = 0, string[] packetsplit = null)
        {
            switch (Effect)
            {
            case 0:
                if (Option == 0)
                {
                    if (packetsplit.Length == 9)
                    {
                        BoxInstance box = session.Character.Inventory.LoadBySlotAndType <BoxInstance>(inv.Slot, InventoryType.Equipment);
                        if (box != null)
                        {
                            if (box.Item.ItemSubType == 3)
                            {
                                session.SendPacket($"qna #guri^300^8023^{inv.Slot} {Language.Instance.GetMessageFromKey("ASK_OPEN_BOX")}");
                            }
                            else if (box.HoldingVNum == 0)
                            {
                                session.SendPacket($"qna #guri^300^8023^{inv.Slot}^{packetsplit[3]} {Language.Instance.GetMessageFromKey("ASK_STORE_PET")}");
                            }
                            else
                            {
                                session.SendPacket($"qna #guri^300^8023^{inv.Slot} {Language.Instance.GetMessageFromKey("ASK_RELEASE_PET")}");
                            }
                        }
                    }
                }
                else
                {
                    //u_i 2 2000000 0 21 0 0
                    BoxInstance box = session.Character.Inventory.LoadBySlotAndType <BoxInstance>(inv.Slot, InventoryType.Equipment);
                    if (box != null)
                    {
                        if (box.Item.ItemSubType == 3)
                        {
                            List <RollGeneratedItemDTO> roll = box.Item.RollGeneratedItems.Where(s => s.MinimumOriginalItemRare <= box.Rare && s.MaximumOriginalItemRare >= box.Rare && s.OriginalItemDesign == box.Design).ToList();
                            int probabilities          = roll.Sum(s => s.Probability);
                            int rnd                    = ServerManager.Instance.RandomNumber(0, probabilities);
                            int currentrnd             = 0;
                            List <ItemInstance> newInv = null;
                            foreach (RollGeneratedItemDTO rollitem in roll)
                            {
                                if (newInv == null)
                                {
                                    currentrnd += rollitem.Probability;
                                    if (currentrnd >= rnd)
                                    {
                                        newInv = session.Character.Inventory.AddNewToInventory(rollitem.ItemGeneratedVNum, rollitem.ItemGeneratedAmount);
                                        if (newInv.Any())
                                        {
                                            short Slot = inv.Slot;
                                            if (Slot != -1)
                                            {
                                                session.SendPacket(session.Character.GenerateSay($"{Language.Instance.GetMessageFromKey("ITEM_ACQUIRED")}: {newInv.First().Item.Name} x 1)", 12));
                                                newInv.ForEach(s => session.SendPacket(s.GenerateInventoryAdd()));
                                                session.Character.Inventory.RemoveItemAmountFromInventory(1, box.Id);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        else if (box.HoldingVNum == 0)
                        {
                            if (packetsplit.Length == 1)
                            {
                                if (int.TryParse(packetsplit[0], out int PetId))
                                {
                                    Mate mate = session.Character.Mates.FirstOrDefault(s => s.MateTransportId == PetId);
                                    box.HoldingVNum = mate.NpcMonsterVNum;
                                    box.SpLevel     = mate.Level;
                                    box.SpDamage    = mate.Attack;
                                    box.SpDefence   = mate.Defence;
                                    session.Character.Mates.Remove(mate);
                                    session.SendPacket(UserInterfaceHelper.Instance.GenerateInfo(Language.Instance.GetMessageFromKey("PET_STORED")));
                                    session.SendPacket(UserInterfaceHelper.Instance.GeneratePClear());
                                    session.SendPackets(session.Character.GenerateScP());
                                    session.SendPackets(session.Character.GenerateScN());
                                    session.CurrentMapInstance?.Broadcast(mate.GenerateOut());
                                }
                            }
                        }
                        else
                        {
                            NpcMonster heldMonster = ServerManager.Instance.GetNpc(box.HoldingVNum);
                            if (heldMonster != null)
                            {
                                Mate mate = new Mate(session.Character, heldMonster, 1, MateType.Pet)
                                {
                                    Attack  = box.SpDamage,
                                    Defence = box.SpDefence
                                };
                                if (session.Character.AddPet(mate))
                                {
                                    session.Character.Inventory.RemoveItemAmountFromInventory(1, inv.Id);
                                    session.SendPacket(UserInterfaceHelper.Instance.GenerateInfo(Language.Instance.GetMessageFromKey("PET_LEAVE_BEAD")));
                                }
                            }
                        }
                    }
                }
                break;

            case 1:
                if (Option == 0)
                {
                    session.SendPacket($"qna #guri^300^8023^{inv.Slot} {Language.Instance.GetMessageFromKey("ASK_RELEASE_PET")}");
                }
                else
                {
                    NpcMonster heldMonster = ServerManager.Instance.GetNpc((short)EffectValue);
                    if (session.CurrentMapInstance == session.Character.Miniland && heldMonster != null)
                    {
                        Mate mate = new Mate(session.Character, heldMonster, LevelMinimum, ItemSubType == 1 ? MateType.Partner : MateType.Pet);
                        if (session.Character.AddPet(mate))
                        {
                            session.Character.Inventory.RemoveItemAmountFromInventory(1, inv.Id);
                            session.SendPacket(UserInterfaceHelper.Instance.GenerateInfo(Language.Instance.GetMessageFromKey("PET_LEAVE_BEAD")));
                        }
                    }
                    else
                    {
                        //TODO ADD MINILAND SENDPACKET
                    }
                }

                break;

            case 69:
                if (EffectValue == 1 || EffectValue == 2)
                {
                    BoxInstance box = session.Character.Inventory.LoadBySlotAndType <BoxInstance>(inv.Slot, InventoryType.Equipment);
                    if (box != null)
                    {
                        if (box.HoldingVNum == 0)
                        {
                            session.SendPacket($"wopen 44 {inv.Slot}");
                        }
                        else
                        {
                            List <ItemInstance> newInv = session.Character.Inventory.AddNewToInventory(box.HoldingVNum);
                            if (newInv.Any())
                            {
                                ItemInstance       itemInstance = newInv.First();
                                SpecialistInstance specialist   = session.Character.Inventory.LoadBySlotAndType <SpecialistInstance>(itemInstance.Slot, itemInstance.Type);
                                if (specialist != null)
                                {
                                    specialist.SlDamage       = box.SlDamage;
                                    specialist.SlDefence      = box.SlDefence;
                                    specialist.SlElement      = box.SlElement;
                                    specialist.SlHP           = box.SlHP;
                                    specialist.SpDamage       = box.SpDamage;
                                    specialist.SpDark         = box.SpDark;
                                    specialist.SpDefence      = box.SpDefence;
                                    specialist.SpElement      = box.SpElement;
                                    specialist.SpFire         = box.SpFire;
                                    specialist.SpHP           = box.SpHP;
                                    specialist.SpLevel        = box.SpLevel;
                                    specialist.SpLight        = box.SpLight;
                                    specialist.SpStoneUpgrade = box.SpStoneUpgrade;
                                    specialist.SpWater        = box.SpWater;
                                    specialist.Upgrade        = box.Upgrade;
                                    specialist.XP             = box.XP;
                                }
                                short Slot = inv.Slot;
                                if (Slot != -1)
                                {
                                    if (specialist != null)
                                    {
                                        session.SendPacket(session.Character.GenerateSay($"{Language.Instance.GetMessageFromKey("ITEM_ACQUIRED")}: {specialist.Item.Name} + {specialist.Upgrade}", 12));
                                        newInv.ForEach(s => session.SendPacket(specialist.GenerateInventoryAdd()));
                                    }
                                    session.Character.Inventory.RemoveItemAmountFromInventory(1, box.Id);
                                }
                            }
                            else
                            {
                                session.SendPacket(UserInterfaceHelper.Instance.GenerateMsg(Language.Instance.GetMessageFromKey("NOT_ENOUGH_PLACE"), 0));
                            }
                        }
                    }
                }
                if (EffectValue == 3)
                {
                    BoxInstance box = session.Character.Inventory.LoadBySlotAndType <BoxInstance>(inv.Slot, InventoryType.Equipment);
                    if (box != null)
                    {
                        if (box.HoldingVNum == 0)
                        {
                            session.SendPacket($"guri 26 0 {inv.Slot}");
                        }
                        else
                        {
                            List <ItemInstance> newInv = session.Character.Inventory.AddNewToInventory(box.HoldingVNum);
                            if (newInv.Any())
                            {
                                ItemInstance     itemInstance = newInv.First();
                                WearableInstance fairy        = session.Character.Inventory.LoadBySlotAndType <WearableInstance>(itemInstance.Slot, itemInstance.Type);
                                if (fairy != null)
                                {
                                    fairy.ElementRate = box.ElementRate;
                                }
                                short Slot = inv.Slot;
                                if (Slot != -1)
                                {
                                    if (fairy != null)
                                    {
                                        session.SendPacket(session.Character.GenerateSay($"{Language.Instance.GetMessageFromKey("ITEM_ACQUIRED")}: {fairy.Item.Name} ({fairy.ElementRate}%)", 12));
                                        newInv.ForEach(s => session.SendPacket(fairy.GenerateInventoryAdd()));
                                    }
                                    session.Character.Inventory.RemoveItemAmountFromInventory(1, box.Id);
                                }
                            }
                            else
                            {
                                session.SendPacket(UserInterfaceHelper.Instance.GenerateMsg(Language.Instance.GetMessageFromKey("NOT_ENOUGH_PLACE"), 0));
                            }
                        }
                    }
                }
                if (EffectValue == 4)
                {
                    BoxInstance box = session.Character.Inventory.LoadBySlotAndType <BoxInstance>(inv.Slot, InventoryType.Equipment);
                    if (box != null)
                    {
                        if (box.HoldingVNum == 0)
                        {
                            session.SendPacket($"guri 24 0 {inv.Slot}");
                        }
                        else
                        {
                            List <ItemInstance> newInv = session.Character.Inventory.AddNewToInventory(box.HoldingVNum);
                            if (newInv.Any())
                            {
                                short Slot = inv.Slot;
                                if (Slot != -1)
                                {
                                    session.SendPacket(session.Character.GenerateSay($"{Language.Instance.GetMessageFromKey("ITEM_ACQUIRED")}: {newInv.First().Item.Name} x 1)", 12));
                                    newInv.ForEach(s => session.SendPacket(s.GenerateInventoryAdd()));
                                    session.Character.Inventory.RemoveItemAmountFromInventory(1, box.Id);
                                }
                            }
                            else
                            {
                                session.SendPacket(UserInterfaceHelper.Instance.GenerateMsg(Language.Instance.GetMessageFromKey("NOT_ENOUGH_PLACE"), 0));
                            }
                        }
                    }
                }
                break;

            default:
                Logger.Log.Warn(string.Format(Language.Instance.GetMessageFromKey("NO_HANDLER_ITEM"), GetType()));
                break;
            }
        }
        public override void Use(ClientSession session, ref ItemInstance inv, bool delay = false, string[] packetsplit = null)
        {
            switch (Effect)
            {
            default:
                short         slot           = inv.Slot;
                InventoryType itemToWearType = inv.Type;

                if (inv == null)
                {
                    return;
                }
                if (ItemValidTime > 0 && inv.IsBound)
                {
                    inv.ItemDeleteTime = DateTime.Now.AddSeconds(ItemValidTime);
                }
                if (!inv.IsBound)
                {
                    if (!delay && ((EquipmentSlot == EquipmentType.Fairy && (MaxElementRate == 70 || MaxElementRate == 80)) || EquipmentSlot == EquipmentType.CostumeHat || EquipmentSlot == EquipmentType.CostumeSuit || EquipmentSlot == EquipmentType.WeaponSkin))
                    {
                        session.SendPacket($"qna #u_i^1^{session.Character.CharacterId}^{(byte)itemToWearType}^{slot}^1 {Language.Instance.GetMessageFromKey("ASK_BIND")}");
                        return;
                    }
                    if (delay)
                    {
                        inv.BoundCharacterId = session.Character.CharacterId;
                    }
                }

                double timeSpanSinceLastSpUsage = (DateTime.Now - Process.GetCurrentProcess().StartTime.AddSeconds(-50)).TotalSeconds - session.Character.LastSp;

                if (EquipmentSlot == EquipmentType.Sp && inv.Rare == -2)
                {
                    session.SendPacket(session.Character.GenerateMsg(Language.Instance.GetMessageFromKey("CANT_EQUIP_DESTROYED_SP"), 0));
                    return;
                }

                if (EquipmentSlot == EquipmentType.Sp && timeSpanSinceLastSpUsage <= session.Character.SpCooldown && session.Character.Inventory.LoadBySlotAndType <SpecialistInstance>((byte)EquipmentType.Sp, InventoryType.Specialist) != null)
                {
                    session.SendPacket(session.Character.GenerateMsg(string.Format(Language.Instance.GetMessageFromKey("SP_INLOADING"), session.Character.SpCooldown - (int)Math.Round(timeSpanSinceLastSpUsage)), 0));
                    return;
                }
                if ((ItemType != ItemType.Weapon &&
                     ItemType != ItemType.Armor &&
                     ItemType != ItemType.Fashion &&
                     ItemType != ItemType.Jewelery &&
                     ItemType != ItemType.Specialist) ||
                    LevelMinimum > (IsHeroic ? session.Character.HeroLevel : session.Character.Level) || (Sex != 0 && Sex != (byte)session.Character.Gender + 1) ||
                    (ItemType != ItemType.Jewelery && EquipmentSlot != EquipmentType.Boots && EquipmentSlot != EquipmentType.Gloves && ((Class >> (byte)session.Character.Class) & 1) != 1))
                {
                    session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("BAD_EQUIPMENT"), 10));
                    return;
                }

                if (session.Character.UseSp)
                {
                    SpecialistInstance sp = session.Character.Inventory.LoadBySlotAndType <SpecialistInstance>((byte)EquipmentType.Sp, InventoryType.Wear);

                    if (sp.Item.Element != 0 && EquipmentSlot == EquipmentType.Fairy && Element != sp.Item.Element && Element != sp.Item.SecondaryElement)
                    {
                        session.SendPacket(session.Character.GenerateMsg(Language.Instance.GetMessageFromKey("BAD_FAIRY"), 0));
                        return;
                    }
                }

                if (session.Character.UseSp && EquipmentSlot == EquipmentType.Sp)
                {
                    session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("SP_BLOCKED"), 10));
                    return;
                }

                if (session.Character.JobLevel < LevelJobMinimum)
                {
                    session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("LOW_JOB_LVL"), 10));
                    return;
                }

                ItemInstance currentlyEquippedItem = session.Character.Inventory.LoadBySlotAndType((short)EquipmentSlot, InventoryType.Wear);
                if (EquipmentSlot == EquipmentType.Amulet)
                {
                    session.SendPacket(session.Character.GenerateEff(39));
                    inv.BoundCharacterId = session.Character.CharacterId;
                }

                if (currentlyEquippedItem == null)
                {
                    // move from equipment to wear
                    session.Character.Inventory.MoveInInventory(inv.Slot, itemToWearType, InventoryType.Wear);
                    session.SendPacket(session.Character.GenerateInventoryAdd(-1, 0, itemToWearType, slot, 0, 0, 0, 0));
                    session.SendPacket(session.Character.GenerateStatChar());
                    session.CurrentMap?.Broadcast(session.Character.GenerateEq());
                    session.SendPacket(session.Character.GenerateEquipment());
                    session.CurrentMap?.Broadcast(session.Character.GeneratePairy());
                }
                else
                {
                    // move from wear to equipment and back
                    session.Character.Inventory.MoveInInventory(currentlyEquippedItem.Slot, InventoryType.Wear, itemToWearType, inv.Slot);

                    session.SendPacket(session.Character.GenerateInventoryAdd(-1, 0, itemToWearType, slot, 0, 0, 0, 0));
                    session.SendPacket(session.Character.GenerateInventoryAdd(currentlyEquippedItem.ItemVNum, currentlyEquippedItem.Amount,
                                                                              currentlyEquippedItem.Type, currentlyEquippedItem.Slot, currentlyEquippedItem.Rare, currentlyEquippedItem.Design, currentlyEquippedItem.Upgrade, (currentlyEquippedItem as SpecialistInstance)?.SpStoneUpgrade ?? (byte)0));

                    session.SendPacket(session.Character.GenerateStatChar());
                    session.CurrentMap?.Broadcast(session.Character.GenerateEq());
                    session.SendPacket(session.Character.GenerateEquipment());
                    session.CurrentMap?.Broadcast(session.Character.GeneratePairy());
                }

                if (EquipmentSlot == EquipmentType.Fairy)
                {
                    WearableInstance fairy = session.Character.Inventory.LoadBySlotAndType <WearableInstance>((byte)EquipmentType.Fairy, InventoryType.Wear);
                    session.SendPacket(session.Character.GenerateSay(string.Format(Language.Instance.GetMessageFromKey("FAIRYSTATS"), fairy.XP, CharacterHelper.LoadFairyXPData(fairy.ElementRate + fairy.Item.ElementRate)), 10));
                }
                break;
            }
        }
Пример #19
0
        public override void Use(ClientSession session, ref ItemInstance inv, byte option = 0, string[] packetsplit = null)
        {
            switch (Effect)
            {
            default:
                bool delay = false;
                if (option == 255)
                {
                    delay  = true;
                    option = 0;
                }
                Mate mate = null;
                if (option != 0)
                {
                    mate = session.Character.Mates.FirstOrDefault(s => s.MateType == MateType.Partner && s.PetId == (option - 1));
                }
                short         slot      = inv.Slot;
                InventoryType equipment = InventoryType.Wear;
                switch (option)
                {
                case 1:
                    equipment = InventoryType.FirstPartnerInventory;
                    break;

                case 2:
                    equipment = InventoryType.SecondPartnerInventory;
                    break;

                case 3:
                    equipment = InventoryType.ThirdPartnerInventory;
                    break;
                }

                InventoryType itemToWearType = inv.Type;

                if (inv == null)
                {
                    return;
                }

                if (ItemValidTime > 0 && inv.IsBound)
                {
                    inv.ItemDeleteTime = DateTime.Now.AddSeconds(ItemValidTime);
                }
                if (!inv.IsBound)
                {
                    if (!delay && (EquipmentSlot == EquipmentType.Fairy && (MaxElementRate == 70 || MaxElementRate == 80) || EquipmentSlot == EquipmentType.CostumeHat || EquipmentSlot == EquipmentType.CostumeSuit || EquipmentSlot == EquipmentType.WeaponSkin))
                    {
                        session.SendPacket($"qna #u_i^1^{session.Character.CharacterId}^{(byte)itemToWearType}^{slot}^1 {Language.Instance.GetMessageFromKey("ASK_BIND")}");
                        return;
                    }
                    if (delay)
                    {
                        inv.BoundCharacterId = session.Character.CharacterId;
                    }
                }

                double timeSpanSinceLastSpUsage = (DateTime.Now - Process.GetCurrentProcess().StartTime.AddSeconds(-50)).TotalSeconds - session.Character.LastSp;

                if (EquipmentSlot == EquipmentType.Sp && inv.Rare == -2)
                {
                    session.SendPacket(UserInterfaceHelper.Instance.GenerateMsg(Language.Instance.GetMessageFromKey("CANT_EQUIP_DESTROYED_SP"), 0));
                    return;
                }

                if (option == 0)
                {
                    if (EquipmentSlot == EquipmentType.Sp && timeSpanSinceLastSpUsage <= session.Character.SpCooldown && session.Character.Inventory.LoadBySlotAndType <SpecialistInstance>((byte)EquipmentType.Sp, InventoryType.Specialist) != null)
                    {
                        session.SendPacket(UserInterfaceHelper.Instance.GenerateMsg(string.Format(Language.Instance.GetMessageFromKey("SP_INLOADING"), session.Character.SpCooldown - (int)Math.Round(timeSpanSinceLastSpUsage)), 0));
                        return;
                    }

                    if (ItemType != ItemType.Weapon && ItemType != ItemType.Armor && ItemType != ItemType.Fashion && ItemType != ItemType.Jewelery && ItemType != ItemType.Specialist ||
                        LevelMinimum > (IsHeroic ? session.Character.HeroLevel : session.Character.Level) || Sex != 0 && Sex != (byte)session.Character.Gender + 1 ||
                        ItemType != ItemType.Jewelery && EquipmentSlot != EquipmentType.Boots && EquipmentSlot != EquipmentType.Gloves && ((Class >> (byte)session.Character.Class) & 1) != 1)
                    {
                        session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("BAD_EQUIPMENT"), 10));
                        return;
                    }

                    if (session.Character.UseSp)
                    {
                        SpecialistInstance sp = session.Character.Inventory.LoadBySlotAndType <SpecialistInstance>((byte)EquipmentType.Sp, equipment);

                        if (sp != null && sp.Item.Element != 0 && EquipmentSlot == EquipmentType.Fairy && Element != sp.Item.Element && Element != sp.Item.SecondaryElement)
                        {
                            session.SendPacket(UserInterfaceHelper.Instance.GenerateMsg(Language.Instance.GetMessageFromKey("BAD_FAIRY"), 0));
                            return;
                        }
                    }

                    if (session.Character.UseSp && EquipmentSlot == EquipmentType.Sp)
                    {
                        session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("SP_BLOCKED"), 10));
                        return;
                    }

                    if (session.Character.JobLevel < LevelJobMinimum)
                    {
                        session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("LOW_JOB_LVL"), 10));
                        return;
                    }
                }
                else if (mate != null)
                {
                    if (mate.Level < LevelMinimum)
                    {
                        session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("BAD_EQUIPMENT"), 10));
                        return;
                    }
                    switch (EquipmentSlot)
                    {
                    case EquipmentType.Armor:
                        if (ItemSubType == 4)
                        {
                            mate.ArmorInstance = inv;
                            break;
                        }
                        else
                        {
                            goto default;
                        }

                    case EquipmentType.MainWeapon:
                        if (ItemSubType == 12)
                        {
                            mate.WeaponInstance = inv;
                            break;
                        }
                        else
                        {
                            goto default;
                        }

                    case EquipmentType.Gloves:
                        mate.GlovesInstance = inv;
                        break;

                    case EquipmentType.Boots:
                        mate.BootsInstance = inv;
                        break;

                    case EquipmentType.Sp:
                        if (ItemSubType == 4)
                        {
                            mate.SpInstance = inv;
                            break;
                        }
                        else
                        {
                            goto default;
                        }

                    default:
                        session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("BAD_EQUIPMENT"), 10));
                        return;
                    }
                }

                ItemInstance currentlyEquippedItem = session.Character.Inventory.LoadBySlotAndType((short)EquipmentSlot, equipment);

                if (currentlyEquippedItem == null)
                {
                    // move from equipment to wear
                    session.Character.Inventory.MoveInInventory(inv.Slot, itemToWearType, equipment);
                    session.SendPacket(UserInterfaceHelper.Instance.GenerateInventoryRemove(itemToWearType, slot));
                }
                else
                {
                    // move from wear to equipment and back
                    session.Character.Inventory.MoveInInventory(currentlyEquippedItem.Slot, equipment, itemToWearType, inv.Slot);
                    session.SendPacket(currentlyEquippedItem.GenerateInventoryAdd());
                    session.Character.EquipmentBCards = session.Character.EquipmentBCards.Replace(o => o.ItemVNum != currentlyEquippedItem.ItemVNum);
                    switch (currentlyEquippedItem.Slot)
                    {
                    case (byte)EquipmentType.Armor:
                        session.Character.Inventory.Armor = null;
                        break;

                    case (byte)EquipmentType.MainWeapon:
                        session.Character.Inventory.PrimaryWeapon = null;
                        break;

                    case (byte)EquipmentType.SecondaryWeapon:
                        session.Character.Inventory.SecondaryWeapon = null;
                        break;
                    }
                }
                inv.Item.BCards.ForEach(s => session.Character.EquipmentBCards.Add(s));

                if (inv is WearableInstance wearableInstance)
                {
                    if (wearableInstance.EquipmentOptions != null)
                    {
                        switch (wearableInstance.Item.ItemType)
                        {
                        case ItemType.Armor:
                        case ItemType.Weapon:
                            switch (wearableInstance.Slot)
                            {
                            case (byte)EquipmentType.Armor:
                                session.Character.Inventory.Armor = wearableInstance;
                                break;

                            case (byte)EquipmentType.MainWeapon:
                                session.Character.Inventory.PrimaryWeapon = wearableInstance;
                                break;

                            case (byte)EquipmentType.SecondaryWeapon:
                                session.Character.Inventory.SecondaryWeapon = wearableInstance;
                                break;
                            }
                            EquipmentOptionHelper.Instance.ShellToBCards(wearableInstance.EquipmentOptions, wearableInstance.ItemVNum).ForEach(s => session.Character.EquipmentBCards.Add(s));
                            break;

                        case ItemType.Jewelery:
                            EquipmentOptionHelper.Instance.CellonToBCards(wearableInstance.EquipmentOptions, wearableInstance.ItemVNum).ForEach(s => session.Character.EquipmentBCards.Add(s));
                            break;
                        }
                    }
                }

                if (option == 0)
                {
                    session.SendPacket(session.Character.GenerateStatChar());
                    session.CurrentMapInstance?.Broadcast(session.Character.GenerateEq());
                    session.SendPacket(session.Character.GenerateEquipment());
                    session.CurrentMapInstance?.Broadcast(session.Character.GeneratePairy());

                    switch (EquipmentSlot)
                    {
                    case EquipmentType.Fairy:
                        WearableInstance fairy = session.Character.Inventory.LoadBySlotAndType <WearableInstance>((byte)EquipmentType.Fairy, equipment);
                        session.SendPacket(session.Character.GenerateSay(string.Format(Language.Instance.GetMessageFromKey("FAIRYSTATS"), fairy.XP, CharacterHelper.LoadFairyXpData(fairy.ElementRate + fairy.Item.ElementRate)), 10));
                        break;

                    case EquipmentType.Amulet:
                        session.SendPacket(session.Character.GenerateEff(39));
                        inv.BoundCharacterId = session.Character.CharacterId;
                        break;
                    }
                }
                else if (mate != null)
                {
                    session.SendPacket(mate.GenerateScPacket());
                }
                break;
            }
        }
Пример #20
0
        public override void Use(ClientSession session, ref Inventory inventory, bool DelayUsed = false)
        {
            switch (Effect)
            {
            default:
                short         slot = inventory.Slot;
                InventoryType type = inventory.Type;

                if (inventory == null)
                {
                    return;
                }
                if (ItemValidTime > 0 && ((ItemInstance)inventory.ItemInstance).IsBound)
                {
                    inventory.ItemInstance.ItemDeleteTime = DateTime.Now.AddSeconds(ItemValidTime);
                }
                if (!((ItemInstance)inventory.ItemInstance).IsBound)
                {
                    if (!DelayUsed && ((EquipmentSlot == (byte)EquipmentType.Fairy && (MaxElementRate == 70 || MaxElementRate == 80)) || (EquipmentSlot == (byte)EquipmentType.CostumeHat || EquipmentSlot == (byte)EquipmentType.CostumeSuit || EquipmentSlot == (byte)EquipmentType.WeaponSkin)))
                    {
                        session.SendPacket($"qna #u_i^1^{session.Character.CharacterId}^{(byte)type}^{slot}^1 {Language.Instance.GetMessageFromKey("ASK_BIND")}");
                        return;
                    }
                    else if (DelayUsed)
                    {
                        inventory.ItemInstance.BoundCharacterId = session.Character.CharacterId;
                    }
                }

                double timeSpanSinceLastSpUsage = (DateTime.Now - Process.GetCurrentProcess().StartTime.AddSeconds(-50)).TotalSeconds - session.Character.LastSp;

                if (EquipmentSlot == (byte)EquipmentType.Sp && inventory.ItemInstance.Rare == -2)
                {
                    session.SendPacket(session.Character.GenerateMsg(Language.Instance.GetMessageFromKey("CANT_EQUIP_DESTROYED_SP"), 0));
                    return;
                }

                if (EquipmentSlot == (byte)EquipmentType.Sp && timeSpanSinceLastSpUsage <= session.Character.SpCooldown && session.Character.EquipmentList.LoadInventoryBySlotAndType((byte)EquipmentType.Sp, InventoryType.Sp) != null)
                {
                    session.SendPacket(session.Character.GenerateMsg(string.Format(Language.Instance.GetMessageFromKey("SP_INLOADING"), session.Character.SpCooldown - (int)Math.Round(timeSpanSinceLastSpUsage)), 0));
                    return;
                }
                if ((ItemType != (byte)Domain.ItemType.Weapon &&
                     ItemType != (byte)Domain.ItemType.Armor &&
                     ItemType != (byte)Domain.ItemType.Fashion &&
                     ItemType != (byte)Domain.ItemType.Jewelery &&
                     ItemType != (byte)Domain.ItemType.Specialist) ||
                    LevelMinimum > (IsHeroic ? session.Character.HeroLevel : session.Character.Level) || (Sex != 0 && Sex != session.Character.Gender + 1) ||
                    ((ItemType != (byte)Domain.ItemType.Jewelery && EquipmentSlot != (byte)EquipmentType.Boots && EquipmentSlot != (byte)EquipmentType.Gloves) && ((Class >> session.Character.Class) & 1) != 1))
                {
                    session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("BAD_EQUIPMENT"), 10));
                    return;
                }

                if (session.Character.UseSp)
                {
                    SpecialistInstance sp = session.Character.EquipmentList.LoadBySlotAndType <SpecialistInstance>(
                        (byte)EquipmentType.Sp,
                        InventoryType.Equipment);

                    if (sp.Item.Element != 0 && EquipmentSlot == (byte)EquipmentType.Fairy && Element != sp.Item.Element && Element != sp.Item.SecondaryElement)
                    {
                        session.SendPacket(session.Character.GenerateMsg(Language.Instance.GetMessageFromKey("BAD_FAIRY"), 0));
                        return;
                    }
                }

                if (session.Character.UseSp && EquipmentSlot == (byte)EquipmentType.Sp)
                {
                    session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("SP_BLOCKED"), 10));
                    return;
                }

                if (session.Character.JobLevel < LevelJobMinimum)
                {
                    session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("LOW_JOB_LVL"), 10));
                    return;
                }

                Inventory equip = session.Character.EquipmentList.LoadInventoryBySlotAndType(EquipmentSlot, InventoryType.Equipment);
                if (EquipmentSlot == (byte)EquipmentType.Amulet)
                {
                    session.SendPacket(session.Character.GenerateEff(39));
                    inventory.ItemInstance.BoundCharacterId = session.Character.CharacterId;
                }

                if (equip == null)
                {
                    session.Character.EquipmentList.AddToInventoryWithSlotAndType(inventory.ItemInstance as ItemInstance, InventoryType.Equipment, EquipmentSlot);
                    session.SendPacket(session.Character.GenerateInventoryAdd(-1, 0, type, slot, 0, 0, 0, 0));
                    session.Character.InventoryList.DeleteFromSlotAndType(inventory.Slot, inventory.Type);
                    session.SendPacket(session.Character.GenerateStatChar());
                    session.CurrentMap?.Broadcast(session.Character.GenerateEq());
                    session.SendPacket(session.Character.GenerateEquipment());
                    session.CurrentMap?.Broadcast(session.Character.GeneratePairy());
                }
                else
                {
                    session.Character.InventoryList.DeleteFromSlotAndType(inventory.Slot, inventory.Type);
                    session.Character.EquipmentList.DeleteFromSlotAndType(equip.Slot, equip.Type);
                    session.SendPacket(session.Character.GenerateInventoryAdd(-1, 0, type, slot, 0, 0, 0, 0));
                    session.Character.EquipmentList.AddToInventoryWithSlotAndType(inventory.ItemInstance as ItemInstance, InventoryType.Equipment, EquipmentSlot);
                    session.Character.InventoryList.AddToInventoryWithSlotAndType(equip.ItemInstance as ItemInstance, type, slot);
                    session.SendPacket(session.Character.GenerateInventoryAdd(equip.ItemInstance.ItemVNum, equip.ItemInstance.Amount, type, slot, equip.ItemInstance.Rare, equip.ItemInstance.Design, equip.ItemInstance.Upgrade, 0));
                    session.SendPacket(session.Character.GenerateStatChar());
                    session.CurrentMap?.Broadcast(session.Character.GenerateEq());
                    session.SendPacket(session.Character.GenerateEquipment());
                    session.CurrentMap?.Broadcast(session.Character.GeneratePairy());
                }

                if (EquipmentSlot == (byte)EquipmentType.Fairy)
                {
                    WearableInstance fairy = session.Character.EquipmentList.LoadBySlotAndType <WearableInstance>((byte)EquipmentType.Fairy, InventoryType.Equipment);
                    session.SendPacket(session.Character.GenerateSay(String.Format(Language.Instance.GetMessageFromKey("FAIRYSTATS"), fairy.XP, CharacterHelper.LoadFairyXpData((fairy.ElementRate + fairy.Item.ElementRate))), 10));
                }
                break;
            }
        }