public void Filter(EntityUpdate previous) { if (position != null) { if (Math.Abs(position.x - previous.position.x) < 100000 && Math.Abs(position.y - previous.position.y) < 100000 && Math.Abs(position.z - previous.position.z) < 100000) { position = null; } } rotation = null; if (velocity != null) { if (Math.Abs(velocity.z - previous.velocity.z) < 2) { velocity = null; } } if (acceleration != null) { if (Math.Abs(acceleration.x - previous.acceleration.x) < 10 && Math.Abs(acceleration.y - previous.acceleration.y) < 10 && Math.Abs(acceleration.z - previous.acceleration.z) < 10) { acceleration = null; } } if (extraVel != null) { if (Math.Abs(extraVel.x) < 1 && Math.Abs(extraVel.y) < 1 && Math.Abs(extraVel.z) < 1) { extraVel = null; } } viewportPitch = null; physicsFlags = null; if (modeTimer != null && modeTimer > 100) { previous.modeTimer = modeTimer;//necessary for rayhit filtering modeTimer = null; } lastHitTime = null; if (roll != null && !(roll > 500)) { roll = null; } if (stun != null && stun < previous.stun) { stun = null; } if (slow != null && slow < previous.slow) { slow = null; } if (ice != null && ice < previous.ice) { ice = null; } if (wind != null && wind < previous.wind) { wind = null; } showPatchTime = null; if (charge != null) { if (Math.Abs((float)(charge - previous.charge)) < 0.1f) { charge = null; } } unused24 = null; unused25 = null; if (rayHit != null) { if (previous.mode == 0 || previous.modeTimer > 1500 || //current could be null (Math.Abs(rayHit.x - previous.rayHit.x) < 1.5f && Math.Abs(rayHit.y - previous.rayHit.y) < 1.5f && Math.Abs(rayHit.z - previous.rayHit.z) < 1.5f)) { rayHit = null; } } MP = null; multipliers = null; unused31 = null; unused32 = null; XP = null; unused36 = null; powerBase = null; unused38 = null; unused39 = null; spawnPos = null; unused41 = null; unused42 = null; skillDistribution = null; manaCubes = null; }
public EntityUpdate(BinaryReader reader) { byte[] uncompressed = Zlib.Decompress(reader.ReadBytes(reader.ReadInt32())); MemoryStream stream = new MemoryStream(uncompressed); BinaryReader r = new BinaryReader(stream); guid = r.ReadInt64(); var bitfield = r.ReadInt64(); if (Tools.GetBit(bitfield, 0)) { position = new LongVector(r); } if (Tools.GetBit(bitfield, 1)) { rotation = new FloatVector(r); } if (Tools.GetBit(bitfield, 2)) { velocity = new FloatVector(r); } if (Tools.GetBit(bitfield, 3)) { acceleration = new FloatVector(r); } if (Tools.GetBit(bitfield, 4)) { extraVel = new FloatVector(r); } if (Tools.GetBit(bitfield, 5)) { viewportPitch = r.ReadSingle(); } if (Tools.GetBit(bitfield, 6)) { physicsFlags = r.ReadInt32(); } if (Tools.GetBit(bitfield, 7)) { hostility = r.ReadByte(); } if (Tools.GetBit(bitfield, 8)) { entityType = r.ReadInt32(); } if (Tools.GetBit(bitfield, 9)) { mode = r.ReadByte(); } if (Tools.GetBit(bitfield, 10)) { modeTimer = r.ReadInt32(); } if (Tools.GetBit(bitfield, 11)) { combo = r.ReadInt32(); } if (Tools.GetBit(bitfield, 12)) { lastHitTime = r.ReadInt32(); } if (Tools.GetBit(bitfield, 13)) { appearance = new Part.Appearance(r); } if (Tools.GetBit(bitfield, 14)) { entityFlags = r.ReadInt16(); } if (Tools.GetBit(bitfield, 15)) { roll = r.ReadInt32(); } if (Tools.GetBit(bitfield, 16)) { stun = r.ReadInt32(); } if (Tools.GetBit(bitfield, 17)) { slow = r.ReadInt32(); } if (Tools.GetBit(bitfield, 18)) { ice = r.ReadInt32(); } if (Tools.GetBit(bitfield, 19)) { wind = r.ReadInt32(); } if (Tools.GetBit(bitfield, 20)) { showPatchTime = r.ReadInt32(); } if (Tools.GetBit(bitfield, 21)) { entityClass = r.ReadByte(); } if (Tools.GetBit(bitfield, 22)) { specialization = r.ReadByte(); } if (Tools.GetBit(bitfield, 23)) { charge = r.ReadSingle(); } if (Tools.GetBit(bitfield, 24)) { unused24 = new FloatVector(r); } if (Tools.GetBit(bitfield, 25)) { unused25 = new FloatVector(r); } if (Tools.GetBit(bitfield, 26)) { rayHit = new FloatVector(r); } if (Tools.GetBit(bitfield, 27)) { HP = r.ReadSingle(); } if (Tools.GetBit(bitfield, 28)) { MP = r.ReadSingle(); } if (Tools.GetBit(bitfield, 29)) { block = r.ReadSingle(); } if (Tools.GetBit(bitfield, 30)) { multipliers = new Part.Multipliers(r); } if (Tools.GetBit(bitfield, 31)) { unused31 = r.ReadByte(); } if (Tools.GetBit(bitfield, 32)) { unused32 = r.ReadByte(); } if (Tools.GetBit(bitfield, 33)) { level = r.ReadInt32(); } if (Tools.GetBit(bitfield, 34)) { XP = r.ReadInt32(); } if (Tools.GetBit(bitfield, 35)) { parentOwner = r.ReadInt64(); } if (Tools.GetBit(bitfield, 36)) { unused36 = r.ReadInt64(); } if (Tools.GetBit(bitfield, 37)) { powerBase = r.ReadByte(); } if (Tools.GetBit(bitfield, 38)) { unused38 = r.ReadInt32(); } if (Tools.GetBit(bitfield, 39)) { unused39 = new IntVector(r); } if (Tools.GetBit(bitfield, 40)) { spawnPos = new LongVector(r); } if (Tools.GetBit(bitfield, 41)) { unused41 = new IntVector(r); } if (Tools.GetBit(bitfield, 42)) { unused42 = r.ReadByte(); } if (Tools.GetBit(bitfield, 43)) { consumable = new Part.Item(r); } if (Tools.GetBit(bitfield, 44)) { equipment = new Part.Item[13]; for (int i = 0; i < 13; i++) { equipment[i] = new Part.Item(r); } } if (Tools.GetBit(bitfield, 45)) { name = new string(r.ReadChars(16)); name = name.Substring(0, name.IndexOf("\0")); } if (Tools.GetBit(bitfield, 46)) { skillDistribution = new Part.SkillDistribution(r); } if (Tools.GetBit(bitfield, 47)) { manaCubes = r.ReadInt32(); } }