Esempio n. 1
0
 public TeleporterDTO Insert(TeleporterDTO teleporter)
 {
     using (var context = DataAccessHelper.CreateContext())
     {
         Teleporter entity = Mapper.Map <Teleporter>(teleporter);
         context.teleporter.Add(entity);
         context.SaveChanges();
         return(Mapper.Map <TeleporterDTO>(entity));
     }
 }
Esempio n. 2
0
 public IEnumerable <TeleporterDTO> LoadFromNpc(int npcId)
 {
     using (OpenNosContext context = DataAccessHelper.CreateContext())
     {
         List <TeleporterDTO> result = new List <TeleporterDTO>();
         foreach (Teleporter entity in context.Teleporter.Where(c => c.MapNpcId.Equals(npcId)))
         {
             TeleporterDTO dto = new TeleporterDTO();
             Mapper.Mapper.Instance.TeleporterMapper.ToTeleporterDTO(entity, dto);
             result.Add(dto);
         }
         return(result);
     }
 }
 public static bool ToTeleporterDTO(Teleporter input, TeleporterDTO output)
 {
     if (input == null)
     {
         return(false);
     }
     output.Index        = input.Index;
     output.MapId        = input.MapId;
     output.MapNpcId     = input.MapNpcId;
     output.MapX         = input.MapX;
     output.MapY         = input.MapY;
     output.TeleporterId = input.TeleporterId;
     return(true);
 }
Esempio n. 4
0
 public IEnumerable <TeleporterDTO> LoadAll()
 {
     using (OpenNosContext context = DataAccessHelper.CreateContext())
     {
         List <TeleporterDTO> result = new List <TeleporterDTO>();
         foreach (Teleporter entity in context.Teleporter)
         {
             TeleporterDTO dto = new TeleporterDTO();
             Mapper.Mapper.Instance.TeleporterMapper.ToTeleporterDTO(entity, dto);
             result.Add(dto);
         }
         return(result);
     }
 }
Esempio n. 5
0
 public TeleporterDTO Insert(TeleporterDTO teleporter)
 {
     try
     {
         using (var context = DataAccessHelper.CreateContext())
         {
             Teleporter entity = _mapper.Map <Teleporter>(teleporter);
             context.Teleporter.Add(entity);
             context.SaveChanges();
             return(_mapper.Map <TeleporterDTO>(entity));
         }
     }
     catch (Exception e)
     {
         Logger.Error(e);
         return(null);
     }
 }
Esempio n. 6
0
        public TeleporterDTO LoadById(short teleporterId)
        {
            try
            {
                using (OpenNosContext context = DataAccessHelper.CreateContext())
                {
                    TeleporterDTO dto = new TeleporterDTO();
                    if (Mapper.Mapper.Instance.TeleporterMapper.ToTeleporterDTO(context.Teleporter.FirstOrDefault(i => i.TeleporterId.Equals(teleporterId)), dto))
                    {
                        return(dto);
                    }

                    return(null);
                }
            }
            catch (Exception e)
            {
                Logger.Error(e);
                return(null);
            }
        }
Esempio n. 7
0
        public TeleporterDTO Insert(TeleporterDTO teleporter)
        {
            try
            {
                using (OpenNosContext context = DataAccessHelper.CreateContext())
                {
                    Teleporter entity = new Teleporter();
                    Mapper.Mapper.Instance.TeleporterMapper.ToTeleporter(teleporter, entity);
                    context.Teleporter.Add(entity);
                    context.SaveChanges();
                    if (Mapper.Mapper.Instance.TeleporterMapper.ToTeleporterDTO(entity, teleporter))
                    {
                        return(teleporter);
                    }

                    return(null);
                }
            }
            catch (Exception e)
            {
                Logger.Error(e);
                return(null);
            }
        }
Esempio n. 8
0
        public static void NRun(ClientSession Session, byte type, short runner, short data3, short npcid)
        {
            MapNpc npc = Session.CurrentMap.Npcs.FirstOrDefault(s => s.MapNpcId == npcid);

            switch (runner)
            {
            case 1:
                if (Session.Character.Class != (byte)ClassType.Adventurer)
                {
                    Session.Client.SendPacket(Session.Character.GenerateMsg(Language.Instance.GetMessageFromKey("NOT_ADVENTURER"), 0));
                    return;
                }
                if (Session.Character.Level < 15 || Session.Character.JobLevel < 20)
                {
                    Session.Client.SendPacket(Session.Character.GenerateMsg(Language.Instance.GetMessageFromKey("LOW_LVL"), 0));
                    return;
                }
                if (type == Session.Character.Class)
                {
                    return;
                }
                if (!Session.Character.EquipmentList.Inventory.Any())
                {
                    ItemInstance newItem1 = Session.Character.InventoryList.CreateItemInstance((short)(4 + type * 14));
                    Session.Character.EquipmentList.AddToInventoryWithSlotAndType(newItem1, (byte)InventoryType.Equipment, newItem1.Item.EquipmentSlot);
                    ItemInstance newItem2 = Session.Character.InventoryList.CreateItemInstance((short)(81 + type * 13));
                    Session.Character.EquipmentList.AddToInventoryWithSlotAndType(newItem2, (byte)InventoryType.Equipment, newItem2.Item.EquipmentSlot);
                    switch (type)
                    {
                    case 1:
                        ItemInstance newItem68 = Session.Character.InventoryList.CreateItemInstance(68);
                        Session.Character.EquipmentList.AddToInventoryWithSlotAndType(newItem68, (byte)InventoryType.Equipment, newItem68.Item.EquipmentSlot);
                        Session.Character.InventoryList.AddNewItemToInventory(2082, 10);
                        break;

                    case 2:
                        ItemInstance newItem78 = Session.Character.InventoryList.CreateItemInstance(78);
                        Session.Character.EquipmentList.AddToInventoryWithSlotAndType(newItem78, (byte)InventoryType.Equipment, newItem78.Item.EquipmentSlot);
                        Session.Character.InventoryList.AddNewItemToInventory(2083, 10);
                        break;

                    case 3:
                        ItemInstance newItem86 = Session.Character.InventoryList.CreateItemInstance(86);
                        Session.Character.EquipmentList.AddToInventoryWithSlotAndType(newItem86, (byte)InventoryType.Equipment, newItem86.Item.EquipmentSlot);
                        break;
                    }
                    Session.CurrentMap?.Broadcast(Session.Character.GenerateEq());
                    Session.Client.SendPacket(Session.Character.GenerateEquipment());
                    Session.Character.GenerateStartupInventory();
                    Session.Character.ChangeClass(Convert.ToByte(type));
                }
                else
                {
                    Session.Client.SendPacket(Session.Character.GenerateMsg(Language.Instance.GetMessageFromKey("EQ_NOT_EMPTY"), 0));
                }
                break;

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

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

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

            case 14:
                Session.Client.SendPacket($"wopen 27 0");
                string recipelist = "m_list 2";

                if (npc != null)
                {
                    List <Recipe> tp = npc.Recipes;

                    foreach (Recipe rec in tp.Where(s => s.Amount > 0))
                    {
                        recipelist += String.Format(" {0}", rec.ItemVNum);
                    }
                    recipelist += " -100";
                    Session.Client.SendPacket(recipelist);
                }
                break;

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

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

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

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

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

            default:
                Logger.Log.Warn(String.Format(Language.Instance.GetMessageFromKey("NO_NRUN_HANDLER"), runner));
                break;
            }
        }
Esempio n. 9
0
        public static void NRun(ClientSession Session, byte type, short runner, short npcid)
        {
            if (!Session.HasCurrentMapInstance)
            {
                return;
            }
            MapNpc npc = Session.CurrentMapInstance.Npcs.FirstOrDefault(s => s.MapNpcId == npcid);

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

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

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

            case 12:
                Session.SendPacket($"wopen {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 16:
                if (npc != null)
                {
                    TeleporterDTO tp = npc.Teleporters?.FirstOrDefault(s => s.Index == type);
                    if (tp != null)
                    {
                        if (Session.Character.Gold >= 1000 * type)
                        {
                            ServerManager.Instance.LeaveMap(Session.Character.CharacterId);
                            Session.Character.Gold -= 1000 * 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 26:
                if (npc != null)
                {
                    TeleporterDTO tp = npc.Teleporters?.FirstOrDefault(s => s.Index == type);
                    if (tp != null)
                    {
                        if (Session.Character.Gold >= 5000 * type)
                        {
                            ServerManager.Instance.LeaveMap(Session.Character.CharacterId);
                            Session.Character.Gold -= 5000 * 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 == type);
                    if (tp != null)
                    {
                        if (Session.Character.Gold >= 500)
                        {
                            ServerManager.Instance.LeaveMap(Session.Character.CharacterId);
                            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 == type);
                    if (tp != null)
                    {
                        ServerManager.Instance.LeaveMap(Session.Character.CharacterId);
                        ServerManager.Instance.ChangeMap(Session.Character.CharacterId, tp.MapId, tp.MapX, tp.MapY);
                    }
                }
                break;

            case 150:
                if (npc != null)
                {
                    if (Session.Character.Family != null)
                    {
                        ServerManager.Instance.LeaveMap(Session.Character.CharacterId);
                        ServerManager.Instance.ChangeMapInstance(Session.Character.CharacterId, Session.Character.Family.LandOfDeathId, 153, 145);
                    }
                    else
                    {
                        Session.SendPacket(Session.Character.GenerateMsg(Language.Instance.GetMessageFromKey("NEED_FAMILY"), 0));
                    }
                }
                break;

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

            case 23:
                Session.SendPacket(Session.Character.GenerateInbox(type, 14));
                //Session.SendPacket(Session.Character.GenerateFamilyMember());
                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 == type);
                    if (tp != null)
                    {
                        Session.SendPacket("it 3");
                        ServerManager.Instance.LeaveMap(Session.Character.CharacterId);
                        ServerManager.Instance.ChangeMap(Session.Character.CharacterId, tp.MapId, tp.MapX, tp.MapY);
                    }
                }
                break;

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

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

            case 5012:
                if (npc != null)
                {
                    TeleporterDTO tp = npc.Teleporters?.FirstOrDefault(s => s.Index == type);
                    if (tp != null)
                    {
                        ServerManager.Instance.LeaveMap(Session.Character.CharacterId);
                        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"), runner));
                break;
            }
        }
Esempio n. 10
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;
            }
        }
Esempio n. 11
0
        /// <summary>
        ///  guri packet
        /// </summary>
        /// <param name="guriPacket"></param>
        public void Guri(GuriPacket guriPacket)
        {
            if (guriPacket == null)
            {
                return;
            }
            if (guriPacket.Type == 10 && guriPacket.Data >= 973 && guriPacket.Data <= 999 && !Session.Character.EmoticonsBlocked)
            {
                if (guriPacket.User != null && Convert.ToInt64(guriPacket.User.Value) == Session.Character.CharacterId)
                {
                    Session.CurrentMapInstance?.Broadcast(Session, Session.Character.GenerateEff(guriPacket.Data + 4099), ReceiverType.AllNoEmoBlocked);
                }
                else
                {
                    Mate mate = Session.Character.Mates.FirstOrDefault(s => guriPacket.User != null && s.MateTransportId == Convert.ToInt32(guriPacket.User.Value));
                    if (mate != null)
                    {
                        Session.CurrentMapInstance?.Broadcast(Session, mate.GenerateEff(guriPacket.Data + 4099), ReceiverType.AllNoEmoBlocked);
                    }
                }
            }
            else
            {
                switch (guriPacket.Type)
                {
                // SHELL IDENTIFYING
                case 204:
                    if (guriPacket.User == null)
                    {
                        // WRONG PACKET
                        return;
                    }

                    var          inventoryType = (InventoryType)guriPacket.Argument;
                    ItemInstance pearls        = Session.Character.Inventory.FirstOrDefault(s => s.Value.ItemVNum == 1429).Value;
                    var          shell         = (WearableInstance)Session.Character.Inventory.LoadBySlotAndType((short)guriPacket.User.Value, inventoryType);

                    if (pearls == null)
                    {
                        // USING PACKET LOGGER
                        return;
                    }

                    if (shell.EquipmentOptions.Any())
                    {
                        // ALREADY IDENTIFIED
                        Session.SendPacket(UserInterfaceHelper.Instance.GenerateMsg(Language.Instance.GetMessageFromKey("SHELL_ALREADY_IDENTIFIED"), 0));
                        return;
                    }

                    if (!ShellGeneratorHelper.Instance.ShellTypes.TryGetValue(shell.ItemVNum, out byte shellType))
                    {
                        // SHELL TYPE NOT IMPLEMENTED
                        return;
                    }

                    if (shellType != 8 && shellType != 9)
                    {
                        if (shell.Upgrade < 50)
                        {
                            return;
                        }
                    }

                    if (shellType == 8 || shellType == 9)
                    {
                        switch (shell.Upgrade)
                        {
                        case 25:
                        case 30:
                        case 40:
                        case 55:
                        case 60:
                        case 65:
                        case 70:
                        case 75:
                        case 80:
                        case 85:
                            break;

                        default:
                            Session.Character.Inventory.RemoveItemAmountFromInventory(1, shell.Id);
                            Session.SendPacket(UserInterfaceHelper.Instance.GenerateMsg(Language.Instance.GetMessageFromKey("STOP_SPAWNING_BROKEN_SHELL"), 0));
                            return;
                        }
                    }

                    int perlsNeeded = shell.Upgrade / 10 + shell.Rare;

                    if (Session.Character.Inventory.CountItem(pearls.ItemVNum) < perlsNeeded)
                    {
                        // NOT ENOUGH PEARLS
                        return;
                    }

                    List <EquipmentOptionDTO> shellOptions = ShellGeneratorHelper.Instance.GenerateShell(shellType, shell.Rare, shell.Upgrade);

                    if (!shellOptions.Any())
                    {
                        Session.Character.Inventory.RemoveItemAmountFromInventory(1, shell.Id);
                        Session.SendPacket(UserInterfaceHelper.Instance.GenerateMsg(Language.Instance.GetMessageFromKey("STOP_SPAWNING_BROKEN_SHELL"), 0));
                        return;
                    }

                    shell.EquipmentOptions.AddRange(shellOptions);

                    Session.Character.Inventory.RemoveItemAmount(pearls.ItemVNum, perlsNeeded);
                    Session.CurrentMapInstance?.Broadcast(Session, Session.Character.GenerateEff(3006));
                    Session.SendPacket(UserInterfaceHelper.Instance.GenerateMsg(Language.Instance.GetMessageFromKey("SHELL_IDENTIFIED"), 0));
                    break;

                case 205:
                    if (guriPacket.User == null)
                    {
                        return;
                    }
                    const int perfumeVnum          = 1428;
                    var       perfumeInventoryType = (InventoryType)guriPacket.Argument;
                    var       eq = (WearableInstance)Session.Character.Inventory.LoadBySlotAndType((short)guriPacket.User.Value, perfumeInventoryType);

                    if (eq.BoundCharacterId == Session.Character.CharacterId)
                    {
                        // ALREADY YOURS
                        return;
                    }
                    if (eq.ShellRarity == null)
                    {
                        // NO SHELL APPLIED
                        return;
                    }

                    int perfumesNeeded = ShellGeneratorHelper.Instance.PerfumeFromItemLevelAndShellRarity(eq.Item.LevelMinimum, (byte)eq.ShellRarity.Value);
                    if (Session.Character.Inventory.CountItem(perfumeVnum) < perfumesNeeded)
                    {
                        // NOT ENOUGH PEARLS
                        return;
                    }

                    Session.Character.Inventory.RemoveItemAmount(perfumeVnum, perfumesNeeded);
                    eq.BoundCharacterId = Session.Character.CharacterId;
                    break;

                case 300:
                    if (guriPacket.Argument == 8023)
                    {
                        if (guriPacket.User == null)
                        {
                            return;
                        }
                        short        slot = (short)guriPacket.User.Value;
                        ItemInstance box  = Session.Character.Inventory.LoadBySlotAndType <BoxInstance>(slot, InventoryType.Equipment);
                        if (box != null)
                        {
                            if (guriPacket.Data > 0)
                            {
                                box.Item.Use(Session, ref box, 1, new[] { guriPacket.Data.ToString() });
                            }
                            else
                            {
                                box.Item.Use(Session, ref box, 1);
                            }
                        }
                    }
                    break;

                case 501:
                    if (ServerManager.Instance.IceBreakerInWaiting && IceBreaker.Map.Sessions.Count() < IceBreaker.MaxAllowedPlayers)
                    {
                        ServerManager.Instance.TeleportOnRandomPlaceInMap(Session, IceBreaker.Map.MapInstanceId);
                        var group = new Group(GroupType.IceBreaker);
                        if (Session.Character.Group != null)
                        {
                            foreach (var session in Session.Character.Group.Characters)
                            {
                                group.Characters.Add(session);
                            }
                        }
                        else
                        {
                            group.Characters.Add(Session);
                        }
                        IceBreaker.AddGroup(group);
                    }
                    break;

                case 502:
                    long?charid = guriPacket.User;
                    if (charid == null)
                    {
                        return;
                    }
                    ClientSession target = ServerManager.Instance.GetSessionByCharacterId(charid.Value);
                    IceBreaker.FrozenPlayers.Remove(target);
                    IceBreaker.AlreadyFrozenPlayers.Add(target);
                    target.SendPacket(target.Character?.GenerateCond());
                    target.CurrentMapInstance?.Broadcast(
                        UserInterfaceHelper.Instance.GenerateMsg(string.Format(Language.Instance.GetMessageFromKey("ICEBREAKER_PLAYER_UNFROZEN"), target.Character?.Name), 0));
                    if (!IceBreaker.SessionsHaveSameGroup(Session, target))
                    {
                        Group[] groups = { IceBreaker.GetGroupByClientSession(Session), IceBreaker.GetGroupByClientSession(target) };
                        IceBreaker.MergeGroups(groups);
                    }
                    break;

                case 506:
                    if (ServerManager.Instance.EventInWaiting)
                    {
                        Session.Character.IsWaitingForEvent = true;
                    }
                    break;

                case 710:     // Maps Teleporters
                    if (!Session.CurrentMapInstance.Npcs.Any(n => n.MapNpcId.Equals(guriPacket.Data)))
                    {
                        return;
                    }
                    Session.Character.TeleportOnMap((short)guriPacket.Argument, (short)guriPacket.User);
                    break;

                case 711:     // Maps Teleporters
                    TeleporterDTO tp = Session.CurrentMapInstance.Npcs.FirstOrDefault(n => n.Teleporters.Any(t => t?.TeleporterId == guriPacket.Argument))?.Teleporters.FirstOrDefault(t => t?.Type == TeleporterType.TeleportOnOtherMap);
                    if (tp == null)
                    {
                        return;
                    }
                    ServerManager.Instance.ChangeMap(Session.Character.CharacterId, tp.MapId, tp.MapX, tp.MapY);
                    break;

                case 4999:     //RollGeneratedItem for SpecialItem
                    if (guriPacket.Argument == 8023)
                    {
                        if (guriPacket.User == null)
                        {
                            return;
                        }
                        short        slot = (short)guriPacket.User.Value;
                        ItemInstance item = Session.Character.Inventory.LoadBySlotAndType(slot, InventoryType.Main);
                        if (item != null)
                        {
                            if (guriPacket.Data > 0)
                            {
                                item.Item.Use(Session, ref item, 1, new[] { guriPacket.Data.ToString() });
                            }
                            else
                            {
                                item.Item.Use(Session, ref item, 1);
                            }
                        }
                    }
                    break;

                default:
                    if (guriPacket.Type == 199 && guriPacket.Argument == 2)
                    {
                        short[] listWingOfFriendship = { 2160, 2312, 10048 };
                        short   vnumToUse            = -1;
                        foreach (short vnum in listWingOfFriendship)
                        {
                            if (Session.Character.Inventory.CountItem(vnum) > 0)
                            {
                                vnumToUse = vnum;
                            }
                        }
                        if (vnumToUse != -1 || Session.Character.Authority > AuthorityType.User)
                        {
                            if (guriPacket.User == null)
                            {
                                return;
                            }
                            if (!long.TryParse(guriPacket.User.Value.ToString(), out long charId))
                            {
                                return;
                            }
                            ClientSession session = ServerManager.Instance.GetSessionByCharacterId(charId);
                            if (session != null)
                            {
                                if (Session.Character.IsFriendOfCharacter(charId))
                                {
                                    if (session.CurrentMapInstance.MapInstanceType == MapInstanceType.BaseMapInstance)
                                    {
                                        short mapy  = session.Character.PositionY;
                                        short mapx  = session.Character.PositionX;
                                        short mapId = session.Character.MapInstance.Map.MapId;

                                        ServerManager.Instance.ChangeMap(Session.Character.CharacterId, mapId, mapx, mapy);
                                        Session.Character.Inventory.RemoveItemAmount(vnumToUse);
                                    }
                                    else
                                    {
                                        if (session.Character.Faction == Session.Character.Faction && session.Character.MapInstance.MapInstanceType == MapInstanceType.Act4Instance || session.Character.MapInstance.MapInstanceType == MapInstanceType.LobbyMapInstance)
                                        {
                                            short mapy  = session.Character.PositionY;
                                            short mapx  = session.Character.PositionX;
                                            Guid  mapId = session.CurrentMapInstance.MapInstanceId;

                                            ServerManager.Instance.ChangeMapInstance(Session.Character.CharacterId, mapId, mapx, mapy);
                                            Session.Character.Inventory.RemoveItemAmount(vnumToUse);
                                        }
                                        else
                                        {
                                            Session.SendPacket(UserInterfaceHelper.Instance.GenerateMsg(Language.Instance.GetMessageFromKey("USER_ON_INSTANCEMAP"), 0));
                                        }
                                    }
                                }
                            }
                            else
                            {
                                Session.SendPacket(UserInterfaceHelper.Instance.GenerateMsg(Language.Instance.GetMessageFromKey("USER_NOT_CONNECTED"), 0));
                            }
                        }
                        else
                        {
                            Session.SendPacket(Session.Character.GenerateSay(Language.Instance.GetMessageFromKey("NO_WINGS"), 10));
                        }
                    }
                    else
                    {
                        switch (guriPacket.Type)
                        {
                        case 400:
                            if (guriPacket.Argument != 0)
                            {
                                if (!Session.HasCurrentMapInstance)
                                {
                                    return;
                                }
                                MapNpc npc = Session.CurrentMapInstance.Npcs.FirstOrDefault(n => n.MapNpcId.Equals(guriPacket.Argument));
                                if (npc != null)
                                {
                                    NpcMonster mapobject = ServerManager.Instance.GetNpc(npc.NpcVNum);

                                    int rateDrop = ServerManager.Instance.DropRate;
                                    int delay    = (int)Math.Round((3 + mapobject.RespawnTime / 1000d) * Session.Character.TimesUsed);
                                    delay = delay > 11 ? 8 : delay;
                                    if (Session.Character.LastMapObject.AddSeconds(delay) < DateTime.Now)
                                    {
                                        if (mapobject.Drops.Any(s => s.MonsterVNum != null))
                                        {
                                            if (mapobject.VNumRequired > 10 && Session.Character.Inventory.CountItem(mapobject.VNumRequired) < mapobject.AmountRequired)
                                            {
                                                Session.SendPacket(UserInterfaceHelper.Instance.GenerateMsg(Language.Instance.GetMessageFromKey("NOT_ENOUGH_ITEM"), 0));
                                                return;
                                            }
                                        }
                                        var     random       = new Random();
                                        double  randomAmount = ServerManager.Instance.RandomNumber() * random.NextDouble();
                                        DropDTO drop         = mapobject.Drops.FirstOrDefault(s => s.MonsterVNum == npc.NpcVNum);
                                        if (drop != null)
                                        {
                                            short vnum = drop.ItemVNum;
                                            if (npc.NpcVNum == 2004 && npc.IsOut == false)
                                            {
                                                ItemInstance newInv = Session.Character.Inventory.AddNewToInventory(vnum).FirstOrDefault();
                                                if (newInv == null)
                                                {
                                                    return;
                                                }
                                                Session.Character.IncrementQuests(QuestType.Collect1, drop.ItemVNum);
                                                Session.CurrentMapInstance.Broadcast(npc.GenerateOut());
                                                Session.SendPacket(UserInterfaceHelper.Instance.GenerateMsg(string.Format(Language.Instance.GetMessageFromKey("RECEIVED_ITEM"), newInv.Item.Name), 0));
                                                Session.SendPacket(Session.Character.GenerateSay(string.Format(Language.Instance.GetMessageFromKey("RECEIVED_ITEM"), newInv.Item.Name), 11));
                                                return;
                                            }
                                            int dropChance = drop.DropChance;
                                            if (randomAmount <= (double)dropChance * rateDrop / 5000.000)
                                            {
                                                ItemInstance newInv = Session.Character.Inventory.AddNewToInventory(vnum).FirstOrDefault();
                                                Session.Character.LastMapObject = DateTime.Now;
                                                Session.Character.TimesUsed++;
                                                if (Session.Character.TimesUsed >= 4)
                                                {
                                                    Session.Character.TimesUsed = 0;
                                                }
                                                if (newInv != null)
                                                {
                                                    Session.SendPacket(UserInterfaceHelper.Instance.GenerateMsg(
                                                                           string.Format(Language.Instance.GetMessageFromKey("RECEIVED_ITEM"), newInv.Item.Name), 0));
                                                    Session.SendPacket(Session.Character.GenerateSay(string.Format(Language.Instance.GetMessageFromKey("RECEIVED_ITEM"), newInv.Item.Name),
                                                                                                     11));
                                                    Session.Character.IncrementQuests(QuestType.Collect1, vnum);
                                                }
                                                else
                                                {
                                                    Session.SendPacket(UserInterfaceHelper.Instance.GenerateMsg(Language.Instance.GetMessageFromKey("NOT_ENOUGH_PLACE"), 0));
                                                }
                                            }
                                            else
                                            {
                                                Session.SendPacket(UserInterfaceHelper.Instance.GenerateMsg(Language.Instance.GetMessageFromKey("TRY_FAILED"), 0));
                                            }
                                        }
                                    }
                                    else
                                    {
                                        Session.SendPacket(UserInterfaceHelper.Instance.GenerateMsg(
                                                               string.Format(Language.Instance.GetMessageFromKey("TRY_FAILED_WAIT"),
                                                                             (int)(Session.Character.LastMapObject.AddSeconds(delay) - DateTime.Now).TotalSeconds), 0));
                                    }
                                }
                            }
                            break;

                        case 710:
                            if (guriPacket.Value != null)
                            {
                                // MapNpc npc = Session.CurrentMapInstance.Npcs.FirstOrDefault(n =>
                                // n.MapNpcId.Equals(Convert.ToInt16(guriPacket.Data)); NpcMonster mapObject
                                // = ServerManager.Instance.GetNpc(npc.NpcVNum); teleport free
                            }
                            break;

                        case 750:
                            if (!guriPacket.User.HasValue)
                            {
                                const short baseVnum = 1623;
                                if (!short.TryParse(guriPacket.Argument.ToString(), out short faction))
                                {
                                    // WRONG PACKET
                                    return;
                                }
                                if (Session.Character.Inventory.CountItem(baseVnum + faction) < 1)
                                {
                                    // NO EGG
                                    return;
                                }
                                if (faction > 4)
                                {
                                    /*
                                     * Character faction : 1 - 2
                                     * Family faction : 3 - 4
                                     */
                                    return;
                                }
                                if (faction < 3)
                                {
                                    if (Session.Character.Family != null)
                                    {
                                        // CAN'T USE PERSONAL EGG IF IN FAMILY
                                        Session.SendPacket(UserInterfaceHelper.Instance.GenerateMsg(Language.Instance.GetMessageFromKey("CHANGE_CHARACTER_FACTION_IN_FAM"), 0));
                                        return;
                                    }
                                    Session.Character.Faction = (FactionType)faction;
                                    Session.Character.Inventory.RemoveItemAmount(baseVnum + faction);
                                    Session.SendPacket("scr 0 0 0 0 0 0 0");
                                    Session.SendPacket(Session.Character.GenerateFaction());
                                    Session.SendPacket(Session.Character.GenerateEff(4799 + faction));
                                    Session.SendPacket(UserInterfaceHelper.Instance.GenerateMsg(
                                                           Language.Instance.GetMessageFromKey(
                                                               $"GET_PROTECTION_POWER_{faction}"), 0));
                                }
                                else
                                {
                                    if (Session.Character.Family == null)
                                    {
                                        // IF CHARACTER HAS NO FAMILY
                                        Session.SendPacket(UserInterfaceHelper.Instance.GenerateMsg(Language.Instance.GetMessageFromKey("NEED_FAMILY"), 0));
                                        return;
                                    }
                                    if (Session.Character.FamilyCharacter.Authority != FamilyAuthority.Head)
                                    {
                                        // IF IS NOT HEAD OF FAMILY
                                        Session.SendPacket(UserInterfaceHelper.Instance.GenerateMsg(Language.Instance.GetMessageFromKey("NOT_FAMILYHEAD"), 0));
                                        return;
                                    }
                                    FamilyDTO fam = Session.Character.Family;
                                    fam.FamilyFaction         = (byte)(faction / 2);
                                    Session.Character.Faction = (FactionType)(faction / 2);
                                    Session.SendPacket(Session.Character.GenerateFaction());
                                    DaoFactory.FamilyDao.InsertOrUpdate(ref fam);
                                    ServerManager.Instance.FamilyRefresh(Session.Character.Family.FamilyId);
                                    Session.SendPacket(Session.Character.GenerateEff(4799 + faction / 2));
                                    Session.Character.Inventory.RemoveItemAmount(baseVnum + faction);
                                    Session.SendPacket(UserInterfaceHelper.Instance.GenerateMsg(
                                                           Language.Instance.GetMessageFromKey(
                                                               $"GET_PROTECTION_POWER_{faction / 2}"), 0));
                                }
                            }
                            break;

                        case 2:
                            Session.CurrentMapInstance?.Broadcast(UserInterfaceHelper.Instance.GenerateGuri(2, 1, Session.Character.CharacterId), Session.Character.PositionX,
                                                                  Session.Character.PositionY);
                            break;

                        case 4:
                            const int speakerVNum = 2173;
                            const int petnameVNum = 2157;
                            switch (guriPacket.Argument)
                            {
                            case 1:
                                Mate mate = Session.Character.Mates.FirstOrDefault(s => s.MateTransportId == guriPacket.Data);
                                if (guriPacket.Value.Length > 15)
                                {
                                    Session.SendPacket(UserInterfaceHelper.Instance.GenerateInfo(Language.Instance.GetMessageFromKey("NEW_NAME_PET_MAX_LENGTH")));
                                    return;
                                }
                                if (mate != null)
                                {
                                    mate.Name = guriPacket.Value;
                                    Session.CurrentMapInstance.Broadcast(mate.GenerateOut());
                                    Session.CurrentMapInstance.Broadcast(mate.GenerateIn());
                                    Session.SendPacket(UserInterfaceHelper.Instance.GenerateInfo(Language.Instance.GetMessageFromKey("NEW_NAME_PET")));
                                    Session.SendPacket(Session.Character.GeneratePinit());
                                    Session.SendPackets(Session.Character.Mates.Where(s => s.IsTeamMember)
                                                        .OrderBy(s => s.MateType)
                                                        .Select(s => s.GeneratePst()));
                                    Session.SendPackets(Session.Character.GenerateScP());
                                    Session.Character.Inventory.RemoveItemAmount(petnameVNum);
                                }
                                break;

                            case 2:
                                int presentationVNum = Session.Character.Inventory.CountItem(1117) > 0 ? 1117 : (Session.Character.Inventory.CountItem(9013) > 0 ? 9013 : -1);
                                if (presentationVNum != -1)
                                {
                                    string message = string.Empty;

                                    // message = $" ";
                                    string[] valuesplit = guriPacket.Value.Split(' ');
                                    message = valuesplit.Aggregate(message, (current, t) => current + t + "^");
                                    message = message.Substring(0, message.Length - 1);             // Remove the last ^
                                    message = message.Trim();
                                    if (message.Length > 60)
                                    {
                                        message = message.Substring(0, 60);
                                    }

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

                            case 3:
                                if (Session.Character.Inventory.CountItem(speakerVNum) > 0)
                                {
                                    if (Session.Character == null || guriPacket.Value == null)
                                    {
                                        return;
                                    }
                                    string   message    = $"<{Language.Instance.GetMessageFromKey("SPEAKER")}> [{Session.Character.Name}]:";
                                    string[] valuesplit = guriPacket.Value.Split(' ');
                                    message = valuesplit.Aggregate(message, (current, t) => current + t + " ");
                                    if (message.Length > 120)
                                    {
                                        message = message.Substring(0, 120);
                                    }

                                    message = message.Trim();

                                    if (Session.Character.IsMuted())
                                    {
                                        Session.SendPacket(Session.Character.GenerateSay(Language.Instance.GetMessageFromKey("SPEAKER_CANT_BE_USED"), 10));
                                        return;
                                    }
                                    Session.Character.Inventory.RemoveItemAmount(speakerVNum);
                                    ServerManager.Instance.Broadcast(Session.Character.GenerateSay(message, 13));
                                    LogHelper.Instance.InsertChatLog(ChatType.Speaker, Session.Character.CharacterId, message, Session.IpAddress);
                                }
                                break;
                            }

                            // presentation message

                            // Speaker
                            break;

                        default:
                            if (guriPacket.Type == 199 && guriPacket.Argument == 1)
                            {
                                if (guriPacket.User != null && long.TryParse(guriPacket.User.Value.ToString(), out long charId))
                                {
                                    if (!Session.Character.IsFriendOfCharacter(charId))
                                    {
                                        Session.SendPacket(Language.Instance.GetMessageFromKey("CHARACTER_NOT_IN_FRIENDLIST"));
                                        return;
                                    }
                                    Session.SendPacket(UserInterfaceHelper.Instance.GenerateDelay(3000, 4, $"#guri^199^2^{guriPacket.User.Value}"));
                                }
                            }
                            else
                            {
                                switch (guriPacket.Type)
                                {
                                case 201:
                                    if (Session.Character.StaticBonusList.Any(s => s.StaticBonusType == StaticBonusType.PetBasket))
                                    {
                                        Session.SendPacket(Session.Character.GenerateStashAll());
                                    }
                                    break;

                                case 202:
                                    Session.SendPacket(Session.Character.GenerateSay(Language.Instance.GetMessageFromKey("PARTNER_BACKPACK"), 10));
                                    Session.SendPacket(Session.Character.GeneratePStashAll());
                                    break;

                                default:
                                    switch (guriPacket.Type)
                                    {
                                    case 208 when guriPacket.Argument == 0:
                                    {
                                        if (guriPacket.User != null && short.TryParse(guriPacket.User.Value.ToString(), out short pearlSlot) &&
                                            short.TryParse(guriPacket.Value, out short mountSlot))
                                        {
                                            var mount = Session.Character.Inventory.LoadBySlotAndType <ItemInstance>(mountSlot, InventoryType.Main);
                                            var pearl = Session.Character.Inventory.LoadBySlotAndType <BoxInstance>(pearlSlot, InventoryType.Equipment);
                                            if (mount != null && pearl != null)
                                            {
                                                pearl.HoldingVNum = mount.ItemVNum;
                                                Session.Character.Inventory.RemoveItemAmountFromInventory(1, mount.Id);
                                            }
                                        }

                                        break;
                                    }

                                    case 209 when guriPacket.Argument == 0:
                                    {
                                        if (guriPacket.User != null && short.TryParse(guriPacket.User.Value.ToString(), out short pearlSlot) &&
                                            short.TryParse(guriPacket.Value, out short mountSlot))
                                        {
                                            var fairy = Session.Character.Inventory.LoadBySlotAndType <WearableInstance>(mountSlot, InventoryType.Equipment);
                                            var pearl = Session.Character.Inventory.LoadBySlotAndType <BoxInstance>(pearlSlot, InventoryType.Equipment);
                                            if (fairy != null && pearl != null)
                                            {
                                                pearl.HoldingVNum = fairy.ItemVNum;
                                                pearl.ElementRate = fairy.ElementRate;
                                                Session.Character.Inventory.RemoveItemAmountFromInventory(1, fairy.Id);
                                            }
                                        }

                                        break;
                                    }

                                    case 203 when guriPacket.Argument == 0:
                                        // SP points initialization
                                        int[] listPotionResetVNums = { 1366, 1427, 5115, 9040 };
                                        int   vnumToUse            = -1;
                                        foreach (int vnum in listPotionResetVNums)
                                        {
                                            if (Session.Character.Inventory.CountItem(vnum) > 0)
                                            {
                                                vnumToUse = vnum;
                                            }
                                        }
                                        if (vnumToUse != -1)
                                        {
                                            if (Session.Character.UseSp)
                                            {
                                                var specialistInstance =
                                                    Session.Character.Inventory.LoadBySlotAndType <SpecialistInstance>((byte)EquipmentType.Sp, InventoryType.Wear);
                                                if (specialistInstance != null)
                                                {
                                                    specialistInstance.SlDamage  = 0;
                                                    specialistInstance.SlDefence = 0;
                                                    specialistInstance.SlElement = 0;
                                                    specialistInstance.SlHP      = 0;

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

                                                    Session.Character.Inventory.RemoveItemAmount(vnumToUse);
                                                    Session.Character.Inventory.DeleteFromSlotAndType((byte)EquipmentType.Sp, InventoryType.Wear);
                                                    Session.Character.Inventory.AddToInventoryWithSlotAndType(specialistInstance, InventoryType.Wear, (byte)EquipmentType.Sp);
                                                    Session.SendPacket(Session.Character.GenerateCond());
                                                    Session.SendPacket(specialistInstance.GenerateSlInfo());
                                                    Session.SendPacket(Session.Character.GenerateLev());
                                                    Session.SendPacket(Session.Character.GenerateStatChar());
                                                    Session.SendPacket(UserInterfaceHelper.Instance.GenerateMsg(Language.Instance.GetMessageFromKey("POINTS_RESET"), 0));
                                                }
                                            }
                                            else
                                            {
                                                Session.SendPacket(Session.Character.GenerateSay(Language.Instance.GetMessageFromKey("TRANSFORMATION_NEEDED"), 10));
                                            }
                                        }
                                        else
                                        {
                                            Session.SendPacket(Session.Character.GenerateSay(Language.Instance.GetMessageFromKey("NOT_ENOUGH_POINTS"), 10));
                                        }

                                        break;
                                    }
                                    break;
                                }
                            }
                            break;
                        }
                    }
                    break;
                }
            }
        }
Esempio n. 12
0
        public static void NRun(ClientSession Session, byte type, short runner, short data3, short npcid)
        {
            MapNpc npc = Session.CurrentMap.Npcs.FirstOrDefault(s => s.MapNpcId == npcid);

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

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

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

            case 12:
                Session.SendPacket($"wopen {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 rec in tp.Where(s => s.Amount > 0))
                    {
                        recipelist += String.Format(" {0}", rec.ItemVNum);
                    }
                    recipelist += " -100";
                    Session.SendPacket(recipelist);
                }
                break;

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

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

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

            case 5012:
                if (npc != null)
                {
                    TeleporterDTO tp = npc.Teleporters?.FirstOrDefault(s => s.Index == type);
                    if (tp != null)
                    {
                        ServerManager.Instance.LeaveMap(Session.Character.CharacterId);
                        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"), runner));
                break;
            }
        }
        public static void NRun(ClientSession Session, byte type, short runner, short value, short npcid)
        {
            if (!Session.HasCurrentMap)
            {
                return;
            }
            MapNpc npc = Session.CurrentMap.Npcs.FirstOrDefault(s => s.MapNpcId == npcid);

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

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

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

            case 12:
                Session.SendPacket($"wopen {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 16:
                if (npc != null)
                {
                    TeleporterDTO tp = npc.Teleporters?.FirstOrDefault(s => s.Index == type);
                    if (tp != null)
                    {
                        if (Session.Character.Gold >= 1000 * type)
                        {
                            ServerManager.Instance.LeaveMap(Session.Character.CharacterId);
                            Session.Character.Gold -= 1000 * 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 26:
                if (npc != null)
                {
                    TeleporterDTO tp = npc.Teleporters?.FirstOrDefault(s => s.Index == type);
                    if (tp != null)
                    {
                        if (Session.Character.Gold >= 5000 * type)
                        {
                            ServerManager.Instance.LeaveMap(Session.Character.CharacterId);
                            Session.Character.Gold -= 5000 * 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 == type);
                    if (tp != null)
                    {
                        if (Session.Character.Gold >= 500)
                        {
                            ServerManager.Instance.LeaveMap(Session.Character.CharacterId);
                            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 == type);
                    if (tp != null)
                    {
                        ServerManager.Instance.LeaveMap(Session.Character.CharacterId);
                        ServerManager.Instance.ChangeMap(Session.Character.CharacterId, tp.MapId, tp.MapX, tp.MapY);
                    }
                }
                break;

            case 150:
                if (npc != null)
                {
                    var lodMinimumLevel = 45;
                    if (Session.Character.Level >= lodMinimumLevel)
                    {
                        ServerManager.Instance.LeaveMap(Session.Character.CharacterId);
                        ServerManager.Instance.ChangeMap(Session.Character.CharacterId, 150, 153, 145);
                    }
                    else
                    {
                        Session.SendPacket(Session.Character.GenerateSay("Vous devez être niveau " + lodMinimumLevel + " minimum pour entrer au LoD", 11));
                    }
                }
                break;

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

            case 23:
                Session.SendPacket(Session.Character.GenerateInbox(type, 14));
                Session.SendPacket(Session.Character.GenerateFamilyMember(Session.Character.Group));
                break;

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

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

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

            case 5012:
                if (npc != null)
                {
                    TeleporterDTO tp = npc.Teleporters?.FirstOrDefault(s => s.Index == type);
                    if (tp != null)
                    {
                        ServerManager.Instance.LeaveMap(Session.Character.CharacterId);
                        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"), runner));
                break;
            }
        }
 public TeleporterDTO Insert(TeleporterDTO teleporter)
 {
     throw new NotImplementedException();
 }
Esempio n. 15
0
        /// <summary>
        /// npc_req packet
        /// </summary>
        /// <param name="requestNpcPacket"></param>
        public void ShowShop(RequestNpcPacket requestNpcPacket)
        {
            long owner = requestNpcPacket.Owner;

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

                TeleporterDTO tp = npc.Teleporters?.FirstOrDefault(t => t?.Type == TeleporterType.TeleportOnMap);
                if (tp != null)
                {
                    Session.SendPacket(UserInterfaceHelper.Instance.GenerateDelay(5000, 1, $"#guri^710^{tp.MapX}^{tp.MapY}^{npc.MapNpcId}"));
                    return;
                }

                tp = npc.Teleporters?.FirstOrDefault(t => t?.Type == TeleporterType.TeleportOnOtherMap);
                if (tp != null)
                {
                    Session.SendPacket(UserInterfaceHelper.Instance.GenerateDelay(5000, 1, $"#guri^711^{tp.TeleporterId}"));
                    return;
                }

                #region Quest

                Session.Character.IncrementQuests(QuestType.Dialog1, npc.NpcVNum);
                Session.Character.IncrementQuests(QuestType.Dialog2, npc.NpcVNum);
                Session.Character.IncrementQuests(QuestType.Wear, npc.NpcVNum);
                Session.Character.IncrementQuests(QuestType.Brings, npc.NpcVNum);
                Session.Character.IncrementQuests(QuestType.Required, npc.NpcVNum);

                if (Session.Character.LastQuest.AddSeconds(1) > DateTime.Now)
                {
                    return;
                }

                #endregion

                if (npc.Npc.Drops.Any(s => s.MonsterVNum != null) && npc.Npc.Race == 8 && (npc.Npc.RaceType == 7 || npc.Npc.RaceType == 5))
                {
                    Session.SendPacket(UserInterfaceHelper.Instance.GenerateDelay(5000, 4, $"#guri^400^{npc.MapNpcId}"));
                }
                else if (npc.Npc.VNumRequired > 0 && npc.Npc.Race == 8 && (npc.Npc.RaceType == 7 || npc.Npc.RaceType == 5))
                {
                    Session.SendPacket(UserInterfaceHelper.Instance.GenerateDelay(6000, 4, $"#guri^400^{npc.MapNpcId}"));
                }
                else if (npc.Npc.MaxHP == 0 && npc.Npc.Drops.All(s => s.MonsterVNum == null) && npc.Npc.Race == 8 && (npc.Npc.RaceType == 7 || npc.Npc.RaceType == 5))
                {
                    Session.SendPacket(UserInterfaceHelper.Instance.GenerateDelay(5000, 1, $"#guri^710^162^85^{npc.MapNpcId}")); // #guri^710^X^Y^MapNpcId
                }
                else if (!string.IsNullOrEmpty(npc.GetNpcDialog()))
                {
                    Session.SendPacket(npc.GetNpcDialog());
                }
            }
        }