Пример #1
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;
            }
        }
Пример #2
0
        public string GenerateEInfo()
        {
            EquipmentType equipmentslot = Item.EquipmentSlot;
            ItemType      itemType      = Item.ItemType;
            byte          classe        = Item.Class;
            byte          subtype       = Item.ItemSubType;
            DateTime      test          = ItemDeleteTime ?? DateTime.Now;
            long          time          = ItemDeleteTime != null ? (long)test.Subtract(DateTime.Now).TotalSeconds : 0;
            long          seconds       = IsBound ? time : Item.ItemValidTime;

            if (seconds < 0)
            {
                seconds = 0;
            }
            switch (itemType)
            {
            case ItemType.Weapon:
                switch (equipmentslot)
                {
                case EquipmentType.MainWeapon:
                    switch (classe)
                    {
                    case 4:
                        return($"e_info 1 {ItemVNum} {Rare} {Upgrade} {(IsFixed ? 1 : 0)} {Item.LevelMinimum} {Item.DamageMinimum + DamageMinimum} {Item.DamageMaximum + DamageMaximum} {Item.HitRate + HitRate} {Item.CriticalLuckRate + CriticalLuckRate} {Item.CriticalRate + CriticalRate} {Ammo} {Item.MaximumAmmo} {Item.Price} -1 0 0 0");            // -1 = {ShellEffectValue} {FirstShell}...

                    case 8:
                        return($"e_info 5 {ItemVNum} {Rare} {Upgrade} {(IsFixed ? 1 : 0)} {Item.LevelMinimum} {Item.DamageMinimum + DamageMinimum} {Item.DamageMaximum + DamageMaximum} {Item.HitRate + HitRate} {Item.CriticalLuckRate + CriticalLuckRate} {Item.CriticalRate + CriticalRate} {Ammo} {Item.MaximumAmmo} {Item.Price} -1 0 0 0");

                    default:
                        return($"e_info 0 {ItemVNum} {Rare} {Upgrade} {(IsFixed ? 1 : 0)} {Item.LevelMinimum} {Item.DamageMinimum + DamageMinimum} {Item.DamageMaximum + DamageMaximum} {Item.HitRate + HitRate} {Item.CriticalLuckRate + CriticalLuckRate} {Item.CriticalRate + CriticalRate} {Ammo} {Item.MaximumAmmo} {Item.Price} -1 0 0 0");
                    }

                case EquipmentType.SecondaryWeapon:
                    switch (classe)
                    {
                    case 1:
                        return($"e_info 1 {ItemVNum} {Rare} {Upgrade} {(IsFixed ? 1 : 0)} {Item.LevelMinimum} {Item.DamageMinimum + DamageMinimum} {Item.DamageMaximum + DamageMaximum} {Item.HitRate + HitRate} {Item.CriticalLuckRate + CriticalLuckRate} {Item.CriticalRate + CriticalRate} {Ammo} {Item.MaximumAmmo} {Item.Price} -1 0 0 0");

                    case 2:
                        return($"e_info 1 {ItemVNum} {Rare} {Upgrade} {(IsFixed ? 1 : 0)} {Item.LevelMinimum} {Item.DamageMinimum + DamageMinimum} {Item.DamageMaximum + DamageMaximum} {Item.HitRate + HitRate} {Item.CriticalLuckRate + CriticalLuckRate} {Item.CriticalRate + CriticalRate} {Ammo} {Item.MaximumAmmo} {Item.Price} -1 0 0 0");

                    default:
                        return($"e_info 0 {ItemVNum} {Rare} {Upgrade} {(IsFixed ? 1 : 0)} {Item.LevelMinimum} {Item.DamageMinimum + DamageMinimum} {Item.DamageMaximum + DamageMaximum} {Item.HitRate + HitRate} {Item.CriticalLuckRate + CriticalLuckRate} {Item.CriticalRate + CriticalRate} {Ammo} {Item.MaximumAmmo} {Item.Price} -1 0 0 0");
                    }
                }
                break;

            case ItemType.Armor:
                return($"e_info 2 {ItemVNum} {Rare} {Upgrade} {(IsFixed ? 1 : 0)} {Item.LevelMinimum} {Item.CloseDefence + CloseDefence} {Item.DistanceDefence + DistanceDefence} {Item.MagicDefence + MagicDefence} {Item.DefenceDodge + DefenceDodge} {Item.Price} -1 0 0 0");

            case ItemType.Fashion:
                switch (equipmentslot)
                {
                case EquipmentType.CostumeHat:
                    return($"e_info 3 {ItemVNum} {Item.LevelMinimum} {Item.CloseDefence + CloseDefence} {Item.DistanceDefence + DistanceDefence} {Item.MagicDefence + MagicDefence} {Item.DefenceDodge + DefenceDodge} {Item.FireResistance + FireResistance} {Item.WaterResistance + WaterResistance} {Item.LightResistance + LightResistance} {Item.DarkResistance + DarkResistance} {Item.Price} {(Item.ItemValidTime == 0 ? -1 : 0)} 2 {(Item.ItemValidTime == 0 ? -1 : seconds / 3600)}");

                case EquipmentType.CostumeSuit:
                    return($"e_info 2 {ItemVNum} {Rare} {Upgrade} {(IsFixed ? 1 : 0)} {Item.LevelMinimum} {Item.CloseDefence + CloseDefence} {Item.DistanceDefence + DistanceDefence} {Item.MagicDefence + MagicDefence} {Item.DefenceDodge + DefenceDodge} {Item.Price} {(Item.ItemValidTime == 0 ? -1 : 0)} 1 {(Item.ItemValidTime == 0 ? -1 : seconds / 3600)}");        // 1 = IsCosmetic -1 = no shells

                default:
                    return($"e_info 3 {ItemVNum} {Item.LevelMinimum} {Item.CloseDefence + CloseDefence} {Item.DistanceDefence + DistanceDefence} {Item.MagicDefence + MagicDefence} {Item.DefenceDodge + DefenceDodge} {Item.FireResistance + FireResistance} {Item.WaterResistance + WaterResistance} {Item.LightResistance + LightResistance} {Item.DarkResistance + DarkResistance} {Item.Price} {Upgrade} 0 -1");        // after Item.Price theres TimesConnected {(Item.ItemValidTime == 0 ? -1 : Item.ItemValidTime / (3600))}
                }

            case ItemType.Jewelery:
                switch (equipmentslot)
                {
                case EquipmentType.Amulet:
                    return($"e_info 4 {ItemVNum} {Item.LevelMinimum} {seconds * 10} 0 0 {Item.Price}");

                case EquipmentType.Fairy:
                    return($"e_info 4 {ItemVNum} {Item.Element} {ElementRate + Item.ElementRate} 0 0 0 0 0");        // last IsNosmall

                default:
                    return($"e_info 4 {ItemVNum} {Item.LevelMinimum} {Item.MaxCellonLvl} {Item.MaxCellon} {Cellon} {Item.Price}");
                }

            case ItemType.Specialist:
                return($"e_info 8 {ItemVNum}");

            case ItemType.Box:
                if (GetType() == typeof(BoxInstance))
                {
                    BoxInstance specialist = (BoxInstance)this;

                    // 0 = NOSMATE pearl 1= npc pearl 2 = sp box 3 = raid box 4= VEHICLE pearl
                    // 5=fairy pearl
                    switch (subtype)
                    {
                    case 0:
                        return(specialist.HoldingVNum == 0 ?
                               $"e_info 7 {ItemVNum} 0" : $"e_info 7 {ItemVNum} 1 {specialist.HoldingVNum} {specialist.SpLevel} {specialist.XP} 100 {specialist.SpDamage} {specialist.SpDefence}");

                    case 2:
                        Item spitem = ServerManager.Instance.GetItem(specialist.HoldingVNum);
                        return(specialist.HoldingVNum == 0 ?
                               $"e_info 7 {ItemVNum} 0" :
                               $"e_info 7 {ItemVNum} 1 {specialist.HoldingVNum} {specialist.SpLevel} {specialist.XP} {CharacterHelper.SPXPData[specialist.SpLevel - 1]} {Upgrade} {CharacterHelper.SlPoint(specialist.SlDamage, 0)} {CharacterHelper.SlPoint(specialist.SlDefence, 1)} {CharacterHelper.SlPoint(specialist.SlElement, 2)} {CharacterHelper.SlPoint(specialist.SlHP, 3)} {CharacterHelper.SPPoint(specialist.SpLevel, Upgrade) - specialist.SlDamage - specialist.SlHP - specialist.SlElement - specialist.SlDefence} {specialist.SpStoneUpgrade} {spitem.FireResistance} {spitem.WaterResistance} {spitem.LightResistance} {spitem.DarkResistance} {specialist.SpDamage} {specialist.SpDefence} {specialist.SpElement} {specialist.SpHP} {specialist.SpFire} {specialist.SpWater} {specialist.SpLight} {specialist.SpDark}");

                    case 4:
                        return(specialist.HoldingVNum == 0 ?
                               $"e_info 11 {ItemVNum} 0" :
                               $"e_info 11 {ItemVNum} 1 {specialist.HoldingVNum}");

                    case 5:
                        Item fairyitem = ServerManager.Instance.GetItem(specialist.HoldingVNum);
                        return(specialist.HoldingVNum == 0 ?
                               $"e_info 12 {ItemVNum} 0" :
                               $"e_info 12 {ItemVNum} 1 {specialist.HoldingVNum} {specialist.ElementRate + fairyitem.ElementRate}");

                    default:
                        return($"e_info 8 {ItemVNum} {Design} {Rare}");
                    }
                }
                return($"e_info 7 {ItemVNum} 0");

            case ItemType.Shell:
                return($"e_info 4 {ItemVNum} {Item.LevelMinimum} {Rare} {Item.Price} 0");    // 0 = Number of effects
            }
            return(string.Empty);
        }
Пример #3
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;
            }
        }
Пример #4
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;
            }
        }