local group = ActorGroup.Monsters -- or ActorGroup.OtherPlayers / ActorGroup.NPCs local fallback_name = "qweqwe" -- name to search when no party-assist target is present while true do local assist_ptr = game.find_party_assist_marked_character(ActorGroup.Monsters) if assist_ptr ~= 0 then -- Ensure we are targeting the assist-marked character local current_target = game.get_player_target() if current_target ~= assist_ptr then actions.set_target(assist_ptr, true) end else -- No party assist: try to find by name and move to that character local found_ptr = game.find_character_by_name(ActorGroup.OtherPlayers, fallback_name) if found_ptr ~= 0 then local coord = game.get_character_coord(found_ptr) if coord ~= nil and coord.x and coord.y and coord.z then local player_coord = game.get_player_coord() if player_coord ~= nil then local dx = player_coord.x - coord.x local dy = player_coord.y - coord.y local dz = player_coord.z - coord.z local distance = math.sqrt(dx * dx + dy * dy + dz * dz) local radius = 75 if distance > radius then -- pick a random offset inside a 50-unit radius local angle = math.random() * math.pi * 2 local dist = math.random() * radius local rx = coord.x + math.cos(angle) * dist local ry = coord.y + math.sin(angle) * dist local rz = coord.z actions.move_player(rx, ry, rz) end end end end end -- If we have any target, auto-attack and use bar action (1,1) local current_target = game.get_player_target() if current_target ~= 0 then actions.click_on_target(current_target) sleep(100) actions.use_bar_action(1, 1) end sleep(100) -- wait 100 ms before checking again end