Looks fine to me except you probably don't want to send 20 triggers per second.
Hurting NPCs should probably be done serverside:
PHP Code:
function hurtNPCs() {
for (temp.npc : findAreaNPCs(this.x, this.y, 2, 2)) {
temp.npc.trigger("hurt");
}
}
then you can add an onHurt function in any NPCs which can be hurt.