Object check on getting distance for PvP attacks

Fixes #586, although I'm not entirely sure what's causing the object to be invalid in the first case, so this is a temporal fix.