Exemplo n.º 1
0
        public SaveResult InsertOrUpdate(ref RespawnMapTypeDTO respawnMapType)
        {
            try
            {
                using (OpenNosContext context = DataAccessHelper.CreateContext())
                {
                    short          mapId  = respawnMapType.DefaultMapId;
                    RespawnMapType entity = context.RespawnMapType.FirstOrDefault(c => c.DefaultMapId.Equals(mapId));

                    if (entity == null)
                    {
                        respawnMapType = insert(respawnMapType, context);
                        return(SaveResult.Inserted);
                    }

                    respawnMapType.RespawnMapTypeId = entity.RespawnMapTypeId;
                    respawnMapType = update(entity, respawnMapType, context);
                    return(SaveResult.Updated);
                }
            }
            catch (Exception e)
            {
                Logger.Error(e);
                return(SaveResult.Error);
            }
        }
Exemplo n.º 2
0
 public static bool ToRespawnMapTypeDTO(RespawnMapType input, RespawnMapTypeDTO output)
 {
     if (input == null)
     {
         return(false);
     }
     output.DefaultMapId     = input.DefaultMapId;
     output.DefaultX         = input.DefaultX;
     output.DefaultY         = input.DefaultY;
     output.Name             = input.Name;
     output.RespawnMapTypeId = input.RespawnMapTypeId;
     return(true);
 }
Exemplo n.º 3
0
        private RespawnMapTypeDTO update(RespawnMapType entity, RespawnMapTypeDTO respawnMapType, OpenNosContext context)
        {
            if (entity != null)
            {
                Mapper.Mapper.Instance.RespawnMapTypeMapper.ToRespawnMapType(respawnMapType, entity);
                context.SaveChanges();
            }
            if (Mapper.Mapper.Instance.RespawnMapTypeMapper.ToRespawnMapTypeDTO(entity, respawnMapType))
            {
                return(respawnMapType);
            }

            return(null);
        }
        // Map
        public void ReviveFirstPosition(long characterId)
        {
            ClientSession session = GetSessionByCharacterId(characterId);

            if (session != null && session.Character.Hp <= 0)
            {
                Random rnd = new Random();
                LeaveMap(session.Character.CharacterId);
                session.Character.Hp = 1;
                session.Character.Mp = 1;
                RespawnMapTypeDTO resp = session.Character.Respawn;
                short             x    = (short)(resp.DefaultX + RandomNumber(-5, 5));
                short             y    = (short)(resp.DefaultY + RandomNumber(-5, 5));
                ChangeMap(session.Character.CharacterId, resp.DefaultMapId, x, y);
                session.CurrentMap?.Broadcast(session, session.Character.GenerateTp());
                session.CurrentMap?.Broadcast(session.Character.GenerateRevive());
                session.SendPacket(session.Character.GenerateStat());
            }
        }
Exemplo n.º 5
0
        public RespawnMapTypeDTO LoadById(long respawnMapTypeId)
        {
            try
            {
                using (OpenNosContext context = DataAccessHelper.CreateContext())
                {
                    RespawnMapTypeDTO dto = new RespawnMapTypeDTO();
                    if (Mapper.Mapper.Instance.RespawnMapTypeMapper.ToRespawnMapTypeDTO(context.RespawnMapType.FirstOrDefault(s => s.RespawnMapTypeId.Equals(respawnMapTypeId)), dto))
                    {
                        return(dto);
                    }

                    return(null);
                }
            }
            catch (Exception e)
            {
                Logger.Error(e);
                return(null);
            }
        }
Exemplo n.º 6
0
        private RespawnMapTypeDTO insert(RespawnMapTypeDTO respawnMapType, OpenNosContext context)
        {
            try
            {
                RespawnMapType entity = new RespawnMapType();
                Mapper.Mapper.Instance.RespawnMapTypeMapper.ToRespawnMapType(respawnMapType, entity);
                context.RespawnMapType.Add(entity);
                context.SaveChanges();
                if (Mapper.Mapper.Instance.RespawnMapTypeMapper.ToRespawnMapTypeDTO(entity, respawnMapType))
                {
                    return(respawnMapType);
                }

                return(null);
            }
            catch (Exception e)
            {
                Logger.Error(e);
                return(null);
            }
        }
Exemplo n.º 7
0
        public RespawnMapTypeDTO LoadByMapId(short mapId)
        {
            try
            {
                using (OpenNosContext context = DataAccessHelper.CreateContext())
                {
                    RespawnMapTypeDTO dto = new RespawnMapTypeDTO();
                    if (Mapper.Mappers.RespawnMapTypeMapper.ToRespawnMapTypeDTO(context.RespawnMapType.AsNoTracking().FirstOrDefault(s => s.DefaultMapId.Equals(mapId)), dto))
                    {
                        return(dto);
                    }

                    return(null);
                }
            }
            catch (Exception e)
            {
                Logger.Error(e);
                return(null);
            }
        }
Exemplo n.º 8
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;
            }
        }
Exemplo n.º 9
0
 public SaveResult InsertOrUpdate(ref RespawnMapTypeDTO respawnMapType)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 10
0
        public override void Use(ClientSession session, ref ItemInstance inv, bool delay = false, string[] packetsplit = null)
        {
            Random random = new Random();

            switch (Effect)
            {
            // airwaves - eventitems
            case 0:
                if (ItemType == ItemType.Event)
                {
                    session.CurrentMap?.Broadcast(session.Character.GenerateEff(EffectValue));
                    if (MappingHelper.GuriItemEffects.ContainsKey(EffectValue))
                    {
                        session.CurrentMap?.Broadcast(session.Character.GenerateGuri(19, 1, MappingHelper.GuriItemEffects[EffectValue]), session.Character.MapX, session.Character.MapY);
                    }
                    session.Character.Inventory.RemoveItemAmountFromInventory(1, inv.Id);
                }
                break;

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

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

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

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

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

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

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

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

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

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

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

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

            default:
                Logger.Log.Warn(string.Format(Language.Instance.GetMessageFromKey("NO_HANDLER_ITEM"), GetType()));
                break;
            }
        }
Exemplo n.º 11
0
        public override void Use(ClientSession session, ref ItemInstance inv, byte option = 0, string[] packetsplit = null)
        {
            switch (Effect)
            {
            // airwaves - eventitems
            case 0:
                if (ItemType == ItemType.Event)
                {
                    session.CurrentMapInstance?.Broadcast(session.Character.GenerateEff(EffectValue));
                    if (MappingHelper.Instance.GuriItemEffects.ContainsKey(EffectValue))
                    {
                        session.CurrentMapInstance?.Broadcast(UserInterfaceHelper.Instance.GenerateGuri(19, 1, session.Character.CharacterId, MappingHelper.Instance.GuriItemEffects[EffectValue]), session.Character.MapX, session.Character.MapY);
                    }
                    session.Character.Inventory.RemoveItemAmountFromInventory(1, inv.Id);
                }
                // APPLY SHELL ON EQUIPMENT
                if (inv.Item.ItemType == ItemType.Shell)
                {
                    if (!((WearableInstance)inv).EquipmentOptions.Any())
                    {
                        session.SendPacket(UserInterfaceHelper.Instance.GenerateMsg(Language.Instance.GetMessageFromKey("SHELL_MUST_BE_IDENTIFIED"), 0));
                        return;
                    }
                    if (packetsplit == null)
                    {
                        return;
                    }

                    if (packetsplit.Length < 9)
                    {
                        // MODIFIED PACKET
                        return;
                    }

                    if (!short.TryParse(packetsplit[9], out short eqSlot) || !Enum.TryParse(packetsplit[8], out InventoryType eqType))
                    {
                        return;
                    }

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

                    WearableInstance shell = (WearableInstance)inv;
                    WearableInstance eq    = session.Character.Inventory.LoadBySlotAndType <WearableInstance>(eqSlot, eqType);

                    if (eq == null)
                    {
                        // PACKET MODIFIED
                        return;
                    }
                    if (eq.Item.ItemType != ItemType.Armor && shell.Item.ItemSubType == 1)
                    {
                        // ARMOR SHELL ONLY APPLY ON ARMORS
                        session.SendPacket(UserInterfaceHelper.Instance.GenerateMsg(Language.Instance.GetMessageFromKey("SHELL_FOR_ARMOR_ONLY"), 0));
                        return;
                    }
                    if (eq.Item.ItemType != ItemType.Weapon && shell.Item.ItemSubType == 0)
                    {
                        // WEAPON SHELL ONLY APPLY ON WEAPONS
                        session.SendPacket(UserInterfaceHelper.Instance.GenerateMsg(Language.Instance.GetMessageFromKey("SHELL_FOR_WEAPON_ONLY"), 0));
                        return;
                    }
                    switch (requestType)
                    {
                    case 0:
                        session.SendPacket(eq.EquipmentOptions.Any()
                                    ? $"qna #u_i^1^{session.Character.CharacterId}^{(short) inv.Type}^{inv.Slot}^1^1^{(short) eqType}^{eqSlot} {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}^{eqSlot} {Language.Instance.GetMessageFromKey("ADD_OPTION_ON_STUFF")}");
                        break;

                    case 1:
                        if (shell.EquipmentOptions == null)
                        {
                            // SHELL NOT IDENTIFIED
                            return;
                        }
                        if (eq.BoundCharacterId != session.Character.CharacterId && eq.BoundCharacterId != null)
                        {
                            // NEED TO PERFUME STUFF BEFORE CHANGING SHELL
                            session.SendPacket(UserInterfaceHelper.Instance.GenerateMsg(Language.Instance.GetMessageFromKey("NEED_PARFUM_TO_CHANGE_SHELL"), 0));
                            return;
                        }
                        if (eq.Rare < shell.Rare)
                        {
                            // RARITY TOO HIGH ON SHELL
                            session.SendPacket(UserInterfaceHelper.Instance.GenerateMsg(Language.Instance.GetMessageFromKey("SHELL_RARITY_TOO_HIGH"), 0));
                            return;
                        }
                        if (eq.Item.LevelMinimum < shell.Upgrade)
                        {
                            // SHELL LEVEL TOO HIGH
                            session.SendPacket(UserInterfaceHelper.Instance.GenerateMsg(Language.Instance.GetMessageFromKey("SHELL_LEVEL_TOO_HIGH"), 0));
                            return;
                        }

                        if (eq.EquipmentOptions?.Any() == true)
                        {
                            if (new Random().Next(100) >= 50)
                            {
                                // BREAK BECAUSE DIDN'T USE MAGIC ERASER
                                session.SendPacket(UserInterfaceHelper.Instance.GenerateMsg(Language.Instance.GetMessageFromKey("SHELL_BROKEN"), 0));
                                session.Character.Inventory.RemoveItemAmountFromInventory(1, shell.Id);
                                return;
                            }
                        }
                        if (eq.EquipmentOptions == null)
                        {
                            eq.EquipmentOptions = new List <EquipmentOptionDTO>();
                        }

                        eq.EquipmentOptions.Clear();
                        foreach (EquipmentOptionDTO i in shell.EquipmentOptions)
                        {
                            session.SendPacket(UserInterfaceHelper.Instance.GenerateGuri(17, 1, session.Character.CharacterId));
                            session.SendPacket(UserInterfaceHelper.Instance.GenerateMsg(Language.Instance.GetMessageFromKey("SHELL_OPTION_SET"), 0));
                            eq.EquipmentOptions.Add(i);
                        }

                        eq.BoundCharacterId = session.Character.CharacterId;
                        eq.ShellRarity      = shell.Rare;
                        session.Character.Inventory.RemoveItemAmountFromInventory(1, shell.Id);
                        break;
                    }
                }
                break;

            //respawn objects
            case 1:
                if (session.Character.MapInstance.MapInstanceType != MapInstanceType.BaseMapInstance)
                {
                    session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("CANT_USE_THAT"), 10));
                    return;
                }
                if (packetsplit != null && int.TryParse(packetsplit[2], out var type) && int.TryParse(packetsplit[3], out var secondaryType) && int.TryParse(packetsplit[4], out var inventoryType) && int.TryParse(packetsplit[5], out var slot))
                {
                    int packetType;
                    switch (EffectValue)
                    {
                    case 0:
                        if (option == 0)
                        {
                            session.SendPacket(UserInterfaceHelper.Instance.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.Instance.GenerateDelay(5000, 7, $"#u_i^{type}^{secondaryType}^{inventoryType}^{slot}^3"));
                                    break;

                                case 2:
                                    session.SendPacket(UserInterfaceHelper.Instance.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.Instance.RandomNumber(-5, 5)), (short)(respawn.DefaultY + ServerManager.Instance.RandomNumber(-5, 5)));
                                    }
                                    session.Character.Inventory.RemoveItemAmountFromInventory(1, 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.Instance.RandomNumber(-5, 5)), (short)(respawnObj.DefaultY + ServerManager.Instance.RandomNumber(-5, 5)));
                                    }
                                    session.Character.Inventory.RemoveItemAmountFromInventory(1, 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.Instance.GenerateRp(respawn.DefaultMapId, respawn.DefaultX, respawn.DefaultY, $"#u_i^{type}^{secondaryType}^{inventoryType}^{slot}^1"));
                                }
                                break;

                            case 1:
                                session.SendPacket(UserInterfaceHelper.Instance.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.RemoveItemAmountFromInventory(1, inv.Id);
                                break;
                            }
                        }
                        break;

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

            // dyes or waxes
            case 10:
            case 11:
                if (!session.Character.IsVehicled)
                {
                    if (Effect == 10)
                    {
                        if (EffectValue == 99)
                        {
                            byte nextValue = (byte)ServerManager.Instance.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.Instance.GenerateMsg(Language.Instance.GetMessageFromKey("ADVENTURERS_CANT_USE"), 10));
                            return;
                        }
                        session.Character.HairStyle = Enum.IsDefined(typeof(HairStyleType), (byte)EffectValue) ? (HairStyleType)EffectValue : 0;
                    }
                    session.SendPacket(session.Character.GenerateEq());
                    session.CurrentMapInstance?.Broadcast(session, session.Character.GenerateIn());
                    session.CurrentMapInstance?.Broadcast(session, session.Character.GenerateGidx());
                    session.Character.Inventory.RemoveItemAmountFromInventory(1, inv.Id);
                }
                break;

            // dignity restoration
            case 14:
                if ((EffectValue == 100 || EffectValue == 200) && session.Character.Dignity < 100 && !session.Character.IsVehicled)
                {
                    session.Character.Dignity += EffectValue;
                    if (session.Character.Dignity > 100)
                    {
                        session.Character.Dignity = 100;
                    }
                    session.SendPacket(session.Character.GenerateFd());
                    session.SendPacket(session.Character.GenerateEff(49 - (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.RemoveItemAmountFromInventory(1, inv.Id);
                }
                else if (EffectValue == 2000 && session.Character.Dignity < 100 && !session.Character.IsVehicled)
                {
                    session.Character.Dignity = 100;
                    session.SendPacket(session.Character.GenerateFd());
                    session.SendPacket(session.Character.GenerateEff(49 - (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.RemoveItemAmountFromInventory(1, inv.Id);
                }
                break;

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

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

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

            //Raid stone
            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))
                {
                    Parallel.ForEach(session.Character.Group.Characters.Replace(s => s.Character.Group?.GroupId == session.Character.Group?.GroupId), sess =>
                    {
                        ServerManager.Instance.TeleportOnRandomPlaceInMap(sess, session.CurrentMapInstance.MapInstanceId);
                    });
                    session.Character.Inventory.RemoveItemAmountFromInventory(1, inv.Id);
                }
                break;

            default:
                Logger.Log.Warn(string.Format(Language.Instance.GetMessageFromKey("NO_HANDLER_ITEM"), GetType()));
                break;
            }
        }
Exemplo n.º 12
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 (inv.ShellEffects.Count > 0 && ServerManager.Instance.RandomNumber() < 50)
                                {
                                    session.Character.DeleteItemByItemInstanceId(inv.Id);
                                    session.SendPacket(UserInterfaceHelper.Instance.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.Instance.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.Instance.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.Instance.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.Instance.GenerateDelay(5000, 7, $"#u_i^{type}^{secondaryType}^{inventoryType}^{slot}^3"));
                                break;

                            case 2:
                                session.SendPacket(UserInterfaceHelper.Instance.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.Instance.RandomNumber(-5, 5)), (short)(respawn.DefaultY + ServerManager.Instance.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.Instance.RandomNumber(-5, 5)), (short)(respawnObj.DefaultY + ServerManager.Instance.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.Instance.GenerateRp(respawn.DefaultMapId, respawn.DefaultX, respawn.DefaultY, $"#u_i^{type}^{secondaryType}^{inventoryType}^{slot}^1"));
                                }
                                break;

                            case 1:
                                session.SendPacket(UserInterfaceHelper.Instance.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.Instance.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.Instance.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.Instance.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.Instance.GenerateGuri(10, 3, session.Character.CharacterId, 1));
                }
                break;

            // bubbles
            case 16:
                if (!session.Character.IsVehicled && Option == 0)
                {
                    session.SendPacket(UserInterfaceHelper.Instance.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.Instance.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.Instance.GenerateMsg(Language.Instance.GetMessageFromKey("NO_WIG"), 0));
                    }
                }
                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()));
                break;
            }
        }
Exemplo n.º 13
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;
            }
        }
Exemplo n.º 14
0
        public override void Use(ClientSession session, ref ItemInstance inv, byte Option = 0, string[] packetsplit = null)
        {
            switch (Effect)
            {
            // Shell
            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 (inv.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;

            //Bank
            case 10066:
                if (session.Character.MapInstance.MapInstanceType != MapInstanceType.BaseMapInstance)
                {
                    return;
                }

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

            case 10541:
                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;
                }

                if (inv.Item.VNum == 2188 /* LoD Teleport Scroll */)
                {
                    session.Character.Inventory.RemoveItemAmount(inv.Item.VNum);
                    ServerManager.Instance.ChangeMap(session.Character.CharacterId, 98, (short)ServerManager.RandomNumber(12, 18), (short)ServerManager.RandomNumber(18, 24));
                    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 (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, 50 - (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, 50 - (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));
                    session.Character.Inventory.RemoveItemFromInventory(inv.Id);
                }
                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;

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

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

            //Teleport Vip shop
            case 9016:
                if (Option == 0)
                {
                    session.SendPacket($"qna #u_i^1^{session.Character.CharacterId}^{(byte)inv.Type}^{inv.Slot}^3 {Language.Instance.GetMessageFromKey("ASK_USE_EC_KEY")}");
                }
                else
                {
                    ServerManager.Instance.ChangeMap(session.Character.CharacterId, 4200, 7, 13);
                    session.SendPacket(
                        session.Character.GenerateSay(
                            Language.Instance.GetMessageFromKey("WELCOME_VIP_SHOP_MAP"), 0));
                }
                break;

            //Haar Fix
            case 9021:
                session.Character.HairStyle = HairStyleType.Hair7;
                session.Character.Inventory.RemoveItemFromInventory(inv.Id);
                ServerManager.Instance.ChangeMapInstance(session.Character.CharacterId,
                                                         session.Character.MapInstanceId, session.Character.PositionX, session.Character.PositionY,
                                                         true);
                break;

            //Haar Fix
            case 9022:
                session.Character.HairStyle = HairStyleType.Hair6;
                session.Character.Inventory.RemoveItemFromInventory(inv.Id);
                ServerManager.Instance.ChangeMapInstance(session.Character.CharacterId,
                                                         session.Character.MapInstanceId, session.Character.PositionX, session.Character.PositionY,
                                                         true);
                break;

            //Pes Item ID: 2457
            case 9030:
                session.SendPacket("wopen 41");
                break;

            //Luinia
            case 9041:
                if (Option == 0)
                {
                    session.SendPacket($"qna #u_i^1^{session.Character.CharacterId}^{(byte)inv.Type}^{inv.Slot}^3 {Language.Instance.GetMessageFromKey("ASK_USE_LUINIA")}");
                }
                else
                {
                    session.CurrentMapInstance?.Broadcast(
                        StaticPacketHelper.GenerateEff(UserType.Player, session.Character.CharacterId,
                                                       647), session.Character.PositionX, session.Character.PositionY);
                    Buff buff = new Buff(35, 10);
                    session.Character.AddBuff(buff, true);
                    session.SendPacket(session.Character.GenerateSay("Luinia la restauración fue utilizada.", 12));
                    session.Character.Inventory.RemoveItemFromInventory(inv.Id);
                }
                break;

            default:
                Logger.Warn(string.Format(Language.Instance.GetMessageFromKey("NO_HANDLER_ITEM"), GetType()));
                break;
            }
        }