feat: auto-hack is 360-aware — with omni_mark on, pick nearest hackable unit from smart-tag registry instead of crosshair-scoped HUD markers
This commit is contained in:
@@ -21,6 +21,9 @@ local Managers = Managers
|
|||||||
local callback = callback
|
local callback = callback
|
||||||
local get_game_object_field = GameSession.game_object_field
|
local get_game_object_field = GameSession.game_object_field
|
||||||
local ScriptUnit_extension = ScriptUnit.extension
|
local ScriptUnit_extension = ScriptUnit.extension
|
||||||
|
local HEALTH_ALIVE = HEALTH_ALIVE
|
||||||
|
local Unit_world_position = Unit.world_position
|
||||||
|
local Vector3_distance = Vector3.distance
|
||||||
|
|
||||||
local HACK_TAG_NAME = "hacking_over_here_companion"
|
local HACK_TAG_NAME = "hacking_over_here_companion"
|
||||||
local CANCEL_INTERVAL = 0.5
|
local CANCEL_INTERVAL = 0.5
|
||||||
@@ -214,6 +217,30 @@ local find_hackable_target_unit = function()
|
|||||||
return selected_marker_unit, selected_marker_distance
|
return selected_marker_unit, selected_marker_distance
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function find_hackable_target_unit_omni()
|
||||||
|
local smart_tag_system = context.smart_tag_system
|
||||||
|
local player = context.player
|
||||||
|
local player_unit = player and player.player_unit
|
||||||
|
if not smart_tag_system or not player_unit then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local player_position = Unit_world_position(player_unit, 1)
|
||||||
|
local selected_unit, selected_distance
|
||||||
|
for unit, target_extension in pairs(smart_tag_system._unit_extension_data) do
|
||||||
|
if unit ~= player_unit and HEALTH_ALIVE[unit] and target_extension._target_type == "breed" then
|
||||||
|
local template_name = target_extension:_contextual_tag_template_name(player_unit, "companion_order")
|
||||||
|
if template_name == HACK_TAG_NAME then
|
||||||
|
local distance = Vector3_distance(Unit_world_position(unit, 1), player_position)
|
||||||
|
if not selected_distance or distance < selected_distance then
|
||||||
|
selected_unit, selected_distance = unit, distance
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return selected_unit, selected_distance
|
||||||
|
end
|
||||||
|
|
||||||
local hack_interval = 0
|
local hack_interval = 0
|
||||||
function mod:auto_hack(dt, t, fixed_frame)
|
function mod:auto_hack(dt, t, fixed_frame)
|
||||||
if not mod_settings.auto_hack or (mod_settings.disable_auto_hack_for_noospheric_command and context.has_noospheric_command) or context.class_name ~= "cryptic" or not context.has_servo_skull then
|
if not mod_settings.auto_hack or (mod_settings.disable_auto_hack_for_noospheric_command and context.has_noospheric_command) or context.class_name ~= "cryptic" or not context.has_servo_skull then
|
||||||
@@ -240,7 +267,7 @@ function mod:auto_hack(dt, t, fixed_frame)
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local target_unit, _ = find_hackable_target_unit()
|
local target_unit, _ = mod_settings.omni_mark and find_hackable_target_unit_omni() or find_hackable_target_unit()
|
||||||
if not target_unit then
|
if not target_unit then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user