Beispiel #1
0
        private void ExecuteHandler(ClientSession session)
        {
            switch (Option)
            {
            case null:
                session.SendPacket(UserInterfaceHelper.GenerateDialog(
                                       $"#b_i^{(byte)InventoryType}^{Slot}^1 #b_i^0^0^5 {Language.Instance.GetMessageFromKey("ASK_TO_DELETE")}"));
                break;

            case 1:
                session.SendPacket(UserInterfaceHelper.GenerateDialog(
                                       $"#b_i^{(byte)InventoryType}^{Slot}^2 #b_i^{(byte)InventoryType}^{Slot}^5 {Language.Instance.GetMessageFromKey("SURE_TO_DELETE")}"));
                break;

            case 2:
                if (session.Character.InExchangeOrTrade || InventoryType == InventoryType.Bazaar)
                {
                    return;
                }

                ItemInstance delInstance =
                    session.Character.Inventory.LoadBySlotAndType(Slot, InventoryType);
                session.Character.DeleteItem(InventoryType, Slot);

                if (delInstance != null)
                {
                    GameLogger.Instance.LogItemDelete(ServerManager.Instance.ChannelId, session.Character.Name,
                                                      session.Character.CharacterId, delInstance, session.CurrentMapInstance?.Map.MapId ?? -1,
                                                      session.Character.PositionX, session.Character.PositionY);
                }

                break;
            }
        }
Beispiel #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;
            }
        }
        private void ExecuteHandler(ClientSession session)
        {
            if (session.CurrentMapInstance?.MapInstanceType == MapInstanceType.BaseMapInstance)
            {
                ClientSession sess = null;
                if (CharacterId.HasValue)
                {
                    sess = ServerManager.Instance.GetSessionByCharacterId(CharacterId.Value);
                }

                if (sess != null && session.Character.MapInstanceId
                    != sess.Character.MapInstanceId)
                {
                    sess.Character.ExchangeInfo    = null;
                    session.Character.ExchangeInfo = null;
                }
                else
                {
                    switch (RequestType)
                    {
                    case RequestExchangeType.Requested:
                        if (!session.HasCurrentMapInstance || !CharacterId.HasValue)
                        {
                            return;
                        }

                        ClientSession targetSession =
                            session.CurrentMapInstance.GetSessionByCharacterId(CharacterId.Value);
                        if (targetSession == null)
                        {
                            return;
                        }

                        if (targetSession.Character.IsAfk)
                        {
                            session.SendPacket(UserInterfaceHelper.GenerateInfo(
                                                   string.Format(Language.Instance.GetMessageFromKey("PLAYER_IS_AFK"),
                                                                 targetSession.Character.Name)));
                        }

                        if (targetSession.Character.Group != null &&
                            targetSession.Character.Group?.GroupType != GroupType.Group)
                        {
                            session.SendPacket(UserInterfaceHelper.GenerateMsg(
                                                   Language.Instance.GetMessageFromKey("EXCHANGE_NOT_ALLOWED_IN_RAID"), 0));
                            return;
                        }

                        if (session.Character.Group != null &&
                            session.Character.Group?.GroupType != GroupType.Group)
                        {
                            session.SendPacket(UserInterfaceHelper.GenerateMsg(
                                                   Language.Instance.GetMessageFromKey("EXCHANGE_NOT_ALLOWED_WITH_RAID_MEMBER"), 0));
                            return;
                        }

                        if (session.Character.IsBlockedByCharacter(CharacterId.Value))
                        {
                            session.SendPacket(
                                UserInterfaceHelper.GenerateInfo(
                                    Language.Instance.GetMessageFromKey("BLACKLIST_BLOCKED")));
                            return;
                        }

                        if (session.Character.Speed == 0 || targetSession.Character.Speed == 0)
                        {
                            session.Character.ExchangeBlocked = true;
                        }

                        if (targetSession.Character.LastSkillUse.AddSeconds(20) > DateTime.UtcNow ||
                            targetSession.Character.LastDefence.AddSeconds(20) > DateTime.UtcNow)
                        {
                            session.SendPacket(UserInterfaceHelper.GenerateInfo(
                                                   string.Format(Language.Instance.GetMessageFromKey("PLAYER_IN_BATTLE"),
                                                                 targetSession.Character.Name)));
                            return;
                        }

                        if (session.Character.LastSkillUse.AddSeconds(20) > DateTime.UtcNow ||
                            session.Character.LastDefence.AddSeconds(20) > DateTime.UtcNow)
                        {
                            session.SendPacket(
                                UserInterfaceHelper.GenerateInfo(Language.Instance.GetMessageFromKey("IN_BATTLE")));
                            return;
                        }

                        if (session.Character.HasShopOpened || targetSession.Character.HasShopOpened)
                        {
                            session.SendPacket(
                                UserInterfaceHelper.GenerateMsg(
                                    Language.Instance.GetMessageFromKey("HAS_SHOP_OPENED"), 10));
                            return;
                        }

                        if (targetSession.Character.ExchangeBlocked)
                        {
                            session.SendPacket(
                                session.Character.GenerateSay(Language.Instance.GetMessageFromKey("TRADE_BLOCKED"),
                                                              11));
                        }
                        else
                        {
                            if (session.Character.InExchangeOrTrade || targetSession.Character.InExchangeOrTrade)
                            {
                                session.SendPacket(
                                    UserInterfaceHelper.GenerateModal(
                                        Language.Instance.GetMessageFromKey("ALREADY_EXCHANGE"), 0));
                            }
                            else
                            {
                                session.SendPacket(UserInterfaceHelper.GenerateModal(
                                                       string.Format(Language.Instance.GetMessageFromKey("YOU_ASK_FOR_EXCHANGE"),
                                                                     targetSession.Character.Name), 0));

                                session.Character.TradeRequests.Add(targetSession.Character.CharacterId);
                                targetSession.SendPacket(UserInterfaceHelper.GenerateDialog(
                                                             $"#req_exc^2^{session.Character.CharacterId} #req_exc^5^{session.Character.CharacterId} {string.Format(Language.Instance.GetMessageFromKey("INCOMING_EXCHANGE"), session.Character.Name)}"));
                            }
                        }

                        break;

                    case RequestExchangeType.Confirmed:     // click Trade button in exchange window
                        if (session.HasCurrentMapInstance && session.HasSelectedCharacter &&
                            session.Character.ExchangeInfo != null &&
                            session.Character.ExchangeInfo.TargetCharacterId
                            != session.Character.CharacterId)
                        {
                            if (!session.HasCurrentMapInstance)
                            {
                                return;
                            }

                            targetSession =
                                session.CurrentMapInstance.GetSessionByCharacterId(session.Character.ExchangeInfo
                                                                                   .TargetCharacterId);

                            if (targetSession == null)
                            {
                                return;
                            }

                            if (session.Character.Group != null &&
                                session.Character.Group?.GroupType != GroupType.Group)
                            {
                                session.SendPacket(UserInterfaceHelper.GenerateMsg(
                                                       Language.Instance.GetMessageFromKey("EXCHANGE_NOT_ALLOWED_IN_RAID"), 0));
                                return;
                            }

                            if (targetSession.Character.Group != null &&
                                targetSession.Character.Group?.GroupType != GroupType.Group)
                            {
                                session.SendPacket(UserInterfaceHelper.GenerateMsg(
                                                       Language.Instance.GetMessageFromKey("EXCHANGE_NOT_ALLOWED_WITH_RAID_MEMBER"),
                                                       0));
                                return;
                            }

                            if (session.IsDisposing || targetSession.IsDisposing)
                            {
                                session.CloseExchange(targetSession);
                                return;
                            }

                            lock (targetSession.Character.Inventory)
                            {
                                lock (session.Character.Inventory)
                                {
                                    ExchangeInfo targetExchange = targetSession.Character.ExchangeInfo;
                                    Inventory    inventory      = targetSession.Character.Inventory;

                                    long gold    = targetSession.Character.Gold;
                                    long maxGold = ServerManager.Instance.Configuration.MaxGold;

                                    if (targetExchange == null || session.Character.ExchangeInfo == null)
                                    {
                                        return;
                                    }

                                    if (session.Character.ExchangeInfo.Validated && targetExchange.Validated)
                                    {
                                        try
                                        {
                                            session.Character.ExchangeInfo.Confirmed = true;
                                            if (targetExchange.Confirmed &&
                                                session.Character.ExchangeInfo.Confirmed)
                                            {
                                                session.SendPacket("exc_close 1");
                                                targetSession.SendPacket("exc_close 1");

                                                bool continues = true;
                                                bool goldmax   = false;
                                                if (!session.Character.Inventory.EnoughPlace(targetExchange
                                                                                             .ExchangeList))
                                                {
                                                    continues = false;
                                                }

                                                continues &=
                                                    inventory.EnoughPlace(session.Character.ExchangeInfo
                                                                          .ExchangeList);
                                                goldmax |= session.Character.ExchangeInfo.Gold + gold > maxGold;
                                                if (session.Character.ExchangeInfo.Gold > session.Character.Gold)
                                                {
                                                    return;
                                                }

                                                goldmax |= targetExchange.Gold + session.Character.Gold > maxGold;
                                                if (!continues || goldmax)
                                                {
                                                    string message = !continues
                                                            ? UserInterfaceHelper.GenerateMsg(
                                                        Language.Instance.GetMessageFromKey("NOT_ENOUGH_PLACE"),
                                                        0)
                                                            : UserInterfaceHelper.GenerateMsg(
                                                        Language.Instance.GetMessageFromKey("MAX_GOLD"), 0);

                                                    session.SendPacket(message);
                                                    targetSession.SendPacket(message);
                                                    session.CloseExchange(targetSession);
                                                }
                                                else
                                                {
                                                    if (session.Character.ExchangeInfo.ExchangeList.Any(ei =>
                                                                                                        !(ei.Item.IsTradable || ei.IsBound)))
                                                    {
                                                        session.SendPacket(
                                                            UserInterfaceHelper.GenerateMsg(
                                                                Language.Instance.GetMessageFromKey(
                                                                    "ITEM_NOT_TRADABLE"), 0));
                                                        session.CloseExchange(targetSession);
                                                    }
                                                    else     // all items can be traded
                                                    {
                                                        session.Character.IsExchanging           =
                                                            targetSession.Character.IsExchanging = true;

                                                        // exchange all items from target to source
                                                        targetSession.Exchange(session);

                                                        // exchange all items from source to target
                                                        session.Exchange(targetSession);

                                                        session.Character.IsExchanging           =
                                                            targetSession.Character.IsExchanging = false;
                                                    }
                                                }
                                            }
                                            else
                                            {
                                                session.SendPacket(UserInterfaceHelper.GenerateInfo(
                                                                       string.Format(
                                                                           Language.Instance.GetMessageFromKey("IN_WAITING_FOR"),
                                                                           targetSession.Character.Name)));
                                            }
                                        }
                                        catch (NullReferenceException nre)
                                        {
                                            Logger.Error(nre);
                                        }
                                    }
                                }
                            }
                        }

                        break;

                    case RequestExchangeType.Cancelled:     // cancel trade thru exchange window
                        if (session.HasCurrentMapInstance && session.Character.ExchangeInfo != null)
                        {
                            targetSession =
                                session.CurrentMapInstance.GetSessionByCharacterId(session.Character.ExchangeInfo
                                                                                   .TargetCharacterId);
                            session.CloseExchange(targetSession);
                        }

                        break;

                    case RequestExchangeType.List:
                        if (sess != null &&
                            (!session.Character.InExchangeOrTrade || !sess.Character.InExchangeOrTrade))
                        {
                            ClientSession otherSession =
                                ServerManager.Instance.GetSessionByCharacterId(CharacterId.Value);
                            if (CharacterId.Value == session.Character.CharacterId ||
                                session.Character.Speed == 0 || otherSession?.Character.TradeRequests.All(s => s != session.Character.CharacterId) != false
                                )
                            {
                                return;
                            }

                            if (session.Character.Group != null &&
                                session.Character.Group?.GroupType != GroupType.Group)
                            {
                                session.SendPacket(UserInterfaceHelper.GenerateMsg(
                                                       Language.Instance.GetMessageFromKey("EXCHANGE_NOT_ALLOWED_IN_RAID"), 0));
                                return;
                            }

                            if (otherSession.Character.Group != null &&
                                otherSession.Character.Group?.GroupType != GroupType.Group)
                            {
                                session.SendPacket(UserInterfaceHelper.GenerateMsg(
                                                       Language.Instance.GetMessageFromKey("EXCHANGE_NOT_ALLOWED_WITH_RAID_MEMBER"),
                                                       0));
                                return;
                            }

                            session.SendPacket($"exc_list 1 {CharacterId} -1");
                            session.Character.ExchangeInfo = new ExchangeInfo
                            {
                                TargetCharacterId = CharacterId.Value,
                                Confirmed         = false
                            };
                            sess.Character.ExchangeInfo = new ExchangeInfo
                            {
                                TargetCharacterId = session.Character.CharacterId,
                                Confirmed         = false
                            };
                            session.CurrentMapInstance?.Broadcast(session,
                                                                  $"exc_list 1 {session.Character.CharacterId} -1", ReceiverType.OnlySomeone,
                                                                  string.Empty, CharacterId.Value);
                        }
                        else
                        {
                            if (CharacterId != null)
                            {
                                session.CurrentMapInstance?.Broadcast(session,
                                                                      UserInterfaceHelper.GenerateModal(
                                                                          Language.Instance.GetMessageFromKey("ALREADY_EXCHANGE"), 0),
                                                                      ReceiverType.OnlySomeone, string.Empty, CharacterId.Value);
                            }
                        }

                        break;

                    case RequestExchangeType.Declined:
                        if (sess != null)
                        {
                            sess.Character.ExchangeInfo = null;
                        }

                        session.Character.ExchangeInfo = null;
                        session.SendPacket(
                            session.Character.GenerateSay(Language.Instance.GetMessageFromKey("YOU_REFUSED"), 10));
                        sess?.SendPacket(
                            session.Character.GenerateSay(
                                string.Format(Language.Instance.GetMessageFromKey("EXCHANGE_REFUSED"),
                                              session.Character.Name), 10));

                        break;

                    default:
                        Logger.Warn(
                            $"Exchange-Request-Type not implemented. RequestType: {RequestType})");
                        break;
                    }
                }
            }
            else
            {
                session.SendPacket(
                    UserInterfaceHelper.GenerateInfo(Language.Instance.GetMessageFromKey("IMPOSSIBLE_TO_USE")));
            }
        }
Beispiel #4
0
        private void ExecuteHandler(ClientSession session)
        {
            if (CharacterId == session.Character.CharacterId)
            {
                return;
            }
            if (IsInvoker)
            {
                if (session.Character.Inventory.CountItem(1981) < 1)
                {
                    return;
                }

                if (session.Character.CharacterRelations.Any(s => s.RelationType == CharacterRelationType.Spouse))
                {
                    session.SendPacket($"info {Language.Instance.GetMessageFromKey("ALREADY_MARRIED")}");
                    return;
                }

                if (session.Character.IsFriendOfCharacter(CharacterId))
                {
                    ClientSession otherSession = ServerManager.Instance.GetSessionByCharacterId(CharacterId);
                    if (otherSession != null)
                    {
                        otherSession.SendPacket(UserInterfaceHelper.GenerateDialog(
                                                    $"#marry^1^{session.Character.CharacterId} #marry^0^{session.Character.CharacterId} " +
                                                    string.Format(Language.Instance.GetMessageFromKey("MARRY_REQUEST"), session.Character.Name)));
                        session.Character.MarriageRequestCharacters.Add(CharacterId);
                        session.Character.Inventory.RemoveItemAmount(1981);
                    }
                }
                else
                {
                    session.SendPacket($"info {Language.Instance.GetMessageFromKey("NOT_FRIEND")}");
                }
            }
            else
            {
                if (session.Character.CharacterRelations.Any(s => s.RelationType == CharacterRelationType.Spouse))
                {
                    session.SendPacket($"info {Language.Instance.GetMessageFromKey("ALREADY_MARRIED")}");
                    return;
                }
                if (ServerManager.Instance.GetSessionByCharacterId(CharacterId) is ClientSession targetsSession &&
                    targetsSession.Character.MarriageRequestCharacters.Any(s => s == session.Character.CharacterId))
                {
                    if (Accept)
                    {
                        session.Character.DeleteRelation(CharacterId);
                        session.Character.AddRelation(CharacterId, CharacterRelationType.Spouse);

                        ServerManager.Instance.Broadcast(UserInterfaceHelper.GenerateMsg(
                                                             string.Format(Language.Instance.GetMessageFromKey("MARRIAGE_ACCEPT"),
                                                                           session.Character.Name,
                                                                           targetsSession.Character.Name), 0));
                        session.CurrentMapInstance.Broadcast(
                            StaticPacketHelper.GenerateEff(UserType.Player, CharacterId, 850));
                        session.CurrentMapInstance.Broadcast(
                            StaticPacketHelper.GenerateEff(UserType.Player, session.Character.CharacterId, 850));
                    }
                    else
                    {
                        ServerManager.Instance.Broadcast(UserInterfaceHelper.GenerateMsg(
                                                             string.Format(Language.Instance.GetMessageFromKey("MARRIAGE_REJECT"),
                                                                           session.Character.Name,
                                                                           targetsSession.Character.Name), 0));
                    }

                    targetsSession.Character.MarriageRequestCharacters.Remove(session.Character.CharacterId);
                }
            }
        }
Beispiel #5
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;
            }
        }
Beispiel #6
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;
            }
        }
Beispiel #7
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;
            }
        }
Beispiel #8
0
        private void ExecuteHandler(ClientSession session)
        {
            foreach (ScriptedInstance portal in session.CurrentMapInstance.ScriptedInstances)
            {
                if (session.Character.PositionY >= portal.PositionY - 1 &&
                    session.Character.PositionY <= portal.PositionY + 1 &&
                    session.Character.PositionX >= portal.PositionX - 1 &&
                    session.Character.PositionX <= portal.PositionX + 1)
                {
                    switch (Value)
                    {
                    case 0:
                        if (session.Character.Group?.Characters.Any(s =>
                                                                    s.CurrentMapInstance.InstanceBag?.Lock == false &&
                                                                    s.CurrentMapInstance.MapInstanceType == MapInstanceType.TimeSpaceInstance &&
                                                                    s.Character.MapId == portal.MapId &&
                                                                    s.Character.CharacterId != session.Character.CharacterId &&
                                                                    s.Character.MapX == portal.PositionX &&
                                                                    s.Character.MapY == portal.PositionY) == true)
                        {
                            session.SendPacket(UserInterfaceHelper.GenerateDialog(
                                                   $"#wreq^3^{session.Character.CharacterId} #wreq^0^1 {Language.Instance.GetMessageFromKey("ASK_JOIN_TEAM_TS")}"));
                        }
                        else
                        {
                            session.SendPacket(portal.GenerateRbr());
                        }

                        break;

                    case 1:
                        if (!Parameter.HasValue)
                        {
                            session.EnterInstance(portal);
                        }
                        else if (Parameter.Value == 1)
                        {
                            TreqPacket.HandlePacket(session, $"1 treq {portal.PositionX} {portal.PositionY} 1 1");
                        }
                        break;

                    case 3:
                        if (!Parameter.HasValue)
                        {
                            return;
                        }
                        ClientSession clientSession =
                            session.Character.Group?.Characters.Find(s => s.Character.CharacterId == Parameter.Value);
                        if (clientSession != null)
                        {
                            if (session.Character.Level < portal.LevelMinimum)
                            {
                                session.SendPacket(UserInterfaceHelper.GenerateMsg(
                                                       Language.Instance.GetMessageFromKey("NOT_REQUIERED_LEVEL"), 0));
                                return;
                            }

                            MapCell mapcell = clientSession.CurrentMapInstance.Map.GetRandomPosition();
                            session.Character.MapX = portal.PositionX;
                            session.Character.MapY = portal.PositionY;
                            ServerManager.Instance.ChangeMapInstance(session.Character.CharacterId,
                                                                     clientSession.CurrentMapInstance.MapInstanceId, mapcell.X, mapcell.Y);
                            session.SendPacket(portal.GenerateMainInfo());
                            session.SendPackets(portal.GenerateMinimap());
                            session.SendPacket(portal.FirstMap.InstanceBag.GenerateScore());
                            session.Character.Timespace = portal;
                        }

                        // TODO: Implement
                        break;
                    }
                }
            }
        }
        private void ExecuteHandler(ClientSession session)
        {
            bool          createNewGroup = true;
            ClientSession targetSession  = ServerManager.Instance.GetSessionByCharacterId(CharacterId);

            if (targetSession == null && !RequestType.Equals(GroupRequestType.Sharing))
            {
                return;
            }
            // HUANTERS FIX
            if (session.Character.IsBlockedByCharacter(CharacterId))
            {
                session.SendPacket(
                    UserInterfaceHelper.GenerateInfo(
                        Language.Instance.GetMessageFromKey("BLACKLIST_BLOCKED")));
                return;
            }
            if (RequestType.Equals(GroupRequestType.Requested) ||
                RequestType.Equals(GroupRequestType.Invited))
            {
                if (CharacterId == 0)
                {
                    return;
                }

                if (ServerManager.Instance.IsCharactersGroupFull(CharacterId))
                {
                    session.SendPacket(
                        UserInterfaceHelper.GenerateInfo(Language.Instance.GetMessageFromKey("GROUP_FULL")));
                    return;
                }

                if (ServerManager.Instance.IsCharacterMemberOfGroup(CharacterId) &&
                    ServerManager.Instance.IsCharacterMemberOfGroup(session.Character.CharacterId))
                {
                    session.SendPacket(
                        UserInterfaceHelper.GenerateInfo(Language.Instance.GetMessageFromKey("ALREADY_IN_GROUP")));
                    return;
                }

                if (session.Character.CharacterId != CharacterId && targetSession != null)
                {
                    if (session.Character.IsBlockedByCharacter(CharacterId))
                    {
                        session.SendPacket(
                            UserInterfaceHelper.GenerateInfo(
                                Language.Instance.GetMessageFromKey("BLACKLIST_BLOCKED")));
                        return;
                    }

                    if (targetSession.Character.GroupRequestBlocked)
                    {
                        session.SendPacket(
                            UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("GROUP_BLOCKED"),
                                                            0));
                    }
                    else
                    {
                        // save sent group request to current character
                        session.Character.GroupSentRequestCharacterIds.Add(targetSession.Character.CharacterId);
                        if (session.Character.Group == null || session.Character.Group.GroupType == GroupType.Group)
                        {
                            if (targetSession.Character?.Group == null ||
                                targetSession.Character?.Group.GroupType == GroupType.Group)
                            {
                                session.SendPacket(UserInterfaceHelper.GenerateInfo(
                                                       string.Format(Language.Instance.GetMessageFromKey("GROUP_REQUEST"),
                                                                     targetSession.Character.Name)));
                                targetSession.SendPacket(UserInterfaceHelper.GenerateDialog(
                                                             $"#pjoin^3^{session.Character.CharacterId} #pjoin^4^{session.Character.CharacterId} {string.Format(Language.Instance.GetMessageFromKey("INVITED_YOU"), session.Character.Name)}"));
                                if (targetSession.Character.IsAfk)
                                {
                                    session.SendPacket(UserInterfaceHelper.GenerateInfo(
                                                           string.Format(Language.Instance.GetMessageFromKey("PLAYER_IS_AFK"),
                                                                         targetSession.Character.Name)));
                                }
                            }
                        }
                        else
                        {
                            targetSession.SendPacket(
                                $"qna #rd^1^{session.Character.CharacterId}^1 {string.Format(Language.Instance.GetMessageFromKey("INVITE_RAID"), session.Character.Name)}");
                        }
                    }
                }
            }
            else if (RequestType.Equals(GroupRequestType.Sharing))
            {
                if (session.Character.Group != null)
                {
                    session.SendPacket(
                        UserInterfaceHelper.GenerateInfo(Language.Instance.GetMessageFromKey("GROUP_SHARE_INFO")));
                    session.Character.Group.Characters
                    .Where(s => s.Character.CharacterId != session.Character.CharacterId).ToList().ForEach(s =>
                    {
                        s.SendPacket(UserInterfaceHelper.GenerateDialog(
                                         $"#pjoin^6^{session.Character.CharacterId} #pjoin^7^{session.Character.CharacterId} {string.Format(Language.Instance.GetMessageFromKey("INVITED_YOU_SHARE"), session.Character.Name)}"));
                        session.Character.GroupSentRequestCharacterIds.Add(s.Character.CharacterId);
                    });
                }
            }
            else if (RequestType.Equals(GroupRequestType.Accepted))
            {
                if (targetSession?.Character.GroupSentRequestCharacterIds.GetAllItems()
                    .Contains(session.Character.CharacterId) == false)
                {
                    return;
                }

                try
                {
                    targetSession?.Character.GroupSentRequestCharacterIds.Remove(session.Character.CharacterId);
                }
                catch (Exception ex)
                {
                    Logger.Error(ex);
                }

                if (ServerManager.Instance.IsCharacterMemberOfGroup(session.Character.CharacterId) &&
                    ServerManager.Instance.IsCharacterMemberOfGroup(CharacterId))
                {
                    // everyone is in group, return
                    return;
                }

                if (ServerManager.Instance.IsCharactersGroupFull(CharacterId) ||
                    ServerManager.Instance.IsCharactersGroupFull(session.Character.CharacterId))
                {
                    session.SendPacket(
                        UserInterfaceHelper.GenerateInfo(Language.Instance.GetMessageFromKey("GROUP_FULL")));
                    targetSession?.SendPacket(
                        UserInterfaceHelper.GenerateInfo(Language.Instance.GetMessageFromKey("GROUP_FULL")));
                    return;
                }

                // get group and add to group
                if (ServerManager.Instance.IsCharacterMemberOfGroup(session.Character.CharacterId))
                {
                    // target joins source
                    Group currentGroup =
                        ServerManager.Instance.GetGroupByCharacterId(session.Character.CharacterId);

                    if (currentGroup != null)
                    {
                        currentGroup.JoinGroup(targetSession);
                        targetSession?.SendPacket(
                            UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("JOINED_GROUP"),
                                                            10));
                        createNewGroup = false;
                    }
                }
                else if (ServerManager.Instance.IsCharacterMemberOfGroup(CharacterId))
                {
                    // source joins target
                    Group currentGroup = ServerManager.Instance.GetGroupByCharacterId(CharacterId);

                    if (currentGroup != null)
                    {
                        createNewGroup = false;
                        if (currentGroup.GroupType == GroupType.Group)
                        {
                            currentGroup.JoinGroup(session);
                        }
                        else
                        {
                            if (currentGroup.Raid != null)
                            {
                                if ((currentGroup.Raid.Id == 16 && session.Character.RaidDracoRuns > 255) ||
                                    (currentGroup.Raid.Id == 17 && session.Character.RaidGlacerusRuns > 255))
                                {
                                    session.SendPacket(session.Character.GenerateSay(
                                                           Language.Instance.GetMessageFromKey("RAID_LIMIT_EXCEEDED"), 10));
                                    return;
                                }

                                if ((currentGroup.Raid.Id == 16 && session.Character.Inventory
                                     .LoadBySlotAndType((short)EquipmentType.Amulet, InventoryType.Wear)?.ItemVNum != 4503) ||
                                    (currentGroup.Raid.Id == 17 && session.Character.Inventory
                                     .LoadBySlotAndType((short)EquipmentType.Amulet, InventoryType.Wear)?.ItemVNum != 4504))
                                {
                                    session.SendPacket(session.Character.GenerateSay(
                                                           Language.Instance.GetMessageFromKey("RAID_MISSING_ITEM"), 10));
                                    return;
                                }

                                session.SendPacket(
                                    session.Character.GenerateSay(Language.Instance.GetMessageFromKey("RAID_JOIN"),
                                                                  10));
                                if (session.Character.Level > currentGroup.Raid.LevelMaximum ||
                                    session.Character.Level < currentGroup.Raid.LevelMinimum)
                                {
                                    session.SendPacket(session.Character.GenerateSay(
                                                           Language.Instance.GetMessageFromKey("RAID_LEVEL_INCORRECT"), 10));
                                    if (session.Character.Level
                                        >= currentGroup.Raid.LevelMaximum + 10 /* && AlreadySuccededToday*/)
                                    {
                                        //modal 1 ALREADY_SUCCEDED_AS_ASSISTANT
                                    }
                                }

                                currentGroup.JoinGroup(session);
                                session.SendPacket(session.Character.GenerateRaid(1));
                                currentGroup.Characters.ForEach(s =>
                                {
                                    s.SendPacket(currentGroup.GenerateRdlst());
                                    s.SendPacket(s.Character.GenerateSay(
                                                     string.Format(Language.Instance.GetMessageFromKey("JOIN_TEAM"),
                                                                   session.Character.Name), 10));
                                    // TEMPORARY: This fix is Temporary, confirm it works or fix.
                                    if (currentGroup.IsLeader(s))
                                    {
                                        s.SendPacket(s.Character.GenerateRaid(0));
                                    }
                                    else
                                    {
                                        s.SendPacket(s.Character.GenerateRaid(2));
                                    }
                                });
                            }
                        }
                    }
                }

                if (createNewGroup)
                {
                    Group group = new Group
                    {
                        GroupType = GroupType.Group
                    };
                    group.JoinGroup(CharacterId);
                    session.SendPacket(UserInterfaceHelper.GenerateMsg(
                                           string.Format(Language.Instance.GetMessageFromKey("GROUP_JOIN"),
                                                         targetSession?.Character.Name), 10));
                    group.JoinGroup(session.Character.CharacterId);
                    ServerManager.Instance.AddGroup(group);
                    targetSession?.SendPacket(
                        UserInterfaceHelper.GenerateInfo(Language.Instance.GetMessageFromKey("GROUP_ADMIN")));

                    // set back reference to group
                    session.Character.Group = group;
                    if (targetSession != null)
                    {
                        targetSession.Character.Group = group;
                    }
                }

                if (session.Character.Group.GroupType == GroupType.Group)
                {
                    // player join group
                    ServerManager.Instance.UpdateGroup(CharacterId);
                    session.CurrentMapInstance?.Broadcast(session.Character.GeneratePidx());
                }
            }
            else if (RequestType == GroupRequestType.Declined)
            {
                if (targetSession?.Character.GroupSentRequestCharacterIds.GetAllItems()
                    .Contains(session.Character.CharacterId) == false)
                {
                    return;
                }

                targetSession?.Character.GroupSentRequestCharacterIds.Remove(session.Character.CharacterId);

                targetSession?.SendPacket(session.Character.GenerateSay(
                                              string.Format(Language.Instance.GetMessageFromKey("REFUSED_GROUP_REQUEST"),
                                                            session.Character.Name), 10));
            }
            else if (RequestType == GroupRequestType.AcceptedShare)
            {
                if (targetSession?.Character.GroupSentRequestCharacterIds.GetAllItems()
                    .Contains(session.Character.CharacterId) == false)
                {
                    return;
                }

                targetSession?.Character.GroupSentRequestCharacterIds.Remove(session.Character.CharacterId);

                session.SendPacket(UserInterfaceHelper.GenerateMsg(
                                       string.Format(Language.Instance.GetMessageFromKey("ACCEPTED_SHARE"),
                                                     targetSession?.Character.Name), 0));
                if (session.Character?.Group?.IsMemberOfGroup(CharacterId) == true &&
                    targetSession != null)
                {
                    session.Character.SetReturnPoint(targetSession.Character.Return.DefaultMapId,
                                                     targetSession.Character.Return.DefaultX, targetSession.Character.Return.DefaultY);
                    targetSession.SendPacket(UserInterfaceHelper.GenerateMsg(
                                                 string.Format(Language.Instance.GetMessageFromKey("CHANGED_SHARE"),
                                                               targetSession.Character.Name), 0));
                }
            }
            else if (RequestType == GroupRequestType.DeclinedShare)
            {
                if (targetSession?.Character.GroupSentRequestCharacterIds.GetAllItems()
                    .Contains(session.Character.CharacterId) == false)
                {
                    return;
                }

                targetSession?.Character.GroupSentRequestCharacterIds.Remove(session.Character.CharacterId);

                session.SendPacket(
                    UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("REFUSED_SHARE"), 0));
            }
        }
        private void ExecuteHandler(ClientSession session)
        {
            if (session.Character.Family == null || session.Character.FamilyCharacter == null)
            {
                return;
            }

            if (session.Character.FamilyCharacter.Authority == FamilyAuthority.Member ||
                (session.Character.FamilyCharacter.Authority == FamilyAuthority.Manager &&
                 !session.Character.Family.ManagerCanInvite))
            {
                session.SendPacket(UserInterfaceHelper.GenerateInfo(
                                       string.Format(Language.Instance.GetMessageFromKey("FAMILY_INVITATION_NOT_ALLOWED"))));
                return;
            }

            ClientSession otherSession = ServerManager.Instance.GetSessionByCharacterName(Name);

            if (otherSession == null)
            {
                session.SendPacket(
                    UserInterfaceHelper.GenerateInfo(
                        string.Format(Language.Instance.GetMessageFromKey("USER_NOT_FOUND"))));
                return;
            }

            GameLogger.Instance.LogGuildInvite(ServerManager.Instance.ChannelId, session.Character.Name,
                                               session.Character.CharacterId, session.Character.Family.Name, session.Character.Family.FamilyId,
                                               otherSession.Character.Name, otherSession.Character.CharacterId);

            if (session.Character.IsBlockedByCharacter(otherSession.Character.CharacterId))
            {
                session.SendPacket(
                    UserInterfaceHelper.GenerateInfo(Language.Instance.GetMessageFromKey("BLACKLIST_BLOCKED")));
                return;
            }

            if (session.Character.Family.FamilyCharacters.Count + 1 > session.Character.Family.MaxSize)
            {
                session.SendPacket(
                    UserInterfaceHelper.GenerateInfo(Language.Instance.GetMessageFromKey("FAMILY_FULL")));
                return;
            }

            if (otherSession.Character.Family != null || otherSession.Character.FamilyCharacter != null)
            {
                session.SendPacket(
                    UserInterfaceHelper.GenerateInfo(Language.Instance.GetMessageFromKey("ALREADY_IN_FAMILY")));
                return;
            }

            if (otherSession.Character.LastFamilyLeave > DateTime.UtcNow.AddDays(-1).Ticks)
            {
                session.SendPacket(
                    UserInterfaceHelper.GenerateInfo(Language.Instance.GetMessageFromKey("CANT_ENTER_FAMILY")));
                return;
            }

            session.SendPacket(UserInterfaceHelper.GenerateInfo(
                                   string.Format(Language.Instance.GetMessageFromKey("FAMILY_INVITED"), otherSession.Character.Name)));
            otherSession.SendPacket(UserInterfaceHelper.GenerateDialog(
                                        $"#gjoin^1^{session.Character.CharacterId} #gjoin^2^{session.Character.CharacterId} {string.Format(Language.Instance.GetMessageFromKey("ASK_FAMILY_INVITED"), session.Character.Family.Name)}"));
            session.Character.FamilyInviteCharacters.Add(otherSession.Character.CharacterId);
        }
        private void ExecuteHandler(ClientSession session)
        {
            if (!session.HasCurrentMapInstance)
            {
                return;
            }
            double currentRunningSeconds =
                (DateTime.UtcNow - Process.GetCurrentProcess().StartTime.AddHours(-2).AddSeconds(-50)).TotalSeconds;
            double timeSpanSinceLastPortal = currentRunningSeconds - session.Character.LastPortal;

            if (!(timeSpanSinceLastPortal >= 4) || !session.HasCurrentMapInstance)
            {
                session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("CANT_MOVE"), 10));
                return;
            }

            if (session.CurrentMapInstance.Portals.Concat(session.Character.GetExtraPortal())
                .FirstOrDefault(s =>
                                session.Character.PositionY >= s.SourceY - 1 && session.Character.PositionY <= s.SourceY + 1 &&
                                session.Character.PositionX >= s.SourceX - 1 &&
                                session.Character.PositionX
                                <= s.SourceX + 1) is Portal
                portal)
            {
                switch (portal.Type)
                {
                case (sbyte)PortalType.MapPortal:
                case (sbyte)PortalType.TsNormal:
                case (sbyte)PortalType.Open:
                case (sbyte)PortalType.Miniland:
                case (sbyte)PortalType.TsEnd:
                case (sbyte)PortalType.Exit:
                case (sbyte)PortalType.Effect:
                case (sbyte)PortalType.ShopTeleport:
                    break;

                case (sbyte)PortalType.Raid:
                    if (session.Character.Group?.Raid != null)
                    {
                        if (session.Character.Group.IsLeader(session))
                        {
                            session.SendPacket(
                                $"qna #mkraid^0^275 {Language.Instance.GetMessageFromKey("RAID_START_QUESTION")}");
                        }
                        else
                        {
                            session.SendPacket(
                                session.Character.GenerateSay(
                                    Language.Instance.GetMessageFromKey("NOT_TEAM_LEADER"), 10));
                        }
                    }
                    else
                    {
                        session.SendPacket(
                            session.Character.GenerateSay(Language.Instance.GetMessageFromKey("NEED_TEAM"), 10));
                    }

                    return;

                case (sbyte)PortalType.BlueRaid:
                case (sbyte)PortalType.DarkRaid:
                    if ((int)session.Character.Faction == portal.Type - 9 &&
                        session.Character.Family?.Act4Raid != null &&
                        session.Character.Level > 59 &&
                        session.Character.Reputation > 60000)
                    {
                        session.Character.SetReputation(session.Character.Level * -50);

                        session.Character.LastPortal = currentRunningSeconds;

                        switch (session.Character.Family.Act4Raid.MapInstanceType)
                        {
                        case MapInstanceType.Act4Morcos:
                            ServerManager.Instance.ChangeMapInstance(session.Character.CharacterId,
                                                                     session.Character.Family.Act4Raid.MapInstanceId, 43, 179);
                            break;

                        case MapInstanceType.Act4Hatus:
                            ServerManager.Instance.ChangeMapInstance(session.Character.CharacterId,
                                                                     session.Character.Family.Act4Raid.MapInstanceId, 15, 9);
                            break;

                        case MapInstanceType.Act4Calvina:
                            ServerManager.Instance.ChangeMapInstance(session.Character.CharacterId,
                                                                     session.Character.Family.Act4Raid.MapInstanceId, 24, 6);
                            break;

                        case MapInstanceType.Act4Berios:
                            ServerManager.Instance.ChangeMapInstance(session.Character.CharacterId,
                                                                     session.Character.Family.Act4Raid.MapInstanceId, 20, 20);
                            break;
                        }
                    }
                    else
                    {
                        session.SendPacket(
                            session.Character.GenerateSay(Language.Instance.GetMessageFromKey("PORTAL_BLOCKED"),
                                                          10));
                    }

                    return;

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

                if (session.CurrentMapInstance.MapInstanceType == MapInstanceType.TimeSpaceInstance &&
                    !session.Character.Timespace.InstanceBag.Lock)
                {
                    if (session.Character.CharacterId == session.Character.Timespace.InstanceBag.CreatorId)
                    {
                        session.SendPacket(UserInterfaceHelper.GenerateDialog(
                                               $"#rstart^1 rstart {Language.Instance.GetMessageFromKey("FIRST_ROOM_START")}"));
                    }

                    return;
                }

                portal.OnTraversalEvents.ForEach(e => EventHelper.Instance.RunEvent(e));
                if (portal.DestinationMapInstanceId == default)
                {
                    return;
                }

                if (ServerManager.Instance.ChannelId == 51)
                {
                    if ((session.Character.Faction == FactionType.Angel && portal.DestinationMapId == 131) ||
                        (session.Character.Faction == FactionType.Demon && portal.DestinationMapId == 130))
                    {
                        session.SendPacket(
                            session.Character.GenerateSay(Language.Instance.GetMessageFromKey("PORTAL_BLOCKED"), 10));
                        return;
                    }

                    if ((portal.DestinationMapId == 130 || portal.DestinationMapId == 131) &&
                        timeSpanSinceLastPortal < 60)
                    {
                        session.SendPacket(
                            session.Character.GenerateSay(Language.Instance.GetMessageFromKey("CANT_MOVE"), 10));
                        return;
                    }
                }

                session.SendPacket(session.CurrentMapInstance.GenerateRsfn());

                session.Character.LastPortal = currentRunningSeconds;

                if (ServerManager.GetMapInstance(portal.SourceMapInstanceId).MapInstanceType
                    != MapInstanceType.BaseMapInstance &&
                    ServerManager.GetMapInstance(portal.DestinationMapInstanceId).MapInstanceType
                    == MapInstanceType.BaseMapInstance)
                {
                    ServerManager.Instance.ChangeMap(session.Character.CharacterId, session.Character.MapId,
                                                     session.Character.MapX, session.Character.MapY);
                }
                else if (portal.DestinationMapInstanceId == session.Character.Miniland.MapInstanceId)
                {
                    ServerManager.Instance.JoinMiniland(session, session);
                }
                else if (portal.DestinationMapId == 20000)
                {
                    ClientSession sess = ServerManager.Instance.Sessions.FirstOrDefault(s =>
                                                                                        s.Character.Miniland.MapInstanceId == portal.DestinationMapInstanceId);
                    if (sess != null)
                    {
                        ServerManager.Instance.JoinMiniland(session, sess);
                    }
                }
                else
                {
                    if (ServerManager.Instance.ChannelId == 51)
                    {
                        short destinationX = portal.DestinationX;
                        short destinationY = portal.DestinationY;

                        if (portal.DestinationMapInstanceId == CaligorRaid.CaligorMapInstance?.MapInstanceId
                            ) /* Caligor Raid Map */
                        {
                            switch (session.Character.Faction)
                            {
                            case FactionType.Angel:
                                destinationX = 50;
                                destinationY = 172;
                                break;

                            case FactionType.Demon:
                                destinationX = 130;
                                destinationY = 172;
                                break;
                            }
                        }
                        else if (portal.DestinationMapId == 153) /* Unknown Land */
                        {
                            switch (session.Character.Faction)
                            {
                            case FactionType.Angel:
                                destinationX = 50;
                                destinationY = 172;
                                break;

                            case FactionType.Demon:
                                destinationX = 130;
                                destinationY = 172;
                                break;
                            }
                        }

                        ServerManager.Instance.ChangeMapInstance(session.Character.CharacterId,
                                                                 portal.DestinationMapInstanceId, destinationX, destinationY);
                    }
                    else
                    {
                        ServerManager.Instance.ChangeMapInstance(session.Character.CharacterId,
                                                                 portal.DestinationMapInstanceId, portal.DestinationX, portal.DestinationY);
                    }
                }
            }
        }
Beispiel #12
0
        private void ExecuteHandler(ClientSession session)
        {
            if (session.CurrentMapInstance?.MapInstanceType == MapInstanceType.BaseMapInstance)
            {
                if (!session.Character.IsFriendlistFull())
                {
                    long characterId = CharacterId;
                    if (!session.Character.IsFriendOfCharacter(characterId))
                    {
                        if (!session.Character.IsBlockedByCharacter(characterId))
                        {
                            if (!session.Character.IsBlockingCharacter(characterId))
                            {
                                ClientSession otherSession =
                                    ServerManager.Instance.GetSessionByCharacterId(characterId);
                                if (otherSession != null)
                                {
                                    if (otherSession.Character.FriendRequestBlocked)
                                    {
                                        session.SendPacket(
                                            UserInterfaceHelper.GenerateInfo(Language.Instance.GetMessageFromKey("FRIEND_REJECTED")));
                                        return;
                                    }

                                    if (otherSession.Character.FriendRequestCharacters.GetAllItems()
                                        .Contains(session.Character.CharacterId))
                                    {
                                        switch (Type)
                                        {
                                        case 1:
                                            session.Character.AddRelation(characterId,
                                                                          CharacterRelationType.Friend);
                                            session.SendPacket(
                                                UserInterfaceHelper.GenerateInfo(Language.Instance.GetMessageFromKey("FRIEND_ADDED")));
                                            otherSession.SendPacket(
                                                UserInterfaceHelper.GenerateInfo(Language.Instance.GetMessageFromKey("FRIEND_ADDED")));
                                            break;

                                        case 2:
                                            otherSession.SendPacket(
                                                UserInterfaceHelper.GenerateInfo(Language.Instance.GetMessageFromKey("FRIEND_REJECTED")));
                                            break;

                                        default:
                                            if (session.Character.IsFriendlistFull())
                                            {
                                                session.SendPacket(
                                                    UserInterfaceHelper.GenerateInfo(Language.Instance.GetMessageFromKey("FRIEND_FULL")));
                                                otherSession.SendPacket(
                                                    UserInterfaceHelper.GenerateInfo(Language.Instance.GetMessageFromKey("FRIEND_FULL")));
                                            }

                                            break;
                                        }
                                    }
                                    else
                                    {
                                        otherSession.SendPacket(UserInterfaceHelper.GenerateDialog(
                                                                    $"#fins^1^{session.Character.CharacterId} #fins^2^{session.Character.CharacterId} {string.Format(Language.Instance.GetMessageFromKey("FRIEND_ADD"), session.Character.Name)}"));
                                        session.Character.FriendRequestCharacters.Add(characterId);
                                        if (otherSession.Character.IsAfk)
                                        {
                                            session.SendPacket(UserInterfaceHelper.GenerateInfo(
                                                                   string.Format(Language.Instance.GetMessageFromKey("PLAYER_IS_AFK"),
                                                                                 otherSession.Character.Name)));
                                        }
                                    }
                                }
                            }
                            else
                            {
                                session.SendPacket(UserInterfaceHelper.GenerateInfo(Language.Instance.GetMessageFromKey("BLACKLIST_BLOCKING")));
                            }
                        }
                        else
                        {
                            session.SendPacket(UserInterfaceHelper.GenerateInfo(Language.Instance.GetMessageFromKey("BLACKLIST_BLOCKED")));
                        }
                    }
                    else
                    {
                        session.SendPacket(UserInterfaceHelper.GenerateInfo(Language.Instance.GetMessageFromKey("ALREADY_FRIEND")));
                    }
                }
                else
                {
                    session.SendPacket(UserInterfaceHelper.GenerateInfo(Language.Instance.GetMessageFromKey("FRIEND_FULL")));
                }
            }
            else
            {
                session.SendPacket(
                    UserInterfaceHelper.GenerateInfo(Language.Instance.GetMessageFromKey("IMPOSSIBLE_TO_USE")));
            }
        }