local monsters = {"X1", "X2"}

if underattack("P") and maround(7, unpack(monsters)) < 2 then
closetibia()
else
if underattack("P") then
setcavebo("off")
end
end
how can i change the attackmode to defe and closetibia() if someone is attacking me?