Your browser does not support JavaScript or its disabled!
Please turn it on, or be aware that some features on this website will not work correctly.
236
Fight Mode Toggle #39
Toggles current fight mode depending on amount of mobs around.
550b | 19 lines.
local fightmode = FightOffensive
macro(500, "Fight Mode Toggle", function()
    if isInPz() then return end
    local monsters = 0
    for i, mob in ipairs(getSpectators(posz())) do
        if mob:isMonster() and getDistanceBetween(player:getPosition(), mob:getPosition()) ==1 then
            monsters = monsters + 1
        end
    end
    if monsters >= 4 then
        fightmode = FightDefensive
    else
        fightmode = FightOffensive
    end

    if fightmode ~= g_game.getFightMode() then
        g_game.setFightMode(fightmode)
    end
end)

12 Jun 2021