If you didn't find a Clientside solution yet and onWasHit is being invoked by all forms of damage, you could try:
PHP Code:
function onWasHit(){
//receive original x and y from before first frame of recoil movement
temp.x = player.x - player.hurtdx;
temp.y = player.y - player.hurtdy;
temp.plist = findnearestplayers(temp.x, temp.y);
for(temp.pl : temp.plist){
if(temp.pl.ani.name == "sword"){
temp.bx = temp.pl.x + 0.5 + (vecx(temp.pl.dir) * 2);
temp.by = temp.pl.y + 1 + (vecy(temp.pl.dir) * 2);
if(
temp.x + 0.5 <= temp.bx + 2 &&
temp.x + 2.5 >= temp.bx &&
temp.y + 1 <= temp.by + 2 &&
temp.y + 3 >= temp.by
){
this.playerSlashed(temp.pl);
return;
}
}
}
}