local function spiral_wrap_signed(value, bits)
    local modulus = 2 ^ bits
    value = value % modulus
    if value >= modulus / 2 then value = value - modulus end
    return value
end
local function spiral_mul_mod32(a, b)
    a = a % 4294967296
    b = b % 4294967296
    local a_low = a % 65536
    local a_high = (a - a_low) / 65536
    return (a_low * b + ((a_high * b) % 65536) * 65536) % 4294967296
end
local Us0_Some, Us0_None, Us1_ReachFirst, Us1_CurrentFirst, Us1_Scored, Mut0, Uh0_Cons, Mut1, Mut2, Us2_Knight, Us2_Target, Us3_Some, Us3_None, Us4_Some, Us4_None, Us5_Some, Us5_None, Us6_Stepped, Us6_Gated, Us6_Cornered, Us7_Free, Us7_Ramp, Us7_Occupied, Us7_Blocked, Us7_Unknown, Us8_InReach, Us8_OutOfReach, Us8_NoTarget, Us9_Strike, Us9_Approach, Us9_Hold, Uh1_Cons, get_environment_variable_1, method2, method3, env_i32_0, env_text_4, disable_client_bot_5, mute_6, closure0, file_exists_8, log_flush_10, write_log_line_9, closure3, typed_c2, format_real_11, player_present_12, live_monster_14, adjacent_from_13, closure5, typed_c4, labelled_15, closure9, closure8, closure7, on_position_change_16, chasing_17, parity_summary_19, method21, method22, method23, forget_dead_20, positioned_monster_25, positions_from_24, scan_sight_26, scan_threats_27, fill_28, outputs_from_29, arena_protection_zone_dy35_36, arena_protection_zone_dy36_37, arena_protection_zone_11_44, arena_protection_zone_10_43, arena_protection_zone_9_42, arena_protection_zone_8_41, arena_protection_zone_7_40, arena_protection_zone_6_39, arena_protection_zone_5_38, arena_protection_zone_4_35, arena_protection_zone_3_34, arena_protection_zone_2_33, arena_protection_zone_1_32, arena_protection_zone_31, footing_of_46, footing_at_45, diagonal_south_50, diagonal_step_49, south_or_west_step_48, step_47, near_from_51, attempt_from_30, adjacent_from_52, rejected_from_53, method55, remember_54, monster_lines_57, method58, monsters_described_56, attacking_described_59, player_zone_60, closure12, ticked_18, closure11, closure10, closure6, closure13, poll_7, closure1, closure14
function Us0_Some(v0) return { tag = "Us0_Some",  _1 = v0 } end
function Us0_None() return { tag = "Us0_None" } end

function Us1_ReachFirst() return { tag = "Us1_ReachFirst" } end
function Us1_CurrentFirst() return { tag = "Us1_CurrentFirst" } end
function Us1_Scored(v0, v1, v2, v3) return { tag = "Us1_Scored",  _1 = v0,  _2 = v1,  _3 = v2,  _4 = v3 } end

Mut0 = function(l0) return { __tag = "Mut0", l0 = l0 } end

Uh0_Nil = (function() local shared = { tag = "Uh0_Nil" } return function() return shared end end)()
function Uh0_Cons(v0, v1, v2) return { tag = "Uh0_Cons",  _1 = v0,  _2 = v1,  _3 = v2 } end

Mut1 = function(l0) return { __tag = "Mut1", l0 = l0 } end

Mut2 = function(l0) return { __tag = "Mut2", l0 = l0 } end

function Us2_Knight() return { tag = "Us2_Knight" } end
function Us2_Target() return { tag = "Us2_Target" } end

function Us3_Some(v0) return { tag = "Us3_Some",  _1 = v0 } end
function Us3_None() return { tag = "Us3_None" } end

function Us4_Some(v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10) return { tag = "Us4_Some",  _1 = v0,  _2 = v1,  _3 = v2,  _4 = v3,  _5 = v4,  _6 = v5,  _7 = v6,  _8 = v7,  _9 = v8,  _10 = v9,  _11 = v10 } end
function Us4_None() return { tag = "Us4_None" } end

function Us5_Some(v0, v1) return { tag = "Us5_Some",  _1 = v0,  _2 = v1 } end
function Us5_None() return { tag = "Us5_None" } end

function Us6_Stepped() return { tag = "Us6_Stepped" } end
function Us6_Gated() return { tag = "Us6_Gated" } end
function Us6_Cornered() return { tag = "Us6_Cornered" } end

function Us7_Free() return { tag = "Us7_Free" } end
function Us7_Ramp() return { tag = "Us7_Ramp" } end
function Us7_Occupied() return { tag = "Us7_Occupied" } end
function Us7_Blocked() return { tag = "Us7_Blocked" } end
function Us7_Unknown() return { tag = "Us7_Unknown" } end

function Us8_InReach() return { tag = "Us8_InReach" } end
function Us8_OutOfReach() return { tag = "Us8_OutOfReach" } end
function Us8_NoTarget() return { tag = "Us8_NoTarget" } end

function Us9_Strike() return { tag = "Us9_Strike" } end
function Us9_Approach() return { tag = "Us9_Approach" } end
function Us9_Hold() return { tag = "Us9_Hold" } end

Uh1_Nil = (function() local shared = { tag = "Uh1_Nil" } return function() return shared end end)()
function Uh1_Cons(v0, v1) return { tag = "Uh1_Cons",  _1 = v0,  _2 = v1 } end

function get_environment_variable_1(v0)
    local v1 = os.getenv(v0) or ""
    return v1
end

function method2(v0, v1, v2)
    local v3 = v2 >= v1
    if v3 then
        return v1
    else
        local v4 = string.sub(v0, (v2)+1, (v2)+1)
        local v5 = v4 == " "
        local getv11 = function()
            if v5 then
                return true
            else
                local v6 = v4 == "\t"
                if v6 then
                    return true
                else
                    local v7 = v4 == "\r"
                    if v7 then
                        return true
                    else
                        local v8 = v4 == "\n"
                        return v8
                    end
                end
            end
        end
        local v11 = getv11()
        if v11 then
            local v12 = spiral_wrap_signed((v2 + 1), 32)
            return method2(v0, v1, v12)
        else
            return v2
        end
    end
end

function method3(v0, v1)
    local v2 = v1 <= 0
    if v2 then
        return -1
    else
        local v3 = spiral_wrap_signed((v1 - 1), 32)
        local v4 = string.sub(v0, (v3)+1, (v3)+1)
        local v5 = v4 == " "
        local getv11 = function()
            if v5 then
                return true
            else
                local v6 = v4 == "\t"
                if v6 then
                    return true
                else
                    local v7 = v4 == "\r"
                    if v7 then
                        return true
                    else
                        local v8 = v4 == "\n"
                        return v8
                    end
                end
            end
        end
        local v11 = getv11()
        if v11 then
            return method3(v0, v3)
        else
            return v3
        end
    end
end

function env_i32_0(v0, v1)
    local v2 = get_environment_variable_1(v0)
    local v3 = string.len(v2)
    local v4 = 0
    local v5 = method2(v2, v3, v4)
    local v6 = spiral_wrap_signed((v3 - 1), 32)
    local v7 = string.sub(v2, (v5)+1, (v6)+1)
    local v8 = string.len(v7)
    local v9 = method3(v7, v8)
    local v10 = string.sub(v7, (0)+1, (v9)+1)
    local v11 = (string.match(v10, "^%s*[+-]?%d+%s*$") ~= nil)
    local v12 = (tonumber(v10) or 0)
    local v13 = (math.modf(v12))
    local getv15 = function()
        if v11 then
            local v14 = v12 >= -2147483648.0
            return v14
        else
            return false
        end
    end
    local v15 = getv15()
    local getv17 = function()
        if v15 then
            local v16 = v12 <= 2147483647.0
            return v16
        else
            return false
        end
    end
    local v17 = getv17()
    local getv20 = function()
        if v17 then
            return Us0_Some(v13)
        else
            return Us0_None()
        end
    end
    local v20 = getv20()
    if v20 ~= nil and v20.tag == "Us0_None" then
        return v1
    elseif v20 ~= nil and v20.tag == "Us0_Some" then
        local v21 = v20._1
        return v21
    end
end

function env_text_4(v0, v1)
    local v2 = get_environment_variable_1(v0)
    local v3 = v2 == ""
    if v3 then
        return v1
    else
        return v2
    end
end

function disable_client_bot_5(v0)
    local v1 = g_settings.getNode("bot")
    local v2 = (v1) ~= nil
    local getv4 = function()
        if v2 then
            return v1
        else
            local v3 = {}
            return v3
        end
    end
    local v4 = getv4()
    do (v4)[v0] = { enabled = false } end
    g_settings.setNode("bot", v4)
    g_settings.save()
    return nil
end

function mute_6()
    g_settings.set("enableAudio", false)
    local v0 = g_sounds ~= nil
    if v0 then
        g_sounds.setAudioEnabled(false)
        g_sounds.stopAll()
        return nil
    else
    end
end

function closure0(capt)
    return function(dom)
        local v0 = "TIBIA_PROBE_HIDDEN"
        local v1 = get_environment_variable_1(v0)
        local v2 = v1 == "1"
        if v2 then
            g_window.move({ x = -32000, y = -32000 })
            g_window.hide()
        else
        end
        return mute_6()
    end
end

function file_exists_8(v0)
    local v1 = "r"
    local v2 = io.open(v0, v1)
    local v3 = (v2) ~= nil
    if v3 then
        do (v2):close() end
        return true
    else
        return false
    end
end

function log_flush_10()
    local v0 = table.concat(TibiaProbeLog, string.char(10))
    local v1 = "\n"
    local v2 = v0 .. v1 
    g_resources.writeFileContents("/tibia-probe.log", v2)
    return nil
end

function write_log_line_9(v0)
    local v1 = TibiaProbeLog == nil
    if v1 then
        TibiaProbeLog = {}
    else
    end
    table.insert(TibiaProbeLog, v0)
    g_logger.info(v0)
    return log_flush_10()
end

function closure3(capt)
    return function(dom)
        g_app.exit()
        return nil
    end
end

function typed_c2(capt)
    return function(v0)
        local v1 = tostring(v0)
        local v2 = "game login error: "
        local v3 = v2 .. v1 
        local v4 = "[tibia-probe] "
        local v5 = v4 .. v3 
        write_log_line_9(v5)
        local v6 = "finish: "
        local v7 = "game login error"
        local v8 = v6 .. v7 
        local v9 = v4 .. v8 
        write_log_line_9(v9)
        local v10 = g_game.isOnline()
        if v10 then
            g_game.safeLogout()
        else
        end
        local v11 = closure3(nil)
        scheduleEvent(v11, 2000)
        return nil
    end
end

function format_real_11(v0)
    local v1 = ""
    local v2 = { __tag = "Mut2", l0 = v1 }
    local v3 = tostring(v0)       
    local v4 = v2 ~= nil and v2.l0
    local v5 = v4 .. v3 
    v2.l0 = v5
    local v6 = v2 ~= nil and v2.l0
    return v6
end

function player_present_12()
    local v0 = g_game.getLocalPlayer() ~= nil
    if v0 then
        local v1 = g_game.isOnline()
        return v1
    else
        return false
    end
end

function live_monster_14(v0)
    local v1 = (v0):isMonster()
    local getv4 = function()
        if v1 then
            local v2 = (v0):isDead()
            local v3 = v2 == false
            return v3
        else
            return false
        end
    end
    local v4 = getv4()
    if v4 then
        local v5 = (v0):getPosition() ~= nil
        return v5
    else
        return false
    end
end

function adjacent_from_13(v0, v1, v2, v3, v4, v5)
    local v6 = #(v3)
    local v7 = v4 > v6
    if v7 then
        return v5
    else
        local v8 = spiral_wrap_signed((v4 + 1), 32)
        local v9 = (v3)[v4]
        local v10 = live_monster_14(v9)
        local getv26 = function()
            if v10 then
                local v11 = (v9):getPosition()
                local v12 = v11.x
                local v13 = v11.y
                local v14 = v11.z
                local v15 = v12 > v0
                local getv18 = function()
                    if v15 then
                        local v16 = spiral_wrap_signed((v12 - v0), 32)
                        return v16
                    else
                        local v17 = spiral_wrap_signed((v0 - v12), 32)
                        return v17
                    end
                end
                local v18 = getv18()
                local v19 = v13 > v1
                local getv22 = function()
                    if v19 then
                        local v20 = spiral_wrap_signed((v13 - v1), 32)
                        return v20
                    else
                        local v21 = spiral_wrap_signed((v1 - v13), 32)
                        return v21
                    end
                end
                local v22 = getv22()
                local v23 = v18 > v22
                local getv24 = function()
                    if v23 then
                        return v18
                    else
                        return v22
                    end
                end
                local v24 = getv24()
                local v25 = v24 <= 1
                return v25
            else
                return false
            end
        end
        local v26 = getv26()
        local getv28 = function()
            if v26 then
                local v27 = spiral_wrap_signed((v5 + 1), 32)
                return v27
            else
                return v5
            end
        end
        local v28 = getv28()
        return adjacent_from_13(v0, v1, v2, v3, v8, v28)
    end
end

function closure5(capt)
    local v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15 = (table.unpack or unpack)(capt)
    return function(v16)
        local v17 = tostring(v15)
        local v18 = tostring(v16)
        local v19 = "due to your"
        local v20 = string.find(v18, v19, 1, true) ~= nil 
        if v20 then
            local v21 = g_clock.millis()
            v6.l0 = v21
        else
        end
        local v22 = g_clock.millis()
        local v23 = v5 ~= nil and v5.l0
        local v24 = spiral_wrap_signed((v22 - v23), 32)
        local v25 = "server text ["
        local v26 = v25 .. v17 
        local v27 = "]: "
        local v28 = v26 .. v27 
        local v29 = v28 .. v18 
        local v30 = " @t+"
        local v31 = v29 .. v30 
        local v32 = format_real_11(v24)
        local v33 = v31 .. v32 
        local v34 = "[tibia-probe] "
        local v35 = v34 .. v33 
        write_log_line_9(v35)
        local v36 = g_game.getLocalPlayer():getSkillLevel(Skill.Shielding)
        local v37 = v7 ~= nil and v7.l0
        local v38 = v36 ~= v37
        if v38 then
            v7.l0 = v36
            local v39 = format_real_11(v36)
            local v40 = "shield skill "
            local v41 = v40 .. v39 
            local v42 = v41 .. v30 
            local v43 = format_real_11(v24)
            local v44 = v42 .. v43 
            local v45 = v34 .. v44 
            write_log_line_9(v45)
        else
        end
        local getv48 = function()
            if v10 then
                local v46 = "due to an attack"
                local v47 = string.find(v18, v46, 1, true) ~= nil 
                return v47
            else
                return false
            end
        end
        local v48 = getv48()
        if v48 then
            local v49 = v12 ~= nil and v12.l0
            local v50 = spiral_wrap_signed((v49 + 1), 32)
            v12.l0 = v50
            local v51 = player_present_12()
            if v51 then
                local v52 = g_game.getLocalPlayer():getPosition()
                local v53 = v52.x
                local v54 = v52.y
                local v55 = v52.z
                local v56 = g_map.getSpectators({ x = v53, y = v54, z = v55 }, false)
                local v57 = 1
                local v58 = 0
                local v59 = adjacent_from_13(v53, v54, v55, v56, v57, v58)
                local v60 = format_real_11(v24)
                local v61 = "hit at "
                local v62 = v61 .. v60 
                local v63 = " ms with "
                local v64 = v62 .. v63 
                local v65 = format_real_11(v59)
                local v66 = v64 .. v65 
                local v67 = " adjacent"
                local v68 = v66 .. v67 
                local v69 = v34 .. v68 
                return write_log_line_9(v69)
            else
            end
        else
        end
    end
end

function typed_c4(capt)
    local v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14 = (table.unpack or unpack)(capt)
    return function(v15)
        return closure5({ v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15 })
    end
end

function labelled_15(v0, v1, v2, v3)
    local v4 = string.len(v1)
    local v5 = v2 >= v4
    if v5 then
        return v3
    else
        local v6 = spiral_wrap_signed((v2 + 1), 32)
        local v7 = string.sub(v1, v6, v6)
        local v8 = string.lower(v7)
        local v9 = v2 > 0
        local getv11 = function()
            if v9 then
                local v10 = v8 ~= v7
                return v10
            else
                return false
            end
        end
        local v11 = getv11()
        local getv13 = function()
            if v11 then
                local v12 = v0 .. v8 
                return v12
            else
                return v8
            end
        end
        local v13 = getv13()
        local v14 = v3 .. v13 
        return labelled_15(v0, v1, v6, v14)
    end
end

function closure9(capt)
    local v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16 = (table.unpack or unpack)(capt)
    return function(v17)
        local v18 = (v16) ~= nil
        local getv20 = function()
            if v18 then
                local v19 = (v17) ~= nil
                return v19
            else
                return false
            end
        end
        local v20 = getv20()
        if v20 then
            local v21 = v5 ~= nil and v5.l0
            local v22 = v21 == 0
            local getv24 = function()
                if v22 then
                    local v23 = (v15):isMonster()
                    return v23
                else
                    return false
                end
            end
            local v24 = getv24()
            if v24 then
                local v25 = v16.x
                local v26 = v16.y
                local v27 = v16.z
                local v28 = (v15):getId()
                local v29 = format_real_11(v28)
                local v30 = "monster "
                local v31 = v30 .. v29 
                local v32 = " moved to "
                local v33 = v31 .. v32 
                local v34 = format_real_11(v25)
                local v35 = v33 .. v34 
                local v36 = ","
                local v37 = v35 .. v36 
                local v38 = format_real_11(v26)
                local v39 = v37 .. v38 
                local v40 = " @login+"
                local v41 = v39 .. v40 
                local v42 = g_clock.millis()
                local v43 = v8 ~= nil and v8.l0
                local v44 = spiral_wrap_signed((v42 - v43), 32)
                local v45 = format_real_11(v44)
                local v46 = v41 .. v45 
                local v47 = "[tibia-probe] "
                local v48 = v47 .. v46 
                return write_log_line_9(v48)
            else
                local v49 = v5 ~= nil and v5.l0
                local v50 = v49 > 0
                if v50 then
                    local v51 = (v15):isLocalPlayer()
                    local getv60 = function()
                        if v51 then
                            local v52 = Us2_Knight()
                            return Us3_Some(v52)
                        else
                            local v54 = g_game.getAttackingCreature()
                            local v55 = (v54) == (v15)
                            if v55 then
                                local v56 = Us2_Target()
                                return Us3_Some(v56)
                            else
                                return Us3_None()
                            end
                        end
                    end
                    local v60 = getv60()
                    if v60 ~= nil and v60.tag == "Us3_None" then
                        return nil
                    elseif v60 ~= nil and v60.tag == "Us3_Some" then
                        local v61 = v60._1
                        
                        
                        local getv62 = function()
                            if v61 ~= nil and v61.tag == "Us2_Knight" then
                                return true
                            else
                                return false
                            end
                        end
                        local v62 = getv62()
                        local getv72 = function()
                            if v62 then
                                local v63 = "_"
                                local v64 = ""
                                local v65 = "Knight"
                                local v66 = v64 == "" or v65:sub(1, #v64) == v64 
                                local getv68 = function()
                                    if v66 then
                                        local v67 = string.sub(v65, 1, 6)
                                        return v67
                                    else
                                        return v65
                                    end
                                end
                                local v68 = getv68()
                                local v69 = 0
                                return labelled_15(v63, v68, v69, v64)
                            else
                                local v71 = ""
                                return v71
                            end
                        end
                        local v72 = getv72()
                        local getv73 = function()
                            if v61 ~= nil and v61.tag == "Us2_Target" then
                                return true
                            else
                                return false
                            end
                        end
                        local v73 = getv73()
                        local getv82 = function()
                            if v73 then
                                local v74 = "_"
                                local v75 = ""
                                local v76 = "Target"
                                local v77 = v75 == "" or v76:sub(1, #v75) == v75 
                                local getv79 = function()
                                    if v77 then
                                        local v78 = string.sub(v76, 1, 6)
                                        return v78
                                    else
                                        return v76
                                    end
                                end
                                local v79 = getv79()
                                local v80 = 0
                                return labelled_15(v74, v79, v80, v75)
                            else
                                return v72
                            end
                        end
                        local v82 = getv82()
                        local v83 = v16.x
                        local v84 = v16.y
                        local v85 = v16.z
                        local v86 = " moved to "
                        local v87 = v82 .. v86 
                        local v88 = format_real_11(v83)
                        local v89 = v87 .. v88 
                        local v90 = ","
                        local v91 = v89 .. v90 
                        local v92 = format_real_11(v84)
                        local v93 = v91 .. v92 
                        local v94 = " @t+"
                        local v95 = v93 .. v94 
                        local v96 = g_clock.millis()
                        local v97 = v5 ~= nil and v5.l0
                        local v98 = spiral_wrap_signed((v96 - v97), 32)
                        local v99 = format_real_11(v98)
                        local v100 = v95 .. v99 
                        local v101 = "[tibia-probe] "
                        local v102 = v101 .. v100 
                        return write_log_line_9(v102)
                    end
                else
                end
            end
        else
        end
    end
end

function closure8(capt)
    local v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15 = (table.unpack or unpack)(capt)
    return function(v16)
        return closure9({ v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16 })
    end
end

function closure7(capt)
    local v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14 = (table.unpack or unpack)(capt)
    return function(v15)
        return closure8({ v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15 })
    end
end

function on_position_change_16(v0)
    local v1 = function(c, n, o) (v0)(c)(n)(o) end
    connect(Creature, { onPositionChange = v1 })
    connect(LocalPlayer, { onPositionChange = v1 })
    return nil
end

function chasing_17(v0)
    local getv3 = function()
        if v0 then
            local v1 = ChaseOpponent
            return v1
        else
            local v2 = DontChase
            return v2
        end
    end
    local v3 = getv3()
    local v4 = g_game.getChaseMode()
    local v5 = v4 ~= v3
    if v5 then
        g_game.setChaseMode(v3)
        return nil
    else
    end
end

function parity_summary_19()
    local v0 = ArenaParity ~= nil
    if v0 then
        local v1 = ArenaParity.summary()
        return v1
    else
        local v2 = ""
        return v2
    end
end

function method21(v0, v1)
    if v0 ~= nil and v0.tag == "Uh0_Cons" then
        local v2 = v0._1
        local v3 = v0._2
        local v4 = v0._3
        local v5 = method21(v4, v1)
        local v6 = (v3):isDead()
        if v6 then
            return Uh0_Cons(v2, v3, v5)
        else
            return v5
        end
    elseif v0 ~= nil and v0.tag == "Uh0_Nil" then
        return v1
    end
end

function method22(v0, v1)
    if v0 ~= nil and v0.tag == "Uh0_Cons" then
        local v2 = v0._1
        local v3 = v0._2
        local v4 = v0._3
        local v5 = method22(v4, v1)
        local v6 = (v3):isDead()
        local v7 = v6 == false
        if v7 then
            return Uh0_Cons(v2, v3, v5)
        else
            return v5
        end
    elseif v0 ~= nil and v0.tag == "Uh0_Nil" then
        return v1
    end
end

function method23(v0, v1)
    if v0 ~= nil and v0.tag == "Uh0_Cons" then
        local v2 = v0._1
        local v3 = v0._2
        local v4 = v0._3
        local v5 = spiral_wrap_signed((v1 + 1), 32)
        return method23(v4, v5)
    elseif v0 ~= nil and v0.tag == "Uh0_Nil" then
        return v1
    end
end

function forget_dead_20(v0)
    local v1 = v0 ~= nil and v0.l0
    local v2 = Uh0_Nil()
    local v3 = method21(v1, v2)
    local v4 = v0 ~= nil and v0.l0
    local v5 = Uh0_Nil()
    local v6 = method22(v4, v5)
    v0.l0 = v6
    local v7 = 0
    return method23(v3, v7)
end

function positioned_monster_25(v0)
    local v1 = (v0):isMonster()
    if v1 then
        local v2 = (v0):getPosition() ~= nil
        return v2
    else
        return false
    end
end

function positions_from_24(v0, v1, v2)
    local v3 = #(v0)
    local v4 = v1 > v3
    if v4 then
        return v2
    else
        local v5 = spiral_wrap_signed((v1 + 1), 32)
        local v6 = (v0)[v1]
        local v7 = positioned_monster_25(v6)
        local getv27 = function()
            if v7 then
                local v8 = (v6):getPosition()
                local v9 = v8.x
                local v10 = v8.y
                local v11 = v8.z
                local v12 = format_real_11(v9)
                local v13 = ""
                local v14 = v13 .. v12 
                local v15 = ","
                local v16 = v14 .. v15 
                local v17 = format_real_11(v10)
                local v18 = v16 .. v17 
                local v19 = v18 .. v15 
                local v20 = format_real_11(v11)
                local v21 = v19 .. v20 
                local v22 = v2 == ""
                if v22 then
                    return v21
                else
                    local v23 = " "
                    local v24 = v2 .. v23 
                    local v25 = v24 .. v21 
                    return v25
                end
            else
                return v2
            end
        end
        local v27 = getv27()
        return positions_from_24(v0, v5, v27)
    end
end

function scan_sight_26(v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21)
    local v22 = #(v18)
    local v23 = v20 > v22
    if v23 then
        return v21
    else
        local v24 = spiral_wrap_signed((v20 + 1), 32)
        local v25 = (v18)[v20]
        local v26 = live_monster_14(v25)
        local getv104 = function()
            if v26 then
                local v27 = (v25):getPosition()
                local v28 = v27.x
                local v29 = v27.y
                local v30 = v27.z
                local v31 = v28 > v15
                local getv34 = function()
                    if v31 then
                        local v32 = spiral_wrap_signed((v28 - v15), 32)
                        return v32
                    else
                        local v33 = spiral_wrap_signed((v15 - v28), 32)
                        return v33
                    end
                end
                local v34 = getv34()
                local v35 = v29 > v16
                local getv38 = function()
                    if v35 then
                        local v36 = spiral_wrap_signed((v29 - v16), 32)
                        return v36
                    else
                        local v37 = spiral_wrap_signed((v16 - v29), 32)
                        return v37
                    end
                end
                local v38 = getv38()
                local v39 = v34 > v38
                local getv40 = function()
                    if v39 then
                        return v34
                    else
                        return v38
                    end
                end
                local v40 = getv40()
                local getv101 = function()
                    if v21 ~= nil and v21.tag == "Us5_None" then
                        return true
                    elseif v21 ~= nil and v21.tag == "Us5_Some" then
                        local v41 = v21._1
                        local v42 = v21._2
                        local v43 = (v25) == (v19)
                        local v44 = (v25):getHealthPercent()
                        local v45 = (v18)[v41]
                        local v46 = (v45) == (v19)
                        local v47 = (v45):getHealthPercent()
                        if v4 ~= nil and v4.tag == "Us1_CurrentFirst" then
                            local v58 = v43 ~= v46
                            if v58 then
                                return v43
                            else
                                local v59 = v40 <= 1
                                local v60 = v42 <= 1
                                local v61 = v59 ~= v60
                                if v61 then
                                    return v59
                                else
                                    local v62 = v44 ~= v47
                                    if v62 then
                                        local v63 = v44 < v47
                                        return v63
                                    else
                                        local v64 = v40 < v42
                                        return v64
                                    end
                                end
                            end
                        elseif v4 ~= nil and v4.tag == "Us1_ReachFirst" then
                            local v48 = v40 <= 1
                            local v49 = v42 <= 1
                            local v50 = v48 ~= v49
                            if v50 then
                                return v48
                            else
                                local v51 = v43 ~= v46
                                if v51 then
                                    return v43
                                else
                                    local v52 = v44 ~= v47
                                    if v52 then
                                        local v53 = v44 < v47
                                        return v53
                                    else
                                        local v54 = v40 < v42
                                        return v54
                                    end
                                end
                            end
                        elseif v4 ~= nil and v4.tag == "Us1_Scored" then
                            local v68 = v4._1
                            local v69 = v4._2
                            local v70 = v4._3
                            local v71 = v4._4
                            local getv72 = function()
                                if v43 then
                                    return v68
                                else
                                    return 0
                                end
                            end
                            local v72 = getv72()
                            local v73 = v40 <= 1
                            local getv74 = function()
                                if v73 then
                                    return v69
                                else
                                    return 0
                                end
                            end
                            local v74 = getv74()
                            local v75 = spiral_wrap_signed((v72 + v74), 32)
                            local v76 = spiral_wrap_signed(spiral_mul_mod32(v70, v44), 32)
                            local v77 = (math.modf(v76 / 100))
                            local v78 = spiral_wrap_signed((v75 + v77), 32)
                            local v79 = spiral_wrap_signed(spiral_mul_mod32(v71, v40), 32)
                            local v80 = spiral_wrap_signed((v78 + v79), 32)
                            local getv81 = function()
                                if v46 then
                                    return v68
                                else
                                    return 0
                                end
                            end
                            local v81 = getv81()
                            local v82 = v42 <= 1
                            local getv83 = function()
                                if v82 then
                                    return v69
                                else
                                    return 0
                                end
                            end
                            local v83 = getv83()
                            local v84 = spiral_wrap_signed((v81 + v83), 32)
                            local v85 = spiral_wrap_signed(spiral_mul_mod32(v70, v47), 32)
                            local v86 = (math.modf(v85 / 100))
                            local v87 = spiral_wrap_signed((v84 + v86), 32)
                            local v88 = spiral_wrap_signed(spiral_mul_mod32(v71, v42), 32)
                            local v89 = spiral_wrap_signed((v87 + v88), 32)
                            local v90 = v80 ~= v89
                            if v90 then
                                local v91 = v80 > v89
                                return v91
                            else
                                local v92 = v44 ~= v47
                                if v92 then
                                    local v93 = v44 < v47
                                    return v93
                                else
                                    local v94 = v40 < v42
                                    return v94
                                end
                            end
                        end
                    end
                end
                local v101 = getv101()
                if v101 then
                    return Us5_Some(v20, v40)
                else
                    return v21
                end
            else
                return v21
            end
        end
        local v104 = getv104()
        return scan_sight_26(v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v24, v104)
    end
end

function scan_threats_27(v0, v1, v2, v3, v4, v5, v6)
    local v7 = #(v3)
    local v8 = v4 > v7
    local getv52 = function()
        if v8 then
            return { [1]=v5, [2]=v6 }
        else
            local v9 = spiral_wrap_signed((v4 + 1), 32)
            local v10 = (v3)[v4]
            local v11 = live_monster_14(v10)
            local getv27 = function()
                if v11 then
                    local v12 = (v10):getPosition()
                    local v13 = v12.x
                    local v14 = v12.y
                    local v15 = v12.z
                    local v16 = v13 > v0
                    local getv19 = function()
                        if v16 then
                            local v17 = spiral_wrap_signed((v13 - v0), 32)
                            return v17
                        else
                            local v18 = spiral_wrap_signed((v0 - v13), 32)
                            return v18
                        end
                    end
                    local v19 = getv19()
                    local v20 = v14 > v1
                    local getv23 = function()
                        if v20 then
                            local v21 = spiral_wrap_signed((v14 - v1), 32)
                            return v21
                        else
                            local v22 = spiral_wrap_signed((v1 - v14), 32)
                            return v22
                        end
                    end
                    local v23 = getv23()
                    local v24 = v19 > v23
                    local getv25 = function()
                        if v24 then
                            return v19
                        else
                            return v23
                        end
                    end
                    local v25 = getv25()
                    local v26 = v25 <= 1
                    return v26
                else
                    return false
                end
            end
            local v27 = getv27()
            local getv48 = function()
                if v27 then
                    local v28 = spiral_wrap_signed((v5 + 1), 32)
                    local getv45 = function()
                        if v6 ~= nil and v6.tag == "Us0_None" then
                            return true
                        elseif v6 ~= nil and v6.tag == "Us0_Some" then
                            local v29 = v6._1
                            local v30 = (v10):getPosition()
                            local v31 = v30.x
                            local v32 = v30.y
                            local v33 = v30.z
                            local v34 = spiral_wrap_signed(spiral_mul_mod32(v31, 100000), 32)
                            local v35 = spiral_wrap_signed((v34 + v32), 32)
                            local v36 = (v3)[v29]
                            local v37 = (v36):getPosition()
                            local v38 = v37.x
                            local v39 = v37.y
                            local v40 = v37.z
                            local v41 = spiral_wrap_signed(spiral_mul_mod32(v38, 100000), 32)
                            local v42 = spiral_wrap_signed((v41 + v39), 32)
                            local v43 = v35 < v42
                            return v43
                        end
                    end
                    local v45 = getv45()
                    local getv47 = function()
                        if v45 then
                            return Us0_Some(v4)
                        else
                            return v6
                        end
                    end
                    local v47 = getv47()
                    return { [1]=v28, [2]=v47 }
                else
                    return { [1]=v5, [2]=v6 }
                end
            end
            local v48, v49 = (table.unpack or unpack)(getv48())
            local v50, v51 = (table.unpack or unpack)(scan_threats_27(v0, v1, v2, v3, v9, v48, v49))
            return { [1]=v50, [2]=v51 }
        end
    end
    local v52, v53 = (table.unpack or unpack)(getv52())
    return { [1]=v52, [2]=v53 }
end

function fill_28(v0, v1)
    local v2 = v1 < 66
    if v2 then
        v0[(v1)+1] = 0
        local v3 = spiral_wrap_signed((v1 + 1), 32)
        return fill_28(v0, v3)
    else
    end
end

function outputs_from_29(v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11)
    local v12 = v8 >= 6
    local getv73 = function()
        if v12 then
            local v13 = (math.modf(v9 / 256))
            local v14 = (math.modf(v10 / 256))
            local v15 = (math.modf(v11 / 256))
            local v16 = v13 > 0
            local v17 = v14 > 0
            local getv19 = function()
                if v17 then
                    local v18 = v14 >= v15
                    return v18
                else
                    return false
                end
            end
            local v19 = getv19()
            local v20 = v15 > 0
            local getv22 = function()
                if v20 then
                    local v21 = v15 > v14
                    return v21
                else
                    return false
                end
            end
            local v22 = getv22()
            return { [1]=v16, [2]=v19, [3]=v22 }
        else
            local v23 = spiral_wrap_signed(spiral_mul_mod32(v8, 8), 32)
            local v24 = (v0)[(v23)+1]
            local v25 = spiral_wrap_signed(spiral_mul_mod32(v24, v1), 32)
            local v26 = spiral_wrap_signed((v23 + 1), 32)
            local v27 = (v0)[(v26)+1]
            local v28 = spiral_wrap_signed(spiral_mul_mod32(v27, v2), 32)
            local v29 = spiral_wrap_signed((v25 + v28), 32)
            local v30 = spiral_wrap_signed((v23 + 2), 32)
            local v31 = (v0)[(v30)+1]
            local v32 = spiral_wrap_signed(spiral_mul_mod32(v31, v3), 32)
            local v33 = spiral_wrap_signed((v29 + v32), 32)
            local v34 = spiral_wrap_signed((v23 + 3), 32)
            local v35 = (v0)[(v34)+1]
            local v36 = spiral_wrap_signed(spiral_mul_mod32(v35, v4), 32)
            local v37 = spiral_wrap_signed((v33 + v36), 32)
            local v38 = spiral_wrap_signed((v23 + 4), 32)
            local v39 = (v0)[(v38)+1]
            local v40 = spiral_wrap_signed(spiral_mul_mod32(v39, v5), 32)
            local v41 = spiral_wrap_signed((v23 + 5), 32)
            local v42 = (v0)[(v41)+1]
            local v43 = spiral_wrap_signed(spiral_mul_mod32(v42, v6), 32)
            local v44 = spiral_wrap_signed((v40 + v43), 32)
            local v45 = spiral_wrap_signed((v23 + 6), 32)
            local v46 = (v0)[(v45)+1]
            local v47 = spiral_wrap_signed(spiral_mul_mod32(v46, v7), 32)
            local v48 = spiral_wrap_signed((v44 + v47), 32)
            local v49 = spiral_wrap_signed((v23 + 7), 32)
            local v50 = (v0)[(v49)+1]
            local v51 = spiral_wrap_signed(spiral_mul_mod32(v50, 256), 32)
            local v52 = spiral_wrap_signed((v48 + v51), 32)
            local v53 = spiral_wrap_signed((v37 + v52), 32)
            local v54 = (math.modf(v53 / 256))
            local v55 = v54 > 0
            local getv56 = function()
                if v55 then
                    return v54
                else
                    return 0
                end
            end
            local v56 = getv56()
            local v57 = spiral_wrap_signed((v8 + 1), 32)
            local v58 = spiral_wrap_signed((48 + v8), 32)
            local v59 = (v0)[(v58)+1]
            local v60 = spiral_wrap_signed(spiral_mul_mod32(v59, v56), 32)
            local v61 = spiral_wrap_signed((v9 + v60), 32)
            local v62 = spiral_wrap_signed((54 + v8), 32)
            local v63 = (v0)[(v62)+1]
            local v64 = spiral_wrap_signed(spiral_mul_mod32(v63, v56), 32)
            local v65 = spiral_wrap_signed((v10 + v64), 32)
            local v66 = spiral_wrap_signed((60 + v8), 32)
            local v67 = (v0)[(v66)+1]
            local v68 = spiral_wrap_signed(spiral_mul_mod32(v67, v56), 32)
            local v69 = spiral_wrap_signed((v11 + v68), 32)
            local v70, v71, v72 = (table.unpack or unpack)(outputs_from_29(v0, v1, v2, v3, v4, v5, v6, v7, v57, v61, v65, v69))
            return { [1]=v70, [2]=v71, [3]=v72 }
        end
    end
    local v73, v74, v75 = (table.unpack or unpack)(getv73())
    return { [1]=v73, [2]=v74, [3]=v75 }
end

function arena_protection_zone_dy35_36(v0)
    local v1 = v0 >= 7
    local getv3 = function()
        if v1 then
            local v2 = v0 <= 14
            return v2
        else
            return false
        end
    end
    local v3 = getv3()
    local getv7 = function()
        if v3 then
            return true
        else
            local v4 = v0 >= 21
            if v4 then
                local v5 = v0 <= 23
                return v5
            else
                return false
            end
        end
    end
    local v7 = getv7()
    local getv11 = function()
        if v7 then
            return true
        else
            local v8 = v0 >= 25
            if v8 then
                local v9 = v0 <= 27
                return v9
            else
                return false
            end
        end
    end
    local v11 = getv11()
    local getv15 = function()
        if v11 then
            return true
        else
            local v12 = v0 >= 29
            if v12 then
                local v13 = v0 <= 31
                return v13
            else
                return false
            end
        end
    end
    local v15 = getv15()
    if v15 then
        return true
    else
        local v16 = v0 >= 33
        if v16 then
            local v17 = v0 <= 40
            return v17
        else
            return false
        end
    end
end

function arena_protection_zone_dy36_37(v0)
    local v1 = v0 >= 7
    local getv3 = function()
        if v1 then
            local v2 = v0 <= 14
            return v2
        else
            return false
        end
    end
    local v3 = getv3()
    local getv7 = function()
        if v3 then
            return true
        else
            local v4 = v0 >= 21
            if v4 then
                local v5 = v0 <= 23
                return v5
            else
                return false
            end
        end
    end
    local v7 = getv7()
    local getv11 = function()
        if v7 then
            return true
        else
            local v8 = v0 >= 25
            if v8 then
                local v9 = v0 <= 27
                return v9
            else
                return false
            end
        end
    end
    local v11 = getv11()
    local getv15 = function()
        if v11 then
            return true
        else
            local v12 = v0 >= 29
            if v12 then
                local v13 = v0 <= 31
                return v13
            else
                return false
            end
        end
    end
    local v15 = getv15()
    if v15 then
        return true
    else
        local v16 = v0 >= 33
        if v16 then
            local v17 = v0 <= 40
            return v17
        else
            return false
        end
    end
end

function arena_protection_zone_11_44(v0, v1)
    local v2 = v1 == 5
    if v2 then
        local v3 = v0 >= 33
        if v3 then
            local v4 = v0 <= 40
            return v4
        else
            return false
        end
    else
        return false
    end
end

function arena_protection_zone_10_43(v0, v1)
    local v2 = v1 == 2
    if v2 then
        local v3 = v0 >= 33
        if v3 then
            local v4 = v0 <= 40
            return v4
        else
            return false
        end
    else
        local v6 = v1 == 3
        if v6 then
            local v7 = v0 >= 33
            if v7 then
                local v8 = v0 <= 40
                return v8
            else
                return false
            end
        else
            local v10 = v1 == 4
            if v10 then
                local v11 = v0 >= 33
                if v11 then
                    local v12 = v0 <= 40
                    return v12
                else
                    return false
                end
            else
                return arena_protection_zone_11_44(v0, v1)
            end
        end
    end
end

function arena_protection_zone_9_42(v0, v1)
    local v2 = v1 == 0
    if v2 then
        local v3 = v0 >= 7
        local getv5 = function()
            if v3 then
                local v4 = v0 <= 14
                return v4
            else
                return false
            end
        end
        local v5 = getv5()
        if v5 then
            return true
        else
            local v6 = v0 >= 21
            if v6 then
                local v7 = v0 <= 40
                return v7
            else
                return false
            end
        end
    else
        local v10 = v1 == 1
        if v10 then
            local v11 = v0 >= 8
            local getv13 = function()
                if v11 then
                    local v12 = v0 <= 14
                    return v12
                else
                    return false
                end
            end
            local v13 = getv13()
            if v13 then
                return true
            else
                local v14 = v0 >= 33
                if v14 then
                    local v15 = v0 <= 40
                    return v15
                else
                    return false
                end
            end
        else
            return arena_protection_zone_10_43(v0, v1)
        end
    end
end

function arena_protection_zone_8_41(v0, v1)
    local v2 = v1 == -2
    if v2 then
        local v3 = v0 >= 7
        local getv5 = function()
            if v3 then
                local v4 = v0 <= 14
                return v4
            else
                return false
            end
        end
        local v5 = getv5()
        if v5 then
            return true
        else
            local v6 = v0 >= 21
            if v6 then
                local v7 = v0 <= 40
                return v7
            else
                return false
            end
        end
    else
        local v10 = v1 == -1
        if v10 then
            local v11 = v0 >= 7
            local getv13 = function()
                if v11 then
                    local v12 = v0 <= 14
                    return v12
                else
                    return false
                end
            end
            local v13 = getv13()
            if v13 then
                return true
            else
                local v14 = v0 >= 21
                if v14 then
                    local v15 = v0 <= 40
                    return v15
                else
                    return false
                end
            end
        else
            return arena_protection_zone_9_42(v0, v1)
        end
    end
end

function arena_protection_zone_7_40(v0, v1)
    local v2 = v1 == -4
    if v2 then
        local v3 = v0 >= 7
        local getv5 = function()
            if v3 then
                local v4 = v0 <= 14
                return v4
            else
                return false
            end
        end
        local v5 = getv5()
        if v5 then
            return true
        else
            local v6 = v0 >= 21
            if v6 then
                local v7 = v0 <= 40
                return v7
            else
                return false
            end
        end
    else
        local v10 = v1 == -3
        if v10 then
            local v11 = v0 >= 7
            local getv13 = function()
                if v11 then
                    local v12 = v0 <= 14
                    return v12
                else
                    return false
                end
            end
            local v13 = getv13()
            if v13 then
                return true
            else
                local v14 = v0 >= 21
                if v14 then
                    local v15 = v0 <= 40
                    return v15
                else
                    return false
                end
            end
        else
            return arena_protection_zone_8_41(v0, v1)
        end
    end
end

function arena_protection_zone_6_39(v0, v1)
    local v2 = v1 == -6
    if v2 then
        local v3 = v0 >= 7
        local getv5 = function()
            if v3 then
                local v4 = v0 <= 14
                return v4
            else
                return false
            end
        end
        local v5 = getv5()
        if v5 then
            return true
        else
            local v6 = v0 >= 21
            if v6 then
                local v7 = v0 <= 40
                return v7
            else
                return false
            end
        end
    else
        local v10 = v1 == -5
        if v10 then
            local v11 = v0 >= 7
            local getv13 = function()
                if v11 then
                    local v12 = v0 <= 14
                    return v12
                else
                    return false
                end
            end
            local v13 = getv13()
            if v13 then
                return true
            else
                local v14 = v0 >= 21
                if v14 then
                    local v15 = v0 <= 40
                    return v15
                else
                    return false
                end
            end
        else
            return arena_protection_zone_7_40(v0, v1)
        end
    end
end

function arena_protection_zone_5_38(v0, v1)
    local v2 = v1 == -8
    if v2 then
        local v3 = v0 >= 7
        local getv5 = function()
            if v3 then
                local v4 = v0 <= 14
                return v4
            else
                return false
            end
        end
        local v5 = getv5()
        if v5 then
            return true
        else
            local v6 = v0 >= 21
            if v6 then
                local v7 = v0 <= 40
                return v7
            else
                return false
            end
        end
    else
        local v10 = v1 == -7
        if v10 then
            local v11 = v0 >= 7
            local getv13 = function()
                if v11 then
                    local v12 = v0 <= 14
                    return v12
                else
                    return false
                end
            end
            local v13 = getv13()
            if v13 then
                return true
            else
                local v14 = v0 >= 21
                if v14 then
                    local v15 = v0 <= 40
                    return v15
                else
                    return false
                end
            end
        else
            return arena_protection_zone_6_39(v0, v1)
        end
    end
end

function arena_protection_zone_4_35(v0, v1)
    local v2 = v1 == -10
    if v2 then
        return arena_protection_zone_dy35_36(v0)
    else
        local v4 = v1 == -9
        if v4 then
            return arena_protection_zone_dy36_37(v0)
        else
            return arena_protection_zone_5_38(v0, v1)
        end
    end
end

function arena_protection_zone_3_34(v0, v1)
    local v2 = v1 == -20
    if v2 then
        local v3 = v0 >= 38
        if v3 then
            local v4 = v0 <= 45
            return v4
        else
            return false
        end
    else
        local v6 = v1 == -19
        if v6 then
            local v7 = v0 >= 38
            if v7 then
                local v8 = v0 <= 45
                return v8
            else
                return false
            end
        else
            local v10 = v1 == -18
            if v10 then
                local v11 = v0 >= 38
                if v11 then
                    local v12 = v0 <= 45
                    return v12
                else
                    return false
                end
            else
                return arena_protection_zone_4_35(v0, v1)
            end
        end
    end
end

function arena_protection_zone_2_33(v0, v1)
    local v2 = v1 == -23
    if v2 then
        local v3 = v0 >= 41
        if v3 then
            local v4 = v0 <= 45
            return v4
        else
            return false
        end
    else
        local v6 = v1 == -22
        if v6 then
            local v7 = v0 >= 41
            if v7 then
                local v8 = v0 <= 45
                return v8
            else
                return false
            end
        else
            local v10 = v1 == -21
            if v10 then
                local v11 = v0 >= 38
                if v11 then
                    local v12 = v0 <= 45
                    return v12
                else
                    return false
                end
            else
                return arena_protection_zone_3_34(v0, v1)
            end
        end
    end
end

function arena_protection_zone_1_32(v0, v1)
    local v2 = v1 == -26
    if v2 then
        local v3 = v0 >= 41
        if v3 then
            local v4 = v0 <= 45
            return v4
        else
            return false
        end
    else
        local v6 = v1 == -25
        if v6 then
            local v7 = v0 >= 41
            if v7 then
                local v8 = v0 <= 45
                return v8
            else
                return false
            end
        else
            local v10 = v1 == -24
            if v10 then
                local v11 = v0 >= 41
                if v11 then
                    local v12 = v0 <= 45
                    return v12
                else
                    return false
                end
            else
                return arena_protection_zone_2_33(v0, v1)
            end
        end
    end
end

function arena_protection_zone_31(v0, v1)
    local v2 = v1 == -29
    if v2 then
        local v3 = v0 >= 41
        local getv5 = function()
            if v3 then
                local v4 = v0 <= 43
                return v4
            else
                return false
            end
        end
        local v5 = getv5()
        if v5 then
            return true
        else
            local v6 = v0 == 45
            return v6
        end
    else
        local v8 = v1 == -28
        if v8 then
            local v9 = v0 >= 41
            local getv11 = function()
                if v9 then
                    local v10 = v0 <= 43
                    return v10
                else
                    return false
                end
            end
            local v11 = getv11()
            if v11 then
                return true
            else
                local v12 = v0 == 45
                return v12
            end
        else
            local v14 = v1 == -27
            if v14 then
                local v15 = v0 >= 40
                if v15 then
                    local v16 = v0 <= 45
                    return v16
                else
                    return false
                end
            else
                return arena_protection_zone_1_32(v0, v1)
            end
        end
    end
end

function footing_of_46(v0, v1, v2, v3)
    local v4 = v0 == false
    if v4 then
        return Us7_Unknown()
    else
        local getv7 = function()
            if v1 then
                local v6 = v2 == false
                return v6
            else
                return false
            end
        end
        local v7 = getv7()
        if v7 then
            return Us7_Free()
        else
            if v1 then
                return Us7_Ramp()
            else
                if v3 then
                    return Us7_Occupied()
                else
                    return Us7_Blocked()
                end
            end
        end
    end
end

function footing_at_45(v0, v1, v2)
    local v3 = g_map.getTile({ x = v0, y = v1, z = v2 })
    local v4 = (v3) ~= nil
    if v4 then
        local v5 = true
        local v6 = (v3):isWalkable()
        local v7 = (v3):hasFloorChange()
        local v8 = (v3):isWalkable(true)
        return footing_of_46(v5, v6, v7, v8)
    else
        return Us7_Unknown()
    end
end

function diagonal_south_50(v0, v1)
    local v2 = v0 == 1
    local getv4 = function()
        if v2 then
            local v3 = v1 == 1
            return v3
        else
            return false
        end
    end
    local v4 = getv4()
    if v4 then
        local v5 = SouthEast
        local v6 = g_game.walk(v5) ~= false
        return v6
    else
        local v7 = v0 == -1
        local getv9 = function()
            if v7 then
                local v8 = v1 == 1
                return v8
            else
                return false
            end
        end
        local v9 = getv9()
        if v9 then
            local v10 = SouthWest
            local v11 = g_game.walk(v10) ~= false
            return v11
        else
            return false
        end
    end
end

function diagonal_step_49(v0, v1)
    local v2 = v0 == 1
    local getv4 = function()
        if v2 then
            local v3 = v1 == -1
            return v3
        else
            return false
        end
    end
    local v4 = getv4()
    if v4 then
        local v5 = NorthEast
        local v6 = g_game.walk(v5) ~= false
        return v6
    else
        local v7 = v0 == -1
        local getv9 = function()
            if v7 then
                local v8 = v1 == -1
                return v8
            else
                return false
            end
        end
        local v9 = getv9()
        if v9 then
            local v10 = NorthWest
            local v11 = g_game.walk(v10) ~= false
            return v11
        else
            return diagonal_south_50(v0, v1)
        end
    end
end

function south_or_west_step_48(v0, v1)
    local v2 = v0 == 0
    local getv4 = function()
        if v2 then
            local v3 = v1 == 1
            return v3
        else
            return false
        end
    end
    local v4 = getv4()
    if v4 then
        local v5 = South
        local v6 = g_game.walk(v5) ~= false
        return v6
    else
        local v7 = v0 == -1
        local getv9 = function()
            if v7 then
                local v8 = v1 == 0
                return v8
            else
                return false
            end
        end
        local v9 = getv9()
        if v9 then
            local v10 = West
            local v11 = g_game.walk(v10) ~= false
            return v11
        else
            return diagonal_step_49(v0, v1)
        end
    end
end

function step_47(v0, v1)
    local v2 = v0 == 0
    local getv4 = function()
        if v2 then
            local v3 = v1 == -1
            return v3
        else
            return false
        end
    end
    local v4 = getv4()
    if v4 then
        local v5 = North
        local v6 = g_game.walk(v5) ~= false
        return v6
    else
        local v7 = v0 == 1
        local getv9 = function()
            if v7 then
                local v8 = v1 == 0
                return v8
            else
                return false
            end
        end
        local v9 = getv9()
        if v9 then
            local v10 = East
            local v11 = g_game.walk(v10) ~= false
            return v11
        else
            return south_or_west_step_48(v0, v1)
        end
    end
end

function near_from_51(v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26)
    local v27 = #(v21)
    local v28 = v25 > v27
    if v28 then
        return v26
    else
        local v29 = spiral_wrap_signed((v25 + 1), 32)
        local v30 = (v21)[v25]
        local v31 = live_monster_14(v30)
        local getv47 = function()
            if v31 then
                local v32 = (v30):getPosition()
                local v33 = v32.x
                local v34 = v32.y
                local v35 = v32.z
                local v36 = v33 > v15
                local getv39 = function()
                    if v36 then
                        local v37 = spiral_wrap_signed((v33 - v15), 32)
                        return v37
                    else
                        local v38 = spiral_wrap_signed((v15 - v33), 32)
                        return v38
                    end
                end
                local v39 = getv39()
                local v40 = v34 > v16
                local getv43 = function()
                    if v40 then
                        local v41 = spiral_wrap_signed((v34 - v16), 32)
                        return v41
                    else
                        local v42 = spiral_wrap_signed((v16 - v34), 32)
                        return v42
                    end
                end
                local v43 = getv43()
                local v44 = v39 > v43
                local getv45 = function()
                    if v44 then
                        return v39
                    else
                        return v43
                    end
                end
                local v45 = getv45()
                local v46 = v45 <= 2
                return v46
            else
                return false
            end
        end
        local v47 = getv47()
        local getv67 = function()
            if v47 then
                local v48 = (v30):getPosition()
                local v49 = v48.x
                local v50 = v48.y
                local v51 = v48.z
                local v52 = format_real_11(v49)
                local v53 = ""
                local v54 = v53 .. v52 
                local v55 = ","
                local v56 = v54 .. v55 
                local v57 = format_real_11(v50)
                local v58 = v56 .. v57 
                local v59 = v58 .. v55 
                local v60 = format_real_11(v51)
                local v61 = v59 .. v60 
                local v62 = v26 == ""
                if v62 then
                    return v61
                else
                    local v63 = " "
                    local v64 = v26 .. v63 
                    local v65 = v64 .. v61 
                    return v65
                end
            else
                return v26
            end
        end
        local v67 = getv67()
        return near_from_51(v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v29, v67)
    end
end

function attempt_from_30(v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25)
    local v26 = v25 >= 7
    if v26 then
        local v27 = Us6_Cornered()
        return { [1]=v27, [2]=0 }
    else
        local v28 = v25 == 0
        local getv53 = function()
            if v28 then
                return { [1]=v22, [2]=v23, [3]=true }
            else
                local v29 = v25 == 1
                local getv50 = function()
                    if v29 then
                        return { [1]=v22, [2]=0, [3]=true }
                    else
                        local v30 = v25 == 2
                        local getv47 = function()
                            if v30 then
                                return { [1]=0, [2]=v23, [3]=true }
                            else
                                local v31 = v25 <= 4
                                local getv44 = function()
                                    if v31 then
                                        local v32 = v25 == 3
                                        local getv35 = function()
                                            if v32 then
                                                local v33 = v22 == 0
                                                return { [1]=1, [2]=v23, [3]=v33 }
                                            else
                                                local v34 = v22 == 0
                                                return { [1]=-1, [2]=v23, [3]=v34 }
                                            end
                                        end
                                        local v35, v36, v37 = (table.unpack or unpack)(getv35())
                                        return { [1]=v35, [2]=v36, [3]=v37 }
                                    else
                                        local v38 = v25 == 5
                                        local getv41 = function()
                                            if v38 then
                                                local v39 = v23 == 0
                                                return { [1]=v22, [2]=1, [3]=v39 }
                                            else
                                                local v40 = v23 == 0
                                                return { [1]=v22, [2]=-1, [3]=v40 }
                                            end
                                        end
                                        local v41, v42, v43 = (table.unpack or unpack)(getv41())
                                        return { [1]=v41, [2]=v42, [3]=v43 }
                                    end
                                end
                                local v44, v45, v46 = (table.unpack or unpack)(getv44())
                                return { [1]=v44, [2]=v45, [3]=v46 }
                            end
                        end
                        local v47, v48, v49 = (table.unpack or unpack)(getv47())
                        return { [1]=v47, [2]=v48, [3]=v49 }
                    end
                end
                local v50, v51, v52 = (table.unpack or unpack)(getv50())
                return { [1]=v50, [2]=v51, [3]=v52 }
            end
        end
        local v53, v54, v55 = (table.unpack or unpack)(getv53())
        local getv59 = function()
            if v55 then
                local v56 = v53 ~= 0
                if v56 then
                    return true
                else
                    local v57 = v54 ~= 0
                    return v57
                end
            else
                return false
            end
        end
        local v59 = getv59()
        local getv69 = function()
            if v59 then
                local v60 = spiral_wrap_signed((v15 + v53), 32)
                local v61 = spiral_wrap_signed((v16 + v54), 32)
                local v62 = spiral_wrap_signed((v60 - 1933), 32)
                local v63 = spiral_wrap_signed((v61 - 1350), 32)
                local v64 = arena_protection_zone_31(v62, v63)
                local getv67 = function()
                    if v64 then
                        return Us7_Blocked()
                    else
                        return footing_at_45(v60, v61, v17)
                    end
                end
                local v67 = getv67()
                if v67 ~= nil and v67.tag == "Us7_Free" then
                    return true
                else
                    return false
                end
            else
                return false
            end
        end
        local v69 = getv69()
        if v69 then
            local v70 = step_47(v53, v54)
            if v70 then
                local v71 = g_clock.millis()
                local v72 = v6 ~= nil and v6.l0
                local v73 = spiral_wrap_signed((v71 - v72), 32)
                local v74 = format_real_11(v15)
                local v75 = ""
                local v76 = v75 .. v74 
                local v77 = ","
                local v78 = v76 .. v77 
                local v79 = format_real_11(v16)
                local v80 = v78 .. v79 
                local v81 = v80 .. v77 
                local v82 = format_real_11(v17)
                local v83 = v81 .. v82 
                local v84 = 1
                local v85 = near_from_51(v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v84, v75)
                local v86 = "step away from "
                local v87 = v86 .. v83 
                local v88 = " by "
                local v89 = v87 .. v88 
                local v90 = format_real_11(v53)
                local v91 = v89 .. v90 
                local v92 = v91 .. v77 
                local v93 = format_real_11(v54)
                local v94 = v92 .. v93 
                local v95 = " @t+"
                local v96 = v94 .. v95 
                local v97 = format_real_11(v73)
                local v98 = v96 .. v97 
                local v99 = " near "
                local v100 = v98 .. v99 
                local v101 = v100 .. v85 
                local v102 = "[tibia-probe] "
                local v103 = v102 .. v101 
                write_log_line_9(v103)
                local v104 = v53 ~= 0
                local getv106 = function()
                    if v104 then
                        local v105 = v54 ~= 0
                        return v105
                    else
                        return false
                    end
                end
                local v106 = getv106()
                local getv107 = function()
                    if v106 then
                        return 3
                    else
                        return 1
                    end
                end
                local v107 = getv107()
                local v108 = spiral_wrap_signed(spiral_mul_mod32(650, v107), 32)
                local v109 = spiral_wrap_signed((v24 + v108), 32)
                local v110 = Us6_Stepped()
                return { [1]=v110, [2]=v109 }
            else
                local v111 = Us6_Gated()
                return { [1]=v111, [2]=0 }
            end
        else
            local v114 = spiral_wrap_signed((v25 + 1), 32)
            return attempt_from_30(v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v114)
        end
    end
end

function adjacent_from_52(v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26)
    local v27 = #(v21)
    local v28 = v25 > v27
    if v28 then
        return v26
    else
        local v29 = spiral_wrap_signed((v25 + 1), 32)
        local v30 = (v21)[v25]
        local v31 = positioned_monster_25(v30)
        local getv47 = function()
            if v31 then
                local v32 = (v30):getPosition()
                local v33 = v32.x
                local v34 = v32.y
                local v35 = v32.z
                local v36 = v33 > v15
                local getv39 = function()
                    if v36 then
                        local v37 = spiral_wrap_signed((v33 - v15), 32)
                        return v37
                    else
                        local v38 = spiral_wrap_signed((v15 - v33), 32)
                        return v38
                    end
                end
                local v39 = getv39()
                local v40 = v34 > v16
                local getv43 = function()
                    if v40 then
                        local v41 = spiral_wrap_signed((v34 - v16), 32)
                        return v41
                    else
                        local v42 = spiral_wrap_signed((v16 - v34), 32)
                        return v42
                    end
                end
                local v43 = getv43()
                local v44 = v39 > v43
                local getv45 = function()
                    if v44 then
                        return v39
                    else
                        return v43
                    end
                end
                local v45 = getv45()
                local v46 = v45 <= 1
                return v46
            else
                return false
            end
        end
        local v47 = getv47()
        local getv67 = function()
            if v47 then
                local v48 = (v30):getPosition()
                local v49 = v48.x
                local v50 = v48.y
                local v51 = v48.z
                local v52 = format_real_11(v49)
                local v53 = ""
                local v54 = v53 .. v52 
                local v55 = ","
                local v56 = v54 .. v55 
                local v57 = format_real_11(v50)
                local v58 = v56 .. v57 
                local v59 = v58 .. v55 
                local v60 = format_real_11(v51)
                local v61 = v59 .. v60 
                local v62 = v26 == ""
                if v62 then
                    return v61
                else
                    local v63 = " "
                    local v64 = v26 .. v63 
                    local v65 = v64 .. v61 
                    return v65
                end
            else
                return v26
            end
        end
        local v67 = getv67()
        return adjacent_from_52(v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v29, v67)
    end
end

function rejected_from_53(v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26)
    local v27 = v25 >= 7
    if v27 then
        return v26
    else
        local v28 = v25 == 0
        local getv53 = function()
            if v28 then
                return { [1]=v22, [2]=v23, [3]=true }
            else
                local v29 = v25 == 1
                local getv50 = function()
                    if v29 then
                        return { [1]=v22, [2]=0, [3]=true }
                    else
                        local v30 = v25 == 2
                        local getv47 = function()
                            if v30 then
                                return { [1]=0, [2]=v23, [3]=true }
                            else
                                local v31 = v25 <= 4
                                local getv44 = function()
                                    if v31 then
                                        local v32 = v25 == 3
                                        local getv35 = function()
                                            if v32 then
                                                local v33 = v22 == 0
                                                return { [1]=1, [2]=v23, [3]=v33 }
                                            else
                                                local v34 = v22 == 0
                                                return { [1]=-1, [2]=v23, [3]=v34 }
                                            end
                                        end
                                        local v35, v36, v37 = (table.unpack or unpack)(getv35())
                                        return { [1]=v35, [2]=v36, [3]=v37 }
                                    else
                                        local v38 = v25 == 5
                                        local getv41 = function()
                                            if v38 then
                                                local v39 = v23 == 0
                                                return { [1]=v22, [2]=1, [3]=v39 }
                                            else
                                                local v40 = v23 == 0
                                                return { [1]=v22, [2]=-1, [3]=v40 }
                                            end
                                        end
                                        local v41, v42, v43 = (table.unpack or unpack)(getv41())
                                        return { [1]=v41, [2]=v42, [3]=v43 }
                                    end
                                end
                                local v44, v45, v46 = (table.unpack or unpack)(getv44())
                                return { [1]=v44, [2]=v45, [3]=v46 }
                            end
                        end
                        local v47, v48, v49 = (table.unpack or unpack)(getv47())
                        return { [1]=v47, [2]=v48, [3]=v49 }
                    end
                end
                local v50, v51, v52 = (table.unpack or unpack)(getv50())
                return { [1]=v50, [2]=v51, [3]=v52 }
            end
        end
        local v53, v54, v55 = (table.unpack or unpack)(getv53())
        local v56 = spiral_wrap_signed((v25 + 1), 32)
        local getv60 = function()
            if v55 then
                local v57 = v53 ~= 0
                if v57 then
                    return true
                else
                    local v58 = v54 ~= 0
                    return v58
                end
            else
                return false
            end
        end
        local v60 = getv60()
        local getv94 = function()
            if v60 then
                local v61 = spiral_wrap_signed((v15 + v53), 32)
                local v62 = spiral_wrap_signed((v16 + v54), 32)
                local v63 = spiral_wrap_signed((v61 - 1933), 32)
                local v64 = spiral_wrap_signed((v62 - 1350), 32)
                local v65 = arena_protection_zone_31(v63, v64)
                local getv78 = function()
                    if v65 then
                        local v66 = "zone"
                        return v66
                    else
                        local v67 = footing_at_45(v61, v62, v17)
                        if v67 ~= nil and v67.tag == "Us7_Blocked" then
                            local v71 = "blocked"
                            return v71
                        elseif v67 ~= nil and v67.tag == "Us7_Free" then
                            local v68 = "walk"
                            return v68
                        elseif v67 ~= nil and v67.tag == "Us7_Occupied" then
                            local v70 = "creature"
                            return v70
                        elseif v67 ~= nil and v67.tag == "Us7_Ramp" then
                            local v69 = "walk"
                            return v69
                        elseif v67 ~= nil and v67.tag == "Us7_Unknown" then
                            local v72 = "none"
                            return v72
                        end
                    end
                end
                local v78 = getv78()
                local v79 = format_real_11(v53)
                local v80 = ""
                local v81 = v80 .. v79 
                local v82 = ","
                local v83 = v81 .. v82 
                local v84 = format_real_11(v54)
                local v85 = v83 .. v84 
                local v86 = ":"
                local v87 = v85 .. v86 
                local v88 = v87 .. v78 
                local v89 = v26 == ""
                if v89 then
                    return v88
                else
                    local v90 = " "
                    local v91 = v26 .. v90 
                    local v92 = v91 .. v88 
                    return v92
                end
            else
                return v26
            end
        end
        local v94 = getv94()
        return rejected_from_53(v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v56, v94)
    end
end

function method55(v0, v1, v2)
    if v1 ~= nil and v1.tag == "Uh0_Cons" then
        local v3 = v1._1
        local v4 = v1._2
        local v5 = v1._3
        local v6 = method55(v0, v5, v2)
        local v7 = v3 ~= v0
        if v7 then
            return Uh0_Cons(v3, v4, v6)
        else
            return v6
        end
    elseif v1 ~= nil and v1.tag == "Uh0_Nil" then
        return v2
    end
end

function remember_54(v0, v1)
    local v2 = (v1):getId()
    local v3 = v0 ~= nil and v0.l0
    local v4 = Uh0_Nil()
    local v5 = method55(v2, v3, v4)
    local v6 = Uh0_Cons(v2, v1, v5)
    v0.l0 = v6
    return nil
end

function monster_lines_57(v0, v1, v2)
    local v3 = v1 < 1
    if v3 then
        return v2
    else
        local v4 = (v0)[v1]
        local v5 = spiral_wrap_signed((v1 - 1), 32)
        local v6 = live_monster_14(v4)
        local getv27 = function()
            if v6 then
                local v7 = (v4):getPosition()
                local v8 = v7.x
                local v9 = v7.y
                local v10 = v7.z
                local v11 = (v4):getName()
                local v12 = " "
                local v13 = v11 .. v12 
                local v14 = (v4):getHealthPercent()
                local v15 = format_real_11(v14)
                local v16 = v13 .. v15 
                local v17 = "%"
                local v18 = v16 .. v17 
                local v19 = v18 .. v12 
                local v20 = format_real_11(v8)
                local v21 = v19 .. v20 
                local v22 = ","
                local v23 = v21 .. v22 
                local v24 = format_real_11(v9)
                local v25 = v23 .. v24 
                return Uh1_Cons(v25, v2)
            else
                return v2
            end
        end
        local v27 = getv27()
        return monster_lines_57(v0, v5, v27)
    end
end

function method58(v0, v1, v2)
    local getv12 = function()
        if v0 ~= nil and v0.tag == "Uh1_Cons" then
            local v3 = v0._1
            local v4 = v0._2
            local v5, v6 = (table.unpack or unpack)(method58(v4, v1, v2))
            local v7 = v3 .. v6 
            local v8 = v7 .. v5 
            local v9 = "; "
            return { [1]=v8, [2]=v9 }
        else
            local getv10 = function()
                if v0 ~= nil and v0.tag == "Uh1_Nil" then
                    return { [1]=v1, [2]=v2 }
                end
            end
            local v10, v11 = (table.unpack or unpack)(getv10())
            return { [1]=v10, [2]=v11 }
        end
    end
    local v12, v13 = (table.unpack or unpack)(getv12())
    return { [1]=v12, [2]=v13 }
end

function monsters_described_56(v0, v1, v2)
    local v3 = g_map.getSpectators({ x = v0, y = v1, z = v2 }, false)
    local v4 = #(v3)
    local v5 = Uh1_Nil()
    local v6 = monster_lines_57(v3, v4, v5)
    if v6 ~= nil and v6.tag == "Uh1_Nil" then
        local v7 = "none"
        return v7
    else
        local v8 = ""
        local v9, v10 = (table.unpack or unpack)(method58(v6, v8, v8))
        return v9
    end
end

function attacking_described_59()
    local v0 = g_game.getAttackingCreature()
    local v1 = (v0) ~= nil
    if v1 then
        local v2 = (v0):getName()
        local v3 = " "
        local v4 = v2 .. v3 
        local v5 = (v0):getHealthPercent()
        local v6 = format_real_11(v5)
        local v7 = v4 .. v6 
        local v8 = "%"
        local v9 = v7 .. v8 
        local v10 = " at "
        local v11 = v9 .. v10 
        local v12 = (v0):getPosition()
        local v13 = v12.x
        local v14 = v12.y
        local v15 = v12.z
        local v16 = format_real_11(v13)
        local v17 = ""
        local v18 = v17 .. v16 
        local v19 = ","
        local v20 = v18 .. v19 
        local v21 = format_real_11(v14)
        local v22 = v20 .. v21 
        local v23 = v22 .. v19 
        local v24 = format_real_11(v15)
        local v25 = v23 .. v24 
        local v26 = v11 .. v25 
        return v26
    else
        local v27 = "nothing"
        return v27
    end
end

function player_zone_60()
    local v0 = g_game.getLocalPlayer()
    local v1 = (v0).isInProtectionZone ~= nil
    if v1 then
        local v2 = (v0):isInProtectionZone()
        if v2 then
            local v3 = "true"
            return v3
        else
            local v4 = "false"
            return v4
        end
    else
        local v6 = "?"
        return v6
    end
end

function closure12(capt)
    local v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25 = (table.unpack or unpack)(capt)
    return function(dom)
        return ticked_18(v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v17, v18, v19, v20, v21, v22, v23, v24, v25, v15, v16)
    end
end

function ticked_18(v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25)
    local v26 = player_present_12()
    local v27 = v26 == false
    local getv942 = function()
        if v27 then
            local v28 = parity_summary_19()
            local v29 = v28 ~= ""
            if v29 then
                local v30 = "[tibia-probe] "
                local v31 = v30 .. v28 
                write_log_line_9(v31)
            else
            end
            local v32 = "finish: "
            local v33 = "offline"
            local v34 = v32 .. v33 
            local v35 = "[tibia-probe] "
            local v36 = v35 .. v34 
            write_log_line_9(v36)
            local v37 = g_game.isOnline()
            if v37 then
                g_game.safeLogout()
            else
            end
            local v38 = closure3(nil)
            scheduleEvent(v38, 2000)
            return Us4_None()
        else
            local v40 = g_clock.millis()
            local v41 = g_game.getLocalPlayer():getHealth()
            local v42 = spiral_wrap_signed((v15 + 1), 32)
            local v43 = v41 < v23
            local getv44 = function()
                if v43 then
                    return v41
                else
                    return v23
                end
            end
            local v44 = getv44()
            local v45 = v41 <= 0
            if v45 then
                local v46 = g_game.getLocalPlayer():getHealth()
                local v47 = g_game.getLocalPlayer():getExperience()
                local v48 = spiral_wrap_signed((v47 - v5), 32)
                local v49 = format_real_11(v42)
                local v50 = "ticks "
                local v51 = v50 .. v49 
                local v52 = " heals "
                local v53 = v51 .. v52 
                local v54 = format_real_11(v16)
                local v55 = v53 .. v54 
                local v56 = " strikes "
                local v57 = v55 .. v56 
                local v58 = format_real_11(v17)
                local v59 = v57 .. v58 
                local v60 = " holds "
                local v61 = v59 .. v60 
                local v62 = format_real_11(v18)
                local v63 = v61 .. v62 
                local v64 = format_real_11(v20)
                local v65 = " retreats "
                local v66 = v65 .. v64 
                local v67 = " cornered "
                local v68 = v66 .. v67 
                local v69 = format_real_11(v21)
                local v70 = v68 .. v69 
                local v71 = " gated "
                local v72 = v70 .. v71 
                local v73 = format_real_11(v22)
                local v74 = v72 .. v73 
                local v75 = " kills "
                local v76 = v74 .. v75 
                local v77 = format_real_11(v19)
                local v78 = v76 .. v77 
                local v79 = v63 .. v78 
                local v80 = format_real_11(v46)
                local v81 = " health "
                local v82 = v81 .. v80 
                local v83 = " lowest "
                local v84 = v82 .. v83 
                local v85 = format_real_11(v44)
                local v86 = v84 .. v85 
                local v87 = " experience +"
                local v88 = v86 .. v87 
                local v89 = format_real_11(v48)
                local v90 = v88 .. v89 
                local v91 = v79 .. v90 
                local v92 = "dead: "
                local v93 = v92 .. v91 
                local v94 = "[tibia-probe] "
                local v95 = v94 .. v93 
                write_log_line_9(v95)
                local v96 = parity_summary_19()
                local v97 = v96 ~= ""
                if v97 then
                    local v98 = v94 .. v96 
                    write_log_line_9(v98)
                else
                end
                local v99 = "finish: "
                local v100 = "death"
                local v101 = v99 .. v100 
                local v102 = v94 .. v101 
                write_log_line_9(v102)
                local v103 = g_game.isOnline()
                if v103 then
                    g_game.safeLogout()
                else
                end
                local v104 = closure3(nil)
                scheduleEvent(v104, 2000)
                return Us4_None()
            else
                local v106 = forget_dead_20(v8)
                local v107 = spiral_wrap_signed((v19 + v106), 32)
                local v108 = g_game.getLocalPlayer():getPosition()
                local v109 = v108.x
                local v110 = v108.y
                local v111 = v108.z
                local v112 = g_map.getSpectators({ x = v109, y = v110, z = v111 }, false)
                if v10 then
                    local v113 = v13 ~= nil and v13.l0
                    local v114 = v113 < 0
                    if v114 then
                        local v115 = format_real_11(v109)
                        local v116 = ""
                        local v117 = v116 .. v115 
                        local v118 = ","
                        local v119 = v117 .. v118 
                        local v120 = format_real_11(v110)
                        local v121 = v119 .. v120 
                        local v122 = v121 .. v118 
                        local v123 = format_real_11(v111)
                        local v124 = v122 .. v123 
                        local v125 = "start positions: knight "
                        local v126 = v125 .. v124 
                        local v127 = " monsters "
                        local v128 = v126 .. v127 
                        local v129 = 1
                        local v130 = positions_from_24(v112, v129, v116)
                        local v131 = v128 .. v130 
                        local v132 = "[tibia-probe] "
                        local v133 = v132 .. v131 
                        write_log_line_9(v133)
                    else
                        local v134 = spiral_wrap_signed((v40 - v113), 32)
                        local v135 = 1
                        local v136 = 0
                        local v137 = adjacent_from_13(v109, v110, v111, v112, v135, v136)
                        local v138 = v11 ~= nil and v11.l0
                        local v139 = spiral_wrap_signed(spiral_mul_mod32(v137, v134), 32)
                        local v140 = spiral_wrap_signed((v138 + v139), 32)
                        v11.l0 = v140
                        local v141 = v137 > 3
                        local getv142 = function()
                            if v141 then
                                return 3
                            else
                                return v137
                            end
                        end
                        local v142 = getv142()
                        local v143 = (v14)[(v142)+1]
                        local v144 = spiral_wrap_signed((v143 + v134), 32)
                        v14[(v142)+1] = v144
                    end
                    v13.l0 = v40
                else
                end
                local v145 = g_game.getAttackingCreature()
                local v146 = 1
                local v147 = Us5_None()
                local v148 = scan_sight_26(v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v109, v110, v111, v112, v145, v146, v147)
                local v149 = 1
                local v150 = 0
                local v151 = Us0_None()
                local v152, v153 = (table.unpack or unpack)(scan_threats_27(v109, v110, v111, v112, v149, v150, v151))
                local v154 = spiral_wrap_signed((v40 - v24), 32)
                local v155 = v154 >= 1000
                local v156 = v152 > 0
                local getv158 = function()
                    if v156 then
                        local v157 = v40 >= v25
                        return v157
                    else
                        return false
                    end
                end
                local v158 = getv158()
                local getv161 = function()
                    if v158 then
                        local v159 = g_game.getLocalPlayer():isWalking()
                        local v160 = v159 == false
                        return v160
                    else
                        return false
                    end
                end
                local v161 = getv161()
                local v162 = v3 > 0
                local getv835 = function()
                    if v162 then
                        local v163 = g_game.getLocalPlayer():getMaxHealth()
                        local v164 = spiral_wrap_signed((v0 - 1), 32)
                        local v165 = spiral_wrap_signed(spiral_mul_mod32(v164, 256), 32)
                        local v166 = (math.modf(v165 / v163))
                        local v167 = spiral_wrap_signed((v166 + 1), 32)
                        local v168 = (function(n) local t = {} for i = 1, n do t[i] = 0 end return t end)(66)
                        local v169 = 0
                        fill_28(v168, v169)
                        v168[(0)+1] = -256
                        v168[(7)+1] = v167
                        v168[(48)+1] = 256
                        v168[(15)+1] = 256
                        v168[(55)+1] = 256
                        v168[(17)+1] = 256
                        v168[(21)+1] = -256
                        local v170 = spiral_wrap_signed((v3 - 1), 32)
                        local v171 = spiral_wrap_signed(spiral_mul_mod32(v170, 85), 32)
                        local v172 = spiral_wrap_signed(-(v171), 32)
                        v168[(23)+1] = v172
                        v168[(62)+1] = 1024
                        local v173 = spiral_wrap_signed(spiral_mul_mod32(v41, 256), 32)
                        local v174 = (math.modf(v173 / v163))
                        local getv180 = function()
                            if v148 ~= nil and v148.tag == "Us5_None" then
                                return 0
                            elseif v148 ~= nil and v148.tag == "Us5_Some" then
                                local v175 = v148._1
                                local v176 = v148._2
                                local v177 = (v112)[v175]
                                local v178 = (v177):getHealthPercent()
                                return v178
                            end
                        end
                        local v180 = getv180()
                        local v181 = spiral_wrap_signed(spiral_mul_mod32(v180, 256), 32)
                        local v182 = (math.modf(v181 / 100))
                        local getv186 = function()
                            if v148 ~= nil and v148.tag == "Us5_None" then
                                return 0
                            elseif v148 ~= nil and v148.tag == "Us5_Some" then
                                local v183 = v148._1
                                local v184 = v148._2
                                return v184
                            end
                        end
                        local v186 = getv186()
                        local v187 = v9 ~= nil and v9.l0
                        local v188 = spiral_wrap_signed((v40 - v187), 32)
                        local v189 = v188 >= 2000
                        local getv190 = function()
                            if v155 then
                                return 256
                            else
                                return 0
                            end
                        end
                        local v190 = getv190()
                        local getv191 = function()
                            if v189 then
                                return 256
                            else
                                return 0
                            end
                        end
                        local v191 = getv191()
                        local v192 = spiral_wrap_signed(spiral_mul_mod32(v152, 85), 32)
                        local v193 = v186 > 7
                        local getv194 = function()
                            if v193 then
                                return 7
                            else
                                return v186
                            end
                        end
                        local v194 = getv194()
                        local v195 = spiral_wrap_signed(spiral_mul_mod32(v194, 32), 32)
                        local v196 = 0
                        local v197 = 0
                        local v198 = 0
                        local v199 = 0
                        local v200 = 0
                        local v201, v202, v203 = (table.unpack or unpack)(outputs_from_29(v168, v174, v192, v182, v195, v190, v191, v196, v197, v198, v199, v200))
                        local getv204 = function()
                            if v201 then
                                return 1
                            else
                                return 0
                            end
                        end
                        local v204 = getv204()
                        local getv205 = function()
                            if v202 then
                                return 2
                            else
                                return 0
                            end
                        end
                        local v205 = getv205()
                        local v206 = spiral_wrap_signed((v204 + v205), 32)
                        local getv207 = function()
                            if v203 then
                                return 4
                            else
                                return 0
                            end
                        end
                        local v207 = getv207()
                        local v208 = spiral_wrap_signed((v206 + v207), 32)
                        local v209 = math.fmod(v208, 2)
                        local v210 = v209 == 1
                        local v211 = (v210) and (v155)
                        local getv232 = function()
                            if v211 then
                                local v212 = g_game.useInventoryItemWith(266, g_game.getLocalPlayer()) ~= false
                                local getv215 = function()
                                    if v212 then
                                        local v213 = "heal (potion) at health "
                                        return v213
                                    else
                                        local v214 = "heal dropped by the action gate at health "
                                        return v214
                                    end
                                end
                                local v215 = getv215()
                                local v216 = format_real_11(v41)
                                local v217 = v215 .. v216 
                                local v218 = "[tibia-probe] "
                                local v219 = v218 .. v217 
                                write_log_line_9(v219)
                                if v212 then
                                    local v220 = spiral_wrap_signed((v16 + 1), 32)
                                    return { [1]=v42, [2]=v220, [3]=v17, [4]=v18, [5]=v107, [6]=v20, [7]=v21, [8]=v22, [9]=v44, [10]=v40, [11]=v25 }
                                else
                                    return { [1]=v42, [2]=v16, [3]=v17, [4]=v18, [5]=v107, [6]=v20, [7]=v21, [8]=v22, [9]=v44, [10]=v24, [11]=v25 }
                                end
                            else
                                return { [1]=v42, [2]=v16, [3]=v17, [4]=v18, [5]=v107, [6]=v20, [7]=v21, [8]=v22, [9]=v44, [10]=v24, [11]=v25 }
                            end
                        end
                        local v232, v233, v234, v235, v236, v237, v238, v239, v240, v241, v242 = (table.unpack or unpack)(getv232())
                        local v243 = (math.modf(v208 / 4))
                        local v244 = math.fmod(v243, 2)
                        local v245 = v244 == 1
                        local v246 = (v245) and (v161)
                        local getv373 = function()
                            if v246 then
                                if v153 ~= nil and v153.tag == "Us0_None" then
                                    return { [1]=false, [2]=v232, [3]=v233, [4]=v234, [5]=v235, [6]=v236, [7]=v237, [8]=v238, [9]=v239, [10]=v240, [11]=v241, [12]=v242 }
                                elseif v153 ~= nil and v153.tag == "Us0_Some" then
                                    local v247 = v153._1
                                    local v248 = (v112)[v247]
                                    local v249 = (v248):getPosition()
                                    local v250 = v249.x
                                    local v251 = v249.y
                                    local v252 = v249.z
                                    local v253 = false
                                    chasing_17(v253)
                                    local v254 = spiral_wrap_signed((v109 - v250), 32)
                                    local v255 = v254 > 0
                                    local getv258 = function()
                                        if v255 then
                                            return 1
                                        else
                                            local v256 = v254 < 0
                                            if v256 then
                                                return -1
                                            else
                                                return 0
                                            end
                                        end
                                    end
                                    local v258 = getv258()
                                    local v259 = spiral_wrap_signed((v110 - v251), 32)
                                    local v260 = v259 > 0
                                    local getv263 = function()
                                        if v260 then
                                            return 1
                                        else
                                            local v261 = v259 < 0
                                            if v261 then
                                                return -1
                                            else
                                                return 0
                                            end
                                        end
                                    end
                                    local v263 = getv263()
                                    local v264 = g_clock.millis()
                                    local v265 = 0
                                    local v266, v267 = (table.unpack or unpack)(attempt_from_30(v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v109, v110, v111, v250, v251, v252, v112, v258, v263, v264, v265))
                                    local getv268 = function()
                                        if v266 ~= nil and v266.tag == "Us6_Cornered" then
                                            return true
                                        else
                                            return false
                                        end
                                    end
                                    local v268 = getv268()
                                    local getv272 = function()
                                        if v268 then
                                            local v269 = spiral_wrap_signed((v238 + 1), 32)
                                            local v270 = math.fmod(v269, 50)
                                            local v271 = v270 == 1
                                            return v271
                                        else
                                            return false
                                        end
                                    end
                                    local v272 = getv272()
                                    if v272 then
                                        local v273 = format_real_11(v109)
                                        local v274 = ""
                                        local v275 = v274 .. v273 
                                        local v276 = ","
                                        local v277 = v275 .. v276 
                                        local v278 = format_real_11(v110)
                                        local v279 = v277 .. v278 
                                        local v280 = v279 .. v276 
                                        local v281 = format_real_11(v111)
                                        local v282 = v280 .. v281 
                                        local v283 = "cornered at "
                                        local v284 = v283 .. v282 
                                        local v285 = " threat "
                                        local v286 = v284 .. v285 
                                        local v287 = format_real_11(v250)
                                        local v288 = v274 .. v287 
                                        local v289 = v288 .. v276 
                                        local v290 = format_real_11(v251)
                                        local v291 = v289 .. v290 
                                        local v292 = v291 .. v276 
                                        local v293 = format_real_11(v252)
                                        local v294 = v292 .. v293 
                                        local v295 = v286 .. v294 
                                        local v296 = 1
                                        local v297 = adjacent_from_52(v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v109, v110, v111, v250, v251, v252, v112, v258, v263, v264, v296, v274)
                                        local v298 = 0
                                        local v299 = rejected_from_53(v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v109, v110, v111, v250, v251, v252, v112, v258, v263, v264, v298, v274)
                                        local v300 = " adjacent ["
                                        local v301 = v295 .. v300 
                                        local v302 = v301 .. v297 
                                        local v303 = "] candidates ["
                                        local v304 = v302 .. v303 
                                        local v305 = v304 .. v299 
                                        local v306 = "]"
                                        local v307 = v305 .. v306 
                                        local v308 = "[tibia-probe] "
                                        local v309 = v308 .. v307 
                                        write_log_line_9(v309)
                                    else
                                    end
                                    if v266 ~= nil and v266.tag == "Us6_Cornered" then
                                        local v312 = spiral_wrap_signed((v238 + 1), 32)
                                        return { [1]=false, [2]=v232, [3]=v233, [4]=v234, [5]=v235, [6]=v236, [7]=v237, [8]=v312, [9]=v239, [10]=v240, [11]=v241, [12]=v242 }
                                    elseif v266 ~= nil and v266.tag == "Us6_Gated" then
                                        local v311 = spiral_wrap_signed((v239 + 1), 32)
                                        return { [1]=false, [2]=v232, [3]=v233, [4]=v234, [5]=v235, [6]=v236, [7]=v237, [8]=v238, [9]=v311, [10]=v240, [11]=v241, [12]=v242 }
                                    elseif v266 ~= nil and v266.tag == "Us6_Stepped" then
                                        local v310 = spiral_wrap_signed((v237 + 1), 32)
                                        return { [1]=true, [2]=v232, [3]=v233, [4]=v234, [5]=v235, [6]=v236, [7]=v310, [8]=v238, [9]=v239, [10]=v240, [11]=v241, [12]=v267 }
                                    end
                                end
                            else
                                return { [1]=false, [2]=v232, [3]=v233, [4]=v234, [5]=v235, [6]=v236, [7]=v237, [8]=v238, [9]=v239, [10]=v240, [11]=v241, [12]=v242 }
                            end
                        end
                        local v373, v374, v375, v376, v377, v378, v379, v380, v381, v382, v383, v384 = (table.unpack or unpack)(getv373())
                        if v373 then
                            return { [1]=v374, [2]=v375, [3]=v376, [4]=v377, [5]=v378, [6]=v379, [7]=v380, [8]=v381, [9]=v382, [10]=v383, [11]=v384 }
                        else
                            local getv393 = function()
                                if v148 ~= nil and v148.tag == "Us5_None" then
                                    return Us8_NoTarget()
                                elseif v148 ~= nil and v148.tag == "Us5_Some" then
                                    local v385 = v148._1
                                    local v386 = v148._2
                                    local v387 = v386 <= 1
                                    if v387 then
                                        return Us8_InReach()
                                    else
                                        return Us8_OutOfReach()
                                    end
                                end
                            end
                            local v393 = getv393()
                            local v394 = (math.modf(v208 / 2))
                            local v395 = math.fmod(v394, 2)
                            local v396 = v395 == 1
                            local getv399 = function()
                                if v396 then
                                    local getv397 = function()
                                        if v393 ~= nil and v393.tag == "Us8_NoTarget" then
                                            return true
                                        else
                                            return false
                                        end
                                    end
                                    local v397 = getv397()
                                    local v398 = v397 ~= true
                                    return v398
                                else
                                    return false
                                end
                            end
                            local v399 = getv399()
                            if v399 then
                                local getv400 = function()
                                    if v393 ~= nil and v393.tag == "Us8_OutOfReach" then
                                        return true
                                    else
                                        return false
                                    end
                                end
                                local v400 = getv400()
                                local v401 = g_game.getChaseMode() == ChaseOpponent
                                local v402 = v401 ~= v400
                                if v402 then
                                    local getv405 = function()
                                        if v400 then
                                            local v403 = "on"
                                            return v403
                                        else
                                            local v404 = "off"
                                            return v404
                                        end
                                    end
                                    local v405 = getv405()
                                    local v406 = g_clock.millis()
                                    local v407 = v6 ~= nil and v6.l0
                                    local v408 = spiral_wrap_signed((v406 - v407), 32)
                                    local v409 = "chase "
                                    local v410 = v409 .. v405 
                                    local v411 = " @t+"
                                    local v412 = v410 .. v411 
                                    local v413 = format_real_11(v408)
                                    local v414 = v412 .. v413 
                                    local v415 = "[tibia-probe] "
                                    local v416 = v415 .. v414 
                                    write_log_line_9(v416)
                                else
                                end
                                chasing_17(v400)
                                if v148 ~= nil and v148.tag == "Us5_None" then
                                elseif v148 ~= nil and v148.tag == "Us5_Some" then
                                    local v417 = v148._1
                                    local v418 = v148._2
                                    local v419 = (v112)[v417]
                                    local v420 = g_game.getAttackingCreature()
                                    local v421 = (v420) == (v419)
                                    local v422 = v421 == false
                                    if v422 then
                                        g_game.attack(v419)
                                        remember_54(v8, v419)
                                        local getv425 = function()
                                            if v400 then
                                                local v423 = "approach"
                                                return v423
                                            else
                                                local v424 = "strike"
                                                return v424
                                            end
                                        end
                                        local v425 = getv425()
                                        local v426 = (v419):getName()
                                        local v427 = " "
                                        local v428 = v425 .. v427 
                                        local v429 = v428 .. v426 
                                        local v430 = (v419):getPosition()
                                        local v431 = v430.x
                                        local v432 = v430.y
                                        local v433 = v430.z
                                        local v434 = format_real_11(v431)
                                        local v435 = ""
                                        local v436 = v435 .. v434 
                                        local v437 = ","
                                        local v438 = v436 .. v437 
                                        local v439 = format_real_11(v432)
                                        local v440 = v438 .. v439 
                                        local v441 = v440 .. v437 
                                        local v442 = format_real_11(v433)
                                        local v443 = v441 .. v442 
                                        local v444 = " at "
                                        local v445 = v444 .. v443 
                                        local v446 = " from "
                                        local v447 = v445 .. v446 
                                        local v448 = format_real_11(v109)
                                        local v449 = v435 .. v448 
                                        local v450 = v449 .. v437 
                                        local v451 = format_real_11(v110)
                                        local v452 = v450 .. v451 
                                        local v453 = v452 .. v437 
                                        local v454 = format_real_11(v111)
                                        local v455 = v453 .. v454 
                                        local v456 = v447 .. v455 
                                        local v457 = v429 .. v456 
                                        local v458 = g_clock.millis()
                                        local v459 = v6 ~= nil and v6.l0
                                        local v460 = spiral_wrap_signed((v458 - v459), 32)
                                        local v461 = " health "
                                        local v462 = v457 .. v461 
                                        local v463 = format_real_11(v41)
                                        local v464 = v462 .. v463 
                                        local v465 = " @t+"
                                        local v466 = v464 .. v465 
                                        local v467 = format_real_11(v460)
                                        local v468 = v466 .. v467 
                                        local v469 = "[tibia-probe] "
                                        local v470 = v469 .. v468 
                                        write_log_line_9(v470)
                                    else
                                    end
                                end
                                local v471 = spiral_wrap_signed((v376 + 1), 32)
                                return { [1]=v374, [2]=v375, [3]=v471, [4]=v377, [5]=v378, [6]=v379, [7]=v380, [8]=v381, [9]=v382, [10]=v383, [11]=v384 }
                            else
                                local v472 = g_game.isAttacking()
                                local getv483 = function()
                                    if v472 then
                                        local getv481 = function()
                                            if v148 ~= nil and v148.tag == "Us5_None" then
                                                return Us8_NoTarget()
                                            elseif v148 ~= nil and v148.tag == "Us5_Some" then
                                                local v473 = v148._1
                                                local v474 = v148._2
                                                local v475 = v474 <= 1
                                                if v475 then
                                                    return Us8_InReach()
                                                else
                                                    return Us8_OutOfReach()
                                                end
                                            end
                                        end
                                        local v481 = getv481()
                                        if v481 ~= nil and v481.tag == "Us8_InReach" then
                                            return true
                                        else
                                            return false
                                        end
                                    else
                                        return false
                                    end
                                end
                                local v483 = getv483()
                                if v483 then
                                    g_game.cancelAttack()
                                    local v484 = format_real_11(v41)
                                    local v485 = "hold at health "
                                    local v486 = v485 .. v484 
                                    local v487 = "[tibia-probe] "
                                    local v488 = v487 .. v486 
                                    write_log_line_9(v488)
                                else
                                end
                                local v489 = spiral_wrap_signed((v377 + 1), 32)
                                return { [1]=v374, [2]=v375, [3]=v376, [4]=v489, [5]=v378, [6]=v379, [7]=v380, [8]=v381, [9]=v382, [10]=v383, [11]=v384 }
                            end
                        end
                    else
                        local getv522 = function()
                            if v155 then
                                local v521 = v41 < v0
                                return v521
                            else
                                return false
                            end
                        end
                        local v522 = getv522()
                        local getv543 = function()
                            if v522 then
                                local v523 = g_game.useInventoryItemWith(266, g_game.getLocalPlayer()) ~= false
                                local getv526 = function()
                                    if v523 then
                                        local v524 = "heal (potion) at health "
                                        return v524
                                    else
                                        local v525 = "heal dropped by the action gate at health "
                                        return v525
                                    end
                                end
                                local v526 = getv526()
                                local v527 = format_real_11(v41)
                                local v528 = v526 .. v527 
                                local v529 = "[tibia-probe] "
                                local v530 = v529 .. v528 
                                write_log_line_9(v530)
                                if v523 then
                                    local v531 = spiral_wrap_signed((v16 + 1), 32)
                                    return { [1]=v42, [2]=v531, [3]=v17, [4]=v18, [5]=v107, [6]=v20, [7]=v21, [8]=v22, [9]=v44, [10]=v40, [11]=v25 }
                                else
                                    return { [1]=v42, [2]=v16, [3]=v17, [4]=v18, [5]=v107, [6]=v20, [7]=v21, [8]=v22, [9]=v44, [10]=v24, [11]=v25 }
                                end
                            else
                                return { [1]=v42, [2]=v16, [3]=v17, [4]=v18, [5]=v107, [6]=v20, [7]=v21, [8]=v22, [9]=v44, [10]=v24, [11]=v25 }
                            end
                        end
                        local v543, v544, v545, v546, v547, v548, v549, v550, v551, v552, v553 = (table.unpack or unpack)(getv543())
                        local v554 = v2 > 0
                        local getv556 = function()
                            if v554 then
                                local v555 = v152 >= v2
                                return v555
                            else
                                return false
                            end
                        end
                        local v556 = getv556()
                        local v557 = (v556) and (v161)
                        local getv684 = function()
                            if v557 then
                                if v153 ~= nil and v153.tag == "Us0_None" then
                                    return { [1]=false, [2]=v543, [3]=v544, [4]=v545, [5]=v546, [6]=v547, [7]=v548, [8]=v549, [9]=v550, [10]=v551, [11]=v552, [12]=v553 }
                                elseif v153 ~= nil and v153.tag == "Us0_Some" then
                                    local v558 = v153._1
                                    local v559 = (v112)[v558]
                                    local v560 = (v559):getPosition()
                                    local v561 = v560.x
                                    local v562 = v560.y
                                    local v563 = v560.z
                                    local v564 = false
                                    chasing_17(v564)
                                    local v565 = spiral_wrap_signed((v109 - v561), 32)
                                    local v566 = v565 > 0
                                    local getv569 = function()
                                        if v566 then
                                            return 1
                                        else
                                            local v567 = v565 < 0
                                            if v567 then
                                                return -1
                                            else
                                                return 0
                                            end
                                        end
                                    end
                                    local v569 = getv569()
                                    local v570 = spiral_wrap_signed((v110 - v562), 32)
                                    local v571 = v570 > 0
                                    local getv574 = function()
                                        if v571 then
                                            return 1
                                        else
                                            local v572 = v570 < 0
                                            if v572 then
                                                return -1
                                            else
                                                return 0
                                            end
                                        end
                                    end
                                    local v574 = getv574()
                                    local v575 = g_clock.millis()
                                    local v576 = 0
                                    local v577, v578 = (table.unpack or unpack)(attempt_from_30(v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v109, v110, v111, v561, v562, v563, v112, v569, v574, v575, v576))
                                    local getv579 = function()
                                        if v577 ~= nil and v577.tag == "Us6_Cornered" then
                                            return true
                                        else
                                            return false
                                        end
                                    end
                                    local v579 = getv579()
                                    local getv583 = function()
                                        if v579 then
                                            local v580 = spiral_wrap_signed((v549 + 1), 32)
                                            local v581 = math.fmod(v580, 50)
                                            local v582 = v581 == 1
                                            return v582
                                        else
                                            return false
                                        end
                                    end
                                    local v583 = getv583()
                                    if v583 then
                                        local v584 = format_real_11(v109)
                                        local v585 = ""
                                        local v586 = v585 .. v584 
                                        local v587 = ","
                                        local v588 = v586 .. v587 
                                        local v589 = format_real_11(v110)
                                        local v590 = v588 .. v589 
                                        local v591 = v590 .. v587 
                                        local v592 = format_real_11(v111)
                                        local v593 = v591 .. v592 
                                        local v594 = "cornered at "
                                        local v595 = v594 .. v593 
                                        local v596 = " threat "
                                        local v597 = v595 .. v596 
                                        local v598 = format_real_11(v561)
                                        local v599 = v585 .. v598 
                                        local v600 = v599 .. v587 
                                        local v601 = format_real_11(v562)
                                        local v602 = v600 .. v601 
                                        local v603 = v602 .. v587 
                                        local v604 = format_real_11(v563)
                                        local v605 = v603 .. v604 
                                        local v606 = v597 .. v605 
                                        local v607 = 1
                                        local v608 = adjacent_from_52(v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v109, v110, v111, v561, v562, v563, v112, v569, v574, v575, v607, v585)
                                        local v609 = 0
                                        local v610 = rejected_from_53(v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v109, v110, v111, v561, v562, v563, v112, v569, v574, v575, v609, v585)
                                        local v611 = " adjacent ["
                                        local v612 = v606 .. v611 
                                        local v613 = v612 .. v608 
                                        local v614 = "] candidates ["
                                        local v615 = v613 .. v614 
                                        local v616 = v615 .. v610 
                                        local v617 = "]"
                                        local v618 = v616 .. v617 
                                        local v619 = "[tibia-probe] "
                                        local v620 = v619 .. v618 
                                        write_log_line_9(v620)
                                    else
                                    end
                                    if v577 ~= nil and v577.tag == "Us6_Cornered" then
                                        local v623 = spiral_wrap_signed((v549 + 1), 32)
                                        return { [1]=false, [2]=v543, [3]=v544, [4]=v545, [5]=v546, [6]=v547, [7]=v548, [8]=v623, [9]=v550, [10]=v551, [11]=v552, [12]=v553 }
                                    elseif v577 ~= nil and v577.tag == "Us6_Gated" then
                                        local v622 = spiral_wrap_signed((v550 + 1), 32)
                                        return { [1]=false, [2]=v543, [3]=v544, [4]=v545, [5]=v546, [6]=v547, [7]=v548, [8]=v549, [9]=v622, [10]=v551, [11]=v552, [12]=v553 }
                                    elseif v577 ~= nil and v577.tag == "Us6_Stepped" then
                                        local v621 = spiral_wrap_signed((v548 + 1), 32)
                                        return { [1]=true, [2]=v543, [3]=v544, [4]=v545, [5]=v546, [6]=v547, [7]=v621, [8]=v549, [9]=v550, [10]=v551, [11]=v552, [12]=v578 }
                                    end
                                end
                            else
                                return { [1]=false, [2]=v543, [3]=v544, [4]=v545, [5]=v546, [6]=v547, [7]=v548, [8]=v549, [9]=v550, [10]=v551, [11]=v552, [12]=v553 }
                            end
                        end
                        local v684, v685, v686, v687, v688, v689, v690, v691, v692, v693, v694, v695 = (table.unpack or unpack)(getv684())
                        if v684 then
                            return { [1]=v685, [2]=v686, [3]=v687, [4]=v688, [5]=v689, [6]=v690, [7]=v691, [8]=v692, [9]=v693, [10]=v694, [11]=v695 }
                        else
                            local getv704 = function()
                                if v148 ~= nil and v148.tag == "Us5_None" then
                                    return Us8_NoTarget()
                                elseif v148 ~= nil and v148.tag == "Us5_Some" then
                                    local v696 = v148._1
                                    local v697 = v148._2
                                    local v698 = v697 <= 1
                                    if v698 then
                                        return Us8_InReach()
                                    else
                                        return Us8_OutOfReach()
                                    end
                                end
                            end
                            local v704 = getv704()
                            local getv716 = function()
                                if v704 ~= nil and v704.tag == "Us8_InReach" then
                                    local v705 = v41 >= v1
                                    if v705 then
                                        return Us9_Strike()
                                    else
                                        return Us9_Hold()
                                    end
                                elseif v704 ~= nil and v704.tag == "Us8_NoTarget" then
                                    return Us9_Hold()
                                elseif v704 ~= nil and v704.tag == "Us8_OutOfReach" then
                                    local v709 = v41 >= v1
                                    if v709 then
                                        return Us9_Approach()
                                    else
                                        return Us9_Hold()
                                    end
                                end
                            end
                            local v716 = getv716()
                            local getv719 = function()
                                if v716 ~= nil and v716.tag == "Us9_Approach" then
                                    return 2
                                elseif v716 ~= nil and v716.tag == "Us9_Hold" then
                                    return 0
                                elseif v716 ~= nil and v716.tag == "Us9_Strike" then
                                    return 1
                                end
                            end
                            local v719 = getv719()
                            local v720 = v719 == 1
                            local getv722 = function()
                                if v720 then
                                    return true
                                else
                                    local v721 = v719 == 2
                                    return v721
                                end
                            end
                            local v722 = getv722()
                            if v722 then
                                local v723 = v719 == 2
                                local v724 = g_game.getChaseMode() == ChaseOpponent
                                local v725 = v724 ~= v723
                                if v725 then
                                    local getv728 = function()
                                        if v723 then
                                            local v726 = "on"
                                            return v726
                                        else
                                            local v727 = "off"
                                            return v727
                                        end
                                    end
                                    local v728 = getv728()
                                    local v729 = g_clock.millis()
                                    local v730 = v6 ~= nil and v6.l0
                                    local v731 = spiral_wrap_signed((v729 - v730), 32)
                                    local v732 = "chase "
                                    local v733 = v732 .. v728 
                                    local v734 = " @t+"
                                    local v735 = v733 .. v734 
                                    local v736 = format_real_11(v731)
                                    local v737 = v735 .. v736 
                                    local v738 = "[tibia-probe] "
                                    local v739 = v738 .. v737 
                                    write_log_line_9(v739)
                                else
                                end
                                chasing_17(v723)
                                if v148 ~= nil and v148.tag == "Us5_None" then
                                elseif v148 ~= nil and v148.tag == "Us5_Some" then
                                    local v740 = v148._1
                                    local v741 = v148._2
                                    local v742 = (v112)[v740]
                                    local v743 = g_game.getAttackingCreature()
                                    local v744 = (v743) == (v742)
                                    local v745 = v744 == false
                                    if v745 then
                                        g_game.attack(v742)
                                        remember_54(v8, v742)
                                        local getv748 = function()
                                            if v723 then
                                                local v746 = "approach"
                                                return v746
                                            else
                                                local v747 = "strike"
                                                return v747
                                            end
                                        end
                                        local v748 = getv748()
                                        local v749 = (v742):getName()
                                        local v750 = " "
                                        local v751 = v748 .. v750 
                                        local v752 = v751 .. v749 
                                        local v753 = (v742):getPosition()
                                        local v754 = v753.x
                                        local v755 = v753.y
                                        local v756 = v753.z
                                        local v757 = format_real_11(v754)
                                        local v758 = ""
                                        local v759 = v758 .. v757 
                                        local v760 = ","
                                        local v761 = v759 .. v760 
                                        local v762 = format_real_11(v755)
                                        local v763 = v761 .. v762 
                                        local v764 = v763 .. v760 
                                        local v765 = format_real_11(v756)
                                        local v766 = v764 .. v765 
                                        local v767 = " at "
                                        local v768 = v767 .. v766 
                                        local v769 = " from "
                                        local v770 = v768 .. v769 
                                        local v771 = format_real_11(v109)
                                        local v772 = v758 .. v771 
                                        local v773 = v772 .. v760 
                                        local v774 = format_real_11(v110)
                                        local v775 = v773 .. v774 
                                        local v776 = v775 .. v760 
                                        local v777 = format_real_11(v111)
                                        local v778 = v776 .. v777 
                                        local v779 = v770 .. v778 
                                        local v780 = v752 .. v779 
                                        local v781 = g_clock.millis()
                                        local v782 = v6 ~= nil and v6.l0
                                        local v783 = spiral_wrap_signed((v781 - v782), 32)
                                        local v784 = " health "
                                        local v785 = v780 .. v784 
                                        local v786 = format_real_11(v41)
                                        local v787 = v785 .. v786 
                                        local v788 = " @t+"
                                        local v789 = v787 .. v788 
                                        local v790 = format_real_11(v783)
                                        local v791 = v789 .. v790 
                                        local v792 = "[tibia-probe] "
                                        local v793 = v792 .. v791 
                                        write_log_line_9(v793)
                                    else
                                    end
                                end
                                local v794 = spiral_wrap_signed((v687 + 1), 32)
                                return { [1]=v685, [2]=v686, [3]=v794, [4]=v688, [5]=v689, [6]=v690, [7]=v691, [8]=v692, [9]=v693, [10]=v694, [11]=v695 }
                            else
                                local v795 = g_game.isAttacking()
                                local getv806 = function()
                                    if v795 then
                                        local getv804 = function()
                                            if v148 ~= nil and v148.tag == "Us5_None" then
                                                return Us8_NoTarget()
                                            elseif v148 ~= nil and v148.tag == "Us5_Some" then
                                                local v796 = v148._1
                                                local v797 = v148._2
                                                local v798 = v797 <= 1
                                                if v798 then
                                                    return Us8_InReach()
                                                else
                                                    return Us8_OutOfReach()
                                                end
                                            end
                                        end
                                        local v804 = getv804()
                                        if v804 ~= nil and v804.tag == "Us8_InReach" then
                                            return true
                                        else
                                            return false
                                        end
                                    else
                                        return false
                                    end
                                end
                                local v806 = getv806()
                                if v806 then
                                    g_game.cancelAttack()
                                    local v807 = format_real_11(v41)
                                    local v808 = "hold at health "
                                    local v809 = v808 .. v807 
                                    local v810 = "[tibia-probe] "
                                    local v811 = v810 .. v809 
                                    write_log_line_9(v811)
                                else
                                end
                                local v812 = spiral_wrap_signed((v688 + 1), 32)
                                return { [1]=v685, [2]=v686, [3]=v687, [4]=v812, [5]=v689, [6]=v690, [7]=v691, [8]=v692, [9]=v693, [10]=v694, [11]=v695 }
                            end
                        end
                    end
                end
                local v835, v836, v837, v838, v839, v840, v841, v842, v843, v844, v845 = (table.unpack or unpack)(getv835())
                local v846 = math.fmod(v835, 10)
                local v847 = v846 == 0
                if v847 then
                    local v848 = g_game.getLocalPlayer():getPosition()
                    local v849 = v848.x
                    local v850 = v848.y
                    local v851 = v848.z
                    local v852 = format_real_11(v849)
                    local v853 = "seen at "
                    local v854 = v853 .. v852 
                    local v855 = ","
                    local v856 = v854 .. v855 
                    local v857 = format_real_11(v850)
                    local v858 = v856 .. v857 
                    local v859 = ": "
                    local v860 = v858 .. v859 
                    local v861 = monsters_described_56(v849, v850, v851)
                    local v862 = v860 .. v861 
                    local v863 = "[tibia-probe] "
                    local v864 = v863 .. v862 
                    write_log_line_9(v864)
                else
                end
                local v865 = math.fmod(v835, 100)
                local v866 = v865 == 0
                if v866 then
                    local v867 = attacking_described_59()
                    local v868 = g_game.getLocalPlayer():getPosition()
                    local v869 = v868.x
                    local v870 = v868.y
                    local v871 = v868.z
                    local v872 = format_real_11(v869)
                    local v873 = ""
                    local v874 = v873 .. v872 
                    local v875 = ","
                    local v876 = v874 .. v875 
                    local v877 = format_real_11(v870)
                    local v878 = v876 .. v877 
                    local v879 = v878 .. v875 
                    local v880 = format_real_11(v871)
                    local v881 = v879 .. v880 
                    local v882 = player_zone_60()
                    local v883 = " attacking "
                    local v884 = v883 .. v867 
                    local v885 = " player at "
                    local v886 = v884 .. v885 
                    local v887 = v886 .. v881 
                    local v888 = " pz "
                    local v889 = v887 .. v888 
                    local v890 = v889 .. v882 
                    local v891 = g_game.getLocalPlayer():getHealth()
                    local v892 = g_game.getLocalPlayer():getExperience()
                    local v893 = spiral_wrap_signed((v892 - v5), 32)
                    local v894 = format_real_11(v835)
                    local v895 = "ticks "
                    local v896 = v895 .. v894 
                    local v897 = " heals "
                    local v898 = v896 .. v897 
                    local v899 = format_real_11(v836)
                    local v900 = v898 .. v899 
                    local v901 = " strikes "
                    local v902 = v900 .. v901 
                    local v903 = format_real_11(v837)
                    local v904 = v902 .. v903 
                    local v905 = " holds "
                    local v906 = v904 .. v905 
                    local v907 = format_real_11(v838)
                    local v908 = v906 .. v907 
                    local v909 = format_real_11(v840)
                    local v910 = " retreats "
                    local v911 = v910 .. v909 
                    local v912 = " cornered "
                    local v913 = v911 .. v912 
                    local v914 = format_real_11(v841)
                    local v915 = v913 .. v914 
                    local v916 = " gated "
                    local v917 = v915 .. v916 
                    local v918 = format_real_11(v842)
                    local v919 = v917 .. v918 
                    local v920 = " kills "
                    local v921 = v919 .. v920 
                    local v922 = format_real_11(v839)
                    local v923 = v921 .. v922 
                    local v924 = v908 .. v923 
                    local v925 = format_real_11(v891)
                    local v926 = " health "
                    local v927 = v926 .. v925 
                    local v928 = " lowest "
                    local v929 = v927 .. v928 
                    local v930 = format_real_11(v843)
                    local v931 = v929 .. v930 
                    local v932 = " experience +"
                    local v933 = v931 .. v932 
                    local v934 = format_real_11(v893)
                    local v935 = v933 .. v934 
                    local v936 = v924 .. v935 
                    local v937 = v936 .. v890 
                    local v938 = "[tibia-probe] "
                    local v939 = v938 .. v937 
                    write_log_line_9(v939)
                else
                end
                return Us4_Some(v835, v836, v837, v838, v839, v840, v841, v842, v843, v844, v845)
            end
        end
    end
    local v942 = getv942()
    if v942 ~= nil and v942.tag == "Us4_None" then
        return nil
    elseif v942 ~= nil and v942.tag == "Us4_Some" then
        local v943 = v942._1
        local v944 = v942._2
        local v945 = v942._3
        local v946 = v942._4
        local v947 = v942._5
        local v948 = v942._6
        local v949 = v942._7
        local v950 = v942._8
        local v951 = v942._9
        local v952 = v942._10
        local v953 = v942._11
        local v954 = g_clock.millis()
        local v955 = v6 ~= nil and v6.l0
        local v956 = spiral_wrap_signed((v954 - v955), 32)
        local v957 = "TIBIA_ARENA_RUN_MS"
        local v958 = 150000
        local v959 = env_i32_0(v957, v958)
        local v960 = v956 > v959
        if v960 then
            local v961 = g_game.getLocalPlayer():getHealth()
            local v962 = g_game.getLocalPlayer():getExperience()
            local v963 = spiral_wrap_signed((v962 - v5), 32)
            local v964 = format_real_11(v943)
            local v965 = "ticks "
            local v966 = v965 .. v964 
            local v967 = " heals "
            local v968 = v966 .. v967 
            local v969 = format_real_11(v944)
            local v970 = v968 .. v969 
            local v971 = " strikes "
            local v972 = v970 .. v971 
            local v973 = format_real_11(v945)
            local v974 = v972 .. v973 
            local v975 = " holds "
            local v976 = v974 .. v975 
            local v977 = format_real_11(v946)
            local v978 = v976 .. v977 
            local v979 = format_real_11(v948)
            local v980 = " retreats "
            local v981 = v980 .. v979 
            local v982 = " cornered "
            local v983 = v981 .. v982 
            local v984 = format_real_11(v949)
            local v985 = v983 .. v984 
            local v986 = " gated "
            local v987 = v985 .. v986 
            local v988 = format_real_11(v950)
            local v989 = v987 .. v988 
            local v990 = " kills "
            local v991 = v989 .. v990 
            local v992 = format_real_11(v947)
            local v993 = v991 .. v992 
            local v994 = v978 .. v993 
            local v995 = format_real_11(v961)
            local v996 = " health "
            local v997 = v996 .. v995 
            local v998 = " lowest "
            local v999 = v997 .. v998 
            local v1000 = format_real_11(v951)
            local v1001 = v999 .. v1000 
            local v1002 = " experience +"
            local v1003 = v1001 .. v1002 
            local v1004 = format_real_11(v963)
            local v1005 = v1003 .. v1004 
            local v1006 = v994 .. v1005 
            local v1007 = "end: "
            local v1008 = v1007 .. v1006 
            local v1009 = "[tibia-probe] "
            local v1010 = v1009 .. v1008 
            write_log_line_9(v1010)
            local v1011 = parity_summary_19()
            local v1012 = v1011 ~= ""
            if v1012 then
                local v1013 = v1009 .. v1011 
                write_log_line_9(v1013)
            else
            end
            local v1014 = "finish: "
            local v1015 = "run complete"
            local v1016 = v1014 .. v1015 
            local v1017 = v1009 .. v1016 
            write_log_line_9(v1017)
            local v1018 = g_game.isOnline()
            if v1018 then
                g_game.safeLogout()
            else
            end
            local v1019 = closure3(nil)
            scheduleEvent(v1019, 2000)
            return nil
        else
            local v1020 = g_game.getLocalPlayer():getExperience()
            local v1021 = spiral_wrap_signed((v1020 - v5), 32)
            local v1022 = v1021 >= v7
            if v1022 then
                local v1023 = g_clock.millis()
                local v1024 = v6 ~= nil and v6.l0
                local v1025 = spiral_wrap_signed((v1023 - v1024), 32)
                local v1026 = format_real_11(v1025)
                local v1027 = "cleared at "
                local v1028 = v1027 .. v1026 
                local v1029 = " ms"
                local v1030 = v1028 .. v1029 
                local v1031 = "[tibia-probe] "
                local v1032 = v1031 .. v1030 
                write_log_line_9(v1032)
                local v1033 = g_game.getLocalPlayer():getHealth()
                local v1034 = g_game.getLocalPlayer():getExperience()
                local v1035 = spiral_wrap_signed((v1034 - v5), 32)
                local v1036 = format_real_11(v943)
                local v1037 = "ticks "
                local v1038 = v1037 .. v1036 
                local v1039 = " heals "
                local v1040 = v1038 .. v1039 
                local v1041 = format_real_11(v944)
                local v1042 = v1040 .. v1041 
                local v1043 = " strikes "
                local v1044 = v1042 .. v1043 
                local v1045 = format_real_11(v945)
                local v1046 = v1044 .. v1045 
                local v1047 = " holds "
                local v1048 = v1046 .. v1047 
                local v1049 = format_real_11(v946)
                local v1050 = v1048 .. v1049 
                local v1051 = format_real_11(v948)
                local v1052 = " retreats "
                local v1053 = v1052 .. v1051 
                local v1054 = " cornered "
                local v1055 = v1053 .. v1054 
                local v1056 = format_real_11(v949)
                local v1057 = v1055 .. v1056 
                local v1058 = " gated "
                local v1059 = v1057 .. v1058 
                local v1060 = format_real_11(v950)
                local v1061 = v1059 .. v1060 
                local v1062 = " kills "
                local v1063 = v1061 .. v1062 
                local v1064 = format_real_11(v947)
                local v1065 = v1063 .. v1064 
                local v1066 = v1050 .. v1065 
                local v1067 = format_real_11(v1033)
                local v1068 = " health "
                local v1069 = v1068 .. v1067 
                local v1070 = " lowest "
                local v1071 = v1069 .. v1070 
                local v1072 = format_real_11(v951)
                local v1073 = v1071 .. v1072 
                local v1074 = " experience +"
                local v1075 = v1073 .. v1074 
                local v1076 = format_real_11(v1035)
                local v1077 = v1075 .. v1076 
                local v1078 = v1066 .. v1077 
                local v1079 = "cleared: "
                local v1080 = v1079 .. v1078 
                local v1081 = v1031 .. v1080 
                write_log_line_9(v1081)
                if v10 then
                    local v1082 = v11 ~= nil and v11.l0
                    local v1083 = v12 ~= nil and v12.l0
                    local v1084 = format_real_11(v1082)
                    local v1085 = "adjacency: "
                    local v1086 = v1085 .. v1084 
                    local v1087 = " monster-ms adjacent, "
                    local v1088 = v1086 .. v1087 
                    local v1089 = format_real_11(v1083)
                    local v1090 = v1088 .. v1089 
                    local v1091 = " landed hits, "
                    local v1092 = v1090 .. v1091 
                    local v1093 = v1083
                    local v1094 = (v1093 * 1000.0)
                    local v1095 = v1082 > 1
                    local getv1096 = function()
                        if v1095 then
                            return v1082
                        else
                            return 1
                        end
                    end
                    local v1096 = getv1096()
                    local v1097 = v1096
                    local v1098 = v1094 / v1097
                    local v1099 = string.format("%." .. 3 .. "f", v1098)
                    local v1100 = v1092 .. v1099 
                    local v1101 = " landed hits per adjacent monster-second"
                    local v1102 = v1100 .. v1101 
                    local v1103 = v1031 .. v1102 
                    write_log_line_9(v1103)
                    local v1104 = (v14)[(0)+1]
                    local v1105 = (v14)[(1)+1]
                    local v1106 = (v14)[(2)+1]
                    local v1107 = (v14)[(3)+1]
                    local v1108 = format_real_11(v1104)
                    local v1109 = "adjacent time by count: 0 "
                    local v1110 = v1109 .. v1108 
                    local v1111 = " 1 "
                    local v1112 = v1110 .. v1111 
                    local v1113 = format_real_11(v1105)
                    local v1114 = v1112 .. v1113 
                    local v1115 = " 2 "
                    local v1116 = v1114 .. v1115 
                    local v1117 = format_real_11(v1106)
                    local v1118 = v1116 .. v1117 
                    local v1119 = " 3 "
                    local v1120 = v1118 .. v1119 
                    local v1121 = format_real_11(v1107)
                    local v1122 = v1120 .. v1121 
                    local v1123 = v1122 .. v1029 
                    local v1124 = v1031 .. v1123 
                    write_log_line_9(v1124)
                else
                end
                local v1125 = parity_summary_19()
                local v1126 = v1125 ~= ""
                if v1126 then
                    local v1127 = v1031 .. v1125 
                    write_log_line_9(v1127)
                else
                end
                local v1128 = "finish: "
                local v1129 = "cleared"
                local v1130 = v1128 .. v1129 
                local v1131 = v1031 .. v1130 
                write_log_line_9(v1131)
                local v1132 = g_game.isOnline()
                if v1132 then
                    g_game.safeLogout()
                else
                end
                local v1133 = closure3(nil)
                scheduleEvent(v1133, 2000)
                return nil
            else
                local v1134 = closure12({ v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v952, v953, v943, v944, v945, v946, v947, v948, v949, v950, v951 })
                scheduleEvent(v1134, 100)
                return nil
            end
        end
    end
end

function closure11(capt)
    local v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15 = (table.unpack or unpack)(capt)
    return function(dom)
        local v16 = g_game.getLocalPlayer():getPosition()
        local v17 = v16.x
        local v18 = v16.y
        local v19 = v16.z
        local v20 = format_real_11(v17)
        local v21 = ""
        local v22 = v21 .. v20 
        local v23 = ","
        local v24 = v22 .. v23 
        local v25 = format_real_11(v18)
        local v26 = v24 .. v25 
        local v27 = v26 .. v23 
        local v28 = format_real_11(v19)
        local v29 = v27 .. v28 
        local v30 = "policy starts at "
        local v31 = v30 .. v29 
        local v32 = format_real_11(v0)
        local v33 = " thresholds heal<"
        local v34 = v33 .. v32 
        local v35 = " strike>="
        local v36 = v34 .. v35 
        local v37 = format_real_11(v1)
        local v38 = v36 .. v37 
        local v39 = " kite at "
        local v40 = v38 .. v39 
        local v41 = format_real_11(v3)
        local v42 = v40 .. v41 
        local v43 = " retreat at "
        local v44 = v42 .. v43 
        local v45 = format_real_11(v2)
        local v46 = v44 .. v45 
        local v47 = v31 .. v46 
        local v48 = "TIBIA_ARENA_TARGETING"
        local v49 = "current"
        local v50 = env_text_4(v48, v49)
        local v51 = os.time()
        local v52 = " targeting "
        local v53 = v47 .. v52 
        local v54 = v53 .. v50 
        local v55 = " wall "
        local v56 = v54 .. v55 
        local v57 = format_real_11(v51)
        local v58 = v56 .. v57 
        local v59 = "[tibia-probe] "
        local v60 = v59 .. v58 
        write_log_line_9(v60)
        local v61 = g_clock.millis()
        v5.l0 = v61
        local v62 = "TIBIA_ARENA_FULL_EXPERIENCE"
        local v63 = 90
        local v64 = env_i32_0(v62, v63)
        local v65 = 0
        local v66 = 0
        local v67 = 0
        local v68 = 0
        local v69 = 0
        local v70 = 0
        local v71 = 0
        local v72 = 0
        local v73 = 999
        local v74 = -1000
        local v75 = 0
        return ticked_18(v0, v1, v2, v3, v4, v15, v5, v64, v9, v6, v10, v11, v12, v13, v14, v65, v66, v67, v68, v69, v70, v71, v72, v73, v74, v75)
    end
end

function closure10(capt)
    local v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14 = (table.unpack or unpack)(capt)
    return function(dom)
        local v15 = g_game.getLocalPlayer():getExperience()
        local v16 = false
        chasing_17(v16)
        g_game.setFightMode(FightBalanced)
        local v17 = closure11({ v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15 })
        scheduleEvent(v17, 1000)
        return nil
    end
end

function closure6(capt)
    local v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14 = (table.unpack or unpack)(capt)
    return function(dom)
        local v15 = g_game.getLocalPlayer():getName()
        local v16 = g_game.getLocalPlayer():getHealth()
        local v17 = g_game.getLocalPlayer():getMana()
        local v18 = "in game as "
        local v19 = v18 .. v15 
        local v20 = " health "
        local v21 = v19 .. v20 
        local v22 = format_real_11(v16)
        local v23 = v21 .. v22 
        local v24 = " mana "
        local v25 = v23 .. v24 
        local v26 = format_real_11(v17)
        local v27 = v25 .. v26 
        local v28 = "[tibia-probe] "
        local v29 = v28 .. v27 
        write_log_line_9(v29)
        local v30 = g_clock.millis()
        v8.l0 = v30
        local v31 = closure7({ v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14 })
        on_position_change_16(v31)
        local v32 = closure10({ v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14 })
        scheduleEvent(v32, 1500)
        return nil
    end
end

function closure13(capt)
    local v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31 = (table.unpack or unpack)(capt)
    return function(dom)
        return poll_7(v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31)
    end
end

function poll_7(v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31)
    local v32 = v0 == ""
    local getv34 = function()
        if v32 then
            return true
        else
            return file_exists_8(v0)
        end
    end
    local v34 = getv34()
    if v34 then
        g_game.setClientVersion(1511)
        g_game.setProtocolVersion(g_game.getClientProtocolVersion(1511))
        g_game.chooseRsa("127.0.0.1")
        local v35 = typed_c2(nil)
        local v36 = function(message) (v35)(message) end
        local v37 = typed_c4({ v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16 })
        local v38 = function(mode, text) (v37)(mode)(text) end
        local v39 = closure6({ v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31 })
        connect(g_game, { onGameStart = v39, onLoginError = v36, onTextMessage = v38 })
        local v40 = "@god"
        local v41 = "@god\ngod"
        g_game.loginWorld(v40, "god", "OTServBR-Global", "127.0.0.1", 7172, v1, "", v41)
        return nil
    else
        local v42 = closure13({ v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31 })
        scheduleEvent(v42, 50)
        return nil
    end
end

function closure1(capt)
    local v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30 = (table.unpack or unpack)(capt)
    return function(dom)
        local v31 = "TIBIA_LOGIN_GATE"
        local v32 = ""
        local v33 = env_text_4(v31, v32)
        return poll_7(v33, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30)
    end
end

function closure14(capt)
    return function(dom)
        local v0 = parity_summary_19()
        local v1 = v0 ~= ""
        if v1 then
            local v2 = "[tibia-probe] "
            local v3 = v2 .. v0 
            write_log_line_9(v3)
        else
        end
        local v4 = "finish: "
        local v5 = "timeout"
        local v6 = v4 .. v5 
        local v7 = "[tibia-probe] "
        local v8 = v7 .. v6 
        write_log_line_9(v8)
        local v9 = g_game.isOnline()
        if v9 then
            g_game.safeLogout()
        else
        end
        local v10 = closure3(nil)
        scheduleEvent(v10, 2000)
        return nil
    end
end

local v0 = "TIBIA_ARENA_HEAL_BELOW"
local v1 = 120
local v2 = env_i32_0(v0, v1)
local v3 = "TIBIA_ARENA_STRIKE_ABOVE"
local v4 = 40
local v5 = env_i32_0(v3, v4)
local v6 = "TIBIA_ARENA_RETREAT_AT"
local v7 = 0
local v8 = env_i32_0(v6, v7)
local v9 = "TIBIA_ARENA_KITE_AT"
local v10 = 0
local v11 = env_i32_0(v9, v10)
local v12 = "TIBIA_ARENA_TARGETING"
local v13 = get_environment_variable_1(v12)
local v14 = v13 == "reach"
local getv17 = function()
    if v14 then
        local v15 = Us1_ReachFirst()
        return { [1]=v2, [2]=v5, [3]=v8, [4]=v11, [5]=v15 }
    else
        local v16 = Us1_CurrentFirst()
        return { [1]=v2, [2]=v5, [3]=v8, [4]=v11, [5]=v16 }
    end
end
local v17, v18, v19, v20, v21 = (table.unpack or unpack)(getv17())
local v22 = { __tag = "Mut0", l0 = 0 }
local v23 = { __tag = "Mut0", l0 = -2000 }
local v24 = { __tag = "Mut0", l0 = 0 }
local v25 = { __tag = "Mut0", l0 = 0 }
local v26 = Uh0_Nil()
local v27 = { __tag = "Mut1", l0 = v26 }
local v28 = "TIBIA_ARENA_ADJACENCY"
local v29 = get_environment_variable_1(v28)
local v30 = v29 == "1"
local v31 = { __tag = "Mut0", l0 = 0 }
local v32 = { __tag = "Mut0", l0 = 0 }
local v33 = { __tag = "Mut0", l0 = -1 }
local v34 = { 0, 0, 0, 0 }
local v35 = "TIBIA_ARENA_RUN_MS"
local v36 = 150000
local v37 = env_i32_0(v35, v36)
local v38 = spiral_wrap_signed((v37 + 50000), 32)
local v39 = "TIBIA_ARENA_CHARACTER"
local v40 = "Knight Sample"
local v41 = env_text_4(v39, v40)
local v42 = "_1511"
local v43 = v41 .. v42 
disable_client_bot_5(v43)
local v44 = env_text_4(v39, v40)
local v45 = "TIBIA_PROBE_HIDDEN"
local v46 = get_environment_variable_1(v45)
local v47 = v46 == "1"
if v47 then
    g_window.move({ x = -32000, y = -32000 })
    g_window.hide()
else
end
mute_6()
local v48 = closure0(nil)
scheduleEvent(v48, 200)
scheduleEvent(v48, 1000)
local v49 = closure1({ v44, v17, v18, v19, v20, v21, v22, v23, v24, v25, v27, v30, v31, v32, v33, v34, v17, v18, v19, v20, v21, v22, v23, v24, v25, v27, v30, v31, v32, v33, v34 })
scheduleEvent(v49, 3000)
local v50 = closure14(nil)
scheduleEvent(v50, v38)
return 0
