Advertisement
shekohex

DecryptAttackPacket

Mar 31st, 2017
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.49 KB | None | 0 0
  1.  public static void DecryptAttackPacket(byte[] Packet, Player player)
  2.         {
  3.             #region Extract attack information
  4.             ushort SpellID = 0, X = 0, Y = 0;
  5.             uint Target = 0;
  6.             #region GetSkillID
  7.             SpellID = Convert.ToUInt16(((long)Packet[28] & 0xFF) | (((long)Packet[29] & 0xFF) << 8));
  8.             SpellID ^= (ushort)0x915d;
  9.             SpellID ^= (ushort)player.UID;
  10.             SpellID = (ushort)(SpellID << 0x3 | SpellID >> 0xd);
  11.             SpellID -= 0xeb42;
  12.             #endregion
  13.             #region GetCoords
  14.             X = (ushort)((Packet[20] & 0xFF) | ((Packet[21] & 0xFF) << 8));
  15.             X = (ushort)(X ^ (uint)(player.UID & 0xffff) ^ 0x2ed6);
  16.             X = (ushort)(((X << 1) | ((X & 0x8000) >> 15)) & 0xffff);
  17.             X = (ushort)((X | 0xffff0000) - 0xffff22ee);
  18.  
  19.             Y = (ushort)((Packet[22] & 0xFF) | ((Packet[23] & 0xFF) << 8));
  20.             Y = (ushort)(Y ^ (uint)(player.UID & 0xffff) ^ 0xb99b);
  21.             Y = (ushort)(((Y << 5) | ((Y & 0xF800) >> 11)) & 0xffff);
  22.             Y = (ushort)((Y | 0xffff0000) - 0xffff8922);
  23.             #endregion
  24.             #region GetTarget
  25.             Target = ((uint)Packet[16] & 0xFF) | (((uint)Packet[17] & 0xFF) << 8) | (((uint)Packet[18] & 0xFF) << 16) | (((uint)Packet[19] & 0xFF) << 24);
  26.             Target = ((((Target & 0xffffe000) >> 13) | ((Target & 0x1fff) << 19)) ^ 0x5F2D2463 ^ player.UID) - 0x746F4AE6;
  27.             #endregion
  28.             #endregion
  29.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement