feat: bypass host-side look-check by replicating set_tag's accept-branch in a hook (source from Darktide-Source-Code dump: gate is _tagger_is_looking_at_target dot-0.75 cone + LOS sweep inside set_tag/handler; everything after is _generate_tag_id/_create_tag_locally/group-limit/rpc — reproduced verbatim for flagged auto-hack targets, pcall-guarded with vanilla fallback); replaces never-installed spoof attempt

This commit is contained in:
2026-10-03 15:23:52 -04:00
parent ac79578c19
commit 33bdc872b2
@@ -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