Esempio n. 1
0
        private void ExecuteHandler(ClientSession session)
        {
            if (!session.HasCurrentMapInstance)
            {
                return;
            }

            if (Type == 1)
            {
                // User Shop
                KeyValuePair <long, MapShop> shopList = session.CurrentMapInstance.UserShops.FirstOrDefault(s => s.Value.OwnerId.Equals(OwnerId));
                session.LoadShopItem(OwnerId, shopList);
            }
            else
            {
                // Npc Shop , ignore if has drop
                MapNpc npc = session.CurrentMapInstance.Npcs.Find(n => n.MapNpcId.Equals((int)OwnerId));
                if (npc == null)
                {
                    return;
                }

                session.Character.OnTalk(new TalkEventArgs(npc));

                if (npc.Npc.Drops.Any(s => s.MonsterVNum != null) && npc.Npc.Race == 8 &&
                    (npc.Npc.RaceType == 7 || npc.Npc.RaceType == 5))
                {
                    session.SendPacket(UserInterfaceHelper.GenerateDelay(5000, 4, $"#guri^400^{npc.MapNpcId}"));
                }
                else if (npc.Npc.VNumRequired > 0 && npc.Npc.Race == 8 &&
                         (npc.Npc.RaceType == 7 || npc.Npc.RaceType == 5))
                {
                    session.SendPacket(UserInterfaceHelper.GenerateDelay(6000, 4, $"#guri^400^{npc.MapNpcId}"));
                }
                else if (npc.Npc.MaxHP == 0 && npc.Npc.Drops.All(s => s.MonsterVNum == null) && npc.Npc.Race == 8 &&
                         (npc.Npc.RaceType == 7 || npc.Npc.RaceType == 5))
                {
                    session.SendPacket(UserInterfaceHelper.GenerateDelay(5000, 1,
                                                                         $"#guri^710^{npc.MapX}^{npc.MapY}^{npc.MapNpcId}")); // #guri^710^DestinationX^DestinationY^MapNpcId
                }
                else if (!string.IsNullOrEmpty(npc.GetNpcDialog()))
                {
                    session.SendPacket(npc.GetNpcDialog());
                }
            }
        }
Esempio n. 2
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 (inv.ItemVNum == 2539 || inv.ItemVNum == 10066)//Cuarry Bank Money Card
            {
                if (session.Character.MapInstance.MapInstanceType != MapInstanceType.NormalInstance || session.Character.MapInstance.MapInstanceType != MapInstanceType.BaseMapInstance)
                {
                    return;
                }

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

            switch (Effect)
            {
            // airwaves - eventitems
            case 0:
                if (inv.Item.ItemType == ItemType.Shell)
                {
                    if (!(inv).ShellEffects.Any())
                    {
                        session.SendPacket(UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("SHELL_MUST_BE_IDENTIFIED"), 0));
                        return;
                    }

                    if (packetsplit?.Length < 9)
                    {
                        return;
                    }

                    if (!int.TryParse(packetsplit[6], out int requestType))
                    {
                        return;
                    }
                    if (!Enum.TryParse(packetsplit[8], out InventoryType eqType))
                    {
                        return;
                    }

                    if (inv.ShellEffects.Count != 0 && packetsplit?.Length > 9 && byte.TryParse(packetsplit[9], out byte islot))
                    {
                        ItemInstance wearable = session.Character.Inventory.LoadBySlotAndType(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)
                        {
                            switch (requestType)
                            {
                            case 0:
                                session.SendPacket(wearable.ShellEffects.Any()
                                            ? $"qna #u_i^1^{session.Character.CharacterId}^{(short)inv.Type}^{inv.Slot}^1^1^{(short)eqType}^{islot} {Language.Instance.GetMessageFromKey("ADD_OPTION_ON_STUFF_NOT_EMPTY")}"
                                            : $"qna #u_i^1^{session.Character.CharacterId}^{(short)inv.Type}^{inv.Slot}^1^1^{(short)eqType}^{islot} {Language.Instance.GetMessageFromKey("ADD_OPTION_ON_STUFF")}");
                                break;

                            case 1:

                                if (inv.ShellEffects == null)
                                {
                                    return;
                                }
                                if (wearable.BoundCharacterId != session.Character.CharacterId && wearable.BoundCharacterId != null)
                                {
                                    session.SendPacket(UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("NEED_FRAGANCE"), 0));
                                    return;
                                }
                                if (wearable.Rare < inv.Rare)
                                {
                                    session.SendPacket(UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("SHELL_RARITY_TOO_HIGH"), 0));
                                    return;
                                }
                                if (wearable.Item.LevelMinimum < inv.Upgrade)
                                {
                                    session.SendPacket(UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("SHELL_LEVEL_TOO_HIGH"), 0));
                                    return;
                                }

                                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_FAIL"), 0));
                                        return;
                                    }
                                    wearable.BoundCharacterId = session.Character.CharacterId;
                                    wearable.ShellRarity      = inv.Rare;
                                    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_SUCCESS"), 0));
                                }
                                if (ItemType == ItemType.Magical)
                                {
                                    switch (VNum)
                                    {
                                    // Bank Card
                                    case 2539:
                                    case 10066:
                                        if (session.Character.MapInstance.MapInstanceType != MapInstanceType.BaseMapInstance)
                                        {
                                            return;
                                        }

                                        session.Character.OpenBank();
                                        session.Character.Inventory.RemoveItemFromInventory(inv.Id);
                                        return;
                                    }
                                }
                                break;
                            }
                        }
                    }
                    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.PositionX, session.Character.PositionY);
                    }
                    session.Character.Inventory.RemoveItemFromInventory(inv.Id);
                }
                break;

            //respawn objects
            case 1:
                if (session.Character.MapInstance.MapInstanceType != MapInstanceType.BaseMapInstance || session.Character.IsSeal)
                {
                    session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("CANT_USE_THAT"), 10));
                    return;
                }
                int type, secondaryType, inventoryType, slot;
                if (packetsplit?.Length > 6 && 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 (inv.ItemVNum != 2070 && inv.ItemVNum != 10010 || (session.CurrentMapInstance.Map.MapTypes.Any(m => m.MapTypeId == (short)MapTypeEnum.Act51 || m.MapTypeId == (short)MapTypeEnum.Act52)))
                        {
                            return;
                        }
                        if (Option == 0)
                        {
                            if (ServerManager.Instance.ChannelId == 51)
                            {
                                session.SendPacket(UserInterfaceHelper.GenerateDialog($"#u_i^{type}^{secondaryType}^{inventoryType}^{slot}^2 #u_i^{type}^{secondaryType}^{inventoryType}^{slot}^0 {Language.Instance.GetMessageFromKey("WANT_TO_GO_BASE")}"));
                            }
                            else
                            {
                                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)
                                {
                                    MapCell mapCell = new MapCell();
                                    for (int i = 0; i < 5; i++)
                                    {
                                        mapCell.X = (short)(respawn.DefaultX + ServerManager.RandomNumber(-3, 3));
                                        mapCell.Y = (short)(respawn.DefaultY + ServerManager.RandomNumber(-3, 3));
                                        if (ServerManager.GetMapInstanceByMapId(respawn.DefaultMapId) is MapInstance GoToMap)
                                        {
                                            if (!GoToMap.Map.IsBlockedZone(mapCell.X, mapCell.Y))
                                            {
                                                break;
                                            }
                                        }
                                    }
                                    ServerManager.Instance.ChangeMap(session.Character.CharacterId, respawn.DefaultMapId, mapCell.X, mapCell.Y);
                                }
                                session.Character.Inventory.RemoveItemFromInventory(inv.Id);
                                break;

                            case 4:
                                RespawnMapTypeDTO respawnObj = session.Character.Respawn;
                                if (ServerManager.Instance.ChannelId == 51)
                                {
                                    respawnObj.DefaultMapId = (short)(129 + session.Character.Faction);
                                    respawnObj.DefaultX     = 41;
                                    respawnObj.DefaultY     = 42;
                                }
                                if (respawnObj.DefaultX != 0 && respawnObj.DefaultY != 0 && respawnObj.DefaultMapId != 0)
                                {
                                    MapCell mapCell = new MapCell();
                                    for (int i = 0; i < 5; i++)
                                    {
                                        mapCell.X = (short)(respawnObj.DefaultX + ServerManager.RandomNumber(-3, 3));
                                        mapCell.Y = (short)(respawnObj.DefaultY + ServerManager.RandomNumber(-3, 3));
                                        if (ServerManager.GetMapInstanceByMapId(respawnObj.DefaultMapId) is MapInstance GoToMap)
                                        {
                                            if (!GoToMap.Map.IsBlockedZone(mapCell.X, mapCell.Y))
                                            {
                                                break;
                                            }
                                        }
                                    }
                                    ServerManager.Instance.ChangeMap(session.Character.CharacterId, respawnObj.DefaultMapId, mapCell.X, mapCell.Y);
                                }
                                session.Character.Inventory.RemoveItemFromInventory(inv.Id);
                                break;
                            }
                        }
                        break;

                    case 1:
                        if (inv.ItemVNum != 2071 && inv.ItemVNum != 10011)
                        {
                            return;
                        }
                        if (int.TryParse(packetsplit[6], out packetType))
                        {
                            if (ServerManager.Instance.ChannelId == 51)
                            {
                                session.SendPacket(UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("CANNOT_USE"), 10));
                                return;
                            }
                            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 (inv.ItemVNum != 2072 && inv.ItemVNum != 10012)
                        {
                            return;
                        }
                        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 4:
                        if (inv.ItemVNum != 2188 || session.Character.MapInstance.Map.MapTypes.Any(s => s.MapTypeId == (short)MapTypeEnum.Act4))
                        {
                            return;
                        }
                        if (Option == 0)
                        {
                            session.SendPacket(UserInterfaceHelper.GenerateDelay(5000, 7, $"#u_i^{type}^{secondaryType}^{inventoryType}^{slot}^1"));
                        }
                        else
                        {
                            ServerManager.Instance.ChangeMap(session.Character.CharacterId, 98, 28, 34);
                            session.Character.Inventory.RemoveItemFromInventory(inv.Id);
                        }
                        break;

                    case 5:
                        if (inv.ItemVNum != 2311 || ServerManager.Instance.ChannelId != 51)
                        {
                            return;
                        }
                        if (ServerManager.GetAllMapInstances().SelectMany(s => s.Monsters.ToList()).LastOrDefault(s => s.MonsterVNum == (short)session.Character.Faction + 964) is MapMonster flag)
                        {
                            if (Option == 0)
                            {
                                session.SendPacket(UserInterfaceHelper.GenerateDelay(5000, 7, $"#u_i^{type}^{secondaryType}^{inventoryType}^{slot}^1"));
                            }
                            else
                            {
                                ServerManager.Instance.ChangeMapInstance(session.Character.CharacterId, flag.MapInstance.MapInstanceId, flag.MapX, flag.MapY);
                                session.Character.Inventory.RemoveItemFromInventory(inv.Id);
                            }
                        }
                        break;

                    case 6:
                        if (inv.ItemVNum != 2384 || ServerManager.Instance.ChannelId == 51 || session.CurrentMapInstance.MapInstanceType != MapInstanceType.BaseMapInstance)
                        {
                            return;
                        }
                        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:
                                if (session.CurrentMapInstance.Map.MapTypes.Any(s => s.MapTypeId == (short)MapTypeEnum.Act51 || s.MapTypeId == (short)MapTypeEnum.Act52))
                                {
                                    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)
                                    {
                                        MapCell mapCell = new MapCell();
                                        for (int i = 0; i < 5; i++)
                                        {
                                            mapCell.X = (short)(respawn.DefaultX + ServerManager.RandomNumber(-3, 3));
                                            mapCell.Y = (short)(respawn.DefaultY + ServerManager.RandomNumber(-3, 3));
                                            if (ServerManager.GetMapInstanceByMapId(respawn.DefaultMapId) is MapInstance GoToMap)
                                            {
                                                if (!GoToMap.Map.IsBlockedZone(mapCell.X, mapCell.Y))
                                                {
                                                    break;
                                                }
                                            }
                                        }
                                        ServerManager.Instance.ChangeMap(session.Character.CharacterId, respawn.DefaultMapId, mapCell.X, mapCell.Y);
                                    }
                                    session.Character.Inventory.RemoveItemFromInventory(inv.Id);
                                }
                                else
                                {
                                    goto case 4;
                                }
                                break;

                            case 4:
                                MapInstance mapInstanceBackup = session.CurrentMapInstance;
                                session.CurrentMapInstance = ServerManager.GetMapInstanceByMapId(170);
                                RespawnMapTypeDTO respawnObj = session.Character.Respawn;
                                session.CurrentMapInstance = mapInstanceBackup;
                                if (ServerManager.Instance.ChannelId == 51)
                                {
                                    respawnObj.DefaultMapId = (short)(129 + session.Character.Faction);
                                    respawnObj.DefaultX     = 41;
                                    respawnObj.DefaultY     = 42;
                                }
                                if (respawnObj.DefaultX != 0 && respawnObj.DefaultY != 0 && respawnObj.DefaultMapId != 0)
                                {
                                    MapCell mapCell = new MapCell();
                                    for (int i = 0; i < 5; i++)
                                    {
                                        mapCell.X = (short)(respawnObj.DefaultX + ServerManager.RandomNumber(-3, 3));
                                        mapCell.Y = (short)(respawnObj.DefaultY + ServerManager.RandomNumber(-3, 3));
                                        if (ServerManager.GetMapInstanceByMapId(respawnObj.DefaultMapId) is MapInstance GoToMap)
                                        {
                                            if (!GoToMap.Map.IsBlockedZone(mapCell.X, mapCell.Y))
                                            {
                                                break;
                                            }
                                        }
                                    }
                                    ServerManager.Instance.ChangeMap(session.Character.CharacterId, respawnObj.DefaultMapId, mapCell.X, mapCell.Y);
                                }
                                session.Character.Inventory.RemoveItemFromInventory(inv.Id);
                                break;
                            }
                        }
                        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 && (VNum < 2130 || VNum > 2162) && (VNum < 10025 || VNum > 10026))
                        {
                            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;

            // TS npcs health
            case 12:
                if (EffectValue > 0)
                {
                    if (session.Character.Timespace != null)
                    {
                        session.Character.MapInstance.GetBattleEntitiesInRange(new MapCell {
                            X = session.Character.PositionX, Y = session.Character.PositionY
                        }, 6)
                        .Where(s => (s.MapNpc != null || (s.Mate != null && s.Mate.IsTemporalMate)) && !session.Character.BattleEntity.CanAttackEntity(s)).ToList()
                        .ForEach(s =>
                        {
                            int health = EffectValue;
                            if (s.Hp + EffectValue > s.HpMax)
                            {
                                health = s.HpMax - s.Hp;
                            }
                            s.Hp += health;
                            session.Character.MapInstance.Broadcast(s.GenerateRc(health));
                            s.Mate?.Owner.Session.SendPacket(s.Mate.GenerateStatInfo());
                        });
                        session.Character.Inventory.RemoveItemFromInventory(inv.Id);
                        session.SendPacket(StaticPacketHelper.GenerateEff(UserType.Player, session.Character.CharacterId, 48));
                    }
                }
                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(InEffect: 1), 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(InEffect: 1), 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;

            // Passive skills books
            case 99:
                if (session.Character.HeroLevel >= EffectValue)
                {
                    if (session.Character.AddSkill((short)(Sex + 1)))
                    {
                        session.SendPacket(session.Character.GenerateSki());
                        session.Character.Inventory.RemoveItemFromInventory(inv.Id);
                    }
                }
                else
                {
                    session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("LOW_HERO_LVL"), 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.Sessions.GetAllItems())
                    {
                        Observable.Timer(TimeSpan.FromMilliseconds(delay)).Subscribe(o =>
                        {
                            if (sess?.Character != null && session?.CurrentMapInstance != null && session?.Character != null && sess.Character != session.Character)
                            {
                                ServerManager.Instance.TeleportOnRandomPlaceInMap(sess, session.CurrentMapInstance.MapInstanceId);
                            }
                        });
                        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;
            }
        }
Esempio n. 3
0
        private void ExecuteHandler(ClientSession session)
        {
            ItemInstance specialistInstance =
                session.Character.Inventory.LoadBySlotAndType((byte)EquipmentType.Sp, InventoryType.Wear);

            if (Type == 10)
            {
                short specialistDamage     = SpecialistDamage,
                      specialistDefense    = SpecialistDefense,
                      specialistElement    = SpecialistElement,
                      specialistHealpoints = SpecialistHP;
                int transportId            = TransportId;
                if (!session.Character.UseSp || specialistInstance == null ||
                    transportId != specialistInstance.TransportId)
                {
                    session.SendPacket(
                        UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("SPUSE_NEEDED"), 0));
                    return;
                }

                if (CharacterHelper.SpPoint(specialistInstance.SpLevel, specialistInstance.Upgrade)
                    - specialistInstance.SlDamage - specialistInstance.SlHP - specialistInstance.SlElement
                    - specialistInstance.SlDefence - specialistDamage - specialistDefense - specialistElement
                    - specialistHealpoints < 0)
                {
                    return;
                }

                if (specialistDamage < 0 || specialistDefense < 0 || specialistElement < 0 ||
                    specialistHealpoints < 0)
                {
                    return;
                }

                specialistInstance.SlDamage  += specialistDamage;
                specialistInstance.SlDefence += specialistDefense;
                specialistInstance.SlElement += specialistElement;
                specialistInstance.SlHP      += specialistHealpoints;

                ItemInstance mainWeapon =
                    session.Character.Inventory.LoadBySlotAndType((byte)EquipmentType.MainWeapon,
                                                                  InventoryType.Wear);
                ItemInstance secondaryWeapon =
                    session.Character.Inventory.LoadBySlotAndType((byte)EquipmentType.MainWeapon,
                                                                  InventoryType.Wear);
                List <ShellEffectDTO> effects = new List <ShellEffectDTO>();
                if (mainWeapon?.ShellEffects != null)
                {
                    effects.AddRange(mainWeapon.ShellEffects);
                }

                if (secondaryWeapon?.ShellEffects != null)
                {
                    effects.AddRange(secondaryWeapon.ShellEffects);
                }

                int GetShellWeaponEffectValue(ShellWeaponEffectType effectType)
                {
                    return(effects.Where(s => s.Effect == (byte)effectType).OrderByDescending(s => s.Value)
                           .FirstOrDefault()?.Value ?? 0);
                }

                int slElement = CharacterHelper.SlPoint(specialistInstance.SlElement, 2)
                                + GetShellWeaponEffectValue(ShellWeaponEffectType.SlElement)
                                + GetShellWeaponEffectValue(ShellWeaponEffectType.SlGlobal);
                int slHp = CharacterHelper.SlPoint(specialistInstance.SlHP, 3)
                           + GetShellWeaponEffectValue(ShellWeaponEffectType.Slhp)
                           + GetShellWeaponEffectValue(ShellWeaponEffectType.SlGlobal);
                int slDefence = CharacterHelper.SlPoint(specialistInstance.SlDefence, 1)
                                + GetShellWeaponEffectValue(ShellWeaponEffectType.SlDefence)
                                + GetShellWeaponEffectValue(ShellWeaponEffectType.SlGlobal);
                int slHit = CharacterHelper.SlPoint(specialistInstance.SlDamage, 0)
                            + GetShellWeaponEffectValue(ShellWeaponEffectType.SlDamage)
                            + GetShellWeaponEffectValue(ShellWeaponEffectType.SlGlobal);

                #region slHit

                specialistInstance.DamageMinimum        = 0;
                specialistInstance.DamageMaximum        = 0;
                specialistInstance.HitRate              = 0;
                specialistInstance.CriticalLuckRate     = 0;
                specialistInstance.CriticalRate         = 0;
                specialistInstance.DefenceDodge         = 0;
                specialistInstance.DistanceDefenceDodge = 0;
                specialistInstance.ElementRate          = 0;
                specialistInstance.DarkResistance       = 0;
                specialistInstance.LightResistance      = 0;
                specialistInstance.FireResistance       = 0;
                specialistInstance.WaterResistance      = 0;
                specialistInstance.CriticalDodge        = 0;
                specialistInstance.CloseDefence         = 0;
                specialistInstance.DistanceDefence      = 0;
                specialistInstance.MagicDefence         = 0;
                specialistInstance.HP = 0;
                specialistInstance.MP = 0;

                if (slHit >= 1)
                {
                    specialistInstance.DamageMinimum += 5;
                    specialistInstance.DamageMaximum += 5;
                }

                if (slHit >= 10)
                {
                    specialistInstance.HitRate += 10;
                }

                if (slHit >= 20)
                {
                    specialistInstance.CriticalLuckRate += 2;
                }

                if (slHit >= 30)
                {
                    specialistInstance.DamageMinimum += 5;
                    specialistInstance.DamageMaximum += 5;
                    specialistInstance.HitRate       += 10;
                }

                if (slHit >= 40)
                {
                    specialistInstance.CriticalRate += 10;
                }

                if (slHit >= 50)
                {
                    specialistInstance.HP += 200;
                    specialistInstance.MP += 200;
                }

                if (slHit >= 60)
                {
                    specialistInstance.HitRate += 15;
                }

                if (slHit >= 70)
                {
                    specialistInstance.HitRate       += 15;
                    specialistInstance.DamageMinimum += 5;
                    specialistInstance.DamageMaximum += 5;
                }

                if (slHit >= 80)
                {
                    specialistInstance.CriticalLuckRate += 3;
                }

                if (slHit >= 90)
                {
                    specialistInstance.CriticalRate += 20;
                }

                if (slHit >= 100)
                {
                    specialistInstance.CriticalLuckRate += 3;
                    specialistInstance.CriticalRate     += 20;
                    specialistInstance.HP            += 200;
                    specialistInstance.MP            += 200;
                    specialistInstance.DamageMinimum += 5;
                    specialistInstance.DamageMaximum += 5;
                    specialistInstance.HitRate       += 20;
                }

                #endregion

                #region slDefence

                if (slDefence >= 10)
                {
                    specialistInstance.DefenceDodge         += 5;
                    specialistInstance.DistanceDefenceDodge += 5;
                }

                if (slDefence >= 20)
                {
                    specialistInstance.CriticalDodge += 2;
                }

                if (slDefence >= 30)
                {
                    specialistInstance.HP += 100;
                }

                if (slDefence >= 40)
                {
                    specialistInstance.CriticalDodge += 2;
                }

                if (slDefence >= 50)
                {
                    specialistInstance.DefenceDodge         += 5;
                    specialistInstance.DistanceDefenceDodge += 5;
                }

                if (slDefence >= 60)
                {
                    specialistInstance.HP += 200;
                }

                if (slDefence >= 70)
                {
                    specialistInstance.CriticalDodge += 3;
                }

                if (slDefence >= 75)
                {
                    specialistInstance.FireResistance  += 2;
                    specialistInstance.WaterResistance += 2;
                    specialistInstance.LightResistance += 2;
                    specialistInstance.DarkResistance  += 2;
                }

                if (slDefence >= 80)
                {
                    specialistInstance.DefenceDodge         += 10;
                    specialistInstance.DistanceDefenceDodge += 10;
                    specialistInstance.CriticalDodge        += 3;
                }

                if (slDefence >= 90)
                {
                    specialistInstance.FireResistance  += 3;
                    specialistInstance.WaterResistance += 3;
                    specialistInstance.LightResistance += 3;
                    specialistInstance.DarkResistance  += 3;
                }

                if (slDefence >= 95)
                {
                    specialistInstance.HP += 300;
                }

                if (slDefence >= 100)
                {
                    specialistInstance.DefenceDodge         += 20;
                    specialistInstance.DistanceDefenceDodge += 20;
                    specialistInstance.FireResistance       += 5;
                    specialistInstance.WaterResistance      += 5;
                    specialistInstance.LightResistance      += 5;
                    specialistInstance.DarkResistance       += 5;
                }

                #endregion

                #region slHp

                if (slHp >= 5)
                {
                    specialistInstance.DamageMinimum += 5;
                    specialistInstance.DamageMaximum += 5;
                }

                if (slHp >= 10)
                {
                    specialistInstance.DamageMinimum += 5;
                    specialistInstance.DamageMaximum += 5;
                }

                if (slHp >= 15)
                {
                    specialistInstance.DamageMinimum += 5;
                    specialistInstance.DamageMaximum += 5;
                }

                if (slHp >= 20)
                {
                    specialistInstance.DamageMinimum   += 5;
                    specialistInstance.DamageMaximum   += 5;
                    specialistInstance.CloseDefence    += 10;
                    specialistInstance.DistanceDefence += 10;
                    specialistInstance.MagicDefence    += 10;
                }

                if (slHp >= 25)
                {
                    specialistInstance.DamageMinimum += 5;
                    specialistInstance.DamageMaximum += 5;
                }

                if (slHp >= 30)
                {
                    specialistInstance.DamageMinimum += 5;
                    specialistInstance.DamageMaximum += 5;
                }

                if (slHp >= 35)
                {
                    specialistInstance.DamageMinimum += 5;
                    specialistInstance.DamageMaximum += 5;
                }

                if (slHp >= 40)
                {
                    specialistInstance.DamageMinimum   += 5;
                    specialistInstance.DamageMaximum   += 5;
                    specialistInstance.CloseDefence    += 15;
                    specialistInstance.DistanceDefence += 15;
                    specialistInstance.MagicDefence    += 15;
                }

                if (slHp >= 45)
                {
                    specialistInstance.DamageMinimum += 10;
                    specialistInstance.DamageMaximum += 10;
                }

                if (slHp >= 50)
                {
                    specialistInstance.DamageMinimum   += 10;
                    specialistInstance.DamageMaximum   += 10;
                    specialistInstance.FireResistance  += 2;
                    specialistInstance.WaterResistance += 2;
                    specialistInstance.LightResistance += 2;
                    specialistInstance.DarkResistance  += 2;
                }

                if (slHp >= 55)
                {
                    specialistInstance.DamageMinimum += 10;
                    specialistInstance.DamageMaximum += 10;
                }

                if (slHp >= 60)
                {
                    specialistInstance.DamageMinimum += 10;
                    specialistInstance.DamageMaximum += 10;
                }

                if (slHp >= 65)
                {
                    specialistInstance.DamageMinimum += 10;
                    specialistInstance.DamageMaximum += 10;
                }

                if (slHp >= 70)
                {
                    specialistInstance.DamageMinimum   += 10;
                    specialistInstance.DamageMaximum   += 10;
                    specialistInstance.CloseDefence    += 20;
                    specialistInstance.DistanceDefence += 20;
                    specialistInstance.MagicDefence    += 20;
                }

                if (slHp >= 75)
                {
                    specialistInstance.DamageMinimum += 15;
                    specialistInstance.DamageMaximum += 15;
                }

                if (slHp >= 80)
                {
                    specialistInstance.DamageMinimum += 15;
                    specialistInstance.DamageMaximum += 15;
                }

                if (slHp >= 85)
                {
                    specialistInstance.DamageMinimum += 15;
                    specialistInstance.DamageMaximum += 15;
                    specialistInstance.CriticalDodge++;
                }

                if (slHp >= 86)
                {
                    specialistInstance.CriticalDodge++;
                }

                if (slHp >= 87)
                {
                    specialistInstance.CriticalDodge++;
                }

                if (slHp >= 88)
                {
                    specialistInstance.CriticalDodge++;
                }

                if (slHp >= 90)
                {
                    specialistInstance.DamageMinimum   += 15;
                    specialistInstance.DamageMaximum   += 15;
                    specialistInstance.CloseDefence    += 25;
                    specialistInstance.DistanceDefence += 25;
                    specialistInstance.MagicDefence    += 25;
                }

                if (slHp >= 91)
                {
                    specialistInstance.DefenceDodge         += 2;
                    specialistInstance.DistanceDefenceDodge += 2;
                }

                if (slHp >= 92)
                {
                    specialistInstance.DefenceDodge         += 2;
                    specialistInstance.DistanceDefenceDodge += 2;
                }

                if (slHp >= 93)
                {
                    specialistInstance.DefenceDodge         += 2;
                    specialistInstance.DistanceDefenceDodge += 2;
                }

                if (slHp >= 94)
                {
                    specialistInstance.DefenceDodge         += 2;
                    specialistInstance.DistanceDefenceDodge += 2;
                }

                if (slHp >= 95)
                {
                    specialistInstance.DamageMinimum        += 20;
                    specialistInstance.DamageMaximum        += 20;
                    specialistInstance.DefenceDodge         += 2;
                    specialistInstance.DistanceDefenceDodge += 2;
                }

                if (slHp >= 96)
                {
                    specialistInstance.DefenceDodge         += 2;
                    specialistInstance.DistanceDefenceDodge += 2;
                }

                if (slHp >= 97)
                {
                    specialistInstance.DefenceDodge         += 2;
                    specialistInstance.DistanceDefenceDodge += 2;
                }

                if (slHp >= 98)
                {
                    specialistInstance.DefenceDodge         += 2;
                    specialistInstance.DistanceDefenceDodge += 2;
                }

                if (slHp >= 99)
                {
                    specialistInstance.DefenceDodge         += 2;
                    specialistInstance.DistanceDefenceDodge += 2;
                }

                if (slHp >= 100)
                {
                    specialistInstance.FireResistance       += 3;
                    specialistInstance.WaterResistance      += 3;
                    specialistInstance.LightResistance      += 3;
                    specialistInstance.DarkResistance       += 3;
                    specialistInstance.CloseDefence         += 30;
                    specialistInstance.DistanceDefence      += 30;
                    specialistInstance.MagicDefence         += 30;
                    specialistInstance.DamageMinimum        += 20;
                    specialistInstance.DamageMaximum        += 20;
                    specialistInstance.DefenceDodge         += 2;
                    specialistInstance.DistanceDefenceDodge += 2;
                    specialistInstance.CriticalDodge++;
                }

                #endregion

                #region slElement

                if (slElement >= 1)
                {
                    specialistInstance.ElementRate += 2;
                }

                if (slElement >= 10)
                {
                    specialistInstance.MP += 100;
                }

                if (slElement >= 20)
                {
                    specialistInstance.MagicDefence += 5;
                }

                if (slElement >= 30)
                {
                    specialistInstance.FireResistance  += 2;
                    specialistInstance.WaterResistance += 2;
                    specialistInstance.LightResistance += 2;
                    specialistInstance.DarkResistance  += 2;
                    specialistInstance.ElementRate     += 2;
                }

                if (slElement >= 40)
                {
                    specialistInstance.MP += 100;
                }

                if (slElement >= 50)
                {
                    specialistInstance.MagicDefence += 5;
                }

                if (slElement >= 60)
                {
                    specialistInstance.FireResistance  += 3;
                    specialistInstance.WaterResistance += 3;
                    specialistInstance.LightResistance += 3;
                    specialistInstance.DarkResistance  += 3;
                    specialistInstance.ElementRate     += 2;
                }

                if (slElement >= 70)
                {
                    specialistInstance.MP += 100;
                }

                if (slElement >= 80)
                {
                    specialistInstance.MagicDefence += 5;
                }

                if (slElement >= 90)
                {
                    specialistInstance.FireResistance  += 4;
                    specialistInstance.WaterResistance += 4;
                    specialistInstance.LightResistance += 4;
                    specialistInstance.DarkResistance  += 4;
                    specialistInstance.ElementRate     += 2;
                }

                if (slElement >= 100)
                {
                    specialistInstance.FireResistance  += 6;
                    specialistInstance.WaterResistance += 6;
                    specialistInstance.LightResistance += 6;
                    specialistInstance.DarkResistance  += 6;
                    specialistInstance.MagicDefence    += 5;
                    specialistInstance.MP          += 200;
                    specialistInstance.ElementRate += 2;
                }

                #endregion

                session.SendPacket(session.Character.GenerateStatChar());
                session.SendPacket(session.Character.GenerateStat());
                session.SendPacket(specialistInstance.GenerateSlInfo());
                session.SendPacket(
                    UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("POINTS_SET"), 0));
            }
            else if (!session.Character.IsSitting)
            {
                if (session.Character.Skills.Any(s => !s.CanBeUsed()))
                {
                    session.SendPacket(
                        UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("SKILLS_IN_LOADING"),
                                                        0));
                    return;
                }

                if (specialistInstance == null)
                {
                    session.SendPacket(UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("NO_SP"),
                                                                       0));
                    return;
                }

                if (session.Character.IsVehicled)
                {
                    session.SendPacket(
                        UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("REMOVE_VEHICLE"), 0));
                    return;
                }

                double currentRunningSeconds =
                    (DateTime.UtcNow - Process.GetCurrentProcess().StartTime.AddHours(-2).AddSeconds(-50)).TotalSeconds;

                if (session.Character.UseSp)
                {
                    session.Character.LastSp = currentRunningSeconds;
                    session.RemoveSp(specialistInstance.ItemVNum);
                }
                else
                {
                    if (session.Character.LastMove.AddSeconds(1) >= DateTime.UtcNow ||
                        session.Character.LastSkillUse.AddSeconds(2) >= DateTime.UtcNow)
                    {
                        return;
                    }

                    if (session.Character.SpPoint == 0 && session.Character.SpAdditionPoint == 0)
                    {
                        session.SendPacket(
                            UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("SP_NOPOINTS"), 0));
                    }

                    double timeSpanSinceLastSpUsage = currentRunningSeconds - session.Character.LastSp;
                    if (timeSpanSinceLastSpUsage >= session.Character.SpCooldown)
                    {
                        if (Type == 1)
                        {
                            if (session.Character.Buff.Any(s => s.Card.BuffType == BuffType.Bad))
                            {
                                session.SendPacket(
                                    UserInterfaceHelper.GenerateMsg(
                                        Language.Instance.GetMessageFromKey("UNDER_BAD_BUFF"), 0));
                                return;
                            }
                            DateTime delay = DateTime.UtcNow.AddSeconds(-6);
                            if (session.Character.LastDelay > delay &&
                                session.Character.LastDelay < delay.AddSeconds(2))
                            {
                                session.ChangeSp();
                            }
                        }
                        else
                        {
                            session.Character.LastDelay = DateTime.UtcNow;
                            session.SendPacket(UserInterfaceHelper.GenerateDelay(5000, 3, "#sl^1"));
                            session.CurrentMapInstance?.Broadcast(
                                UserInterfaceHelper.GenerateGuri(2, 1, session.Character.CharacterId),
                                session.Character.PositionX, session.Character.PositionY);
                        }
                    }
                    else
                    {
                        session.SendPacket(UserInterfaceHelper.GenerateMsg(
                                               string.Format(Language.Instance.GetMessageFromKey("SP_INLOADING"),
                                                             session.Character.SpCooldown - (int)Math.Round(timeSpanSinceLastSpUsage, 0)), 0));
                    }
                }
            }
        }
Esempio n. 4
0
        public static void NRun(ClientSession Session, NRunPacket packet)
        {
            if (!Session.HasCurrentMapInstance)
            {
                return;
            }
            MapNpc        npc = Session.CurrentMapInstance.Npcs.Find(s => s.MapNpcId == packet.NpcId);
            TeleporterDTO tp;

            switch (packet.Runner)
            {
            case 1:
                if (Session.Character.Class != (byte)ClassType.Adventurer)
                {
                    Session.SendPacket(UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("NOT_ADVENTURER"), 0));
                    return;
                }
                if (Session.Character.Level < 15 || Session.Character.JobLevel < 20)
                {
                    Session.SendPacket(UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("LOW_LVL"), 0));
                    return;
                }
                if (packet.Type == (byte)Session.Character.Class)
                {
                    return;
                }
                if (Session.Character.Inventory.All(i => i.Type != InventoryType.Wear))
                {
                    Session.Character.Inventory.AddNewToInventory((short)(4 + (packet.Type * 14)), type: InventoryType.Wear);
                    Session.Character.Inventory.AddNewToInventory((short)(81 + (packet.Type * 13)), type: InventoryType.Wear);
                    switch (packet.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.CurrentMapInstance?.Broadcast(Session.Character.GenerateEq());
                    Session.SendPacket(Session.Character.GenerateEquipment());
                    Session.Character.ChangeClass((ClassType)packet.Type);
                }
                else
                {
                    Session.SendPacket(UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("EQ_NOT_EMPTY"), 0));
                }
                break;

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

            case 4:
                Mate mate = Session.Character.Mates.Find(s => s.MateTransportId == packet.NpcId);
                switch (packet.Type)
                {
                case 2:
                    if (mate != null)
                    {
                        if (Session.Character.Level >= mate.Level)
                        {
                            Mate teammate = Session.Character.Mates.Where(s => s.IsTeamMember).FirstOrDefault(s => s.MateType == mate.MateType);
                            if (teammate != null)
                            {
                                teammate.IsTeamMember = false;
                                teammate.MapX         = teammate.PositionX;
                                teammate.MapY         = teammate.PositionY;
                            }
                            mate.IsTeamMember = true;
                        }
                        else
                        {
                            Session.SendPacket(UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("PET_HIGHER_LEVEL"), 0));
                        }
                    }
                    break;

                case 3:
                    if (mate != null && Session.Character.Miniland == Session.Character.MapInstance)
                    {
                        mate.IsTeamMember = false;
                        mate.MapX         = mate.PositionX;
                        mate.MapY         = mate.PositionY;
                    }
                    break;

                case 4:
                    if (mate != null)
                    {
                        if (Session.Character.Miniland == Session.Character.MapInstance)
                        {
                            mate.IsTeamMember = false;
                            mate.MapX         = mate.PositionX;
                            mate.MapY         = mate.PositionY;
                        }
                        else
                        {
                            Session.SendPacket($"qna #n_run^4^5^3^{mate.MateTransportId} {Language.Instance.GetMessageFromKey("ASK_KICK_PET")}");
                        }
                        break;
                    }
                    break;

                case 5:
                    if (mate != null)
                    {
                        Session.SendPacket(UserInterfaceHelper.GenerateDelay(3000, 10, $"#n_run^4^6^3^{mate.MateTransportId}"));
                    }
                    break;

                case 6:
                    if (mate != null && Session.Character.Miniland != Session.Character.MapInstance)
                    {
                        mate.IsTeamMember = false;
                        Session.CurrentMapInstance.Broadcast(mate.GenerateOut());
                        Session.SendPacket(Session.Character.GenerateSay(string.Format(Language.Instance.GetMessageFromKey("PET_KICKED"), mate.Name), 11));
                        Session.SendPacket(UserInterfaceHelper.GenerateMsg(string.Format(Language.Instance.GetMessageFromKey("PET_KICKED"), mate.Name), 0));
                    }
                    break;

                case 7:
                    if (mate != null)
                    {
                        if (Session.Character.Mates.Any(s => s.MateType == mate.MateType && s.IsTeamMember))
                        {
                            Session.SendPacket(Session.Character.GenerateSay(Language.Instance.GetMessageFromKey("ALREADY_PET_IN_TEAM"), 11));
                            Session.SendPacket(UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("ALREADY_PET_IN_TEAM"), 0));
                        }
                        else
                        {
                            Session.SendPacket(UserInterfaceHelper.GenerateDelay(3000, 10, $"#n_run^4^9^3^{mate.MateTransportId}"));
                        }
                    }
                    break;

                case 9:
                    if (mate != null && Session.Character.Level >= mate.Level)
                    {
                        mate.PositionX    = (short)(Session.Character.PositionX + (mate.MateType == MateType.Partner ? -1 : 1));
                        mate.PositionY    = (short)(Session.Character.PositionY + 1);
                        mate.IsTeamMember = true;
                        Session.CurrentMapInstance?.Broadcast(mate.GenerateIn());
                    }
                    else
                    {
                        Session.SendPacket(UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("PET_HIGHER_LEVEL"), 0));
                    }
                    break;
                }
                Session.SendPacket(Session.Character.GeneratePinit());
                Session.SendPackets(Session.Character.GeneratePst());
                break;

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

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

            case 14:
                Session.SendPacket("wopen 27 0");
                string recipelist = "m_list 2";
                if (npc != null)
                {
                    List <Recipe> tps = npc.Recipes;
                    recipelist  = tps.Where(s => s.Amount > 0).Aggregate(recipelist, (current, s) => current + $" {s.ItemVNum}");
                    recipelist += " -100";
                    Session.SendPacket(recipelist);
                }
                break;

            case 15:
                if (npc != null)
                {
                    if (packet.Value == 2)
                    {
                        Session.SendPacket($"qna #n_run^15^1^1^{npc.MapNpcId} {Language.Instance.GetMessageFromKey("ASK_CHANGE_SPAWNLOCATION")}");
                    }
                    else
                    {
                        switch (npc.MapId)
                        {
                        case 1:
                            Session.Character.SetRespawnPoint(1, 79, 116);
                            break;

                        case 20:
                            Session.Character.SetRespawnPoint(20, 9, 92);
                            break;

                        case 145:
                            Session.Character.SetRespawnPoint(145, 13, 110);
                            break;
                        }
                        Session.SendPacket(UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("RESPAWNLOCATION_CHANGED"), 0));
                    }
                }
                break;

            case 16:
                tp = npc?.Teleporters?.FirstOrDefault(s => s.Index == packet.Type);
                if (tp != null)
                {
                    if (Session.Character.Gold >= 1000 * packet.Type)
                    {
                        Session.Character.Gold -= 1000 * packet.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 17:
                double currentRunningSeconds   = (DateTime.Now - Process.GetCurrentProcess().StartTime.AddSeconds(-50)).TotalSeconds;
                double timeSpanSinceLastPortal = currentRunningSeconds - Session.Character.LastPortal;
                if (!(timeSpanSinceLastPortal >= 4) || !Session.HasCurrentMapInstance || ServerManager.Instance.ChannelId == 51 || Session.CurrentMapInstance.MapInstanceId == ServerManager.Instance.ArenaInstance.MapInstanceId || Session.CurrentMapInstance.MapInstanceId == ServerManager.Instance.FamilyArenaInstance.MapInstanceId)
                {
                    Session.SendPacket(Session.Character.GenerateSay(Language.Instance.GetMessageFromKey("CANT_MOVE"), 10));
                    return;
                }
                if (Session.Character.Gold >= 500 * (1 + packet.Type))
                {
                    Session.Character.LastPortal = currentRunningSeconds;
                    Session.Character.Gold      -= 500 * (1 + packet.Type);
                    Session.SendPacket(Session.Character.GenerateGold());
                    MapCell pos = packet.Type == 0 ? ServerManager.Instance.ArenaInstance.Map.GetRandomPosition() : ServerManager.Instance.FamilyArenaInstance.Map.GetRandomPosition();
                    ServerManager.Instance.ChangeMapInstance(Session.Character.CharacterId, packet.Type == 0 ? ServerManager.Instance.ArenaInstance.MapInstanceId : ServerManager.Instance.FamilyArenaInstance.MapInstanceId, pos.X, pos.Y);
                }
                else
                {
                    Session.SendPacket(Session.Character.GenerateSay(Language.Instance.GetMessageFromKey("NOT_ENOUGH_MONEY"), 10));
                }
                break;

            case 18:
                Session.SendPacket(Session.Character.GenerateNpcDialog(17));
                break;

            case 26:
                tp = npc?.Teleporters?.FirstOrDefault(s => s.Index == packet.Type);
                if (tp != null)
                {
                    if (Session.Character.Gold >= 5000 * packet.Type)
                    {
                        Session.Character.Gold -= 5000 * packet.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:
                tp = npc?.Teleporters?.FirstOrDefault(s => s.Index == packet.Type);
                if (tp != null)
                {
                    if (Session.Character.Gold >= 500)
                    {
                        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:
                tp = npc?.Teleporters?.FirstOrDefault(s => s.Index == packet.Type);
                if (tp != null)
                {
                    ServerManager.Instance.ChangeMap(Session.Character.CharacterId, tp.MapId, tp.MapX, tp.MapY);
                }
                break;

            case 135:
                if (TalentArena.IsRunning)
                {
                    TalentArena.RegisteredParticipants[Session.Character.CharacterId] = Session;
                    Session.SendPacket(UserInterfaceHelper.GenerateBSInfo(0, 3, 300, 5));
                }
                break;

            case 150:
                if (npc != null)
                {
                    if (Session.Character.Family != null)
                    {
                        if (Session.Character.Family.LandOfDeath != null && npc.EffectActivated)
                        {
                            if (Session.Character.Level >= 55)
                            {
                                ServerManager.Instance.ChangeMapInstance(Session.Character.CharacterId, Session.Character.Family.LandOfDeath.MapInstanceId, 153, 145);
                            }
                            else
                            {
                                Session.SendPacket(UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("LOD_REQUIERE_LVL"), 0));
                            }
                        }
                        else
                        {
                            Session.SendPacket(UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("LOD_CLOSED"), 0));
                        }
                    }
                    else
                    {
                        Session.SendPacket(UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("NEED_FAMILY"), 0));
                    }
                }
                break;

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

            case 1600:
                Session.SendPacket(Session.Character.OpenFamilyWarehouse());
                break;

            case 1601:
                Session.SendPackets(Session.Character.OpenFamilyWarehouseHist());
                break;

            case 1602:
                if (Session.Character.Family?.FamilyLevel >= 3 && Session.Character.Family.WarehouseSize < 21)
                {
                    if (Session.Character.FamilyCharacter.Authority == FamilyAuthority.Head)
                    {
                        if (500000 >= Session.Character.Gold)
                        {
                            Session.SendPacket(Session.Character.GenerateSay(Language.Instance.GetMessageFromKey("NOT_ENOUGH_MONEY"), 10));
                            return;
                        }
                        Session.Character.Family.WarehouseSize = 21;
                        Session.Character.Gold -= 500000;
                        Session.SendPacket(Session.Character.GenerateGold());
                        FamilyDTO fam = Session.Character.Family;
                        DAOFactory.FamilyDAO.InsertOrUpdate(ref fam);
                        ServerManager.Instance.FamilyRefresh(Session.Character.Family.FamilyId);
                    }
                    else
                    {
                        Session.SendPacket(Session.Character.GenerateSay(Language.Instance.GetMessageFromKey("ONLY_HEAD_CAN_BUY"), 10));
                        Session.SendPacket(UserInterfaceHelper.GenerateModal(Language.Instance.GetMessageFromKey("ONLY_HEAD_CAN_BUY"), 1));
                    }
                }
                break;

            case 1603:
                if (Session.Character.Family?.FamilyLevel >= 7 && Session.Character.Family.WarehouseSize < 49)
                {
                    if (Session.Character.FamilyCharacter.Authority == FamilyAuthority.Head)
                    {
                        if (2000000 >= Session.Character.Gold)
                        {
                            Session.SendPacket(Session.Character.GenerateSay(Language.Instance.GetMessageFromKey("NOT_ENOUGH_MONEY"), 10));
                            return;
                        }
                        Session.Character.Family.WarehouseSize = 49;
                        Session.Character.Gold -= 2000000;
                        Session.SendPacket(Session.Character.GenerateGold());
                        FamilyDTO fam = Session.Character.Family;
                        DAOFactory.FamilyDAO.InsertOrUpdate(ref fam);
                        ServerManager.Instance.FamilyRefresh(Session.Character.Family.FamilyId);
                    }
                    else
                    {
                        Session.SendPacket(Session.Character.GenerateSay(Language.Instance.GetMessageFromKey("ONLY_HEAD_CAN_BUY"), 10));
                        Session.SendPacket(UserInterfaceHelper.GenerateModal(Language.Instance.GetMessageFromKey("ONLY_HEAD_CAN_BUY"), 1));
                    }
                }
                break;

            case 1604:
                if (Session.Character.Family?.FamilyLevel >= 5 && Session.Character.Family.MaxSize < 70)
                {
                    if (Session.Character.FamilyCharacter.Authority == FamilyAuthority.Head)
                    {
                        if (5000000 >= Session.Character.Gold)
                        {
                            Session.SendPacket(Session.Character.GenerateSay(Language.Instance.GetMessageFromKey("NOT_ENOUGH_MONEY"), 10));
                            return;
                        }
                        Session.Character.Family.MaxSize = 70;
                        Session.Character.Gold          -= 5000000;
                        Session.SendPacket(Session.Character.GenerateGold());
                        FamilyDTO fam = Session.Character.Family;
                        DAOFactory.FamilyDAO.InsertOrUpdate(ref fam);
                        ServerManager.Instance.FamilyRefresh(Session.Character.Family.FamilyId);
                    }
                    else
                    {
                        Session.SendPacket(Session.Character.GenerateSay(Language.Instance.GetMessageFromKey("ONLY_HEAD_CAN_BUY"), 10));
                        Session.SendPacket(UserInterfaceHelper.GenerateModal(Language.Instance.GetMessageFromKey("ONLY_HEAD_CAN_BUY"), 1));
                    }
                }
                break;

            case 1605:
                if (Session.Character.Family?.FamilyLevel >= 9 && Session.Character.Family.MaxSize < 100)
                {
                    if (Session.Character.FamilyCharacter.Authority == FamilyAuthority.Head)
                    {
                        if (10000000 >= Session.Character.Gold)
                        {
                            Session.SendPacket(Session.Character.GenerateSay(Language.Instance.GetMessageFromKey("NOT_ENOUGH_MONEY"), 10));
                            return;
                        }
                        Session.Character.Family.MaxSize = 100;
                        Session.Character.Gold          -= 10000000;
                        Session.SendPacket(Session.Character.GenerateGold());
                        FamilyDTO fam = Session.Character.Family;
                        DAOFactory.FamilyDAO.InsertOrUpdate(ref fam);
                        ServerManager.Instance.FamilyRefresh(Session.Character.Family.FamilyId);
                    }
                    else
                    {
                        Session.SendPacket(Session.Character.GenerateSay(Language.Instance.GetMessageFromKey("ONLY_HEAD_CAN_BUY"), 10));
                        Session.SendPacket(UserInterfaceHelper.GenerateModal(Language.Instance.GetMessageFromKey("ONLY_HEAD_CAN_BUY"), 1));
                    }
                }
                break;

            case 23:
                if (packet.Type == 0)
                {
                    if (Session.Character.Group?.CharacterCount == 3)
                    {
                        foreach (ClientSession s in Session.Character.Group.Characters.GetAllItems())
                        {
                            if (s.Character.Family != null)
                            {
                                Session.SendPacket(UserInterfaceHelper.GenerateInfo(Language.Instance.GetMessageFromKey("GROUP_MEMBER_ALREADY_IN_FAMILY")));
                                return;
                            }
                        }
                    }
                    if (Session.Character.Group == null || Session.Character.Group.CharacterCount != 3)
                    {
                        Session.SendPacket(UserInterfaceHelper.GenerateInfo(Language.Instance.GetMessageFromKey("FAMILY_GROUP_NOT_FULL")));
                        return;
                    }
                    Session.SendPacket(UserInterfaceHelper.GenerateInbox($"#glmk^ {14} 1 {Language.Instance.GetMessageFromKey("CREATE_FAMILY").Replace(' ', '^')}"));
                }
                else
                {
                    if (Session.Character.Family == null)
                    {
                        Session.SendPacket(UserInterfaceHelper.GenerateInfo(Language.Instance.GetMessageFromKey("NOT_IN_FAMILY")));
                        return;
                    }
                    if (Session.Character.Family != null && Session.Character.FamilyCharacter != null && Session.Character.FamilyCharacter.Authority != FamilyAuthority.Head)
                    {
                        Session.SendPacket(UserInterfaceHelper.GenerateInfo(Language.Instance.GetMessageFromKey("NOT_FAMILY_HEAD")));
                        return;
                    }
                    Session.SendPacket($"qna #glrm^1 {Language.Instance.GetMessageFromKey("DISMISS_FAMILY")}");
                }

                break;

            case 60:
                StaticBonusDTO medal = Session.Character.StaticBonusList.Find(s => s.StaticBonusType == StaticBonusType.BazaarMedalGold || s.StaticBonusType == StaticBonusType.BazaarMedalSilver);
                byte           Medal = 0;
                int            Time  = 0;
                if (medal != null)
                {
                    Medal = medal.StaticBonusType == StaticBonusType.BazaarMedalGold ? (byte)MedalType.Gold : (byte)MedalType.Silver;
                    Time  = (int)(medal.DateEnd - DateTime.Now).TotalHours;
                }
                Session.SendPacket($"wopen 32 {Medal} {Time}");
                break;

            case 5002:
                tp = npc?.Teleporters?.FirstOrDefault(s => s.Index == packet.Type);
                if (tp != null)
                {
                    //Session.SendPacket("it 3");
                    if (ServerManager.Instance.ChannelId == 51)
                    {
                        string connection = CommunicationServiceClient.Instance.RetrieveOriginWorld(Session.Account.AccountId);
                        if (string.IsNullOrWhiteSpace(connection))
                        {
                            return;
                        }
                        Session.Character.MapId = tp.MapId;
                        Session.Character.MapX  = tp.MapX;
                        Session.Character.MapY  = tp.MapY;
                        int port = Convert.ToInt32(connection.Split(':')[1]);
                        Session.Character.ChangeChannel(connection.Split(':')[0], port, 3);
                    }
                    else
                    {
                        ServerManager.Instance.ChangeMap(Session.Character.CharacterId, tp.MapId, tp.MapX, tp.MapY);
                    }
                }
                break;

            case 5001:
                if (npc != null)
                {
                    MapInstance map = null;
                    switch (Session.Character.Faction)
                    {
                    case FactionType.None:
                        Session.SendPacket(UserInterfaceHelper.GenerateInfo("You need to be part of a faction to join Act 4"));
                        return;

                    case FactionType.Angel:
                        map = ServerManager.GetAllMapInstances().Find(s => s.MapInstanceType.Equals(MapInstanceType.Act4ShipAngel));

                        break;

                    case FactionType.Demon:
                        map = ServerManager.GetAllMapInstances().Find(s => s.MapInstanceType.Equals(MapInstanceType.Act4ShipDemon));

                        break;
                    }
                    if (map == null || npc.EffectActivated)
                    {
                        Session.SendPacket(UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("SHIP_NOTARRIVED"), 0));
                        return;
                    }
                    if (3000 > Session.Character.Gold)
                    {
                        Session.SendPacket(Session.Character.GenerateSay(Language.Instance.GetMessageFromKey("NOT_ENOUGH_MONEY"), 10));
                        return;
                    }
                    Session.Character.Gold -= 3000;
                    MapCell pos = map.Map.GetRandomPosition();
                    ServerManager.Instance.ChangeMapInstance(Session.Character.CharacterId, map.MapInstanceId, pos.X, pos.Y);
                }
                break;

            case 5004:
                if (npc != null)
                {
                    ServerManager.Instance.ChangeMap(Session.Character.CharacterId, 145, 50, 41);
                }
                break;

            case 5011:
                if (npc != null)
                {
                    ServerManager.Instance.ChangeMap(Session.Character.CharacterId, 170, 127, 46);
                }
                break;

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

            default:
                Logger.Warn(string.Format(Language.Instance.GetMessageFromKey("NO_NRUN_HANDLER"), packet.Runner));
                break;
            }
        }
Esempio n. 5
0
        private void ExecuteHandler(ClientSession session)
        {
            if (session.Character.LastSkillUse.AddSeconds(1) > DateTime.UtcNow ||
                (session.Character.IsVehicled &&
                 session.CurrentMapInstance?.MapInstanceType != MapInstanceType.EventGameInstance) ||
                !session.HasCurrentMapInstance)
            {
                return;
            }

            if (TransportId < 100000)
            {
                MapButton button = session.CurrentMapInstance.Buttons.Find(s => s.MapButtonId == TransportId);
                if (button != null)
                {
                    session.SendPacket(UserInterfaceHelper.GenerateDelay(2000, 1, $"#git^{button.MapButtonId}"));
                }
            }
            else
            {
                if (!session.CurrentMapInstance.DroppedList.ContainsKey(TransportId))
                {
                    return;
                }

                MapItem mapItem = session.CurrentMapInstance.DroppedList[TransportId];

                if (mapItem != null)
                {
                    bool canpick = false;
                    switch (PickerType)
                    {
                    case 1:
                        canpick = session.Character.IsInRange(mapItem.PositionX, mapItem.PositionY, 8);
                        break;

                    case 2:
                        Mate mate = session.Character.Mates.Find(s =>
                                                                 s.MateTransportId == PickerId && s.CanPickUp);
                        if (mate != null)
                        {
                            canpick = mate.IsInRange(mapItem.PositionX, mapItem.PositionY, 8);
                        }

                        break;
                    }

                    if (canpick && session.HasCurrentMapInstance)
                    {
                        if (mapItem is MonsterMapItem item)
                        {
                            MonsterMapItem monsterMapItem = item;
                            if (session.CurrentMapInstance.MapInstanceType != MapInstanceType.LodInstance &&
                                monsterMapItem.OwnerId.HasValue && monsterMapItem.OwnerId.Value != -1)
                            {
                                Group group = ServerManager.Instance.Groups.Find(g =>
                                                                                 g.IsMemberOfGroup(monsterMapItem.OwnerId.Value) &&
                                                                                 g.IsMemberOfGroup(session.Character.CharacterId));
                                if (item.CreatedDate.AddSeconds(30) > DateTime.UtcNow &&
                                    !(monsterMapItem.OwnerId == session.Character.CharacterId ||
                                      (group?.SharingMode == (byte)GroupSharingType.Everyone)))
                                {
                                    session.SendPacket(
                                        session.Character.GenerateSay(
                                            Language.Instance.GetMessageFromKey("NOT_YOUR_ITEM"), 10));
                                    return;
                                }
                            }

                            // initialize and rarify
                            item.Rarify(null);
                        }

                        if (mapItem.ItemVNum != 1046)
                        {
                            ItemInstance mapItemInstance = mapItem.GetItemInstance();
                            if (mapItemInstance.Item.ItemType == ItemType.Map)
                            {
                                if (mapItemInstance.Item.Effect == 71)
                                {
                                    session.Character.SpPoint += mapItem.GetItemInstance().Item.EffectValue;
                                    if (session.Character.SpPoint > 10000)
                                    {
                                        session.Character.SpPoint = 10000;
                                    }

                                    session.SendPacket(UserInterfaceHelper.GenerateMsg(
                                                           string.Format(Language.Instance.GetMessageFromKey("SP_POINTSADDED"),
                                                                         mapItem.GetItemInstance().Item.EffectValue), 0));
                                    session.SendPacket(session.Character.GenerateSpPoint());
                                }

                                if (ServerManager.Instance.QuestModelList.FirstOrDefault(s =>
                                                                                         s.QuestGiver.QuestGiverId == mapItemInstance.Item.VNum &&
                                                                                         s.QuestGiver.Type == QuestGiverType.ItemLoot) is QuestModel model)
                                {
                                    session.Character.QuestManager.AddQuest(model.QuestId);
                                }

                                session.CurrentMapInstance.DroppedList.Remove(TransportId);
                                session.CurrentMapInstance?.Broadcast(
                                    session.Character.GenerateGet(PickerId, TransportId));
                            }
                            else
                            {
                                lock (session.Character.Inventory)
                                {
                                    short        amount = mapItem.Amount;
                                    ItemInstance inv    = session.Character.Inventory.AddToInventory(mapItemInstance)
                                                          .FirstOrDefault();
                                    if (inv != null)
                                    {
                                        session.CurrentMapInstance.DroppedList.Remove(TransportId);
                                        session.CurrentMapInstance?.Broadcast(
                                            session.Character.GenerateGet(PickerId, TransportId));
                                        if (PickerType == 2)
                                        {
                                            Mate mate = session.Character.Mates.FirstOrDefault(s => s.MateTransportId == PickerId && s.CanPickUp);
                                            if (mate != null)
                                            {
                                                session.SendPacket(session.Character.GenerateIcon(1, 1, inv.ItemVNum));
                                                mate.Owner?.Session.CurrentMapInstance?.Broadcast(StaticPacketHelper.GenerateEff(UserType.Npc, mate.MateTransportId, 5004), mate.PositionX, mate.PositionY);
                                            }
                                            else
                                            {
                                                return;
                                            }
                                        }

                                        session.SendPacket(session.Character.GenerateSay(
                                                               $"{Language.Instance.GetMessageFromKey("ITEM_ACQUIRED")}: {inv.Item.Name} x {amount}",
                                                               12));
                                        if (session.CurrentMapInstance.MapInstanceType == MapInstanceType.LodInstance)
                                        {
                                            session.CurrentMapInstance?.Broadcast(
                                                session.Character.GenerateSay(
                                                    $"{string.Format(Language.Instance.GetMessageFromKey("ITEM_ACQUIRED_LOD"), session.Character.Name)}: {inv.Item.Name} x {mapItem.Amount}",
                                                    10));
                                        }

                                        session.Character.OnPickupItem(new PickupItemEventArgs(inv.Item));
                                    }
                                    else
                                    {
                                        session.SendPacket(UserInterfaceHelper.GenerateMsg(
                                                               Language.Instance.GetMessageFromKey("NOT_ENOUGH_PLACE"), 0));
                                    }
                                }
                            }
                        }
                        else
                        {
                            // handle gold drop
                            long   maxGold    = ServerManager.Instance.Configuration.MaxGold;
                            double multiplier =
                                1 + (session.Character.GetBuff(BCardType.CardType.Item,
                                                               (byte)AdditionalTypes.Item.IncreaseEarnedGold)[0] / 100D);
                            multiplier +=
                                (session.Character.ShellEffectMain.FirstOrDefault(s =>
                                                                                  s.Effect == (byte)ShellWeaponEffectType.GainMoreGold)?.Value ?? 0) / 100D;
                            if (mapItem is MonsterMapItem droppedGold)
                            {
                                if (session.Character.Gold + (droppedGold.GoldAmount * multiplier) <= maxGold)
                                {
                                    if (PickerType == 2)
                                    {
                                        session.SendPacket(session.Character.GenerateIcon(1, 1, 1046));
                                    }

                                    session.Character.Gold += (int)(droppedGold.GoldAmount * multiplier);
                                    GameLogger.Instance.LogPickupGold(ServerManager.Instance.ChannelId,
                                                                      session.Character.Name, session.Character.CharacterId,
                                                                      (int)(droppedGold.GoldAmount * multiplier), false);
                                    session.SendPacket(session.Character.GenerateSay(
                                                           $"{Language.Instance.GetMessageFromKey("ITEM_ACQUIRED")}: {mapItem.GetItemInstance().Item.Name} x {droppedGold.GoldAmount}{(multiplier > 1 ? $" + {(int) (droppedGold.GoldAmount * multiplier) - droppedGold.GoldAmount}" : string.Empty)}",
                                                           12));
                                }
                                else
                                {
                                    session.Character.Gold = maxGold;
                                    GameLogger.Instance.LogPickupGold(ServerManager.Instance.ChannelId,
                                                                      session.Character.Name, session.Character.CharacterId,
                                                                      (int)(droppedGold.GoldAmount * multiplier), true);
                                    session.SendPacket(
                                        UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("MAX_GOLD"),
                                                                        0));
                                }
                            }

                            session.SendPacket(session.Character.GenerateGold());
                            session.CurrentMapInstance.DroppedList.Remove(TransportId);
                            session.CurrentMapInstance?.Broadcast(session.Character.GenerateGet(PickerId, TransportId));
                        }
                    }
                }
            }
        }
Esempio n. 6
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;

            // 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 146:
                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;

            case 2081:
                if (!session.Character.Buff.ContainsKey(146))
                {
                    session.Character.Inventory.RemoveItemFromInventory(inv.Id);
                    session.Character.AddStaticBuff(new StaticBuffDTO()
                    {
                        CardId = 146
                    });
                }
                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)
                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;
                        }

                        if (session.Character.IsFriendOfCharacter(characterId))
                        {
                            var 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);
                            }
                        }
                        else
                        {
                            session.SendPacket($"info {Language.Instance.GetMessageFromKey("NOT_FRIEND")}");
                        }
                    }
                }

                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;
            }
        }
        private void ExecuteHandler(ClientSession session)
        {
            if (session.Account.IsVerified || Type == 4 && Argument == 11)
            {
                if (Data.HasValue && Type == 10 && Data.Value >= 973 &&
                    Data.Value <= 999 && !session.Character.EmoticonsBlocked)
                {
                    if (Parameter == session.Character.CharacterId)
                    {
                        session.CurrentMapInstance?.Broadcast(session,
                                                              StaticPacketHelper.GenerateEff(UserType.Player, session.Character.CharacterId,
                                                                                             Data.Value + 4099), ReceiverType.AllNoEmoBlocked);
                    }
                    else if (Parameter.TryCastToInt(out int mateTransportId))
                    {
                        Mate mate = session.Character.Mates.Find(s => s.MateTransportId == mateTransportId);
                        if (mate != null)
                        {
                            session.CurrentMapInstance?.Broadcast(session,
                                                                  StaticPacketHelper.GenerateEff(UserType.Npc, mate.MateTransportId,
                                                                                                 Data.Value + 4099), ReceiverType.AllNoEmoBlocked);
                        }
                    }
                }
                else if (Type == 204)
                {
                    if (Argument == 0 && short.TryParse(Parameter.ToString(), out short slot))
                    {
                        ItemInstance shell =
                            session.Character.Inventory.LoadBySlotAndType(slot, InventoryType.Equipment);
                        if (shell?.ShellEffects.Count == 0 && shell.Upgrade > 0 && shell.Rare > 0 &&
                            session.Character.Inventory.CountItem(1429) >= ((shell.Upgrade / 10) + shell.Rare))
                        {
                            shell.SetShellEffects();
                            session.SendPacket(
                                UserInterfaceHelper.GenerateMsg(
                                    Language.Instance.GetMessageFromKey("OPTION_IDENTIFIED"), 0));
                            session.SendPacket(StaticPacketHelper.GenerateEff(UserType.Player,
                                                                              session.Character.CharacterId, 3006));
                            session.Character.Inventory.RemoveItemAmount(1429, (shell.Upgrade / 10) + shell.Rare);
                        }
                    }
                }
                else if (Type == 205)
                {
                    if (Parameter.TryCastToShort(out short slot))
                    {
                        ItemInstance inv = session.Character.Inventory.LoadBySlotAndType(slot, InventoryType.Equipment);
                        if (inv.Rare < 1 || inv.Rare > 8 || inv.Item.LevelMinimum > 99 ||
                            inv.BoundCharacterId == null)
                        {
                            return;
                        }

                        short[][] parfumeReq =
                        {
                            new short[] { 0, 0,  0,  0,  0,   5,  10,  10,  20 },
                            new short[] { 0, 0,  0,  0,  5,  10,  10,  20,  40 },
                            new short[] { 0, 0,  0,  5, 10,  10,  20,  40,  80 },
                            new short[] { 0, 0,  5,  5, 10,  20,  40,  80, 120 },
                            new short[] { 0, 0,  5, 10, 20,  40,  80, 120, 160 },
                            new short[] { 0, 0,  5, 20, 40,  80, 120, 160, 200 },
                            new short[] { 0, 0, 10, 40, 80, 120, 160, 200, 300 },
                            new short[] { 0, 0, 10, 40, 80, 120, 160, 200, 400 }
                        };
                        int[] goldReq =
                        {
                            1000,
                            2000,
                            5000,
                            8000,
                            10000,
                            12500,
                            15000,
                            17500,
                            20000,
                            30000
                        };

                        if (session.Character.Inventory.CountItem(1428)
                            >= parfumeReq[inv.Rare - 1][(inv.Item.LevelMinimum / 10) - 1] &&
                            session.Character.Gold >= goldReq[(inv.Item.LevelMinimum / 10) - 1])
                        {
                            session.Character.Inventory.RemoveItemAmount(1428,
                                                                         parfumeReq[inv.Rare - 1][(inv.Item.LevelMinimum / 10) - 1]);
                            session.Character.Gold -= goldReq[(inv.Item.LevelMinimum / 10) - 1];
                            session.SendPacket(session.Character.GenerateGold());
                            inv.BoundCharacterId = session.Character.CharacterId;
                            session.SendPacket(
                                UserInterfaceHelper.GenerateMsg(
                                    Language.Instance.GetMessageFromKey("SHELL_PERFUMED"), 0));
                        }
                    }
                }
                else if (Type == 300)
                {
                    if (Argument == 8023 && Parameter.TryCastToShort(out short slot))
                    {
                        ItemInstance box = session.Character.Inventory.LoadBySlotAndType(slot, InventoryType.Equipment);
                        if (box != null)
                        {
                            box.Item.Use(session, ref box, 1, new[] { Data?.ToString() ?? string.Empty });
                        }
                    }
                }
                else if (Type == 506)
                {
                    session.Character.IsWaitingForEvent |= ServerManager.Instance.EventInWaiting;
                }
                else if (Type == 199 && Argument == 2)
                {
                    short[] listWingOfFriendship = { 2160, 2312, 10048 };
                    short   vnumToUse            = -1;
                    foreach (short vnum in listWingOfFriendship)
                    {
                        if (session.Character.Inventory.CountItem(vnum) > 0)
                        {
                            vnumToUse = vnum;
                        }
                    }

                    if (vnumToUse != -1 || session.Character.IsSpouseOfCharacter(Parameter))
                    {
                        ClientSession sess = ServerManager.Instance.GetSessionByCharacterId(Parameter);
                        if (sess != null)
                        {
                            if (session.Character.IsFriendOfCharacter(Parameter))
                            {
                                if (sess.CurrentMapInstance?.MapInstanceType == MapInstanceType.BaseMapInstance)
                                {
                                    if (session.Character.MapInstance.MapInstanceType
                                        != MapInstanceType.BaseMapInstance ||
                                        (ServerManager.Instance.ChannelId == 51 &&
                                         session.Character.Faction != sess.Character.Faction))
                                    {
                                        session.SendPacket(
                                            session.Character.GenerateSay(
                                                Language.Instance.GetMessageFromKey("CANT_USE_THAT"), 10));
                                        return;
                                    }

                                    short mapy  = sess.Character.PositionY;
                                    short mapx  = sess.Character.PositionX;
                                    short mapId = sess.Character.MapInstance.Map.MapId;

                                    ServerManager.Instance.ChangeMap(session.Character.CharacterId, mapId, mapx, mapy);
                                    if (!session.Character.IsSpouseOfCharacter(Parameter))
                                    {
                                        session.Character.Inventory.RemoveItemAmount(vnumToUse);
                                    }
                                }
                                else
                                {
                                    session.SendPacket(
                                        UserInterfaceHelper.GenerateMsg(
                                            Language.Instance.GetMessageFromKey("USER_ON_INSTANCEMAP"), 0));
                                }
                            }
                        }
                        else
                        {
                            session.SendPacket(
                                UserInterfaceHelper.GenerateMsg(
                                    Language.Instance.GetMessageFromKey("USER_NOT_CONNECTED"), 0));
                        }
                    }
                    else
                    {
                        session.SendPacket(
                            session.Character.GenerateSay(Language.Instance.GetMessageFromKey("NO_WINGS"), 10));
                    }
                }
                else if (Type == 400)
                {
                    if (!session.HasCurrentMapInstance)
                    {
                        return;
                    }

                    MapNpc npc = session.CurrentMapInstance.Npcs.Find(n => n.MapNpcId.Equals(Argument));
                    if (npc != null)
                    {
                        NpcMonster mapobject = ServerManager.GetNpcMonster(npc.NpcVNum);

                        int rateDrop = ServerManager.Instance.Configuration.RateDrop;
                        int delay    = (int)Math.Round(
                            (3 + (mapobject.RespawnTime / 1000d)) * session.Character.TimesUsed);
                        delay = delay > 11 ? 8 : delay;
                        if (session.Character.LastMapObject.AddSeconds(delay) < DateTime.UtcNow)
                        {
                            if (mapobject.Drops.Any(s => s.MonsterVNum != null) && mapobject.VNumRequired > 10 &&
                                session.Character.Inventory
                                .CountItem(mapobject.VNumRequired)
                                < mapobject.AmountRequired)
                            {
                                session.SendPacket(
                                    UserInterfaceHelper.GenerateMsg(
                                        Language.Instance.GetMessageFromKey("NOT_ENOUGH_ITEM"), 0));
                                return;
                            }

                            Random  random       = new Random();
                            double  randomAmount = ServerManager.RandomNumber() * random.NextDouble();
                            DropDTO drop         = mapobject.Drops.Find(s => s.MonsterVNum == npc.NpcVNum);
                            if (drop != null)
                            {
                                int dropChance = drop.DropChance;
                                if (randomAmount <= (double)dropChance * rateDrop / 5000.000)
                                {
                                    short        vnum   = drop.ItemVNum;
                                    ItemInstance newInv = session.Character.Inventory.AddNewToInventory(vnum)
                                                          .FirstOrDefault();
                                    session.Character.LastMapObject = DateTime.UtcNow;
                                    session.Character.TimesUsed++;
                                    if (session.Character.TimesUsed >= 4)
                                    {
                                        session.Character.TimesUsed = 0;
                                    }

                                    if (newInv != null)
                                    {
                                        session.SendPacket(UserInterfaceHelper.GenerateMsg(
                                                               string.Format(Language.Instance.GetMessageFromKey("RECEIVED_ITEM"),
                                                                             newInv.Item.Name), 0));
                                        session.SendPacket(session.Character.GenerateSay(
                                                               string.Format(Language.Instance.GetMessageFromKey("RECEIVED_ITEM"),
                                                                             newInv.Item.Name), 11));
                                    }
                                    else
                                    {
                                        session.SendPacket(UserInterfaceHelper.GenerateMsg(
                                                               Language.Instance.GetMessageFromKey("NOT_ENOUGH_PLACE"), 0));
                                    }
                                }
                                else
                                {
                                    session.SendPacket(
                                        UserInterfaceHelper.GenerateMsg(
                                            Language.Instance.GetMessageFromKey("TRY_FAILED"), 0));
                                }
                            }
                        }
                        else
                        {
                            session.SendPacket(UserInterfaceHelper.GenerateMsg(
                                                   string.Format(Language.Instance.GetMessageFromKey("TRY_FAILED_WAIT"),
                                                                 (int)(session.Character.LastMapObject.AddSeconds(delay) - DateTime.UtcNow)
                                                                 .TotalSeconds), 0));
                        }
                    }
                }
                else if (Type == 710)
                {
                    if (Value != null)
                    {
                        // TODO: MAP TELEPORTER
                    }
                }
                else if (Type == 750)
                {
                    const short baseVnum = 1623;
                    if (Argument.TryCastToByte(out byte faction) &&
                        (Enum.IsDefined(typeof(FactionType), faction) ||
                         Enum.IsDefined(typeof(FactionType), (byte)(faction / 2))) &&
                        session.Character.Inventory.CountItem(baseVnum + faction) > 0)
                    {
                        if (faction < 3)
                        {
                            if (session.Character.Family != null)
                            {
                                session.SendPacket(
                                    UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("IN_FAMILY"),
                                                                    0));
                                return;
                            }

                            session.Character.Faction = (FactionType)faction;
                            session.Character.Inventory.RemoveItemAmount(baseVnum + faction);
                            session.SendPacket("scr 0 0 0 0 0 0 0");
                            session.SendPacket(session.Character.GenerateFaction());
                            session.SendPacket(StaticPacketHelper.GenerateEff(UserType.Player,
                                                                              session.Character.CharacterId, 4799 + faction));
                            session.SendPacket(UserInterfaceHelper.GenerateMsg(
                                                   Language.Instance.GetMessageFromKey($"GET_PROTECTION_POWER_{faction}"), 0));
                        }
                        else
                        {
                            if (session.Character.Family == null || session.Character.Family.FamilyCharacters
                                .Find(s => s.Authority.Equals(FamilyAuthority.Head))?.CharacterId
                                .Equals(session.Character.CharacterId) != true)
                            {
                                session.SendPacket(
                                    UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("NO_FAMILY"),
                                                                    0));
                                return;
                            }

                            if (session.Character.Family.LastFactionChange > DateTime.UtcNow.AddDays(-1).Ticks)
                            {
                                session.SendPacket(UserInterfaceHelper.GenerateMsg(
                                                       Language.Instance.GetMessageFromKey("CHANGE_NOT PERMITTED"), 0));
                                return;
                            }

                            session.Character.Faction = (FactionType)(faction / 2);
                            session.Character.Inventory.RemoveItemAmount(baseVnum + faction);
                            session.SendPacket("scr 0 0 0 0 0 0 0");
                            session.SendPacket(session.Character.GenerateFaction());
                            session.SendPacket(StaticPacketHelper.GenerateEff(UserType.Player,
                                                                              session.Character.CharacterId, 4799 + (faction / 2)));
                            session.SendPacket(UserInterfaceHelper.GenerateMsg(
                                                   Language.Instance.GetMessageFromKey($"GET_PROTECTION_POWER_{faction / 2}"), 0));
                            session.Character.Family.LastFactionChange = DateTime.UtcNow.Ticks;
                            session.Character.Save();
                            ServerManager.Instance.FamilyRefresh(session.Character.Family.FamilyId);
                            CommunicationServiceClient.Instance.SendMessageToCharacter(new ScsCharacterMessage
                            {
                                DestinationCharacterId = session.Character.Family.FamilyId,
                                SourceCharacterId      = 0,
                                SourceWorldId          = ServerManager.Instance.WorldId,
                                Message = "fhis_stc",
                                Type    = MessageType.Family
                            });
                        }
                    }
                }
                else if (Type == 2)
                {
                    session.CurrentMapInstance?.Broadcast(
                        UserInterfaceHelper.GenerateGuri(2, 1, session.Character.CharacterId),
                        session.Character.PositionX, session.Character.PositionY);
                }
                else if (Type == 4)
                {
                    const int speakerVNum = 2173;
                    const int petnameVNum = 2157;
                    if (Argument == 1 && Data.HasValue)
                    {
                        Mate mate = session.Character.Mates.Find(s => s.MateTransportId == Data.Value);
                        if (mate != null && session.Character.Inventory.CountItem(petnameVNum) > 0)
                        {
                            mate.Name = Value.Truncate(16);
                            session.CurrentMapInstance?.Broadcast(mate.GenerateOut(), ReceiverType.AllExceptMe);
                            session.CurrentMapInstance?.Broadcast(mate.GenerateIn());
                            session.SendPacket(mate.GenerateCond());
                            session.SendPacket(
                                UserInterfaceHelper.GenerateInfo(Language.Instance.GetMessageFromKey("NEW_NAME_PET")));
                            session.SendPacket(session.Character.GeneratePinit());
                            session.SendPackets(session.Character.GeneratePst());
                            session.SendPackets(session.Character.GenerateScP());
                            session.Character.Inventory.RemoveItemAmount(petnameVNum);
                        }
                    }

                    // presentation message
                    if (Argument == 2)
                    {
                        int presentationVNum = session.Character.Inventory.CountItem(1117) > 0
                            ? 1117
                            : (session.Character.Inventory.CountItem(9013) > 0 ? 9013 : -1);
                        if (presentationVNum != -1)
                        {
                            string   message    = string.Empty;
                            string[] valuesplit = Value?.Split(' ');
                            if (valuesplit == null)
                            {
                                return;
                            }

                            for (int i = 0; i < valuesplit.Length; i++)
                            {
                                message += valuesplit[i] + "^";
                            }

                            message = message.Substring(0, message.Length - 1); // Remove the last ^
                            message = message.Trim();
                            if (message.Length > 60)
                            {
                                message = message.Substring(0, 60);
                            }

                            session.Character.Biography = message;
                            session.SendPacket(
                                session.Character.GenerateSay(Language.Instance.GetMessageFromKey("INTRODUCTION_SET"),
                                                              10));
                            session.Character.Inventory.RemoveItemAmount(presentationVNum);
                        }
                    }

                    // Speaker
                    if (Argument == 3 && session.Character.Inventory.CountItem(speakerVNum) > 0)
                    {
                        string message =
                            $"[{session.Character.Name}]:";
                        int      baseLength = message.Length;
                        string[] valuesplit = Value?.Split(' ');
                        if (valuesplit == null)
                        {
                            return;
                        }

                        for (int i = 0; i < valuesplit.Length; i++)
                        {
                            message += valuesplit[i] + " ";
                        }

                        if (message.Length > 120 + baseLength)
                        {
                            message = message.Substring(0, 120 + baseLength);
                        }

                        message = message.Replace("\n", string.Empty).Replace("\r", string.Empty)
                                  .Replace($"<{Language.Instance.GetMessageFromKey("SPEAKER")}>", string.Empty).Trim();
                        message = $"<{Language.Instance.GetMessageFromKey("SPEAKER")}> {message}";
                        if (session.Character.IsMuted())
                        {
                            session.SendPacket(
                                session.Character.GenerateSay(
                                    Language.Instance.GetMessageFromKey("SPEAKER_CANT_BE_USED"), 10));
                            return;
                        }

                        session.Character.Inventory.RemoveItemAmount(speakerVNum);
                        ServerManager.Instance.Broadcast(session.Character.GenerateSay(message, 13));

                        if (ServerManager.Instance.Configuration.UseChatLogService)
                        {
                            ChatLogServiceClient.Instance.LogChatMessage(new ChatLogEntry
                            {
                                Sender      = session.Character.Name,
                                SenderId    = session.Character.CharacterId,
                                Receiver    = null,
                                ReceiverId  = null,
                                MessageType = ChatLogType.Speaker,
                                Message     = message
                            });
                        }
                    }

                    if (Argument == 11 && !string.IsNullOrWhiteSpace(Value) &&
                        !string.IsNullOrWhiteSpace(session.Account.TotpSecret))
                    {
                        Totp totp = new Totp(Base32Encoding.ToBytes(session.Account.TotpSecret));
                        if (totp.VerifyTotp(Value, out long _, VerificationWindow.RfcSpecifiedNetworkDelay))
                        {
                            session.Character.GeneralLogs.Add(new GeneralLogDTO
                            {
                                AccountId = session.Account.AccountId,
                                IpAddress = session.IpAddress,
                                LogType   = GeneralLogType.TOTP.ToString(),
                                LogData   = "SUCCESS",
                                Timestamp = DateTime.UtcNow
                            });
                            session.Account.IsVerified = true;
                            session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("TOTP_VERIFIED"), 12));
                        }
                        else
                        {
                            session.Character.GeneralLogs.Add(new GeneralLogDTO
                            {
                                AccountId = session.Account.AccountId,
                                IpAddress = session.IpAddress,
                                LogType   = GeneralLogType.TOTP.ToString(),
                                LogData   = "FAIL",
                                Timestamp = DateTime.UtcNow
                            });
                            session.Disconnect();
                        }
                    }
                }
                else if (Type == 199 && Argument == 1)
                {
                    if (!session.Character.IsFriendOfCharacter(Parameter))
                    {
                        session.SendPacket(Language.Instance.GetMessageFromKey("CHARACTER_NOT_IN_FRIENDLIST"));
                        return;
                    }

                    session.SendPacket(UserInterfaceHelper.GenerateDelay(3000, 4, $"#guri^199^2^{Parameter}"));
                }
                else if (Type == 201)
                {
                    if (session.Character.StaticBonusList.Any(s => s.StaticBonusType == StaticBonusType.PetBasket))
                    {
                        session.SendPacket(session.Character.GenerateStashAll());
                    }
                }
                else if (Type == 202)
                {
                    session.SendPacket(
                        session.Character.GenerateSay(Language.Instance.GetMessageFromKey("PARTNER_BACKPACK"), 10));
                    session.SendPacket(session.Character.GeneratePStashAll());
                }
                else if (Type == 208 && Argument == 0)
                {
                    if (short.TryParse(Value, out short mountSlot) &&
                        Parameter.TryCastToShort(out short pearlSlot))
                    {
                        ItemInstance mount =
                            session.Character.Inventory.LoadBySlotAndType <ItemInstance>(mountSlot, InventoryType.Main);
                        ItemInstance pearl =
                            session.Character.Inventory.LoadBySlotAndType(pearlSlot, InventoryType.Equipment);
                        if (mount != null && pearl != null)
                        {
                            pearl.HoldingVNum = mount.ItemVNum;
                            session.Character.Inventory.RemoveItemFromInventory(mount.Id);
                        }
                    }
                }
                else if (Type == 209 && Argument == 0)
                {
                    if (short.TryParse(Value, out short mountSlot) &&
                        Parameter.TryCastToShort(out short pearlSlot))
                    {
                        ItemInstance fairy =
                            session.Character.Inventory.LoadBySlotAndType(mountSlot, InventoryType.Equipment);
                        ItemInstance pearl =
                            session.Character.Inventory.LoadBySlotAndType(pearlSlot, InventoryType.Equipment);
                        if (fairy != null && pearl != null)
                        {
                            pearl.HoldingVNum = fairy.ItemVNum;
                            pearl.ElementRate = fairy.ElementRate;
                            session.Character.Inventory.RemoveItemFromInventory(fairy.Id);
                        }
                    }
                }
                else if (Type == 203 && Argument == 0)
                {
                    // SP points initialization
                    int[] listPotionResetVNums = { 1366, 1427, 5115, 9040 };
                    int   vnumToUse            = -1;
                    foreach (int vnum in listPotionResetVNums)
                    {
                        if (session.Character.Inventory.CountItem(vnum) > 0)
                        {
                            vnumToUse = vnum;
                        }
                    }

                    if (vnumToUse != -1)
                    {
                        if (session.Character.UseSp)
                        {
                            ItemInstance specialistInstance =
                                session.Character.Inventory.LoadBySlotAndType((byte)EquipmentType.Sp,
                                                                              InventoryType.Wear);
                            if (specialistInstance != null)
                            {
                                specialistInstance.SlDamage  = 0;
                                specialistInstance.SlDefence = 0;
                                specialistInstance.SlElement = 0;
                                specialistInstance.SlHP      = 0;

                                specialistInstance.DamageMinimum        = 0;
                                specialistInstance.DamageMaximum        = 0;
                                specialistInstance.HitRate              = 0;
                                specialistInstance.CriticalLuckRate     = 0;
                                specialistInstance.CriticalRate         = 0;
                                specialistInstance.DefenceDodge         = 0;
                                specialistInstance.DistanceDefenceDodge = 0;
                                specialistInstance.ElementRate          = 0;
                                specialistInstance.DarkResistance       = 0;
                                specialistInstance.LightResistance      = 0;
                                specialistInstance.FireResistance       = 0;
                                specialistInstance.WaterResistance      = 0;
                                specialistInstance.CriticalDodge        = 0;
                                specialistInstance.CloseDefence         = 0;
                                specialistInstance.DistanceDefence      = 0;
                                specialistInstance.MagicDefence         = 0;
                                specialistInstance.HP = 0;
                                specialistInstance.MP = 0;

                                session.Character.Inventory.RemoveItemAmount(vnumToUse);
                                session.Character.Inventory.DeleteFromSlotAndType((byte)EquipmentType.Sp,
                                                                                  InventoryType.Wear);
                                session.Character.Inventory.AddToInventoryWithSlotAndType(specialistInstance,
                                                                                          InventoryType.Wear, (byte)EquipmentType.Sp);
                                session.SendPacket(session.Character.GenerateCond());
                                session.SendPacket(specialistInstance.GenerateSlInfo());
                                session.SendPacket(session.Character.GenerateLev());
                                session.SendPacket(session.Character.GenerateStatChar());
                                session.SendPacket(
                                    UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("POINTS_RESET"),
                                                                    0));
                            }
                        }
                        else
                        {
                            session.SendPacket(
                                session.Character.GenerateSay(
                                    Language.Instance.GetMessageFromKey("TRANSFORMATION_NEEDED"), 10));
                        }
                    }
                    else
                    {
                        session.SendPacket(
                            session.Character.GenerateSay(Language.Instance.GetMessageFromKey("NOT_ENOUGH_POINTS"),
                                                          10));
                    }
                }
            }
Esempio n. 8
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;
            }
        }
Esempio n. 9
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;
            }
        }
Esempio n. 10
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))
                {
                    session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("RAID_OPEN_GROUP"), 12));
                    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));
                    session.SendPacket(session.Character.GenerateRaid(0));
                    session.SendPacket(session.Character.GenerateRaid(1));
                    session.SendPacket(group.GenerateRdlst());
                }
                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, 3014), 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;

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

            case 2081:
                if (!session.Character.Buff.ContainsKey(146))
                {
                    session.Character.Inventory.RemoveItemFromInventory(inv.Id);
                    session.Character.AddStaticBuff(new StaticBuffDTO {
                        CardId = 146
                    });
                }
                else
                {
                    session.SendPacket(UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("ITEM_IN_USE"), 0));
                }
                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 100:
            {
            }
            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 (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, 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;

            // 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.MapInstanceType == MapInstanceType.BaseMapInstance && (session.Character.LastVessel.AddSeconds(1) <= DateTime.Now || session.Character.StaticBonusList.Any(s => s.StaticBonusType == StaticBonusType.FastVessels)))
                {
                    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);
                    session.Character.LastVessel = DateTime.Now;
                }
                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(), VNum, Effect, EffectValue));
                    break;
                }
                break;
            }
        }
Esempio n. 11
0
            public void SummonNpc(MapInstance map)
            {
                List <MapNpc> npc = new List <MapNpc>
                {
                    new MapNpc
                    {
                        NpcVNum   = 922,
                        MapNpcId  = map.GetNextNpcId(),
                        Dialog    = 0,
                        MapId     = map.Map.MapId,
                        MapX      = 59,
                        MapY      = 40,
                        IsMoving  = false,
                        Position  = 0,
                        IsSitting = false,
                        Effect    = 3009,
                        Score     = 5
                    },
                    new MapNpc
                    {
                        NpcVNum   = 923,
                        MapNpcId  = map.GetNextNpcId(),
                        Dialog    = 0,
                        MapId     = map.Map.MapId,
                        MapX      = 74,
                        MapY      = 53,
                        IsMoving  = false,
                        Position  = 0,
                        IsSitting = false,
                        Effect    = 3009,
                        Score     = 2
                    },
                    new MapNpc
                    {
                        NpcVNum   = 923,
                        MapNpcId  = map.GetNextNpcId(),
                        Dialog    = 0,
                        MapId     = map.Map.MapId,
                        MapX      = 32,
                        MapY      = 75,
                        IsMoving  = false,
                        Position  = 0,
                        IsSitting = false,
                        Effect    = 3009,
                        Score     = 2
                    },
                    new MapNpc
                    {
                        NpcVNum   = 923,
                        MapNpcId  = map.GetNextNpcId(),
                        Dialog    = 0,
                        MapId     = map.Map.MapId,
                        MapX      = 85,
                        MapY      = 4,
                        IsMoving  = false,
                        Position  = 0,
                        IsSitting = false,
                        Effect    = 3009,
                        Score     = 2
                    },
                    new MapNpc
                    {
                        NpcVNum   = 923,
                        MapNpcId  = map.GetNextNpcId(),
                        Dialog    = 0,
                        MapId     = map.Map.MapId,
                        MapX      = 43,
                        MapY      = 26,
                        IsMoving  = false,
                        Position  = 0,
                        IsSitting = false,
                        Effect    = 3009,
                        Score     = 2
                    },
                    new MapNpc
                    {
                        NpcVNum   = 924,
                        MapNpcId  = map.GetNextNpcId(),
                        Dialog    = 0,
                        MapId     = map.Map.MapId,
                        MapX      = 15,
                        MapY      = 40,
                        IsMoving  = false,
                        Position  = 0,
                        IsSitting = false,
                        Effect    = 3009,
                        Score     = 1
                    },
                    new MapNpc
                    {
                        NpcVNum   = 924,
                        MapNpcId  = map.GetNextNpcId(),
                        Dialog    = 999,
                        MapId     = map.Map.MapId,
                        MapX      = 102,
                        MapY      = 39,
                        IsMoving  = false,
                        Position  = 0,
                        IsSitting = false,
                        Effect    = 3009,
                        Score     = 1
                    },
                };

                foreach (var Stone in npc)
                {
                    Stone.Dialog = 999;
                    Stone.Initialize(map);
                    map.AddNPC(Stone);
                    map.Broadcast(Stone.GenerateIn());
                    IEnumerable <ClientSession> sess = ServerManager.Instance.Sessions.Where(s => s.Character?.CharacterId == null);
                    foreach (ClientSession ses in sess)
                    {
                        if (Stone.Dialog == 999)
                        {
                            ses.SendPacket(UserInterfaceHelper.GenerateDelay(5000, 1, $"#guri^711^{Stone.MapNpcId}"));
                            Stone.Score++;
                            RainbowBattleManager.SendFbs();
                        }
                    }
                }
            }