Hey all. This script will save you from accidental teleports onto players using the infamous 0 speedhack with cheat engine. If you are within 1.1 tiles of the
avatar, if you get hit by a shot, the script will it will
block it, send a nexus, and disconnect you.
From my tests, it worked 100% of the time over 10+ tests on a 0/8 level 20 knight with tops, and it worked about 50% of the time over 6 tests on a level 1 trickster with no equips. You will have higher success rates playing on a server with low ping (close to you). On my level 1, I died more when I was on an EU server while I live in the US (but I still died on US servers sometimes, so I recommend being maxed).
I am in the process of porting it to K Relay.
Disclaimer: I am not responsible if you lose a character while using my script.
Code:
/* avatarblock.js by 059
UPDATE
Tile[] tiles
Entity[] newObjs
int[] drops
Entity
short objectType
Status status
Status
int objectId
Location pos
StatData[] data
Location
float x
float y
float distanceSquaredTo(Location location)
float distanceTo(Location location)
*/
var ID_MOVE = $.findPacketId("MOVE");
var ID_UPDATE = $.findPacketId("UPDATE");
var ID_ESCAPE = $.findPacketId("ESCAPE");
var ID_OTHERHIT = $.findPacketId("OTHERHIT");
var ID_PLAYERHIT = $.findPacketId("PLAYERHIT");
var myPos;
var block = false;
var avatarPos;
var avatarFound = false;
function onClientPacket(event) {
var packet = event.getPacket();
if (packet.id() == ID_MOVE) {
myPos = packet.newPosition;
if (avatarFound) {
var dist = Math.sqrt(myPos.distanceSquaredTo(avatarPos));
if (dist < 1.1) {
block = true;
} else
block = false;
}
}
if (block) {
if (packet.id() == ID_PLAYERHIT) {
event.cancel();
event.sendToServer(event.createPacket(ID_ESCAPE));
$.disconnect();
}
if (packet.id() == ID_SHOOTACK) {
event.cancel();
event.sendToServer(event.createPacket(ID_ESCAPE));
$.disconnect();
}
if (packet.id() == ID_OTHERHIT) {
event.cancel();
event.sendToServer(event.createPacket(ID_ESCAPE));
$.disconnect();
}
}
}
function onServerPacket(event) {
var packet = event.getPacket();
if (packet.id() == ID_UPDATE)
if (!avatarFound)
for (var x = 0; x < packet.newObjs.length; x++)
if (packet.newObjs[x].objectType == 0x734d) {
avatarFound = true;
avatarPos = packet.newObjs[x].status.pos;
}
}