Code:
using System;
using System.Collections;
using System.Runtime.InteropServices;
using System.Text;
using System.Native;
namespace Conquer.Packets
{
public enum AttackTypes : uint
{
None = 0x00,
Physical = 0x02,
Magic = 0x15,
Archer = 0x19,
RequestMarriage = 0x08,
AcceptMarriage = 0x09,
Death = 0x0E
}
public unsafe struct RequestAttackPacket
{
public ushort Size;
public ushort Type;
public TIME TimeStamp;
public uint UID;
public uint OpponentUID;
public ushort X;
public ushort Y;
public AttackTypes AtkType;
// C++
// union DWORD
// {
// WORD SpellID;
// WORD SpellLevel;
// DWORD Damage;
// }
public ushort SpellID;
public ushort SpellLevel;
public fixed sbyte TQServer[8];
// Extra Informaiton used in re-casting (autoattack)
public ushort Attacker_X;
public ushort Attacker_Y;
public bool Aggressive;
public bool Decrypted;
public void Decrypt(uint Seed)
{
ushort wSeed = (ushort)Seed;
OpponentUID = (uint)Assembler.RollRight(OpponentUID, 13, 32);
OpponentUID = (OpponentUID ^ 0x5F2D2463 ^ Seed) - 0x746F4AE6;
SpellID = (ushort)(SpellID ^ (wSeed ^ 0x915D));
SpellID = (ushort)(Assembler.RollLeft(SpellID, 3, 16) - 0xEB42);
X = (ushort)(X ^ (wSeed ^ 0x2ED6));
X = (ushort)(Assembler.RollLeft(X, 1, 16) - 0x22ee);
Y = (ushort)(Y ^ (wSeed ^ 0xB99B));
Y = (ushort)(Assembler.RollLeft(Y, 5, 16) - 0x8922);
}
public static void MoveData(void* New, void* Old)
{
Native.memcpy(New, Old, *((ushort*)Old) + 8);
}
public static RequestAttackPacket Create()
{
RequestAttackPacket retn = new RequestAttackPacket();
retn.Size = 0x1C;
retn.Type = 0x3FE;
retn.TimeStamp = Native.timeGetTime();
PacketBuilder.AppendTQServer((byte*)retn.TQServer, 8);
return retn;
}
}
}