Exemple #1
0
    public FieldWar(int id)
    {
        Id    = id;
        MapId = FieldWarMetadataStorage.MapId(id);

        List <Player> onlinePlayers = GameServer.PlayerManager.GetAllPlayers().Where(x => !MapMetadataStorage.MapIsInstancedOnly(x.MapId)).ToList();

        DateTimeOffset now = DateTimeOffset.UtcNow;

        EntryClosureTime = now.AddSeconds(-now.Second).AddMinutes(5);

        foreach (Player player in onlinePlayers)
        {
            player.Session.Send(FieldWarPacket.LegionPopup(id, EntryClosureTime.ToUnixTimeSeconds()));
        }
    }
Exemple #2
0
    public override void Handle(GameSession session, PacketReader packet)
    {
        packet.ReadInt(); // ?

        // Liftable: 00 00 00 00 00
        // SendBreakable
        // Self
        Player  player  = session.Player;
        Account account = player.Account;

        session.EnterField(player);
        session.Send(StatPacket.SetStats(player.FieldPlayer));
        session.Send(StatPointPacket.WriteTotalStatPoints(player));
        session.Send(StatPointPacket.WriteTotalStatPoints(player)); // This packet is sent twice on GMS, not sure why
        session.Send(StatPointPacket.WriteStatPointDistribution(player));
        session.Send(SkillPointPacket.ExtraSkillPoints(player));

        if (player.ActivePet is not null)
        {
            player.ActivePet.SetMetadataValues();
            Pet pet = session.FieldManager.RequestPet(player.ActivePet, player.FieldPlayer);
            if (pet is not null)
            {
                player.FieldPlayer.ActivePet = pet;

                session.Send(ResponsePetPacket.LoadPetSettings(pet));
                session.Send(NoticePacket.Notice(SystemNotice.PetSummonOn, NoticeType.Chat | NoticeType.FastText));
            }
        }

        if (account.IsVip())
        {
            session.Send(BuffPacket.SendBuff(0,
                                             new(100000014, player.FieldPlayer.ObjectId, player.FieldPlayer.ObjectId, 1, (int)account.VIPExpiration, 1)));
            session.Send(PremiumClubPacket.ActivatePremium(player.FieldPlayer, account.VIPExpiration));
        }

        session.Send(EmotePacket.LoadEmotes(player));
        session.Send(MacroPacket.LoadControls(player.Macros));
        session.Send(ChatStickerPacket.LoadChatSticker(player));

        session.Send(ResponseCubePacket.DecorationScore(account.Home));
        session.Send(ResponseCubePacket.LoadHome(player.FieldPlayer.ObjectId, player.Account.Home));
        session.Send(ResponseCubePacket.ReturnMap(player.ReturnMapId));
        session.Send(LapenshardPacket.Load(player.Inventory.LapenshardStorage));

        IEnumerable <Cube> cubes = session.FieldManager.State.Cubes.Values
                                   .Where(x => x.Value.PlotNumber == 1 && x.Value.Item.HousingCategory is ItemHousingCategory.Farming or ItemHousingCategory.Ranching)
                                   .Select(x => x.Value);

        foreach (Cube cube in cubes)
        {
            session.Send(FunctionCubePacket.UpdateFunctionCube(cube.CoordF.ToByte(), 2, 1));
        }

        if (player.Party is not null)
        {
            session.Send(PartyPacket.UpdatePlayer(player));
        }

        GlobalEvent globalEvent = GameServer.GlobalEventManager.GetCurrentEvent();

        if (globalEvent is not null && !MapMetadataStorage.MapIsInstancedOnly(player.MapId))
        {
            session.Send(GlobalPortalPacket.Notice(globalEvent));
        }

        FieldWar fieldWar = GameServer.FieldWarManager.CurrentFieldWar;

        if (fieldWar is not null && !MapMetadataStorage.MapIsInstancedOnly(player.MapId) && fieldWar.MapId != player.MapId)
        {
            session.Send(FieldWarPacket.LegionPopup(fieldWar.Id, fieldWar.EntryClosureTime.ToUnixTimeSeconds()));
        }

        session.Send(KeyTablePacket.SendHotbars(player.GameOptions));

        TrophyManager.OnMapEntered(player, player.MapId);

        QuestManager.OnMapEnter(player, player.MapId);

        player.InitializeEffects();
    }