コード例 #1
0
        public static void NRun(ClientSession Session, NRunPacket packet)
        {
            if (!Session.HasCurrentMapInstance)
            {
                return;
            }
            MapNpc        npc = Session.CurrentMapInstance.Npcs.Find(s => s.MapNpcId == packet.NpcId);
            TeleporterDTO tp;

            switch (packet.Runner)
            {
            case 1:
                if (Session.Character.Class != (byte)ClassType.Adventurer)
                {
                    Session.SendPacket(UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("NOT_ADVENTURER"), 0));
                    return;
                }
                if (Session.Character.Level < 15 || Session.Character.JobLevel < 20)
                {
                    Session.SendPacket(UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("LOW_LVL"), 0));
                    return;
                }
                if (packet.Type == (byte)Session.Character.Class)
                {
                    return;
                }
                if (Session.Character.Inventory.All(i => i.Type != InventoryType.Wear))
                {
                    Session.Character.Inventory.AddNewToInventory((short)(4 + (packet.Type * 14)), type: InventoryType.Wear);
                    Session.Character.Inventory.AddNewToInventory((short)(81 + (packet.Type * 13)), type: InventoryType.Wear);
                    switch (packet.Type)
                    {
                    case 1:
                        Session.Character.Inventory.AddNewToInventory(68, type: InventoryType.Wear);
                        Session.Character.Inventory.AddNewToInventory(2082, 10);
                        break;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                break;

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

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

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

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

                        break;

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

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

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

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

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

            default:
                Logger.Warn(string.Format(Language.Instance.GetMessageFromKey("NO_NRUN_HANDLER"), packet.Runner));
                break;
            }
        }
コード例 #2
0
        public static void NRun(ClientSession Session, NRunPacket packet)
        {
            if (!Session.HasCurrentMapInstance)
            {
                return;
            }
            MapNpc npc = Session.CurrentMapInstance.Npcs.FirstOrDefault(s => s.MapNpcId == packet.NpcId);

            switch (packet.Runner)
            {
            case 1:
                if (Session.Character.Class != (byte)ClassType.Adventurer)
                {
                    Session.SendPacket(UserInterfaceHelper.Instance.GenerateMsg(Language.Instance.GetMessageFromKey("NOT_ADVENTURER"), 0));
                    return;
                }
                if (Session.Character.Level < 15 || Session.Character.JobLevel < 20)
                {
                    Session.SendPacket(UserInterfaceHelper.Instance.GenerateMsg(Language.Instance.GetMessageFromKey("LOW_LVL"), 0));
                    return;
                }
                if (packet.Type == (byte)Session.Character.Class)
                {
                    return;
                }
                if (Session.Character.Inventory.GetAllItems().All(i => i.Type != InventoryType.Wear))
                {
                    Session.Character.Inventory.AddNewToInventory((short)(4 + packet.Type * 14), type: InventoryType.Wear);
                    Session.Character.Inventory.AddNewToInventory((short)(81 + packet.Type * 13), type: InventoryType.Wear);
                    switch (packet.Type)
                    {
                    case 1:
                        Session.Character.Inventory.AddNewToInventory(68, type: InventoryType.Wear);
                        Session.Character.Inventory.AddNewToInventory(2082, 10);
                        break;

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

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

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

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

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

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

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

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

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

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

                    break;
                }
                Session.SendPacket(Session.Character.GeneratePinit());
                Session.Character.SendPst();
                break;

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

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

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

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

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

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

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

            case 17:
                double currentRunningSeconds   = (DateTime.Now - Process.GetCurrentProcess().StartTime.AddSeconds(-50)).TotalSeconds;
                double timeSpanSinceLastPortal = currentRunningSeconds - Session.Character.LastPortal;
                if (!(timeSpanSinceLastPortal >= 4) || !Session.HasCurrentMapInstance)
                {
                    Session.SendPacket(Session.Character.GenerateSay(Language.Instance.GetMessageFromKey("CANT_MOVE"), 10));
                    return;
                }
                if (Session.Character.Raid != null && Session.Character.Raid.Launched)
                {
                    Session.SendPacket(Session.Character.GenerateSay("Vous n'avez pas le droit d'aller à l'arène une fois en raid", 10));     // french in source? nou!
                    break;
                }
                if (Session.Character.Gold >= 500 * (1 + packet.Type))
                {
                    Session.Character.LastPortal = currentRunningSeconds;
                    Session.Character.Gold      -= 500 * (1 + packet.Type);
                    Session.SendPacket(Session.Character.GenerateGold());
                    ServerManager.Instance.ChangeMapInstance(Session.Character.CharacterId, packet.Type == 0 ? ServerManager.Instance.ArenaInstance.MapInstanceId : ServerManager.Instance.FamilyArenaInstance.MapInstanceId, packet.Type == 0 ? ServerManager.Instance.ArenaInstance.Map.GetRandomPosition().X : ServerManager.Instance.FamilyArenaInstance.Map.GetRandomPosition().X, packet.Type == 0 ? ServerManager.Instance.ArenaInstance.Map.GetRandomPosition().Y : ServerManager.Instance.FamilyArenaInstance.Map.GetRandomPosition().Y);
                }
                else
                {
                    Session.SendPacket(Session.Character.GenerateSay(Language.Instance.GetMessageFromKey("NOT_ENOUGH_MONEY"), 10));
                }
                break;

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

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

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

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

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

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

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

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

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

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

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

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

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

                break;

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

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

            case 5001:
                if (npc != null)
                {
                    ServerManager.Instance.ChangeMap(Session.Character.CharacterId, 130, 12, 40);
                }
                break;

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

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

            default:
                Logger.Log.Warn(string.Format(Language.Instance.GetMessageFromKey("NO_NRUN_HANDLER"), packet.Runner));
                break;
            }
        }
コード例 #3
0
ファイル: BCard.cs プロジェクト: vvmaja/OpenNos
        public void ApplyBCards(object session, object caster = null)
        {
            switch ((BCardType.CardType)Type)
            {
            case BCardType.CardType.Buff:
                if (session.GetType() == typeof(Character))
                {
                    if (ServerManager.Instance.RandomNumber() < FirstData)
                    {
                        Character character = session as Character;
                        character?.AddBuff(new Buff(SecondData, character.Level));
                    }
                }
                else if (session.GetType() == typeof(MapMonster))
                {
                    if (ServerManager.Instance.RandomNumber() < FirstData)
                    {
                        if (session is MapMonster monster)
                        {
                            monster.AddBuff(!(caster is Character character) ? new Buff(SecondData, 1) : new Buff(SecondData, character.Level));
                        }
                    }
                }
                else if (session.GetType() == typeof(MapNpc))
                {
                }
                else if (session.GetType() == typeof(Mate))
                {
                }
                break;

            case BCardType.CardType.Move:
                if (session.GetType() == typeof(Character))
                {
                    if (session is Character character)
                    {
                        character.LastSpeedChange = DateTime.Now;
                    }
                    Character o = session as Character;
                    o?.Session.SendPacket(o.GenerateCond());
                }
                break;

            case BCardType.CardType.Summons:
                if (session.GetType() == typeof(Character))
                {
                }
                else if (session.GetType() == typeof(MapMonster))
                {
                    if (!(session is MapMonster monster))
                    {
                        return;
                    }
                    ConcurrentBag <MonsterToSummon> summonParameters = new ConcurrentBag <MonsterToSummon>();
                    for (int i = 0; i < FirstData; i++)
                    {
                        short x, y;
                        if (SubType == 11)
                        {
                            x = (short)(i + monster.MapX);
                            y = monster.MapY;
                        }
                        else
                        {
                            x = (short)(ServerManager.Instance.RandomNumber(-3, 3) + monster.MapX);
                            y = (short)(ServerManager.Instance.RandomNumber(-3, 3) + monster.MapY);
                        }
                        summonParameters.Add(new MonsterToSummon((short)SecondData, new MapCell {
                            X = x, Y = y
                        }, -1, true));
                    }
                    int rnd = ServerManager.Instance.RandomNumber();
                    if (rnd <= Math.Abs(ThirdData) || ThirdData == 0)
                    {
                        switch (SubType)
                        {
                        case 31:
                            EventHelper.Instance.RunEvent(new EventContainer(monster.MapInstance, EventActionType.SPAWNMONSTERS, summonParameters));
                            break;

                        default:
                            if (monster.OnDeathEvents.All(s => s.EventActionType != EventActionType.SPAWNMONSTERS))
                            {
                                monster.OnDeathEvents.Add(new EventContainer(monster.MapInstance, EventActionType.SPAWNMONSTERS, summonParameters));
                            }
                            break;
                        }
                    }
                }
                else if (session.GetType() == typeof(MapNpc))
                {
                }
                else if (session.GetType() == typeof(Mate))
                {
                }
                break;

            case BCardType.CardType.SpecialAttack:
                break;

            case BCardType.CardType.SpecialDefence:
                break;

            case BCardType.CardType.AttackPower:
                break;

            case BCardType.CardType.Target:
                break;

            case BCardType.CardType.Critical:
                break;

            case BCardType.CardType.SpecialCritical:
                break;

            case BCardType.CardType.Element:
                break;

            case BCardType.CardType.IncreaseDamage:
                break;

            case BCardType.CardType.Defence:
                break;

            case BCardType.CardType.DodgeAndDefencePercent:
                break;

            case BCardType.CardType.Block:
                break;

            case BCardType.CardType.Absorption:
                break;

            case BCardType.CardType.ElementResistance:
                break;

            case BCardType.CardType.EnemyElementResistance:
                break;

            case BCardType.CardType.Damage:
                break;

            case BCardType.CardType.GuarantedDodgeRangedAttack:
                break;

            case BCardType.CardType.Morale:
                break;

            case BCardType.CardType.Casting:
                break;

            case BCardType.CardType.Reflection:
                break;

            case BCardType.CardType.DrainAndSteal:
                break;

            case BCardType.CardType.HealingBurningAndCasting:
                AdditionalTypes.HealingBurningAndCasting subtype = (AdditionalTypes.HealingBurningAndCasting)SubType;
                switch (subtype)
                {
                case AdditionalTypes.HealingBurningAndCasting.RestoreHP:
                case AdditionalTypes.HealingBurningAndCasting.RestoreHPWhenCasting:
                    if (session is Character sess)
                    {
                        int  heal   = FirstData;
                        bool change = false;
                        if (IsLevelScaled)
                        {
                            if (IsLevelDivided)
                            {
                                heal /= sess.Level;
                            }
                            else
                            {
                                heal *= sess.Level;
                            }
                        }
                        sess.Session?.CurrentMapInstance?.Broadcast(sess.GenerateRc(heal));
                        if (sess.Hp + heal < sess.HPLoad())
                        {
                            sess.Hp += heal;
                            change   = true;
                        }
                        else
                        {
                            if (sess.Hp != (int)sess.HPLoad())
                            {
                                change = true;
                            }
                            sess.Hp = (int)sess.HPLoad();
                        }
                        if (change)
                        {
                            sess.Session?.SendPacket(sess.GenerateStat());
                        }
                    }
                    break;
                }
                break;

            case BCardType.CardType.HPMP:
                break;

            case BCardType.CardType.SpecialisationBuffResistance:
                break;

            case BCardType.CardType.SpecialEffects:
                break;

            case BCardType.CardType.Capture:
                if (session.GetType() == typeof(MapMonster))
                {
                    if (caster is Character)
                    {
                        MapMonster monster   = session as MapMonster;
                        Character  character = caster as Character;
                        if (monster != null && character != null)
                        {
                            if (monster.Monster.RaceType == 1 && (character.MapInstance.MapInstanceType == MapInstanceType.BaseMapInstance || character.MapInstance.MapInstanceType == MapInstanceType.TimeSpaceInstance))
                            {
                                if (monster.Monster.Level < character.Level)
                                {
                                    if (monster.CurrentHp < (monster.Monster.MaxHP / 2))
                                    {
                                        if (character.MaxMateCount == character.Mates.Count())
                                        {
                                            // Algo
                                            int capturerate = ((character.Level / monster.Monster.Level) / (monster.CurrentHp / monster.Monster.MaxHP) * 3);
                                            if (ServerManager.Instance.RandomNumber() <= capturerate)
                                            {
                                                Mate currentmate = character.Mates.FirstOrDefault(m => m.IsTeamMember == true);
                                                if (currentmate != null)
                                                {
                                                    currentmate.IsTeamMember = false;
                                                    character.Session.CurrentMapInstance.Broadcast(currentmate.GenerateOut());
                                                }
                                                monster.MapInstance.DespawnMonster(monster);
                                                NpcMonster mateNpc = ServerManager.Instance.GetNpc(monster.Monster.NpcMonsterVNum);
                                                byte       lvl     = 0;
                                                lvl += monster.Monster.Level;
                                                lvl -= 10;
                                                if (lvl <= 0)
                                                {
                                                    lvl = 1;
                                                }
                                                Mate mate = new Mate(character, mateNpc, lvl, MateType.Pet);
                                                character.Mates.Add(mate);
                                                mate.IsTeamMember = true;
                                                character.Session.SendPacket($"ctl 2 {mate.PetId} 3");
                                                character.MapInstance.Broadcast(mate.GenerateIn());
                                                character.Session.SendPacket(character.GenerateSay(string.Format(Language.Instance.GetMessageFromKey("YOU_GET_PET"), mate.Name), 0));
                                                character.Session.SendPacket(UserInterfaceHelper.Instance.GeneratePClear());
                                                character.Session.SendPackets(character.GenerateScP());
                                                character.Session.SendPackets(character.GenerateScN());
                                                character.Session.SendPacket(UserInterfaceHelper.Instance.GeneratePClear());
                                                character.Session.SendPackets(character.GenerateScP());
                                                character.Session.SendPackets(character.GenerateScN());
                                                character.Session.SendPacket(character.GeneratePinit());
                                                character.Session.SendPackets(character.GeneratePst());
                                            }
                                            else
                                            {
                                                character.Session.SendPacket(UserInterfaceHelper.Instance.GenerateMsg(Language.Instance.GetMessageFromKey("CAPTURE_FAILED"), 0));
                                            }
                                        }
                                        else
                                        {
                                            character.Session.SendPacket(UserInterfaceHelper.Instance.GenerateMsg(Language.Instance.GetMessageFromKey("MAX_MATES_COUNT"), 0));
                                        }
                                    }
                                    else
                                    {
                                        character.Session.SendPacket(UserInterfaceHelper.Instance.GenerateMsg(Language.Instance.GetMessageFromKey("MONSTER_MUST_BE_LOW_HP"), 0));
                                    }
                                }
                                else
                                {
                                    character.Session.SendPacket(UserInterfaceHelper.Instance.GenerateMsg(Language.Instance.GetMessageFromKey("MONSTER_LVL_MUST_BE_LESS"), 0));
                                }
                            }
                            else
                            {
                                character.Session.SendPacket(UserInterfaceHelper.Instance.GenerateMsg(Language.Instance.GetMessageFromKey("MONSTER_CANNOT_BE_CAPTURED"), 0));
                            }
                        }
                    }
                }
                break;

            case BCardType.CardType.SpecialDamageAndExplosions:
                break;

            case BCardType.CardType.SpecialEffects2:
                break;

            case BCardType.CardType.CalculatingLevel:
                break;

            case BCardType.CardType.Recovery:
                break;

            case BCardType.CardType.MaxHPMP:
                break;

            case BCardType.CardType.MultAttack:
                break;

            case BCardType.CardType.MultDefence:
                break;

            case BCardType.CardType.TimeCircleSkills:
                break;

            case BCardType.CardType.RecoveryAndDamagePercent:
                break;

            case BCardType.CardType.Count:
                break;

            case BCardType.CardType.NoDefeatAndNoDamage:
                break;

            case BCardType.CardType.SpecialActions:
                break;

            case BCardType.CardType.Mode:
                break;

            case BCardType.CardType.NoCharacteristicValue:
                break;

            case BCardType.CardType.LightAndShadow:
                break;

            case BCardType.CardType.Item:
                break;

            case BCardType.CardType.DebuffResistance:
                break;

            case BCardType.CardType.SpecialBehaviour:
                break;

            case BCardType.CardType.Quest:
                break;

            case BCardType.CardType.SecondSPCard:
                break;

            case BCardType.CardType.SPCardUpgrade:
                break;

            case BCardType.CardType.HugeSnowman:
                break;

            case BCardType.CardType.Drain:
                break;

            case BCardType.CardType.BossMonstersSkill:
                break;

            case BCardType.CardType.LordHatus:
                break;

            case BCardType.CardType.LordCalvinas:
                break;

            case BCardType.CardType.SESpecialist:
                break;

            case BCardType.CardType.FourthGlacernonFamilyRaid:
                break;

            case BCardType.CardType.SummonedMonsterAttack:
                break;

            case BCardType.CardType.BearSpirit:
                break;

            case BCardType.CardType.SummonSkill:
                break;

            case BCardType.CardType.InflictSkill:
                break;

            case BCardType.CardType.HideBarrelSkill:
                break;

            case BCardType.CardType.FocusEnemyAttentionSkill:
                break;

            case BCardType.CardType.TauntSkill:
                break;

            case BCardType.CardType.FireCannoneerRangeBuff:
                break;

            case BCardType.CardType.VulcanoElementBuff:
                break;

            case BCardType.CardType.DamageConvertingSkill:
                break;

            case BCardType.CardType.MeditationSkill:

                break;

            case BCardType.CardType.FalconSkill:
                break;

            case BCardType.CardType.AbsorptionAndPowerSkill:
                break;

            case BCardType.CardType.LeonaPassiveSkill:
                break;

            case BCardType.CardType.FearSkill:
                break;

            case BCardType.CardType.SniperAttack:
                break;

            case BCardType.CardType.FrozenDebuff:
                break;

            case BCardType.CardType.JumpBackPush:
                break;

            case BCardType.CardType.FairyXPIncrease:
                break;

            case BCardType.CardType.SummonAndRecoverHP:
                break;

            case BCardType.CardType.TeamArenaBuff:
                break;

            case BCardType.CardType.ArenaCamera:
                break;

            case BCardType.CardType.DarkCloneSummon:
                break;

            case BCardType.CardType.AbsorbedSpirit:
                break;

            case BCardType.CardType.AngerSkill:
                break;

            case BCardType.CardType.MeteoriteTeleport:
                break;

            case BCardType.CardType.StealBuff:
                break;

            default:
                Logger.Error(new ArgumentOutOfRangeException($"Card Type {Type} not defined!"));
                //throw new ArgumentOutOfRangeException();
                break;
            }
        }
コード例 #4
0
ファイル: NRunHandler.cs プロジェクト: vvmaja/OpenNos
        public static void NRun(ClientSession Session, NRunPacket packet)
        {
            if (!Session.HasCurrentMapInstance)
            {
                return;
            }
            MapNpc npc = Session.CurrentMapInstance.Npcs.FirstOrDefault(s => s.MapNpcId == packet.NpcId);
            TeleporterDTO tp;
            Random rand = new Random();
            switch (packet.Runner)
            {
                case 1:
                    if (Session.Character.Class != (byte)ClassType.Adventurer)
                    {
                        Session.SendPacket(UserInterfaceHelper.Instance.GenerateMsg(Language.Instance.GetMessageFromKey("NOT_ADVENTURER"), 0));
                        return;
                    }
                    if (Session.Character.Level < 15 || Session.Character.JobLevel < 20)
                    {
                        Session.SendPacket(UserInterfaceHelper.Instance.GenerateMsg(Language.Instance.GetMessageFromKey("LOW_LVL"), 0));
                        return;
                    }
                    if (packet.Type == (byte)Session.Character.Class)
                    {
                        return;
                    }
                    if (Session.Character.Inventory.All(i => i.Value.Type != InventoryType.Wear))
                    {
                        Session.Character.Inventory.AddNewToInventory((short)(4 + packet.Type * 14), type: InventoryType.Wear);
                        Session.Character.Inventory.AddNewToInventory((short)(81 + packet.Type * 13), type: InventoryType.Wear);
                        switch (packet.Type)
                        {
                            case 1:
                                Session.Character.Inventory.AddNewToInventory(68, type: InventoryType.Wear);
                                Session.Character.Inventory.AddNewToInventory(2082, 10);
                                break;

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

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

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

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

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

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

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

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

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

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

                            break;
                    }
                    Session.SendPacket(Session.Character.GeneratePinit());
                    Session.SendPackets(Session.Character.GeneratePst());
                    break;

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

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

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

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

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

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

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

                case 17:
                    double currentRunningSeconds = (DateTime.Now - Process.GetCurrentProcess().StartTime.AddSeconds(-50)).TotalSeconds;
                    double timeSpanSinceLastPortal = currentRunningSeconds - Session.Character.LastPortal;
                    if (!(timeSpanSinceLastPortal >= 4) || !Session.HasCurrentMapInstance || Session.CurrentMapInstance.MapInstanceType == MapInstanceType.Act4Instance)
                    {
                        Session.SendPacket(Session.Character.GenerateSay(Language.Instance.GetMessageFromKey("CANT_MOVE"), 10));
                        return;
                    }
                    if (Session.Character.Gold >= 500 * (1 + packet.Type))
                    {
                        Session.Character.LastPortal = currentRunningSeconds;
                        Session.Character.Gold -= 500 * (1 + packet.Type);
                        Session.SendPacket(Session.Character.GenerateGold());
                        ServerManager.Instance.TeleportOnRandomPlaceInMap(Session,
                            packet.Type == 0 ? ServerManager.Instance.ArenaInstance.MapInstanceId : ServerManager.Instance.FamilyArenaInstance.MapInstanceId);
                    }
                    else
                    {
                        Session.SendPacket(Session.Character.GenerateSay(Language.Instance.GetMessageFromKey("NOT_ENOUGH_MONEY"), 10));
                    }
                    break;

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

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

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

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

                case 137:
                    Session.SendPacket("taw_open");
                    break;

                case 138:
                    ConcurrentBag<ArenaTeamMember> at = ServerManager.Instance.ArenaTeams.OrderBy(s => rand.Next()).FirstOrDefault();
                    if (at != null)
                    {
                        ServerManager.Instance.ChangeMapInstance(Session.Character.CharacterId, at.FirstOrDefault(s => s.Session != null).Session.CurrentMapInstance.MapInstanceId, 69, 100);

                        ArenaTeamMember zenas = at.OrderBy(s => s.Order).FirstOrDefault(s => s.Session != null && !s.Dead && s.ArenaTeamType == ArenaTeamType.ZENAS);
                        ArenaTeamMember erenia = at.OrderBy(s => s.Order).FirstOrDefault(s => s.Session != null && !s.Dead && s.ArenaTeamType == ArenaTeamType.ERENIA);
                        Session.SendPacket(erenia.Session.Character.GenerateTaM(0));
                        Session.SendPacket(erenia.Session.Character.GenerateTaM(3));
                        Session.SendPacket("taw_sv 0");
                        Session.SendPacket(zenas.Session.Character.GenerateTaP(0, true));
                        Session.SendPacket(erenia.Session.Character.GenerateTaP(2, true));
                        Session.SendPacket(zenas.Session.Character.GenerateTaFc(0));
                        Session.SendPacket(erenia.Session.Character.GenerateTaFc(1));
                    }
                    else
                    {
                        Session.SendPacket(UserInterfaceHelper.Instance.GenerateInfo(Language.Instance.GetMessageFromKey("NO_TALENT_ARENA")));
                    }
                    break;
                case 135:
                    if (!ServerManager.Instance.StartedEvents.Contains(EventType.TALENTARENA))
                    {
                        Session.SendPacket(npc?.GenerateSay(Language.Instance.GetMessageFromKey("ARENA_NOT_OPEN"), 10));
                    }
                    else
                    {
                        int tickets = 5 - Session.Character.GeneralLogs.Count(s => s.LogType == "TalentArena" && s.Timestamp.Date == DateTime.Today);
                        if (ServerManager.Instance.ArenaMembers.All(s => s.Session != Session) && tickets > 0)
                        {
                            if (ServerManager.Instance.IsCharacterMemberOfGroup(Session.Character.CharacterId))
                            {
                                Session.SendPacket(UserInterfaceHelper.Instance.GenerateMsg(Language.Instance.GetMessageFromKey("TALENT_ARENA_GROUP"), 0));
                                Session.SendPacket(Session.Character.GenerateSay(Language.Instance.GetMessageFromKey("TALENT_ARENA_GROUP"), 10));
                            }
                            else
                            {
                                Session.SendPacket(Session.Character.GenerateSay(string.Format(Language.Instance.GetMessageFromKey("ARENA_TICKET_LEFT"), tickets), 10));
                                ServerManager.Instance.ArenaMembers.Add(new ArenaMember
                                {
                                    ArenaType = EventType.TALENTARENA,
                                    Session = Session,
                                    GroupId = null,
                                    Time = 0
                                });
                            }
                        }
                        else
                        {
                            Session.SendPacket(UserInterfaceHelper.Instance.GenerateMsg(Language.Instance.GetMessageFromKey("TALENT_ARENA_NO_MORE_TICKET"), 0));
                            Session.SendPacket(Session.Character.GenerateSay(Language.Instance.GetMessageFromKey("TALENT_ARENA_NO_MORE_TICKET"), 10));
                        }
                    }
                    break;

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

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

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

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

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

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

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

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

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

                    break;

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

                case 5001:
                    if (npc != null)
                    {
                        MapInstance map = null;
                        switch (Session.Character.Faction)
                        {
                            case FactionType.Neutral:
                                Session.SendPacket(UserInterfaceHelper.Instance.GenerateInfo("NEED_FACTION_ACT4"));
                                return;
                            case FactionType.Angel:
                                map = ServerManager.Instance.Act4ShipAngel;

                                break;
                            case FactionType.Demon:
                                map = ServerManager.Instance.Act4ShipDemon;

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

                case 5002:
                    if (npc != null)
                    {
                        tp = npc.Teleporters?.FirstOrDefault(s => s.Index == packet.Type);
                        if (tp != null)
                        {
                            Session.SendPacket("it 3");
                            SerializableWorldServer connection = CommunicationServiceClient.Instance.GetPreviousChannelByAccountId(Session.Account.AccountId);
                            Session.Character.MapId = tp.MapId;
                            Session.Character.MapX = tp.MapX;
                            Session.Character.MapY = tp.MapY;
                            Session.Character.ChangeChannel(connection.EndPointIp, connection.EndPointPort, 3);
                        }
                    }
                    break;

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

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

                default:
                    Logger.Log.Warn(string.Format(Language.Instance.GetMessageFromKey("NO_NRUN_HANDLER"), packet.Runner));
                    break;
            }
        }