SendPacket() 공개 메소드

public SendPacket ( PacketDefinition packet, byte priority = 10 ) : void
packet PacketDefinition
priority byte
리턴 void
예제 #1
0
 public void Sync(ClientSession session, Item item)
 {
     for (session.Character.MaxSnack = 0; session.Character.MaxSnack < 5; session.Character.MaxSnack++)
     {
         if (session.Character.Hp <= 0)
         {
             return;
         }
         session.Character.Hp += session.Character.SnackHp;
         session.Character.Mp += session.Character.SnackMp;
         if (session.Character.Mp > session.Character.MPLoad())
         {
             session.Character.Mp = (int)session.Character.MPLoad();
         }
         if (session.Character.Hp > session.Character.HPLoad())
         {
             session.Character.Hp = (int)session.Character.HPLoad();
         }
         if (session.Character.Hp < session.Character.HPLoad() || session.Character.Mp < session.Character.MPLoad())
         {
             session.CurrentMap?.Broadcast(session, session.Character.GenerateRc(session.Character.SnackHp), ReceiverType.All);
         }
         if (session.IsConnected)
         {
             session.SendPacket(session.Character.GenerateStat());
         }
         else
         {
             return;
         }
         Thread.Sleep(1800);
     }
 }
예제 #2
0
 public void Regenerate(ClientSession session, Item item, string[] packetsplit = null)
 {
     session.SendPacket(session.Character.GenerateEff(6000));
     session.Character.SnackAmount++;
     session.Character.MaxSnack = 0;
     session.Character.SnackHp += item.Hp / 5;
     session.Character.SnackMp += item.Mp / 5;
     for (int i = 0; i < 5; i++)
     {
         Thread.Sleep(1800);
     }
     session.Character.SnackHp -= item.Hp / 5;
     session.Character.SnackMp -= item.Mp / 5;
     session.Character.SnackAmount--;
 }
예제 #3
0
        public override void Use(ClientSession session, ref ItemInstance inv, byte Option = 0, string[] packetsplit = null)
        {
            if (!session.HasCurrentMapInstance)
            {
                return;
            }
            if ((DateTime.Now - session.Character.LastPotion).TotalMilliseconds < (session.CurrentMapInstance.Map.MapTypes.OrderByDescending(s => s.PotionDelay).FirstOrDefault()?.PotionDelay ?? 750))
            {
                return;
            }
            session.Character.LastPotion = DateTime.Now;
            switch (Effect)
            {
            default:
                if (session.CurrentMapInstance.IsPVP)
                {
                    return;
                }
                int hpLoad = (int)session.Character.HPLoad();
                int mpLoad = (int)session.Character.MPLoad();
                if ((session.Character.Hp == hpLoad && session.Character.Mp == mpLoad) || session.Character.Hp <= 0)
                {
                    return;
                }
                if (session.Character.MapId == 134 || session.Character.MapId == 153 || session.Character.MapId == 132 || session.Character.MapId == 151 || session.Character.MapId == 133 || session.Character.MapId == 152)
                {
                    if (inv.ItemVNum == 1244 || inv.ItemVNum == 1243 || inv.ItemVNum == 1242)
                    {
                        return;
                    }
                }
                session.Character.Inventory.RemoveItemFromInventory(inv.Id);
                if (hpLoad - session.Character.Hp < Hp)
                {
                    session.CurrentMapInstance?.Broadcast(session.Character.GenerateRc(hpLoad - session.Character.Hp));
                }
                else if (hpLoad - session.Character.Hp > Hp)
                {
                    session.CurrentMapInstance?.Broadcast(session.Character.GenerateRc(Hp));
                }
                session.Character.Mp += Mp;
                session.Character.Hp += Hp;
                if (session.Character.Mp > mpLoad)
                {
                    session.Character.Mp = mpLoad;
                }
                if (session.Character.Hp > hpLoad)
                {
                    session.Character.Hp = hpLoad;
                }
                if (ServerManager.Instance.ChannelId != 51 || session.Character.MapId == 130 || session.Character.MapId == 131)
                {
                    if (inv.ItemVNum == 1242 || inv.ItemVNum == 5582)
                    {
                        if (session.CurrentMapInstance.IsPVP)
                        {
                            return;
                        }
                        session.CurrentMapInstance?.Broadcast(session.Character.GenerateRc(hpLoad - session.Character.Hp));
                        session.Character.Hp = hpLoad;
                    }
                    else if (inv.ItemVNum == 1243 || inv.ItemVNum == 5583)
                    {
                        if (session.CurrentMapInstance.IsPVP)
                        {
                            return;
                        }
                        session.Character.Mp = mpLoad;
                    }
                    else if (inv.ItemVNum == 1244 || inv.ItemVNum == 5584)
                    {
                        if (session.CurrentMapInstance.IsPVP)
                        {
                            return;
                        }

                        session.CurrentMapInstance?.Broadcast(session.Character.GenerateRc(hpLoad - session.Character.Hp));
                        session.Character.Hp = hpLoad;
                        session.Character.Mp = mpLoad;
                    }
                }
                session.SendPacket(session.Character.GenerateStat());

                foreach (Mate mate in session.Character.Mates.Where(s => s.IsTeamMember))
                {
                    hpLoad = mate.MaxHp;
                    mpLoad = mate.MaxMp;
                    if ((mate.Hp == hpLoad && mate.Mp == mpLoad) || mate.Hp <= 0)
                    {
                        return;
                    }

                    if (hpLoad - mate.Hp < Hp)
                    {
                        session.CurrentMapInstance?.Broadcast(mate.GenerateRc(hpLoad - mate.Hp));
                    }
                    else if (hpLoad - mate.Hp > Hp)
                    {
                        session.CurrentMapInstance?.Broadcast(mate.GenerateRc(Hp));
                    }

                    mate.Mp += Mp;
                    mate.Hp += Hp;
                    if (mate.Mp > mpLoad)
                    {
                        mate.Mp = mpLoad;
                    }

                    if (mate.Hp > hpLoad)
                    {
                        mate.Hp = hpLoad;
                    }

                    if (ServerManager.Instance.ChannelId != 51 || session.Character.MapId == 130 ||
                        session.Character.MapId == 131)
                    {
                        if (inv.ItemVNum == 1242 || inv.ItemVNum == 5582)
                        {
                            if (session.CurrentMapInstance.IsPVP)
                            {
                                return;
                            }
                            session.CurrentMapInstance?.Broadcast(
                                mate.GenerateRc(hpLoad - mate.Hp));
                            mate.Hp = hpLoad;
                        }
                        else if (inv.ItemVNum == 1243 || inv.ItemVNum == 5583)
                        {
                            if (session.CurrentMapInstance.IsPVP)
                            {
                                return;
                            }
                            mate.Mp = mpLoad;
                        }
                        else if (inv.ItemVNum == 1244 || inv.ItemVNum == 5584)
                        {
                            if (session.CurrentMapInstance.IsPVP)
                            {
                                return;
                            }
                            session.CurrentMapInstance?.Broadcast(
                                mate.GenerateRc(hpLoad - mate.Hp));
                            mate.Hp = hpLoad;
                            mate.Mp = mpLoad;
                        }
                    }

                    session.SendPacket(mate.GenerateStatInfo());
                }

                break;
            }
        }
예제 #4
0
        public override void Use(ClientSession session, ref ItemInstance inv, byte Option = 0, string[] packetsplit = null)
        {
            switch (Effect)
            {
            // airwaves - eventitems
            case 0:
                if (inv.Item.ItemType == ItemType.Shell)
                {
                    if (inv.ShellEffects.Count != 0 && packetsplit?.Length > 9 && byte.TryParse(packetsplit[9], out byte islot))
                    {
                        ItemInstance wearable = session.Character.Inventory.LoadBySlotAndType <ItemInstance>(islot, InventoryType.Equipment);
                        if (wearable != null && (wearable.Item.ItemType == ItemType.Weapon || wearable.Item.ItemType == ItemType.Armor) && wearable.Item.LevelMinimum >= inv.Upgrade && wearable.Rare >= inv.Rare && !wearable.Item.IsHeroic)
                        {
                            bool weapon = false;
                            if ((inv.ItemVNum >= 565 && inv.ItemVNum <= 576) || (inv.ItemVNum >= 589 && inv.ItemVNum <= 598))
                            {
                                weapon = true;
                            }
                            else if ((inv.ItemVNum >= 577 && inv.ItemVNum <= 588) || (inv.ItemVNum >= 656 && inv.ItemVNum <= 664) || inv.ItemVNum == 599)
                            {
                                weapon = false;
                            }
                            else
                            {
                                return;
                            }
                            if ((wearable.Item.ItemType == ItemType.Weapon && weapon) || (wearable.Item.ItemType == ItemType.Armor && !weapon))
                            {
                                if (wearable.ShellEffects.Count > 0 && ServerManager.RandomNumber() < 50)
                                {
                                    session.Character.DeleteItemByItemInstanceId(inv.Id);
                                    session.SendPacket(UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("OPTION_APPLY_FAIL"), 0));
                                    return;
                                }
                                wearable.ShellEffects.Clear();
                                DAOFactory.ShellEffectDAO.DeleteByEquipmentSerialId(wearable.EquipmentSerialId);
                                wearable.ShellEffects.AddRange(inv.ShellEffects);
                                if (wearable.EquipmentSerialId == Guid.Empty)
                                {
                                    wearable.EquipmentSerialId = Guid.NewGuid();
                                }
                                DAOFactory.ShellEffectDAO.InsertOrUpdateFromList(wearable.ShellEffects, wearable.EquipmentSerialId);

                                session.Character.DeleteItemByItemInstanceId(inv.Id);
                                session.SendPacket(UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("OPTION_APPLY_SUCCESS"), 0));
                            }
                        }
                    }
                    return;
                }

                if (ItemType == ItemType.Event)
                {
                    session.CurrentMapInstance?.Broadcast(StaticPacketHelper.GenerateEff(UserType.Player, session.Character.CharacterId, EffectValue));
                    if (MappingHelper.GuriItemEffects.ContainsKey(EffectValue))
                    {
                        session.CurrentMapInstance?.Broadcast(UserInterfaceHelper.GenerateGuri(19, 1, session.Character.CharacterId, MappingHelper.GuriItemEffects[EffectValue]), session.Character.MapX, session.Character.MapY);
                    }
                    session.Character.Inventory.RemoveItemFromInventory(inv.Id);
                }
                break;

            //respawn objects
            case 1:
                if (session.Character.MapInstance.MapInstanceType != MapInstanceType.BaseMapInstance || ServerManager.Instance.ChannelId == 51)
                {
                    session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("CANT_USE_THAT"), 10));
                    return;
                }
                int type, secondaryType, inventoryType, slot;
                if (packetsplit != null && int.TryParse(packetsplit[2], out type) && int.TryParse(packetsplit[3], out secondaryType) && int.TryParse(packetsplit[4], out inventoryType) && int.TryParse(packetsplit[5], out slot))
                {
                    int packetType;
                    switch (EffectValue)
                    {
                    case 0:
                        if (Option == 0)
                        {
                            session.SendPacket(UserInterfaceHelper.GenerateDialog($"#u_i^{type}^{secondaryType}^{inventoryType}^{slot}^1 #u_i^{type}^{secondaryType}^{inventoryType}^{slot}^2 {Language.Instance.GetMessageFromKey("WANT_TO_SAVE_POSITION")}"));
                        }
                        else if (int.TryParse(packetsplit[6], out packetType))
                        {
                            switch (packetType)
                            {
                            case 1:
                                session.SendPacket(UserInterfaceHelper.GenerateDelay(5000, 7, $"#u_i^{type}^{secondaryType}^{inventoryType}^{slot}^3"));
                                break;

                            case 2:
                                session.SendPacket(UserInterfaceHelper.GenerateDelay(5000, 7, $"#u_i^{type}^{secondaryType}^{inventoryType}^{slot}^4"));
                                break;

                            case 3:
                                session.Character.SetReturnPoint(session.Character.MapId, session.Character.MapX, session.Character.MapY);
                                RespawnMapTypeDTO respawn = session.Character.Respawn;
                                if (respawn.DefaultX != 0 && respawn.DefaultY != 0 && respawn.DefaultMapId != 0)
                                {
                                    ServerManager.Instance.ChangeMap(session.Character.CharacterId, respawn.DefaultMapId, (short)(respawn.DefaultX + ServerManager.RandomNumber(-5, 5)), (short)(respawn.DefaultY + ServerManager.RandomNumber(-5, 5)));
                                }
                                session.Character.Inventory.RemoveItemFromInventory(inv.Id);
                                break;

                            case 4:
                                RespawnMapTypeDTO respawnObj = session.Character.Respawn;
                                if (respawnObj.DefaultX != 0 && respawnObj.DefaultY != 0 && respawnObj.DefaultMapId != 0)
                                {
                                    ServerManager.Instance.ChangeMap(session.Character.CharacterId, respawnObj.DefaultMapId, (short)(respawnObj.DefaultX + ServerManager.RandomNumber(-5, 5)), (short)(respawnObj.DefaultY + ServerManager.RandomNumber(-5, 5)));
                                }
                                session.Character.Inventory.RemoveItemFromInventory(inv.Id);
                                break;
                            }
                        }
                        break;

                    case 1:
                        if (int.TryParse(packetsplit[6], out packetType))
                        {
                            RespawnMapTypeDTO respawn = session.Character.Return;
                            switch (packetType)
                            {
                            case 0:
                                if (respawn.DefaultX != 0 && respawn.DefaultY != 0 && respawn.DefaultMapId != 0)
                                {
                                    session.SendPacket(UserInterfaceHelper.GenerateRp(respawn.DefaultMapId, respawn.DefaultX, respawn.DefaultY, $"#u_i^{type}^{secondaryType}^{inventoryType}^{slot}^1"));
                                }
                                break;

                            case 1:
                                session.SendPacket(UserInterfaceHelper.GenerateDelay(5000, 7, $"#u_i^{type}^{secondaryType}^{inventoryType}^{slot}^2"));
                                break;

                            case 2:
                                if (respawn.DefaultX != 0 && respawn.DefaultY != 0 && respawn.DefaultMapId != 0)
                                {
                                    ServerManager.Instance.ChangeMap(session.Character.CharacterId, respawn.DefaultMapId, respawn.DefaultX, respawn.DefaultY);
                                }
                                session.Character.Inventory.RemoveItemFromInventory(inv.Id);
                                break;
                            }
                        }
                        break;

                    case 2:
                        if (Option == 0)
                        {
                            session.SendPacket(UserInterfaceHelper.GenerateDelay(5000, 7, $"#u_i^{type}^{secondaryType}^{inventoryType}^{slot}^1"));
                        }
                        else
                        {
                            ServerManager.Instance.JoinMiniland(session, session);
                            session.Character.Inventory.RemoveItemFromInventory(inv.Id);
                        }
                        break;
                    }
                }
                break;

            // dyes or waxes
            case 10:
            case 11:
                if (!session.Character.IsVehicled)
                {
                    if (Effect == 10)
                    {
                        if (EffectValue == 99)
                        {
                            byte nextValue = (byte)ServerManager.RandomNumber(0, 127);
                            session.Character.HairColor = Enum.IsDefined(typeof(HairColorType), nextValue) ? (HairColorType)nextValue : 0;
                        }
                        else
                        {
                            session.Character.HairColor = Enum.IsDefined(typeof(HairColorType), (byte)EffectValue) ? (HairColorType)EffectValue : 0;
                        }
                    }
                    else if (Effect == 11)
                    {
                        if (session.Character.Class == (byte)ClassType.Adventurer && EffectValue > 1)
                        {
                            session.SendPacket(UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("ADVENTURERS_CANT_USE"), 10));
                            return;
                        }
                        if (session.Character.Gender != (GenderType)Sex)
                        {
                            session.SendPacket(UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("CANNOT_USE"), 10));
                            return;
                        }
                        session.Character.HairStyle = Enum.IsDefined(typeof(HairStyleType), (byte)EffectValue) ? (HairStyleType)EffectValue : 0;
                    }
                    else
                    {
                        if (session.Character.Class == (byte)ClassType.Adventurer && EffectValue > 1)
                        {
                            session.SendPacket(UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("ADVENTURERS_CANT_USE"), 10));
                            return;
                        }
                        session.Character.HairStyle = Enum.IsDefined(typeof(HairStyleType), (byte)EffectValue) ? (HairStyleType)EffectValue : 0;
                    }
                    session.SendPacket(session.Character.GenerateEq());
                    session.CurrentMapInstance?.Broadcast(session, session.Character.GenerateIn());
                    session.CurrentMapInstance?.Broadcast(session, session.Character.GenerateGidx());
                    session.Character.Inventory.RemoveItemFromInventory(inv.Id);
                }
                break;

            // dignity restoration
            case 14:
                if ((EffectValue == 100 || EffectValue == 200) && session.Character.Dignity < 100 && !session.Character.IsVehicled)
                {
                    session.Character.Dignity += EffectValue;
                    if (session.Character.Dignity > 100)
                    {
                        session.Character.Dignity = 100;
                    }
                    session.SendPacket(session.Character.GenerateFd());
                    session.SendPacket(StaticPacketHelper.GenerateEff(UserType.Player, session.Character.CharacterId, 49 - (byte)session.Character.Faction));
                    session.CurrentMapInstance?.Broadcast(session, session.Character.GenerateIn(), ReceiverType.AllExceptMe);
                    session.CurrentMapInstance?.Broadcast(session, session.Character.GenerateGidx(), ReceiverType.AllExceptMe);
                    session.Character.Inventory.RemoveItemFromInventory(inv.Id);
                }
                else if (EffectValue == 2000 && session.Character.Dignity < 100 && !session.Character.IsVehicled)
                {
                    session.Character.Dignity = 100;
                    session.SendPacket(session.Character.GenerateFd());
                    session.SendPacket(StaticPacketHelper.GenerateEff(UserType.Player, session.Character.CharacterId, 49 - (byte)session.Character.Faction));
                    session.CurrentMapInstance?.Broadcast(session, session.Character.GenerateIn(), ReceiverType.AllExceptMe);
                    session.CurrentMapInstance?.Broadcast(session, session.Character.GenerateGidx(), ReceiverType.AllExceptMe);
                    session.Character.Inventory.RemoveItemFromInventory(inv.Id);
                }
                break;

            // speakers
            case 15:
                if (!session.Character.IsVehicled && Option == 0)
                {
                    session.SendPacket(UserInterfaceHelper.GenerateGuri(10, 3, session.Character.CharacterId, 1));
                }
                break;

            // bubbles
            case 16:
                if (!session.Character.IsVehicled && Option == 0)
                {
                    session.SendPacket(UserInterfaceHelper.GenerateGuri(10, 4, session.Character.CharacterId, 1));
                }
                break;

            // wigs
            case 30:
                if (!session.Character.IsVehicled)
                {
                    ItemInstance wig = session.Character.Inventory.LoadBySlotAndType((byte)EquipmentType.Hat, InventoryType.Wear);
                    if (wig != null)
                    {
                        wig.Design = (byte)ServerManager.RandomNumber(0, 15);
                        session.SendPacket(session.Character.GenerateEq());
                        session.SendPacket(session.Character.GenerateEquipment());
                        session.CurrentMapInstance?.Broadcast(session, session.Character.GenerateIn());
                        session.CurrentMapInstance?.Broadcast(session, session.Character.GenerateGidx());
                        session.Character.Inventory.RemoveItemFromInventory(inv.Id);
                    }
                    else
                    {
                        session.SendPacket(UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("NO_WIG"), 0));
                    }
                }
                break;

            case 31:
                if (!session.Character.IsVehicled && session.Character.HairStyle == HairStyleType.Hair7)
                {
                    session.Character.HairStyle = HairStyleType.Hair8;
                    session.SendPacket(session.Character.GenerateEq());
                    session.CurrentMapInstance?.Broadcast(session, session.Character.GenerateIn());
                    session.CurrentMapInstance?.Broadcast(session, session.Character.GenerateGidx());
                    session.Character.Inventory.RemoveItemFromInventory(inv.Id);
                    // idk how it works yet but seems like all characters with this hairstyle have DarkPurple hair
                    //session.Character.HairColor = HairColorType.DarkPurple;
                }
                break;

            case 300:
                if (session.Character.Group != null && session.Character.Group.GroupType != GroupType.Group && session.Character.Group.IsLeader(session) && session.CurrentMapInstance.Portals.Any(s => s.Type == (short)PortalType.Raid))
                {
                    int delay = 0;
                    foreach (ClientSession sess in session.Character.Group.Characters.GetAllItems())
                    {
                        Observable.Timer(TimeSpan.FromMilliseconds(delay)).Subscribe(o =>
                        {
                            if (sess?.Character != null && session?.CurrentMapInstance != null && session?.Character != null)
                            {
                                ServerManager.Instance.ChangeMapInstance(sess.Character.CharacterId, session.CurrentMapInstance.MapInstanceId, session.Character.PositionX, session.Character.PositionY);
                            }
                        });
                        delay += 100;
                    }
                    session.Character.Inventory.RemoveItemFromInventory(inv.Id);
                }
                break;

            default:
                Logger.Warn(string.Format(Language.Instance.GetMessageFromKey("NO_HANDLER_ITEM"), GetType(), VNum, Effect, EffectValue));
                break;
            }
        }
예제 #5
0
        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;
                    }
                    else 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 != Domain.ItemType.Weapon &&
                     ItemType != Domain.ItemType.Armor &&
                     ItemType != Domain.ItemType.Fashion &&
                     ItemType != Domain.ItemType.Jewelery &&
                     ItemType != Domain.ItemType.Specialist) ||
                    LevelMinimum > (IsHeroic ? session.Character.HeroLevel : session.Character.Level) || (Sex != 0 && Sex != (byte)session.Character.Gender + 1) ||
                    ((ItemType != Domain.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 is SpecialistInstance ? ((SpecialistInstance)currentlyEquippedItem).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;
            }
        }
예제 #6
0
        // Both partly
        public void ChangeMap(long id, short?mapId = null, short?mapX = null, short?mapY = null)
        {
            ClientSession session = GetSessionByCharacterId(id);

            if (session != null && session.Character != null && !session.Character.IsChangingMap)
            {
                try
                {
                    session.Character.IsChangingMap = true;
                    session.CurrentMap.UnregisterSession(session.Character.CharacterId);

                    //cleanup sending queue to avoid sending uneccessary packets to it
                    Task.Factory.StartNew(async() =>
                    {
                        await session.ClearLowpriorityQueue();
                    });

                    //avoid cleaning new portals
                    Task.Delay(100);
                    if (mapId != null || mapX != null || mapY != null)
                    {
                        session.Character.MapId = (short)mapId;
                        session.Character.MapX  = (short)mapX;
                        session.Character.MapY  = (short)mapY;
                    }

                    session.CurrentMap = GetMap(session.Character.MapId);
                    session.CurrentMap.RegisterSession(session);
                    session.SendPacket(session.Character.GenerateCond());
                    session.SendPacket(session.Character.GenerateCInfo());
                    session.SendPacket(session.Character.GenerateCMode());
                    session.SendPacket(session.Character.GenerateEq());
                    session.SendPacket(session.Character.GenerateEquipment());
                    session.SendPacket(session.Character.GenerateLev());
                    session.SendPacket(session.Character.GenerateStat());
                    session.SendPacket(session.Character.GenerateAt());
                    session.SendPacket(session.Character.GenerateCMap());
                    session.SendPacket(session.Character.GenerateStatChar());
                    session.SendPacket($"gidx 1 {session.Character.CharacterId} -1 - 0"); // family
                    session.SendPacket("rsfp 0 -1");

                    // in 2 // send only when partner present cond 2 // send only when partner present
                    session.SendPacket("pinit 0"); // clear party list
                    session.SendPacket(session.Character.GeneratePairy());
                    session.SendPacket("act6");    // act6 1 0 14 0 0 0 14 0 0 0

                    Sessions.Where(s => s.Character != null && s.Character.MapId.Equals(session.Character.MapId) && s.Character.Name != session.Character.Name && !s.Character.InvisibleGm).ToList().ForEach(s => RequireBroadcastFromUser(session, s.Character.CharacterId, "GenerateIn"));

                    session.SendPackets(session.Character.GenerateGp());

                    // wp 23 124 4 4 12 99
                    session.SendPackets(session.Character.GenerateIn3());
                    session.SendPackets(session.Character.GenerateIn2());
                    session.SendPackets(session.Character.GenerateNPCShopOnMap());
                    session.SendPackets(session.Character.GenerateDroppedItem());
                    session.SendPackets(session.Character.GenerateShopOnMap());
                    session.SendPackets(session.Character.GeneratePlayerShopOnMap());
                    if (!session.Character.InvisibleGm)
                    {
                        session.CurrentMap?.Broadcast(session, session.Character.GenerateIn(), ReceiverType.AllExceptMe);
                    }
                    if (session.Character.Size != 10)
                    {
                        session.SendPacket(session.Character.GenerateScal());
                    }
                    if (session.CurrentMap.IsDancing && !session.Character.IsDancing)
                    {
                        session.CurrentMap?.Broadcast("dance 2");
                    }
                    else if (!session.CurrentMap.IsDancing && session.Character.IsDancing)
                    {
                        session.Character.IsDancing = false;
                        session.CurrentMap?.Broadcast("dance");
                    }
                    foreach (Group g in Groups)
                    {
                        foreach (ClientSession groupSession in g.Characters)
                        {
                            ClientSession chara = Sessions.FirstOrDefault(s => s.Character != null && s.Character.CharacterId == groupSession.Character.CharacterId && s.CurrentMap.MapId == groupSession.CurrentMap.MapId);
                            if (chara != null)
                            {
                                groupSession.SendPacket(groupSession.Character.GeneratePinit());
                            }
                            if (groupSession.Character.CharacterId == groupSession.Character.CharacterId)
                            {
                                session.CurrentMap?.Broadcast(groupSession, groupSession.Character.GeneratePidx(), ReceiverType.AllExceptMe);
                            }
                        }
                    }

                    session.Character.IsChangingMap = false;
                }
                catch (Exception)
                {
                    Logger.Log.Warn("Character changed while changing map. Do not abuse Commands.");
                    session.Character.IsChangingMap = false;
                }
            }
        }
예제 #7
0
        public void UpgradeSp(ClientSession Session, UpgradeProtection protect)
        {
            short[] upsuccess = { 100, 100, 95, 90, 85, 80, 75, 70, 65, 60, 55, 50, 45, 40, 30 };
            short[] upfail = { 20, 25, 25, 30, 35, 40, 40, 40, 40, 40, 45, 43, 40, 37, 29 };

            int[] goldprice = { 200000, 200000, 200000, 200000, 200000, 500000, 500000, 500000, 500000, 500000, 1000000, 1000000, 1000000, 1000000, 1000000 };
            short[] feather = { 3, 5, 8, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 70 };
            short[] fullmoon = { 1, 3, 5, 7, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30 };
            short[] soul = { 2, 4, 6, 8, 10, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5 };
            short featherVnum = 2282;
            short fullmoonVnum = 1030;
            short greenSoulVnum = 2283;
            short redSoulVnum = 2284;
            short blueSoulVnum = 2285;
            short dragonSkinVnum = 2511;
            short dragonBloodVnum = 2512;
            short dragonHeartVnum = 2513;
            short blueScrollVnum = 1363;
            short redScrollVnum = 1364;

            if (!Session.HasCurrentMap)
            {
                return;
            }
            if (this.IsFixed)
            {
                Session.SendPacket(Session.Character.GenerateSay(Language.Instance.GetMessageFromKey("ITEM_IS_FIXED"), 10));
                return;
            }
            if (Session.Character.Inventory.CountItem(fullmoonVnum) < fullmoon[this.Upgrade])
            {
                Session.SendPacket(Session.Character.GenerateSay(Language.Instance.GetMessageFromKey(String.Format(Language.Instance.GetMessageFromKey("NOT_ENOUGH_ITEMS"), ServerManager.GetItem(fullmoonVnum).Name, fullmoon[this.Upgrade])), 10));
                return;
            }
            if (Session.Character.Inventory.CountItem(featherVnum) < feather[this.Upgrade])
            {
                Session.SendPacket(Session.Character.GenerateSay(Language.Instance.GetMessageFromKey(String.Format(Language.Instance.GetMessageFromKey("NOT_ENOUGH_ITEMS"), ServerManager.GetItem(featherVnum).Name, feather[this.Upgrade])), 10));
                return;
            }
            if (Session.Character.Gold < goldprice[this.Upgrade])
            {
                Session.SendPacket(Session.Character.GenerateSay(Language.Instance.GetMessageFromKey("NOT_ENOUGH_MONEY"), 10));
                return;
            }

            if (this.Upgrade < 5)
            {
                if (this.SpLevel > 20)
                {
                    if (this.Item.Morph <= 16)
                    {
                        if (Session.Character.Inventory.CountItem(greenSoulVnum) < soul[this.Upgrade])
                        {
                            Session.SendPacket(Session.Character.GenerateSay(Language.Instance.GetMessageFromKey(String.Format(Language.Instance.GetMessageFromKey("NOT_ENOUGH_ITEMS"), ServerManager.GetItem(greenSoulVnum).Name, soul[this.Upgrade])), 10));
                            return;
                        }
                        if (protect == UpgradeProtection.Protected)
                        {
                            if (Session.Character.Inventory.CountItem(blueScrollVnum) < 1)
                            {
                                Session.SendPacket(Session.Character.GenerateSay(Language.Instance.GetMessageFromKey(String.Format(Language.Instance.GetMessageFromKey("NOT_ENOUGH_ITEMS"), ServerManager.GetItem(blueScrollVnum).Name, 1)), 10));
                                return;
                            }
                            Session.Character.Inventory.RemoveItemAmount(blueScrollVnum);
                            Session.SendPacket("shop_end 2");
                        }
                        Session.Character.Inventory.RemoveItemAmount(greenSoulVnum, (soul[this.Upgrade]));
                    }
                    else
                    {
                        if (Session.Character.Inventory.CountItem(dragonSkinVnum) < soul[this.Upgrade])
                        {
                            Session.SendPacket(Session.Character.GenerateSay(Language.Instance.GetMessageFromKey(String.Format(Language.Instance.GetMessageFromKey("NOT_ENOUGH_ITEMS"), ServerManager.GetItem(dragonSkinVnum).Name, soul[this.Upgrade])), 10));
                            return;
                        }
                        if (protect == UpgradeProtection.Protected)
                        {
                            if (Session.Character.Inventory.CountItem(blueScrollVnum) < 1)
                            {
                                Session.SendPacket(Session.Character.GenerateSay(Language.Instance.GetMessageFromKey(String.Format(Language.Instance.GetMessageFromKey("NOT_ENOUGH_ITEMS"), ServerManager.GetItem(blueScrollVnum).Name, 1)), 10));
                                return;
                            }
                            Session.Character.Inventory.RemoveItemAmount(blueScrollVnum);
                            Session.SendPacket("shop_end 2");
                        }
                        Session.Character.Inventory.RemoveItemAmount(dragonSkinVnum, (soul[this.Upgrade]));
                    }
                }
                else
                {
                    Session.SendPacket(Session.Character.GenerateSay(String.Format(Language.Instance.GetMessageFromKey("LVL_REQUIRED"), 21), 11));
                    return;
                }
            }
            else if (this.Upgrade < 10)
            {
                if (this.SpLevel > 40)
                {
                    if (this.Item.Morph <= 16)
                    {
                        if (Session.Character.Inventory.CountItem(redSoulVnum) < soul[this.Upgrade])
                        {
                            Session.SendPacket(Session.Character.GenerateSay(Language.Instance.GetMessageFromKey(String.Format(Language.Instance.GetMessageFromKey("NOT_ENOUGH_ITEMS"), ServerManager.GetItem(redSoulVnum).Name, soul[this.Upgrade])), 10));
                            return;
                        }
                        if (protect == UpgradeProtection.Protected)
                        {
                            if (Session.Character.Inventory.CountItem(blueScrollVnum) < 1)
                            {
                                Session.SendPacket(Session.Character.GenerateSay(Language.Instance.GetMessageFromKey(String.Format(Language.Instance.GetMessageFromKey("NOT_ENOUGH_ITEMS"), ServerManager.GetItem(blueScrollVnum).Name, 1)), 10));
                                return;
                            }
                            Session.Character.Inventory.RemoveItemAmount(blueScrollVnum);
                            Session.SendPacket("shop_end 2");
                        }
                        Session.Character.Inventory.RemoveItemAmount(redSoulVnum, (soul[this.Upgrade]));
                    }
                    else
                    {
                        if (Session.Character.Inventory.CountItem(dragonBloodVnum) < soul[this.Upgrade])
                        {
                            Session.SendPacket(Session.Character.GenerateSay(Language.Instance.GetMessageFromKey(String.Format(Language.Instance.GetMessageFromKey("NOT_ENOUGH_ITEMS"), ServerManager.GetItem(dragonBloodVnum).Name, soul[this.Upgrade])), 10));
                            return;
                        }
                        if (protect == UpgradeProtection.Protected)
                        {
                            if (Session.Character.Inventory.CountItem(blueScrollVnum) < 1)
                            {
                                Session.SendPacket(Session.Character.GenerateSay(Language.Instance.GetMessageFromKey(String.Format(Language.Instance.GetMessageFromKey("NOT_ENOUGH_ITEMS"), ServerManager.GetItem(blueScrollVnum).Name, 1)), 10));
                                return;
                            }
                            Session.Character.Inventory.RemoveItemAmount(blueScrollVnum);
                            Session.SendPacket("shop_end 2");
                        }
                        Session.Character.Inventory.RemoveItemAmount(dragonBloodVnum, (soul[this.Upgrade]));
                    }
                }
                else
                {
                    Session.SendPacket(Session.Character.GenerateSay(String.Format(Language.Instance.GetMessageFromKey("LVL_REQUIRED"), 41), 11));
                    return;
                }
            }
            else if (this.Upgrade < 15)
            {
                if (this.SpLevel > 50)
                {
                    if (this.Item.Morph <= 16)
                    {
                        if (Session.Character.Inventory.CountItem(blueSoulVnum) < soul[this.Upgrade])
                        {
                            Session.SendPacket(Session.Character.GenerateSay(Language.Instance.GetMessageFromKey(String.Format(Language.Instance.GetMessageFromKey("NOT_ENOUGH_ITEMS"), ServerManager.GetItem(blueSoulVnum).Name, soul[this.Upgrade])), 10));
                            return;
                        }
                        if (protect == UpgradeProtection.Protected && this.Upgrade > 9)
                        {
                            if (Session.Character.Inventory.CountItem(redScrollVnum) < 1)
                            {
                                return;
                            }
                            Session.Character.Inventory.RemoveItemAmount(redScrollVnum);
                            Session.SendPacket("shop_end 2");
                        }
                        Session.Character.Inventory.RemoveItemAmount(blueSoulVnum, (soul[this.Upgrade]));
                    }
                    else
                    {
                        if (Session.Character.Inventory.CountItem(dragonHeartVnum) < soul[this.Upgrade])
                        {
                            return;
                        }
                        if (protect == UpgradeProtection.Protected && this.Upgrade > 9)
                        {
                            if (Session.Character.Inventory.CountItem(redScrollVnum) < 1)
                            {
                                Session.SendPacket(Session.Character.GenerateSay(Language.Instance.GetMessageFromKey(String.Format(Language.Instance.GetMessageFromKey("NOT_ENOUGH_ITEMS"), ServerManager.GetItem(redScrollVnum).Name, 1)), 10));
                                return;
                            }
                            Session.Character.Inventory.RemoveItemAmount(redScrollVnum);
                            Session.SendPacket("shop_end 2");
                        }
                        Session.Character.Inventory.RemoveItemAmount(dragonHeartVnum, (soul[this.Upgrade]));
                    }
                }
                else
                {
                    Session.SendPacket(Session.Character.GenerateSay(String.Format(Language.Instance.GetMessageFromKey("LVL_REQUIRED"), 51), 11));
                    return;
                }
            }

            Session.Character.Gold -= goldprice[this.Upgrade];

            // remove feather and fullmoon before upgrading
            Session.Character.Inventory.RemoveItemAmount(featherVnum, (feather[this.Upgrade]));
            Session.Character.Inventory.RemoveItemAmount(fullmoonVnum, (fullmoon[this.Upgrade]));

            WearableInstance wearable = Session.Character.Inventory.LoadByItemInstance<WearableInstance>(this.Id);
            ItemInstance inventory = Session.Character.Inventory.GetItemInstanceById(this.Id);
            int rnd = _random.Next(100);
            if (rnd <= upfail[this.Upgrade])
            {
                if (protect == UpgradeProtection.Protected)
                {
                    Session.CurrentMap.Broadcast(Session.Character.GenerateEff(3004), Session.Character.MapX, Session.Character.MapY);
                }
                Session.SendPacket(Session.Character.GenerateSay(Language.Instance.GetMessageFromKey("UPGRADESP_FAILED"), 11));
                Session.SendPacket(Session.Character.GenerateMsg(Language.Instance.GetMessageFromKey("UPGRADESP_FAILED"), 0));
            }
            else if (rnd <= upsuccess[this.Upgrade])
            {
                if (protect == UpgradeProtection.Protected)
                {
                    Session.CurrentMap.Broadcast(Session.Character.GenerateEff(3004), Session.Character.MapX, Session.Character.MapY);
                }
                Session.CurrentMap.Broadcast(Session.Character.GenerateEff(3005), Session.Character.MapX, Session.Character.MapY);
                Session.SendPacket(Session.Character.GenerateSay(Language.Instance.GetMessageFromKey("UPGRADESP_SUCCESS"), 12));
                Session.SendPacket(Session.Character.GenerateMsg(Language.Instance.GetMessageFromKey("UPGRADESP_SUCCESS"), 0));
                wearable.Upgrade++;
                Session.SendPacket(Session.Character.GenerateInventoryAdd(this.ItemVNum, 1, inventory.Type, inventory.Slot, wearable.Rare, wearable.Design, wearable.Upgrade, this.SpStoneUpgrade));
            }
            else
            {
                if (protect == UpgradeProtection.Protected)
                {
                    Session.CurrentMap.Broadcast(Session.Character.GenerateEff(3004), Session.Character.MapX, Session.Character.MapY);
                    Session.SendPacket(Session.Character.GenerateSay(Language.Instance.GetMessageFromKey("UPGRADESP_FAILED_SAVED"), 11));
                    Session.SendPacket(Session.Character.GenerateMsg(Language.Instance.GetMessageFromKey("UPGRADESP_FAILED_SAVED"), 0));
                }
                else
                {
                    wearable.Rare = (sbyte)-2;
                    Session.SendPacket(Session.Character.GenerateSay(Language.Instance.GetMessageFromKey("UPGRADESP_DESTROYED"), 11));
                    Session.SendPacket(Session.Character.GenerateMsg(Language.Instance.GetMessageFromKey("UPGRADESP_DESTROYED"), 0));
                    Session.SendPacket(Session.Character.GenerateInventoryAdd(this.ItemVNum, 1, inventory.Type, inventory.Slot, wearable.Rare, wearable.Design, wearable.Upgrade, this.SpStoneUpgrade));
                }
            }
            Session.SendPacket(Session.Character.GenerateGold());
            Session.SendPacket(Session.Character.GenerateEq());
            Session.SendPacket("shop_end 1");
        }
예제 #8
0
        public static void NRun(ClientSession Session, byte type, short runner, short value, short npcid)
        {
            if (!Session.HasCurrentMap)
            {
                return;
            }
            MapNpc npc = Session.CurrentMap.Npcs.FirstOrDefault(s => s.MapNpcId == npcid);
            switch (runner)
            {
                case 1:
                    if (Session.Character.Class != (byte)ClassType.Adventurer)
                    {
                        Session.SendPacket(Session.Character.GenerateMsg(Language.Instance.GetMessageFromKey("NOT_ADVENTURER"), 0));
                        return;
                    }
                    if (Session.Character.Level < 15 || Session.Character.JobLevel < 20)
                    {
                        Session.SendPacket(Session.Character.GenerateMsg(Language.Instance.GetMessageFromKey("LOW_LVL"), 0));
                        return;
                    }
                    if (type == (byte)Session.Character.Class)
                    {
                        return;
                    }
                    if (Session.Character.Inventory.GetAllItems().All(i => i.Type != InventoryType.Wear))
                    {
                        Session.Character.Inventory.AddNewToInventory((short)(4 + type * 14), type: InventoryType.Wear);
                        Session.Character.Inventory.AddNewToInventory((short)(81 + type * 13), type: InventoryType.Wear);
                        switch (type)
                        {
                            case 1:
                                Session.Character.Inventory.AddNewToInventory(68, type: InventoryType.Wear);
                                Session.Character.Inventory.AddNewToInventory(2082, 10);
                                break;

                            case 2:
                                Session.Character.Inventory.AddNewToInventory(78, type: InventoryType.Wear);
                                Session.Character.Inventory.AddNewToInventory(2083, 10);
                                break;

                            case 3:
                                Session.Character.Inventory.AddNewToInventory(86, type: InventoryType.Wear);
                                break;
                        }
                        Session.CurrentMap?.Broadcast(Session.Character.GenerateEq());
                        Session.SendPacket(Session.Character.GenerateEquipment());
                        Session.Character.ChangeClass((ClassType)type);
                    }
                    else
                    {
                        Session.SendPacket(Session.Character.GenerateMsg(Language.Instance.GetMessageFromKey("EQ_NOT_EMPTY"), 0));
                    }
                    break;

                case 2:
                    Session.SendPacket("wopen 1 0");
                    break;

                case 10:
                    Session.SendPacket("wopen 3 0");
                    break;

                case 12:
                    Session.SendPacket($"wopen {type} 0");
                    break;

                case 14:
                    Session.SendPacket("wopen 27 0");
                    string recipelist = "m_list 2";

                    if (npc != null)
                    {
                        List<Recipe> tp = npc.Recipes;
                        foreach (Recipe s in tp)
                        {
                            if (s.Amount > 0) recipelist = recipelist + $" {s.ItemVNum}";
                        }
                        recipelist += " -100";
                        Session.SendPacket(recipelist);
                    }
                    break;

                case 16:
                    if (npc != null)
                    {
                        TeleporterDTO tp = npc.Teleporters?.FirstOrDefault(s => s.Index == type);
                        if (tp != null)
                        {
                            if (Session.Character.Gold >= 1000 * type)
                            {
                                ServerManager.Instance.LeaveMap(Session.Character.CharacterId);
                                Session.Character.Gold -= 1000 * type;
                                Session.SendPacket(Session.Character.GenerateGold());
                                ServerManager.Instance.ChangeMap(Session.Character.CharacterId, tp.MapId, tp.MapX, tp.MapY);
                            }
                            else
                            {
                                Session.SendPacket(Session.Character.GenerateSay(Language.Instance.GetMessageFromKey("NOT_ENOUGH_MONEY"), 10));
                            }
                        }
                    }
                    break;

                case 26:
                    if (npc != null)
                    {
                        TeleporterDTO tp = npc.Teleporters?.FirstOrDefault(s => s.Index == type);
                        if (tp != null)
                        {
                            if (Session.Character.Gold >= 5000 * type)
                            {
                                ServerManager.Instance.LeaveMap(Session.Character.CharacterId);
                                Session.Character.Gold -= 5000 * type;
                                ServerManager.Instance.ChangeMap(Session.Character.CharacterId, tp.MapId, tp.MapX, tp.MapY);
                            }
                            else
                            {
                                Session.SendPacket(Session.Character.GenerateSay(Language.Instance.GetMessageFromKey("NOT_ENOUGH_MONEY"), 10));
                            }
                        }
                    }
                    break;

                case 45:
                    if (npc != null)
                    {
                        TeleporterDTO tp = npc.Teleporters?.FirstOrDefault(s => s.Index == type);
                        if (tp != null)
                        {
                            if (Session.Character.Gold >= 500)
                            {
                                ServerManager.Instance.LeaveMap(Session.Character.CharacterId);
                                Session.Character.Gold -= 500;
                                Session.SendPacket(Session.Character.GenerateGold());
                                ServerManager.Instance.ChangeMap(Session.Character.CharacterId, tp.MapId, tp.MapX, tp.MapY);
                            }
                            else
                            {
                                Session.SendPacket(Session.Character.GenerateSay(Language.Instance.GetMessageFromKey("NOT_ENOUGH_MONEY"), 10));
                            }
                        }
                    }
                    break;

                case 132:
                    if (npc != null)
                    {
                        TeleporterDTO tp = npc.Teleporters?.FirstOrDefault(s => s.Index == type);
                        if (tp != null)
                        {
                            ServerManager.Instance.LeaveMap(Session.Character.CharacterId);
                            ServerManager.Instance.ChangeMap(Session.Character.CharacterId, tp.MapId, tp.MapX, tp.MapY);
                        }
                    }
                    break;

                case 301:
                    if (npc != null)
                    {
                        TeleporterDTO tp = npc.Teleporters?.FirstOrDefault(s => s.Index == type);
                        if (tp != null)
                        {
                            ServerManager.Instance.LeaveMap(Session.Character.CharacterId);
                            ServerManager.Instance.ChangeMap(Session.Character.CharacterId, tp.MapId, tp.MapX, tp.MapY);
                        }
                    }
                    break;

                case 23:
                    Session.SendPacket(Session.Character.GenerateInbox(type, 14));
                    Session.SendPacket(Session.Character.GenerateFamilyMember(Session.Character.Group));
                    break;

                case 5002:
                    if (npc != null)
                    {
                        TeleporterDTO tp = npc.Teleporters?.FirstOrDefault(s => s.Index == type);
                        if (tp != null)
                        {
                            Session.SendPacket("it 3");
                            ServerManager.Instance.LeaveMap(Session.Character.CharacterId);
                            ServerManager.Instance.ChangeMap(Session.Character.CharacterId, tp.MapId, tp.MapX, tp.MapY);
                        }
                    }
                    break;

                case 5012:
                    if (npc != null)
                    {
                        TeleporterDTO tp = npc.Teleporters?.FirstOrDefault(s => s.Index == type);
                        if (tp != null)
                        {
                            ServerManager.Instance.LeaveMap(Session.Character.CharacterId);
                            ServerManager.Instance.ChangeMap(Session.Character.CharacterId, tp.MapId, tp.MapX, tp.MapY);
                        }
                    }
                    break;

                default:
                    Logger.Log.Warn(string.Format(Language.Instance.GetMessageFromKey("NO_NRUN_HANDLER"), runner));
                    break;
            }
        }
예제 #9
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;
            }
        }
예제 #10
0
        public override void Use(ClientSession session, ref ItemInstance inv, byte Option = 0, string[] packetsplit = null)
        {
            switch (Effect)
            {
            case 10:
            {
                switch (EffectValue)
                {
                case 1:
                    if (session.Character.Inventory.CountItem(1036) < 1 || session.Character.Inventory.CountItem(1013) < 1)
                    {
                        return;
                    }
                    session.Character.Inventory.RemoveItemAmount(1036);
                    session.Character.Inventory.RemoveItemAmount(1013);
                    if (ServerManager.RandomNumber() < 25)
                    {
                        switch (ServerManager.RandomNumber(0, 2))
                        {
                        case 0:
                            session.Character.GiftAdd(1015, 1);
                            break;

                        case 1:
                            session.Character.GiftAdd(1016, 1);
                            break;
                        }
                    }
                    break;

                case 2:
                    if (session.Character.Inventory.CountItem(1038) < 1 || session.Character.Inventory.CountItem(1013) < 1)
                    {
                        return;
                    }
                    session.Character.Inventory.RemoveItemAmount(1038);
                    session.Character.Inventory.RemoveItemAmount(1013);
                    if (ServerManager.RandomNumber() < 25)
                    {
                        switch (ServerManager.RandomNumber(0, 4))
                        {
                        case 0:
                            session.Character.GiftAdd(1031, 1);
                            break;

                        case 1:
                            session.Character.GiftAdd(1032, 1);
                            break;

                        case 2:
                            session.Character.GiftAdd(1033, 1);
                            break;

                        case 3:
                            session.Character.GiftAdd(1034, 1);
                            break;
                        }
                    }
                    break;

                case 3:
                    if (session.Character.Inventory.CountItem(1037) < 1 || session.Character.Inventory.CountItem(1013) < 1)
                    {
                        return;
                    }
                    session.Character.Inventory.RemoveItemAmount(1037);
                    session.Character.Inventory.RemoveItemAmount(1013);
                    if (ServerManager.RandomNumber() < 25)
                    {
                        switch (ServerManager.RandomNumber(0, 17))
                        {
                        case 0:
                        case 1:
                        case 2:
                        case 3:
                        case 4:
                            session.Character.GiftAdd(1017, 1);
                            break;

                        case 5:
                        case 6:
                        case 7:
                        case 8:
                            session.Character.GiftAdd(1018, 1);
                            break;

                        case 9:
                        case 10:
                        case 11:
                            session.Character.GiftAdd(1019, 1);
                            break;

                        case 12:
                        case 13:
                            session.Character.GiftAdd(1020, 1);
                            break;

                        case 14:
                            session.Character.GiftAdd(1021, 1);
                            break;

                        case 15:
                            session.Character.GiftAdd(1022, 1);
                            break;

                        case 16:
                            session.Character.GiftAdd(1023, 1);
                            break;
                        }
                    }
                    break;
                }

                session.Character.GiftAdd(1014, (byte)ServerManager.RandomNumber(5, 11));
            }
            break;

            //Bendición de la Flor del Sonido
            case 9007:
                if (!session.Character.Buff.ContainsKey(378))

                {
                    session.Character.Inventory.RemoveItemFromInventory(inv.Id);
                    session.Character.AddStaticBuff(new StaticBuffDTO {
                        CardId = 378
                    });
                }
                else
                {
                    session.SendPacket(UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("ITEM_IN_USE"), 0));
                }
                break;

            //Lord Mukraju Buffbuch
            case 9032:
                if (Option == 0)
                {
                    session.SendPacket($"qna #u_i^1^{session.Character.CharacterId}^{(byte)inv.Type}^{inv.Slot}^3 {Language.Instance.GetMessageFromKey("ASK_USE_BUFFBOOK")}");
                }
                else
                {
                    Buff buff = new Buff(72, 1);     //Moral
                    session.Character.AddBuff(buff, true);
                    Buff buff2 = new Buff(75, 1);    //Windläufer
                    session.Character.AddBuff(buff2, true);
                    Buff buff3 = new Buff(67, 1);    //Feuersegen
                    session.Character.AddBuff(buff3, true);
                    Buff buff4 = new Buff(91, 1);    //Segnung
                    session.Character.AddBuff(buff4, true);
                    Buff buff5 = new Buff(89, 1);    //Heilige Waffe
                    session.Character.AddBuff(buff5, true);
                    Buff buff6 = new Buff(138, 1);   //Gebet der Verteidigung
                    session.Character.AddBuff(buff6, true);
                    Buff buff9 = new Buff(152, 1);   //Geist des Bären
                    session.Character.AddBuff(buff9, true);
                    Buff buff10 = new Buff(153, 1);  //Geist des Adlers
                    session.Character.AddBuff(buff10, true);
                    Buff buff11 = new Buff(155, 1);  //Elementares Leuchten
                    session.Character.AddBuff(buff11, true);
                    Buff buff12 = new Buff(134, 1);  //Wassersegen
                    session.Character.AddBuff(buff12, true);
                    session.Character.Inventory.RemoveItemFromInventory(inv.Id);
                }
                break;

            default:
                Logger.Warn(string.Format(Language.Instance.GetMessageFromKey("NO_HANDLER_ITEM"), GetType()));
                break;
            }
        }
예제 #11
0
        private void SpreadBroadcastpacket(BroadcastPacket sentPacket)
        {
            if (Sessions != null && !string.IsNullOrEmpty(sentPacket?.Packet))
            {
                switch (sentPacket.Receiver)
                {
                    case ReceiverType.All: // send packet to everyone
                        foreach (ClientSession session in Sessions)
                        {
                            if (session.HasSelectedCharacter)
                            {
                                if (sentPacket.Sender != null)
                                {
                                    if (!sentPacket.Sender.Character.IsBlockedByCharacter(session.Character.CharacterId))
                                    {
                                        session.SendPacket(sentPacket.Packet);
                                    }
                                }
                                else
                                {
                                    session.SendPacket(sentPacket.Packet);
                                }
                            }
                        }
                        break;

                    case ReceiverType.AllExceptMe: // send to everyone except the sender
                        foreach (ClientSession session in Sessions.Where(s => s.SessionId != sentPacket.Sender.SessionId))
                        {
                            if (session.HasSelectedCharacter)
                            {
                                if (sentPacket.Sender != null)
                                {
                                    if (!sentPacket.Sender.Character.IsBlockedByCharacter(session.Character.CharacterId))
                                    {
                                        session.SendPacket(sentPacket.Packet);
                                    }
                                }
                                else
                                {
                                    session.SendPacket(sentPacket.Packet);
                                }
                            }
                        }
                        break;

                    case ReceiverType.AllInRange: // send to everyone which is in a range of 50x50
                        if (sentPacket.XCoordinate != 0 && sentPacket.YCoordinate != 0)
                        {
                            foreach (ClientSession session in Sessions.Where(s => s.Character.IsInRange(sentPacket.XCoordinate, sentPacket.YCoordinate)))
                            {
                                if (session.HasSelectedCharacter)
                                {
                                    if (sentPacket.Sender != null)
                                    {
                                        if (!sentPacket.Sender.Character.IsBlockedByCharacter(session.Character.CharacterId))
                                        {
                                            session.SendPacket(sentPacket.Packet);
                                        }
                                    }
                                    else
                                    {
                                        session.SendPacket(sentPacket.Packet);
                                    }
                                }
                            }
                        }
                        break;

                    case ReceiverType.OnlySomeone:
                        if (sentPacket.SomeonesCharacterId > 0 || !string.IsNullOrEmpty(sentPacket.SomeonesCharacterName))
                        {
                            ClientSession targetSession = Sessions.SingleOrDefault(s => s.Character.CharacterId == sentPacket.SomeonesCharacterId || s.Character.Name == sentPacket.SomeonesCharacterName);
                            if (targetSession != null && targetSession.HasSelectedCharacter)
                            {
                                if (sentPacket.Sender != null)
                                {
                                    if (!sentPacket.Sender.Character.IsBlockedByCharacter(targetSession.Character.CharacterId))
                                    {
                                        targetSession.SendPacket(sentPacket.Packet);
                                    }
                                    else
                                    {
                                        sentPacket.Sender.SendPacket(UserInterfaceHelper.Instance.GenerateInfo(Language.Instance.GetMessageFromKey("BLACKLIST_BLOCKED")));
                                    }
                                }
                                else
                                {
                                    targetSession.SendPacket(sentPacket.Packet);
                                }
                            }
                        }
                        break;

                    case ReceiverType.AllNoEmoBlocked:
                        foreach (ClientSession session in Sessions.Where(s => !s.Character.EmoticonsBlocked))
                        {
                            if (session.HasSelectedCharacter)
                            {
                                if (!sentPacket.Sender.Character.IsBlockedByCharacter(session.Character.CharacterId))
                                {
                                    session.SendPacket(sentPacket.Packet);
                                }
                            }
                        }
                        break;

                    case ReceiverType.AllNoHeroBlocked:
                        foreach (ClientSession session in Sessions.Where(s => !s.Character.HeroChatBlocked))
                        {
                            if (session.HasSelectedCharacter)
                            {
                                if (!sentPacket.Sender.Character.IsBlockedByCharacter(session.Character.CharacterId))
                                {
                                    session.SendPacket(sentPacket.Packet);
                                }
                            }
                        }
                        break;

                    case ReceiverType.Group:
                        foreach (ClientSession session in Sessions.Where(s => s.Character?.Group != null && sentPacket.Sender?.Character?.Group != null && s.Character.Group.GroupId == sentPacket.Sender.Character.Group.GroupId))
                        {
                            session.SendPacket(sentPacket.Packet);
                        }
                        break;

                    case ReceiverType.Unknown:
                        break;
                }
            }
        }
예제 #12
0
        public override void Use(ClientSession session, ref ItemInstance inv, bool delay = false, string[] packetsplit = null)
        {
            Random random = new Random();
            switch (Effect)
            {
                // airwaves - eventitems
                case 0:
                    if (this != null && this.ItemType == Domain.ItemType.Event)
                    {
                        session.CurrentMap?.Broadcast(session.Character.GenerateEff(EffectValue));
                        if (MappingHelper.GuriItemEffects.ContainsKey(EffectValue))
                        {
                            session.CurrentMap?.Broadcast(session.Character.GenerateGuri(19, 1, MappingHelper.GuriItemEffects[EffectValue]), session.Character.MapX, session.Character.MapY);
                        }
                        session.Character.Inventory.RemoveItemAmountFromInventory(1, inv.Id);
                    }
                    break;

                //respawn objects
                case 1:
                    int x1;
                    int x2;
                    int x3;
                    int x4;
                    int x5;
                    if (int.TryParse(packetsplit[2], out x1) && int.TryParse(packetsplit[3], out x2) && int.TryParse(packetsplit[4], out x3) && int.TryParse(packetsplit[5], out x4))
                    {
                        switch (EffectValue)
                        {
                            case 0:
                                if (!delay)
                                {
                                    session.SendPacket(session.Character.GenerateDialog($"#u_i^{x1}^{x2}^{x3}^{x4}^1 #u_i^{x1}^{x2}^{x3}^{x4}^2 {Language.Instance.GetMessageFromKey("WANT_TO_SAVE_POSITION")}"));
                                }
                                else
                                {
                                    if (int.TryParse(packetsplit[6], out x5))
                                    {
                                        switch (x5)
                                        {
                                            case 1:
                                                session.SendPacket(session.Character.GenerateDelay(5000, 7, $"#u_i^{x1}^{x2}^{x3}^{x4}^3"));
                                                break;

                                            case 2:
                                                session.SendPacket(session.Character.GenerateDelay(5000, 7, $"#u_i^{x1}^{x2}^{x3}^{x4}^4"));
                                                break;

                                            case 3:
                                                session.Character.SetReturnPoint(session.Character.MapId, session.Character.MapX, session.Character.MapY);
                                                RespawnMapTypeDTO resp = session.Character.Respawn;
                                                if (resp.DefaultX != 0 && resp.DefaultY != 0 && resp.DefaultMapId != 0)
                                                {
                                                    ServerManager.Instance.LeaveMap(session.Character.CharacterId);
                                                    Random rnd = new Random();
                                                    ServerManager.Instance.ChangeMap(session.Character.CharacterId, resp.DefaultMapId, (short)(resp.DefaultX + rnd.Next(-5, 5)), (short)(resp.DefaultY + rnd.Next(-5, 5)));
                                                }
                                                session.Character.Inventory.RemoveItemAmountFromInventory(1, inv.Id);
                                                break;

                                            case 4:
                                                RespawnMapTypeDTO respa = session.Character.Respawn;
                                                if (respa.DefaultX != 0 && respa.DefaultY != 0 && respa.DefaultMapId != 0)
                                                {
                                                    ServerManager.Instance.LeaveMap(session.Character.CharacterId);
                                                    Random rnd = new Random();
                                                    ServerManager.Instance.ChangeMap(session.Character.CharacterId, respa.DefaultMapId, (short)(respa.DefaultX + rnd.Next(-5, 5)), (short)(respa.DefaultY + rnd.Next(-5, 5)));
                                                }
                                                session.Character.Inventory.RemoveItemAmountFromInventory(1, inv.Id);
                                                break;
                                        }
                                    }
                                }
                                break;

                            case 1:
                                if (int.TryParse(packetsplit[6], out x5))
                                {
                                    RespawnMapTypeDTO resp = session.Character.Return;
                                    switch (x5)
                                    {
                                        case 0:
                                            if (resp.DefaultX != 0 && resp.DefaultY != 0 && resp.DefaultMapId != 0)
                                            {
                                                session.SendPacket(session.Character.GenerateRp(resp.DefaultMapId, resp.DefaultX, resp.DefaultY, $"#u_i^{x1}^{x2}^{x3}^{x4}^1"));
                                            }
                                            break;

                                        case 1:
                                            session.SendPacket(session.Character.GenerateDelay(5000, 7, $"#u_i^{x1}^{x2}^{x3}^{x4}^2"));
                                            break;

                                        case 2:
                                            if (resp.DefaultX != 0 && resp.DefaultY != 0 && resp.DefaultMapId != 0)
                                            {
                                                ServerManager.Instance.LeaveMap(session.Character.CharacterId);
                                                ServerManager.Instance.ChangeMap(session.Character.CharacterId, resp.DefaultMapId, resp.DefaultX, resp.DefaultY);
                                            }
                                            session.Character.Inventory.RemoveItemAmountFromInventory(1, inv.Id);
                                            break;
                                    }
                                }
                                break;
                        }
                    }
                    break;

                // dyes or waxes
                case 10:
                case 11:
                    if (this != null && !session.Character.IsVehicled)
                    {
                        if (Effect == 10)
                        {
                            if (EffectValue == 99)
                            {
                                byte nextValue = (byte)random.Next(0, 127);
                                session.Character.HairColor = Enum.IsDefined(typeof(HairColorType), (byte)nextValue) ? (HairColorType)nextValue : 0;
                            }
                            else
                            {
                                session.Character.HairColor = Enum.IsDefined(typeof(HairColorType), (byte)EffectValue) ? (HairColorType)EffectValue : 0;
                            }
                        }
                        else
                        {
                            if (session.Character.Class == (byte)ClassType.Adventurer && EffectValue > 1)
                            {
                                session.SendPacket(session.Character.GenerateMsg(Language.Instance.GetMessageFromKey("ADVENTURERS_CANT_USE"), 10));
                                return;
                            }
                            else
                            {
                                session.Character.HairStyle = Enum.IsDefined(typeof(HairStyleType), (byte)EffectValue) ? (HairStyleType)EffectValue : 0;
                            }
                        }
                        session.SendPacket(session.Character.GenerateEq());
                        session.CurrentMap?.Broadcast(session, session.Character.GenerateIn(), ReceiverType.All);
                        session.Character.Inventory.RemoveItemAmountFromInventory(1, inv.Id);
                    }
                    break;

                // dignity restoration
                case 14:
                    if ((EffectValue == 100 || EffectValue == 200) && session.Character.Dignity < 100 && !session.Character.IsVehicled)
                    {
                        session.Character.Dignity += EffectValue;
                        if (session.Character.Dignity > 100)
                        {
                            session.Character.Dignity = 100;
                        }
                        session.SendPacket(session.Character.GenerateFd());
                        session.SendPacket(session.Character.GenerateEff(48));
                        session.CurrentMap?.Broadcast(session, session.Character.GenerateIn(), ReceiverType.AllExceptMe);
                        session.Character.Inventory.RemoveItemAmountFromInventory(1, inv.Id);
                    }
                    else if (EffectValue == 2000 && session.Character.Dignity < 100 && !session.Character.IsVehicled)
                    {
                        session.Character.Dignity = 100;
                        session.SendPacket(session.Character.GenerateFd());
                        session.SendPacket(session.Character.GenerateEff(48));
                        session.CurrentMap?.Broadcast(session, session.Character.GenerateIn(), ReceiverType.AllExceptMe);
                        session.Character.Inventory.RemoveItemAmountFromInventory(1, inv.Id);
                    }
                    break;

                // speakers
                case 15:
                    if (this != null && !session.Character.IsVehicled)
                    {
                        if (!delay)
                        {
                            session.SendPacket(session.Character.GenerateGuri(10, 3, 1));
                        }
                    }
                    break;

                // bubbles
                case 16:
                    if (this != null && !session.Character.IsVehicled)
                    {
                        if (!delay)
                        {
                            session.SendPacket(session.Character.GenerateGuri(10, 4, 1));
                        }
                    }
                    break;

                // wigs
                case 30:
                    if (this != null && !session.Character.IsVehicled)
                    {
                        WearableInstance wig = session.Character.Inventory.LoadBySlotAndType<WearableInstance>((byte)EquipmentType.Hat, InventoryType.Wear);
                        if (wig != null)
                        {
                            wig.Design = (byte)random.Next(0, 15);
                            session.SendPacket(session.Character.GenerateEq());
                            session.SendPacket(session.Character.GenerateEquipment());
                            session.CurrentMap?.Broadcast(session, session.Character.GenerateIn(), ReceiverType.All);
                            session.Character.Inventory.RemoveItemAmountFromInventory(1, inv.Id);
                        }
                        else
                        {
                            session.SendPacket(session.Character.GenerateMsg(Language.Instance.GetMessageFromKey("NO_WIG"), 0));
                            return;
                        }
                    }
                    break;

                default:
                    Logger.Log.Warn(String.Format(Language.Instance.GetMessageFromKey("NO_HANDLER_ITEM"), this.GetType().ToString()));
                    break;
            }
        }
예제 #13
0
 public override void Use(ClientSession session, ref ItemInstance inv, bool delay = false, string[] packetsplit = null)
 {
     if ((DateTime.Now - session.Character.LastPotion).TotalMilliseconds < 750)
     {
         return;
     }
     else
     {
         session.Character.LastPotion = DateTime.Now;
     }
     Item item = inv.Item;
     switch (Effect)
     {
         default:
             if (session.Character.Hp <= 0)
             {
                 return;
             }
             int amount = session.Character.SnackAmount;
             if (amount < 5)
             {
                 Thread workerThread = new Thread(() => Regenerate(session, item));
                 workerThread.Start();
                 session.Character.Inventory.RemoveItemAmountFromInventory(1, inv.Id);
             }
             else
             {
                 if (session.Character.Gender == Domain.GenderType.Female)
                 {
                     session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("NOT_HUNGRY_FEMALE"), 1));
                 }
                 else
                 {
                     session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("NOT_HUNGRY_MALE"), 1));
                 }
             }
             if (amount == 0)
             {
                 Thread workerThread2 = new Thread(() => Sync(session, item));
                 workerThread2.Start();
             }
             break;
     }
 }
예제 #14
0
        public void RarifyItem(ClientSession session, RarifyMode mode, RarifyProtection protection,
                               bool isCommand = false)
        {
            double       raren2              = 80;
            double       raren1              = 70;
            double       rare0               = 60;
            double       rare1               = 40;
            double       rare2               = 30;
            double       rare3               = 15;
            double       rare4               = 10;
            double       rare5               = 5;
            double       rare6               = 3;
            double       rare7               = 2;
            double       rare8               = 1;
            const short  goldprice           = 500;
            const double reducedpricefactor  = 0.5;
            const double reducedchancefactor = 1.1;
            const byte   cella               = 5;
            const int    cellaVnum           = 1014;
            const int    scrollVnum          = 1218;
            double       rnd;

            if (session != null && !session.HasCurrentMapInstance)
            {
                return;
            }
            if (mode != RarifyMode.Drop || Item.ItemType == ItemType.Shell)
            {
                raren2 = 0;
                raren1 = 0;
                rare0  = 0;
                rnd    = ServerManager.Instance.RandomNumber(0, 80);
            }
            else
            {
                rnd = ServerManager.Instance.RandomNumber(0, 1000) / 10D;
            }
            if (protection == RarifyProtection.RedAmulet)
            {
                raren2 = raren1 * reducedchancefactor;
                raren1 = raren1 * reducedchancefactor;
                rare0  = rare0 * reducedchancefactor;
                rare1  = rare1 * reducedchancefactor;
                rare2  = rare2 * reducedchancefactor;
                rare3  = rare3 * reducedchancefactor;
                rare4  = rare4 * reducedchancefactor;
                rare5  = rare5 * reducedchancefactor;
                rare6  = rare6 * reducedchancefactor;
                rare7  = rare7 * reducedchancefactor;
                rare8  = rare8 * reducedchancefactor;
            }
            if (session != null)
            {
                switch (mode)
                {
                case RarifyMode.Free:
                    break;

                case RarifyMode.Reduced:

                    // TODO: Reduced Item Amount
                    if (session.Character.Gold < (long)(goldprice * reducedpricefactor))
                    {
                        return;
                    }
                    if (session.Character.Inventory.CountItem(cellaVnum) < cella * reducedpricefactor)
                    {
                        return;
                    }
                    session.Character.Inventory.RemoveItemAmount(cellaVnum, (int)(cella * reducedpricefactor));
                    session.Character.Gold -= (long)(goldprice * reducedpricefactor);
                    session.SendPacket(session.Character.GenerateGold());
                    break;

                case RarifyMode.Normal:

                    // TODO: Normal Item Amount
                    if (session.Character.Gold < goldprice)
                    {
                        return;
                    }
                    if (session.Character.Inventory.CountItem(cellaVnum) < cella)
                    {
                        return;
                    }
                    if (protection == RarifyProtection.Scroll && !isCommand &&
                        session.Character.Inventory.CountItem(scrollVnum) < 1)
                    {
                        return;
                    }

                    if (protection == RarifyProtection.Scroll && !isCommand)
                    {
                        session.Character.Inventory.RemoveItemAmount(scrollVnum);
                        session.SendPacket("shop_end 2");
                    }
                    session.Character.Gold -= goldprice;
                    session.Character.Inventory.RemoveItemAmount(cellaVnum, cella);
                    session.SendPacket(session.Character.GenerateGold());
                    break;

                case RarifyMode.Drop:
                    break;

                default:
                    throw new ArgumentOutOfRangeException(nameof(mode), mode, null);
                }
            }
            if (Item.IsHeroic && protection == RarifyProtection.Scroll)
            {
                if (rnd < rare8 && !(protection == RarifyProtection.Scroll && Rare >= 8))
                {
                    if (mode != RarifyMode.Drop)
                    {
                        session?.Character.NotifyRarifyResult(8);
                    }

                    Rare = 8;
                    SetRarityPoint();
                    ItemInstance inventory = session?.Character.Inventory.GetItemInstanceById(Id);
                    if (inventory != null)
                    {
                        session.SendPacket(inventory.GenerateInventoryAdd());
                    }
                    return;
                }
            }
            if (rnd < rare7 && !(protection == RarifyProtection.Scroll && Rare >= 7))
            {
                if (mode != RarifyMode.Drop)
                {
                    session?.Character.NotifyRarifyResult(7);
                }

                Rare = 7;
                SetRarityPoint();
            }
            else if (rnd < rare6 && !(protection == RarifyProtection.Scroll && Rare >= 6))
            {
                if (mode != RarifyMode.Drop)
                {
                    session?.Character.NotifyRarifyResult(6);
                }
                Rare = 6;
                SetRarityPoint();
            }
            else if (rnd < rare5 && !(protection == RarifyProtection.Scroll && Rare >= 5))
            {
                if (mode != RarifyMode.Drop)
                {
                    session?.Character.NotifyRarifyResult(5);
                }
                Rare = 5;
                SetRarityPoint();
            }
            else if (rnd < rare4 && !(protection == RarifyProtection.Scroll && Rare >= 4))
            {
                if (mode != RarifyMode.Drop)
                {
                    session?.Character.NotifyRarifyResult(4);
                }
                Rare = 4;
                SetRarityPoint();
            }
            else if (rnd < rare3 && !(protection == RarifyProtection.Scroll && Rare >= 3))
            {
                if (mode != RarifyMode.Drop)
                {
                    session?.Character.NotifyRarifyResult(3);
                }
                Rare = 3;
                SetRarityPoint();
            }
            else if (rnd < rare2 && !(protection == RarifyProtection.Scroll && Rare >= 2))
            {
                if (mode != RarifyMode.Drop)
                {
                    session?.Character.NotifyRarifyResult(2);
                }
                Rare = 2;
                SetRarityPoint();
            }
            else if (rnd < rare1 && !(protection == RarifyProtection.Scroll && Rare >= 1))
            {
                if (mode != RarifyMode.Drop)
                {
                    session?.Character.NotifyRarifyResult(1);
                }
                Rare = 1;
                SetRarityPoint();
            }
            else if (rnd < rare0 && !(protection == RarifyProtection.Scroll && Rare >= 0))
            {
                if (mode != RarifyMode.Drop)
                {
                    session?.Character.NotifyRarifyResult(0);
                }
                Rare = 0;
                SetRarityPoint();
            }
            else if (rnd < raren1 && !(protection == RarifyProtection.Scroll && Rare >= -1))
            {
                if (mode != RarifyMode.Drop)
                {
                    session?.Character.NotifyRarifyResult(-1);
                }
                Rare = -1;
                SetRarityPoint();
            }
            else if (rnd < raren2 && !(protection == RarifyProtection.Scroll && Rare >= -2))
            {
                if (mode != RarifyMode.Drop)
                {
                    session?.Character.NotifyRarifyResult(-2);
                }
                Rare = -2;
                SetRarityPoint();
            }
            else
            {
                if (mode != RarifyMode.Drop && session != null)
                {
                    if (protection == RarifyProtection.None)
                    {
                        session.Character.DeleteItemByItemInstanceId(Id);
                        session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("RARIFY_FAILED"), 11));
                        session.SendPacket(UserInterfaceHelper.Instance.GenerateMsg(Language.Instance.GetMessageFromKey("RARIFY_FAILED"), 0));
                    }
                    else
                    {
                        session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("RARIFY_FAILED_ITEM_SAVED"), 11));
                        session.SendPacket(UserInterfaceHelper.Instance.GenerateMsg(Language.Instance.GetMessageFromKey("RARIFY_FAILED_ITEM_SAVED"), 0));
                        session.CurrentMapInstance.Broadcast(session.Character.GenerateEff(3004), session.Character.MapX, session.Character.MapY);
                    }
                }
            }
            if (mode != RarifyMode.Drop && session != null)
            {
                ItemInstance inventory = session.Character.Inventory.GetItemInstanceById(Id);
                if (inventory != null)
                {
                    session.SendPacket(inventory.GenerateInventoryAdd());
                }
            }
        }
예제 #15
0
        public override void Use(ClientSession session, ref ItemInstance inv, byte Option = 0, string[] packetsplit = null)
        {
            switch (Effect)
            {
            // airwaves - eventitems
            case 0:
                if (inv.Item.ItemType == ItemType.Shell)
                {
                    if (inv.ShellEffects.Count != 0 && packetsplit?.Length > 9 && byte.TryParse(packetsplit[9], out byte islot))
                    {
                        ItemInstance wearable = session.Character.Inventory.LoadBySlotAndType <ItemInstance>(islot, InventoryType.Equipment);
                        if (wearable != null && (wearable.Item.ItemType == ItemType.Weapon || wearable.Item.ItemType == ItemType.Armor) && (wearable.Item.LevelMinimum >= inv.Upgrade || wearable.Item.IsHeroic) && wearable.Rare >= inv.Rare)
                        {
                            bool weapon = false;
                            if ((inv.ItemVNum >= 565 && inv.ItemVNum <= 576) || (inv.ItemVNum >= 589 && inv.ItemVNum <= 598))
                            {
                                weapon = true;
                            }
                            else if ((inv.ItemVNum >= 577 && inv.ItemVNum <= 588) || (inv.ItemVNum >= 656 && inv.ItemVNum <= 664) || inv.ItemVNum == 599)
                            {
                                weapon = false;
                            }
                            else
                            {
                                return;
                            }
                            if ((wearable.Item.ItemType == ItemType.Weapon && weapon) || (wearable.Item.ItemType == ItemType.Armor && !weapon))
                            {
                                //if (wearable.ShellEffects.Count > 0 && ServerManager.RandomNumber() < 50)
                                //{
                                //    session.Character.DeleteItemByItemInstanceId(inv.Id);
                                //    session.SendPacket(UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("OPTION_APPLY_FAIL"), 0));
                                //    return;
                                //}
                                wearable.ShellEffects.Clear();
                                DAOFactory.ShellEffectDAO.DeleteByEquipmentSerialId(wearable.EquipmentSerialId);
                                wearable.ShellEffects.AddRange(inv.ShellEffects);
                                if (wearable.EquipmentSerialId == Guid.Empty)
                                {
                                    wearable.EquipmentSerialId = Guid.NewGuid();
                                }
                                DAOFactory.ShellEffectDAO.InsertOrUpdateFromList(wearable.ShellEffects, wearable.EquipmentSerialId);

                                session.Character.DeleteItemByItemInstanceId(inv.Id);
                                session.SendPacket(UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("OPTION_APPLY_SUCCESS"), 0));
                            }
                        }
                    }
                    return;
                }

                if (ItemType == ItemType.Event)
                {
                    session.CurrentMapInstance?.Broadcast(StaticPacketHelper.GenerateEff(UserType.Player, session.Character.CharacterId, EffectValue));
                    if (MappingHelper.GuriItemEffects.ContainsKey(EffectValue))
                    {
                        session.CurrentMapInstance?.Broadcast(UserInterfaceHelper.GenerateGuri(19, 1, session.Character.CharacterId, MappingHelper.GuriItemEffects[EffectValue]), session.Character.MapX, session.Character.MapY);
                    }
                    session.Character.Inventory.RemoveItemFromInventory(inv.Id);
                }
                break;

            //respawn objects
            case 1:
                if (session.Character.MapInstance.MapInstanceType != MapInstanceType.BaseMapInstance || ServerManager.Instance.ChannelId == 51)
                {
                    session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("CANT_USE_THAT"), 10));
                    return;
                }
                int type, secondaryType, inventoryType, slot;
                if (packetsplit != null && int.TryParse(packetsplit[2], out type) && int.TryParse(packetsplit[3], out secondaryType) && int.TryParse(packetsplit[4], out inventoryType) && int.TryParse(packetsplit[5], out slot))
                {
                    int packetType;
                    switch (EffectValue)
                    {
                    case 0:
                        if (Option == 0)
                        {
                            session.SendPacket(UserInterfaceHelper.GenerateDialog($"#u_i^{type}^{secondaryType}^{inventoryType}^{slot}^1 #u_i^{type}^{secondaryType}^{inventoryType}^{slot}^2 {Language.Instance.GetMessageFromKey("WANT_TO_SAVE_POSITION")}"));
                        }
                        else if (int.TryParse(packetsplit[6], out packetType))
                        {
                            switch (packetType)
                            {
                            case 1:
                                session.SendPacket(UserInterfaceHelper.GenerateDelay(5000, 7, $"#u_i^{type}^{secondaryType}^{inventoryType}^{slot}^3"));
                                break;

                            case 2:
                                session.SendPacket(UserInterfaceHelper.GenerateDelay(5000, 7, $"#u_i^{type}^{secondaryType}^{inventoryType}^{slot}^4"));
                                break;

                            case 3:
                                session.Character.SetReturnPoint(session.Character.MapId, session.Character.MapX, session.Character.MapY);
                                RespawnMapTypeDTO respawn = session.Character.Respawn;
                                if (respawn.DefaultX != 0 && respawn.DefaultY != 0 && respawn.DefaultMapId != 0)
                                {
                                    ServerManager.Instance.ChangeMap(session.Character.CharacterId, respawn.DefaultMapId, (short)(respawn.DefaultX + ServerManager.RandomNumber(-5, 5)), (short)(respawn.DefaultY + ServerManager.RandomNumber(-5, 5)));
                                }
                                session.Character.Inventory.RemoveItemFromInventory(inv.Id);
                                break;

                            case 4:
                                RespawnMapTypeDTO respawnObj = session.Character.Respawn;
                                if (respawnObj.DefaultX != 0 && respawnObj.DefaultY != 0 && respawnObj.DefaultMapId != 0)
                                {
                                    ServerManager.Instance.ChangeMap(session.Character.CharacterId, respawnObj.DefaultMapId, (short)(respawnObj.DefaultX + ServerManager.RandomNumber(-5, 5)), (short)(respawnObj.DefaultY + ServerManager.RandomNumber(-5, 5)));
                                }
                                session.Character.Inventory.RemoveItemFromInventory(inv.Id);
                                break;
                            }
                        }
                        break;

                    case 1:
                        if (int.TryParse(packetsplit[6], out packetType))
                        {
                            RespawnMapTypeDTO respawn = session.Character.Return;
                            switch (packetType)
                            {
                            case 0:
                                if (respawn.DefaultX != 0 && respawn.DefaultY != 0 && respawn.DefaultMapId != 0)
                                {
                                    session.SendPacket(UserInterfaceHelper.GenerateRp(respawn.DefaultMapId, respawn.DefaultX, respawn.DefaultY, $"#u_i^{type}^{secondaryType}^{inventoryType}^{slot}^1"));
                                }
                                break;

                            case 1:
                                session.SendPacket(UserInterfaceHelper.GenerateDelay(5000, 7, $"#u_i^{type}^{secondaryType}^{inventoryType}^{slot}^2"));
                                break;

                            case 2:
                                if (respawn.DefaultX != 0 && respawn.DefaultY != 0 && respawn.DefaultMapId != 0)
                                {
                                    ServerManager.Instance.ChangeMap(session.Character.CharacterId, respawn.DefaultMapId, respawn.DefaultX, respawn.DefaultY);
                                }
                                session.Character.Inventory.RemoveItemFromInventory(inv.Id);
                                break;
                            }
                        }
                        break;

                    case 2:
                        if (Option == 0)
                        {
                            session.SendPacket(UserInterfaceHelper.GenerateDelay(5000, 7, $"#u_i^{type}^{secondaryType}^{inventoryType}^{slot}^1"));
                        }
                        else
                        {
                            ServerManager.Instance.JoinMiniland(session, session);
                            session.Character.Inventory.RemoveItemFromInventory(inv.Id);
                        }
                        break;

                    case 9:
                    {
                        if (Option == 0)
                        {
                            session.SendPacket(UserInterfaceHelper.GenerateDialog($"#u_i^{type}^{secondaryType}^{inventoryType}^{slot}^1 #u_i^{type}^{secondaryType}^{inventoryType}^{slot}^2 {Language.Instance.GetMessageFromKey("WANT_TO_SAVE_POSITION")}"));
                        }
                        else if (int.TryParse(packetsplit[6], out packetType))
                        {
                            switch (packetType)
                            {
                            case 1:
                                session.SendPacket(UserInterfaceHelper.GenerateDelay(5000, 7, $"#u_i^{type}^{secondaryType}^{inventoryType}^{slot}^3"));
                                break;

                            case 2:
                                session.SendPacket(UserInterfaceHelper.GenerateDelay(5000, 7, $"#u_i^{type}^{secondaryType}^{inventoryType}^{slot}^4"));
                                break;

                            case 3:
                                session.Character.SetReturnPoint(session.Character.MapId, session.Character.MapX, session.Character.MapY);
                                RespawnMapTypeDTO respawn = session.Character.Respawn;
                                if (respawn.DefaultX != 0 && respawn.DefaultY != 0 && respawn.DefaultMapId != 0)
                                {
                                    ServerManager.Instance.ChangeMap(session.Character.CharacterId, respawn.DefaultMapId, (short)(respawn.DefaultX + ServerManager.RandomNumber(-5, 5)), (short)(respawn.DefaultY + ServerManager.RandomNumber(-5, 5)));
                                }
                                break;

                            case 4:
                                RespawnMapTypeDTO respawnObj = session.Character.Respawn;
                                if (respawnObj.DefaultX != 0 && respawnObj.DefaultY != 0 && respawnObj.DefaultMapId != 0)
                                {
                                    ServerManager.Instance.ChangeMap(session.Character.CharacterId, respawnObj.DefaultMapId, (short)(respawnObj.DefaultX + ServerManager.RandomNumber(-5, 5)), (short)(respawnObj.DefaultY + ServerManager.RandomNumber(-5, 5)));
                                }
                                break;
                            }
                        }
                    }
                    break;
                    }
                }
                break;

            // dyes or waxes
            case 10:
            case 11:
                if (!session.Character.IsVehicled)
                {
                    if (Effect == 10)
                    {
                        if (EffectValue == 99)
                        {
                            var nextValue = (byte)ServerManager.RandomNumber(0, 127);
                            session.Character.HairColor = Enum.IsDefined(typeof(HairColorType), nextValue) ? (HairColorType)nextValue : 0;
                        }
                        else
                        {
                            session.Character.HairColor = Enum.IsDefined(typeof(HairColorType), (byte)EffectValue) ? (HairColorType)EffectValue : 0;
                        }
                    }
                    else
                    {
                        if (session.Character.Class == (byte)ClassType.Adventurer && EffectValue > 1)
                        {
                            session.SendPacket(UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("ADVENTURERS_CANT_USE"), 10));
                            return;
                        }

                        if (EffectValue == 10 || EffectValue == 11 || EffectValue == 13 || EffectValue == 15)
                        {
                            if ((EffectValue == 10 || EffectValue == 11) && session.Character.Gender == GenderType.Female)
                            {
                                session.Character.HairStyle = Enum.IsDefined(typeof(HairStyleType), (byte)EffectValue) ? (HairStyleType)EffectValue : 0;
                            }
                            else if ((EffectValue == 13 || EffectValue == 15) && session.Character.Gender == GenderType.Male)
                            {
                                session.Character.HairStyle = Enum.IsDefined(typeof(HairStyleType), (byte)EffectValue) ? (HairStyleType)EffectValue : 0;
                            }
                            else
                            {
                                session.SendPacket("info You cant use the Item!");
                                return;
                            }
                        }
                        else
                        {
                            session.Character.HairStyle = Enum.IsDefined(typeof(HairStyleType), (byte)EffectValue) ? (HairStyleType)EffectValue : 0;
                        }
                    }

                    session.SendPacket(session.Character.GenerateEq());
                    session.CurrentMapInstance?.Broadcast(session, session.Character.GenerateIn());
                    session.CurrentMapInstance?.Broadcast(session, session.Character.GenerateGidx());
                    session.Character.Inventory.RemoveItemAmount(inv.ItemVNum, 1);
                }

                break;

            // dignity restoration
            case 14:
                if ((EffectValue == 100 || EffectValue == 200) && session.Character.Dignity < 100 && !session.Character.IsVehicled)
                {
                    session.Character.Dignity += EffectValue;
                    if (session.Character.Dignity > 100)
                    {
                        session.Character.Dignity = 100;
                    }
                    session.SendPacket(session.Character.GenerateFd());
                    session.SendPacket(StaticPacketHelper.GenerateEff(UserType.Player, session.Character.CharacterId, 49 - (byte)session.Character.Faction));
                    session.CurrentMapInstance?.Broadcast(session, session.Character.GenerateIn(), ReceiverType.AllExceptMe);
                    session.CurrentMapInstance?.Broadcast(session, session.Character.GenerateGidx(), ReceiverType.AllExceptMe);
                    session.Character.Inventory.RemoveItemFromInventory(inv.Id);
                }
                else if (EffectValue == 2000 && session.Character.Dignity < 100 && !session.Character.IsVehicled)
                {
                    session.Character.Dignity = 100;
                    session.SendPacket(session.Character.GenerateFd());
                    session.SendPacket(StaticPacketHelper.GenerateEff(UserType.Player, session.Character.CharacterId, 49 - (byte)session.Character.Faction));
                    session.CurrentMapInstance?.Broadcast(session, session.Character.GenerateIn(), ReceiverType.AllExceptMe);
                    session.CurrentMapInstance?.Broadcast(session, session.Character.GenerateGidx(), ReceiverType.AllExceptMe);
                    session.Character.Inventory.RemoveItemFromInventory(inv.Id);
                }
                break;

            // speakers
            case 15:
                if (!session.Character.IsVehicled && Option == 0)
                {
                    session.SendPacket(UserInterfaceHelper.GenerateGuri(10, 3, session.Character.CharacterId, 1));
                }
                break;

            // bubbles
            case 16:
                if (!session.Character.IsVehicled && Option == 0)
                {
                    session.SendPacket(UserInterfaceHelper.GenerateGuri(10, 4, session.Character.CharacterId, 1));
                }
                break;

            // wigs
            case 30:
                if (!session.Character.IsVehicled)
                {
                    ItemInstance wig = session.Character.Inventory.LoadBySlotAndType((byte)EquipmentType.Hat, InventoryType.Wear);
                    if (wig != null)
                    {
                        wig.Design = (byte)ServerManager.RandomNumber(0, 15);
                        session.SendPacket(session.Character.GenerateEq());
                        session.SendPacket(session.Character.GenerateEquipment());
                        session.CurrentMapInstance?.Broadcast(session, session.Character.GenerateIn());
                        session.CurrentMapInstance?.Broadcast(session, session.Character.GenerateGidx());
                        session.Character.Inventory.RemoveItemFromInventory(inv.Id);
                    }
                    else
                    {
                        session.SendPacket(UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("NO_WIG"), 0));
                    }
                }
                break;

            case 13378:                                                                                // goldene up rolle 5369
                var item3 = session.Character.Inventory.LoadBySlotAndType(0, InventoryType.Equipment); // dont touch that People need to put the Sp in slot 0

                if (item3 != null && (item3.Item.ItemType == ItemType.Weapon || item3.Item.ItemType == ItemType.Armor))
                {
                    if (item3.Upgrade < 10 && item3.Item.ItemType != ItemType.Specialist)
                    {
                        for (int i = 0; i < 10; i++)
                        {
                            item3.UpgradeItem(session, UpgradeMode.Reduced, UpgradeProtection.Protected);
                        }
                    }
                    else
                    {
                        session.SendPacket("msg 2 Equipment already have max upgrade!", 10);
                        session.SendPacket(session.Character.GenerateSay($" Equipment already have max upgrade!", 11));
                    }
                }
                else
                {
                    session.SendPacket(session.Character.GenerateSay($"Put your item to upgrade in first inventory slot", 11));
                }
                break;

            case 13380:                                                                                // weapon dmg increase item
                var item4 = session.Character.Inventory.LoadBySlotAndType(0, InventoryType.Equipment); // dont touch that People need to put the Sp in slot 0

                if (item4 != null && (item4.Item.ItemType == ItemType.Weapon))
                {
                    if (item4.DamageMinimum < 3550 && item4.DamageMaximum < 6050 && item4.Item.ItemType != ItemType.Specialist && item4.ItemVNum == 4983)    //bogen
                    {
                        if (item4.Upgrade >= 10 && item4.Rare >= 10)
                        {
                            item4.DamageMinimum += 10;
                            item4.DamageMaximum += 16;
                            session.CurrentMapInstance?.Broadcast(StaticPacketHelper.GenerateEff(UserType.Player, session.Character.CharacterId, 23), session.Character.PositionX, session.Character.PositionY);
                            session.Character.Inventory.RemoveItemFromInventory(inv.Id);
                        }
                        else
                        {
                            session.SendPacket("msg 2 The item is not Rare 10 + 10", 10);
                            session.SendPacket(session.Character.GenerateSay($" The item is not Rare 10 + 10", 11));
                        }
                    }
                    else if (item4.DamageMinimum < 3430 && item4.DamageMaximum < 5870 && item4.Item.ItemType != ItemType.Specialist && item4.ItemVNum == 4980)   //Dolch
                    {
                        if (item4.Upgrade >= 10 && item4.Rare >= 10)
                        {
                            item4.DamageMinimum += 9;
                            item4.DamageMaximum += 15;
                            session.CurrentMapInstance?.Broadcast(StaticPacketHelper.GenerateEff(UserType.Player, session.Character.CharacterId, 23), session.Character.PositionX, session.Character.PositionY);
                            session.Character.Inventory.RemoveItemFromInventory(inv.Id);
                        }
                        else
                        {
                            session.SendPacket("msg 2 The item is not Rare 10 + 10", 10);
                            session.SendPacket(session.Character.GenerateSay($" The item is not Rare 10 + 10", 11));
                        }
                    }
                    else if (item4.DamageMinimum < 3320 && item4.DamageMaximum < 5800 && item4.Item.ItemType != ItemType.Specialist && item4.ItemVNum == 4981)   //Sword
                    {
                        if (item4.Upgrade >= 10 && item4.Rare >= 10)
                        {
                            item4.DamageMinimum += 8;
                            item4.DamageMaximum += 14;
                            session.CurrentMapInstance?.Broadcast(StaticPacketHelper.GenerateEff(UserType.Player, session.Character.CharacterId, 23), session.Character.PositionX, session.Character.PositionY);
                            session.Character.Inventory.RemoveItemFromInventory(inv.Id);
                        }
                        else
                        {
                            session.SendPacket("msg 2 The item is not Rare 10 + 10", 10);
                            session.SendPacket(session.Character.GenerateSay($" The item is not Rare 10 + 10", 11));
                        }
                    }
                    else if (item4.DamageMinimum < 3250 && item4.DamageMaximum < 5720 && item4.Item.ItemType != ItemType.Specialist && item4.ItemVNum == 4978)    //crossbow
                    {
                        if (item4.Upgrade >= 10 && item4.Rare >= 10)
                        {
                            item4.DamageMinimum += 8;
                            item4.DamageMaximum += 14;
                            session.CurrentMapInstance?.Broadcast(StaticPacketHelper.GenerateEff(UserType.Player, session.Character.CharacterId, 23), session.Character.PositionX, session.Character.PositionY);
                            session.Character.Inventory.RemoveItemFromInventory(inv.Id);
                        }
                        else
                        {
                            session.SendPacket("msg 2 The item is not Rare 10 + 10", 10);
                            session.SendPacket(session.Character.GenerateSay($" The item is not Rare 10 + 10", 11));
                        }
                    }
                    else if (item4.DamageMinimum < 3700 && item4.DamageMaximum < 6300 && item4.Item.ItemType != ItemType.Specialist && item4.ItemVNum == 4982)   //stab
                    {
                        if (item4.Upgrade >= 10 && item4.Rare >= 10)
                        {
                            item4.DamageMinimum += 12;
                            item4.DamageMaximum += 18;
                            session.CurrentMapInstance?.Broadcast(StaticPacketHelper.GenerateEff(UserType.Player, session.Character.CharacterId, 23), session.Character.PositionX, session.Character.PositionY);
                            session.Character.Inventory.RemoveItemFromInventory(inv.Id);
                        }
                        else
                        {
                            session.SendPacket("msg 2 The item is not Rare 10 + 10", 10);
                            session.SendPacket(session.Character.GenerateSay($" The item is not Rare 10 + 10", 11));
                        }
                    }
                    else if (item4.DamageMinimum < 3640 && item4.DamageMaximum < 6200 && item4.Item.ItemType != ItemType.Specialist && item4.ItemVNum == 4979)    //zauberwaffe
                    {
                        if (item4.Upgrade >= 10 && item4.Rare >= 10)
                        {
                            item4.DamageMinimum += 11;
                            item4.DamageMaximum += 17;
                            session.CurrentMapInstance?.Broadcast(StaticPacketHelper.GenerateEff(UserType.Player, session.Character.CharacterId, 23), session.Character.PositionX, session.Character.PositionY);
                            session.Character.Inventory.RemoveItemFromInventory(inv.Id);
                        }
                        else
                        {
                            session.SendPacket("msg 2 The item is not Rare 10 + 10", 10);
                            session.SendPacket(session.Character.GenerateSay($" The item is not Rare 10 + 10", 11));
                        }
                    }
                    else
                    {
                        session.SendPacket("msg 2 You reached the maximal upgrade", 10);
                        session.SendPacket(session.Character.GenerateSay($" You reached the maximal upgrade", 11));
                    }
                }
                else
                {
                    session.SendPacket(session.Character.GenerateSay($"Put your weapon in first inventory slot", 11));
                }
                break;


            case 13377:                                                                                //   Rote sp rolle  1364 //auto upgrade Toxic
                var item2 = session.Character.Inventory.LoadBySlotAndType(0, InventoryType.Equipment); // dont touch that People need to put the Sp in slot 0

                if (item2 != null && (item2.Item.ItemType == ItemType.Specialist))
                {
                    if (item2.Rare != -2 && item2.Item.ItemType != ItemType.Weapon && item2.Item.ItemType != ItemType.Armor)
                    {
                        if (item2.Upgrade >= 10 && item2.Upgrade < 15)
                        {
                            for (int i = 0; i < 20; i++)
                            {
                                item2.UpgradeSp(session, UpgradeProtection.Protected);
                            }
                        }
                        else
                        {
                            session.SendPacket(session.Character.GenerateSay($" your sp is under +10 or is already +15", 11));
                        }
                    }
                    else
                    {
                        session.SendPacket("msg 2 Your SP is destroyed!", 10);
                        session.SendPacket(session.Character.GenerateSay($" Your SP is destroyed!", 11));
                    }
                }
                else
                {
                    session.SendPacket(session.Character.GenerateSay($"Put your sp in the 1.st invorty slot", 11));
                }
                break;



            case 13376:                                                                                 //   blaue sp rolle  1363//auto upgrade Toxic
                var itemsp = session.Character.Inventory.LoadBySlotAndType(0, InventoryType.Equipment); // dont touch that People need to put the Sp in slot 0

                if (itemsp != null && (itemsp.Item.ItemType == ItemType.Specialist))
                {
                    if (itemsp.Rare != -2 && itemsp.Item.ItemType != ItemType.Weapon && itemsp.Item.ItemType != ItemType.Armor)
                    {
                        if (itemsp.Upgrade < 10)
                        {
                            for (int i = 0; i < 20; i++)
                            {
                                itemsp.UpgradeSp(session, UpgradeProtection.Protected);
                            }
                        }
                        else
                        {
                            session.SendPacket(session.Character.GenerateSay($" please use the red scroll", 11));
                        }
                    }
                    else
                    {
                        session.SendPacket("msg 2 Your SP is destroyed!", 10);
                        session.SendPacket(session.Character.GenerateSay($" Your SP is destroyed!", 11));
                    }
                }
                else
                {
                    session.SendPacket(session.Character.GenerateSay($"Put your sp in the 1.st invorty slot", 11));
                }
                break;

            case 13387:                                                                                    //perfi 200 item
            {
                var itemperfi = session.Character.Inventory.LoadBySlotAndType(0, InventoryType.Equipment); // dont touch that People need to put the Sp in slot 0

                if (itemperfi != null && (itemperfi.Item.ItemType == ItemType.Specialist))
                {
                    if (itemperfi.SpStoneUpgrade >= 100)
                    {
                        if (itemperfi.SpStoneUpgrade <= 199)
                        {
                            itemperfi.SpStoneUpgrade++;
                            session.Character.Inventory.RemoveItemFromInventory(inv.Id);
                            int rnd1 = ServerManager.RandomNumber(0, 10);

                            if (rnd1 == 1)
                            {
                                itemperfi.SpDamage += 2;
                                session.CurrentMapInstance?.Broadcast(StaticPacketHelper.GenerateEff(UserType.Player, session.Character.CharacterId, 50), session.Character.PositionX, session.Character.PositionY);
                            }
                            if (rnd1 == 2)
                            {
                                itemperfi.SpDefence += 2;
                                session.CurrentMapInstance?.Broadcast(StaticPacketHelper.GenerateEff(UserType.Player, session.Character.CharacterId, 50), session.Character.PositionX, session.Character.PositionY);
                            }
                            if (rnd1 == 3)
                            {
                                itemperfi.SpElement += 2;
                                session.CurrentMapInstance?.Broadcast(StaticPacketHelper.GenerateEff(UserType.Player, session.Character.CharacterId, 50), session.Character.PositionX, session.Character.PositionY);
                            }
                            if (rnd1 == 4)
                            {
                                itemperfi.SpHP += 2;
                                session.CurrentMapInstance?.Broadcast(StaticPacketHelper.GenerateEff(UserType.Player, session.Character.CharacterId, 50), session.Character.PositionX, session.Character.PositionY);
                            }
                            if (rnd1 >= 5)
                            {
                                session.SendPacket("msg 2 upgrade failed", 10);
                                session.SendPacket(session.Character.GenerateSay($" upgrade failed", 11));
                            }
                        }
                        else
                        {
                            session.SendPacket("msg 2 The item is already on perfection 200", 10);
                            session.SendPacket(session.Character.GenerateSay($" The item is already on perfection 200", 11));
                        }
                    }
                    else
                    {
                        session.SendPacket("msg 2 you need perfection 100 on the sp to do this", 10);
                        session.SendPacket(session.Character.GenerateSay($" you need perfection 100 on the sp to do this", 11));
                    }
                }
                else
                {
                    session.SendPacket("msg 2 No sp in slot 1 found", 10);
                    session.SendPacket(session.Character.GenerateSay($" No sp in slot 1 found", 11));
                }
                break;
            }

            case 13379:
            {
                if (session.Character.HeroLevel > 27)
                {
                    if (session.Character.HeroLevel < 50)
                    {
                        session.Character.HeroLevel++;
                        session.CurrentMapInstance?.Broadcast(StaticPacketHelper.GenerateEff(UserType.Player, session.Character.CharacterId, 281), session.Character.PositionX, session.Character.PositionY);
                        session.CurrentMapInstance?.Broadcast(StaticPacketHelper.GenerateEff(UserType.Player, session.Character.CharacterId, 280), session.Character.PositionX, session.Character.PositionY);
                        session.Character.Inventory.RemoveItemFromInventory(inv.Id);
                        UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("You Reached Hero Level: " + session.Character.HeroLevel), 0);
                        session.SendPacket(session.Character.GenerateLev());
                        session.CurrentMapInstance?.Broadcast(session, session.Character.GenerateIn(), ReceiverType.AllExceptMe);
                        session.CurrentMapInstance?.Broadcast(session, session.Character.GenerateGidx(), ReceiverType.AllExceptMe);
                        session.CurrentMapInstance?.Broadcast(
                            StaticPacketHelper.GenerateEff(UserType.Player, session.Character.CharacterId, 6),
                            session.Character.PositionX, session.Character.PositionY);
                    }
                    else
                    {
                        session.SendPacket("msg 2 you reached already the maximum hero level", 10);
                    }
                }
                else
                {
                    session.SendPacket("msg 2 you need atleast hero lvl 28 to use this", 10);
                }
                break;
            }



            case 300:
                if (session.Character.Group != null && session.Character.Group.GroupType != GroupType.Group && session.Character.Group.IsLeader(session) && session.CurrentMapInstance.Portals.Any(s => s.Type == (short)PortalType.Raid))
                {
                    int delay = 0;
                    foreach (ClientSession sess in session.Character.Group.Characters.GetAllItems())
                    {
                        Observable.Timer(TimeSpan.FromMilliseconds(delay)).Subscribe(o =>
                        {
                            if (sess?.Character != null && session?.CurrentMapInstance != null && session?.Character != null)
                            {
                                ServerManager.Instance.ChangeMapInstance(sess.Character.CharacterId, session.CurrentMapInstance.MapInstanceId, session.Character.PositionX, session.Character.PositionY);
                            }
                        });
                        delay += 100;
                    }
                    session.Character.Inventory.RemoveItemFromInventory(inv.Id);
                }
                break;

            default:
                Logger.Warn(string.Format(Language.Instance.GetMessageFromKey("NO_HANDLER_ITEM"), GetType(), VNum, Effect, EffectValue));
                break;
            }
        }
예제 #16
0
        private static void Sync(ClientSession session)
        {
            for (session.Character.MaxFood = 0; session.Character.MaxFood < 5; session.Character.MaxFood++)
            {
                if (session.Character.Hp <= 0 || !session.Character.IsSitting)
                {
                    _regenerateDisposable?.Dispose();
                    session.Character.FoodAmount = 0;
                    session.Character.FoodHp     = 0;
                    session.Character.FoodMp     = 0;
                    return;
                }

                int hpLoad = (int)session.Character.HPLoad();
                int mpLoad = (int)session.Character.MPLoad();

                double buffRc = session.Character.GetBuff(BCardType.CardType.LeonaPassiveSkill, (byte)AdditionalTypes.LeonaPassiveSkill.IncreaseRecoveryItems)[0] / 100D;

                int hpAmount = session.Character.FoodHp + (int)(session.Character.FoodHp * buffRc);
                int mpAmount = session.Character.FoodMp + (int)(session.Character.FoodMp * buffRc);

                if (session.Character.Hp + hpAmount > hpLoad)
                {
                    hpAmount = hpLoad - session.Character.Hp;
                }

                if (session.Character.Mp + mpAmount > mpLoad)
                {
                    mpAmount = mpLoad - session.Character.Mp;
                }

                bool convertRecoveryToDamage = ServerManager.RandomNumber() < session.Character.GetBuff(BCardType.CardType.DarkCloneSummon, (byte)AdditionalTypes.DarkCloneSummon.ConvertRecoveryToDamage)[0];

                if (convertRecoveryToDamage)
                {
                    session.Character.Hp -= hpAmount;

                    if (session.Character.Hp < 1)
                    {
                        session.Character.Hp = 1;
                    }

                    if (hpAmount > 0)
                    {
                        session.CurrentMapInstance?.Broadcast(session, session.Character.GenerateDm(hpAmount));
                    }
                }
                else
                {
                    session.Character.Hp += hpAmount;

                    if (hpAmount > 0)
                    {
                        session.CurrentMapInstance?.Broadcast(session, session.Character.GenerateRc(hpAmount));
                    }
                }

                session.Character.Mp += mpAmount;

                foreach (Mate mate in session.Character.Mates.Where(s => s.IsTeamMember && s.IsAlive && s.IsSitting))
                {
                    hpLoad = mate.HpLoad();
                    mpLoad = mate.MpLoad();

                    hpAmount = session.Character.FoodHp;
                    mpAmount = session.Character.FoodMp;

                    if (mate.Hp + hpAmount > hpLoad)
                    {
                        hpAmount = hpLoad - (int)mate.Hp;
                    }

                    if (mate.Mp + mpAmount > mpLoad)
                    {
                        mpAmount = mpLoad - (int)mate.Mp;
                    }

                    mate.Hp += hpAmount;
                    mate.Mp += mpAmount;

                    if (hpAmount > 0)
                    {
                        session.CurrentMapInstance?.Broadcast(session, mate.GenerateRc(hpAmount));
                    }
                }

                if (session.IsConnected)
                {
                    session.SendPacket(session.Character.GenerateStat());

                    if (session.Character.Mates.Any(m => m.IsTeamMember && m.IsAlive && m.IsSitting))
                    {
                        session.SendPackets(session.Character.GeneratePst());
                    }

                    Thread.Sleep(1800);
                }
            }
        }
예제 #17
0
        public override void Use(ClientSession Session, ref Inventory Inv, bool DelayUsed = false)
        {
            Random random = new Random();

            switch (Effect)
            {
            // dyes
            case 10:
                if (this != null && !Session.Character.IsVehicled)
                {
                    if (EffectValue == 99)
                    {
                        Session.Character.HairColor = (byte)random.Next(0, 127);
                    }
                    else
                    {
                        Session.Character.HairColor = (byte)EffectValue;
                    }
                    Session.SendPacket(Session.Character.GenerateEq());
                    Session.CurrentMap?.Broadcast(Session, Session.Character.GenerateIn(), ReceiverType.All);
                    Inv.ItemInstance.Amount--;
                    if (Inv.ItemInstance.Amount > 0)
                    {
                        Session.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.SendPacket(Session.Character.GenerateInventoryAdd(-1, 0, Inv.Type, Inv.Slot, 0, 0, 0, 0));
                    }
                }
                break;

            // waxes
            case 11:
                if (this != null && !Session.Character.IsVehicled)
                {
                    if (Session.Character.Class == (byte)ClassType.Adventurer && EffectValue > 1)
                    {
                        Session.SendPacket(Session.Character.GenerateMsg(Language.Instance.GetMessageFromKey("ADVENTURERS_CANT_USE"), 10));
                    }
                    else
                    {
                        Session.Character.HairStyle = Session.Character.HairStyle != (byte)EffectValue ? (byte)EffectValue : (byte)1;
                        Session.SendPacket(Session.Character.GenerateEq());
                        Session.CurrentMap?.Broadcast(Session, Session.Character.GenerateIn(), ReceiverType.All);
                        Inv.ItemInstance.Amount--;
                        if (Inv.ItemInstance.Amount > 0)
                        {
                            Session.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.SendPacket(Session.Character.GenerateInventoryAdd(-1, 0, Inv.Type, Inv.Slot, 0, 0, 0, 0));
                        }
                    }
                }
                break;

            case 14:
                switch (this.VNum)
                {
                // It's not good we need to parse it. Asap
                case 2156:
                    if (Session.Character.Dignity < 100 && !Session.Character.IsVehicled)
                    {
                        Session.Character.Dignity += 100;
                        if (Session.Character.Dignity > 100)
                        {
                            Session.Character.Dignity = 100;
                        }
                        Session.SendPacket(Session.Character.GenerateFd());
                        Session.SendPacket(Session.Character.GenerateEff(48));
                        Session.CurrentMap?.Broadcast(Session, Session.Character.GenerateIn(), ReceiverType.AllExceptMe);
                        Inv.ItemInstance.Amount--;
                        if (Inv.ItemInstance.Amount > 0)
                        {
                            Session.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.SendPacket(Session.Character.GenerateInventoryAdd(-1, 0, Inv.Type, Inv.Slot, 0, 0, 0, 0));
                        }
                    }
                    break;
                }
                break;

            // speakers
            case 15:
                if (this != null && !Session.Character.IsVehicled)
                {
                    if (!DelayUsed)
                    {
                        Session.SendPacket(Session.Character.GenerateGuri(10, 3, 1));
                    }
                }
                break;

            // bubbles
            case 16:
                if (this != null && !Session.Character.IsVehicled)
                {
                    if (!DelayUsed)
                    {
                        Session.SendPacket(Session.Character.GenerateGuri(10, 4, 1));
                    }
                }
                break;

            // wigs
            case 30:
                if (this != null && !Session.Character.IsVehicled)
                {
                    WearableInstance wig = Session.Character.EquipmentList.LoadBySlotAndType <WearableInstance>((byte)EquipmentType.Hat, InventoryType.Equipment);
                    if (wig != null)
                    {
                        wig.Design = (byte)random.Next(0, 15);
                        Session.SendPacket(Session.Character.GenerateEq());
                        Session.SendPacket(Session.Character.GenerateEquipment());
                        Session.CurrentMap?.Broadcast(Session, Session.Character.GenerateIn(), ReceiverType.All);
                        Inv.ItemInstance.Amount--;
                        if (Inv.ItemInstance.Amount > 0)
                        {
                            Session.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.SendPacket(Session.Character.GenerateInventoryAdd(-1, 0, Inv.Type, Inv.Slot, 0, 0, 0, 0));
                        }
                    }
                    else
                    {
                        Session.SendPacket(Session.Character.GenerateMsg(Language.Instance.GetMessageFromKey("NO_WIG"), 0));
                        return;
                    }
                }
                break;

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


            default:
                Logger.Debug("NO_HANDLER_ITEM");
                break;
            }
        }
예제 #18
0
        public void Sum(ClientSession session, WearableInstance itemToSum)
        {
            if (!session.HasCurrentMap)
            {
                return;
            }

            // cannot sum higher than 5
            if (Upgrade < 6)
            {
                short[] upsuccess = { 100, 100, 85, 70, 50, 20 };
                int[] goldprice = { 1500, 3000, 6000, 12000, 24000, 48000 };
                short[] sand = { 5, 10, 15, 20, 25, 30 };
                int sandVnum = 1027;
                if ((Upgrade + itemToSum.Upgrade) < 6 && ((((itemToSum.Item.EquipmentSlot == EquipmentType.Gloves) && (Item.EquipmentSlot == EquipmentType.Gloves)) || ((Item.EquipmentSlot == EquipmentType.Boots) && (itemToSum.Item.EquipmentSlot == EquipmentType.Boots)))))
                {
                    if (session.Character.Gold < goldprice[Upgrade])
                    {
                        return;
                    }
                    if (session.Character.Inventory.CountItem(sandVnum) < sand[Upgrade])
                    {
                        return;
                    }
                    session.Character.Inventory.RemoveItemAmount(sandVnum, (byte)(sand[Upgrade]));
                    session.Character.Gold -= goldprice[Upgrade];

                    int rnd = _random.Next(100);
                    if (rnd <= upsuccess[Upgrade + itemToSum.Upgrade])
                    {
                        Upgrade += (byte)(itemToSum.Upgrade + 1);
                        DarkResistance += (short)(itemToSum.DarkResistance + itemToSum.Item.DarkResistance);
                        LightResistance += (short)(itemToSum.LightResistance + itemToSum.Item.LightResistance);
                        WaterResistance += (short)(itemToSum.WaterResistance + itemToSum.Item.WaterResistance);
                        FireResistance += (short)(itemToSum.FireResistance + itemToSum.Item.FireResistance);
                        session.Character.DeleteItemByItemInstanceId(itemToSum.Id);
                        session.SendPacket($"pdti 10 {ItemVNum} 1 27 {Upgrade} 0");
                        session.SendPacket(session.Character.GenerateMsg(Language.Instance.GetMessageFromKey("SUM_SUCCESS"), 0));
                        session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("SUM_SUCCESS"), 12));
                        session.SendPacket(session.Character.GenerateGuri(19, 1, 1324));
                        ItemInstance itemInstnace = session.Character.Inventory.GetItemInstanceById(Id);
                        session.SendPacket(session.Character.GenerateInventoryAdd(itemInstnace.ItemVNum, 1, itemInstnace.Type, itemInstnace.Slot, 0, 0, Upgrade, 0));
                    }
                    else
                    {
                        session.SendPacket(session.Character.GenerateMsg(Language.Instance.GetMessageFromKey("SUM_FAILED"), 0));
                        session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("SUM_FAILED"), 11));
                        session.SendPacket(session.Character.GenerateGuri(19, 1, 1332));
                        session.Character.DeleteItemByItemInstanceId(itemToSum.Id);
                        session.Character.DeleteItemByItemInstanceId(Id);
                    }
                    session.CurrentMap?.Broadcast(session.Character.GenerateGuri(6, 1), session.Character.MapX, session.Character.MapY);
                    session.SendPacket(session.Character.GenerateGold());
                    session.SendPacket("shop_end 1");
                }
            }
        }
예제 #19
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;
            }
        }
        public void SpreadBroadcastpacket(BroadcastPacket sentPacket)
        {
            if (Sessions != null && !string.IsNullOrEmpty(sentPacket?.Packet))
            {
                switch (sentPacket.Receiver)
                {
                case ReceiverType.All:     // send packet to everyone
                    foreach (ClientSession session in Sessions)
                    {
                        session.SendPacket(sentPacket.Packet);
                    }
                    break;

                case ReceiverType.AllExceptMe:     // send to everyone except the sender
                    foreach (ClientSession session in Sessions.Where(s => s.SessionId != sentPacket.Sender.SessionId))
                    {
                        session.SendPacket(sentPacket.Packet);
                    }
                    break;

                case ReceiverType.AllInRange:     // send to everyone which is in a range of 50x50
                    if (sentPacket.XCoordinate != 0 && sentPacket.YCoordinate != 0)
                    {
                        foreach (ClientSession session in Sessions.Where(s => s.Character.IsInRange(sentPacket.XCoordinate, sentPacket.YCoordinate)))
                        {
                            session.SendPacket(sentPacket.Packet, 1);
                        }
                    }
                    break;

                case ReceiverType.OnlySomeone:
                {
                    if (sentPacket.SomeonesCharacterId > 0 || !string.IsNullOrEmpty(sentPacket.SomeonesCharacterName))
                    {
                        ClientSession targetSession = Sessions.SingleOrDefault(s => s.Character.CharacterId == sentPacket.SomeonesCharacterId || s.Character.Name == sentPacket.SomeonesCharacterName);

                        targetSession?.SendPacket(sentPacket.Packet);
                    }

                    break;
                }

                case ReceiverType.AllNoEmoBlocked:
                    foreach (ClientSession session in Sessions.Where(s => !s.Character.EmoticonsBlocked))
                    {
                        session.SendPacket(sentPacket.Packet);
                    }
                    break;

                case ReceiverType.AllNoHeroBlocked:
                    foreach (ClientSession session in Sessions.Where(s => !s.Character.HeroChatBlocked))
                    {
                        session.SendPacket(sentPacket.Packet);
                    }
                    break;

                case ReceiverType.Group:
                    foreach (ClientSession session in Sessions.Where(s => s.Character?.Group != null && sentPacket.Sender?.Character?.Group != null && s.Character.Group.GroupId == sentPacket.Sender.Character.Group.GroupId))
                    {
                        session.SendPacket(sentPacket.Packet);
                    }
                    break;
                }
            }
        }
예제 #21
0
        private void spreadBroadcastpacket(BroadcastPacket sentPacket)
        {
            if (Sessions != null && !string.IsNullOrEmpty(sentPacket?.Packet))
            {
                switch (sentPacket.Receiver)
                {
                case ReceiverType.All:     // send packet to everyone
                    if (sentPacket.Packet.StartsWith("out", StringComparison.CurrentCulture))
                    {
                        foreach (ClientSession session in Sessions.Where(s => s.Character == null || !s.Character.IsChangingMapInstance))
                        {
                            if (session.HasSelectedCharacter)
                            {
                                if (sentPacket.Sender != null)
                                {
                                    if (!sentPacket.Sender.Character.IsBlockedByCharacter(session.Character.CharacterId))
                                    {
                                        session.SendPacket(sentPacket.Packet);
                                    }
                                }
                                else
                                {
                                    session.SendPacket(sentPacket.Packet);
                                }
                            }
                        }
                    }
                    else
                    {
                        Parallel.ForEach(Sessions, session =>
                        {
                            if (session?.HasSelectedCharacter == true)
                            {
                                if (sentPacket.Sender != null)
                                {
                                    if (!sentPacket.Sender.Character.IsBlockedByCharacter(session.Character.CharacterId) || sentPacket.Packet.StartsWith("revive", StringComparison.CurrentCulture))
                                    {
                                        session.SendPacket(sentPacket.Packet);
                                    }
                                }
                                else
                                {
                                    session.SendPacket(sentPacket.Packet);
                                }
                            }
                        });
                    }
                    break;

                case ReceiverType.AllExceptMe:     // send to everyone except the sender
                    if (sentPacket.Packet.StartsWith("out", StringComparison.CurrentCulture))
                    {
                        foreach (ClientSession session in Sessions.Where(s => s?.SessionId != sentPacket.Sender?.SessionId && (s.Character == null || !s.Character.IsChangingMapInstance)))
                        {
                            if (session.HasSelectedCharacter)
                            {
                                if (sentPacket.Sender != null)
                                {
                                    //if (!sentPacket.Sender.Character.IsBlockedByCharacter(session.Character.CharacterId))
                                    {
                                        session.SendPacket(sentPacket.Packet);
                                    }
                                }
                                else
                                {
                                    session.SendPacket(sentPacket.Packet);
                                }
                            }
                        }
                    }
                    else
                    {
                        Parallel.ForEach(Sessions.Where(s => s?.SessionId != sentPacket.Sender?.SessionId), session =>
                        {
                            if (session?.HasSelectedCharacter == true)
                            {
                                if (sentPacket.Sender != null)
                                {
                                    if (!sentPacket.Sender.Character.IsBlockedByCharacter(session.Character.CharacterId))
                                    {
                                        session.SendPacket(sentPacket.Packet);
                                    }
                                }
                                else
                                {
                                    session.SendPacket(sentPacket.Packet);
                                }
                            }
                        });
                    }
                    break;

                case ReceiverType.AllExceptGroup:
                    if (sentPacket.Packet.StartsWith("out", StringComparison.CurrentCulture))
                    {
                        foreach (ClientSession session in Sessions.Where(s => s.SessionId != sentPacket.Sender.SessionId && (s.Character == null || !s.Character.IsChangingMapInstance)))
                        {
                            if (session.HasSelectedCharacter)
                            {
                                if (sentPacket.Sender != null)
                                {
                                    if (!sentPacket.Sender.Character.IsBlockedByCharacter(session.Character.CharacterId))
                                    {
                                        session.SendPacket(sentPacket.Packet);
                                    }
                                }
                                else
                                {
                                    session.SendPacket(sentPacket.Packet);
                                }
                            }
                        }
                    }
                    else
                    {
                        foreach (ClientSession session in Sessions.Where(s => s.SessionId != sentPacket.Sender.SessionId && (s.Character?.Group == null || (s.Character?.Group?.GroupId != sentPacket.Sender?.Character?.Group?.GroupId))))
                        {
                            if (session.HasSelectedCharacter && !sentPacket.Sender.Character.IsBlockedByCharacter(session.Character.CharacterId))
                            {
                                session.SendPacket(sentPacket.Packet);
                            }
                        }
                    }
                    break;

                case ReceiverType.AllExceptMeAct4:     // send to everyone except the sender(Act4)
                    Parallel.ForEach(Sessions.Where(s => s.SessionId != sentPacket.Sender?.SessionId && (s.Character == null || !s.Character.IsChangingMapInstance)), session =>
                    {
                        if (session?.HasSelectedCharacter == true)
                        {
                            if (sentPacket.Sender != null)
                            {
                                if (!sentPacket.Sender.Character.IsBlockedByCharacter(session.Character.CharacterId))
                                {
                                    if (session.Character.Faction == sentPacket.Sender.Character.Faction)
                                    {
                                        session.SendPacket(sentPacket.Packet);
                                    }
                                }
                            }
                            else
                            {
                                session.SendPacket(sentPacket.Packet);
                            }
                        }
                    });
                    break;

                case ReceiverType.AllInRange:     // send to everyone which is in a range of 50x50
                    if (sentPacket.XCoordinate != 0 && sentPacket.YCoordinate != 0)
                    {
                        Parallel.ForEach(Sessions.Where(s => s?.Character.IsInRange(sentPacket.XCoordinate, sentPacket.YCoordinate) == true && (s.Character == null || !s.Character.IsChangingMapInstance)), session =>
                        {
                            if (session?.HasSelectedCharacter == true)
                            {
                                if (sentPacket.Sender != null)
                                {
                                    if (!sentPacket.Sender.Character.IsBlockedByCharacter(session.Character.CharacterId))
                                    {
                                        session.SendPacket(sentPacket.Packet);
                                    }
                                }
                                else
                                {
                                    session.SendPacket(sentPacket.Packet);
                                }
                            }
                        });
                    }
                    break;

                case ReceiverType.OnlySomeone:
                    if (sentPacket.SomeonesCharacterId > 0 || !string.IsNullOrEmpty(sentPacket.SomeonesCharacterName))
                    {
                        ClientSession targetSession = Sessions.SingleOrDefault(s => s.Character.CharacterId == sentPacket.SomeonesCharacterId || s.Character.Name == sentPacket.SomeonesCharacterName);
                        if (targetSession?.HasSelectedCharacter == true)
                        {
                            if (sentPacket.Sender != null)
                            {
                                if (!sentPacket.Sender.Character.IsBlockedByCharacter(targetSession.Character.CharacterId))
                                {
                                    targetSession.SendPacket(sentPacket.Packet);
                                }
                                else
                                {
                                    sentPacket.Sender.SendPacket(UserInterfaceHelper.GenerateInfo(Language.Instance.GetMessageFromKey("BLACKLIST_BLOCKED")));
                                }
                            }
                            else
                            {
                                targetSession.SendPacket(sentPacket.Packet);
                            }
                        }
                    }
                    break;

                case ReceiverType.AllNoEmoBlocked:
                    Parallel.ForEach(Sessions.Where(s => s?.Character.EmoticonsBlocked == false), session =>
                    {
                        if (session?.HasSelectedCharacter == true && sentPacket.Sender?.Character.IsBlockedByCharacter(session.Character.CharacterId) == false)
                        {
                            session.SendPacket(sentPacket.Packet);
                        }
                    });
                    break;

                case ReceiverType.AllNoHeroBlocked:
                    Parallel.ForEach(Sessions.Where(s => s?.Character.HeroChatBlocked == false), session =>
                    {
                        if (session?.HasSelectedCharacter == true && sentPacket.Sender?.Character.IsBlockedByCharacter(session.Character.CharacterId) == false)
                        {
                            session.SendPacket(sentPacket.Packet);
                        }
                    });
                    break;

                case ReceiverType.Group:
                    foreach (ClientSession session in Sessions.Where(s => s.Character?.Group != null && sentPacket.Sender?.Character?.Group != null && s.Character.Group.GroupId == sentPacket.Sender.Character.Group.GroupId))
                    {
                        session.SendPacket(sentPacket.Packet);
                    }
                    break;

                case ReceiverType.Unknown:
                    break;

                case ReceiverType.OnlyGmAndAbove:
                    foreach (ClientSession session in Sessions.Where(s => s.Character.Authority >= AuthorityType.GameMaster))
                    {
                        session.SendPacket(sentPacket.Packet);
                    }
                    break;
                }
            }
        }
예제 #22
0
        public override void Use(ClientSession session, ref ItemInstance inv, byte Option = 0, string[] packetsplit = null)
        {
            /*if (session.Character.IsVehicled)
             * {
             *  session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("CANT_DO_VEHICLED"), 10));
             *  return;
             * }*/

            if (session.CurrentMapInstance?.MapInstanceType != MapInstanceType.TalentArenaMapInstance && VNum == 2802)
            {
                return;
            }
            if (session.CurrentMapInstance.MapInstanceType == MapInstanceType.TalentArenaMapInstance && VNum != 2802)
            {
                return;
            }

            Item item = inv.Item;

            switch (Effect)
            {
            default:
                if (session.Character.Hp <= 0)
                {
                    return;
                }
                if (item.BCards.Find(s => s.Type == 25) is BCard Buff)
                {
                    if (ServerManager.RandomNumber() < Buff.FirstData)
                    {
                        session.Character.AddBuff(new Buff((short)Buff.SecondData, session.Character.Level), session.Character.BattleEntity);
                    }
                    session.Character.Inventory.RemoveItemFromInventory(inv.Id);
                }
                else
                {
                    if (session.Character.SnackAmount < 0)
                    {
                        session.Character.SnackAmount = 0;
                    }
                    int amount = session.Character.SnackAmount;
                    if (amount < 5)
                    {
                        Thread workerThread = new Thread(() => Regenerate(session, item));
                        workerThread.Start();
                        session.Character.Inventory.RemoveItemFromInventory(inv.Id);
                    }
                    else
                    {
                        session.SendPacket(session.Character.Gender == GenderType.Female
                                ? session.Character.GenerateSay(Language.Instance.GetMessageFromKey("NOT_HUNGRY_FEMALE"), 1)
                                : session.Character.GenerateSay(Language.Instance.GetMessageFromKey("NOT_HUNGRY_MALE"), 1));
                    }
                    if (amount == 0)
                    {
                        Thread workerThread2 = new Thread(() => Sync(session));
                        workerThread2.Start();
                    }
                }
                break;
            }
        }
예제 #23
0
        public override void Use(ClientSession session, ref ItemInstance inv, bool delay = false, string[] packetsplit = null)
        {
            switch (Effect)
            {
            // airwaves - eventitems
            case 0:
                if (ItemType == ItemType.Event)
                {
                    session.CurrentMapInstance?.Broadcast(session.Character.GenerateEff(EffectValue));
                    if (MappingHelper.GuriItemEffects.ContainsKey(EffectValue))
                    {
                        session.CurrentMapInstance?.Broadcast(session.Character.GenerateGuri(19, 1, MappingHelper.GuriItemEffects[EffectValue]), session.Character.MapX, session.Character.MapY);
                    }
                    session.Character.Inventory.RemoveItemAmountFromInventory(1, inv.Id);
                }
                break;

            //respawn objects
            case 1:
                if (session.Character.MapInstance.MapInstanceType != MapInstanceType.BaseInstance)
                {
                    session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("CANT_USE_THAT"), 10));
                    return;
                }
                int x1;
                int x2;
                int x3;
                int x4;
                if (packetsplit != null && int.TryParse(packetsplit[2], out x1) && int.TryParse(packetsplit[3], out x2) && int.TryParse(packetsplit[4], out x3) && int.TryParse(packetsplit[5], out x4))
                {
                    int x5;
                    switch (EffectValue)
                    {
                    case 0:
                        if (!delay)
                        {
                            session.SendPacket(session.Character.GenerateDialog($"#u_i^{x1}^{x2}^{x3}^{x4}^1 #u_i^{x1}^{x2}^{x3}^{x4}^2 {Language.Instance.GetMessageFromKey("WANT_TO_SAVE_POSITION")}"));
                        }
                        else
                        {
                            if (int.TryParse(packetsplit[6], out x5))
                            {
                                switch (x5)
                                {
                                case 1:
                                    session.SendPacket(session.Character.GenerateDelay(5000, 7, $"#u_i^{x1}^{x2}^{x3}^{x4}^3"));
                                    break;

                                case 2:
                                    session.SendPacket(session.Character.GenerateDelay(5000, 7, $"#u_i^{x1}^{x2}^{x3}^{x4}^4"));
                                    break;

                                case 3:
                                    session.Character.SetReturnPoint(session.Character.MapId, session.Character.MapX, session.Character.MapY);
                                    RespawnMapTypeDTO resp = session.Character.Respawn;
                                    if (resp.DefaultX != 0 && resp.DefaultY != 0 && resp.DefaultMapId != 0)
                                    {
                                        ServerManager.Instance.LeaveMap(session.Character.CharacterId);
                                        ServerManager.Instance.ChangeMap(session.Character.CharacterId, resp.DefaultMapId, (short)(resp.DefaultX + ServerManager.RandomNumber(-5, 5)), (short)(resp.DefaultY + ServerManager.RandomNumber(-5, 5)));
                                    }
                                    session.Character.Inventory.RemoveItemAmountFromInventory(1, inv.Id);
                                    break;

                                case 4:
                                    RespawnMapTypeDTO respa = session.Character.Respawn;
                                    if (respa.DefaultX != 0 && respa.DefaultY != 0 && respa.DefaultMapId != 0)
                                    {
                                        ServerManager.Instance.LeaveMap(session.Character.CharacterId);
                                        ServerManager.Instance.ChangeMap(session.Character.CharacterId, respa.DefaultMapId, (short)(respa.DefaultX + ServerManager.RandomNumber(-5, 5)), (short)(respa.DefaultY + ServerManager.RandomNumber(-5, 5)));
                                    }
                                    session.Character.Inventory.RemoveItemAmountFromInventory(1, inv.Id);
                                    break;
                                }
                            }
                        }
                        break;

                    case 1:
                        if (int.TryParse(packetsplit[6], out x5))
                        {
                            RespawnMapTypeDTO resp = session.Character.Return;
                            switch (x5)
                            {
                            case 0:
                                if (resp.DefaultX != 0 && resp.DefaultY != 0 && resp.DefaultMapId != 0)
                                {
                                    session.SendPacket(session.Character.GenerateRp(resp.DefaultMapId, resp.DefaultX, resp.DefaultY, $"#u_i^{x1}^{x2}^{x3}^{x4}^1"));
                                }
                                break;

                            case 1:
                                session.SendPacket(session.Character.GenerateDelay(5000, 7, $"#u_i^{x1}^{x2}^{x3}^{x4}^2"));
                                break;

                            case 2:
                                if (resp.DefaultX != 0 && resp.DefaultY != 0 && resp.DefaultMapId != 0)
                                {
                                    ServerManager.Instance.LeaveMap(session.Character.CharacterId);
                                    ServerManager.Instance.ChangeMap(session.Character.CharacterId, resp.DefaultMapId, resp.DefaultX, resp.DefaultY);
                                }
                                session.Character.Inventory.RemoveItemAmountFromInventory(1, inv.Id);
                                break;
                            }
                        }
                        break;

                    case 2:
                        if (!delay)
                        {
                            session.SendPacket(session.Character.GenerateDelay(5000, 7, $"#u_i^{x1}^{x2}^{x3}^{x4}^1"));
                        }
                        else
                        {
                            ServerManager.Instance.LeaveMap(session.Character.CharacterId);
                            ServerManager.Instance.ChangeMapInstance(session.Character.CharacterId, session.Character.MinilandId, 3, 8);
                            session.Character.Inventory.RemoveItemAmountFromInventory(1, inv.Id);
                        }
                        break;
                    }
                }
                break;

            // dyes or waxes
            case 10:
            case 11:
                if (!session.Character.IsVehicled)
                {
                    if (Effect == 10)
                    {
                        if (EffectValue == 99)
                        {
                            byte nextValue = (byte)ServerManager.RandomNumber(0, 127);
                            session.Character.HairColor = Enum.IsDefined(typeof(HairColorType), nextValue) ? (HairColorType)nextValue : 0;
                        }
                        else
                        {
                            session.Character.HairColor = Enum.IsDefined(typeof(HairColorType), (byte)EffectValue) ? (HairColorType)EffectValue : 0;
                        }
                    }
                    else
                    {
                        if (session.Character.Class == (byte)ClassType.Adventurer && EffectValue > 1)
                        {
                            session.SendPacket(session.Character.GenerateMsg(Language.Instance.GetMessageFromKey("ADVENTURERS_CANT_USE"), 10));
                            return;
                        }
                        session.Character.HairStyle = Enum.IsDefined(typeof(HairStyleType), (byte)EffectValue) ? (HairStyleType)EffectValue : 0;
                    }
                    session.SendPacket(session.Character.GenerateEq());
                    session.CurrentMapInstance?.Broadcast(session, session.Character.GenerateIn());
                    session.CurrentMapInstance?.Broadcast(session, session.Character.GenerateGidx());
                    session.Character.Inventory.RemoveItemAmountFromInventory(1, inv.Id);
                }
                break;

            // dignity restoration
            case 14:
                if ((EffectValue == 100 || EffectValue == 200) && session.Character.Dignity < 100 && !session.Character.IsVehicled)
                {
                    session.Character.Dignity += EffectValue;
                    if (session.Character.Dignity > 100)
                    {
                        session.Character.Dignity = 100;
                    }
                    session.SendPacket(session.Character.GenerateFd());
                    session.SendPacket(session.Character.GenerateEff(49 - session.Character.Faction));
                    session.CurrentMapInstance?.Broadcast(session, session.Character.GenerateIn(), ReceiverType.AllExceptMe);
                    session.CurrentMapInstance?.Broadcast(session, session.Character.GenerateGidx(), ReceiverType.AllExceptMe);
                    session.Character.Inventory.RemoveItemAmountFromInventory(1, inv.Id);
                }
                else if (EffectValue == 2000 && session.Character.Dignity < 100 && !session.Character.IsVehicled)
                {
                    session.Character.Dignity = 100;
                    session.SendPacket(session.Character.GenerateFd());
                    session.SendPacket(session.Character.GenerateEff(49 - session.Character.Faction));
                    session.CurrentMapInstance?.Broadcast(session, session.Character.GenerateIn(), ReceiverType.AllExceptMe);
                    session.CurrentMapInstance?.Broadcast(session, session.Character.GenerateGidx(), ReceiverType.AllExceptMe);
                    session.Character.Inventory.RemoveItemAmountFromInventory(1, inv.Id);
                }
                break;

            // speakers
            case 15:
                if (!session.Character.IsVehicled)
                {
                    if (!delay)
                    {
                        session.SendPacket(session.Character.GenerateGuri(10, 3, 1));
                    }
                }
                break;

            // bubbles
            case 16:
                if (!session.Character.IsVehicled)
                {
                    if (!delay)
                    {
                        session.SendPacket(session.Character.GenerateGuri(10, 4, 1));
                    }
                }
                break;

            // wigs
            case 30:
                if (!session.Character.IsVehicled)
                {
                    WearableInstance wig = session.Character.Inventory.LoadBySlotAndType <WearableInstance>((byte)EquipmentType.Hat, InventoryType.Wear);
                    if (wig != null)
                    {
                        wig.Design = (byte)ServerManager.RandomNumber(0, 15);
                        session.SendPacket(session.Character.GenerateEq());
                        session.SendPacket(session.Character.GenerateEquipment());
                        session.CurrentMapInstance?.Broadcast(session, session.Character.GenerateIn());
                        session.CurrentMapInstance?.Broadcast(session, session.Character.GenerateGidx());
                        session.Character.Inventory.RemoveItemAmountFromInventory(1, inv.Id);
                    }
                    else
                    {
                        session.SendPacket(session.Character.GenerateMsg(Language.Instance.GetMessageFromKey("NO_WIG"), 0));
                    }
                }
                break;

            default:
                Logger.Log.Warn(string.Format(Language.Instance.GetMessageFromKey("NO_HANDLER_ITEM"), GetType()));
                break;
            }
        }
예제 #24
0
파일: Map.cs 프로젝트: Ziratoxdu36/OpenNos
        private void CharacterLifeManager()
        {
            try
            {
                List <Task> NpcLifeTask = new List <Task>();
                for (int i = Sessions.Where(s => s.HasSelectedCharacter).Count() - 1; i >= 0; i--)
                {
                    ClientSession Session = Sessions.Where(s => s?.Character != null).ElementAt(i);
                    if (Session.Character.LastMailRefresh.AddSeconds(30) < DateTime.Now)
                    {
                        Session.Character.RefreshMail();
                    }
                    int  x      = 1;
                    bool change = false;
                    if (Session.Character.Hp == 0 && Session.Character.LastHealth.AddSeconds(2) <= DateTime.Now)
                    {
                        Session.Character.Mp = 0;
                        Session.SendPacket(Session.Character.GenerateStat());
                        Session.Character.LastHealth = DateTime.Now;
                    }
                    else
                    {
                        WearableInstance amulet = Session.Character.Inventory.LoadBySlotAndType <WearableInstance>((byte)EquipmentType.Amulet, InventoryType.Wear);
                        if (Session.Character.LastEffect.AddSeconds(5) <= DateTime.Now && amulet != null)
                        {
                            if (amulet.ItemVNum == 4503 || amulet.ItemVNum == 4504)
                            {
                                Session.CurrentMap?.Broadcast(Session.Character.GenerateEff(amulet.Item.EffectValue + (Session.Character.Class == (byte)ClassType.Adventurer ? 0 : Session.Character.Class - 1)), Session.Character.MapX, Session.Character.MapY);
                            }
                            else
                            {
                                Session.CurrentMap?.Broadcast(Session.Character.GenerateEff(amulet.Item.EffectValue), Session.Character.MapX, Session.Character.MapY);
                            }
                            Session.Character.LastEffect = DateTime.Now;
                        }

                        if ((Session.Character.LastHealth.AddSeconds(2) <= DateTime.Now) || (Session.Character.IsSitting && Session.Character.LastHealth.AddSeconds(1.5) <= DateTime.Now))
                        {
                            Session.Character.LastHealth = DateTime.Now;
                            if (Session.HealthStop)
                            {
                                Session.HealthStop = false;
                                return;
                            }

                            if (Session.Character.LastDefence.AddSeconds(2) <= DateTime.Now && Session.Character.LastSkill.AddSeconds(2) <= DateTime.Now && Session.Character.Hp > 0)
                            {
                                if (x == 0)
                                {
                                    x = 1;
                                }
                                if (Session.Character.Hp + Session.Character.HealthHPLoad() < Session.Character.HPLoad())
                                {
                                    change = true;
                                    Session.Character.Hp += Session.Character.HealthHPLoad();
                                }
                                else
                                {
                                    if (Session.Character.Hp != (int)Session.Character.HPLoad())
                                    {
                                        change = true;
                                    }
                                    Session.Character.Hp = (int)Session.Character.HPLoad();
                                }
                                if (x == 1)
                                {
                                    if (Session.Character.Mp + Session.Character.HealthMPLoad() < Session.Character.MPLoad())
                                    {
                                        Session.Character.Mp += Session.Character.HealthMPLoad();
                                        change = true;
                                    }
                                    else
                                    {
                                        if (Session.Character.Mp != (int)Session.Character.MPLoad())
                                        {
                                            change = true;
                                        }
                                        Session.Character.Mp = (int)Session.Character.MPLoad();
                                    }
                                    x = 0;
                                }
                                if (change)
                                {
                                    Session.SendPacket(Session.Character.GenerateStat());
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Logger.Error(e);
            }
        }
예제 #25
0
        public override void Use(ClientSession Session, ref ItemInstance Inv, bool DelayUsed = false, string[] packetsplit = null)
        {
            Random random = new Random();

            switch (Effect)
            {
            // airwaves - eventitems
            case 0:
                if (this != null && this.ItemType == Domain.ItemType.Event)
                {
                    Session.CurrentMap?.Broadcast(Session.Character.GenerateEff(EffectValue));
                    if (MappingHelper.GuriItemEffects.ContainsKey(EffectValue))
                    {
                        Session.CurrentMap?.Broadcast(Session.Character.GenerateGuri(19, 1, MappingHelper.GuriItemEffects[EffectValue]), Session.Character.MapX, Session.Character.MapY);
                    }

                    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));
                    }
                }
                break;

            // dyes
            case 10:
                if (this != null && !Session.Character.IsVehicled)
                {
                    if (EffectValue == 99)
                    {
                        byte nextValue = (byte)random.Next(0, 127);
                        Session.Character.HairColor = Enum.IsDefined(typeof(HairColorType), (byte)nextValue) ? (HairColorType)nextValue : 0;
                    }
                    else
                    {
                        Session.Character.HairColor = Enum.IsDefined(typeof(HairColorType), (byte)EffectValue) ? (HairColorType)EffectValue : 0;
                    }
                    Session.SendPacket(Session.Character.GenerateEq());
                    Session.CurrentMap?.Broadcast(Session, Session.Character.GenerateIn(), ReceiverType.All);
                    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));
                    }
                }
                break;

            // waxes
            case 11:
                if (this != null && !Session.Character.IsVehicled)
                {
                    if (Session.Character.Class == (byte)ClassType.Adventurer && EffectValue > 1)
                    {
                        Session.SendPacket(Session.Character.GenerateMsg(Language.Instance.GetMessageFromKey("ADVENTURERS_CANT_USE"), 10));
                    }
                    else
                    {
                        // TODO better handling of waxes combined with hairstyle
                        Session.Character.HairStyle = Enum.IsDefined(typeof(HairStyleType), (byte)EffectValue) ? (HairStyleType)EffectValue : 0;
                        Session.SendPacket(Session.Character.GenerateEq());
                        Session.CurrentMap?.Broadcast(Session, Session.Character.GenerateIn(), ReceiverType.All);
                        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));
                        }
                    }
                }
                break;

            // dignity restoration
            case 14:
                if ((EffectValue == 100 || EffectValue == 200) && Session.Character.Dignity < 100 && !Session.Character.IsVehicled)
                {
                    Session.Character.Dignity += EffectValue;
                    if (Session.Character.Dignity > 100)
                    {
                        Session.Character.Dignity = 100;
                    }
                    Session.SendPacket(Session.Character.GenerateFd());
                    Session.SendPacket(Session.Character.GenerateEff(48));
                    Session.CurrentMap?.Broadcast(Session, Session.Character.GenerateIn(), ReceiverType.AllExceptMe);
                    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 if (EffectValue == 2000 && Session.Character.Dignity < 100 && !Session.Character.IsVehicled)
                {
                    Session.Character.Dignity = 100;
                    Session.SendPacket(Session.Character.GenerateFd());
                    Session.SendPacket(Session.Character.GenerateEff(48));
                    Session.CurrentMap?.Broadcast(Session, Session.Character.GenerateIn(), ReceiverType.AllExceptMe);
                    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));
                    }
                }
                break;

            // speakers
            case 15:
                if (this != null && !Session.Character.IsVehicled)
                {
                    if (!DelayUsed)
                    {
                        Session.SendPacket(Session.Character.GenerateGuri(10, 3, 1));
                    }
                }
                break;

            // bubbles
            case 16:
                if (this != null && !Session.Character.IsVehicled)
                {
                    if (!DelayUsed)
                    {
                        Session.SendPacket(Session.Character.GenerateGuri(10, 4, 1));
                    }
                }
                break;

            // wigs
            case 30:
                if (this != null && !Session.Character.IsVehicled)
                {
                    WearableInstance wig = Session.Character.Inventory.LoadBySlotAndType <WearableInstance>((byte)EquipmentType.Hat, InventoryType.Wear);
                    if (wig != null)
                    {
                        wig.Design = (byte)random.Next(0, 15);
                        Session.SendPacket(Session.Character.GenerateEq());
                        Session.SendPacket(Session.Character.GenerateEquipment());
                        Session.CurrentMap?.Broadcast(Session, Session.Character.GenerateIn(), ReceiverType.All);
                        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(Session.Character.GenerateMsg(Language.Instance.GetMessageFromKey("NO_WIG"), 0));
                        return;
                    }
                }
                break;

            default:
                Logger.Log.Warn(String.Format(Language.Instance.GetMessageFromKey("NO_HANDLER_ITEM"), this.GetType().ToString()));
                break;
            }
        }
예제 #26
0
        public override void Use(ClientSession session, ref ItemInstance inv, byte Option = 0, string[] packetsplit = null)
        {
            try
            {
                switch (Effect)
                {
                case 0:
                    if (Option == 0)
                    {
                        if (packetsplit.Length == 9)
                        {
                            ItemInstance box = session.Character.Inventory.LoadBySlotAndType <ItemInstance>(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
                        ItemInstance box = session.Character.Inventory.LoadBySlotAndType <ItemInstance>(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.RandomNumber(0, probabilities);
                                int currentrnd    = 0;
                                foreach (RollGeneratedItemDTO rollitem in roll)
                                {
                                    currentrnd += rollitem.Probability;
                                    if (currentrnd >= rnd)
                                    {
                                        Item  i       = ServerManager.GetItem(rollitem.ItemGeneratedVNum);
                                        sbyte rare    = 0;
                                        byte  upgrade = 0;
                                        if (i.ItemType == ItemType.Armor || i.ItemType == ItemType.Weapon || i.ItemType == ItemType.Shell)
                                        {
                                            rare = box.Rare;
                                        }
                                        if (i.ItemType == ItemType.Shell)
                                        {
                                            upgrade = (byte)ServerManager.RandomNumber(50, 81);
                                        }
                                        session.Character.GiftAdd(rollitem.ItemGeneratedVNum, rollitem.ItemGeneratedAmount, (byte)rare, upgrade);
                                        session.SendPacket($"rdi {rollitem.ItemGeneratedVNum} {rollitem.ItemGeneratedAmount}");
                                        session.Character.Inventory.RemoveItemFromInventory(box.Id);
                                        return;

                                        //newInv = session.Character.Inventory.AddNewToInventory(rollitem.ItemGeneratedVNum, amount: rollitem.ItemGeneratedAmount, Design: design, Rare: rare);
                                        //if (newInv.Count > 0)
                                        //{
                                        //    short Slot = inv.Slot;
                                        //    if (Slot != -1)
                                        //    {
                                        //        session.SendPacket(session.Character.GenerateSay(
                                        //            $"{Language.Instance.GetMessageFromKey("ITEM_ACQUIRED")}: {newInv.FirstOrDefault(s => s != null)?.Item?.Name} x {rollitem.ItemGeneratedAmount}",
                                        //            12));
                                        //        newInv.Where(s => s != null).ToList()
                                        //            .ForEach(s => session.SendPacket(s.GenerateInventoryAdd()));
                                        //        session.Character.Inventory
                                        //            .RemoveItemAmountFromInventory(box.Id);
                                        //    }
                                        //}
                                    }
                                }
                            }
                            else if (box.HoldingVNum == 0)
                            {
                                if (packetsplit.Length == 1 && int.TryParse(packetsplit[0], out int PetId) && session.Character.Mates.Find(s => s.MateTransportId == PetId) is Mate mate)
                                {
                                    box.HoldingVNum = mate.NpcMonsterVNum;
                                    box.SpLevel     = mate.Level;
                                    box.SpDamage    = mate.Attack;
                                    box.SpDefence   = mate.Defence;
                                    session.Character.Mates.Remove(mate);
                                    session.SendPacket(UserInterfaceHelper.GenerateInfo(Language.Instance.GetMessageFromKey("PET_STORED")));
                                    session.SendPacket(UserInterfaceHelper.GeneratePClear());
                                    session.SendPackets(session.Character.GenerateScP());
                                    session.SendPackets(session.Character.GenerateScN());
                                    session.CurrentMapInstance?.Broadcast(mate.GenerateOut());
                                }
                            }
                            else
                            {
                                NpcMonster heldMonster = ServerManager.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.RemoveItemFromInventory(inv.Id);
                                        session.SendPacket(UserInterfaceHelper.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.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.RemoveItemFromInventory(inv.Id);
                                session.SendPacket(UserInterfaceHelper.GenerateInfo(Language.Instance.GetMessageFromKey("PET_LEAVE_BEAD")));
                            }
                        }
                        else
                        {
                            session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("NOT_IN_MINILAND"), 12));
                        }
                    }

                    break;

                case 69:
                    if (EffectValue == 1 || EffectValue == 2)
                    {
                        ItemInstance box = session.Character.Inventory.LoadBySlotAndType <ItemInstance>(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.Count > 0)
                                {
                                    ItemInstance itemInstance = newInv[0];
                                    ItemInstance specialist   = session.Character.Inventory.LoadBySlotAndType <ItemInstance>(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.EquipmentSerialId = box.EquipmentSerialId;
                                        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.RemoveItemFromInventory(box.Id);
                                    }
                                }
                                else
                                {
                                    session.SendPacket(UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("NOT_ENOUGH_PLACE"), 0));
                                }
                            }
                        }
                    }
                    if (EffectValue == 3)
                    {
                        ItemInstance box = session.Character.Inventory.LoadBySlotAndType <ItemInstance>(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.Count > 0)
                                {
                                    ItemInstance itemInstance = newInv[0];
                                    ItemInstance fairy        = session.Character.Inventory.LoadBySlotAndType <ItemInstance>(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.RemoveItemFromInventory(box.Id);
                                    }
                                }
                                else
                                {
                                    session.SendPacket(UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("NOT_ENOUGH_PLACE"), 0));
                                }
                            }
                        }
                    }
                    if (EffectValue == 4)
                    {
                        ItemInstance box = session.Character.Inventory.LoadBySlotAndType <ItemInstance>(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.Count > 0)
                                {
                                    short Slot = inv.Slot;
                                    if (Slot != -1)
                                    {
                                        session.SendPacket(session.Character.GenerateSay($"{Language.Instance.GetMessageFromKey("ITEM_ACQUIRED")}: {newInv[0].Item.Name} x 1)", 12));
                                        newInv.ForEach(s => session.SendPacket(s.GenerateInventoryAdd()));
                                        session.Character.Inventory.RemoveItemFromInventory(box.Id);
                                    }
                                }
                                else
                                {
                                    session.SendPacket(UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("NOT_ENOUGH_PLACE"), 0));
                                }
                            }
                        }
                    }
                    break;

                default:
                    Logger.Warn(string.Format(Language.Instance.GetMessageFromKey("NO_HANDLER_ITEM"), GetType(), VNum, Effect, EffectValue));
                    break;
                }
            }
            catch
            {
            }
        }
예제 #27
0
        public void PerfectSP(ClientSession Session)
        {
            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 (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 (SpStoneUpgrade > 99)
            {
                return;
            }
            if (SpStoneUpgrade > 80)
            {
                upmode = 5;
            }
            else if (SpStoneUpgrade > 60)
            {
                upmode = 4;
            }
            else if (SpStoneUpgrade > 40)
            {
                upmode = 3;
            }
            else if (SpStoneUpgrade > 20)
            {
                upmode = 2;
            }

            if (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>(Id);

            int rnd = ServerManager.Instance.RandomNumber();

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

                Session.CurrentMapInstance.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(UserInterfaceHelper.Instance.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(UserInterfaceHelper.Instance.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(UserInterfaceHelper.Instance.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(UserInterfaceHelper.Instance.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(UserInterfaceHelper.Instance.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(UserInterfaceHelper.Instance.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(UserInterfaceHelper.Instance.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(UserInterfaceHelper.Instance.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(UserInterfaceHelper.Instance.GenerateMsg(Language.Instance.GetMessageFromKey("PERFECTSP_FAILURE"), 0));
            }
            Session.SendPacket(specialist.GenerateInventoryAdd());
            Session.Character.Gold -= goldprice[upmode - 1];
            Session.SendPacket(Session.Character.GenerateGold());
            Session.Character.Inventory.RemoveItemAmount(stonevnum, stoneprice[upmode - 1]);
            Session.SendPacket("shop_end 1");
        }
        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;
            }
        }
예제 #29
0
        public void UpgradeSp(ClientSession Session, UpgradeProtection protect)
        {
            if (Upgrade >= 15)
            {
                return;
            }

            short[] upfail  = { 20, 25, 30, 40, 50, 60, 65, 70, 75, 80, 90, 93, 95, 97, 99 };
            short[] destroy = { 0, 0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 70 };

            int[]       goldprice       = { 200000, 200000, 200000, 200000, 200000, 500000, 500000, 500000, 500000, 500000, 1000000, 1000000, 1000000, 1000000, 1000000 };
            short[]     feather         = { 3, 5, 8, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 70 };
            short[]     fullmoon        = { 1, 3, 5, 7, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30 };
            short[]     soul            = { 2, 4, 6, 8, 10, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5 };
            const short featherVnum     = 2282;
            const short fullmoonVnum    = 1030;
            const short greenSoulVnum   = 2283;
            const short redSoulVnum     = 2284;
            const short blueSoulVnum    = 2285;
            const short dragonSkinVnum  = 2511;
            const short dragonBloodVnum = 2512;
            const short dragonHeartVnum = 2513;
            const short blueScrollVnum  = 1363;
            const short redScrollVnum   = 1364;

            if (!Session.HasCurrentMapInstance)
            {
                return;
            }
            if (Session.Character.Inventory.CountItem(fullmoonVnum) < fullmoon[Upgrade])
            {
                Session.SendPacket(Session.Character.GenerateSay(Language.Instance.GetMessageFromKey(string.Format(Language.Instance.GetMessageFromKey("NOT_ENOUGH_ITEMS"), ServerManager.Instance.GetItem(fullmoonVnum).Name, fullmoon[Upgrade])), 10));
                return;
            }
            if (Session.Character.Inventory.CountItem(featherVnum) < feather[Upgrade])
            {
                Session.SendPacket(Session.Character.GenerateSay(Language.Instance.GetMessageFromKey(string.Format(Language.Instance.GetMessageFromKey("NOT_ENOUGH_ITEMS"), ServerManager.Instance.GetItem(featherVnum).Name, feather[Upgrade])), 10));
                return;
            }
            if (Session.Character.Gold < goldprice[Upgrade])
            {
                Session.SendPacket(Session.Character.GenerateSay(Language.Instance.GetMessageFromKey("NOT_ENOUGH_MONEY"), 10));
                return;
            }

            if (Upgrade < 5)
            {
                if (SpLevel > 20)
                {
                    if (Item.Morph <= 16)
                    {
                        if (Session.Character.Inventory.CountItem(greenSoulVnum) < soul[Upgrade])
                        {
                            Session.SendPacket(Session.Character.GenerateSay(Language.Instance.GetMessageFromKey(string.Format(Language.Instance.GetMessageFromKey("NOT_ENOUGH_ITEMS"), ServerManager.Instance.GetItem(greenSoulVnum).Name, soul[Upgrade])), 10));
                            return;
                        }
                        if (protect == UpgradeProtection.Protected)
                        {
                            if (Session.Character.Inventory.CountItem(blueScrollVnum) < 1)
                            {
                                Session.SendPacket(Session.Character.GenerateSay(Language.Instance.GetMessageFromKey(string.Format(Language.Instance.GetMessageFromKey("NOT_ENOUGH_ITEMS"), ServerManager.Instance.GetItem(blueScrollVnum).Name, 1)), 10));
                                return;
                            }
                            Session.Character.Inventory.RemoveItemAmount(blueScrollVnum);
                            Session.SendPacket("shop_end 2");
                        }
                        Session.Character.Inventory.RemoveItemAmount(greenSoulVnum, soul[Upgrade]);
                    }
                    else
                    {
                        if (Session.Character.Inventory.CountItem(dragonSkinVnum) < soul[Upgrade])
                        {
                            Session.SendPacket(Session.Character.GenerateSay(Language.Instance.GetMessageFromKey(string.Format(Language.Instance.GetMessageFromKey("NOT_ENOUGH_ITEMS"), ServerManager.Instance.GetItem(dragonSkinVnum).Name, soul[Upgrade])), 10));
                            return;
                        }
                        if (protect == UpgradeProtection.Protected)
                        {
                            if (Session.Character.Inventory.CountItem(blueScrollVnum) < 1)
                            {
                                Session.SendPacket(Session.Character.GenerateSay(Language.Instance.GetMessageFromKey(string.Format(Language.Instance.GetMessageFromKey("NOT_ENOUGH_ITEMS"), ServerManager.Instance.GetItem(blueScrollVnum).Name, 1)), 10));
                                return;
                            }
                            Session.Character.Inventory.RemoveItemAmount(blueScrollVnum);
                            Session.SendPacket("shop_end 2");
                        }
                        Session.Character.Inventory.RemoveItemAmount(dragonSkinVnum, soul[Upgrade]);
                    }
                }
                else
                {
                    Session.SendPacket(Session.Character.GenerateSay(string.Format(Language.Instance.GetMessageFromKey("LVL_REQUIRED"), 21), 11));
                    return;
                }
            }
            else if (Upgrade < 10)
            {
                if (SpLevel > 40)
                {
                    if (Item.Morph <= 16)
                    {
                        if (Session.Character.Inventory.CountItem(redSoulVnum) < soul[Upgrade])
                        {
                            Session.SendPacket(Session.Character.GenerateSay(Language.Instance.GetMessageFromKey(string.Format(Language.Instance.GetMessageFromKey("NOT_ENOUGH_ITEMS"), ServerManager.Instance.GetItem(redSoulVnum).Name, soul[Upgrade])), 10));
                            return;
                        }
                        if (protect == UpgradeProtection.Protected)
                        {
                            if (Session.Character.Inventory.CountItem(blueScrollVnum) < 1)
                            {
                                Session.SendPacket(Session.Character.GenerateSay(Language.Instance.GetMessageFromKey(string.Format(Language.Instance.GetMessageFromKey("NOT_ENOUGH_ITEMS"), ServerManager.Instance.GetItem(blueScrollVnum).Name, 1)), 10));
                                return;
                            }
                            Session.Character.Inventory.RemoveItemAmount(blueScrollVnum);
                            Session.SendPacket("shop_end 2");
                        }
                        Session.Character.Inventory.RemoveItemAmount(redSoulVnum, soul[Upgrade]);
                    }
                    else
                    {
                        if (Session.Character.Inventory.CountItem(dragonBloodVnum) < soul[Upgrade])
                        {
                            Session.SendPacket(Session.Character.GenerateSay(Language.Instance.GetMessageFromKey(string.Format(Language.Instance.GetMessageFromKey("NOT_ENOUGH_ITEMS"), ServerManager.Instance.GetItem(dragonBloodVnum).Name, soul[Upgrade])), 10));
                            return;
                        }
                        if (protect == UpgradeProtection.Protected)
                        {
                            if (Session.Character.Inventory.CountItem(blueScrollVnum) < 1)
                            {
                                Session.SendPacket(Session.Character.GenerateSay(Language.Instance.GetMessageFromKey(string.Format(Language.Instance.GetMessageFromKey("NOT_ENOUGH_ITEMS"), ServerManager.Instance.GetItem(blueScrollVnum).Name, 1)), 10));
                                return;
                            }
                            Session.Character.Inventory.RemoveItemAmount(blueScrollVnum);
                            Session.SendPacket("shop_end 2");
                        }
                        Session.Character.Inventory.RemoveItemAmount(dragonBloodVnum, soul[Upgrade]);
                    }
                }
                else
                {
                    Session.SendPacket(Session.Character.GenerateSay(string.Format(Language.Instance.GetMessageFromKey("LVL_REQUIRED"), 41), 11));
                    return;
                }
            }
            else if (Upgrade < 15)
            {
                if (SpLevel > 50)
                {
                    if (Item.Morph <= 16)
                    {
                        if (Session.Character.Inventory.CountItem(blueSoulVnum) < soul[Upgrade])
                        {
                            Session.SendPacket(Session.Character.GenerateSay(Language.Instance.GetMessageFromKey(string.Format(Language.Instance.GetMessageFromKey("NOT_ENOUGH_ITEMS"), ServerManager.Instance.GetItem(blueSoulVnum).Name, soul[Upgrade])), 10));
                            return;
                        }
                        if (protect == UpgradeProtection.Protected && Upgrade > 9)
                        {
                            if (Session.Character.Inventory.CountItem(redScrollVnum) < 1)
                            {
                                return;
                            }
                            Session.Character.Inventory.RemoveItemAmount(redScrollVnum);
                            Session.SendPacket("shop_end 2");
                        }
                        Session.Character.Inventory.RemoveItemAmount(blueSoulVnum, soul[Upgrade]);
                    }
                    else
                    {
                        if (Session.Character.Inventory.CountItem(dragonHeartVnum) < soul[Upgrade])
                        {
                            return;
                        }
                        if (protect == UpgradeProtection.Protected && Upgrade > 9)
                        {
                            if (Session.Character.Inventory.CountItem(redScrollVnum) < 1)
                            {
                                Session.SendPacket(Session.Character.GenerateSay(Language.Instance.GetMessageFromKey(string.Format(Language.Instance.GetMessageFromKey("NOT_ENOUGH_ITEMS"), ServerManager.Instance.GetItem(redScrollVnum).Name, 1)), 10));
                                return;
                            }
                            Session.Character.Inventory.RemoveItemAmount(redScrollVnum);
                            Session.SendPacket("shop_end 2");
                        }
                        Session.Character.Inventory.RemoveItemAmount(dragonHeartVnum, soul[Upgrade]);
                    }
                }
                else
                {
                    Session.SendPacket(Session.Character.GenerateSay(string.Format(Language.Instance.GetMessageFromKey("LVL_REQUIRED"), 51), 11));
                    return;
                }
            }

            Session.Character.Gold -= goldprice[Upgrade];

            // remove feather and fullmoon before upgrading
            Session.Character.Inventory.RemoveItemAmount(featherVnum, feather[Upgrade]);
            Session.Character.Inventory.RemoveItemAmount(fullmoonVnum, fullmoon[Upgrade]);

            WearableInstance wearable  = Session.Character.Inventory.LoadByItemInstance <WearableInstance>(Id);
            ItemInstance     inventory = Session.Character.Inventory.GetItemInstanceById(Id);
            int rnd = ServerManager.Instance.RandomNumber();

            if (rnd < destroy[Upgrade])
            {
                if (protect == UpgradeProtection.Protected)
                {
                    Session.CurrentMapInstance.Broadcast(Session.Character.GenerateEff(3004), Session.Character.MapX, Session.Character.MapY);
                    Session.SendPacket(Session.Character.GenerateSay(Language.Instance.GetMessageFromKey("UPGRADESP_FAILED_SAVED"), 11));
                    Session.SendPacket(UserInterfaceHelper.Instance.GenerateMsg(Language.Instance.GetMessageFromKey("UPGRADESP_FAILED_SAVED"), 0));
                }
                else
                {
                    wearable.Rare = -2;
                    Session.SendPacket(Session.Character.GenerateSay(Language.Instance.GetMessageFromKey("UPGRADESP_DESTROYED"), 11));
                    Session.SendPacket(UserInterfaceHelper.Instance.GenerateMsg(Language.Instance.GetMessageFromKey("UPGRADESP_DESTROYED"), 0));
                    Session.SendPacket(wearable.GenerateInventoryAdd());
                }
            }
            else if (rnd < upfail[Upgrade])
            {
                if (protect == UpgradeProtection.Protected)
                {
                    Session.CurrentMapInstance.Broadcast(Session.Character.GenerateEff(3004), Session.Character.MapX, Session.Character.MapY);
                }
                Session.SendPacket(Session.Character.GenerateSay(Language.Instance.GetMessageFromKey("UPGRADESP_FAILED"), 11));
                Session.SendPacket(UserInterfaceHelper.Instance.GenerateMsg(Language.Instance.GetMessageFromKey("UPGRADESP_FAILED"), 0));
            }
            else
            {
                if (protect == UpgradeProtection.Protected)
                {
                    Session.CurrentMapInstance.Broadcast(Session.Character.GenerateEff(3004), Session.Character.MapX, Session.Character.MapY);
                }
                Session.CurrentMapInstance.Broadcast(Session.Character.GenerateEff(3005), Session.Character.MapX, Session.Character.MapY);
                Session.SendPacket(Session.Character.GenerateSay(Language.Instance.GetMessageFromKey("UPGRADESP_SUCCESS"), 12));
                Session.SendPacket(UserInterfaceHelper.Instance.GenerateMsg(Language.Instance.GetMessageFromKey("UPGRADESP_SUCCESS"), 0));
                wearable.Upgrade++;
                Session.Character.Family?.InsertFamilyLog(FamilyLogType.ItemUpgraded, Session.Character.Name, itemVNum: wearable.ItemVNum, upgrade: wearable.Upgrade);
                Session.SendPacket(wearable.GenerateInventoryAdd());
            }
            Session.SendPacket(Session.Character.GenerateGold());
            Session.SendPacket(Session.Character.GenerateEq());
            Session.SendPacket("shop_end 1");
        }
예제 #30
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)
            {
            // Honour Medals
            case 69:
                session.Character.Reputation += ReputPrice;
                session.SendPacket(session.Character.GenerateFd());
                session.Character.Inventory.RemoveItemFromInventory(inv.Id);
                break;

            // SP Potions
            case 150:
            case 151:
                session.Character.SpAdditionPoint += EffectValue;
                if (session.Character.SpAdditionPoint > 1000000)
                {
                    session.Character.SpAdditionPoint = 1000000;
                }
                session.SendPacket(UserInterfaceHelper.GenerateMsg(string.Format(Language.Instance.GetMessageFromKey("SP_POINTSADDED"), EffectValue), 0));
                session.Character.Inventory.RemoveItemFromInventory(inv.Id);
                session.SendPacket(session.Character.GenerateSpPoint());
                break;

            // Specialist Medal
            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.GenerateMsg(string.Format(Language.Instance.GetMessageFromKey("SP_POINTSADDEDBOTH"), EffectValue, EffectValue * 3), 0));
                session.Character.Inventory.RemoveItemFromInventory(inv.Id);
                session.SendPacket(session.Character.GenerateSpPoint());
                break;

            // Raid Seals
            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.RemoveItemFromInventory(raidSeal.Id);

                ScriptedInstance raid = ServerManager.Instance.Raids.FirstOrDefault(s => s.RequiredItems?.Any(obj => obj?.VNum == raidSeal.ItemVNum) == true)?.Copy();
                if (raid != null)
                {
                    Group group = new Group()
                    {
                        GroupType = GroupType.BigTeam,
                        Raid      = raid
                    };
                    group.JoinGroup(session.Character.CharacterId);
                    ServerManager.Instance.AddGroup(group);
                    session.SendPacket(UserInterfaceHelper.GenerateMsg(string.Format(Language.Instance.GetMessageFromKey("RAID_LEADER"), session.Character.Name), 0));
                    session.SendPacket(session.Character.GenerateSay(string.Format(Language.Instance.GetMessageFromKey("RAID_LEADER"), 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 1169:
            {
                if (session?.Character != null)
                {
                    if (session.Character.Miniland == session.Character.MapInstance)
                    {
                        ServerManager.Instance.JoinMiniland(session, session);
                    }
                    else
                    {
                        ServerManager.Shout($"GRACIAS POR USAR SERVICIOS HEAT!");
                        ServerManager.Instance.ChangeMapInstance(session.Character.CharacterId, session.Character.MapInstanceId, session.Character.PositionX, session.Character.PositionY);
                        session.SendPacket(StaticPacketHelper.Cancel(2));
                        session.Character.Inventory.RemoveItemFromInventory(inv.Id);
                    }
                }
            }
            break;

            case 1574:
                if (EffectValue == 1574)
                {
                    int rnd = ServerManager.RandomNumber(0, 1);
                    if (rnd < 1)
                    {
                        short[] vnums =
                        {
                            //ID's of the Items, you will get
                            4129, 4130, 4131, 4132
                        };
                        //This Code counts the Items, you inserted
                        byte[] counts = { 1, 1, 1, 1 };
                        int    item   = ServerManager.RandomNumber(0, 4);
                        session.Character.GiftAdd(vnums[item], counts[item]);
                    }
                    //This Code, deltes the Item from the Inventory
                    session.Character.Inventory.RemoveItemFromInventory(inv.Id);
                    session.SendPacket("msg 5 Success! You recieved your Items.");
                }
                break;



            // Partner Suits/Skins
            case 305:
                Mate mate = session.Character.Mates.Find(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.RemoveItemFromInventory(inv.Id);
                }
                break;

            // Fairy Booster
            case 250:
                if (!session.Character.Buff.ContainsKey(131))
                {
                    session.Character.AddStaticBuff(new StaticBuffDTO()
                    {
                        CardId = 131
                    });
                    session.CurrentMapInstance?.Broadcast(session.Character.GeneratePairy());
                    session.SendPacket(UserInterfaceHelper.GenerateMsg(string.Format(Language.Instance.GetMessageFromKey("EFFECT_ACTIVATED"), inv.Item.Name), 0));
                    session.CurrentMapInstance?.Broadcast(StaticPacketHelper.GenerateEff(UserType.Player, session.Character.CharacterId, 3011), session.Character.MapX, session.Character.MapY);
                    session.Character.Inventory.RemoveItemFromInventory(inv.Id);
                }
                else
                {
                    session.SendPacket(UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("ITEM_IN_USE"), 0));
                }
                break;

            // Fairy booster 2
            case 253:
                if (!session.Character.Buff.ContainsKey(131))
                {
                    session.Character.AddStaticBuff(new StaticBuffDTO()
                    {
                        CardId = 131
                    });
                    session.CurrentMapInstance?.Broadcast(session.Character.GeneratePairy());
                    session.SendPacket(UserInterfaceHelper.GenerateMsg(string.Format(Language.Instance.GetMessageFromKey("EFFECT_ACTIVATED"), inv.Item.Name), 0));
                    session.CurrentMapInstance?.Broadcast(StaticPacketHelper.GenerateEff(UserType.Player, session.Character.CharacterId, 3011), session.Character.MapX, session.Character.MapY);
                    session.Character.Inventory.RemoveItemFromInventory(inv.Id);
                }
                else
                {
                    session.SendPacket(UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("ITEM_IN_USE"), 0));
                }
                break;

            // exp/job booster
            case 251:
                if (!session.Character.Buff.ContainsKey(121))
                {
                    session.Character.AddStaticBuff(new StaticBuffDTO()
                    {
                        CardId = 121
                    });
                    session.CurrentMapInstance?.Broadcast(session.Character.GeneratePairy());
                    session.SendPacket(UserInterfaceHelper.GenerateMsg(string.Format(Language.Instance.GetMessageFromKey("EFFECT_ACTIVATED"), inv.Item.Name), 0));
                    session.CurrentMapInstance?.Broadcast(StaticPacketHelper.GenerateEff(UserType.Player, session.Character.CharacterId, 3011), session.Character.MapX, session.Character.MapY);
                    session.Character.Inventory.RemoveItemFromInventory(inv.Id);
                }
                else
                {
                    session.SendPacket(UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("ITEM_IN_USE"), 0));
                }
                break;

            //sp job booster
            case 1362:
                if (!session.Character.Buff.ContainsKey(146))
                {
                    session.Character.AddStaticBuff(new StaticBuffDTO()
                    {
                        CardId = 146
                    });
                    session.CurrentMapInstance?.Broadcast(session.Character.GeneratePairy());
                    session.SendPacket(UserInterfaceHelper.GenerateMsg(string.Format(Language.Instance.GetMessageFromKey("EFFECT_ACTIVATED"), inv.Item.Name), 0));
                    session.CurrentMapInstance?.Broadcast(StaticPacketHelper.GenerateEff(UserType.Player, session.Character.CharacterId, 3011), session.Character.MapX, session.Character.MapY);
                    session.Character.Inventory.RemoveItemFromInventory(inv.Id);
                }
                else
                {
                    session.SendPacket(UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("ITEM_IN_USE"), 0));
                }
                break;

            // Ice oil
            case 252:
                if (!session.Character.Buff.ContainsKey(340))
                {
                    session.Character.AddStaticBuff(new StaticBuffDTO()
                    {
                        CardId = 340
                    });
                    session.CurrentMapInstance?.Broadcast(session.Character.GeneratePairy());
                    session.SendPacket(UserInterfaceHelper.GenerateMsg(string.Format(Language.Instance.GetMessageFromKey("EFFECT_ACTIVATED"), inv.Item.Name), 0));
                    session.CurrentMapInstance?.Broadcast(StaticPacketHelper.GenerateEff(UserType.Player, session.Character.CharacterId, 16), session.Character.MapX, session.Character.MapY);
                    session.Character.Inventory.RemoveItemFromInventory(inv.Id);
                }
                else
                {
                    session.SendPacket(UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("ITEM_IN_USE"), 0));
                }
                break;

            // Valentin Buff
            case 254:
                if (!session.Character.Buff.ContainsKey(109))
                {
                    session.Character.AddStaticBuff(new StaticBuffDTO()
                    {
                        CardId = 109
                    });
                    session.CurrentMapInstance?.Broadcast(session.Character.GeneratePairy());
                    session.SendPacket(UserInterfaceHelper.GenerateMsg(string.Format(Language.Instance.GetMessageFromKey("EFFECT_ACTIVATED"), inv.Item.Name), 0));
                    session.CurrentMapInstance?.Broadcast(StaticPacketHelper.GenerateEff(UserType.Player, session.Character.CharacterId, 3410), session.Character.MapX, session.Character.MapY);
                    session.Character.Inventory.RemoveItemFromInventory(inv.Id);
                }
                else
                {
                    session.SendPacket(UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("ITEM_IN_USE"), 0));
                }
                break;

            // Buff exp 20%
            case 256:
                if (!session.Character.Buff.ContainsKey(119))
                {
                    session.Character.AddStaticBuff(new StaticBuffDTO()
                    {
                        CardId = 119
                    });
                    session.CurrentMapInstance?.Broadcast(session.Character.GeneratePairy());
                    session.SendPacket(UserInterfaceHelper.GenerateMsg(string.Format(Language.Instance.GetMessageFromKey("EFFECT_ACTIVATED"), inv.Item.Name), 0));
                    session.CurrentMapInstance?.Broadcast(StaticPacketHelper.GenerateEff(UserType.Player, session.Character.CharacterId, 4756), session.Character.MapX, session.Character.MapY);
                    session.Character.Inventory.RemoveItemFromInventory(inv.Id);
                }
                else
                {
                    session.SendPacket(UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("ITEM_IN_USE"), 0));
                }
                break;

            // Ancella fate
            case 258:
                if (!session.Character.Buff.ContainsKey(393))
                {
                    session.Character.AddStaticBuff(new StaticBuffDTO()
                    {
                        CardId = 393
                    });
                    session.CurrentMapInstance?.Broadcast(session.Character.GeneratePairy());
                    session.SendPacket(UserInterfaceHelper.GenerateMsg(string.Format(Language.Instance.GetMessageFromKey("EFFECT_ACTIVATED"), inv.Item.Name), 0));
                    session.CurrentMapInstance?.Broadcast(StaticPacketHelper.GenerateEff(UserType.Player, session.Character.CharacterId, 4756), session.Character.MapX, session.Character.MapY);
                    session.Character.Inventory.RemoveItemFromInventory(inv.Id);
                }
                else
                {
                    session.SendPacket(UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("ITEM_IN_USE"), 0));
                }
                break;

            // Speedbooster
            case 260:
                if (!session.Character.IsVehicled || session.Character.Buff.Any(s => s.Card.CardId == 336))
                {
                    return;
                }
                session.CurrentMapInstance?.Broadcast(session.Character.GenerateEff(885), session.Character.MapX, session.Character.MapY);

                session.Character.Speed += 5;
                switch (session.Character.Morph)
                {
                case 2517:         // Nossi M
                case 2518:         // Nossi F
                case 2522:         // Roller M
                case 2523:         // Roller F
                                   // Removes <= lv 4 debuffs
                    List <BuffType> bufftodisable = new List <BuffType> {
                        BuffType.Bad
                    };
                    session.Character.DisableBuffs(bufftodisable, 4);
                    break;
                }
                Observable.Timer(TimeSpan.FromSeconds(session.Character.BuffRandomTime * 0.1D)).Subscribe(o =>
                {
                    session.Character.Speed -= 5;
                    session.Character.LoadSpeed();
                    switch (session.Character.Morph)
                    {
                    case 2526:         // White male unicorn
                    case 2527:         // White female unicorn
                    case 2528:         // Pink male unicorn
                    case 2529:         // Pink female unicorn
                    case 2530:         // Black male unicorn
                    case 2531:         // Black Female Unicorn
                    case 2928:         // Male UFO
                    case 2929:         // Female UFO
                    case 3679:         // Male squelettic dragon
                    case 3680:         // Female squelettic dragon
                        ServerManager.Instance.TeleportOnRandomPlaceInMap(session, session.Character.MapInstanceId, true);
                        break;

                    case 2432:         // Magic broom
                    case 2433:         // Magic broom F
                    case 2520:         // VTT M
                    case 2521:         // VTT F
                        switch (session.Character.Direction)
                        {
                        case 0:
                            // -y
                            ServerManager.Instance.TeleportForward(session, session.Character.MapInstanceId, session.Character.PositionX, (short)(session.Character.PositionY - 5));
                            break;

                        case 1:
                            // +x
                            ServerManager.Instance.TeleportForward(session, session.Character.MapInstanceId, (short)(session.Character.PositionX + 5), session.Character.PositionY);
                            break;

                        case 2:
                            // +y
                            ServerManager.Instance.TeleportForward(session, session.Character.MapInstanceId, session.Character.PositionX, (short)(session.Character.PositionY + 5));
                            break;

                        case 3:
                            // -x
                            ServerManager.Instance.TeleportForward(session, session.Character.MapInstanceId, (short)(session.Character.PositionX - 5), session.Character.PositionY);
                            break;

                        case 4:
                            ServerManager.Instance.TeleportForward(session, session.Character.MapInstanceId, (short)(session.Character.PositionX - 5), (short)(session.Character.PositionY - 5));
                            // -x -y
                            break;

                        case 5:
                            // +x +y
                            ServerManager.Instance.TeleportForward(session, session.Character.MapInstanceId, (short)(session.Character.PositionX - 5), (short)(session.Character.PositionY - 5));
                            break;

                        case 6:
                            // +x -y
                            ServerManager.Instance.TeleportForward(session, session.Character.MapInstanceId, (short)(session.Character.PositionX + 5), (short)(session.Character.PositionY + 5));
                            break;

                        case 7:
                            // -x +y
                            ServerManager.Instance.TeleportForward(session, session.Character.MapInstanceId, (short)(session.Character.PositionX - 5), (short)(session.Character.PositionY + 5));
                            break;
                        }
                        break;
                    }
                });
                session.Character.Inventory.RemoveItemFromInventory(inv.Id);
                break;



            // Rainbow Pearl/Magic Eraser
            case 666:
                if (EffectValue == 1 && byte.TryParse(packetsplit[9], out byte islot))
                {
                    ItemInstance wearInstance = session.Character.Inventory.LoadBySlotAndType(islot, InventoryType.Equipment);

                    if (wearInstance != null && (wearInstance.Item.ItemType == ItemType.Weapon || wearInstance.Item.ItemType == ItemType.Armor) && wearInstance.ShellEffects.Count != 0 && wearInstance.Item.IsHeroic)
                    {
                        wearInstance.ShellEffects.Clear();
                        DAOFactory.ShellEffectDAO.DeleteByEquipmentSerialId(wearInstance.EquipmentSerialId);
                        if (wearInstance.EquipmentSerialId == Guid.Empty)
                        {
                            wearInstance.EquipmentSerialId = Guid.NewGuid();
                        }
                        session.Character.Inventory.RemoveItemFromInventory(inv.Id);
                        session.SendPacket(UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("OPTION_DELETE"), 0));
                    }
                }
                else
                {
                    session.SendPacket("guri 18 0");
                }
                break;

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

            // Ancelloan's Blessing
            case 208:
                if (!session.Character.Buff.ContainsKey(121))
                {
                    session.Character.Inventory.RemoveItemFromInventory(inv.Id);
                    session.Character.AddStaticBuff(new StaticBuffDTO()
                    {
                        CardId = 121
                    });
                }
                else
                {
                    session.SendPacket(UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("ITEM_IN_USE"), 0));
                }
                break;

            // Divorce letter
            case 6969:     // this is imaginary number I = √(-1)
                var rel = session.Character.CharacterRelations.FirstOrDefault(s => s.RelationType == CharacterRelationType.Spouse);
                if (rel != null)
                {
                    session.Character.DeleteRelation(rel.CharacterId == session.Character.CharacterId ? rel.RelatedCharacterId : rel.CharacterId);
                    session.SendPacket(UserInterfaceHelper.GenerateInfo(Language.Instance.GetMessageFromKey("DIVORCED")));

                    session.Character.Inventory.RemoveItemFromInventory(inv.Id);
                }

                break;

            // Cupid's arrow
            case 34:     // this is imaginary number I = √(-1)
                         // Cupid's arrow
                if (packetsplit != null && packetsplit.Length > 3)
                {
                    if (long.TryParse(packetsplit[3], out long characterId))
                    {
                        if (session.Character.CharacterRelations.Any(s => s.RelationType == CharacterRelationType.Spouse))
                        {
                            session.SendPacket($"info {Language.Instance.GetMessageFromKey("ALREADY_MARRIED")}");
                            return;
                        }
                        ClientSession otherSession = ServerManager.Instance.GetSessionByCharacterId(characterId);
                        if (otherSession != null)
                        {
                            otherSession.SendPacket(UserInterfaceHelper.GenerateDialog(
                                                        $"#fins^-34^{session.Character.CharacterId} #fins^-69^{session.Character.CharacterId} {string.Format(Language.Instance.GetMessageFromKey("MARRY_REQUEST"), session.Character.Name)}"));
                            session.Character.FriendRequestCharacters.Add(characterId);
                            session.Character.Inventory.RemoveItemFromInventory(inv.Id, 1);
                            session.Character.AddStaticBuff(new StaticBuffDTO {
                                CardId = 319
                            });
                        }
                    }
                }
                break;


            case 100:
            {
            }
            break;

            case 5836:
            {
                session.SendPacket($"gb 0 {session.Account.BankGold / 1000} {session.Character.Gold} 0 0");
                session.SendPacket($"s_memo 6 [Account balance]: {session.Account.BankGold} gold; [Owned]: {session.Character.Gold} gold\nWe will do our best. Thank you for using the services of Cuarry Bank.");
            }
            break;

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

                break;

            // SP Wings
            case 650:
                ItemInstance specialistInstance = session.Character.Inventory.LoadBySlotAndType((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
                    {
                        void disposeBuff(short vNum)
                        {
                            if (session.Character.BuffObservables.ContainsKey(vNum))
                            {
                                session.Character.BuffObservables[vNum].Dispose();
                                session.Character.BuffObservables.Remove(vNum);
                            }
                            session.Character.RemoveBuff(vNum);
                        }

                        disposeBuff(387);
                        disposeBuff(395);
                        disposeBuff(396);
                        disposeBuff(397);
                        disposeBuff(398);
                        disposeBuff(410);
                        disposeBuff(411);
                        disposeBuff(444);

                        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.RemoveItemFromInventory(inv.Id);
                    }
                }
                else
                {
                    session.SendPacket(UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("NO_SP"), 0));
                }
                break;

            // Self-Introduction
            case 203:
                if (!session.Character.IsVehicled && Option == 0)
                {
                    session.SendPacket(UserInterfaceHelper.GenerateGuri(10, 2, session.Character.CharacterId, 1));
                }
                break;

            // Magic Lamp
            case 651:
                if (session.Character.Inventory.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.RemoveItemFromInventory(inv.Id);
                    }
                }
                else
                {
                    session.SendPacket(UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("EQ_NOT_EMPTY"), 0));
                }
                break;

            // Vehicles
            case 1000:
                if (EffectValue != 0 || ServerManager.Instance.ChannelId == 51 || session.CurrentMapInstance?.MapInstanceType == MapInstanceType.EventGameInstance)
                {
                    return;
                }

                if (session.Character.HasShopOpened)
                {
                    return;
                }

                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.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(StaticPacketHelper.GenerateEff(UserType.Player, session.Character.CharacterId, 4809), 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.Mates?.Where(s => s.IsTeamMember).ToList().ForEach(x =>
                            {
                                x.PositionX = session.Character.PositionX;
                                x.PositionY = session.Character.PositionY;
                                session.CurrentMapInstance?.Broadcast(x.GenerateIn());
                            });
                            session.Character.RemoveVehicle();
                        }
                    }
                }
                break;

            // Sealed Vessel
            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.RemoveItemFromInventory(inv.Id);
                }
                else if (session.HasCurrentMapInstance && 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;
                    }
                    MapMonster monster = new MapMonster
                    {
                        MonsterVNum   = vnum,
                        MapY          = session.Character.MapY,
                        MapX          = session.Character.MapX,
                        MapId         = session.Character.MapInstance.Map.MapId,
                        Position      = 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.RemoveItemFromInventory(inv.Id);
                }
                break;

            // Golden Bazaar Medal
            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.RemoveItemFromInventory(inv.Id);
                    session.SendPacket(session.Character.GenerateSay(string.Format(Language.Instance.GetMessageFromKey("EFFECT_ACTIVATED"), Name), 12));
                }
                break;

            // Silver Bazaar Medal
            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.RemoveItemFromInventory(inv.Id);
                    session.SendPacket(session.Character.GenerateSay(string.Format(Language.Instance.GetMessageFromKey("EFFECT_ACTIVATED"), Name), 12));
                }
                break;

            // Pet Slot Expansion
            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.RemoveItemFromInventory(inv.Id);
                }
                break;

            // Pet Basket
            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.RemoveItemFromInventory(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;

            // Partner's Backpack
            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.RemoveItemFromInventory(inv.Id);
                    session.SendPacket(session.Character.GenerateExts());
                    session.SendPacket(session.Character.GenerateSay(string.Format(Language.Instance.GetMessageFromKey("EFFECT_ACTIVATED"), Name), 12));
                }
                break;

            // Backpack Expansion
            case 1009:
                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.RemoveItemFromInventory(inv.Id);
                    session.SendPacket(session.Character.GenerateExts());
                    session.SendPacket(session.Character.GenerateSay(string.Format(Language.Instance.GetMessageFromKey("EFFECT_ACTIVATED"), Name), 12));
                }
                break;

            // Sealed Tarot Card
            case 1005:
                session.Character.GiftAdd((short)(VNum - Effect), 1);
                session.Character.Inventory.RemoveItemFromInventory(inv.Id);
                break;

            // Tarot Card Game
            case 1894:
                if (EffectValue == 0)
                {
                    for (int i = 0; i < 5; i++)
                    {
                        session.Character.GiftAdd((short)(Effect + ServerManager.RandomNumber(0, 10)), 1);
                    }
                    session.Character.Inventory.RemoveItemFromInventory(inv.Id);
                }
                break;

            // Sealed Tarot Card
            case 2152:
                session.Character.GiftAdd((short)(VNum + Effect), 1);
                session.Character.Inventory.RemoveItemFromInventory(inv.Id);
                break;

            default:
                switch (VNum)
                {
                case 5841:
                    int     rnd   = ServerManager.RandomNumber(0, 1000);
                    short[] vnums = null;
                    if (rnd < 900)
                    {
                        vnums = new short[] { 4356, 4357, 4358, 4359 };
                    }
                    else
                    {
                        vnums = new short[] { 4360, 4361, 4362, 4363 };
                    }
                    session.Character.GiftAdd(vnums[ServerManager.RandomNumber(0, 4)], 1);
                    session.Character.Inventory.RemoveItemFromInventory(inv.Id);
                    break;

                default:
                    Logger.Warn(string.Format(Language.Instance.GetMessageFromKey("NO_HANDLER_ITEM"), GetType()) + $" ItemVNum: {VNum} Effect: {Effect} EffectValue: {EffectValue}");
                    break;
                }
                break;
            }
        }
예제 #31
0
        public override void Use(ClientSession session, ref ItemInstance inv, byte Option = 0, string[] packetsplit = null)
        {
            if (session.Character.IsVehicled && Effect != 888)
            {
                session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("CANT_DO_VEHICLED"), 10));
                return;
            }

            if (inv.ItemVNum == 333 || inv.ItemVNum == 334) // Sealed Jajamaru Specialist Card & Sealed Princess Sakura Bead
            {
                return;
            }

            switch (Effect)
            {
            case 0:
                if (Option == 0)
                {
                    if (packetsplit?.Length == 9)
                    {
                        ItemInstance box = session.Character.Inventory.LoadBySlotAndType(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
                    ItemInstance box = session.Character.Inventory.LoadBySlotAndType(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.RandomNumber(0, probabilities);
                            int currentrnd    = 0;
                            foreach (RollGeneratedItemDTO rollitem in roll.OrderBy(s => ServerManager.RandomNumber()))
                            {
                                currentrnd += rollitem.Probability;
                                if (currentrnd >= rnd)
                                {
                                    Item  i       = ServerManager.GetItem(rollitem.ItemGeneratedVNum);
                                    sbyte rare    = 0;
                                    byte  upgrade = 0;
                                    if (i.ItemType == ItemType.Armor || i.ItemType == ItemType.Weapon || i.ItemType == ItemType.Shell || i.ItemType == ItemType.Box)
                                    {
                                        rare = box.Rare;
                                    }
                                    if (i.ItemType == ItemType.Shell)
                                    {
                                        if (rare < 1)
                                        {
                                            rare = 1;
                                        }
                                        else if (rare > 7)
                                        {
                                            rare = 7;
                                        }
                                        upgrade = (byte)ServerManager.RandomNumber(50, 81);
                                    }
                                    if (rollitem.IsRareRandom)
                                    {
                                        rnd = ServerManager.RandomNumber(0, 100);

                                        for (int j = ItemHelper.RareRate.Length - 1; j >= 0; j--)
                                        {
                                            if (rnd < ItemHelper.RareRate[j])
                                            {
                                                rare = (sbyte)j;
                                                break;
                                            }
                                        }
                                        if (rare < 1)
                                        {
                                            rare = 1;
                                        }
                                    }
                                    session.Character.GiftAdd(rollitem.ItemGeneratedVNum, rollitem.ItemGeneratedAmount, (byte)rare, upgrade, rollitem.ItemGeneratedDesign);
                                    session.SendPacket($"rdi {rollitem.ItemGeneratedVNum} {rollitem.ItemGeneratedAmount}");
                                    session.Character.Inventory.RemoveItemFromInventory(box.Id);
                                    return;

                                    //newInv = session.Character.Inventory.AddNewToInventory(rollitem.ItemGeneratedVNum, amount: rollitem.ItemGeneratedAmount, Design: design, Rare: rare);
                                    //if (newInv.Count > 0)
                                    //{
                                    //    short Slot = inv.Slot;
                                    //    if (Slot != -1)
                                    //    {
                                    //        session.SendPacket(session.Character.GenerateSay(
                                    //            $"{Language.Instance.GetMessageFromKey("ITEM_ACQUIRED")}: {newInv.FirstOrDefault(s => s != null)?.Item?.Name} x {rollitem.ItemGeneratedAmount}",
                                    //            12));
                                    //        newInv.Where(s => s != null).ToList()
                                    //            .ForEach(s => session.SendPacket(s.GenerateInventoryAdd()));
                                    //        session.Character.Inventory
                                    //            .RemoveItemAmountFromInventory(box.Id);
                                    //    }
                                    //}
                                }
                            }
                        }
                        else if (box.HoldingVNum == 0)
                        {
                            if (packetsplit.Length == 1 && int.TryParse(packetsplit[0], out int PetId) && session.Character.Mates.Find(s => s.MateTransportId == PetId) is Mate mate)
                            {
                                if (ItemSubType == 0 && mate.MateType != MateType.Pet || ItemSubType == 1 && mate.MateType != MateType.Partner)
                                {
                                    return;
                                }
                                if (mate.MateType == MateType.Partner && mate.GetInventory().Count > 0)
                                {
                                    session.SendPacket(UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("EQ_NOT_EMPTY"), 0));
                                    return;
                                }
                                box.HoldingVNum = mate.NpcMonsterVNum;
                                box.SpLevel     = mate.Level;
                                box.SpDamage    = mate.Attack;
                                box.SpDefence   = mate.Defence;
                                session.Character.Mates.Remove(mate);
                                if (mate.MateType == MateType.Partner)
                                {
                                    byte i = 0;
                                    session.Character.Mates.Where(s => s.MateType == MateType.Partner).ToList().ForEach(s =>
                                    {
                                        s.GetInventory().ForEach(item => item.Type = (InventoryType)(13 + i));
                                        s.PetId = i;
                                        i++;
                                    });
                                }
                                session.SendPacket(UserInterfaceHelper.GenerateInfo(Language.Instance.GetMessageFromKey("PET_STORED")));
                                session.SendPacket(UserInterfaceHelper.GeneratePClear());
                                session.SendPackets(session.Character.GenerateScP());
                                session.SendPackets(session.Character.GenerateScN());
                                session.CurrentMapInstance?.Broadcast(mate.GenerateOut());
                            }
                        }
                        else
                        {
                            NpcMonster heldMonster = ServerManager.GetNpcMonster(box.HoldingVNum);
                            if (heldMonster != null)
                            {
                                Mate mate = new Mate(session.Character, heldMonster, box.SpLevel, ItemSubType == 0 ? MateType.Pet : MateType.Partner)
                                {
                                    Attack  = box.SpDamage,
                                    Defence = box.SpDefence
                                };
                                if (session.Character.AddPet(mate))
                                {
                                    session.Character.Inventory.RemoveItemFromInventory(inv.Id);
                                    session.SendPacket(UserInterfaceHelper.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.GetNpcMonster((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.RemoveItemFromInventory(inv.Id);
                            session.SendPacket(UserInterfaceHelper.GenerateInfo(Language.Instance.GetMessageFromKey("PET_LEAVE_BEAD")));
                        }
                    }
                    else
                    {
                        session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("NOT_IN_MINILAND"), 12));
                    }
                }

                break;

            case 69:
                if (EffectValue == 1 || EffectValue == 2)
                {
                    ItemInstance box = session.Character.Inventory.LoadBySlotAndType(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.Count > 0)
                            {
                                ItemInstance itemInstance = newInv[0];
                                ItemInstance specialist   = session.Character.Inventory.LoadBySlotAndType(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.EquipmentSerialId = box.EquipmentSerialId;
                                    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.RemoveItemFromInventory(box.Id);
                                }
                            }
                            else
                            {
                                session.SendPacket(UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("NOT_ENOUGH_PLACE"), 0));
                            }
                        }
                    }
                }
                if (EffectValue == 3)
                {
                    ItemInstance box = session.Character.Inventory.LoadBySlotAndType(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.Count > 0)
                            {
                                ItemInstance itemInstance = newInv[0];
                                ItemInstance fairy        = session.Character.Inventory.LoadBySlotAndType(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.RemoveItemFromInventory(box.Id);
                                }
                            }
                            else
                            {
                                session.SendPacket(UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("NOT_ENOUGH_PLACE"), 0));
                            }
                        }
                    }
                }
                if (EffectValue == 4)
                {
                    ItemInstance box = session.Character.Inventory.LoadBySlotAndType(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.Count > 0)
                            {
                                short Slot = inv.Slot;
                                if (Slot != -1)
                                {
                                    session.SendPacket(session.Character.GenerateSay($"{Language.Instance.GetMessageFromKey("ITEM_ACQUIRED")}: {newInv[0].Item.Name} x 1)", 12));
                                    newInv.ForEach(s => session.SendPacket(s.GenerateInventoryAdd()));
                                    session.Character.Inventory.RemoveItemFromInventory(box.Id);
                                }
                            }
                            else
                            {
                                session.SendPacket(UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("NOT_ENOUGH_PLACE"), 0));
                            }
                        }
                    }
                }
                break;

            case 888:
                if (session.Character.IsVehicled)
                {
                    if (!session.Character.Buff.Any(s => s.Card.CardId == 336))
                    {
                        if (inv.ItemDeleteTime == null)
                        {
                            inv.ItemDeleteTime = DateTime.Now.AddHours(LevelMinimum);
                        }
                        session.Character.VehicleItem.BCards.ForEach(s => s.ApplyBCards(session.Character.BattleEntity, session.Character.BattleEntity));
                        session.CurrentMapInstance.Broadcast($"eff 1 {session.Character.CharacterId} 885");
                    }
                }
                break;

            //Need change rewards value for all boxes

            /* case 185: // Hatus raid box
             *   int rnd8 = ServerManager.RandomNumber(0, 1000);
             *   int random8 = ServerManager.RandomNumber(0, 7);
             *   short[] vnums8 = null;
             *   if (rnd8 < 900)
             *   {
             *       vnums8 = new short[] { 567, 570, 573, 576, 579, 582, 585, 588 };
             *   }
             *   else
             *   {
             *       vnums8 = new short[] { 567, 570, 573, 576, 579, 582, 585, 588 };
             *   }
             *   session.Character.GiftAdd(vnums8[ServerManager.RandomNumber(0, 7)], 1, (byte)random8);
             *   session.Character.Inventory.RemoveItemFromInventory(inv.Id);
             *   break;
             *
             * case 882: // Morcos raid box
             *   int rnd7 = ServerManager.RandomNumber(0, 1000);
             *   int random = ServerManager.RandomNumber(0, 7);
             *   short[] vnums7 = null;
             *   if (rnd7 < 900)
             *   {
             *       vnums7 = new short[] { 567, 570, 573, 576, 579, 582, 585, 588 };
             *   }
             *   else
             *   {
             *       vnums7 = new short[] { 567, 570, 573, 576, 579, 582, 585, 588 };
             *   }
             *   session.Character.GiftAdd(vnums7[ServerManager.RandomNumber(0, 7)], 1, (byte)random);
             *   session.Character.Inventory.RemoveItemFromInventory(inv.Id);
             *   break;
             *
             * case 942: // Calvina raid box
             *   int rnd10 = ServerManager.RandomNumber(0, 1000);
             *   int random10 = ServerManager.RandomNumber(0, 7);
             *   short[] vnums10 = null;
             *   if (rnd10 < 900)
             *   {
             *       vnums10 = new short[] { 567, 570, 573, 576, 579, 582, 585, 588 };
             *   }
             *   else
             *   {
             *       vnums10 = new short[] { 567, 570, 573, 576, 579, 582, 585, 588 };
             *   }
             *   session.Character.GiftAdd(vnums10[ServerManager.RandomNumber(0, 7)], 1, (byte)random10);
             *   session.Character.Inventory.RemoveItemFromInventory(inv.Id);
             *   break;
             *
             * case 999: // Berios raid box
             *   int rnd9 = ServerManager.RandomNumber(0, 1000);
             *   int random9 = inv.Item.
             *   short[] vnums9 = null;
             *   if (rnd9 < 900)
             *   {
             *       vnums9 = new short[] { 567, 570, 573, 576, 579, 582, 585, 588 };
             *   }
             *   else
             *   {
             *       vnums9 = new short[] { 567, 570, 573, 576, 579, 582, 585, 588 };
             *   }
             *   session.Character.GiftAdd(vnums9[ServerManager.RandomNumber(0, 7)], 1, (byte)random9);
             *   session.Character.Inventory.RemoveItemFromInventory(inv.Id);
             *   break;*/

            default:
                Logger.Warn(string.Format(Language.Instance.GetMessageFromKey("NO_HANDLER_ITEM"), GetType(), VNum, Effect, EffectValue));
                break;
            }
        }
예제 #32
0
        public void UpgradeItem(ClientSession session, UpgradeMode mode, UpgradeProtection protection, bool isCommand = false)
        {
            if (!session.HasCurrentMapInstance)
            {
                return;
            }
            if (Upgrade < 10)
            {
                short[] upfail;
                short[] upfix;
                int[]   goldprice;
                short[] cella;
                short[] gem;

                if (Rare >= 8)
                {
                    upfix  = new short[] { 50, 40, 70, 65, 80, 90, 95, 97, 98, 99 };
                    upfail = new short[] { 50, 40, 60, 50, 60, 70, 75, 77, 83, 89 };

                    goldprice = new[] { 5000, 15000, 30000, 100000, 300000, 800000, 1500000, 4000000, 7000000, 10000000 };
                    cella     = new short[] { 40, 100, 160, 240, 320, 440, 560, 760, 960, 1200 };
                    gem       = new short[] { 2, 2, 4, 4, 6, 2, 2, 4, 4, 6 };
                }
                else
                {
                    upfix  = new short[] { 0, 0, 10, 15, 20, 20, 20, 20, 15, 14 };
                    upfail = new short[] { 0, 0, 0, 5, 20, 40, 60, 70, 80, 85 };

                    goldprice = new[] { 500, 1500, 3000, 10000, 30000, 80000, 150000, 400000, 700000, 1000000 };
                    cella     = new short[] { 20, 50, 80, 120, 160, 220, 280, 380, 480, 600 };
                    gem       = new short[] { 1, 1, 2, 2, 3, 1, 1, 2, 2, 3 };
                }

                const short  cellaVnum          = 1014;
                const short  gemVnum            = 1015;
                const short  gemFullVnum        = 1016;
                const double reducedpricefactor = 0.5;
                const short  normalScrollVnum   = 1218;
                const short  goldScrollVnum     = 5369;

                if (IsFixed)
                {
                    session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("ITEM_IS_FIXED"), 10));
                    session.SendPacket("shop_end 1");
                    return;
                }
                switch (mode)
                {
                case UpgradeMode.Free:
                    break;

                case UpgradeMode.Reduced:

                    // TODO: Reduced Item Amount
                    if (session.Character.Gold < (long)(goldprice[Upgrade] * reducedpricefactor))
                    {
                        session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("NOT_ENOUGH_MONEY"), 10));
                        return;
                    }
                    if (session.Character.Inventory.CountItem(cellaVnum) < cella[Upgrade] * reducedpricefactor)
                    {
                        session.SendPacket(session.Character.GenerateSay(string.Format(Language.Instance.GetMessageFromKey("NOT_ENOUGH_ITEMS"), ServerManager.Instance.GetItem(cellaVnum).Name, cella[Upgrade] * reducedpricefactor), 10));
                        return;
                    }
                    if (protection == UpgradeProtection.Protected && !isCommand && session.Character.Inventory.CountItem(goldScrollVnum) < 1)
                    {
                        session.SendPacket(session.Character.GenerateSay(string.Format(Language.Instance.GetMessageFromKey("NOT_ENOUGH_ITEMS"), ServerManager.Instance.GetItem(goldScrollVnum).Name, cella[Upgrade] * reducedpricefactor), 10));
                        return;
                    }
                    if (Upgrade < 5)
                    {
                        if (session.Character.Inventory.CountItem(gemVnum) < gem[Upgrade])
                        {
                            session.SendPacket(session.Character.GenerateSay(string.Format(Language.Instance.GetMessageFromKey("NOT_ENOUGH_ITEMS"), ServerManager.Instance.GetItem(gemVnum).Name, gem[Upgrade]), 10));
                            return;
                        }
                        session.Character.Inventory.RemoveItemAmount(gemVnum, gem[Upgrade]);
                    }
                    else
                    {
                        if (session.Character.Inventory.CountItem(gemFullVnum) < gem[Upgrade])
                        {
                            session.SendPacket(session.Character.GenerateSay(string.Format(Language.Instance.GetMessageFromKey("NOT_ENOUGH_ITEMS"), ServerManager.Instance.GetItem(gemFullVnum).Name, gem[Upgrade]), 10));
                            return;
                        }
                        session.Character.Inventory.RemoveItemAmount(gemFullVnum, gem[Upgrade]);
                    }
                    if (protection == UpgradeProtection.Protected && !isCommand)
                    {
                        session.Character.Inventory.RemoveItemAmount(goldScrollVnum);
                        session.SendPacket("shop_end 2");
                    }
                    session.Character.Gold -= (long)(goldprice[Upgrade] * reducedpricefactor);
                    session.Character.Inventory.RemoveItemAmount(cellaVnum, (int)(cella[Upgrade] * reducedpricefactor));
                    session.SendPacket(session.Character.GenerateGold());
                    break;

                case UpgradeMode.Normal:

                    // TODO: Normal Item Amount
                    if (session.Character.Inventory.CountItem(cellaVnum) < cella[Upgrade])
                    {
                        return;
                    }
                    if (session.Character.Gold < goldprice[Upgrade])
                    {
                        session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("NOT_ENOUGH_MONEY"), 10));
                        return;
                    }
                    if (protection == UpgradeProtection.Protected && !isCommand && session.Character.Inventory.CountItem(normalScrollVnum) < 1)
                    {
                        session.SendPacket(session.Character.GenerateSay(string.Format(Language.Instance.GetMessageFromKey("NOT_ENOUGH_ITEMS"), ServerManager.Instance.GetItem(normalScrollVnum).Name, 1), 10));
                        return;
                    }
                    if (Upgrade < 5)
                    {
                        if (session.Character.Inventory.CountItem(gemVnum) < gem[Upgrade])
                        {
                            session.SendPacket(session.Character.GenerateSay(string.Format(Language.Instance.GetMessageFromKey("NOT_ENOUGH_ITEMS"), ServerManager.Instance.GetItem(gemVnum).Name, gem[Upgrade]), 10));
                            return;
                        }
                        session.Character.Inventory.RemoveItemAmount(gemVnum, gem[Upgrade]);
                    }
                    else
                    {
                        if (session.Character.Inventory.CountItem(gemFullVnum) < gem[Upgrade])
                        {
                            session.SendPacket(session.Character.GenerateSay(string.Format(Language.Instance.GetMessageFromKey("NOT_ENOUGH_ITEMS"), ServerManager.Instance.GetItem(gemFullVnum).Name, gem[Upgrade]), 10));
                            return;
                        }
                        session.Character.Inventory.RemoveItemAmount(gemFullVnum, gem[Upgrade]);
                    }
                    if (protection == UpgradeProtection.Protected && !isCommand)
                    {
                        session.Character.Inventory.RemoveItemAmount(normalScrollVnum);
                        session.SendPacket("shop_end 2");
                    }
                    session.Character.Inventory.RemoveItemAmount(cellaVnum, cella[Upgrade]);
                    session.Character.Gold -= goldprice[Upgrade];
                    session.SendPacket(session.Character.GenerateGold());
                    break;
                }
                WearableInstance wearable  = session.Character.Inventory.LoadByItemInstance <WearableInstance>(Id);
                ItemInstance     inventory = session.Character.Inventory.GetItemInstanceById(Id);

                int rnd = ServerManager.Instance.RandomNumber();
                if (Rare == 8)
                {
                    if (rnd < upfail[Upgrade])
                    {
                        if (protection == UpgradeProtection.None)
                        {
                            session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("UPGRADE_FAILED"), 11));
                            session.SendPacket(UserInterfaceHelper.Instance.GenerateMsg(Language.Instance.GetMessageFromKey("UPGRADE_FAILED"), 0));
                            session.Character.DeleteItemByItemInstanceId(Id);
                        }
                        else
                        {
                            session.CurrentMapInstance.Broadcast(session.Character.GenerateEff(3004), session.Character.MapX, session.Character.MapY);
                            session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("SCROLL_PROTECT_USED"), 11));
                            session.SendPacket(UserInterfaceHelper.Instance.GenerateMsg(Language.Instance.GetMessageFromKey("UPGRADE_FAILED_ITEM_SAVED"), 0));
                        }
                    }
                    else if (rnd < upfix[Upgrade])
                    {
                        session.CurrentMapInstance.Broadcast(session.Character.GenerateEff(3004), session.Character.MapX, session.Character.MapY);
                        wearable.IsFixed = true;
                        session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("UPGRADE_FIXED"), 11));
                        session.SendPacket(UserInterfaceHelper.Instance.GenerateMsg(Language.Instance.GetMessageFromKey("UPGRADE_FIXED"), 0));
                    }
                    else
                    {
                        session.CurrentMapInstance.Broadcast(session.Character.GenerateEff(3005), session.Character.MapX, session.Character.MapY);
                        session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("UPGRADE_SUCCESS"), 12));
                        session.SendPacket(UserInterfaceHelper.Instance.GenerateMsg(Language.Instance.GetMessageFromKey("UPGRADE_SUCCESS"), 0));
                        wearable.Upgrade++;
                        if (wearable.Upgrade > 4)
                        {
                            session.Character.Family?.InsertFamilyLog(FamilyLogType.ItemUpgraded, session.Character.Name, itemVNum: wearable.ItemVNum, upgrade: wearable.Upgrade);
                        }
                        session.SendPacket(wearable.GenerateInventoryAdd());
                    }
                }
                else
                {
                    if (rnd < upfix[Upgrade])
                    {
                        session.CurrentMapInstance.Broadcast(session.Character.GenerateEff(3004), session.Character.MapX, session.Character.MapY);
                        wearable.IsFixed = true;
                        session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("UPGRADE_FIXED"), 11));
                        session.SendPacket(UserInterfaceHelper.Instance.GenerateMsg(Language.Instance.GetMessageFromKey("UPGRADE_FIXED"), 0));
                    }
                    else if (rnd < upfail[Upgrade] + upfix[Upgrade])
                    {
                        if (protection == UpgradeProtection.None)
                        {
                            session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("UPGRADE_FAILED"), 11));
                            session.SendPacket(UserInterfaceHelper.Instance.GenerateMsg(Language.Instance.GetMessageFromKey("UPGRADE_FAILED"), 0));
                            session.Character.DeleteItemByItemInstanceId(Id);
                        }
                        else
                        {
                            session.CurrentMapInstance.Broadcast(session.Character.GenerateEff(3004), session.Character.MapX, session.Character.MapY);
                            session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("SCROLL_PROTECT_USED"), 11));
                            session.SendPacket(UserInterfaceHelper.Instance.GenerateMsg(Language.Instance.GetMessageFromKey("UPGRADE_FAILED_ITEM_SAVED"), 0));
                        }
                    }
                    else
                    {
                        session.CurrentMapInstance.Broadcast(session.Character.GenerateEff(3005), session.Character.MapX, session.Character.MapY);
                        session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("UPGRADE_SUCCESS"), 12));
                        session.SendPacket(UserInterfaceHelper.Instance.GenerateMsg(Language.Instance.GetMessageFromKey("UPGRADE_SUCCESS"), 0));
                        wearable.Upgrade++;
                        if (wearable.Upgrade > 4)
                        {
                            session.Character.Family?.InsertFamilyLog(FamilyLogType.ItemUpgraded, session.Character.Name, itemVNum: wearable.ItemVNum, upgrade: wearable.Upgrade);
                        }
                        session.SendPacket(wearable.GenerateInventoryAdd());
                    }
                }
                session.SendPacket("shop_end 1");
            }
        }
예제 #33
0
        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;
                        }
                        else 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;
            }
        }
예제 #34
0
        public override void Use(ClientSession session, ref ItemInstance inv, byte Option = 0, string[] packetsplit = null)
        {
            if (session.Character.IsVehicled)
            {
                session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("CANT_DO_VEHICLED"), 10));
                return;
            }

            if (session.CurrentMapInstance.MapInstanceType == MapInstanceType.TalentArenaMapInstance)
            {
                return;
            }

            if ((DateTime.Now - session.Character.LastPotion).TotalMilliseconds < 750)
            {
                return;
            }
            session.Character.LastPotion = DateTime.Now;
            Item item = inv.Item;

            switch (Effect)
            {
            default:
                if (session.Character.Hp <= 0)
                {
                    return;
                }

                if (item.VNum == 2291 || item.VNum == 10035)
                {
                    if (!session.Character.IsSitting)
                    {
                        session.Character.Rest();
                    }

                    session.SendPacket(StaticPacketHelper.GenerateEff(UserType.Player, session.Character.CharacterId, 6000));

                    session.Character.SpPoint += 1500;

                    if (session.Character.SpPoint > 10000)
                    {
                        session.Character.SpPoint = 10000;
                    }

                    session.Character.Inventory.RemoveItemFromInventory(inv.Id);
                    session.SendPacket(session.Character.GenerateSpPoint());
                    return;
                }

                if (session.Character.FoodAmount < 0)
                {
                    session.Character.FoodAmount = 0;
                }
                int amount = session.Character.FoodAmount;

                if (amount < 5)
                {
                    if (item.BCards.Find(s => s.Type == (byte)BCardType.CardType.HPMP && s.SubType == (byte)AdditionalTypes.HPMP.ReceiveAdditionalHP / 10 && s.FirstData > 0) is BCard AdditionalHpBCard)
                    {
                        // MaxAdditionalHpPercent = AdditionalHp.SecondData;
                        double AdditionalHp = 0;
                        if (session.Character.BattleEntity.AdditionalHp + AdditionalHpBCard.FirstData <= session.Character.HPLoad() * 0.2)
                        {
                            AdditionalHp = AdditionalHpBCard.FirstData;
                        }
                        else if (session.Character.BattleEntity.AdditionalHp < session.Character.HPLoad() * 0.2)
                        {
                            AdditionalHp = session.Character.HPLoad() * 0.2 - session.Character.BattleEntity.AdditionalHp;
                        }
                        if (AdditionalHp > 0 && AdditionalHp <= AdditionalHpBCard.FirstData)
                        {
                            session.Character.FoodAmount++;
                            session.SendPacket(StaticPacketHelper.GenerateEff(UserType.Player, session.Character.CharacterId, 6000));
                            session.Character.BattleEntity.AdditionalHp += AdditionalHp;
                            session.SendPacket(session.Character.GenerateAdditionalHpMp());
                            session.SendPacket(session.Character.GenerateStat());
                            session.Character.Inventory.RemoveItemFromInventory(inv.Id);
                            Observable.Timer(TimeSpan.FromMilliseconds(1800)).Subscribe(s => session.Character.FoodAmount--);
                        }
                        return;
                    }
                    if (item.BCards.Find(s => s.Type == (byte)BCardType.CardType.HPMP && s.SubType == (byte)AdditionalTypes.HPMP.ReceiveAdditionalMP / 10 && s.FirstData < 0) is BCard AdditionalMpBCard)
                    {
                        // MaxAdditionalMpPercent = AdditionalMp.SecondData;
                        double AdditionalMp = 0;
                        if (session.Character.BattleEntity.AdditionalMp + (-AdditionalMpBCard.FirstData) <= session.Character.MPLoad() * 0.2)
                        {
                            AdditionalMp = (-AdditionalMpBCard.FirstData);
                        }
                        else if (session.Character.BattleEntity.AdditionalMp < session.Character.MPLoad() * 0.2)
                        {
                            AdditionalMp = session.Character.MPLoad() * 0.2 - session.Character.BattleEntity.AdditionalMp;
                        }
                        if (AdditionalMp > 0 && AdditionalMp <= -AdditionalMpBCard.FirstData)
                        {
                            session.Character.FoodAmount++;
                            session.SendPacket(StaticPacketHelper.GenerateEff(UserType.Player, session.Character.CharacterId, 6000));
                            session.Character.BattleEntity.AdditionalMp += AdditionalMp;
                            session.SendPacket(session.Character.GenerateAdditionalHpMp());
                            session.SendPacket(session.Character.GenerateStat());
                            session.Character.Inventory.RemoveItemFromInventory(inv.Id);
                            Observable.Timer(TimeSpan.FromMilliseconds(1800)).Subscribe(s => session.Character.FoodAmount--);
                        }
                        return;
                    }
                }

                if (!session.Character.IsSitting)
                {
                    session.Character.Rest();
                }
                session.Character.Mates.Where(s => s.IsTeamMember).ToList().ForEach(m => session.CurrentMapInstance?.Broadcast(m.GenerateRest(true)));

                if (amount < 5)
                {
                    if (!session.Character.IsSitting)
                    {
                        return;
                    }
                    Thread workerThread = new Thread(() => Regenerate(session, item));
                    workerThread.Start();
                    session.Character.Inventory.RemoveItemFromInventory(inv.Id);
                }
                else
                {
                    session.SendPacket(session.Character.Gender == GenderType.Female
                            ? session.Character.GenerateSay(Language.Instance.GetMessageFromKey("NOT_HUNGRY_FEMALE"), 1)
                            : session.Character.GenerateSay(Language.Instance.GetMessageFromKey("NOT_HUNGRY_MALE"), 1));
                }
                if (amount == 0)
                {
                    if (!session.Character.IsSitting)
                    {
                        return;
                    }
                    Thread workerThread2 = new Thread(() => Sync(session));
                    workerThread2.Start();
                }
                break;
            }
        }
예제 #35
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.GetAllItems().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:

                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.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;

            default:
                Logger.Log.Warn(String.Format(Language.Instance.GetMessageFromKey("NO_HANDLER_ITEM"), this.GetType().ToString()));
                break;
            }
        }
예제 #36
0
        public void RarifyItem(ClientSession session, RarifyMode mode, RarifyProtection protection,
            bool isCommand = false)
        {
            double raren2 = 80;
            double raren1 = 70;
            double rare0 = 60;
            double rare1 = 40;
            double rare2 = 30;
            double rare3 = 15;
            double rare4 = 10;
            double rare5 = 5;
            double rare6 = 3;
            double rare7 = 2;
            double rare8 = 1;
            const short goldprice = 500;
            const double reducedpricefactor = 0.5;
            const double reducedchancefactor = 1.1;
            const byte cella = 5;
            const int cellaVnum = 1014;
            const int scrollVnum = 1218;
            int rnd;

            if (session != null && !session.HasCurrentMap)
            {
                return;
            }
            if (mode != RarifyMode.Drop || Item.ItemType == ItemType.Shell)
            {
                raren2 = 0;
                raren1 = 0;
                rare0 = 0;
                rnd = _random.Next(0, 80);
            }
            else
            {
                rnd = _random.Next(0, 100);
            }
            if (protection == RarifyProtection.RedAmulet)
            {
                raren2 = raren1 * reducedchancefactor;
                raren1 = raren1 * reducedchancefactor;
                rare0 = rare0 * reducedchancefactor;
                rare1 = rare1 * reducedchancefactor;
                rare2 = rare2 * reducedchancefactor;
                rare3 = rare3 * reducedchancefactor;
                rare4 = rare4 * reducedchancefactor;
                rare5 = rare5 * reducedchancefactor;
                rare6 = rare6 * reducedchancefactor;
                rare7 = rare7 * reducedchancefactor;
                rare8 = rare8 * reducedchancefactor;

                // rare8 = rare8 * reducedchancefactor;
            }
            if (session != null)
            {
                switch (mode)
                {
                    case RarifyMode.Free:
                        break;

                    case RarifyMode.Reduced:

                        // TODO: Reduced Item Amount
                        if (session.Character.Gold < (long)(goldprice * reducedpricefactor))
                        {
                            return;
                        }
                        if (session.Character.Inventory.CountItem(cellaVnum) < cella * reducedpricefactor)
                        {
                            return;
                        }
                        session.Character.Inventory.RemoveItemAmount(cellaVnum, (int)(cella * reducedpricefactor));
                        session.Character.Gold -= (long)(goldprice * reducedpricefactor);
                        session.SendPacket(session.Character.GenerateGold());
                        break;

                    case RarifyMode.Normal:

                        // TODO: Normal Item Amount
                        if (session.Character.Gold < goldprice)
                        {
                            return;
                        }
                        if (session.Character.Inventory.CountItem(cellaVnum) < cella)
                        {
                            return;
                        }
                        if (protection == RarifyProtection.Scroll && !isCommand &&
                            session.Character.Inventory.CountItem(scrollVnum) < 1)
                        {
                            return;
                        }

                        if (protection == RarifyProtection.Scroll && !isCommand)
                        {
                            session.Character.Inventory.RemoveItemAmount(scrollVnum);
                            session.SendPacket("shop_end 2");
                        }
                        session.Character.Gold -= goldprice;
                        session.Character.Inventory.RemoveItemAmount(cellaVnum, cella);
                        session.SendPacket(session.Character.GenerateGold());
                        break;
                }
            }
            if (Item.IsHeroic && protection == RarifyProtection.Scroll)
            {
                if (rnd <= rare8 && !(protection == RarifyProtection.Scroll && Rare >= 8))
                {
                    if (mode != RarifyMode.Drop)
                    {
                        session?.Character.NotifyRarifyResult(8);
                    }

                    Rare = 8;
                    SetRarityPoint();
                    ItemInstance inventory = session?.Character.Inventory.GetItemInstanceById(Id);
                    if (inventory != null)
                    {
                        session.SendPacket(session.Character.GenerateInventoryAdd(ItemVNum, 1, inventory.Type, inventory.Slot, inventory.Rare, 0, inventory.Upgrade, 0));
                    }
                    return;
                }
            }
            if (rnd <= rare7 && !(protection == RarifyProtection.Scroll && Rare >= 7))
            {
                if (mode != RarifyMode.Drop)
                {
                    session?.Character.NotifyRarifyResult(7);
                }

                Rare = 7;
                SetRarityPoint();
            }
            else if (rnd <= rare6 && !(protection == RarifyProtection.Scroll && Rare >= 6))
            {
                if (mode != RarifyMode.Drop)
                {
                    session?.Character.NotifyRarifyResult(6);
                }
                Rare = 6;
                SetRarityPoint();
            }
            else if (rnd <= rare5 && !(protection == RarifyProtection.Scroll && Rare >= 5))
            {
                if (mode != RarifyMode.Drop)
                {
                    session?.Character.NotifyRarifyResult(5);
                }
                Rare = 5;
                SetRarityPoint();
            }
            else if (rnd <= rare4 && !(protection == RarifyProtection.Scroll && Rare >= 4))
            {
                if (mode != RarifyMode.Drop)
                {
                    session?.Character.NotifyRarifyResult(4);
                }
                Rare = 4;
                SetRarityPoint();
            }
            else if (rnd <= rare3 && !(protection == RarifyProtection.Scroll && Rare >= 3))
            {
                if (mode != RarifyMode.Drop)
                {
                    session?.Character.NotifyRarifyResult(3);
                }
                Rare = 3;
                SetRarityPoint();
            }
            else if (rnd <= rare2 && !(protection == RarifyProtection.Scroll && Rare >= 2))
            {
                if (mode != RarifyMode.Drop)
                {
                    session?.Character.NotifyRarifyResult(2);
                }
                Rare = 2;
                SetRarityPoint();
            }
            else if (rnd <= rare1 && !(protection == RarifyProtection.Scroll && Rare >= 1))
            {
                if (mode != RarifyMode.Drop)
                {
                    session?.Character.NotifyRarifyResult(1);
                }
                Rare = 1;
                SetRarityPoint();
            }
            else if (rnd <= rare0 && !(protection == RarifyProtection.Scroll && Rare >= 0))
            {
                if (mode != RarifyMode.Drop)
                {
                    session?.Character.NotifyRarifyResult(0);
                }
                Rare = 0;
                SetRarityPoint();
            }
            else if (rnd <= raren1 && !(protection == RarifyProtection.Scroll && Rare >= -1))
            {
                if (mode != RarifyMode.Drop)
                {
                    session?.Character.NotifyRarifyResult(-1);
                }
                Rare = -1;
                SetRarityPoint();
            }
            else if (rnd <= raren2 && !(protection == RarifyProtection.Scroll && Rare >= -2))
            {
                if (mode != RarifyMode.Drop)
                {
                    session?.Character.NotifyRarifyResult(-2);
                }
                Rare = -2;
                SetRarityPoint();
            }
            else
            {
                if (mode != RarifyMode.Drop && session != null)
                {
                    if (protection == RarifyProtection.None)
                    {
                        session.Character.DeleteItemByItemInstanceId(Id);
                        session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("RARIFY_FAILED"), 11));
                        session.SendPacket(session.Character.GenerateMsg(Language.Instance.GetMessageFromKey("RARIFY_FAILED"), 0));
                    }
                    else
                    {
                        session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("RARIFY_FAILED_ITEM_SAVED"), 11));
                        session.SendPacket(session.Character.GenerateMsg(Language.Instance.GetMessageFromKey("RARIFY_FAILED_ITEM_SAVED"), 0));
                        session.CurrentMap.Broadcast(session.Character.GenerateEff(3004), session.Character.MapX, session.Character.MapY);
                    }
                }
            }

            // don't place under else.
            if (mode != RarifyMode.Drop && session != null)
            {
                ItemInstance inventory = session.Character.Inventory.GetItemInstanceById(Id);
                if (inventory != null)
                {
                    session.SendPacket(session.Character.GenerateInventoryAdd(ItemVNum, 1, inventory.Type, inventory.Slot, inventory.Rare, 0, inventory.Upgrade, 0));
                }
            }
        }
예제 #37
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()));
            }
        }
예제 #38
0
        public void UpgradeItem(ClientSession session, UpgradeMode mode, UpgradeProtection protection, bool isCommand = false)
        {
            if (!session.HasCurrentMap)
            {
                return;
            }
            if (Upgrade < 10)
            {
                short[] upsuccess;
                short[] upfix;
                int[] goldprice;
                short[] cella;
                short[] gem;

                if (Rare == 8)
                {
                    upsuccess = new short[] { 50, 50, 45, 30, 20, 10, 5, 3, 2, 1 };
                    upfix = new short[] { 0, 0, 10, 15, 20, 20, 20, 20, 15, 10 };
                    goldprice = new[] { 5000, 15000, 30000, 100000, 300000, 800000, 1500000, 4000000, 7000000, 10000000 };
                    cella = new short[] { 40, 100, 160, 240, 320, 440, 560, 760, 960, 1200 };
                    gem = new short[] { 2, 2, 4, 4, 6, 2, 2, 4, 4, 6 };
                }
                else
                {
                    upsuccess = new short[] { 100, 100, 100, 95, 80, 60, 40, 30, 20, 11 };
                    upfix = new short[] { 0, 0, 10, 15, 20, 20, 20, 20, 15, 10 };
                    goldprice = new[] { 500, 1500, 3000, 10000, 30000, 80000, 150000, 400000, 700000, 1000000 };
                    cella = new short[] { 20, 50, 80, 120, 160, 220, 280, 380, 480, 600 };
                    gem = new short[] { 1, 1, 2, 2, 3, 1, 1, 2, 2, 3 };
                }

                short cellaVnum = 1014;
                short gemVnum = 1015;
                short gemFullVnum = 1016;
                double reducedpricefactor = 0.5;
                short normalScrollVnum = 1218;
                short goldScrollVnum = 5369;

                if (IsFixed)
                {
                    session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("ITEM_IS_FIXED"), 10));
                    session.SendPacket("shop_end 1");
                    return;
                }
                switch (mode)
                {
                    case UpgradeMode.Free:
                        break;

                    case UpgradeMode.Reduced:

                        // TODO: Reduced Item Amount
                        if (session.Character.Gold < (long)(goldprice[Upgrade] * reducedpricefactor))
                        {
                            session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("NOT_ENOUGH_MONEY"), 10));
                            return;
                        }
                        if (session.Character.Inventory.CountItem(cellaVnum) < cella[Upgrade] * reducedpricefactor)
                        {
                            session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey(string.Format("NOT_ENOUGH_ITEMS", ServerManager.GetItem(cellaVnum).Name, cella[Upgrade] * reducedpricefactor)), 10));
                            return;
                        }
                        if (protection == UpgradeProtection.Protected && !isCommand && session.Character.Inventory.CountItem(goldScrollVnum) < 1)
                        {
                            session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey(string.Format("NOT_ENOUGH_ITEMS", ServerManager.GetItem(goldScrollVnum).Name, cella[Upgrade] * reducedpricefactor)), 10));
                            return;
                        }
                        if (Upgrade < 5)
                        {
                            if (session.Character.Inventory.CountItem(gemVnum) < gem[Upgrade])
                            {
                                session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey(string.Format("NOT_ENOUGH_ITEMS", ServerManager.GetItem(gemVnum).Name, gem[Upgrade])), 10));
                                return;
                            }
                            session.Character.Inventory.RemoveItemAmount(gemVnum, gem[Upgrade]);
                        }
                        else
                        {
                            if (session.Character.Inventory.CountItem(gemFullVnum) < gem[Upgrade])
                            {
                                session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey(string.Format("NOT_ENOUGH_ITEMS", ServerManager.GetItem(gemFullVnum).Name, gem[Upgrade])), 10));
                                return;
                            }
                            session.Character.Inventory.RemoveItemAmount(gemFullVnum, gem[Upgrade]);
                        }
                        if (protection == UpgradeProtection.Protected && !isCommand)
                        {
                            session.Character.Inventory.RemoveItemAmount(goldScrollVnum);
                            session.SendPacket("shop_end 2");
                        }
                        session.Character.Gold -= (long)(goldprice[Upgrade] * reducedpricefactor);
                        session.Character.Inventory.RemoveItemAmount(cellaVnum, (int)(cella[Upgrade] * reducedpricefactor));
                        session.SendPacket(session.Character.GenerateGold());
                        break;

                    case UpgradeMode.Normal:

                        // TODO: Normal Item Amount
                        if (session.Character.Inventory.CountItem(cellaVnum) < cella[Upgrade])
                        {
                            return;
                        }
                        if (session.Character.Gold < goldprice[Upgrade])
                        {
                            session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("NOT_ENOUGH_MONEY"), 10));
                            return;
                        }
                        if (protection == UpgradeProtection.Protected && !isCommand && session.Character.Inventory.CountItem(normalScrollVnum) < 1)
                        {
                            session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey(string.Format("NOT_ENOUGH_ITEMS", ServerManager.GetItem(normalScrollVnum).Name, 1)), 10));
                            return;
                        }
                        if (Upgrade < 5)
                        {
                            if (session.Character.Inventory.CountItem(gemVnum) < gem[Upgrade])
                            {
                                session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey(string.Format("NOT_ENOUGH_ITEMS", ServerManager.GetItem(gemVnum).Name, gem[Upgrade])), 10));
                                return;
                            }
                            session.Character.Inventory.RemoveItemAmount(gemVnum, (gem[Upgrade]));
                        }
                        else
                        {
                            if (session.Character.Inventory.CountItem(gemFullVnum) < gem[Upgrade])
                            {
                                session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey(string.Format("NOT_ENOUGH_ITEMS", ServerManager.GetItem(gemFullVnum).Name, gem[Upgrade])), 10));
                                return;
                            }
                            session.Character.Inventory.RemoveItemAmount(gemFullVnum, (gem[Upgrade]));
                        }
                        if (protection == UpgradeProtection.Protected && !isCommand)
                        {
                            session.Character.Inventory.RemoveItemAmount(normalScrollVnum);
                            session.SendPacket("shop_end 2");
                        }
                        session.Character.Inventory.RemoveItemAmount(cellaVnum, (cella[Upgrade]));
                        session.Character.Gold -= goldprice[Upgrade];
                        session.SendPacket(session.Character.GenerateGold());
                        break;
                }
                WearableInstance wearable = session.Character.Inventory.LoadByItemInstance<WearableInstance>(Id);
                ItemInstance inventory = session.Character.Inventory.GetItemInstanceById(Id);

                int rnd = _random.Next(1, 100);

                if (Rare == 8)
                {
                    if (rnd <= upsuccess[Upgrade])
                    {
                        session.CurrentMap.Broadcast(session.Character.GenerateEff(3005), session.Character.MapX, session.Character.MapY);
                        session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("UPGRADE_SUCCESS"), 12));
                        session.SendPacket(session.Character.GenerateMsg(Language.Instance.GetMessageFromKey("UPGRADE_SUCCESS"), 0));
                        wearable.Upgrade++;
                        session.SendPacket(session.Character.GenerateInventoryAdd(ItemVNum, 1, inventory.Type, inventory.Slot, wearable.Rare, 0, wearable.Upgrade, 0));
                    }
                    else if (rnd <= upfix[Upgrade])
                    {
                        session.CurrentMap.Broadcast(session.Character.GenerateEff(3004), session.Character.MapX, session.Character.MapY);
                        wearable.IsFixed = true;
                        session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("UPGRADE_FIXED"), 11));
                        session.SendPacket(session.Character.GenerateMsg(Language.Instance.GetMessageFromKey("UPGRADE_FIXED"), 0));
                    }
                    else
                    {
                        if (protection == UpgradeProtection.None)
                        {
                            session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("UPGRADE_FAILED"), 11));
                            session.SendPacket(session.Character.GenerateMsg(Language.Instance.GetMessageFromKey("UPGRADE_FAILED"), 0));
                            session.Character.DeleteItemByItemInstanceId(Id);
                        }
                        else
                        {
                            session.CurrentMap.Broadcast(session.Character.GenerateEff(3004), session.Character.MapX, session.Character.MapY);
                            session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("SCROLL_PROTECT_USED"), 11));
                            session.SendPacket(session.Character.GenerateMsg(Language.Instance.GetMessageFromKey("UPGRADE_FAILED_ITEM_SAVED"), 0));
                        }
                    }
                }
                else
                {
                    if (rnd <= upfix[Upgrade])
                    {
                        session.CurrentMap.Broadcast(session.Character.GenerateEff(3004), session.Character.MapX, session.Character.MapY);
                        wearable.IsFixed = true;
                        session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("UPGRADE_FIXED"), 11));
                        session.SendPacket(session.Character.GenerateMsg(Language.Instance.GetMessageFromKey("UPGRADE_FIXED"), 0));
                    }
                    else if (rnd <= upsuccess[Upgrade])
                    {
                        session.CurrentMap.Broadcast(session.Character.GenerateEff(3005), session.Character.MapX, session.Character.MapY);
                        session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("UPGRADE_SUCCESS"), 12));
                        session.SendPacket(session.Character.GenerateMsg(Language.Instance.GetMessageFromKey("UPGRADE_SUCCESS"), 0));
                        wearable.Upgrade++;
                        session.SendPacket(session.Character.GenerateInventoryAdd(ItemVNum, 1, inventory.Type, inventory.Slot, wearable.Rare, 0, wearable.Upgrade, 0));
                    }
                    else
                    {
                        if (protection == UpgradeProtection.None)
                        {
                            session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("UPGRADE_FAILED"), 11));
                            session.SendPacket(session.Character.GenerateMsg(Language.Instance.GetMessageFromKey("UPGRADE_FAILED"), 0));
                            session.Character.DeleteItemByItemInstanceId(Id);
                        }
                        else
                        {
                            session.CurrentMap.Broadcast(session.Character.GenerateEff(3004), session.Character.MapX, session.Character.MapY);
                            session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("SCROLL_PROTECT_USED"), 11));
                            session.SendPacket(session.Character.GenerateMsg(Language.Instance.GetMessageFromKey("UPGRADE_FAILED_ITEM_SAVED"), 0));
                        }
                    }
                }
            }
            else
            {
                session.CurrentMap.Broadcast(session.Character.GenerateEff(3004), session.Character.MapX, session.Character.MapY);
                session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("SCROLL_PROTECT_USED"), 11));
                session.SendPacket(session.Character.GenerateMsg(Language.Instance.GetMessageFromKey("UPGRADE_FAILED_ITEM_SAVED"), 0));
            }
            session.SendPacket("shop_end 1");
        }
        public override void Use(ClientSession session, ref ItemInstance inv, byte option = 0, string[] packetsplit = null)
        {
            switch (Effect)
            {
            case 10:
            {
                switch (EffectValue)
                {
                case 1:
                    if (session.Character.Inventory.CountItem(1036) < 1 || session.Character.Inventory.CountItem(1013) < 1)
                    {
                        return;
                    }
                    session.Character.Inventory.RemoveItemAmount(1036);
                    session.Character.Inventory.RemoveItemAmount(1013);
                    if (ServerManager.RandomNumber() < 25)
                    {
                        switch (ServerManager.RandomNumber(0, 2))
                        {
                        case 0:
                            session.Character.GiftAdd(1015, 1);
                            break;

                        case 1:
                            session.Character.GiftAdd(1016, 1);
                            break;
                        }
                    }
                    break;

                case 2:
                    if (session.Character.Inventory.CountItem(1038) < 1 || session.Character.Inventory.CountItem(1013) < 1)
                    {
                        return;
                    }
                    session.Character.Inventory.RemoveItemAmount(1038);
                    session.Character.Inventory.RemoveItemAmount(1013);
                    if (ServerManager.RandomNumber() < 25)
                    {
                        switch (ServerManager.RandomNumber(0, 4))
                        {
                        case 0:
                            session.Character.GiftAdd(1031, 1);
                            break;

                        case 1:
                            session.Character.GiftAdd(1032, 1);
                            break;

                        case 2:
                            session.Character.GiftAdd(1033, 1);
                            break;

                        case 3:
                            session.Character.GiftAdd(1034, 1);
                            break;
                        }
                    }
                    break;

                case 573:
                {
                    int rnd = ServerManager.RandomNumber(0, 100);
                    {
                        short[] vnums =
                        {
                            573     //15x
                        };

                        byte[] counts =
                        {
                            1
                        };
                        int item = ServerManager.RandomNumber(0, 1);

                        session.Character.GiftAdd(vnums[ServerManager.RandomNumber(0, 1)], 1, 8, 90);
                        session.SendPacket($"rdi {vnums[item]} {counts[item]}");
                    }
                    session.Character.Inventory.RemoveItemFromInventory(inv.Id);
                }


                break;

                // Shell Armor
                case 585:
                {
                    int rnd = ServerManager.RandomNumber(0, 100);
                    {
                        short[] vnums =
                        {
                            585     //15x
                        };

                        byte[] counts =
                        {
                            1
                        };
                        int item = ServerManager.RandomNumber(0, 1);

                        session.Character.GiftAdd(vnums[ServerManager.RandomNumber(0, 1)], 1, 8, 90);
                        session.SendPacket($"rdi {vnums[item]} {counts[item]}");
                    }
                    session.Character.Inventory.RemoveItemFromInventory(inv.Id);
                }

                break;

                case 3:
                    if (session.Character.Inventory.CountItem(1037) < 1 || session.Character.Inventory.CountItem(1013) < 1)
                    {
                        return;
                    }
                    session.Character.Inventory.RemoveItemAmount(1037);
                    session.Character.Inventory.RemoveItemAmount(1013);
                    if (ServerManager.RandomNumber() < 25)
                    {
                        switch (ServerManager.RandomNumber(0, 17))
                        {
                        case 0:
                        case 1:
                        case 2:
                        case 3:
                        case 4:
                            session.Character.GiftAdd(1017, 1);
                            break;

                        case 5:
                        case 6:
                        case 7:
                        case 8:
                            session.Character.GiftAdd(1018, 1);
                            break;

                        case 9:
                        case 10:
                        case 11:
                            session.Character.GiftAdd(1019, 1);
                            break;

                        case 12:
                        case 13:
                            session.Character.GiftAdd(1020, 1);
                            break;

                        case 14:
                            session.Character.GiftAdd(1021, 1);
                            break;

                        case 15:
                            session.Character.GiftAdd(1022, 1);
                            break;

                        case 16:
                            session.Character.GiftAdd(1023, 1);
                            break;
                        }
                    }
                    break;
                }

                session.Character.GiftAdd(1014, (byte)ServerManager.RandomNumber(5, 11));
            }
            break;

            default:
                if (!OpenBoxItem(session, inv))
                {
                    Logger.Warn(string.Format(Language.Instance.GetMessageFromKey("NO_HANDLER_ITEM"), GetType(),
                                              VNum, Effect, EffectValue));
                }
                break;
            }
        }
예제 #40
0
 public override void Use(ClientSession session, ref ItemInstance inv, bool delay = false, string[] packetsplit = null)
 {
     if ((DateTime.Now - session.Character.LastPotion).TotalMilliseconds < 750)
     {
         return;
     }
     else
     {
         session.Character.LastPotion = DateTime.Now;
     }
     switch (Effect)
     {
         default:
             if (session.Character.Hp == session.Character.HPLoad() && session.Character.Mp == session.Character.MPLoad())
             {
                 return;
             }
             if (session.Character.Hp <= 0)
             {
                 return;
             }
             session.Character.Inventory.RemoveItemAmountFromInventory(1, inv.Id);
             if ((int)session.Character.HPLoad() - session.Character.Hp < Hp)
             {
                 session.CurrentMap?.Broadcast(session.Character.GenerateRc((int)session.Character.HPLoad() - session.Character.Hp));
             }
             else if ((int)session.Character.HPLoad() - session.Character.Hp > Hp)
             {
                 session.CurrentMap?.Broadcast(session.Character.GenerateRc(Hp));
             }
             session.Character.Mp += Mp;
             session.Character.Hp += Hp;
             if (session.Character.Mp > session.Character.MPLoad())
             {
                 session.Character.Mp = (int)session.Character.MPLoad();
             }
             if (session.Character.Hp > session.Character.HPLoad())
             {
                 session.Character.Hp = (int)session.Character.HPLoad();
             }
             if (inv.ItemVNum == 1242 || inv.ItemVNum == 5582)
             {
                 session.CurrentMap?.Broadcast(session.Character.GenerateRc((int)session.Character.HPLoad() - session.Character.Hp));
                 session.Character.Hp = (int)session.Character.HPLoad();
             }
             else if (inv.ItemVNum == 1243 || inv.ItemVNum == 5583)
             {
                 session.Character.Mp = (int)session.Character.MPLoad();
             }
             else if (inv.ItemVNum == 1244 || inv.ItemVNum == 5584)
             {
                 session.CurrentMap?.Broadcast(session.Character.GenerateRc((int)session.Character.HPLoad() - session.Character.Hp));
                 session.Character.Hp = (int)session.Character.HPLoad();
                 session.Character.Mp = (int)session.Character.MPLoad();
             }
             session.SendPacket(session.Character.GenerateStat());
             break;
     }
 }
예제 #41
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.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.HoldingVNum == 0)
                        {
                            if (packetsplit.Length == 1)
                            {
                                int PetId;
                                if (int.TryParse(packetsplit[0], out 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
                        {
                            Mate mate = new Mate(session.Character, (short)box.HoldingVNum, 1, MateType.Pet);
                            mate.Attack  = box.SpDamage;
                            mate.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
                {
                    if (session.CurrentMapInstance == session.Character.Miniland)
                    {
                        Mate mate = new Mate(session.Character, (short)EffectValue, 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())
                            {
                                SpecialistInstance specialist = session.Character.Inventory.LoadBySlotAndType <SpecialistInstance>(newInv.First().Slot, newInv.First().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())
                            {
                                WearableInstance fairy = session.Character.Inventory.LoadBySlotAndType <WearableInstance>(newInv.First().Slot, newInv.First().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;
            }
        }
예제 #42
0
        public override void Use(ClientSession session, ref ItemInstance inv, bool delay = false, string[] packetsplit = null)
        {
            if (Effect == 0)
            {
                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 (delay)
                            {
                                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:
                                    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;
                                            if (session.Character.SpPoint > 10000)
                                            {
                                                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
                                {
                                    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"), this.GetType().ToString()));
            }
        }
예제 #43
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 (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);
                }

                Session.CurrentMap.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.SendPacket(Session.Character.GenerateInventoryAdd(ItemVNum, Amount, InventoryType.Equipment, Slot, Rare, Design, Upgrade, SpStoneUpgrade));
            Session.Character.Gold -= goldprice[upmode - 1];
            Session.SendPacket(Session.Character.GenerateGold());
            Session.Character.Inventory.RemoveItemAmount(stonevnum, stoneprice[upmode - 1]);
            Session.SendPacket("shop_end 1");
        }