You can do it that way using a distance formula I guess, but that's probably a bit inefficient. Why not just trigger from a specific location?
PHP Code:
// in front of the player
temp.locations = { player.x + ( vecx( player.dir ) * 2 ) + 1.1, player.y + ( vecy( player.dir ) * 2 ) + 1.1 };
// trigger in front of the player to an action in NPCs/players
triggerAction( temp.locations[ 0 ], temp.locations[ 1 ], "action to hit the player/npc", parameters );
Something similar could be done for NPC -> NPC interaction as well I suppose.