public static void DecryptSkill(Player player, ref MsgInteract packet, out Skill skill) { byte[] buffer = packet; var id = Convert.ToUInt16(((long)buffer[24] & 0xFF) | (((long)buffer[25] & 0xFF) << 8)); id ^= 0x915d; id ^= (ushort)player.UniqueId; id = (ushort)(id << 0x3 | id >> 0xd); id -= 0xeb42; long x = (buffer[16] & 0xFF) | ((buffer[17] & 0xFF) << 8); long y = (buffer[18] & 0xFF) | ((buffer[19] & 0xFF) << 8); x = x ^ (player.UniqueId & 0xffff) ^ 0x2ed6; x = ((x << 1) | ((x & 0x8000) >> 15)) & 0xffff; x |= 0xffff0000; x -= 0xffff22ee; y = y ^ (player.UniqueId & 0xffff) ^ 0xb99b; y = ((y << 5) | ((y & 0xF800) >> 11)) & 0xffff; y |= 0xffff0000; y -= 0xffff8922; var target = BitConverter.ToUInt32(buffer, 12); target = (uint)((((target & 0xffffe000) >> 13) | ((target & 0x1fff) << 19)) ^ 0x5F2D2463 ^ player.UniqueId) - 0x746F4AE6; packet.TargetUniqueId = (int)target; packet.X = (ushort)x; packet.Y = (ushort)y; skill = player.Skills[(SkillId)id]; BufferPool.RecycleBuffer(buffer); }
public static void Handle(Player account, byte[] buffer) { MsgRemoteText packet = buffer; foreach (var mapObject in GameWorld.Maps.Values.SelectMany(value => value.Entities.Values).OfType <Player>()) { //mapObject.Send(MsgText.CreateFor(packet.Header, Constants.ALLUSERS, packet.Message, MsgTextType.Service)); } }
public static void Handle(Player player, byte[] packet) { AccountId = Encoding.Default.GetString(packet, 4, 16).Trim((char)0x0000); CharName = Encoding.Default.GetString(packet, 20, 16).Trim((char)0x0000); Model = BitConverter.ToUInt16(packet, 52); Job = (byte)BitConverter.ToUInt16(packet, 54); NameAvailable = GameWorld.NameAvailable(CharName); Player = SelectorSystem.GetOrCreatePlayer(AccountId, player.Password); Player.GameSocket = player.GameSocket; Process(); BufferPool.RecycleBuffer(packet); }
public static void Handle(Player player, byte[] packet) { Player = player; Amount = BitConverter.ToUInt16(packet, 10); for (var i = 0; i < Amount; i++) { UniqueIds.Add(BitConverter.ToUInt32(packet, 12 + i * 4)); } Process(); BufferPool.RecycleBuffer(packet); }
public static void Handle(Player player, byte[] buffer) { try { fixed(byte *p = buffer) { var packet = *(MsgFriend *)p; BufferPool.RecycleBuffer(buffer); switch (packet.Action) { case MsgFriendActionType.None: break; case MsgFriendActionType.FriendApply: FriendApply(player, ref packet); break; case MsgFriendActionType.FriendBreak: BreakFrienship(player, ref packet); break; case MsgFriendActionType.GetInfo: GetInfo(player, ref packet); break; case MsgFriendActionType.EnemyOnline: break; case MsgFriendActionType.EnemyOffline: break; case MsgFriendActionType.EnemyDel: break; case MsgFriendActionType.EnemyAdd: break; default: Output.WriteLine($"MsgFriend Subtype not implemented: {Enum.GetName(typeof(MsgFriendActionType), packet.Action)}"); Output.WriteLine(((byte[])packet).HexDump()); break; } } } catch (Exception e) { Output.WriteLine(e); } }
public static byte[] Create(Player member) { var packet = new MsgSynMemberInfo { Size = (ushort)sizeof(MsgSynMemberInfo), Id = 1112, Donation = member.GuildDonation, Rank = member.GuildRank, }; for (byte i = 0; i < member.Name.Length; i++) { packet.Name[i] = (byte)member.Name[i]; } return(packet); }
private static void BreakFrienship(Player player, ref MsgFriend packet) { if (player.Friends.Contains(packet.UniqId)) { player.Friends.Remove(packet.UniqId); } if (GameWorld.Find(packet.UniqId, out Player found)) { if (found.Friends.Contains(player.UniqueId)) { found.Friends.Remove(player.UniqueId); } found.Send(Create(player, MsgFriendActionType.FriendBreak, MsgFriendStatusType.Offline)); } player.Send(Create(found, MsgFriendActionType.FriendBreak, MsgFriendStatusType.Offline)); }
private static void Process() { if (VerifyJob(Job) && VerifyModel(Model) && VerifyName(CharName) && NameAvailable) { var character = CreateCharacter(); character.GameSocket = Player.GameSocket; character.GameSocket.Ref = character; character.AccountId = Player.AccountId; character.Password = Player.Password; Player = character; Player.LoginType = LoginType.Login; SelectorSystem.AddCharacterTo(Player.AccountId, Player); Player.ForceSend(MsgText.Create(Constants.System, Constants.Allusers, Constants.AnswerOk, MsgTextType.Dialog), 29 + Constants.System.Length + Constants.Allusers.Length + Constants.AnswerOk.Length); } else { Player.ForceSend(MsgText.Create(Constants.System, Constants.Allusers, "Taken or invalid name. (A-Y | 0-9)", MsgTextType.Dialog), 29 + Constants.System.Length + Constants.Allusers.Length + "Taken or invalid name. (A-Y | 0-9)".Length); } }
public static byte[] Create(Player target, MsgFriendActionType action, MsgFriendStatusType status) { var packet = new MsgFriend { Size = (ushort)sizeof(MsgFriend), Id = 1019, Action = action, IsOnline = status, Unknow1 = 0, Unknow2 = 0, UniqId = target.UniqueId, }; for (byte i = 0; i < target.Name.Length; i++) { packet.Name[i] = (byte)target.Name[i]; } return(packet); }
public static void Handle(Player player, byte[] buffer) { try { fixed(byte *p = buffer) { var packet = *(MsgWalk *)p; BufferPool.RecycleBuffer(buffer); if (player.UniqueId == packet.UniqueId) { player.CurrentTarget = null; player.RemoveSpawnProtection(); player.Direction = (Direction)((byte)packet.Direction % 8); player.Location.X += (ushort)Constants.DeltaX[(sbyte)player.Direction]; player.Location.Y += (ushort)Constants.DeltaY[(sbyte)player.Direction]; player.Emote = Emote.Stand; ScreenSystem.Send(player, packet, true, true, packet.Size); ScreenSystem.Update(player); if (TeamSystem.Teams.ContainsKey(player.UniqueId)) { TeamSystem.Teams[player.UniqueId].UpdateLeaderPosition(player); } } else if (packet.UniqueId == player.Pet?.UniqueId) { player.Pet.Direction = (Direction)((byte)packet.Direction % 8); player.Pet.Location.X += (ushort)Constants.DeltaX[(sbyte)player.Direction]; player.Pet.Location.Y += (ushort)Constants.DeltaY[(sbyte)player.Direction]; ScreenSystem.Send(player.Pet, packet, false, true, packet.Size); ScreenSystem.Update(player.Pet); } } } catch (Exception e) { Output.WriteLine(e); } }
private static void GiveStarterItems(Player character) { character.Equipment.AddOrUpdate(MsgItemPosition.Armor, ItemFactory.Create(ItemNames.Coat)); character.Inventory.AddItem(ItemFactory.Create(ItemNames.Stancher), 3); if (Job == 100) { character.Equipment.AddOrUpdate(MsgItemPosition.RightWeapon, ItemFactory.Create(ItemNames.LuckyBacksword)); character.Inventory.AddItem(ItemFactory.Create(ItemNames.Agrypnotic), 3); } if (Job == 40) { character.Equipment.AddOrUpdate(MsgItemPosition.RightWeapon, ItemFactory.Create(ItemNames.LuckyBow)); character.Inventory.AddItem(ItemFactory.Create(ItemNames.LuckyArrow), 3); } if (Job == 10 || Job == 20) { character.Equipment.AddOrUpdate(MsgItemPosition.RightWeapon, ItemFactory.Create(ItemNames.LuckyBlade)); } }
public static byte[] Create(Player target) { var packet = new MsgFriendInfo { Size = (ushort)sizeof(MsgFriendInfo), Id = 2033, UniqId = target.UniqueId, Look = target.Look, Level = target.Level, Profession = target.Class, PkPoints = target.PkPoints, GuildUID = 0, Unknow = 0, Position = (byte)target.GuildRank, }; for (byte i = 0; i < target.Partner.Length; i++) { packet.Spouse[i] = (byte)target.Partner[i]; } return(packet); }
private static void FriendApply(Player player, ref MsgFriend packet) { if (GameWorld.Find(packet.UniqId, out Player target)) { if (target.FriendRequestTarget == player.UniqueId) { player.ForceSend(BufferPool.Clone(packet), packet.Size); target.ForceSend(packet, packet.Size); player.Send(Create(target, MsgFriendActionType.FriendAccept, MsgFriendStatusType.Online)); target.Send(Create(player, MsgFriendActionType.FriendAccept, MsgFriendStatusType.Online)); if (player.Friends == null) { player.Friends = new List <int>(); } if (target.Friends == null) { target.Friends = new List <int>(); } if (!player.Friends.Contains(target.UniqueId)) { player.Friends.Add(target.UniqueId); } if (!target.Friends.Contains(player.UniqueId)) { target.Friends.Add(player.UniqueId); } } else { player.FriendRequestTarget = target.UniqueId; target.ForceSend(packet, packet.Size); } } }
public static void Handle(Player player, byte[] buffer) { try { fixed(byte *p = buffer) { var packet = *(MsgSynMemberInfo *)p; BufferPool.RecycleBuffer(buffer); var name = Encoding.UTF8.GetString(packet.Name, 16); if (GameWorld.Find(name.TrimEnd('\0'), out Player found)) { var msg = Create(found); player.Send(msg); } } } catch (Exception e) { Output.WriteLine(e); } }
public static void Handle(Player player, byte[] buffer) { try { fixed(byte *p = buffer) { var packet = *(MsgFloorItem *)p; BufferPool.RecycleBuffer(buffer); switch (packet.MsgFloorItemType) { case MsgFloorItemType.Pick: PickupItem(player, ref packet); break; case MsgFloorItemType.DisplayEffect: break; case MsgFloorItemType.SynchroTrap: break; case MsgFloorItemType.RemoveEffect: break; default: Output.WriteLine(((byte[])packet).HexDump()); break; } } } catch (Exception e) { Output.WriteLine(e); } }
private static void GetInfo(Player player, ref MsgFriend packet) { }
private static Player CreateCharacter() { var character = new Player(true) { UniqueId = UniqueIdGenerator.GetNext(EntityType.Player), Name = CharName.Size16(), Partner = "None", Level = 1, Money = 1000, Look = Model, Class = Job, MapId = 1010, Profs = new Dictionary <int, Prof> { [134] = new Prof(134, 0, 0), [133] = new Prof(133, 0, 0), [130] = new Prof(130, 0, 0), [131] = new Prof(131, 0, 0), [117] = new Prof(117, 0, 0), [114] = new Prof(114, 0, 0), [113] = new Prof(113, 0, 0), [118] = new Prof(118, 0, 0), [111] = new Prof(111, 0, 0), [121] = new Prof(121, 0, 0), [120] = new Prof(120, 0, 0), [150] = new Prof(150, 0, 0), [151] = new Prof(151, 0, 0), [152] = new Prof(152, 0, 0), [160] = new Prof(160, 0, 0), [900] = new Prof(900, 0, 0), [400] = new Prof(400, 0, 0), [410] = new Prof(410, 0, 0), [420] = new Prof(420, 0, 0), [421] = new Prof(421, 0, 0), [430] = new Prof(430, 0, 0), [440] = new Prof(440, 0, 0), [450] = new Prof(450, 0, 0), [460] = new Prof(460, 0, 0), [480] = new Prof(480, 0, 0), [481] = new Prof(481, 0, 0), [490] = new Prof(490, 0, 0), [500] = new Prof(500, 0, 0), [510] = new Prof(510, 0, 0), [530] = new Prof(530, 0, 0), [540] = new Prof(540, 0, 0), [560] = new Prof(560, 0, 0), [561] = new Prof(561, 0, 0), [562] = new Prof(562, 0, 0), [580] = new Prof(580, 0, 0) } }; GiveStarterItems(character); EntityLogic.Recalculate(character); character.CurrentHp = character.MaximumHp; character.CurrentMp = character.MaximumMp; character.Money = 1000; character.Location = new Vector2(61, 109); return(character); }
public static void Handle(Player player, byte[] buffer) { try { fixed(byte *p = buffer) { var packet = *(MsgName *)p; BufferPool.RecycleBuffer(buffer); switch (packet.Type) { case MsgNameType.None: break; case MsgNameType.Fireworks: break; case MsgNameType.CreateSyn: break; case MsgNameType.Syndicate: break; case MsgNameType.ChangeTitle: break; case MsgNameType.DelRole: break; case MsgNameType.Spouse: break; case MsgNameType.QueryNpc: break; case MsgNameType.Wanted: break; case MsgNameType.MapEffect: break; case MsgNameType.RoleEffect: break; case MsgNameType.MemberList: if (player.Guild != null) { var list = player.Guild.GetMemberList(); if (packet.Data == int.MaxValue) { packet.Data = 0; } var amount = list.Length - packet.Data * 10; if (amount > 10) { amount = 10; } var tempList = new string[amount]; Array.Copy(list, (int)(packet.Data * 10), tempList, 0, (int)amount); player.Send(Create((int)(packet.Data + 1), tempList, MsgNameType.MemberList)); } break; case MsgNameType.KickOutSynMem: break; case MsgNameType.QueryWanted: break; case MsgNameType.QueryPoliceWanted: break; case MsgNameType.PoliceWanted: break; case MsgNameType.QuerySpouse: //View equips? { //foreach (var item in player.Equipment.Items) //{ // var ItemInfo = new MsgItemInfoEx(item.Value, item.Key, ItemExType.OtherPlayer_Equipement); // player.ForceSend(ItemInfo, ItemInfo.Size); //} player.Send(Create(packet.Data + 1, player.Partner, (int)MsgNameType.QuerySpouse)); } break; case MsgNameType.AddDicePlayer: break; case MsgNameType.DelDicePlayer: break; case MsgNameType.DiceBonus: break; case MsgNameType.Sound: break; case MsgNameType.SynEnemie: break; case MsgNameType.SynAlly: break; case MsgNameType.Bavarder: var data = Encoding.UTF8.GetString(packet.Params, 255).Trim('\0').Trim('\u0006').Split(new[] { '\t' }, StringSplitOptions.RemoveEmptyEntries); if (data.Length > 0) { if (GameWorld.Find(data[0], out Player found)) { var synName = "No~Guild"; if (found.Guild != null) { synName = found.Guild.Name; } var targetInfo = found.UniqueId + " " + found.Level + " " + 0 /*found.Potency*/ + " #" + synName + " #" + "YiOnline" + " " + found.Partner + " " + 0 /*found.Nobility.Rank*/ + " " + (found.Look % 1000 == 3 ? 1 : 0); player.Send(Create(0, new[] { found.Name.Trim('\0'), targetInfo }, MsgNameType.Bavarder)); } } break; default: Output.WriteLine(((byte[])packet).HexDump()); break; } } } catch (Exception e) { Output.WriteLine(e); } }
private static void PickupItem(Player player, ref MsgFloorItem packet) => FloorItemSystem.Pickup(player, packet.UniqueId);