From 33bdc872b2729b0b466df56f23075aa726be6d30 Mon Sep 17 00:00:00 2001 From: michael Date: Sat, 3 Oct 2026 15:23:52 -0400 Subject: [PATCH] =?UTF-8?q?feat:=20bypass=20host-side=20look-check=20by=20?= =?UTF-8?q?replicating=20set=5Ftag's=20accept-branch=20in=20a=20hook=20(so?= =?UTF-8?q?urce=20from=20Darktide-Source-Code=20dump:=20gate=20is=20=5Ftag?= =?UTF-8?q?ger=5Fis=5Flooking=5Fat=5Ftarget=20dot-0.75=20cone=20+=20LOS=20?= =?UTF-8?q?sweep=20inside=20set=5Ftag/handler;=20everything=20after=20is?= =?UTF-8?q?=20=5Fgenerate=5Ftag=5Fid/=5Fcreate=5Ftag=5Flocally/group-limit?= =?UTF-8?q?/rpc=20=E2=80=94=20reproduced=20verbatim=20for=20flagged=20auto?= =?UTF-8?q?-hack=20targets,=20pcall-guarded=20with=20vanilla=20fallback);?= =?UTF-8?q?=20replaces=20never-installed=20spoof=20attempt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mods/AutoMark/mark/servo_skull_mark.lua | 80 +++++++++---------- 1 file changed, 40 insertions(+), 40 deletions(-) diff --git a/AutoMark/scripts/mods/AutoMark/mark/servo_skull_mark.lua b/AutoMark/scripts/mods/AutoMark/mark/servo_skull_mark.lua index 5818e84..6f93588 100644 --- a/AutoMark/scripts/mods/AutoMark/mark/servo_skull_mark.lua +++ b/AutoMark/scripts/mods/AutoMark/mark/servo_skull_mark.lua @@ -29,52 +29,52 @@ local Vector3_distance = Vector3.distance local HACK_TAG_NAME = "hacking_over_here_companion" local CANCEL_INTERVAL = 0.5 --- set_tag() for off-LOS units is silently rejected because the game re-validates the tag --- through the target extension's forward-LOS _contextual_tag_template_name(); flag the single --- auto-hack target on its extension so the game's own validation accepts the order. --- the owning class is discovered lazily from a LIVE extension instance (the CLASS registry --- scan at load time found nothing - extension classes aren't in it yet at that point). -local function ensure_automark_spoof_hook() - if mod.omni_hack_spoof_hooked then +-- set_tag() for off-LOS units is silently rejected: as HOST, SmartTagSystem:set_tag() runs +-- _tagger_is_looking_at_target() (dot-0.75 aim cone + LOS sweep, from the game source) and +-- returns before creating the tag. Since we hold the full source of the accept-branch +-- (_generate_tag_id -> _create_tag_locally -> group limit check -> rpc to clients), the hook +-- below reproduces it verbatim, minus the look check, for our flagged auto-hack targets only. +local function ensure_automark_tag_hook() + if mod.omni_hack_tag_hooked then return end local smart_tag_system = context.smart_tag_system - local unit_extension_data = smart_tag_system and smart_tag_system._unit_extension_data - local _, any_ext = unit_extension_data and next(unit_extension_data) - if not any_ext then + if not smart_tag_system then return end - local mt = getmetatable(any_ext) - local cls = mt - if cls and type(cls) == "table" and cls._contextual_tag_template_name == nil then - cls = rawget(cls, "__index") - end - if type(cls) == "table" and cls._contextual_tag_template_name ~= nil then - mod:hook(cls, "_contextual_tag_template_name", function(previous_hook, self, player_unit, tag_name) - if tag_name == "companion_order" and self._automark_hack_order then - return HACK_TAG_NAME - end - return previous_hook(self, player_unit, tag_name) - end) - mod.omni_hack_spoof_hooked = true - mod.omni_hack_spoof_class = "lazy_class" - if mod_settings.debug_mode then - mod:diag("OMNI-HACK-DIAG spoof hook INSTALLED") - end - elseif mod_settings.debug_mode and not mod.omni_hack_spoof_fail_logged then - mod.omni_hack_spoof_fail_logged = true - local method_keys = {} - if type(cls) == "table" then - local seen = 0 - for k, v in pairs(cls) do - if type(k) == "string" and seen < 40 then - method_keys[#method_keys + 1] = k .. ":" .. type(v) - seen = seen + 1 + local cls = getmetatable(smart_tag_system) + if type(cls) == "table" and cls.set_tag ~= nil then + mod:hook(cls, "set_tag", function(previous_hook, self, template_name, tagger_unit, target_unit, target_location) + if template_name == HACK_TAG_NAME and target_unit and self._is_server then + local target_extension = self._unit_extension_data[target_unit] + if target_extension and target_extension._automark_hack_order then + local ok, err = pcall(function() + local tag_id = self:_generate_tag_id() + local tag = self:_create_tag_locally(tag_id, template_name, tagger_unit, target_unit, target_location) + self:_server_check_tag_group_limit(tagger_unit, tag:group()) + local template_name_id = NetworkLookup.smart_tag_templates[template_name] + local tagger_game_object_id = Managers.state.unit_spawner:game_object_id(tagger_unit) + local target_game_object_id = Managers.state.unit_spawner:game_object_id(target_unit) + Managers.state.game_session:send_rpc_clients("rpc_set_smart_tag", tag_id, template_name_id, tagger_game_object_id, target_game_object_id, nil, target_location) + end) + if ok then + return + end + if mod_settings.debug_mode and not mod.omni_hack_taghook_err_logged then + mod.omni_hack_taghook_err_logged = true + mod:diag("OMNI-HACK-DIAG tag-branch replication FAILED:", tostring(err)) + end end end - table.sort(method_keys) + return previous_hook(self, template_name, tagger_unit, target_unit, target_location) + end) + mod.omni_hack_tag_hooked = true + if mod_settings.debug_mode then + mod:diag("OMNI-HACK-DIAG set_tag hook INSTALLED") end - mod:diag("OMNI-HACK-DIAG spoof HOOK FAILED mt=", tostring(mt), " cls=", tostring(cls), " instance_has_method=", tostring(any_ext._contextual_tag_template_name ~= nil), " cls_keys=", table.concat(method_keys, ",")) + elseif mod_settings.debug_mode and not mod.omni_hack_taghook_fail_logged then + mod.omni_hack_taghook_fail_logged = true + mod:diag("OMNI-HACK-DIAG set_tag hook FAILED to locate class, mt=", tostring(cls)) end end @@ -282,7 +282,7 @@ local function find_hackable_target_unit_omni() if not smart_tag_system or not player_unit then return end - ensure_automark_spoof_hook() + ensure_automark_tag_hook() local player_position = Unit_world_position(player_unit, 1) local selected_unit, selected_distance, selected_name, selected_extension @@ -354,7 +354,7 @@ function mod:auto_hack(dt, t, fixed_frame) if hack_check.ttl <= 0 then if mod_settings.debug_mode then local smart_tag_system = context.smart_tag_system - mod:diag(string.format("OMNI-HACK-DIAG tagcheck %s alive=%s tag_applied=%s skull_hacking=%s spoof=%s", tostring(hack_check.n), tostring(HEALTH_ALIVE[hack_check.unit] == true), tostring(smart_tag_system and smart_tag_system:unit_tag(hack_check.unit) ~= nil), tostring(mod:is_servo_skull_hacking()), tostring(mod.omni_hack_spoof_class))) + mod:diag(string.format("OMNI-HACK-DIAG tagcheck %s alive=%s tag_applied=%s skull_hacking=%s hooked=%s", tostring(hack_check.n), tostring(HEALTH_ALIVE[hack_check.unit] == true), tostring(smart_tag_system and smart_tag_system:unit_tag(hack_check.unit) ~= nil), tostring(mod:is_servo_skull_hacking()), tostring(mod.omni_hack_tag_hooked))) end hack_check = nil end