// The same mode also handles creation of new homes. private static void HandleMoveToHome(GameSession session, PacketReader packet) { int homeTemplate = packet.ReadInt(); Player player = session.Player; if (player.Account.Home == null) { player.Account.Home = new Home(player.Account.Id, player.Name, homeTemplate); GameServer.HomeManager.AddHome(player.Account.Home); // Send inventories session.Send(WarehouseInventoryPacket.StartList()); int counter = 0; foreach (KeyValuePair <long, Item> kvp in player.Account.Home.WarehouseInventory) { session.Send(WarehouseInventoryPacket.Load(kvp.Value, ++counter)); } session.Send(WarehouseInventoryPacket.EndList()); session.Send(FurnishingInventoryPacket.StartList()); foreach (Cube cube in player.Account.Home.FurnishingInventory.Values.Where(x => x.Item != null)) { session.Send(FurnishingInventoryPacket.Load(cube)); } session.Send(FurnishingInventoryPacket.EndList()); } Home home = GameServer.HomeManager.GetHomeById(player.Account.Home.Id); player.VisitingHomeId = player.Account.Home.Id; player.Guide = null; session.Send(ResponseCubePacket.LoadHome(session.FieldPlayer.ObjectId, session.Player.Account.Home)); player.Warp(home.MapId, player.Coord, player.Rotation, instanceId: home.InstanceId); }
private static void HandleBuyPlot(GameSession session, PacketReader packet) { int groupId = packet.ReadInt(); int housingTemplate = packet.ReadInt(); //TODO: If player already owns a plot, reject UGCMapGroup land = UGCMapMetadataStorage.GetMetadata(session.Player.MapId, (byte)groupId); if (!HandlePlotPayment(session, land.PriceItemCode, land.Price)) { return; } session.Player.PlotMapId = session.Player.MapId; session.Player.HomePlotNumber = land.Id; session.Player.HomeExpiration = DateTimeOffset.UtcNow.ToUnixTimeSeconds() + Environment.TickCount + (land.ContractDate * (24 * 60 * 60)); session.Player.HomeName = session.Player.Name; session.FieldManager.BroadcastPacket(ResponseCubePacket.PurchasePlot(session.Player)); session.FieldManager.BroadcastPacket(ResponseCubePacket.EnablePlotFurnishing(session.Player)); session.Send(ResponseCubePacket.LoadHome(session.FieldPlayer)); session.FieldManager.BroadcastPacket(ResponseCubePacket.NameHome(session.Player), session); session.Send(ResponseCubePacket.CompletePurchase()); }
private static void HandleNameHome(GameSession session, PacketReader packet) { string name = packet.ReadUnicodeString(); session.Player.HomeName = name; session.FieldManager.BroadcastPacket(ResponseCubePacket.NameHome(session.Player)); session.FieldManager.BroadcastPacket(ResponseCubePacket.LoadHome(session.FieldPlayer)); }
private static void HandleVisitHouse(GameSession session, PacketReader packet) { int returnMapId = packet.ReadInt(); packet.Skip(8); long accountId = packet.ReadLong(); string password = packet.ReadUnicodeString(); Player target = GameServer.Storage.GetPlayerByAccountId(accountId); if (target is null) { target = DatabaseManager.Characters.FindPartialPlayerById(accountId); if (target is null) { return; } } Player player = session.Player; Home home = GameServer.HomeManager.GetHomeByAccountId(accountId); if (home == null) { session.SendNotice("This player does not have a home!"); return; } if (player.VisitingHomeId == home.Id && player.MapId == (int)Map.PrivateResidence) { session.SendNotice($"You are already at {target.Name}'s home!"); return; } if (home.IsPrivate) { if (password == "") { session.Send(EnterUGCMapPacket.RequestPassword(accountId)); return; } if (home.Password != password) { session.Send(EnterUGCMapPacket.WrongPassword(accountId)); return; } } player.VisitingHomeId = home.Id; session.Send(ResponseCubePacket.LoadHome(session.FieldPlayer.ObjectId, home)); player.Warp(home.MapId, player.Coord, player.Rotation, instanceId: home.InstanceId); }
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)); 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(ChatStickerPacket.LoadChatSticker(player)); session.Send(HomeCommandPacket.LoadHome(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)); } session.Send(KeyTablePacket.SendHotbars(player.GameOptions)); List <GameEvent> gameEvents = DatabaseManager.Events.FindAll(); session.Send(GameEventPacket.Load(gameEvents)); TrophyManager.OnMapEntered(player, player.MapId); }
public override void Handle(GameSession session, PacketReader packet) { packet.ReadInt(); // ? // Liftable: 00 00 00 00 00 // SendBreakable // Self session.EnterField(session.Player.MapId); session.Send(StatPacket.SetStats(session.FieldPlayer)); session.Send(StatPointPacket.WriteTotalStatPoints(session.Player)); foreach (MasteryExp mastery in session.Player.Levels.MasteryExp) { session.Send(MasteryPacket.SetExp(mastery.Type, mastery.CurrentExp)); } if (session.Player.IsVip()) { session.Send(PremiumClubPacket.ActivatePremium(session.FieldPlayer, session.Player.VIPExpiration)); } session.Send(EmotePacket.LoadEmotes(session.Player)); session.Send(ChatStickerPacket.LoadChatSticker(session.Player)); session.Send(ResponseCubePacket.LoadHome(session.FieldPlayer)); // Normally skill layout would be loaded from a database QuickSlot arrowStream = QuickSlot.From(10500001); QuickSlot arrowBarrage = QuickSlot.From(10500011); QuickSlot eagleGlide = QuickSlot.From(10500151); QuickSlot testSkill = QuickSlot.From(10500153); if (session.Player.GameOptions.TryGetHotbar(0, out Hotbar mainHotbar)) { /* * mainHotbar.MoveQuickSlot(4, arrowStream); * mainHotbar.MoveQuickSlot(5, arrowBarrage); * mainHotbar.MoveQuickSlot(6, eagleGlide); * mainHotbar.MoveQuickSlot(7, testSkill); */ session.Send(KeyTablePacket.SendHotbars(session.Player.GameOptions)); } session.Send(GameEventPacket.Load()); }
private static void HandleBuyPlot(GameSession session, PacketReader packet) { int groupId = packet.ReadInt(); int housingTemplate = packet.ReadInt(); //TODO: If player already owns a plot, reject UGCMapGroup land = UGCMapMetadataStorage.GetMetadata(session.Player.MapId, (byte)groupId); if (land == null) { return; } //Check if sale event is active int price = land.Price; GameEvent gameEvent = DatabaseManager.GetSingleGameEvent(GameEventType.UGCMapContractSale); if (gameEvent != null) { int markdown = land.Price * ((gameEvent.UGCMapContractSale.DiscountAmount / 100) / 100); price = land.Price - markdown; } if (!HandlePlotPayment(session, land.PriceItemCode, price)) { return; } session.Player.PlotMapId = session.Player.MapId; session.Player.HomePlotNumber = land.Id; session.Player.HomeExpiration = DateTimeOffset.UtcNow.ToUnixTimeSeconds() + Environment.TickCount + (land.ContractDate * (24 * 60 * 60)); session.Player.HomeName = session.Player.Name; session.FieldManager.BroadcastPacket(ResponseCubePacket.PurchasePlot(session.Player)); session.FieldManager.BroadcastPacket(ResponseCubePacket.EnablePlotFurnishing(session.Player)); session.Send(ResponseCubePacket.LoadHome(session.FieldPlayer)); session.FieldManager.BroadcastPacket(ResponseCubePacket.NameHome(session.Player), session); session.Send(ResponseCubePacket.CompletePurchase()); }
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(session.FieldPlayer)); session.Send(StatPointPacket.WriteTotalStatPoints(player)); if (account.IsVip()) { session.Send(BuffPacket.SendBuff(0, new Status(100000014, session.FieldPlayer.ObjectId, session.FieldPlayer.ObjectId, 1, (int)account.VIPExpiration, 1))); session.Send(PremiumClubPacket.ActivatePremium(session.FieldPlayer, account.VIPExpiration)); } session.Send(EmotePacket.LoadEmotes(player)); session.Send(ChatStickerPacket.LoadChatSticker(player)); session.Send(HomeCommandPacket.LoadHome(player)); session.Send(ResponseCubePacket.DecorationScore(account.Home)); session.Send(ResponseCubePacket.LoadHome(session.FieldPlayer)); session.Send(ResponseCubePacket.ReturnMap(player.ReturnMapId)); if (player.Party != null) { session.Send(PartyPacket.UpdatePlayer(player)); } session.Send(KeyTablePacket.SendHotbars(player.GameOptions)); List <GameEvent> gameEvents = DatabaseManager.Events.FindAll(); session.Send(GameEventPacket.Load(gameEvents)); }
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(); }
public override void Handle(GameSession session, PacketReader packet) { packet.ReadInt(); // ? // Liftable: 00 00 00 00 00 // SendBreakable // Self session.EnterField(session.Player.MapId); session.Send(StatPacket.SetStats(session.FieldPlayer)); session.Send(StatPointPacket.WriteTotalStatPoints(session.Player)); foreach (MasteryExp mastery in session.Player.Levels.MasteryExp) { session.Send(MasteryPacket.SetExp(mastery.Type, mastery.CurrentExp)); } session.Send(EmotePacket.LoadEmotes(session.Player)); session.Send(ChatStickerPacket.LoadChatSticker(session.Player)); session.Send(ResponseCubePacket.LoadHome(session.FieldPlayer)); // Normally skill layout would be loaded from a database QuickSlot arrowStream = QuickSlot.From(10500001); QuickSlot arrowBarrage = QuickSlot.From(10500011); QuickSlot eagleGlide = QuickSlot.From(10500151); QuickSlot testSkill = QuickSlot.From(10500153); if (session.Player.GameOptions.TryGetHotbar(0, out Hotbar mainHotbar)) { /* * mainHotbar.MoveQuickSlot(4, arrowStream); * mainHotbar.MoveQuickSlot(5, arrowBarrage); * mainHotbar.MoveQuickSlot(6, eagleGlide); * mainHotbar.MoveQuickSlot(7, testSkill); */ session.Send(KeyTablePacket.SendHotbars(session.Player.GameOptions)); } // Add catalysts for testing Item item = new Item(40100001) { Amount = 99999 }; Item item2 = new Item(40100001) { Amount = 90000 }; InventoryController.Add(session, item, true); InventoryController.Add(session, item2, true); //Add mail for testing //System mail without any item Mail sysMail = new Mail ( 101, session.Player.CharacterId, "50000002", "", "", 0, DateTimeOffset.UtcNow.ToUnixTimeSeconds(), null ); // System mail with an item List <Item> items = new List <Item> { new Item(40100001) // 20302228 { CreationTime = DateTimeOffset.UtcNow.ToUnixTimeSeconds(), Owner = session.Player, Amount = 10000 } }; Mail sysItemMail = new Mail ( 101, session.Player.CharacterId, "53000042", "", "", 0, DateTimeOffset.UtcNow.ToUnixTimeSeconds(), items ); // Regular mail Mail regMail = new Mail ( 1, session.Player.CharacterId, session.Player.Name, "Test Title", "Test Body", 0, DateTimeOffset.UtcNow.ToUnixTimeSeconds(), null ); session.Player.Mailbox.AddOrUpdate(sysItemMail); session.Player.Mailbox.AddOrUpdate(sysMail); session.Player.Mailbox.AddOrUpdate(regMail); session.Send(GameEventPacket.Load()); }