Exemple #1
0
        public override void Use(ClientSession session, ref ItemInstance inv, byte Option = 0, string[] packetsplit = null)
        {
            switch (Effect)
            {
            case 0:
                if (Option == 0)
                {
                    if (packetsplit.Length == 9)
                    {
                        BoxInstance box = session.Character.Inventory.LoadBySlotAndType <BoxInstance>(inv.Slot, InventoryType.Equipment);
                        if (box != null)
                        {
                            if (box.Item.ItemSubType == 3)
                            {
                                session.SendPacket($"qna #guri^300^8023^{inv.Slot} {Language.Instance.GetMessageFromKey("ASK_OPEN_BOX")}");
                            }
                            else if (box.HoldingVNum == 0)
                            {
                                session.SendPacket($"qna #guri^300^8023^{inv.Slot}^{packetsplit[3]} {Language.Instance.GetMessageFromKey("ASK_STORE_PET")}");
                            }
                            else
                            {
                                session.SendPacket($"qna #guri^300^8023^{inv.Slot} {Language.Instance.GetMessageFromKey("ASK_RELEASE_PET")}");
                            }
                        }
                    }
                }
                else
                {
                    //u_i 2 2000000 0 21 0 0
                    BoxInstance box = session.Character.Inventory.LoadBySlotAndType <BoxInstance>(inv.Slot, InventoryType.Equipment);
                    if (box != null)
                    {
                        if (box.Item.ItemSubType == 3)
                        {
                            List <RollGeneratedItemDTO> roll = box.Item.RollGeneratedItems.Where(s => s.MinimumOriginalItemRare <= box.Rare && s.MaximumOriginalItemRare >= box.Rare && s.OriginalItemDesign == box.Design).ToList();
                            int probabilities          = roll.Sum(s => s.Probability);
                            int rnd                    = ServerManager.Instance.RandomNumber(0, probabilities);
                            int currentrnd             = 0;
                            List <ItemInstance> newInv = null;
                            foreach (RollGeneratedItemDTO rollitem in roll)
                            {
                                if (newInv == null)
                                {
                                    currentrnd += rollitem.Probability;
                                    if (currentrnd >= rnd)
                                    {
                                        newInv = session.Character.Inventory.AddNewToInventory(rollitem.ItemGeneratedVNum, rollitem.ItemGeneratedAmount);
                                        if (newInv.Any())
                                        {
                                            short Slot = inv.Slot;
                                            if (Slot != -1)
                                            {
                                                session.SendPacket(session.Character.GenerateSay($"{Language.Instance.GetMessageFromKey("ITEM_ACQUIRED")}: {newInv.First().Item.Name} x 1)", 12));
                                                newInv.ForEach(s => session.SendPacket(s.GenerateInventoryAdd()));
                                                session.Character.Inventory.RemoveItemAmountFromInventory(1, box.Id);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        else if (box.HoldingVNum == 0)
                        {
                            if (packetsplit.Length == 1)
                            {
                                if (int.TryParse(packetsplit[0], out int PetId))
                                {
                                    Mate mate = session.Character.Mates.FirstOrDefault(s => s.MateTransportId == PetId);
                                    box.HoldingVNum = mate.NpcMonsterVNum;
                                    box.SpLevel     = mate.Level;
                                    box.SpDamage    = mate.Attack;
                                    box.SpDefence   = mate.Defence;
                                    session.Character.Mates.Remove(mate);
                                    session.SendPacket(UserInterfaceHelper.Instance.GenerateInfo(Language.Instance.GetMessageFromKey("PET_STORED")));
                                    session.SendPacket(UserInterfaceHelper.Instance.GeneratePClear());
                                    session.SendPackets(session.Character.GenerateScP());
                                    session.SendPackets(session.Character.GenerateScN());
                                    session.CurrentMapInstance?.Broadcast(mate.GenerateOut());
                                }
                            }
                        }
                        else
                        {
                            NpcMonster heldMonster = ServerManager.Instance.GetNpc(box.HoldingVNum);
                            if (heldMonster != null)
                            {
                                Mate mate = new Mate(session.Character, heldMonster, 1, MateType.Pet)
                                {
                                    Attack  = box.SpDamage,
                                    Defence = box.SpDefence
                                };
                                if (session.Character.AddPet(mate))
                                {
                                    session.Character.Inventory.RemoveItemAmountFromInventory(1, inv.Id);
                                    session.SendPacket(UserInterfaceHelper.Instance.GenerateInfo(Language.Instance.GetMessageFromKey("PET_LEAVE_BEAD")));
                                }
                            }
                        }
                    }
                }
                break;

            case 1:
                if (Option == 0)
                {
                    session.SendPacket($"qna #guri^300^8023^{inv.Slot} {Language.Instance.GetMessageFromKey("ASK_RELEASE_PET")}");
                }
                else
                {
                    NpcMonster heldMonster = ServerManager.Instance.GetNpc((short)EffectValue);
                    if (session.CurrentMapInstance == session.Character.Miniland && heldMonster != null)
                    {
                        Mate mate = new Mate(session.Character, heldMonster, LevelMinimum, ItemSubType == 1 ? MateType.Partner : MateType.Pet);
                        if (session.Character.AddPet(mate))
                        {
                            session.Character.Inventory.RemoveItemAmountFromInventory(1, inv.Id);
                            session.SendPacket(UserInterfaceHelper.Instance.GenerateInfo(Language.Instance.GetMessageFromKey("PET_LEAVE_BEAD")));
                        }
                    }
                    else
                    {
                        //TODO ADD MINILAND SENDPACKET
                    }
                }

                break;

            case 69:
                if (EffectValue == 1 || EffectValue == 2)
                {
                    BoxInstance box = session.Character.Inventory.LoadBySlotAndType <BoxInstance>(inv.Slot, InventoryType.Equipment);
                    if (box != null)
                    {
                        if (box.HoldingVNum == 0)
                        {
                            session.SendPacket($"wopen 44 {inv.Slot}");
                        }
                        else
                        {
                            List <ItemInstance> newInv = session.Character.Inventory.AddNewToInventory(box.HoldingVNum);
                            if (newInv.Any())
                            {
                                ItemInstance       itemInstance = newInv.First();
                                SpecialistInstance specialist   = session.Character.Inventory.LoadBySlotAndType <SpecialistInstance>(itemInstance.Slot, itemInstance.Type);
                                if (specialist != null)
                                {
                                    specialist.SlDamage       = box.SlDamage;
                                    specialist.SlDefence      = box.SlDefence;
                                    specialist.SlElement      = box.SlElement;
                                    specialist.SlHP           = box.SlHP;
                                    specialist.SpDamage       = box.SpDamage;
                                    specialist.SpDark         = box.SpDark;
                                    specialist.SpDefence      = box.SpDefence;
                                    specialist.SpElement      = box.SpElement;
                                    specialist.SpFire         = box.SpFire;
                                    specialist.SpHP           = box.SpHP;
                                    specialist.SpLevel        = box.SpLevel;
                                    specialist.SpLight        = box.SpLight;
                                    specialist.SpStoneUpgrade = box.SpStoneUpgrade;
                                    specialist.SpWater        = box.SpWater;
                                    specialist.Upgrade        = box.Upgrade;
                                    specialist.XP             = box.XP;
                                }
                                short Slot = inv.Slot;
                                if (Slot != -1)
                                {
                                    if (specialist != null)
                                    {
                                        session.SendPacket(session.Character.GenerateSay($"{Language.Instance.GetMessageFromKey("ITEM_ACQUIRED")}: {specialist.Item.Name} + {specialist.Upgrade}", 12));
                                        newInv.ForEach(s => session.SendPacket(specialist.GenerateInventoryAdd()));
                                    }
                                    session.Character.Inventory.RemoveItemAmountFromInventory(1, box.Id);
                                }
                            }
                            else
                            {
                                session.SendPacket(UserInterfaceHelper.Instance.GenerateMsg(Language.Instance.GetMessageFromKey("NOT_ENOUGH_PLACE"), 0));
                            }
                        }
                    }
                }
                if (EffectValue == 3)
                {
                    BoxInstance box = session.Character.Inventory.LoadBySlotAndType <BoxInstance>(inv.Slot, InventoryType.Equipment);
                    if (box != null)
                    {
                        if (box.HoldingVNum == 0)
                        {
                            session.SendPacket($"guri 26 0 {inv.Slot}");
                        }
                        else
                        {
                            List <ItemInstance> newInv = session.Character.Inventory.AddNewToInventory(box.HoldingVNum);
                            if (newInv.Any())
                            {
                                ItemInstance     itemInstance = newInv.First();
                                WearableInstance fairy        = session.Character.Inventory.LoadBySlotAndType <WearableInstance>(itemInstance.Slot, itemInstance.Type);
                                if (fairy != null)
                                {
                                    fairy.ElementRate = box.ElementRate;
                                }
                                short Slot = inv.Slot;
                                if (Slot != -1)
                                {
                                    if (fairy != null)
                                    {
                                        session.SendPacket(session.Character.GenerateSay($"{Language.Instance.GetMessageFromKey("ITEM_ACQUIRED")}: {fairy.Item.Name} ({fairy.ElementRate}%)", 12));
                                        newInv.ForEach(s => session.SendPacket(fairy.GenerateInventoryAdd()));
                                    }
                                    session.Character.Inventory.RemoveItemAmountFromInventory(1, box.Id);
                                }
                            }
                            else
                            {
                                session.SendPacket(UserInterfaceHelper.Instance.GenerateMsg(Language.Instance.GetMessageFromKey("NOT_ENOUGH_PLACE"), 0));
                            }
                        }
                    }
                }
                if (EffectValue == 4)
                {
                    BoxInstance box = session.Character.Inventory.LoadBySlotAndType <BoxInstance>(inv.Slot, InventoryType.Equipment);
                    if (box != null)
                    {
                        if (box.HoldingVNum == 0)
                        {
                            session.SendPacket($"guri 24 0 {inv.Slot}");
                        }
                        else
                        {
                            List <ItemInstance> newInv = session.Character.Inventory.AddNewToInventory(box.HoldingVNum);
                            if (newInv.Any())
                            {
                                short Slot = inv.Slot;
                                if (Slot != -1)
                                {
                                    session.SendPacket(session.Character.GenerateSay($"{Language.Instance.GetMessageFromKey("ITEM_ACQUIRED")}: {newInv.First().Item.Name} x 1)", 12));
                                    newInv.ForEach(s => session.SendPacket(s.GenerateInventoryAdd()));
                                    session.Character.Inventory.RemoveItemAmountFromInventory(1, box.Id);
                                }
                            }
                            else
                            {
                                session.SendPacket(UserInterfaceHelper.Instance.GenerateMsg(Language.Instance.GetMessageFromKey("NOT_ENOUGH_PLACE"), 0));
                            }
                        }
                    }
                }
                break;

            default:
                Logger.Log.Warn(string.Format(Language.Instance.GetMessageFromKey("NO_HANDLER_ITEM"), GetType()));
                break;
            }
        }
Exemple #2
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;
            }
        }
Exemple #3
0
        public override void Use(ClientSession session, ref ItemInstance inv, byte Option = 0, string[] packetsplit = null)
        {
            if (packetsplit == null)
            {
                return;
            }

            void releasePet(MateType mateType, Guid itemToRemoveId)
            {
                if (int.TryParse(packetsplit[3], out int mateTransportId))
                {
                    Mate mate = session.Character.Mates.Find(s => s.MateTransportId == mateTransportId && s.MateType == mateType);
                    if (mate != null)
                    {
                        if (!mate.IsTeamMember)
                        {
                            session.Character.Mates.Remove(mate);
                            session.SendPacket(UserInterfaceHelper.GenerateInfo(Language.Instance.GetMessageFromKey("PET_RELEASED")));
                            session.SendPacket(UserInterfaceHelper.GeneratePClear());
                            session.SendPackets(session.Character.GenerateScP());
                            session.SendPackets(session.Character.GenerateScN());
                            session.CurrentMapInstance?.Broadcast(mate.GenerateOut());
                            session.Character.Inventory.RemoveItemFromInventory(itemToRemoveId);
                        }
                        else
                        {
                            session.SendPacket(UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("PET_IN_TEAM_UNRELEASABLE"), 0));
                        }
                    }
                }
            }

            switch (Effect)
            {
            case 11:
                if (int.TryParse(packetsplit[3], out int mateTransportId))
                {
                    Mate mate = session.Character.Mates.Find(s => s.MateTransportId == mateTransportId);
                    if (mate == null || mate.Level >= session.Character.Level - 5)
                    {
                        return;
                    }
                    mate.Level++;
                    session.CurrentMapInstance?.Broadcast(StaticPacketHelper.GenerateEff(UserType.Npc, mate.MateTransportId, 8), mate.PositionX, mate.PositionY);
                    session.CurrentMapInstance?.Broadcast(StaticPacketHelper.GenerateEff(UserType.Npc, mate.MateTransportId, 198), mate.PositionX, mate.PositionY);
                    session.Character.Inventory.RemoveItemFromInventory(inv.Id);
                }
                break;

            case 13:
                if (int.TryParse(packetsplit[3], out mateTransportId) && session.Character.Mates.Any(s => s.MateTransportId == mateTransportId))
                {
                    session.SendPacket(UserInterfaceHelper.GenerateGuri(10, 1, mateTransportId, 2));
                }
                break;

            case 14:
                if (int.TryParse(packetsplit[3], out mateTransportId))
                {
                    Mate mate = session.Character.Mates.Find(s => s.MateTransportId == mateTransportId && s.MateType == MateType.Pet);
                    if (mate?.CanPickUp == false)
                    {
                        session.CurrentMapInstance.Broadcast(StaticPacketHelper.GenerateEff(UserType.Npc, mate.MateTransportId, 5));
                        session.CurrentMapInstance.Broadcast(StaticPacketHelper.GenerateEff(UserType.Npc, mate.MateTransportId, 5002));
                        mate.CanPickUp = true;
                        session.SendPackets(session.Character.GenerateScP());
                        session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("PET_CAN_PICK_UP"), 10));
                        session.Character.Inventory.RemoveItemFromInventory(inv.Id);
                    }
                }
                break;

            case 17:
                if (int.TryParse(packetsplit[3], out mateTransportId))
                {
                    Mate mate = session.Character.Mates.Find(s => s.MateTransportId == mateTransportId);
                    if (mate?.IsSummonable == false)
                    {
                        mate.IsSummonable = true;
                        session.SendPackets(session.Character.GenerateScP());
                        session.SendPacket(session.Character.GenerateSay(string.Format(Language.Instance.GetMessageFromKey("PET_SUMMONABLE"), mate.Name), 10));
                        session.SendPacket(UserInterfaceHelper.GenerateMsg(string.Format(Language.Instance.GetMessageFromKey("PET_SUMMONABLE"), mate.Name), 0));
                        session.Character.Inventory.RemoveItemFromInventory(inv.Id);
                    }
                }
                break;

            case 1000:
                releasePet(MateType.Pet, inv.Id);
                break;

            case 1001:
                releasePet(MateType.Partner, inv.Id);
                break;

            default:
                Logger.Warn(string.Format(Language.Instance.GetMessageFromKey("NO_HANDLER_ITEM"), GetType(), VNum, Effect, EffectValue));
                break;
            }
        }
Exemple #4
0
        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;
            }
        }
Exemple #5
0
        public override void Use(ClientSession session, ref ItemInstance inv, byte Option = 0, string[] packetsplit = null)
        {
            if (session.Character.IsVehicled)
            {
                session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("CANT_DO_VEHICLED"), 10));
                return;
            }

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

            if (packetsplit == null)
            {
                return;
            }

            void releasePet(MateType mateType, Guid itemToRemoveId)
            {
                if (int.TryParse(packetsplit[3], out int mateTransportId))
                {
                    Mate mate = session.Character.Mates.Find(s => s.MateTransportId == mateTransportId && s.MateType == mateType);
                    if (mate != null)
                    {
                        if (!mate.IsTeamMember)
                        {
                            List <ItemInstance> mateInventory = mate.GetInventory();
                            if (mateInventory.Count > 0)
                            {
                                session.SendPacket(UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("EQ_NOT_EMPTY"), 0));
                            }
                            else
                            {
                                session.Character.Mates.Remove(mate);
                                byte i = 0;
                                session.Character.Mates.Where(s => s.MateType == MateType.Partner).ToList().ForEach(s =>
                                {
                                    s.GetInventory().ForEach(item => item.Type = (InventoryType)(13 + i));
                                    s.PetId = i;
                                    i++;
                                });
                                session.SendPacket(UserInterfaceHelper.GenerateInfo(Language.Instance.GetMessageFromKey("PET_RELEASED")));
                                session.SendPacket(UserInterfaceHelper.GeneratePClear());
                                session.SendPackets(session.Character.GenerateScP());
                                session.SendPackets(session.Character.GenerateScN());
                                session.CurrentMapInstance?.Broadcast(mate.GenerateOut());
                                session.Character.Inventory.RemoveItemFromInventory(itemToRemoveId);
                            }
                        }
                        else
                        {
                            session.SendPacket(UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("PET_IN_TEAM_UNRELEASABLE"), 0));
                        }
                    }
                }
            }

            if (BCards.Count > 0 && session.Character.MapInstance == session.Character.Miniland)
            {
                BCards.ForEach(c => c.ApplyBCards(session.Character.BattleEntity, session.Character.BattleEntity));
                session.Character.Inventory.RemoveItemFromInventory(inv.Id);
                return;
            }

            switch (Effect)
            {
            case 10:
                if (int.TryParse(packetsplit[3], out int mateTransportId))
                {
                    Mate mate = session.Character.Mates.Find(s => s.MateTransportId == mateTransportId);
                    if (mate == null || mate.MateType != MateType.Pet || mate.Loyalty >= 1000)
                    {
                        return;
                    }
                    mate.Loyalty += 100;
                    if (mate.Loyalty > 1000)
                    {
                        mate.Loyalty = 1000;
                    }
                    mate.GenerateXp(EffectValue);
                    session.SendPacket(mate.GenerateCond());
                    session.SendPacket(StaticPacketHelper.GenerateEff(UserType.Npc, mate.MateTransportId, 5002));
                    session.Character.Inventory.RemoveItemFromInventory(inv.Id);
                }
                break;

            case 11:
                if (int.TryParse(packetsplit[3], out mateTransportId))
                {
                    Mate mate = session.Character.Mates.Find(s => s.MateTransportId == mateTransportId);
                    if (mate == null || mate.MateType != MateType.Pet || mate.Level >= session.Character.Level - 5 || mate.Level + 1 > ServerManager.Instance.Configuration.MaxLevel)
                    {
                        return;
                    }
                    mate.Level++;
                    mate.Hp = mate.MaxHp;
                    mate.Mp = mate.MaxMp;
                    session.SendPacket($"say 2 {mate.MateTransportId} 0 " + Language.Instance.GetMessageFromKey("MATE_POWER_INCREASED"));
                    session.SendPackets(session.Character.GenerateScP());
                    session.CurrentMapInstance?.Broadcast(StaticPacketHelper.GenerateEff(UserType.Npc, mate.MateTransportId, 8), mate.PositionX, mate.PositionY);
                    session.CurrentMapInstance?.Broadcast(StaticPacketHelper.GenerateEff(UserType.Npc, mate.MateTransportId, 198), mate.PositionX, mate.PositionY);
                    session.Character.Inventory.RemoveItemFromInventory(inv.Id);
                }
                break;

            case 12:
                if (int.TryParse(packetsplit[3], out mateTransportId))
                {
                    Mate mate = session.Character.Mates.Find(s => s.MateTransportId == mateTransportId);
                    if (mate == null || mate.MateType != MateType.Partner || mate.Level >= session.Character.Level - 5 || mate.Level + 1 > ServerManager.Instance.Configuration.MaxLevel)
                    {
                        return;
                    }
                    mate.Level++;
                    mate.Hp = mate.MaxHp;
                    mate.Mp = mate.MaxMp;
                    session.SendPacket($"say 2 {mate.MateTransportId} 0 " + Language.Instance.GetMessageFromKey("MATE_POWER_INCREASED"));
                    session.SendPackets(session.Character.GenerateScN());
                    session.CurrentMapInstance?.Broadcast(StaticPacketHelper.GenerateEff(UserType.Npc, mate.MateTransportId, 8), mate.PositionX, mate.PositionY);
                    session.CurrentMapInstance?.Broadcast(StaticPacketHelper.GenerateEff(UserType.Npc, mate.MateTransportId, 198), mate.PositionX, mate.PositionY);
                    session.Character.Inventory.RemoveItemFromInventory(inv.Id);
                }
                break;

            case 13:
                if (int.TryParse(packetsplit[3], out mateTransportId) && session.Character.Mates.FirstOrDefault(s => s.MateTransportId == mateTransportId) is Mate pet)
                {
                    if (pet.MateType == MateType.Pet)
                    {
                        session.SendPacket(UserInterfaceHelper.GenerateGuri(10, 1, mateTransportId, 2));
                    }
                    else
                    {
                        session.SendPacket(UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("CANT_CHANGE_PARTNER_NAME"), 0));
                    }
                }
                break;

            case 14:
                if (int.TryParse(packetsplit[3], out mateTransportId))
                {
                    if (session.Character.MapInstance == session.Character.Miniland)
                    {
                        Mate mate = session.Character.Mates.Find(s => s.MateTransportId == mateTransportId && s.MateType == MateType.Pet);
                        if (mate?.CanPickUp == false)
                        {
                            session.CurrentMapInstance.Broadcast(StaticPacketHelper.GenerateEff(UserType.Npc, mate.MateTransportId, 5));
                            session.CurrentMapInstance.Broadcast(StaticPacketHelper.GenerateEff(UserType.Npc, mate.MateTransportId, 5002));
                            session.SendPacket($"say 2 {mate.MateTransportId} 0 " + Language.Instance.GetMessageFromKey("PET_SMART"));
                            mate.CanPickUp = true;
                            session.SendPackets(session.Character.GenerateScP());
                            session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("PET_CAN_PICK_UP"), 10));
                            session.Character.Inventory.RemoveItemFromInventory(inv.Id);
                        }
                    }
                    else
                    {
                        session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("NOT_IN_MINILAND"), 12));
                    }
                }
                break;

            case 16:
                if (int.TryParse(packetsplit[3], out mateTransportId))
                {
                    Mate mate = session.Character.Mates.Find(s => s.MateTransportId == mateTransportId);
                    if (mate == null || mate.MateType != MateType.Pet || mate.Level == 1)
                    {
                        return;
                    }
                    mate.Level--;
                    mate.Hp = mate.MaxHp;
                    mate.Mp = mate.MaxMp;
                    session.SendPacket($"say 2 {mate.MateTransportId} 0 " + Language.Instance.GetMessageFromKey("MATE_POWER_DECREASED"));
                    session.SendPackets(session.Character.GenerateScP());
                    session.CurrentMapInstance?.Broadcast(StaticPacketHelper.GenerateEff(UserType.Npc, mate.MateTransportId, 198), mate.PositionX, mate.PositionY);
                    session.Character.Inventory.RemoveItemFromInventory(inv.Id);
                }
                break;

            case 17:
                if (int.TryParse(packetsplit[3], out mateTransportId))
                {
                    Mate mate = session.Character.Mates.Find(s => s.MateTransportId == mateTransportId);
                    if (mate?.IsSummonable == false)
                    {
                        mate.IsSummonable = true;
                        session.SendPackets(session.Character.GenerateScP());
                        session.SendPacket(session.Character.GenerateSay(string.Format(Language.Instance.GetMessageFromKey("PET_SUMMONABLE"), mate.Name), 10));
                        session.SendPacket(UserInterfaceHelper.GenerateMsg(string.Format(Language.Instance.GetMessageFromKey("PET_SUMMONABLE"), mate.Name), 0));
                        session.Character.Inventory.RemoveItemFromInventory(inv.Id);
                    }
                }
                break;

            case 18:
                if (int.TryParse(packetsplit[3], out mateTransportId))
                {
                    Mate mate = session.Character.Mates.Find(s => s.MateTransportId == mateTransportId);
                    if (mate == null || mate.MateType != MateType.Partner || mate.Level == 1)
                    {
                        return;
                    }
                    mate.Level--;
                    mate.Hp = mate.MaxHp;
                    mate.Mp = mate.MaxMp;
                    session.SendPacket($"say 2 {mate.MateTransportId} 0 " + Language.Instance.GetMessageFromKey("MATE_POWER_DECREASED"));
                    session.SendPackets(session.Character.GenerateScN());
                    session.CurrentMapInstance?.Broadcast(StaticPacketHelper.GenerateEff(UserType.Npc, mate.MateTransportId, 198), mate.PositionX, mate.PositionY);
                    session.Character.Inventory.RemoveItemFromInventory(inv.Id);
                }
                break;

            case 1000:
                releasePet(MateType.Pet, inv.Id);
                break;

            case 1001:
                releasePet(MateType.Partner, inv.Id);
                break;

            case 1339:
                int rndevolve = ServerManager.RandomNumber(0, 1000);
                if (rndevolve > 900)
                {
                    if (int.TryParse(packetsplit[3], out mateTransportId))
                    {
                        Mate mate = session.Character.Mates.Find(s => s.MateTransportId == mateTransportId);
                        if (mate == null)
                        {
                            session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("PICK_PET"), 10));
                            return;
                        }
                        if (mate.Level >= 30 && mate.NpcMonsterVNum == 649 && mate.IsTeamMember == true && mate.MateType == MateType.Pet)
                        {
                            mate.Level          = 1;
                            mate.NpcMonsterVNum = 650;
                            session.CurrentMapInstance.Broadcast(StaticPacketHelper.GenerateEff(UserType.Npc, mate.MateTransportId, 5));
                            session.CurrentMapInstance.Broadcast(StaticPacketHelper.GenerateEff(UserType.Npc, mate.MateTransportId, 5002));
                            session.SendPackets(session.Character.GenerateScP());
                            session.SendPackets(session.Character.GenerateScN());
                            session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("PET_EVOLED"), 10));
                            if (session?.Character != null)
                            {
                                if (session.Character.Miniland == session.Character.MapInstance)
                                {
                                    ServerManager.Instance.JoinMiniland(session, session);
                                }
                                else
                                {
                                    ServerManager.Instance.ChangeMapInstance(session.Character.CharacterId,
                                                                             session.Character.MapInstanceId, session.Character.PositionX, session.Character.PositionY,
                                                                             true);
                                    session.SendPacket(StaticPacketHelper.Cancel(2));
                                }
                            }
                        }
                        else
                        {
                            if (mate.Level >= 30 && mate.NpcMonsterVNum == 648 && mate.IsTeamMember == true && mate.MateType == MateType.Pet)
                            {
                                mate.Level          = 1;
                                mate.NpcMonsterVNum = 649;
                                session.CurrentMapInstance.Broadcast(StaticPacketHelper.GenerateEff(UserType.Npc, mate.MateTransportId, 5));
                                session.CurrentMapInstance.Broadcast(StaticPacketHelper.GenerateEff(UserType.Npc, mate.MateTransportId, 5002));
                                session.SendPackets(session.Character.GenerateScP());
                                session.SendPackets(session.Character.GenerateScN());
                                session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("PET_EVOLED"), 10));
                                if (session?.Character != null)
                                {
                                    if (session.Character.Miniland == session.Character.MapInstance)
                                    {
                                        ServerManager.Instance.JoinMiniland(session, session);
                                    }
                                    else
                                    {
                                        ServerManager.Instance.ChangeMapInstance(session.Character.CharacterId,
                                                                                 session.Character.MapInstanceId, session.Character.PositionX, session.Character.PositionY,
                                                                                 true);
                                        session.SendPacket(StaticPacketHelper.Cancel(2));
                                    }
                                }
                            }
                            else
                            {
                                if (mate.Level >= 30 && mate.NpcMonsterVNum == 651 && mate.IsTeamMember == true && mate.MateType == MateType.Pet)
                                {
                                    mate.Level          = 1;
                                    mate.NpcMonsterVNum = 652;
                                    session.CurrentMapInstance.Broadcast(StaticPacketHelper.GenerateEff(UserType.Npc, mate.MateTransportId, 5));
                                    session.CurrentMapInstance.Broadcast(StaticPacketHelper.GenerateEff(UserType.Npc, mate.MateTransportId, 5002));
                                    session.SendPackets(session.Character.GenerateScP());
                                    session.SendPackets(session.Character.GenerateScN());
                                    session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("PET_EVOLED"), 10));
                                    if (session?.Character != null)
                                    {
                                        if (session.Character.Miniland == session.Character.MapInstance)
                                        {
                                            ServerManager.Instance.JoinMiniland(session, session);
                                        }
                                        else
                                        {
                                            ServerManager.Instance.ChangeMapInstance(session.Character.CharacterId,
                                                                                     session.Character.MapInstanceId, session.Character.PositionX, session.Character.PositionY,
                                                                                     true);
                                            session.SendPacket(StaticPacketHelper.Cancel(2));
                                        }
                                    }
                                }
                                else
                                {
                                    if (mate.Level >= 30 && mate.NpcMonsterVNum == 652 && mate.IsTeamMember == true && mate.MateType == MateType.Pet)
                                    {
                                        mate.Level          = 1;
                                        mate.NpcMonsterVNum = 653;
                                        session.CurrentMapInstance.Broadcast(StaticPacketHelper.GenerateEff(UserType.Npc, mate.MateTransportId, 5));
                                        session.CurrentMapInstance.Broadcast(StaticPacketHelper.GenerateEff(UserType.Npc, mate.MateTransportId, 5002));
                                        session.SendPackets(session.Character.GenerateScP());
                                        session.SendPackets(session.Character.GenerateScN());
                                        session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("PET_EVOLED"), 10));
                                        if (session?.Character != null)
                                        {
                                            if (session.Character.Miniland == session.Character.MapInstance)
                                            {
                                                ServerManager.Instance.JoinMiniland(session, session);
                                            }
                                            else
                                            {
                                                ServerManager.Instance.ChangeMapInstance(session.Character.CharacterId,
                                                                                         session.Character.MapInstanceId, session.Character.PositionX, session.Character.PositionY,
                                                                                         true);
                                                session.SendPacket(StaticPacketHelper.Cancel(2));
                                            }
                                        }
                                    }
                                    else
                                    {
                                        if (mate.Level >= 30 && mate.NpcMonsterVNum == 660 && mate.IsTeamMember == true && mate.MateType == MateType.Pet)
                                        {
                                            mate.Level          = 1;
                                            mate.NpcMonsterVNum = 661;
                                            session.CurrentMapInstance.Broadcast(StaticPacketHelper.GenerateEff(UserType.Npc, mate.MateTransportId, 5));
                                            session.CurrentMapInstance.Broadcast(StaticPacketHelper.GenerateEff(UserType.Npc, mate.MateTransportId, 5002));
                                            session.SendPackets(session.Character.GenerateScP());
                                            session.SendPackets(session.Character.GenerateScN());
                                            session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("PET_EVOLED"), 10));
                                            if (session?.Character != null)
                                            {
                                                if (session.Character.Miniland == session.Character.MapInstance)
                                                {
                                                    ServerManager.Instance.JoinMiniland(session, session);
                                                }
                                                else
                                                {
                                                    ServerManager.Instance.ChangeMapInstance(session.Character.CharacterId,
                                                                                             session.Character.MapInstanceId, session.Character.PositionX, session.Character.PositionY,
                                                                                             true);
                                                    session.SendPacket(StaticPacketHelper.Cancel(2));
                                                }
                                            }
                                        }
                                        else
                                        {
                                            if (mate.Level >= 30 && mate.NpcMonsterVNum == 661 && mate.IsTeamMember == true && mate.MateType == MateType.Pet)
                                            {
                                                mate.Level          = 1;
                                                mate.NpcMonsterVNum = 662;
                                                session.CurrentMapInstance.Broadcast(StaticPacketHelper.GenerateEff(UserType.Npc, mate.MateTransportId, 5));
                                                session.CurrentMapInstance.Broadcast(StaticPacketHelper.GenerateEff(UserType.Npc, mate.MateTransportId, 5002));
                                                session.SendPackets(session.Character.GenerateScP());
                                                session.SendPackets(session.Character.GenerateScN());
                                                session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("PET_EVOLED"), 10));
                                                if (session?.Character != null)
                                                {
                                                    if (session.Character.Miniland == session.Character.MapInstance)
                                                    {
                                                        ServerManager.Instance.JoinMiniland(session, session);
                                                    }
                                                    else
                                                    {
                                                        ServerManager.Instance.ChangeMapInstance(session.Character.CharacterId,
                                                                                                 session.Character.MapInstanceId, session.Character.PositionX, session.Character.PositionY,
                                                                                                 true);
                                                        session.SendPacket(StaticPacketHelper.Cancel(2));
                                                    }
                                                }
                                            }
                                            else
                                            {
                                                if (mate.Level >= 30 && mate.NpcMonsterVNum == 657 && mate.IsTeamMember == true && mate.MateType == MateType.Pet)
                                                {
                                                    mate.Level          = 1;
                                                    mate.NpcMonsterVNum = 658;
                                                    session.CurrentMapInstance.Broadcast(StaticPacketHelper.GenerateEff(UserType.Npc, mate.MateTransportId, 5));
                                                    session.CurrentMapInstance.Broadcast(StaticPacketHelper.GenerateEff(UserType.Npc, mate.MateTransportId, 5002));
                                                    session.SendPackets(session.Character.GenerateScP());
                                                    session.SendPackets(session.Character.GenerateScN());
                                                    session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("PET_EVOLED"), 10));
                                                    if (session?.Character != null)
                                                    {
                                                        if (session.Character.Miniland == session.Character.MapInstance)
                                                        {
                                                            ServerManager.Instance.JoinMiniland(session, session);
                                                        }
                                                        else
                                                        {
                                                            ServerManager.Instance.ChangeMapInstance(session.Character.CharacterId,
                                                                                                     session.Character.MapInstanceId, session.Character.PositionX, session.Character.PositionY,
                                                                                                     true);
                                                            session.SendPacket(StaticPacketHelper.Cancel(2));
                                                        }
                                                    }
                                                }
                                                else
                                                {
                                                    if (mate.Level >= 30 && mate.NpcMonsterVNum == 658 && mate.IsTeamMember == true && mate.MateType == MateType.Pet)
                                                    {
                                                        mate.Level          = 1;
                                                        mate.NpcMonsterVNum = 659;
                                                        session.CurrentMapInstance.Broadcast(StaticPacketHelper.GenerateEff(UserType.Npc, mate.MateTransportId, 5));
                                                        session.CurrentMapInstance.Broadcast(StaticPacketHelper.GenerateEff(UserType.Npc, mate.MateTransportId, 5002));
                                                        session.SendPackets(session.Character.GenerateScP());
                                                        session.SendPackets(session.Character.GenerateScN());
                                                        session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("PET_EVOLED"), 10));
                                                        if (session?.Character != null)
                                                        {
                                                            if (session.Character.Miniland == session.Character.MapInstance)
                                                            {
                                                                ServerManager.Instance.JoinMiniland(session, session);
                                                            }
                                                            else
                                                            {
                                                                ServerManager.Instance.ChangeMapInstance(session.Character.CharacterId,
                                                                                                         session.Character.MapInstanceId, session.Character.PositionX, session.Character.PositionY,
                                                                                                         true);
                                                                session.SendPacket(StaticPacketHelper.Cancel(2));
                                                            }
                                                        }
                                                    }
                                                    else
                                                    {
                                                        if (mate.Level >= 30 && mate.NpcMonsterVNum == 660 && mate.IsTeamMember == true && mate.MateType == MateType.Pet)
                                                        {
                                                            mate.Level          = 1;
                                                            mate.NpcMonsterVNum = 661;
                                                            session.CurrentMapInstance.Broadcast(StaticPacketHelper.GenerateEff(UserType.Npc, mate.MateTransportId, 5));
                                                            session.CurrentMapInstance.Broadcast(StaticPacketHelper.GenerateEff(UserType.Npc, mate.MateTransportId, 5002));
                                                            session.SendPackets(session.Character.GenerateScP());
                                                            session.SendPackets(session.Character.GenerateScN());
                                                            session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("PET_EVOLED"), 10));
                                                            if (session?.Character != null)
                                                            {
                                                                if (session.Character.Miniland == session.Character.MapInstance)
                                                                {
                                                                    ServerManager.Instance.JoinMiniland(session, session);
                                                                }
                                                                else
                                                                {
                                                                    ServerManager.Instance.ChangeMapInstance(session.Character.CharacterId,
                                                                                                             session.Character.MapInstanceId, session.Character.PositionX, session.Character.PositionY,
                                                                                                             true);
                                                                    session.SendPacket(StaticPacketHelper.Cancel(2));
                                                                }
                                                            }
                                                        }
                                                        else
                                                        {
                                                            if (mate.Level >= 30 && mate.NpcMonsterVNum == 988 && mate.IsTeamMember == true && mate.MateType == MateType.Pet)
                                                            {
                                                                mate.Level          = 1;
                                                                mate.NpcMonsterVNum = 416;
                                                                session.CurrentMapInstance.Broadcast(StaticPacketHelper.GenerateEff(UserType.Npc, mate.MateTransportId, 5));
                                                                session.CurrentMapInstance.Broadcast(StaticPacketHelper.GenerateEff(UserType.Npc, mate.MateTransportId, 5002));
                                                                session.SendPackets(session.Character.GenerateScP());
                                                                session.SendPackets(session.Character.GenerateScN());
                                                                session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("PET_EVOLED"), 10));
                                                                if (session?.Character != null)
                                                                {
                                                                    if (session.Character.Miniland == session.Character.MapInstance)
                                                                    {
                                                                        ServerManager.Instance.JoinMiniland(session, session);
                                                                    }
                                                                    else
                                                                    {
                                                                        ServerManager.Instance.ChangeMapInstance(session.Character.CharacterId,
                                                                                                                 session.Character.MapInstanceId, session.Character.PositionX, session.Character.PositionY,
                                                                                                                 true);
                                                                        session.SendPacket(StaticPacketHelper.Cancel(2));
                                                                    }
                                                                }
                                                            }
                                                            else
                                                            {
                                                                if (mate.Level >= 30 && mate.NpcMonsterVNum == 416 && mate.IsTeamMember == true && mate.MateType == MateType.Pet)
                                                                {
                                                                    mate.Level          = 1;
                                                                    mate.NpcMonsterVNum = 412;
                                                                    session.CurrentMapInstance.Broadcast(StaticPacketHelper.GenerateEff(UserType.Npc, mate.MateTransportId, 5));
                                                                    session.CurrentMapInstance.Broadcast(StaticPacketHelper.GenerateEff(UserType.Npc, mate.MateTransportId, 5002));
                                                                    session.SendPackets(session.Character.GenerateScP());
                                                                    session.SendPackets(session.Character.GenerateScN());
                                                                    session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("PET_EVOLED"), 10));
                                                                    if (session?.Character != null)
                                                                    {
                                                                        if (session.Character.Miniland == session.Character.MapInstance)
                                                                        {
                                                                            ServerManager.Instance.JoinMiniland(session, session);
                                                                        }
                                                                        else
                                                                        {
                                                                            ServerManager.Instance.ChangeMapInstance(session.Character.CharacterId,
                                                                                                                     session.Character.MapInstanceId, session.Character.PositionX, session.Character.PositionY,
                                                                                                                     true);
                                                                            session.SendPacket(StaticPacketHelper.Cancel(2));
                                                                        }
                                                                    }
                                                                }
                                                                else
                                                                {
                                                                    if (mate.Level >= 30 && mate.NpcMonsterVNum == 412 && mate.IsTeamMember == true && mate.MateType == MateType.Pet)
                                                                    {
                                                                        mate.Level          = 1;
                                                                        mate.NpcMonsterVNum = 414;
                                                                        session.CurrentMapInstance.Broadcast(StaticPacketHelper.GenerateEff(UserType.Npc, mate.MateTransportId, 5));
                                                                        session.CurrentMapInstance.Broadcast(StaticPacketHelper.GenerateEff(UserType.Npc, mate.MateTransportId, 5002));
                                                                        session.SendPackets(session.Character.GenerateScP());
                                                                        session.SendPackets(session.Character.GenerateScN());
                                                                        session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("PET_EVOLED"), 10));
                                                                        if (session?.Character != null)
                                                                        {
                                                                            if (session.Character.Miniland == session.Character.MapInstance)
                                                                            {
                                                                                ServerManager.Instance.JoinMiniland(session, session);
                                                                            }
                                                                            else
                                                                            {
                                                                                ServerManager.Instance.ChangeMapInstance(session.Character.CharacterId,
                                                                                                                         session.Character.MapInstanceId, session.Character.PositionX, session.Character.PositionY,
                                                                                                                         true);
                                                                                session.SendPacket(StaticPacketHelper.Cancel(2));
                                                                            }
                                                                        }
                                                                    }
                                                                    else
                                                                    {
                                                                    }
                                                                }
                                                            }
                                                        }
                                                        break;
                                                    }
                                                    break;
                                                }
                                                break;
                                            }
                                            break;
                                        }
                                        break;
                                    }
                                    break;
                                }
                                break;
                            }
                            break;
                        }
                        break;
                    }
                    else
                    {
                        session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("PET_NOT_EVOLED"), 10));
                    }
                    break;
                }
                else
                {
                    session.Character.Inventory.RemoveItemFromInventory(inv.Id);
                    session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("PET_NOT_EVOLED"), 10));
                }
                break;

            case 2137:
                int rnd = ServerManager.RandomNumber(0, 1000);
                {
                    if (int.TryParse(packetsplit[3], out mateTransportId))
                    {
                        Mate mate = session.Character.Mates.Find(s => s.MateTransportId == mateTransportId);
                        if (mate == null)
                        {
                            session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("PICK_PET"), 10));
                        }
                        else
                        if (mate.Defence <= 9 || mate.Attack <= 9)
                        {
                            if (rnd >= 600 && rnd <= 800)
                            {
                                mate.Attack++;
                                session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("ATTACK_PLUS"), 10));
                                session.CurrentMapInstance.Broadcast(StaticPacketHelper.GenerateEff(UserType.Player, session.Character.CharacterId, 3004), session.Character.MapX, session.Character.MapY);
                            }
                            else if (rnd >= 801 && rnd <= 1000)
                            {
                                mate.Defence++;
                                session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("DEF_PLUS"), 10));
                                session.CurrentMapInstance.Broadcast(StaticPacketHelper.GenerateEff(UserType.Player, session.Character.CharacterId, 3004), session.Character.MapX, session.Character.MapY);
                            }
                            else if (rnd <= 800 && rnd >= 400)
                            {
                                if (mate.Defence == 0)
                                {
                                    return;
                                }
                                else
                                {
                                    mate.Defence--;
                                    session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("DEF_MINUS"), 10));
                                    session.CurrentMapInstance.Broadcast(StaticPacketHelper.GenerateEff(UserType.Player, session.Character.CharacterId, 3005), session.Character.MapX, session.Character.MapY);
                                }
                            }
                            else if (rnd <= 399 && rnd >= 0)
                            {
                                if (mate.Attack == 0)
                                {
                                    return;
                                }
                                else
                                {
                                    mate.Attack--;
                                    session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("ATTACK_MINUS"), 10));
                                    session.CurrentMapInstance.Broadcast(StaticPacketHelper.GenerateEff(UserType.Player, session.Character.CharacterId, 3005), session.Character.MapX, session.Character.MapY);
                                }
                            }
                            else
                            {
                                return;
                            }
                        }
                        else
                        {
                            return;
                        }
                    }
                    else
                    {
                        return;
                    }
                    session.Character.Inventory.RemoveItemAmount(2079, 1);
                }
                break;

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

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

            if (packetsplit == null)
            {
                return;
            }

            void releasePet(MateType mateType, Guid itemToRemoveId)
            {
                if (int.TryParse(packetsplit[3], out int mateTransportId))
                {
                    Mate mate = session.Character.Mates.Find(s => s.MateTransportId == mateTransportId && s.MateType == mateType);
                    if (mate != null)
                    {
                        if (!mate.IsTeamMember)
                        {
                            session.Character.Mates.Remove(mate);
                            session.SendPacket(UserInterfaceHelper.GenerateInfo(Language.Instance.GetMessageFromKey("PET_RELEASED")));
                            session.SendPacket(UserInterfaceHelper.GeneratePClear());
                            session.SendPackets(session.Character.GenerateScP());
                            session.SendPackets(session.Character.GenerateScN());
                            session.CurrentMapInstance?.Broadcast(mate.GenerateOut());
                            session.Character.Inventory.RemoveItemFromInventory(itemToRemoveId);
                        }
                        else
                        {
                            session.SendPacket(UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("PET_IN_TEAM_UNRELEASABLE"), 0));
                        }
                    }
                }
            }

            if (BCards.Count > 0 && session.Character.MapInstance == session.Character.Miniland)
            {
                BCards.ForEach(c => c.ApplyBCards(session.Character.BattleEntity, session.Character.BattleEntity));
                session.Character.Inventory.RemoveItemFromInventory(inv.Id);
                return;
            }

            switch (Effect)
            {
            case 10:
                if (int.TryParse(packetsplit[3], out int mateTransportId))
                {
                    Mate mate = session.Character.Mates.Find(s => s.MateTransportId == mateTransportId);
                    if (mate == null || mate.MateType != MateType.Pet || mate.Loyalty >= 1000)
                    {
                        return;
                    }
                    mate.Loyalty += 100;
                    if (mate.Loyalty > 1000)
                    {
                        mate.Loyalty = 1000;
                    }
                    mate.GenerateXp(EffectValue);
                    session.SendPacket(mate.GenerateCond());
                    session.SendPacket(StaticPacketHelper.GenerateEff(UserType.Npc, mate.MateTransportId, 5002));
                    session.Character.Inventory.RemoveItemFromInventory(inv.Id);
                }
                break;

            case 11:
                if (int.TryParse(packetsplit[3], out mateTransportId))
                {
                    Mate mate = session.Character.Mates.Find(s => s.MateTransportId == mateTransportId);
                    if (mate == null || mate.MateType != MateType.Pet || mate.Level >= session.Character.Level - 5 || mate.Level + 1 > ServerManager.Instance.Configuration.MaxLevel)
                    {
                        return;
                    }
                    mate.Level++;
                    session.CurrentMapInstance?.Broadcast(StaticPacketHelper.GenerateEff(UserType.Npc, mate.MateTransportId, 8), mate.PositionX, mate.PositionY);
                    session.CurrentMapInstance?.Broadcast(StaticPacketHelper.GenerateEff(UserType.Npc, mate.MateTransportId, 198), mate.PositionX, mate.PositionY);
                    session.Character.Inventory.RemoveItemFromInventory(inv.Id);
                }
                break;

            case 12:
                if (int.TryParse(packetsplit[3], out mateTransportId))
                {
                    Mate mate = session.Character.Mates.Find(s => s.MateTransportId == mateTransportId);
                    if (mate == null || mate.MateType != MateType.Partner || mate.Level >= session.Character.Level - 5 || mate.Level + 1 > ServerManager.Instance.Configuration.MaxLevel)
                    {
                        return;
                    }
                    mate.Level++;
                    session.CurrentMapInstance?.Broadcast(StaticPacketHelper.GenerateEff(UserType.Npc, mate.MateTransportId, 8), mate.PositionX, mate.PositionY);
                    session.CurrentMapInstance?.Broadcast(StaticPacketHelper.GenerateEff(UserType.Npc, mate.MateTransportId, 198), mate.PositionX, mate.PositionY);
                    session.Character.Inventory.RemoveItemFromInventory(inv.Id);
                }
                break;

            case 13:
                if (int.TryParse(packetsplit[3], out mateTransportId) && session.Character.Mates.FirstOrDefault(s => s.MateTransportId == mateTransportId) is Mate pet)
                {
                    if (pet.MateType == MateType.Pet)
                    {
                        session.SendPacket(UserInterfaceHelper.GenerateGuri(10, 1, mateTransportId, 2));
                    }
                    else
                    {
                        session.SendPacket(UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("CANT_CHANGE_PARTNER_NAME"), 0));
                    }
                }
                break;

            case 14:
                if (int.TryParse(packetsplit[3], out mateTransportId))
                {
                    if (session.Character.MapInstance == session.Character.Miniland)
                    {
                        Mate mate = session.Character.Mates.Find(s => s.MateTransportId == mateTransportId && s.MateType == MateType.Pet);
                        if (mate?.CanPickUp == false)
                        {
                            session.CurrentMapInstance.Broadcast(StaticPacketHelper.GenerateEff(UserType.Npc, mate.MateTransportId, 5));
                            session.CurrentMapInstance.Broadcast(StaticPacketHelper.GenerateEff(UserType.Npc, mate.MateTransportId, 5002));
                            mate.CanPickUp = true;
                            session.SendPackets(session.Character.GenerateScP());
                            session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("PET_CAN_PICK_UP"), 10));
                            session.Character.Inventory.RemoveItemFromInventory(inv.Id);
                        }
                    }
                    else
                    {
                        session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("NOT_IN_MINILAND"), 12));
                    }
                }
                break;

            case 16:
                if (int.TryParse(packetsplit[3], out mateTransportId))
                {
                    Mate mate = session.Character.Mates.Find(s => s.MateTransportId == mateTransportId);
                    if (mate == null || mate.MateType != MateType.Pet || mate.Level == 1)
                    {
                        return;
                    }
                    mate.Level--;
                    session.Character.Inventory.RemoveItemFromInventory(inv.Id);
                }
                break;

            case 17:
                if (int.TryParse(packetsplit[3], out mateTransportId))
                {
                    Mate mate = session.Character.Mates.Find(s => s.MateTransportId == mateTransportId);
                    if (mate?.IsSummonable == false)
                    {
                        mate.IsSummonable = true;
                        session.SendPackets(session.Character.GenerateScP());
                        session.SendPacket(session.Character.GenerateSay(string.Format(Language.Instance.GetMessageFromKey("PET_SUMMONABLE"), mate.Name), 10));
                        session.SendPacket(UserInterfaceHelper.GenerateMsg(string.Format(Language.Instance.GetMessageFromKey("PET_SUMMONABLE"), mate.Name), 0));
                        session.Character.Inventory.RemoveItemFromInventory(inv.Id);
                    }
                }
                break;

            case 18:
                if (int.TryParse(packetsplit[3], out mateTransportId))
                {
                    Mate mate = session.Character.Mates.Find(s => s.MateTransportId == mateTransportId);
                    if (mate == null || mate.MateType != MateType.Partner || mate.Level == 1)
                    {
                        return;
                    }
                    mate.Level--;
                    session.Character.Inventory.RemoveItemFromInventory(inv.Id);
                }
                break;

            case 1000:
                releasePet(MateType.Pet, inv.Id);
                break;

            case 1001:
                releasePet(MateType.Partner, inv.Id);
                break;

            default:
                Logger.Warn(string.Format(Language.Instance.GetMessageFromKey("NO_HANDLER_ITEM"), GetType(), VNum, Effect, EffectValue));
                break;
            }
        }
Exemple #7
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;
            }
        }
Exemple #8
0
        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;
            }
        }
Exemple #9
0
        public override void Use(ClientSession session, ref ItemInstance inv, byte option = 0, string[] packetsplit = null)
        {
            if (packetsplit == null)
            {
                return;
            }

            void ReleasePet(MateType mateType, Guid itemToRemoveId)
            {
                if (!int.TryParse(packetsplit[3], out int mateTransportId))
                {
                    return;
                }

                Mate mate = session.Character.Mates.Find(s => s.MateTransportId == mateTransportId && s.MateType == mateType);

                if (mate == null)
                {
                    return;
                }

                if (mate.MateType == MateType.Partner)
                {
                    if (mate.SpInstance != null || mate.GlovesInstance != null || mate.BootsInstance != null || mate.WeaponInstance != null || mate.ArmorInstance != null)
                    {
                        session.SendPacket(UserInterfaceHelper.GenerateInfo(Language.Instance.GetMessageFromKey("MUST_REMOVE_PARTNER_EQUIPMENT")));
                        return;
                    }
                }

                if (!mate.IsTeamMember)
                {
                    session.Character.Mates.Remove(mate);
                    session.SendPacket(UserInterfaceHelper.GenerateInfo(Language.Instance.GetMessageFromKey("PET_RELEASED")));
                    session.SendPacket(UserInterfaceHelper.GeneratePClear());
                    session.SendPackets(session.Character.GenerateScP());
                    session.SendPackets(session.Character.GenerateScN());
                    session.CurrentMapInstance?.Broadcast(mate.GenerateOut());
                    session.Character.Inventory.RemoveItemFromInventory(itemToRemoveId);
                }
                else
                {
                    session.SendPacket(UserInterfaceHelper.GenerateMsg(Language.Instance.GetMessageFromKey("PET_IN_TEAM_UNRELEASABLE"), 0));
                }
            }

            switch (Effect)
            {
            // loyalty & xp petfood
            case 10:
                if (int.TryParse(packetsplit[3], out var mateTransportId))
                {
                    Mate mate = session.Character.Mates.Find(s => s.MateTransportId == mateTransportId && s.MateType == MateType.Pet);

                    if (mate == null || mate.Loyalty >= 1000 || mate.MateType == MateType.Partner)
                    {
                        return;
                    }

                    mate.Loyalty = (short)(mate.Loyalty + 100 > 1000 ? 1000 : mate.Loyalty + 100);
                    mate.GenerateXp(EffectValue);
                    session.SendPacket(mate.GenerateScPacket());
                    mate.Owner?.Session.SendPacket(mate.GenerateCond());
                    mate.Owner?.Session.SendPacket(StaticPacketHelper.GenerateEff(UserType.Npc, mate.MateTransportId, 5));
                    mate.Owner?.Session.SendPacket(StaticPacketHelper.GenerateEff(UserType.Npc, mate.MateTransportId, 5002));
                    mate.Owner?.Session.SendPacket(mate.Owner.GenerateSay(Language.Instance.GetMessageFromKey("MATE_EATS_FOOD"), 10));
                    session.Character.Inventory.RemoveItemFromInventory(inv.Id);
                }
                break;

            case 11:
            case 12:
                if (int.TryParse(packetsplit[3], out mateTransportId))
                {
                    Mate mate = session.Character.Mates.Find(s => s.MateTransportId == mateTransportId && s.MateType == (Effect == 11 ? MateType.Pet : MateType.Partner));
                    AddPetLevel(ref mate, inv.Id);
                }
                break;

            case 13:
                if (int.TryParse(packetsplit[3], out mateTransportId) && session.Character.Mates.Any(s => s.MateTransportId == mateTransportId))
                {
                    session.SendPacket(UserInterfaceHelper.GenerateGuri(10, 1, mateTransportId, 2));
                }
                break;

            case 14:
                if (int.TryParse(packetsplit[3], out mateTransportId))
                {
                    Mate mate = session.Character.Mates.Find(s => s.MateTransportId == mateTransportId && s.MateType == MateType.Pet);
                    if (mate?.CanPickUp == false)
                    {
                        session.CurrentMapInstance.Broadcast(StaticPacketHelper.GenerateEff(UserType.Npc, mate.MateTransportId, 5));
                        session.CurrentMapInstance.Broadcast(StaticPacketHelper.GenerateEff(UserType.Npc, mate.MateTransportId, 5002));
                        mate.CanPickUp = true;
                        session.SendPackets(session.Character.GenerateScP());
                        session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("PET_CAN_PICK_UP"), 10));
                        session.Character.Inventory.RemoveItemFromInventory(inv.Id);
                    }
                }
                break;

            case 16:
                if (int.TryParse(packetsplit[3], out mateTransportId))
                {
                    Mate mate = session.Character.Mates.Find(s => s.MateTransportId == mateTransportId && s.MateType == MateType.Pet);
                    RemovePetLevel(ref mate, inv.Id);
                }
                break;

            case 17:
                if (int.TryParse(packetsplit[3], out mateTransportId))
                {
                    Mate mate = session.Character.Mates.Find(s => s.MateTransportId == mateTransportId);
                    if (mate?.IsSummonable == false)
                    {
                        mate.IsSummonable = true;
                        session.SendPackets(session.Character.GenerateScP());
                        session.SendPacket(session.Character.GenerateSay(string.Format(Language.Instance.GetMessageFromKey("PET_SUMMONABLE"), mate.Name), 10));
                        session.SendPacket(UserInterfaceHelper.GenerateMsg(string.Format(Language.Instance.GetMessageFromKey("PET_SUMMONABLE"), mate.Name), 0));
                        session.Character.Inventory.RemoveItemFromInventory(inv.Id);
                    }
                }
                break;

            case 18:
                if (int.TryParse(packetsplit[3], out mateTransportId))
                {
                    Mate mate = session.Character.Mates.Find(s => s.MateTransportId == mateTransportId && s.MateType == MateType.Partner);
                    RemovePetLevel(ref mate, inv.Id);
                }
                break;

            case 1000:
                ReleasePet(MateType.Pet, inv.Id);
                break;

            case 1001:
                ReleasePet(MateType.Partner, inv.Id);
                break;

            // Pet trainer
            case 10000:
                if (session.Character.MapInstance != session.Character.Miniland)
                {
                    session.SendPacket(UserInterfaceHelper.GenerateModal(Language.Instance.GetMessageFromKey("NOT_IN_MINILAND"), 1));
                    return;
                }

                var monster = new MapMonster
                {
                    MonsterVNum   = (short)EffectValue,
                    MapY          = session.Character.PositionY,
                    MapX          = session.Character.PositionX,
                    MapId         = session.Character.MapInstance.Map.MapId,
                    Position      = session.Character.Direction,
                    IsMoving      = true,
                    IsHostile     = true,
                    MapMonsterId  = session.CurrentMapInstance.GetNextMonsterId(),
                    IsMateTrainer = true,
                    ShouldRespawn = false
                };

                monster.Initialize(session.CurrentMapInstance);
                session.CurrentMapInstance.AddMonster(monster);
                session.CurrentMapInstance.Broadcast(monster.GenerateIn());
                session.Character.Inventory.RemoveItemAmount(inv.ItemVNum);
                monster.GetNearestOponent();
                break;

            default:
                Logger.Warn(string.Format(Language.Instance.GetMessageFromKey("NO_HANDLER_ITEM"), GetType(), VNum, Effect, EffectValue));
                break;
            }
        }
Exemple #10
0
        public override void Use(ClientSession session, ref ItemInstance inv, byte option = 0, string[] packetsplit = null)
        {
            if (packetsplit == null)
            {
                return;
            }
            int x1;

            switch (Effect)
            {
            case 11:
                if (int.TryParse(packetsplit[3], out x1))
                {
                    Mate mate = session.Character.Mates.FirstOrDefault(s => s.MateTransportId == x1);
                    if (mate == null || mate.Level >= session.Character.Level - 5)
                    {
                        return;
                    }
                    mate.Level++;
                    session.Character.Inventory.RemoveItemAmount(inv.ItemVNum);
                    session.CurrentMapInstance?.Broadcast(mate.GenerateEff(8), mate.PositionX, mate.PositionY);
                    session.CurrentMapInstance?.Broadcast(mate.GenerateEff(198), mate.PositionX, mate.PositionY);
                }
                break;

            case 13:
                if (int.TryParse(packetsplit[3], out x1))
                {
                    if (session.Character.Mates.Any(s => s.MateTransportId == x1))
                    {
                        session.SendPacket(UserInterfaceHelper.Instance.GenerateGuri(10, 1, x1, 2));
                    }
                }
                break;

            case 14:
                if (int.TryParse(packetsplit[3], out x1))
                {
                    Mate mate = session.Character.Mates.FirstOrDefault(s => s.MateTransportId == x1 && s.MateType == MateType.Pet);
                    if (mate != null)
                    {
                        if (!mate.CanPickUp)
                        {
                            session.Character.Inventory.RemoveItemAmount(inv.ItemVNum);
                            session.CurrentMapInstance.Broadcast(mate.GenerateEff(5));
                            session.CurrentMapInstance.Broadcast(mate.GenerateEff(5002));
                            mate.CanPickUp = true;
                            session.SendPackets(session.Character.GenerateScP());
                            session.SendPacket(session.Character.GenerateSay(Language.Instance.GetMessageFromKey("PET_CAN_PICK_UP"), 10));
                        }
                    }
                }
                break;

            case 17:
                if (int.TryParse(packetsplit[3], out x1))
                {
                    Mate mate = session.Character.Mates.FirstOrDefault(s => s.MateTransportId == x1);
                    if (mate != null)
                    {
                        if (!mate.IsSummonable)
                        {
                            session.Character.Inventory.RemoveItemAmount(inv.ItemVNum, 1);
                            mate.IsSummonable = true;
                            session.SendPackets(session.Character.GenerateScP());
                            session.SendPacket(session.Character.GenerateSay(string.Format(Language.Instance.GetMessageFromKey("PET_SUMMONABLE"), mate.Name), 10));
                            session.SendPacket(UserInterfaceHelper.Instance.GenerateMsg(string.Format(Language.Instance.GetMessageFromKey("PET_SUMMONABLE"), mate.Name), 0));
                        }
                    }
                }
                break;

            case 1000:
                if (int.TryParse(packetsplit[3], out x1))
                {
                    Mate mate = session.Character.Mates.FirstOrDefault(s => s.MateTransportId == x1 && s.MateType == MateType.Pet);
                    if (mate != null)
                    {
                        if (!mate.IsTeamMember)
                        {
                            session.Character.Mates.Remove(mate);
                            session.SendPacket(UserInterfaceHelper.Instance.GenerateInfo(Language.Instance.GetMessageFromKey("PET_RELEASED")));
                            session.SendPacket(UserInterfaceHelper.Instance.GeneratePClear());
                            session.SendPackets(session.Character.GenerateScP());
                            session.SendPackets(session.Character.GenerateScN());
                            session.Character.Inventory.RemoveItemAmountFromInventory(1, inv.Id);
                            session.CurrentMapInstance?.Broadcast(mate.GenerateOut());
                        }
                        else
                        {
                            session.SendPacket(UserInterfaceHelper.Instance.GenerateMsg(Language.Instance.GetMessageFromKey("PET_IN_TEAM_UNRELEASABLE"), 0));
                        }
                    }
                }
                break;

            case 1001:
                if (int.TryParse(packetsplit[3], out x1))
                {
                    Mate mate = session.Character.Mates.FirstOrDefault(s => s.MateTransportId == x1 && s.MateType == MateType.Partner);
                    if (mate != null)
                    {
                        if (!mate.IsTeamMember)
                        {
                            session.Character.Mates.Remove(mate);
                            session.SendPacket(UserInterfaceHelper.Instance.GenerateInfo(Language.Instance.GetMessageFromKey("PET_RELEASED")));
                            session.SendPacket(UserInterfaceHelper.Instance.GeneratePClear());
                            session.SendPackets(session.Character.GenerateScP());
                            session.SendPackets(session.Character.GenerateScN());
                            session.Character.Inventory.RemoveItemAmountFromInventory(1, inv.Id);
                            session.CurrentMapInstance?.Broadcast(mate.GenerateOut());
                        }
                        else
                        {
                            session.SendPacket(UserInterfaceHelper.Instance.GenerateMsg(Language.Instance.GetMessageFromKey("PET_IN_TEAM_UNRELEASABLE"), 0));
                        }
                    }
                }
                break;

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