isAttacked function no longer causing freeze

Still not finished though