Files
phantom-gladiator/Mods/PhantomGladiator/Scripts/main.lua
T

3190 lines
179 KiB
Lua
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
-- ============================================================
-- PhantomGladiator — 《影之刃零》斗蛐蛐 Mod (UE4SS Lua)
-- 让 NPC 互相为敌、召唤单位、观战、慢动作、自由镜头。
-- 功能快捷键在面板配置;首次使用全部未绑定。
-- ============================================================
local Config = require("config")
-- Before any module can register one: hooks on blueprints that leave with their map (hook_registry.lua).
local hookRegistry = require("hook_registry").install(_G)
local UEHelpers = require("UEHelpers")
local Session = require("battle_session")
local CombatProbe = require("combat_probe")
local AttackProfile = require("attack_profile")
local Catalog = require("npc_catalog")
local AssetExporter = require("asset_inventory")
local ArenaController = require("arena_controller")
local PanelRuntime = require("panel_runtime")
local SpectatorMode = require("spectator_mode")
local SpawnPolicy = require("spawn_policy")
local RuntimeSession = require("runtime_session")
local SpawnAudit = require("spawn_audit")
local CodexExporter = require("codex_catalog_export")
local SpawnGuard = require("spawn_guard")
local SpawnInspector = require("spawn_inspector")
local WorldMapCatalog = require("world_map_catalog")
local SpawnCatalog = require("spawn_catalog_export")
local ReferenceAudit = require("asset_reference_audit")
local TableCatalog = require("table_catalog_export")
local SummonLinks = require('arena_summon_links')
local BossHUD = require('arena_hud')
local EngineObjectState = require('engine_object_state')
local UEObserve = require('ue_observe')
local UnitKeys = require('unit_keybinds')
local ArenaActivity = require('arena_activity')
local FreeCamera = require('free_camera')
local GrabStudy = require('grab_study')
local ArenaGrabs = require('arena_grabs')
local StatMatch = require('stat_match')
local ObserverGuard = require('observer_guard')
local SpectatorTargets = require('spectator_targets')
local KeyRouter = require('key_router')
local KeyPoll = require('key_poll')
local SpawnDifficulty=require('spawn_difficulty')
local AIDifficulty=require('ai_difficulty')
local Companion=require('companion')
local FunFeatures=require('fun_features')
local SpawnLevel=require('spawn_level')
local StatFormulaProbe=require('stat_formula_probe')
local StatFieldProbe=require('stat_field_probe')
local CompanionHitProbe=require('companion_hit_probe')
local AttackFactionScan=require('attack_faction_scan')
local CodexArtProbe=require('codex_art_probe')
local CodexIcons=require('codex_icons')
local ImmortalTeams=require('immortal_teams')
local BattleClockHUD=require('battle_clock_hud')
local CombatLock=require('combat_lock')
local CompanionBars=require('companion_bars')
local AreaLevels=require('area_levels')
local HomeLevels=require('home_levels')
local Escorts=require('escorts')
local Mounts=require('mounts')
local BossStages=require('boss_stages')
local ArenaExecutions=require('arena_executions')
local ExecutionCamera=require('execution_camera')
local MOD = "[PhantomGladiator]"
local runLogPath=Config.RuntimePath..'/run-'..os.date('%Y%m%d-%H%M%S')..'.log'
local runLogBytes,runLogWarning=0,false
local function log(msg)
local line=string.format('%s %s\n',MOD,tostring(msg))
print(line)
-- UE4SS.log is overwritten on game restart. Preserve bounded per-load UTF-8
-- evidence outside the source tree, without touching game save data.
local durable=os.date('%Y-%m-%d %H:%M:%S')..' '..line
if runLogBytes+#durable>8*1024*1024 then return end
local ok,saved=pcall(function()
local file=io.open(runLogPath,'ab')
if not file then return false end
local wrote=file:write(durable)
local flushed=file:flush()
local closed=file:close()
return wrote~=nil and flushed~=nil and closed~=nil
end)
if ok and saved then runLogBytes=runLogBytes+#durable
elseif not runLogWarning then runLogWarning=true;print(MOD..' 独立运行日志写入未确认;UE4SS日志仍保留\n') end
end
if hookRegistry then hookRegistry.log=log end
local BUILD = "v0.40.25"
SpawnPolicy.loadTrials(Config.RuntimePath..'/spawn-trials.tsv',log)
SpawnPolicy.enableAllCatalog()
log('[SpawnPolicy] 用户开启全部目录尝试召唤;总量不设上限;运行时检查Actor继承和对象有效性')
local function safeValid(obj)
if obj == nil then return false end
local ok, value = pcall(function() return obj:IsValid() end)
return ok and value == true
end
local engineObjectState=EngineObjectState.new({log=log})
local function engineValid(obj)
return safeValid(obj) and engineObjectState:check(obj)~=false
end
UEObserve.setEngineValidator(function(obj) return engineObjectState:check(obj) end)
local function checked(obj)
if not safeValid(obj) then error("object invalid; access refused") end
return obj
end
local function objectName(obj)
if not safeValid(obj) then return "UNKNOWN(invalid)" end
local ok, value = pcall(function() return obj:GetFullName() end)
return ok and tostring(value) or "UNKNOWN(name)"
end
local function actorIsDestroying(actor)
checked(actor)
return actor:IsActorBeingDestroyed()
end
-- A valid wrapper can still point to an Actor already entering destruction.
local function summonActorLive(actor)
local ok,destroying=pcall(actorIsDestroying,actor)
return ok and destroying==false
end
local battle = Session.new(log)
local probeFinished
local probe = CombatProbe.new({log=log, valid=safeValid, config=Config.Probe,
onStop=function(state) if probeFinished then probeFinished(state) end end})
local probeSampleGen = 0
local arenaActors = {}
local spawnRoutes={}
local arena
local panelRuntime
local spectator
local bossHUD
local arenaActivity
local arenaGrabs
local statMatch
local spawnDifficulty
local spawnLevel
local statProbe
local fieldProbe
local companionHitProbe
local attackScan
local codexArt
local codexIcons
local companions
local aiDifficulty
local funFeatures
local immortalTeams
local clockHUD
local combatLock
local playerAim
local aiParams
local bossCombos
local fightWatch
local onGround
local arenaExecutions
local executionCamera
local mounts
local arenaSupport={}
local bossStages
local BeginArenaObservation
local spawnAudit=SpawnAudit.new(Config.RuntimePath.."/spawn-attempts.tsv",log)
local spawnGuard=SpawnGuard.new()
local spawnInspector=SpawnInspector.new({log=log,canSpawn=SpawnPolicy.check})
local function FNameToString(v)
local ok, s = pcall(function() return v:ToString() end)
if ok and s then return s end
return tostring(v)
end
-- ---------- 基础工具 ----------
function arenaSupport:viewportWorld()
if type(UEHelpers.GetGameViewportClient)~='function' then return nil end
local ok,viewport=pcall(UEHelpers.GetGameViewportClient)
if not ok or not safeValid(viewport) then return nil end
local world=UEObserve.field(viewport,'World')
return safeValid(world) and world or nil
end
function arenaSupport:controllerCurrent(pc,world)
local player=UEObserve.field(pc,'Player')
local owner=UEObserve.field(player,'PlayerController')
local key=UEObserve.key(pc)
if not key or UEObserve.key(owner)~=key then return false end
if type(UEHelpers.GetGameViewportClient)=='function' then
local ok,viewport=pcall(UEHelpers.GetGameViewportClient)
if ok and safeValid(viewport) then
if not safeValid(UEObserve.field(viewport,'World')) then return false end
local players=UEObserve.array(UEObserve.field(UEObserve.field(viewport,'GameInstance'),'LocalPlayers'))
if not players then return false end
local found=false
for _,current in ipairs(players)do if UEObserve.key(current)==UEObserve.key(player) then found=true;break end end
if not found then return false end
end
end
if safeValid(world) then
local ok,current=pcall(function()return pc:GetWorld()end)
if not ok or UEObserve.key(current)~=UEObserve.key(world) then return false end
end
return true
end
-- A retained controller can remain valid after its local player has moved to another controller/world.
local function GetRealPlayerController()
local world=arenaSupport:viewportWorld()
local function current(pc)
local okP, good = pcall(function()
if not safeValid(pc) then return false end
local cls = pc:GetClass()
if not safeValid(cls) or objectName(cls):find("DebugCameraController") then return false end
return arenaSupport:controllerCurrent(pc,world)
end)
return okP and good
end
-- Resolve the viewport's current local players afresh; no controller survives here across calls/worlds.
if type(UEHelpers.GetGameViewportClient)=='function' then
local ok,viewport=pcall(UEHelpers.GetGameViewportClient)
if ok and safeValid(viewport) and not safeValid(world) then return nil end
if ok and safeValid(viewport) then
local instance=UEObserve.field(viewport,'GameInstance')
for _,player in ipairs(UEObserve.array(UEObserve.field(instance,'LocalPlayers')) or {})do
local pc=UEObserve.field(player,'PlayerController')
if current(pc) then return pc end
end
return nil
end
end
local ok,list=pcall(FindAllOf,'PlayerController')
if not ok then return nil end
for _,pc in ipairs(UEObserve.array(list) or {})do
if current(pc) then return pc end
end
return nil
end
local function GetCurrentWorld()
local world=arenaSupport:viewportWorld()
if world then return world end
local pc=GetRealPlayerController()
if not safeValid(pc) then return nil end
local ok,current=pcall(function()return pc:GetWorld()end)
return ok and safeValid(current) and current or nil
end
local function GetPlayerPawn()
local pc = GetRealPlayerController()
local pawn=UEObserve.field(pc,'Pawn')
if not summonActorLive(pawn) then return nil end
local world=GetCurrentWorld()
local ok,actual=pcall(function()return pawn:GetWorld()end)
if ok and safeValid(world) and UEObserve.key(actual)==UEObserve.key(world) then return pawn end
return nil
end
local function GetLocation(actor)
if not safeValid(actor) then return nil end
local ok, loc = pcall(function() return actor:K2_GetActorLocation() end)
if ok and loc then return loc end
return nil
end
function arenaSupport:pointText(point)
local ok,x,y,z=pcall(function()return point.X,point.Y,point.Z end)
if not ok or type(x)~='number' or type(y)~='number' or type(z)~='number' then return '?' end
return string.format('%.1f,%.1f,%.1f',x,y,z)
end
function arenaSupport:spawnSpace(actor,transform,world)
local ok,actualWorld=pcall(function()return actor:GetWorld()end)
local match='unknown'
if ok and safeValid(actualWorld) then match=UEObserve.key(actualWorld)==UEObserve.key(world) end
local mesh=UEObserve.field(actor,'Mesh')
return string.format('requested=%s actual=%s world_match=%s hidden=%s mesh_visible=%s',
self:pointText(transform and transform.Translation),self:pointText(GetLocation(actor)),tostring(match),
tostring(UEObserve.field(actor,'bHidden')),tostring(UEObserve.field(mesh,'bVisible')))
end
-- World time in seconds (stops while the game is paused, follows slow motion); nil before a world exists.
local gameplayStatics
local function GameSeconds()
if not safeValid(gameplayStatics) then gameplayStatics=StaticFindObject('/Script/Engine.Default__GameplayStatics') end
local world=GetCurrentWorld()
if not safeValid(gameplayStatics) or not safeValid(world) then return nil end
local ok,seconds=pcall(function()return gameplayStatics:GetTimeSeconds(world)end)
return ok and type(seconds)=='number' and seconds or nil
end
local function DistSq(a, b)
local dx, dy, dz = a.X - b.X, a.Y - b.Y, a.Z - b.Z
return dx * dx + dy * dy + dz * dz
end
local function IsExcluded(pawn)
if not safeValid(pawn) then return true end
local ok, name = pcall(function() return pawn:GetFullName() end)
if not ok or not name then return true end
for _, kw in ipairs(Config.ExcludeClassKeywords) do
if name:find(kw) then return true end
end
return false
end
local function GetGameplayStatics()
local gps = StaticFindObject("/Script/Engine.Default__GameplayStatics")
if gps and gps:IsValid() then return gps end
return nil
end
local playerNeutral = false
local dilationIndex = 1
-- 旧态度返回值修改已移除。脚本态度函数由 CombatProbe 正确注册只读回调。
-- 单位类型目录与活怪列表分开;已知路径及选择跨热重载保存。
local npcCatalog=Catalog.new({log=log,valid=safeValid,getPlayer=GetPlayerPawn,
path=Config.CatalogPath,knownPaths=Config.KnownMonsterClasses,canSpawn=SpawnPolicy.check,allowActors=true,
audit=function(stage,unit,detail) return spawnAudit:record(stage,unit,detail) end})
local exporter=AssetExporter.new({log=log,path=Config.RuntimePath,
config=Config.AssetCatalog})
local worldMaps=WorldMapCatalog.new({log=log,getWorld=GetCurrentWorld})
local codexExporter=CodexExporter.new({log=log,path=Config.RuntimePath.."/codex.tsv",getWorld=GetCurrentWorld,
locationsPath=Config.RuntimePath..'/codex-locations.tsv',
maps=worldMaps,onWritten=function()if bossHUD then bossHUD:reloadCodex()end end})
-- ---------- 强制锁敌:走 SGameAI 自家的作战指令 ----------
-- SGameAIComponent:ForceIntoCombat(Target) = "进入战斗,目标是他";
-- 另把目标写进 AI 的黑板目标键(PBZ_TargetingHandler_AI 从那里读目标)做双保险。
local function GetAIComp(pawn)
if not safeValid(pawn) then return nil end
local ok, sg = pcall(function()
local ctrl = pawn.Controller
if not ctrl or not ctrl:IsValid() then return nil end
local c = ctrl.SGameAIComponent
return (c ~= nil and c:IsValid()) and c or nil
end)
if ok then return sg end
return nil
end
-- 本作的原生仇恨组件(挂在每个 NPC/玩家身上,感知与索敌都以它为准)
local function GetHatredComp(pawn)
if not safeValid(pawn) then return nil end
local ok, h = pcall(function() return pawn.BP_PBZHatredManagerComponent end)
if ok and h ~= nil then
local okV, v = pcall(function() return h:IsValid() end)
if okV and v then return h end
end
return nil
end
local function HatredListContains(hm, actor)
if not safeValid(hm) or not safeValid(actor) then return nil end
local found, unreadable = false, false
local ok = pcall(function()
local hl = hm.HatredList
local addr = actor:GetAddress()
for i = 1, #hl do
local okE, hit = pcall(function()
local entry = hl[i]
return safeValid(entry) and entry:GetAddress() == addr
end)
if not okE then unreadable = true end
if okE and hit then found = true; return end
end
end)
if found then return true end
if not ok or unreadable then return nil end
return false
end
function arenaSupport:rememberHatred(hm,victim)
-- A record whose objects are gone has nothing left to put back, whoever's unit it was. Kept, it would hold up every
-- later cleanup and summon: an adopted summon is engaged before the arena registers it as its own.
battle:remember("hatred:" .. hm:GetAddress() .. ":" .. victim:GetAddress(), function()
if not engineValid(hm) or not engineValid(victim) then
return true,"参赛对象有效性读回=false,目标已不存在;丢弃过期成员记录"
end
checked(hm); checked(victim)
hm:RemoveActorFromHatredList(victim)
local has = HatredListContains(hm, victim)
return has == false, "成员读回=" .. tostring(has)
end)
end
local function AddHatred(attacker, victim)
local hm = GetHatredComp(attacker)
if not hm or not safeValid(victim) then return false, "对象无效" end
local before = HatredListContains(hm, victim)
if before == nil then return false, "成员读取失败" end
if before then return true, "原本存在" end
arenaSupport:rememberHatred(hm,victim)
local ok, err = pcall(function() hm:AddActorToHatredList(victim, false) end)
local has = HatredListContains(hm, victim)
-- 仅对本Mod创建的两名参赛者保留历史已观察到出招的数组配对路径。
local ownA,ownB=false,false
for _,actor in ipairs(arenaActors) do
if safeValid(actor) then
ownA=ownA or actor:GetAddress()==attacker:GetAddress()
ownB=ownB or actor:GetAddress()==victim:GetAddress()
end
end
-- A rider's mount carries the fight for its rider (mounts.lua).
if mounts and mounts:holds(attacker) then ownA=true end
if not has and ownA and ownB then
local wrote=pcall(function()
checked(hm); checked(victim)
local list=hm.HatredList
list[#list+1]=victim
end)
has=HatredListContains(hm,victim)
log("参赛者配对数组写入=" .. tostring(wrote) .. ";成员读回=" .. tostring(has))
return wrote and has==true,"参赛者数组配对(官方门禁尚未修复)"
end
log("官方Add调用=" .. tostring(ok) .. ";成员读回=" .. tostring(has))
return ok and has == true, ok and (has and "官方Add读回存在" or "官方Add未接纳") or tostring(err)
end
-- ---------- 原生阵营系统 ----------
-- NPC 和玩家身上的 "Faction Component"(UFactionComponent)决定谁和谁是敌人,
-- 伤害、格挡、攻击开关等系统都引用它。SetFactionRelationOverride(对手, 关系, Both)
-- 可以针对单个对手覆盖敌我关系,Both=true 时双方同时生效。
-- ETeamAttitude: 0=Friendly 1=Neutral 2=Hostile
local ATTITUDE_NAME = { [0] = "友好", [1] = "中立", [2] = "敌对" }
local HOSTILE, NEUTRAL = 2, 1
local function GetFactionComp(pawn)
if not safeValid(pawn) then return nil end
local ok, fc = pcall(function() return pawn["Faction Component"] end)
if ok and fc ~= nil then
local okV, v = pcall(function() return fc:IsValid() end)
if okV and v then return fc end
end
return nil
end
local function ReadRelation(a, b)
if not safeValid(b) then return nil end
local fc = GetFactionComp(a)
if not fc then return nil end
local ok, r = pcall(function() return fc:GetFactionRelation(b) end)
if ok and type(r) == "number" then return r end
return nil
end
local function RelationName(r)
if r == nil then return "?" end
return ATTITUDE_NAME[r] or tostring(r)
end
local function ReadFactionTag(pawn)
local fc = GetFactionComp(pawn)
if not fc then return "无阵营组件" end
local ok, tag = pcall(function() return fc:GetCurrnetFaction() end)
if not ok or tag == nil then return "?" end
local okN, n = pcall(function() return FNameToString(tag.TagName) end)
return okN and n or "?"
end
local function SetFactionRelation(a, b, relation)
local fa, fb = GetFactionComp(a), GetFactionComp(b)
if not fa or not fb then return false,nil,nil end
local beforeA,beforeB = ReadRelation(a,b),ReadRelation(b,a)
if beforeA == nil or beforeB == nil then return false,beforeA,nil end
local function rememberOne(source,target,fc,original)
battle:remember("relation:" .. source:GetAddress() .. ":" .. target:GetAddress(), function(gone)
local function expired(obj)
if gone and gone[obj] then return true end
if engineValid(obj) then return false end
if gone then gone[obj]=true end
return true
end
if expired(source) or expired(target) or expired(fc) then
return true,"参赛对象有效性读回=false,目标已不存在;丢弃过期关系记录"
end
checked(source); checked(target); checked(fc)
-- 停止擂台时仍开启的全局观战模式继续生效,不撤销它的单向中立关系。
if spectator and spectator:status().enabled_requested then
local player=GetPlayerPawn()
if safeValid(player) and target:GetAddress()==player:GetAddress()
and source:GetAddress()~=player:GetAddress() then
fc:SetFactionRelationOverride(target,NEUTRAL,false)
local neutral=ReadRelation(source,target)
return neutral==NEUTRAL,"观战模式仍开启,保留单向中立;读回="..tostring(neutral)
end
end
fc:ClearFactionRelationOverride(target)
local actual=ReadRelation(source,target)
return actual==original,"清除本轮覆盖;原关系=" .. tostring(original)
.. ";读回=" .. tostring(actual) .. ";原覆盖结构未知"
end)
end
rememberOne(a,b,fa,beforeA); rememberOne(b,a,fb,beforeB)
local ok=pcall(function() fa:SetFactionRelationOverride(b,relation,true) end)
local afterA,afterB=ReadRelation(a,b),ReadRelation(b,a)
log(string.format("关系写入=%s;A %s→%s;B %s→%s",tostring(relation),tostring(beforeA),tostring(afterA),tostring(beforeB),tostring(afterB)))
return ok and afterA==relation and afterB==relation,beforeA,afterA
end
local function GetASC(pawn)
if not safeValid(pawn) then return nil end
local ok, asc = pcall(function() return pawn.AbilitySystemComponent end)
if ok and asc ~= nil then
local okV, v = pcall(function() return asc:IsValid() end)
if okV and v then return asc end
end
return nil
end
local aiLib = nil
local function GetAILib()
if aiLib then
local okV, v = pcall(function() return aiLib:IsValid() end)
if okV and v then return aiLib end
end
for _, path in ipairs({
"/SGameAI/BP_SGameAIFunctionLibrary.Default__BP_SGameAIFunctionLibrary_C",
"/SGameAI/Utils/BP_SGameAIFunctionLibrary.Default__BP_SGameAIFunctionLibrary_C",
}) do
local ok, obj = pcall(StaticFindObject, path)
if ok and obj ~= nil and pcall(function() return obj:IsValid() end) and obj:IsValid() then
aiLib = obj
return obj
end
end
local ok, obj = pcall(FindObject, "BP_SGameAIFunctionLibrary_C",
"Default__BP_SGameAIFunctionLibrary_C")
if ok and obj ~= nil and pcall(function() return obj:IsValid() end) and obj:IsValid() then
aiLib = obj
return obj
end
return nil
end
-- 碰撞诊断:胶囊体和模型的碰撞是否开启、用的什么碰撞配置
-- ECollisionEnabled: 0=关 1=仅查询 2=仅物理 3=查询+物理
local function DescribeCollision(pawn)
if not safeValid(pawn) then return "UNKNOWN(invalid pawn)" end
local function comp(c)
if c == nil then return "无" end
local okV, v = pcall(function() return c:IsValid() end)
if not okV or not v then return "无" end
local en, prof = "?", "?"
pcall(function() en = tostring(c:GetCollisionEnabled()) end)
pcall(function() prof = FNameToString(c:GetCollisionProfileName()) end)
return en .. "/" .. prof
end
local cap, mesh = nil, nil
pcall(function() cap = pawn.CapsuleComponent end)
pcall(function() mesh = pawn.Mesh end)
return string.format("胶囊=%s 模型=%s", comp(cap), comp(mesh))
end
-- 延迟生成只负责拿到Actor;控制器登记所有权后才会调用FinishSpawn。
-- given: the catalog entry of a unit summoned along with the selected one (escorts.lua).
local function SpawnViaAILib(cls, t, world, given, team)
if not safeValid(cls) or not safeValid(world) then return nil,"Class/World无效","not_started" end
local className=objectName(cls)
local classPath=className:match(" (/.+)$")
local allowed,why=SpawnPolicy.check(classPath)
if not allowed then return nil,why,"not_started" end
-- A unit that writes story progress itself only once the story holds what it would write (story_writes.lua).
local storyAllowed,storyWhy=arenaSupport.storyWrites:allowsUnit(classPath)
if not storyAllowed then return nil,storyWhy,"not_started" end
local entry=given or npcCatalog:selected()
if not entry or entry.path~=classPath or type(entry.isNPC)~='boolean' then return nil,'实体类型未读回','not_started' end
local npc=entry.isNPC
local lib=npc and GetAILib() or StaticFindObject('/Script/Engine.Default__GameplayStatics')
if not safeValid(lib) then return nil,'找不到函数库','not_started' end
local pc=GetRealPlayerController()
local player=UEObserve.field(pc,'Pawn')
if not summonActorLive(player) then player=nil end
local context=objectName(world)..' controller='..tostring(UEObserve.key(pc))..' player='..tostring(UEObserve.key(player))
..' player_at='..arenaSupport:pointText(GetLocation(player))..' requested='..arenaSupport:pointText(t and t.Translation)
if not spawnAudit:record("spawn_deferred_begin",classPath,context) then return nil,"阶段日志写入失败;未生成","not_started" end
if not safeValid(cls) or not safeValid(lib) or not safeValid(world) then return nil,"生成前对象失效","not_started" end
local pawn = nil
local ok, err = pcall(function()
if npc then pawn=lib:SpawnAIDefered(cls,t,nil,world)
else pawn=lib:BeginDeferredActorSpawnFromClass(world,cls,t,1,nil,1) end
end)
spawnAudit:record("spawn_deferred_return",classPath,"call="..tostring(ok).." valid="..tostring(safeValid(pawn)))
if not ok then return nil, "延迟生成接口报错,创建结果未知: " .. tostring(err),"uncertain" end
local okV = safeValid(pawn)
if not okV then return nil, "延迟生成接口未返回有效实例;创建结果未知","uncertain" end
spawnRoutes[pawn]=npc and 'npc' or 'actor'
if team=='companion' and classPath==require('companion_profile').second then
arenaSupport.muDeferred=arenaSupport.muDeferred or setmetatable({},{__mode='k'})
arenaSupport.muDeferred[pawn]=true
end
if arenaSupport.hunBody then arenaSupport.hunBody:capture(pawn,classPath)end
log('生成路径读回='..spawnRoutes[pawn]..';actor='..objectName(pawn))
return pawn,nil,"created"
end
-- leader: the unit an escort comes with; the escort takes its level, as a map group shares its domain's.
local function FinishSpawnViaAILib(pawn,t,world,leader,replacing)
if not summonActorLive(pawn) or not safeValid(world) then return false,"Actor/World无效或Actor正在销毁,保留清理记录" end
local route=spawnRoutes[pawn]
if route~='npc' and route~='actor' then return false,'生成路径未登记,保留清理记录' end
if arenaSupport.muDeferred and arenaSupport.muDeferred[pawn] then
local ok,why=require('companion_mu').isolate(pawn,StaticFindObject('/Script/SGameAI.Default__SGameAIFunctionLibrary'))
if not ok then return false,why end
end
if arenaSupport.hunBody then
local ready,why=arenaSupport.hunBody:prepare(pawn)
if not ready then return false,why end
end
if route=='npc' and arenaActivity then arenaActivity:prepare(pawn) end
-- The app's chosen difficulty goes into this actor's own config slots before it initialises.
if route=='npc' and spawnDifficulty then
local applied=spawnDifficulty:prepare(pawn,objectName(pawn))
-- Its AI asks for the difficulty while it initialises, so the hooks must be in place first.
if applied and applied.applied and aiDifficulty then aiDifficulty:ensure(pawn,spawnDifficulty:levelOf(pawn)) end
end
-- Map NPCs get their Level from their spawner before they start; a summoned one gets it here.
if route=='npc' and spawnLevel then
local leveled,level=pcall(function()return spawnLevel:prepare(pawn,objectName(pawn),leader)end)
if not leveled then log('[SpawnLevel] 出生前失败: '..tostring(level))
elseif type(level)=='table' and level.report and arenaSupport.matchReport then
arenaSupport.matchReport:rememberLevel(pawn,level.report,leader)
end
end
-- A spot behind a wall comes back to this side of it (spawn_spot.lua).
if route=='npc' and not replacing and arenaSupport.spawnSpot then
local cleared,clearError=pcall(function()arenaSupport.spawnSpot:clear(world,t)end)
if not cleared then log('[SpawnSpot] 查墙失败: '..tostring(clearError)) end
end
-- A summon starts on the ground, not over it (on_ground.lua).
local placedOnGround=route=='npc' and not replacing and onGround and onGround:place(pawn,t,world) or nil
-- A rider's script puts its mount where the rider's spawner stands, and a few bosses aim a move at their spawner;
-- a summon gets one where it is summoned (mounts.lua).
if route=='npc' and mounts then
local placed,placeError=pcall(function()mounts:prepare(pawn,t,world)end)
if not placed then log('[Mount] 出生前失败: '..tostring(placeError)) end
end
-- 冷荼's abilities find her arena by class; its markers go around her before she starts (boss_stages.lua).
if route=='npc' and bossStages then
local placed,placeError=pcall(function()bossStages:prepare(pawn,t,world)end)
if not placed then log('[BossStage] 出生前失败: '..tostring(placeError)) end
end
local lib=route=='npc' and GetAILib() or StaticFindObject('/Script/Engine.Default__GameplayStatics')
if not summonActorLive(pawn) or not safeValid(lib) or not safeValid(world) then
return false,"FinishSpawn前对象失效或进入销毁,保留清理记录"
end
local name=objectName(pawn)
if arenaSupport.menghuaPhase and not leader then
local ready,why=arenaSupport.menghuaPhase:prepare(pawn)
if not ready then return false,why end
end
local standalone
if route=='npc' and not leader and arenaSupport.standaloneStoryUnits:matches(name) then
local why
standalone,why=arenaSupport.standaloneStoryUnits:prepare(pawn)
if not standalone then return false,why end
end
if not spawnAudit:record("finish_spawn_begin",name,"所有权已登记;"..objectName(world)) then
return false,"FinishSpawn阶段日志写入失败;未继续初始化"
end
if not safeValid(pawn) or not safeValid(lib) or not safeValid(world) then return false,"FinishSpawn前对象失效" end
local ok2, err2 = pcall(function()
if route=='npc' then lib:FinishSpawnAIDefered(pawn,t,world)
else lib:FinishSpawningActor(pawn,t,1) end
end)
local live=summonActorLive(pawn)
local space=live and arenaSupport:spawnSpace(pawn,t,world) or 'spatial_read=skipped_destroying'
local audited=spawnAudit:record("finish_spawn_return",name,"call="..tostring(ok2).." live="..tostring(live)..' '..space)
if not ok2 or not audited then return false,"FinishSpawn未确认: "..tostring(err2)..";保留对象供F4清理" end
if not live then return false,"FinishSpawn 后对象进入销毁或状态不可读" end
if arenaSupport.hunBody then
local ready,why=arenaSupport.hunBody:finished(pawn)
if not ready then return false,why end
end
if standalone and not arenaSupport.standaloneStoryUnits:verify(standalone) then
return false,'出场时的剧情查找未读回;保留对象供清理'
end
-- 冷荼 born under her old save ID (a checkpoint cleared for the save-repair button) moves to the mod's now.
if route=='npc' and bossStages then
local moved,moveError=pcall(function()bossStages:finished(pawn)end)
if not moved then log('[BossStage] 出生后失败: '..tostring(moveError)) end
end
if not summonActorLive(pawn) then return false,"出生后对象进入销毁或状态不可读" end
if onGround then onGround:settle(pawn,placedOnGround) end
if route=='npc' and summonActorLive(pawn) then
local placeholder=mounts and mounts:placeholderOf(pawn)
if not placeholder and arenaSupport.swordFormation then
placeholder=arenaSupport.swordFormation:placeholderOf(pawn)
end
if placeholder then arenaSupport.summonTargetRegistration:enqueue(pawn,placeholder,world) end
end
return summonActorLive(pawn),nil
end
-- 请求原生登场并读回可见状态;不移除游戏效果。
local function FinishEntrance(pawn)
local lib=GetAILib()
local world=GetCurrentWorld()
local live=summonActorLive(pawn)
if not live or not safeValid(lib) or not safeValid(world) then return false,live end
local name=objectName(pawn)
if not spawnAudit:record("activate_begin",name,objectName(world)) then return false,live end
local activated=pcall(function() lib:ActivateAI(pawn,world) end)
live=summonActorLive(pawn)
local space=live and arenaSupport:spawnSpace(pawn,nil,world) or 'spatial_read=skipped_destroying'
spawnAudit:record("activate_return",name,"call="..tostring(activated).." live="..tostring(live)..' '..space)
if live then
log(string.format(" 登场处理: ActivateAI调用=%s(行为未验收) | %s",tostring(activated),DescribeCollision(pawn)))
end
return activated,live
end
-- ---------- 战况只读采样 ----------
local function GetHP(pawn)
if not safeValid(pawn) then return nil end
-- APBZCharacter.AttributeSetBase 已由本地头文件确认;优先直接读,避免每秒全局扫描。
local okDirect, direct = pcall(function()
local attributes = pawn.AttributeSetBase
if not safeValid(attributes) then return nil end
return attributes.Health.CurrentValue
end)
if okDirect and type(direct) == "number" then return direct end
local hp = nil
pcall(function()
local sets=arenaSupport:attributeSetsForSupport()
if not sets then return end
local pawnAddr = pawn:GetAddress()
local ascAddr = nil
pcall(function()
local asc = pawn.AbilitySystemComponent
if asc and asc:IsValid() then ascAddr = asc:GetAddress() end
end)
for _, s in ipairs(sets) do
local okO, outer = pcall(function()
if not safeValid(s) then return nil end
return s:GetOuter()
end)
if okO and outer and outer:IsValid() then
local oa = outer:GetAddress()
if oa == pawnAddr or oa == ascAddr then
hp = s.Health.CurrentValue
return
end
end
end
end)
return hp
end
local function StartDuelWatch(a,b)
local token=battle:begin("两只NPC对照")
local attackProfile=Config.EnableDuelAttackProbe==true and AttackProfile.new({log=log,valid=safeValid})
local ticks,handle=0,nil
local function cancel()
if handle then pcall(CancelDelayedAction,handle); handle=nil end
end
local function sample()
if not battle:isCurrent(token) then cancel(); return end
if not safeValid(a) or not safeValid(b) then
log("对象失效,停止采样;无法据此判定死亡/胜负")
battle:cancel("对象失效"); cancel(); return
end
ticks=ticks+1
if attackProfile then attackProfile:sample({a,b},"duel_sample_"..ticks,GetPlayerPawn()) end
if ticks==1 or ticks==20 or ticks==80 then
local ok,err=pcall(function()
spawnInspector:combat(a,b,'tick'..ticks)
spawnInspector:combat(b,a,'tick'..ticks)
end)
if not ok then log('[SpawnInspect] 战斗状态读取失败: '..tostring(err)) end
end
if ticks%8~=0 then return end
local hpA,hpB=GetHP(a),GetHP(b)
log(string.format("战况[%d] HP=%s/%s 关系=%s/%s;只读",ticks,tostring(hpA),tostring(hpB),RelationName(ReadRelation(a,b)),RelationName(ReadRelation(b,a))))
if ticks>=240 or (hpA and hpA<=0) or (hpB and hpB<=0) then
battle:cancel("采样结束;F4恢复当前账本"); cancel()
end
end
handle=LoopInGameThreadWithDelay(250,sample)
end
-- A fighting unit's fallback target (arena_controller.lua hold_target): PBZ_TargetingHandler_AI, the AI's default
-- targeting handler, reads the blackboard key "Target Key" and, when that holds nothing, "LastSensedActorKey"; the
-- handler instance is the unit's own (Targeting Component.DefaultTargetHandler, its Blackboard set in Initialize).
-- Repair player fallback, confirmed empty keys and an owned corpse still selected in either key.
local senseHold={written=0,cleared=0,failed=0,lines=0,summaryAt=nil}
function arenaSupport:writeArenaTarget(bb,key,wanted,defeated,actor)
if not engineValid(bb) or not engineValid(wanted) then return false end
local original=UEObserve.unwrap(bb:GetValueAsObject(key))
if defeated and (UEObserve.key(original)~=UEObserve.key(defeated) or not arena:canReplaceDefeatedTarget(actor,defeated,wanted)) then return false end
local originalValid=not defeated and engineValid(original)
battle:remember("blackboard:" .. bb:GetAddress() .. ":" .. FNameToString(key),function()
if not engineValid(bb) then return true,"黑板已失效" end
local back=originalValid and engineValid(original)
if back then bb:SetValueAsObject(key,original) else bb:ClearValue(key) end
if not engineValid(bb) then return true,"黑板已失效" end
local actual=UEObserve.unwrap(bb:GetValueAsObject(key))
return (back and engineValid(actual) and UEObserve.key(actual)==UEObserve.key(original)) or (not back and not engineValid(actual)),
"恢复目标读回="..objectName(actual)..((originalValid and not back) and ";原目标已不存在,改为清空" or "")
end)
if not engineValid(bb) or not engineValid(wanted) then return false end
bb:SetValueAsObject(key,wanted)
if not engineValid(bb) then return false end
local actual=UEObserve.unwrap(bb:GetValueAsObject(key))
local actualKey=UEObserve.key(actual)
return actualKey~=nil and actualKey==UEObserve.key(wanted),actual
end
local function HoldSensedTarget(actor,target,why)
local handler=UEObserve.field(UEObserve.field(actor,'Targeting Component'),'DefaultTargetHandler')
local bb=UEObserve.field(handler,'Blackboard')
local key=UEObserve.field(handler,'LastSensedActorKey')
if not safeValid(bb) or key==nil then return false end
local okNow,current=pcall(function()return UEObserve.unwrap(bb:GetValueAsObject(key))end)
if not okNow then return false end
local wanted=safeValid(target) and target or nil
local player=GetPlayerPawn()
local wasPlayer=safeValid(player) and UEObserve.key(current)==UEObserve.key(player)
local function replaceCorpse(ref,keyName)
if not wanted or not safeValid(ref) or UEObserve.key(ref)==UEObserve.key(wanted) or not arena
or not arena:canReplaceDefeatedTarget(actor,ref,wanted) then return end
local called,wrote=pcall(arenaSupport.writeArenaTarget,arenaSupport,bb,keyName,wanted,ref,actor)
if senseHold.lines<12 then
senseHold.lines=senseHold.lines+1
log('[Arena] 尸体目标改派 '..objectName(actor)..' -> '..objectName(wanted)..';读回='..tostring(called and wrote==true))
end
return called and wrote==true
end
local primaryKey=UEObserve.field(handler,'Target Key')
local primaryRead,primary
if wanted and primaryKey~=nil then
local got,value=pcall(function()return UEObserve.unwrap(bb:GetValueAsObject(primaryKey))end)
primaryRead=got
primary=got and value or nil
local replaced=replaceCorpse(primary,primaryKey)
if replaced==false then return false end
if replaced then primary=wanted end
end
local replaced=replaceCorpse(current,key)
if replaced~=nil then return replaced end
if not wasPlayer then
if safeValid(current) or not wanted then return true end
if not primaryRead then return false end
if safeValid(primary) then return true end
end
if wanted then pcall(function()bb:SetValueAsObject(key,wanted)end)
else pcall(function()bb:ClearValue(key)end) end
local readAfter,after=pcall(function()return UEObserve.unwrap(bb:GetValueAsObject(key))end)
local ok=readAfter and (wanted and UEObserve.key(after)==UEObserve.key(wanted) or (not wanted and not safeValid(after)))
if not ok then senseHold.failed=senseHold.failed+1 elseif wanted then senseHold.written=senseHold.written+1 else senseHold.cleared=senseHold.cleared+1 end
if senseHold.lines<12 then
senseHold.lines=senseHold.lines+1
log(string.format('[Arena] 锁定回退目标 %s 的 Last Sensed Actor:%s%s -> %s;写后=%s;读回=%s;%s',objectName(actor),
safeValid(current) and objectName(current) or '空',wasPlayer and '(玩家)' or '',wanted and objectName(wanted) or '清空',
safeValid(after) and objectName(after) or '空',tostring(ok),tostring(why)))
end
local now=os.clock()
senseHold.summaryAt=senseHold.summaryAt or now
if now-senseHold.summaryAt>=30 then
senseHold.summaryAt=now
log(string.format('[Arena] 锁定回退目标累计:改成对手=%d 从玩家身上清空=%d 读回不符=%d',senseHold.written,senseHold.cleared,senseHold.failed))
end
return ok
end
local function ForceAttack(attacker, victim)
if not safeValid(attacker) or not safeValid(victim) then return false end
if arenaSupport.swordFormation and not arenaSupport.swordFormation:beforeAttack(attacker,victim) then return false end
if arenaSupport.menghuaPhase and arenaSupport.menghuaPhase:busy(attacker) then return false end
local okF = SetFactionRelation(attacker, victim, HOSTILE)
local okH, how = AddHatred(attacker, victim)
local sg = GetAIComp(attacker)
local okForce = false
if sg then okForce = pcall(function() sg:ForceIntoCombat(victim) end) end
local targetVerified
-- 只写实际绑定该控制器的黑板键,并保留原目标供F4恢复。
if sg then local wrote=pcall(function()
local bb=sg.BlackboardComponent
if not safeValid(bb) then return end
local handler=arenaSupport:targetHandler(attacker,bb,true)
if safeValid(handler) then
local key=handler["Target Key"]
local actual
targetVerified,actual=arenaSupport:writeArenaTarget(bb,key,victim)
log("参赛目标写入=" .. objectName(victim) .. ";黑板读回=" .. objectName(actual)..';确认='..tostring(targetVerified))
end
end);if not wrote then targetVerified=false end end
local state = "UNKNOWN"
if sg then pcall(function() state = FNameToString(sg.CurrentStateTag.TagName) end) end
log("作战请求=" .. tostring(okForce) .. ";状态读回=" .. state
.. ";仇恨=" .. tostring(okH) .. "/" .. tostring(how) .. ";实际出招待观察")
local combat=state=='AI.State.Combat' or (type(state)=='string' and state:sub(1,#'AI.State.Combat.')=='AI.State.Combat.')
return okF and okH and okForce and (targetVerified==true or (targetVerified==nil and combat))
end
function arenaSupport:targetHandler(actor,bb,refreshMissing)
local board=UEObserve.key(bb)
if not board then return nil end
local function bound(handler)
return UEObserve.valid(handler) and UEObserve.key(UEObserve.field(handler,'Blackboard'))==board
and UEObserve.field(handler,'Target Key')~=nil
end
local own=UEObserve.field(UEObserve.field(actor,'Targeting Component'),'DefaultTargetHandler')
if bound(own) then return own end
-- Some controllers expose the bound handler only through the object list.
-- Index bindings across fighters, but always read the target from the live board.
local world=UEObserve.key(GetCurrentWorld())
local cache=world and self.targetHandlerCache
if cache and cache.world==world and bound(cache.boards[board]) then return cache.boards[board] end
local now=world and (GameSeconds() or os.clock())
if not refreshMissing and cache and cache.world==world and now>=cache.at and now-cache.at<.5 then
return nil
end
cache={world=world,at=now,boards={}}
local ok,list=pcall(FindAllOf,'PBZ_TargetingHandler_AI_C')
for _,handler in ipairs(ok and UEObserve.array(list) or {})do
local key=UEObserve.key(UEObserve.field(handler,'Blackboard'))
if key and not cache.boards[key] and UEObserve.field(handler,'Target Key')~=nil then cache.boards[key]=handler end
end
self.targetHandlerCache=world and cache or nil
if bound(cache.boards[board]) then return cache.boards[board] end
end
-- 不再调用通用ApplyDamage种仇恨;本版不执行假伤害或假死亡。
-- ---------- 扫描 ----------
local function CollectNPCs(linkOwners)
local player = GetPlayerPawn()
local playerAddr = player and player:GetAddress() or nil
local result, seen, complete = {}, {}, true
for _, className in ipairs(Config.EnemyClasses or {"PBZCharacter_NPC"}) do
local ok, found = pcall(FindAllOf, className)
if ok and found~=nil and type(found)~='table' then
found=UEObserve.array(found)
if not found then complete=false end
end
if not ok then complete=false
elseif found then
for _, pawn in ipairs(found) do
if safeValid(pawn) then
local addr = pawn:GetAddress()
if addr ~= playerAddr and not seen[addr] then
seen[addr] = true
-- For summon discovery, run the name filter only after owner/instigator proof.
if linkOwners then
if not linkOwners[tostring(addr)] then result[#result+1]=pawn end
elseif not IsExcluded(pawn) then result[#result+1]=pawn end
end
end
end
end
end
if linkOwners then return result,complete end
return result
end
-- ---------- 解剖:把最近一只怪的 AI 大脑结构写到文件(Shift+扫描键) ----------
-- 注意:UE4SS 对象的空指针链式调用会原生崩溃,pcall 拦不住,
-- 所以每一步都先取引用、IsValid 之后再往下走。
local function DumpBrain()
ExecuteInGameThread(function()
local player = GetPlayerPawn()
local pLoc = player and GetLocation(player)
local npcs = CollectNPCs()
if pLoc then
table.sort(npcs, function(a, b)
local la, lb = GetLocation(a), GetLocation(b)
if not la then return false end
if not lb then return true end
return DistSq(la, pLoc) < DistSq(lb, pLoc)
end)
end
local target = nil
for _, pawn in ipairs(npcs) do
local ok, ctrl = pcall(function() return pawn.Controller end)
if ok and safeValid(ctrl) then
target = { pawn = pawn, ctrl = ctrl }
break
end
end
if not target then
log("解剖失败:附近没有带可用控制器的怪")
return
end
local lines = {}
local function emit(s) table.insert(lines, s) end
emit("== 解剖对象: " .. target.pawn:GetFullName())
-- 把一个对象的类链(属性+函数)全部倒出来
local function dumpClassChain(obj, label)
emit("")
emit("######## " .. label)
if not safeValid(obj) then emit("UNKNOWN(invalid)"); return end
local okCls, cls = pcall(function() return obj:GetClass() end)
while okCls and safeValid(cls) do
local okN, clsName = pcall(function() return cls:GetFullName() end)
emit("")
emit("==== " .. (okN and clsName or "?"))
pcall(function()
cls:ForEachProperty(function(prop)
pcall(function() emit(" prop " .. prop:GetFullName()) end)
end)
end)
pcall(function()
cls:ForEachFunction(function(fn)
pcall(function() emit(" func " .. fn:GetFullName()) end)
end)
end)
local nxt = nil
pcall(function() nxt = cls:GetSuperStruct() end)
cls = nxt
okCls = safeValid(cls)
end
end
-- 1) 控制器 + 它的 SGameAI 组件 + 感知组件 + 怪物本体
dumpClassChain(target.ctrl, "AIController")
local okSG, sg = pcall(function() return target.ctrl.SGameAIComponent end)
if okSG and safeValid(sg) then
dumpClassChain(sg, "SGameAIComponent")
end
local okPC, perc = pcall(function() return target.ctrl.PerceptionComponent end)
if okPC and safeValid(perc) then
dumpClassChain(perc, "PerceptionComponent")
end
dumpClassChain(target.pawn, "Pawn 本体")
-- 2) AI 黑板的键("打谁"大概率藏在这里)
local okBB, bb = pcall(function() return target.ctrl.Blackboard end)
if okBB and safeValid(bb) then
emit("")
emit("==== Blackboard keys")
local okData, data = pcall(function() return bb.DefaultBlackboardAsset end)
if okData and safeValid(data) then
pcall(function()
local keys = data.Keys
for i = 1, #keys do
pcall(function()
local entry = keys[i]
emit(string.format(" key [%d] %s", i,
tostring(entry.EntryName)))
end)
end
end)
else
emit(" (DefaultBlackboardAsset 不可用)")
end
else
emit("")
emit("==== 无 Blackboard 组件")
end
local f, usedPath = nil, nil
for _, path in ipairs({
"ue4ss\\Mods\\PhantomGladiator\\brain_dump.txt",
"ue4ss/Mods/PhantomGladiator/brain_dump.txt",
"brain_dump.txt",
}) do
f = io.open(path, "w")
if f then usedPath = path break end
end
if f then
f:write(table.concat(lines, "\n"))
f:close()
log(string.format("解剖完成:%d 行已写入 %s(游戏 exe 目录下)", #lines, usedPath))
else
log("解剖完成但写文件失败,改打到日志(共 " .. #lines .. " 行)")
for _, s in ipairs(lines) do print(s .. "\n") end
end
end)
end
-- ---------- 目标系统诊断(Shift+互殴键):读出双方的目标类型标签 ----------
local function ReadTargetTypes(pawn, label)
if not safeValid(pawn) then log(label .. " 目标类型=UNKNOWN(invalid)"); return end
local ok, err = pcall(function()
local out = {}
pawn:GetTargetTypes(out)
local names = {}
for i = 1, #out do
local tag = out[i]
local okN, n = pcall(function() return FNameToString(tag.TagName) end)
table.insert(names, okN and n or "?")
end
log(string.format("%s 可打类型 [%d 个]: %s", label, #out,
table.concat(names, ", ")))
end)
if not ok then
log(string.format("%s 读取目标类型失败: %s", label, tostring(err)))
end
end
local function ReadActorTags(pawn, label)
-- 已知本构建没有 GetOwnedGameplayTags 反射入口,不重复失败调用。
log(label .. " 身份标签=UNKNOWN(GetOwnedGameplayTags非反射函数;不据此推断无标签)")
end
local function TargetDiag()
ExecuteInGameThread(function()
local player = GetPlayerPawn()
if player then
ReadTargetTypes(player, "玩家")
ReadActorTags(player, "玩家")
end
local npcs = CollectNPCs()
if player then
log("玩家 阵营: " .. ReadFactionTag(player))
end
-- 附近每只 NPC 的阵营标签和它对玩家的关系(在原生 NPC 互打的场景按这个键,
-- 能直接看到双方用的阵营)
for i = 1, math.min(#npcs, 8) do
local rel = player and RelationName(ReadRelation(npcs[i], player)) or "?"
local okN, n = pcall(function()
return objectName(npcs[i]):match("([%w_]+)$")
end)
log(string.format(" NPC[%d] %s 阵营=%s 对玩家=%s %s", i,
okN and n or "?", ReadFactionTag(npcs[i]), rel,
DescribeCollision(npcs[i])))
end
if #npcs >= 2 then
log(string.format(" NPC[1]→NPC[2] 关系=%s",
RelationName(ReadRelation(npcs[1], npcs[2]))))
end
if #npcs > 0 then
ReadTargetTypes(npcs[1], "怪物")
ReadActorTags(npcs[1], "怪物")
-- 怪物的 TargetingComponent 挂了哪些 handler
pcall(function()
local tc = npcs[1]["Targeting Component"]
if tc and tc:IsValid() then
local hs = tc.TargetingHandlers
for i = 1, #hs do
pcall(function()
local entry = hs[i]
log(string.format(" handler[%d] tag=%s", i,
FNameToString(entry.Tag.TagName)))
end)
end
end
end)
-- 它的原生仇恨列表里现在有谁
pcall(function()
local hm = GetHatredComp(npcs[1])
if hm then
local hl = hm.HatredList
log(string.format(" 仇恨列表 %d 个:", #hl))
for i = 1, math.min(#hl, 5) do
pcall(function()
log(" " .. objectName(hl[i]))
end)
end
else
log(" (没有仇恨组件)")
end
end)
-- 它的感知里现在装着谁
pcall(function()
local ctrl = npcs[1].Controller
if ctrl and ctrl:IsValid() then
local perc = ctrl.PerceptionComponent
if perc and perc:IsValid() then
local seen = {}
perc:GetPerceivedHostileActors(seen)
log(string.format(" 感知到的敌对者 %d 个:", #seen))
for i = 1, math.min(#seen, 5) do
local okE, nameE = pcall(function()
local a = seen[i]
if safeValid(a) then return objectName(a) end
local okGet,resolved=pcall(function() return a:get() end)
return okGet and objectName(resolved) or "UNKNOWN"
end)
log(" " .. (okE and nameE or "?"))
end
end
end
end)
end
end)
end
-- ---------- 碰撞通道对照(Shift+决斗键):玩家 vs 最近的怪 ----------
-- 每个碰撞组件输出:对象类型、碰撞开关、对 32 个通道的反应(0 忽略 1 重叠 2 阻挡)。
-- 怪物攻击检测线如果只扫"玩家受击框"那类通道,而怪物身上没有对应反应的组件,
-- 怪打怪就会打空——对照这张表能直接看出来。
local function DumpCollisionMatrix()
ExecuteInGameThread(function()
local primClass = StaticFindObject("/Script/Engine.PrimitiveComponent")
if not primClass or not primClass:IsValid() then
log("碰撞对照失败:找不到 PrimitiveComponent 类")
return
end
local lines = {}
local function emit(s) table.insert(lines, s) end
-- K2_GetComponentsByClass 在本作返回空数组(实测),改为遍历几类碰撞相关组件,
-- 按拥有者筛选;武器等挂件是独立 Actor,拥有者链再往上查一层
local allComps = {}
for _, cn in ipairs({ "ShapeComponent", "SkeletalMeshComponent", "StaticMeshComponent" }) do
local ok, list = pcall(FindAllOf, cn)
if ok and list then
for _, c in ipairs(list) do table.insert(allComps, c) end
end
end
local function ownedBy(c, actorAddr)
local ok, hit = pcall(function()
if not safeValid(c) then return false end
local o = c:GetOwner()
if not safeValid(o) then return false end
if o:GetAddress() == actorAddr then return true end
local o2 = o:GetOwner()
return o2 ~= nil and o2:IsValid() and o2:GetAddress() == actorAddr
end)
return ok and hit
end
local function dumpActor(actor, label)
if not safeValid(actor) then return end
emit("######## " .. label .. " " .. actor:GetFullName())
local actorAddr = actor:GetAddress()
local comps = {}
for _, c in ipairs(allComps) do
if ownedBy(c, actorAddr) then table.insert(comps, c) end
end
emit(string.format(" (找到 %d 个碰撞相关组件,全局扫描 %d 个)", #comps, #allComps))
for i = 1, #comps do
pcall(function()
local c = comps[i]
if not c:IsValid() then return end
local name = c:GetFullName():match("([%w_]+)$") or "?"
pcall(function()
local o = c:GetOwner()
if not safeValid(o) then return end
if o:GetAddress() ~= actor:GetAddress() then
name = (o:GetFullName():match("([%w_]+)$") or "?") .. "." .. name
end
end)
local objType, enabled, prof = "?", "?", "?"
pcall(function() objType = tostring(c:GetCollisionObjectType()) end)
pcall(function() enabled = tostring(c:GetCollisionEnabled()) end)
pcall(function() prof = FNameToString(c:GetCollisionProfileName()) end)
local resp = {}
for ch = 0, 31 do
local r = "?"
pcall(function() r = tostring(c:GetCollisionResponseToChannel(ch)) end)
table.insert(resp, r)
end
emit(string.format(" %-40s 类型=%s 开关=%s 配置=%s", name, objType, enabled, prof))
emit(" 通道0-31: " .. table.concat(resp, ""))
end)
end
end
local player = GetPlayerPawn()
if player then dumpActor(player, "玩家") end
local pLoc = player and GetLocation(player)
local npcs = CollectNPCs()
if pLoc then
table.sort(npcs, function(a, b)
local la, lb = GetLocation(a), GetLocation(b)
if not la then return false end
if not lb then return true end
return DistSq(la, pLoc) < DistSq(lb, pLoc)
end)
end
if npcs[1] then dumpActor(npcs[1], "怪物") end
local f = io.open("collision_matrix.txt", "w")
if f then
f:write(table.concat(lines, "\n"))
f:close()
log(string.format("碰撞对照完成:%d 行已写入 collision_matrix.txt", #lines))
else
log("碰撞对照写文件失败")
end
end)
end
-- ---------- 慢动作 ----------
local function CycleSlowMo()
ExecuteInGameThread(function()
dilationIndex = dilationIndex % #Config.TimeDilationSteps + 1
local target = Config.TimeDilationSteps[dilationIndex]
local count = 0
local ok, list = pcall(FindAllOf, "WorldSettings")
if ok and list then
for _, ws in ipairs(list) do
if safeValid(ws) then
local okChange=battle:change("time:" .. ws:GetAddress(),
function() checked(ws); return ws.TimeDilation end,
function(value) checked(ws); ws.TimeDilation=value end,target,
function(a,b) return type(a)=="number" and math.abs(a-b)<0.0001 end)
if okChange then count=count+1 end
end
end
end
if count > 0 then
log(string.format("时间流速: %.2fx(%d 个世界)", target, count))
else
log("设置 TimeDilation 失败")
end
end)
end
-- ---------- 自由镜头 ----------
-- Shipping 版的 DebugCameraController 没有自己的 CheatManager(被编译剔除),
-- 而原生退出流程恰恰依赖它:现场构造一个再调 DisableDebugCamera。实测有效。
local function ExitFreeCam(dcc)
checked(dcc)
local cm = dcc.CheatManager
if not cm or not cm:IsValid() then
local cmClass = StaticFindObject("/Script/Engine.CheatManager")
if not cmClass or not cmClass:IsValid() then
error("CheatManager class not found")
end
cm = StaticConstructObject(cmClass, dcc)
if not cm or not cm:IsValid() then
error("construct CheatManager failed")
end
dcc.CheatManager = cm
end
cm:DisableDebugCamera()
end
-- 找"当前真正掌权"的调试相机:每次进出都会生成新实例,旧的会残留,
-- 只有持有 UPlayer 的那个才是激活中的
local function FindActiveDebugCam()
local ok, list = pcall(FindAllOf, "DebugCameraController")
if not ok or not list then return nil end
for _, dcc in ipairs(list) do
local okP, active = pcall(function()
return dcc:IsValid() and dcc.Player and dcc.Player:IsValid()
end)
if okP and active then return dcc end
end
return nil
end
-- Only supportSteps owns this short-lived snapshot; no UObject survives into the next support tick.
function arenaSupport:supportRead(key,reader)
local frame=self.frameContext
if not frame then return reader() end
local entry=frame[key]
if not entry then entry={value=reader()};frame[key]=entry end
return entry.value
end
function arenaSupport:debugCameraForSupport()
return self:supportRead('debugCamera',FindActiveDebugCam)
end
function arenaSupport:attributeSetsForSupport()
return self:supportRead('attributeSets',function()
local ok,list=pcall(FindAllOf,'BasicAttributeSet')
return ok and UEObserve.array(list) or nil
end)
end
local observerGuard=ObserverGuard.new({log=log,getSpectator=function()return spectator end})
local freeCamera=FreeCamera.new({path=Config.RuntimePath,log=log,getController=GetRealPlayerController,guard=observerGuard,
getWorld=GetCurrentWorld,moveSpeed=Config.FreeCamera.MoveSpeed,mouseSensitivity=Config.FreeCamera.MouseSensitivity,
track=function()return arenaSupport.track end})
-- Real seconds less the time 时停 held the game: timers about units that cannot move meanwhile (a companion stuck
-- for 6 s is teleported) wait while it lasts.
local frozenSince,frozenTotal=nil,0
local function LiveSeconds()
local now=os.clock()
local frozen=freeCamera:isFrozen()
if frozen and not frozenSince then frozenSince=now
elseif not frozen and frozenSince then frozenTotal=frozenTotal+(now-frozenSince);frozenSince=nil end
return (frozenSince or now)-frozenTotal
end
local function ToggleFreeCam()
local dcc=FindActiveDebugCam()
if dcc then local ok,why=pcall(ExitFreeCam,dcc);return {ok=ok,message=ok and '已退出原生调试镜头' or tostring(why),spawned_count=0}end
local ok,result=pcall(function()return freeCamera:toggle()end)
local confirmed=ok and result==true
local protection=observerGuard:status()
return {ok=confirmed,message=confirmed and (freeCamera:isActive() and (protection.health_verified and '自由观战已开启:无仇恨、隐身、无敌锁血;声音跟随镜头' or '自由观战已开启;锁血状态待确认,请查看面板保护状态') or '已退出自由观战并恢复')
or ('相机操作未确认,可点击退出观战重试:'..tostring(result)),spawned_count=0}
end
local function ForceExitFreeCam()
local ok,restored=pcall(function()return freeCamera:stop('面板/自定义退出键')end)
local dcc=FindActiveDebugCam();local legacyOK=true
if dcc then legacyOK=pcall(ExitFreeCam,dcc)end
return {ok=ok and restored==true and legacyOK,message=ok and restored==true and legacyOK and '已退出自由观战并恢复原状态' or '退出恢复待确认,可再次点击退出观战',spawned_count=0}
end
-- ---------- 只读攻击追踪 ----------
local function LogProbeScene(label)
local player=GetPlayerPawn()
log("[Scene] " .. label .. " 玩家=" .. objectName(player) .. " HP=" .. tostring(GetHP(player)))
local origin=player and GetLocation(player)
local npcs=CollectNPCs()
if origin then
table.sort(npcs,function(a,b)
local la,lb=GetLocation(a),GetLocation(b)
return (la and DistSq(la,origin) or math.huge)<(lb and DistSq(lb,origin) or math.huge)
end)
end
local subjects = {}
if safeValid(player) then subjects[#subjects+1]=player end
for i=1,math.min(#npcs,4) do
local npc=npcs[i]
subjects[#subjects+1]=npc
log("[Scene] NPC=" .. objectName(npc) .. " HP=" .. tostring(GetHP(npc))
.. " 阵营=" .. ReadFactionTag(npc) .. " 对玩家=" .. RelationName(ReadRelation(npc,player)))
end
return subjects
end
local healthSubjects = {}
probeFinished = function(state)
probeSampleGen=probeSampleGen+1
for _,entry in ipairs(healthSubjects) do
local hp=GetHP(entry.actor)
log("[HPWatch] 结束 " .. objectName(entry.actor) .. " start=" .. tostring(entry.initial)
.. " final=" .. tostring(hp) .. " reason=" .. tostring(state.reason))
end
healthSubjects={}
end
local function StartHealthWatch(subjects,token)
healthSubjects={}
for _,actor in ipairs(subjects) do
local hp=GetHP(actor)
healthSubjects[#healthSubjects+1]={actor=actor,initial=hp,last=hp}
end
local ticks,lines,handle=0,0,nil
local function cancel()
if handle then pcall(CancelDelayedAction,handle); handle=nil end
end
local function sample()
if token~=probeSampleGen or not probe:status().active then cancel(); return end
ticks=ticks+1
for _,entry in ipairs(healthSubjects) do
local hp=GetHP(entry.actor)
if hp~=entry.last and lines<40 then
log("[HPWatch] sample="..ticks.." "..objectName(entry.actor)
.." HP="..tostring(entry.last).."→"..tostring(hp).."(只读,不据此判断伤害来源)")
lines=lines+1
end
entry.last=hp
end
if ticks>=60 then cancel() end
end
handle=LoopInGameThreadWithDelay(1000,sample)
end
BeginArenaObservation=function(a,b)
probe:stop("开始参赛者对照")
local subjects={a,b}
local player=GetPlayerPawn()
if safeValid(player) then subjects[#subjects+1]=player end
probeSampleGen=probeSampleGen+1
if probe:start("arena_duel",subjects) then StartHealthWatch(subjects,probeSampleGen) end
end
local function ToggleProbe()
ExecuteInGameThread(function()
local state=probe:status()
probeSampleGen=probeSampleGen+1
if state.active or state.stopPending then
probe:stop("F11手动结束"); LogProbeScene("结束"); return
end
local subjects=LogProbeScene("开始;只读阳性对照")
local ok=probe:start("native_baseline",subjects)
if not ok then return end
local token=probeSampleGen
StartHealthWatch(subjects,token)
ExecuteInGameThreadWithDelay(60050,function()
if token~=probeSampleGen then return end
LogProbeScene("60秒窗口结束")
end)
end)
end
-- ---------- 单位控制器:按钮与快捷键共用,只有本Mod的参赛者受管理 ----------
local runtimeSession=RuntimeSession.new({valid=safeValid,getWorld=GetCurrentWorld,
getPlayer=GetPlayerPawn,isDestroying=actorIsDestroying,hp=GetHP})
local spectatorTargets=SpectatorTargets.new({log=log})
local spectatorExcluded={count=0}
-- The player's side: companions (their adopted summons included) and anything carrying the player's faction tag.
-- No-aggro leaves these alone and never brings back the relation one had before it joined.
local sideKeys,sideAt={},-1
local function IsPlayerSide(npc)
local now=os.clock()
if now-sideAt>=0.5 or now<sideAt then
sideAt,sideKeys=now,{}
for _,member in ipairs(arena and arena:members() or {})do
local key=member.team=='companion' and UEObserve.key(member.actor)
if key then sideKeys[key]=true end
end
end
local key=UEObserve.key(npc)
if key and sideKeys[key] then return true end
local tag=ReadFactionTag(npc)
return tag~='?' and tag~='无阵营组件' and tag==ReadFactionTag(GetPlayerPawn())
end
spectator=SpectatorMode.new({log=log,valid=engineValid,getPlayer=GetPlayerPawn,path=Config.RuntimePath,
getWorld=GetCurrentWorld,inWorld=UEObserve.inWorld,
refreshTargets=function(force)spectatorTargets:refresh(force)end,
isActorDestroying=actorIsDestroying,
isObserverActive=function()return freeCamera:isActive()end,
isPlayerSide=IsPlayerSide,
preserveCombatFaction=function(npc)return arenaSupport.hunBody and arenaSupport.hunBody:isArenaBody(npc)end,
releasePlayerTarget=function(npc,player)return spectatorTargets:release(npc,player)end,
getNPCs=function(world)
local out={}
world=world or GetCurrentWorld()
local worldKey=UEObserve.key(world)
if not worldKey then return out end
if spectatorExcluded.world~=worldKey then spectatorExcluded={world=worldKey,count=0}end
for _,npc in ipairs(CollectNPCs()) do
if UEObserve.inWorld(npc,world) then
local ok,destroying=pcall(function() checked(npc); return npc:IsActorBeingDestroyed() end)
if not (ok and destroying==true) then out[#out+1]=npc end
else
local key=UEObserve.key(npc)
if key and not spectatorExcluded[key] and spectatorExcluded.count<32 then
spectatorExcluded[key]=true;spectatorExcluded.count=spectatorExcluded.count+1
log('[Spectator] 跳过非当前世界对象:'..objectName(npc))
end
end
end
return out
end})
function arenaSupport:combatPhaseBusy(actor)
return (self.menghuaPhase and self.menghuaPhase:busy(actor)) or
(self.swordFormation and self.swordFormation:supportingActor(actor)) or false
end
arena=ArenaController.new({catalog=npcCatalog,log=log,valid=engineValid,name=objectName,now=GameSeconds,
onCompanionSummoned=function(...)if panelRuntime and panelRuntime.squad then panelRuntime.squad:added(...) end end,
phaseBusy=function(actor)return arenaSupport:combatPhaseBusy(actor)end,
actorKey=function(actor) checked(actor);return actor:GetAddress() end,
hp=function(actor) if spawnRoutes[actor]=='actor' then return nil end;return GetHP(actor) end,
hasCombatHealth=function(actor) return spawnRoutes[actor]~='actor' end,
holdsDeath=function(actor)return arenaSupport.hunBody and arenaSupport.hunBody:holdsDeath(actor)end,
confirmedDead=function(actor)return arenaSupport.hunBody and arenaSupport.hunBody:confirmedDead(actor)end,
canSpawn=SpawnPolicy.check,maxUnits=0,
retireFormation=require('boss_entourage').retireFormation,
companionFormation=require('huashan_formation').supportsCompanion,
prepareFormation=function(group,rows,world,team)return arenaSupport.swordFormation:prepare(group,rows,world,team)end,
formationReady=function(group)return arenaSupport.swordFormation:ready(group)end,
formationActivated=function(group)return arenaSupport.swordFormation:activated(group)end,
formationLifeChanged=function(group,actor,living)arenaSupport.swordFormation:lifeChanged(group,actor,living)end,
abortFormation=function(group)return arenaSupport.swordFormation:abort(group)end,
finalDeath=function(actor,wholeGroup)return arenaSupport:finalDeath(actor,wholeGroup)end,
formationEnabled=function(path)
local m=require('boss_entourage');local id=m.id(path)
if m.supports(id) then return arenaSupport.unitRules and arenaSupport.unitRules:get(id,'entourage')=='on' or false end
end,
escortsFor=function(path,enabled)
local m=require('boss_entourage')
return enabled and m.parties[m.id(path)] or (Config.SummonEscorts and Escorts.of(path) or nil)
end,
resolveEscort=function(path)return npcCatalog:resolvePath(path)end,
spawnLimits=SpawnPolicy.limits,canBattle=SpawnPolicy.canBattle,
spawnGuard=spawnGuard,
combatReady=function(actor) return safeValid(actor) and spawnRoutes[actor]~='actor' and GetAIComp(actor)~=nil end,
factionReady=function(actor)return engineValid(GetFactionComp(actor))end,
isStand=require('arena_stands').isStand,
-- Kept in reserve by its summoner: hidden in game with its AI not started (冷荼's stand-by dolls show ai_state=None).
dormant=function(actor)
if UEObserve.field(actor,'bHidden')~=true then return false end
local ai=GetAIComp(actor)
if not ai then return true end
local okTag,name=pcall(function()return FNameToString(ai.CurrentStateTag.TagName)end)
return okTag and (name=='None' or name=='')
end,
untargetable=function(actor)return bossStages~=nil and bossStages:untargetable(actor)end,
preferredTargets=function(actor,team,currentKey)return arenaSupport.lionWave:preferred(actor,team,currentKey)end,
phaseBlocksAim=function(actor,target)return arenaSupport.lionWave:blocksAim(actor,target)end,
targetProtected=function(actor)return arenaSupport.combatContinuity and arenaSupport.combatContinuity:protected(actor)end,
keepOpponent=function(actor,fresh)return arenaSupport.combatContinuity:keepOpponent(actor,fresh)end,
engagedWith=function(actor,target)
local state=UEObserve.struct(UEObserve.field(GetAIComp(actor),'CurrentStateTag'),'TagName')
local label=state and FNameToString(state)
return type(label)=='string' and (label=='AI.State.Combat' or label:match('^AI%.State%.Combat%.')~=nil)
and UEObserve.key(arenaSupport.hunNativeTarget(actor,true))==UEObserve.key(target)
and HatredListContains(GetHatredComp(actor),target)==true
end,
actionBusy=function(actor)return arenaSupport.combatContinuity and arenaSupport.combatContinuity:actionBusy(actor)or false end,
waitForTarget=function(actor,target)return arenaSupport.combatContinuity:wait(actor,target)end,
resumeIntent=function(actor)return arenaSupport.combatContinuity:resume(actor)end,
maintainTarget=function(actor,target)return arenaSupport.combatContinuity:maintain(actor,target)end,
isStoryTeamActor=function(actor)
return arenaSupport.standaloneStoryUnits:isTeamActor(actor)
end,
prepareStoryTeamActor=function(actor)
return arenaSupport.standaloneStoryUnits:prepareTeamActor(actor)
end,
holdTarget=function(actor,target,why)
if not arenaSupport.standaloneStoryUnits:assignOpponent(actor,target) then return false end
return HoldSensedTarget(actor,target,why)
end,
releaseLock=function(actor,target)return arenaSupport.lockRelease~=nil and arenaSupport.lockRelease:release(actor,target)end,
unstick=function(actor,target,classPath)
return onGround~=nil and not (arenaSupport.lionNPC and arenaSupport.lionNPC:keepsMovement(actor,classPath))
and onGround:free(actor,target)
end,
getPlayer=GetPlayerPawn,getWorld=GetCurrentWorld,getLocation=GetLocation,
getForward=function(actor) checked(actor); return actor:GetActorForwardVector() end,
spawnClass=SpawnViaAILib,
finishSpawn=FinishSpawnViaAILib,
companionTransfer=function(...)return arenaSupport.companionNative.transfer(...)end,
companionRestore=function(...)return arenaSupport.companionNative.restore(...)end,
companionCommitReady=function(...)return arenaSupport.companionNative.commitReady(...)end,
companionChildren=function(...)return arenaSupport.muChildren(...)end,
companionChildGroups=function(...)return arenaSupport.muChildGroups(...)end,inCompanionWorld=UEObserve.inWorld,
quarantineCompanion=function(actor)
if not summonActorLive(actor) then return end
local ai=GetAIComp(actor);if safeValid(ai) then ai:StopAI() end
if summonActorLive(actor) then actor:SetActorEnableCollision(false);actor:SetActorHiddenInGame(true) end
end,
activate=function(actor,unitPath,team,escort,spec)
if spawnRoutes[actor]=='actor' then return safeValid(actor),'通用Actor初始化完成;未调用PBZ战斗AI,不保证具有血量或战斗能力' end
-- A companion is never handed to no-aggro: up to v0.37.3 it was recorded here while still the enemy, and
-- turning no-aggro off (leaving the free camera) set that back, so its attacks hit the player.
if team~='companion' then spectator:applyTo(actor)
elseif spectator:status().enabled_requested then
log('[Spectator] 随从不交给无仇恨接管 unit='..objectName(actor)..' 召唤时对玩家关系='..RelationName(ReadRelation(actor,GetPlayerPawn()))
..'(v0.37.3 及以前会记下这个关系,关闭无仇恨时改回去)')
end
-- Companions get the official follow state, the player's faction and a friendly relation before their AI starts.
if team=='companion' and companions then
local prepared,prepareError=pcall(function()return companions:prepare(actor,unitPath)end)
if require('companion_profile').phase(unitPath) and (not prepared or not prepareError or not prepareError.ok) then
return false,'沐小葵的阵营、友好关系或跟随状态未确认'
end
if not prepared then log('[Companion] 准备失败: '..tostring(prepareError)) end
end
if team~='companion' and arenaSupport.hunBody then arenaSupport.hunBody:prepareRole(actor) end
if arenaSupport.lionStage then
local called,ready,reason=pcall(function()
return arenaSupport.lionStage:prepare(actor,unitPath,GetCurrentWorld(),escort)
end)
if not called or not ready then
local detail=called and reason or tostring(ready)
log('[LionStage] 场地准备失败 '..tostring(detail))
local reasonText=tostring(detail or '烈焰舞狮场地准备失败')
return false,reasonText,reasonText
end
end
local spawnWarning
if arenaSupport.remoteReflect then arenaSupport.remoteReflect:capture(actor,unitPath,escort) end
if arenaSupport.xianzhePhantom then
local called,ok,reason=pcall(function()return arenaSupport.xianzhePhantom:capture(actor,unitPath,escort)end)
if not called or ok~=true then
spawnWarning=reason or '弦者技能虚化设置未确认,请查看日志'
log('[XianZhePhantom] 召唤设置未确认:'..tostring(reason or ok))
end
end
if arenaSupport.phantom then
local called,ok,reason=pcall(function()return arenaSupport.phantom:beforeActivate(actor,unitPath,escort)end)
if not called or not ok then
if not called then log('[Phantom] 虚空登场前处理失败:'..tostring(ok)) end
spawnWarning=reason or '登场保护设置未确认'
end
end
if not summonActorLive(actor) then return false,'登场前对象已失效' end
local activationRequested,live=FinishEntrance(actor)
if not live then return false,"原生登场时对象进入销毁或状态不可读" end
if spectator:status().enabled_requested then spectatorTargets:refresh(true) end
if not summonActorLive(actor) then return false,"刷新观战目标时对象进入销毁或状态不可读" end
if team~='companion' then spectator:applyTo(actor) end
if not summonActorLive(actor) then return false,"应用观战关系后对象进入销毁或状态不可读" end
local ai=GetAIComp(actor)
if arenaSupport.muDeferred and arenaSupport.muDeferred[actor] and not require('companion_mu').attached(actor,ai) then
return false,'铁玉女王已启用的 AI 与私有配置不一致'
end
local hp=GetHP(actor)
log("召唤激活读回 ControllerAI="..tostring(ai~=nil).." HP="..tostring(hp))
local verified,verifyError=pcall(function()spawnDifficulty:verify(actor,unitPath)end)
if not verified then log('[SpawnDifficulty] 生成后读回失败: '..tostring(verifyError)) end
-- What the level written before FinishSpawn changed, next to a map NPC of that level (read only),
-- and how both units' numbers are built from their configs (stat_formula_probe.lua, read only).
if activationRequested==true and spawnLevel then
local reference
local compared,compareError=pcall(function()reference=spawnLevel:verify(actor)end)
if not compared then log('[SpawnLevel] 出生后读回失败: '..tostring(compareError)) end
if statProbe then
local game=spawnDifficulty and spawnDifficulty:status().game or nil
if game=='' then game=nil end
local probed,probeError=pcall(function()
statProbe:unit(actor,'召唤',spawnDifficulty and spawnDifficulty:levelOf(actor) or game)
if reference then statProbe:unit(reference,'地图怪',game) end
end)
if not probed then log('[StatFormula] 失败: '..tostring(probeError)) end
end
end
if team=='companion' and companions then
local checked,checkError=pcall(function()return companions:afterActivate(actor,unitPath)end)
if require('companion_profile').phase(unitPath) and (not checked or checkError~=true) then
return false,'激活后随从身份或跟随行为未读回'
end
if not checked then log('[Companion] 激活后读回失败: '..tostring(checkError)) end
end
-- Companions have a set of their own, separate from the arena's. An escort (a 驯犬客's 狂犬) takes the numbers the player
-- set, but it is part of the unit it came with, not a contestant to be matched.
if escort and team~='companion' and statMatch and statMatch.mode=='match' then
log('[Escort] 随行单位不参与数值统一,保持自身数值 unit='..objectName(actor)..' HP='..tostring(hp))
end
local stats=team=='companion' and arenaSupport.companionStats or statMatch
local reportedMode='game'
local hunStatsMode
-- A Hun body never takes the arena's or the companions' set: its profile's values when it has any, the game's otherwise.
if arenaSupport.hunBody and arenaSupport.hunStats and arenaSupport.hunBody:owns(actor) then
local chosen,dropped,source=require('hun_body').statsFor(true,arenaSupport.hunBody:attributes(actor),arenaSupport.hunStatFields,stats,arenaSupport.hunStats)
stats=chosen
hunStatsMode=source=='方案' and 'hun_profile' or 'game'
log('[HunStats] 魂不用擂台和随从的数值设定:'..(source=='方案' and '按方案写入属性' or '方案没有属性值,保持游戏原值')..' unit='..objectName(actor))
if dropped>0 then log('[HunStats] 方案里有 '..dropped..' 项属性游戏端不认识,已跳过')end
end
local combatReady=activationRequested==true and ai~=nil and type(hp)=='number' and hp>0
if combatReady and escort then
local wrote,result=pcall(function()return stats:onSummon(actor,unitPath)end)
if not wrote or type(result)~='table' or result.ok~=true then
local detail=wrote and type(result)=='table' and tostring(result.message) or tostring(result)
log('[Escort] 数值未确认: '..detail)
if wrote and type(result)=='table' and result.rollback_verified==true then
return true,'初始化通过;数值统一失败已回滚',detail..';单位保留原生数值,可正常交战'
end
return false,'单位已生成;随行数值未确认:'..detail..';保留对象供清理'
end
if result.applied then reportedMode=hunStatsMode or stats.mode end
end
if combatReady and not escort then
local result
if spec then
spec.attributes=spec.attributes or stats:captureCustom()
result=stats:applyCaptured(actor,unitPath,spec.attributes)
else result=stats:onSpawn(actor,unitPath) end
if not result.ok then
if not spec and result.rollback_verified then return true,'初始化通过;数值统一失败已回滚',result.message..';单位保留原生数值,可正常交战' end
return false,'单位已生成;'..result.message..';保留对象供清理'
end
if result.applied then reportedMode=hunStatsMode or (spec and 'custom' or stats.mode) end
-- An experiment: whatever it does, the summon stands.
if fieldProbe and team~='companion' then
local probed,probeError=pcall(function()fieldProbe:start(actor,unitPath)end)
if not probed then log('[StatProbe] 启动失败: '..tostring(probeError)) end
end
end
if combatReady and arenaSupport.matchReport then arenaSupport.matchReport:rememberStats(actor,reportedMode) end
if activationRequested and safeValid(actor) then
local inspected,inspectError=pcall(function() return spawnInspector:inspect(actor,GetCurrentWorld()) end)
if not inspected then log('[SpawnInspect] 只读检查失败: '..tostring(inspectError)) end
end
return combatReady,'仅确认初始化调用、AI组件和正HP;行为待验收',spawnWarning
end,
-- A unit's own summons take the custom numbers of its side (arena adoptSummon).
summonAdopted=function(actor,unitPath,team)
local stats=team=='companion' and arenaSupport.companionStats or statMatch
return stats:onSummon(actor,unitPath)
end,
spawnOrigin=function(body,look,team,world)
local watching=team~='companion' and freeCamera:status().active==true
if watching and not spawnAudit:record("camera_spawn_origin_begin",team,"观战落点检测") then return body,look end
local position,forward=arenaSupport.spawnSpot:origin(body,look,team,world)
if watching then spawnAudit:record("camera_spawn_origin_return",team,"position="..tostring(position~=nil)) end
return position,forward
end,
setRelation=SetFactionRelation,
onAssigned=function(actor,target)
arenaSupport.aggroGuard:arm(actor,target)
arenaSupport.swordFormation:assigned(actor,target)
end,
forceAttack=function(attacker,victim)
if not arenaSupport.standaloneStoryUnits:assignOpponent(attacker,victim) then return false end
local sent=ForceAttack(attacker,victim)
if mounts then mounts:fight(attacker,victim) end
return sent
end,
holdMount=function(rider,target)if mounts then mounts:hold(rider,target) end end,
-- Whether the unit's AI state is combat (AI.State.Combat; Idle and Search are not), and its state name.
inCombat=function(actor)
local sg=GetAIComp(actor)
if not sg then return nil end
local ok,tag=pcall(function()return FNameToString(sg.CurrentStateTag.TagName)end)
if not ok or type(tag)~='string' then return nil end
return tag=='AI.State.Combat' or tag:sub(1,#'AI.State.Combat.')=='AI.State.Combat.',tag
end,
-- Sends a unit that left combat back at its opponent: hatred entry and ForceIntoCombat. The faction
-- relation and blackboard target written by ForceAttack at the start still hold.
engage=function(attacker,victim)
if not arenaSupport.standaloneStoryUnits:assignOpponent(attacker,victim) then return false end
return arenaSupport:engage(attacker,victim)
end,
prepareBattle=function(members)
local prepared=arenaGrabs:sync(Config.EnableNPCGrabs and members or {},true,true)
if prepared and arenaSupport.guillotine then arenaSupport.guillotine:prepare(members) end
return prepared
end,
destroy=function(actor)
checked(actor)
arenaSupport.summonTargetRegistration:cancel(actor)
if arenaSupport.yubiArena then arenaSupport.yubiArena:releaseActor(actor) end
if arenaSupport.menghuaPhase and not arenaSupport.menghuaPhase:releaseActor(actor) then error('梦华阶段帮手回收未确认') end
if arenaSupport.lionNPC and not arenaSupport.lionNPC:releaseActor(actor) then error('下桩清理未读回') end
if arenaSupport.lionStage then arenaSupport.lionStage:releaseActor(actor) end
checked(actor); actor:K2_DestroyActor()
if mounts then mounts:releaseActor(actor,'随单位清理') end
if bossStages then bossStages:releaseActor(actor,'随 BOSS 清理') end
end,
isDestroying=actorIsDestroying,
restore=function()
if arenaSupport.lionWave then arenaSupport.lionWave:stopArena() end
local aggroRestored=not arenaSupport.aggroGuard or arenaSupport.aggroGuard:stop()
probeSampleGen=probeSampleGen+1
probe:stop("停止参赛者")
local guillotineRestored=not arenaSupport.guillotine or arenaSupport.guillotine:stopArena()
if arenaExecutions then arenaExecutions:stop('停止参赛者',true) end
local polesRestored=not arenaSupport.lionNPC or arenaSupport.lionNPC:stop('停止并清理',true)
if bossHUD then bossHUD:clear(true) end
local grabRestored=not arenaGrabs or arenaGrabs:restore()
local phaseRestored=not arenaSupport.menghuaPhase or arenaSupport.menghuaPhase:stop()
local battleRestored=battle:reset("停止参赛者")
return aggroRestored and guillotineRestored and polesRestored and grabRestored and phaseRestored and battleRestored
end,
onUnitsChanged=function(units)
if playerAim then playerAim:prepareWalk(units) end
if arenaSupport.swordFormation then arenaSupport.swordFormation:roster(units) end
if arenaSupport.entourage then arenaSupport.entourage:roster(units) end
if arenaSupport.yubiArena then arenaSupport.yubiArena:roster(units) end
if arenaSupport.menghuaPhase then arenaSupport.menghuaPhase:syncParents(units) end
if statMatch then statMatch:roster(units) end
if arenaSupport.standaloneStoryUnits then arenaSupport.standaloneStoryUnits:prune(units) end
arenaActors={}
local routes={}
for _,entry in ipairs(units) do
arenaActors[#arenaActors+1]=entry.actor
routes[entry.actor]=spawnRoutes[entry.actor]
end
spawnRoutes=routes
end,
onMatchSnapshot=function(members,relay)
if arenaSupport.matchReport then arenaSupport.matchReport:capture(members,relay) end
end,
onMatchEnded=function(result)
if arenaSupport.matchReport then arenaSupport.matchReport:finish(result) end
end,
onBattleStarted=function(a,b)
StartDuelWatch(a,b)
BeginArenaObservation(a,b)
end})
local summonLinks=SummonLinks.new({getWorld=GetCurrentWorld,getNPCs=CollectNPCs,log=log,
allowNPC=function(actor)return not IsExcluded(actor)end,
idleOwner=function(actor)
local tag=UEObserve.struct(UEObserve.field(GetAIComp(actor),'CurrentStateTag'),'TagName')
local state=tag and FNameToString(tag)
if state~='AI.State.Idle' and not (state and state:match('^AI%.State%.Idle%.')) then return false end
local mesh=UEObserve.field(actor,'Mesh')
if not UEObserve.valid(mesh) then return false end
local anim=mesh:GetAnimInstance()
return UEObserve.valid(anim) and anim:IsAnyMontagePlaying()==false
end,
localNPC=(type(Config.EnemyClasses)=='table' and #Config.EnemyClasses==1 and Config.EnemyClasses[1]=='PBZCharacter_NPC') and function(actor)
local player=GetPlayerPawn();return safeValid(player) and UEObserve.key(player)~=UEObserve.key(actor)
end or nil})
arenaSupport.menghuaPhase=require('menghua_phase').new({log=log,clock=LiveSeconds,world=GetCurrentWorld,hp=GetHP,isDestroying=actorIsDestroying,
rule=function(id)return arenaSupport.unitRules and arenaSupport.unitRules:get(id,'menghua_stage') or 'keep' end,
ready=function()return runtimeSession:status().game_ready==true end,
gameTime=GameSeconds,opponent=function(actor,team)
local target=arenaSupport:skillOpponent(actor,team)
if target or team=='companion' or not arena:intentContext() then return target end
local fallback=arena:opponentOf(UEObserve.key(actor))
if ReadRelation(actor,fallback)==HOSTILE then return fallback end
end,
canRequest=function(actor)
local continuity=arenaSupport.combatContinuity
return continuity~=nil and not freeCamera:isFrozen() and not continuity:actionBusy(actor)
end,
boardOf=function(actor)return UEObserve.field(GetAIComp(actor),'BlackboardComponent')end})
arenaActivity=ArenaActivity.new({log=log,isNPC=function(actor)return spawnRoutes[actor]~='actor' end,
freeCam=function()return freeCamera:isActive() or safeValid(arenaSupport:debugCameraForSupport()) end,
context=function()
local debugCamera=arenaSupport:debugCameraForSupport()
local original=UEObserve.field(debugCamera,'OriginalControllerRef')
local originalPawn=UEObserve.field(original,'Pawn')
local world=GetCurrentWorld()
local level=UEObserve.field(world,'PersistentLevel')
local settings=UEObserve.field(level,'WorldSettings')
return 'mod_player='..tostring(UEObserve.key(GetPlayerPawn()))
..' debug_original_pawn='..tostring(UEObserve.key(originalPawn))
..' world_time='..tostring(UEObserve.field(settings,'TimeDilation'))
..' cinematic_time='..tostring(UEObserve.field(settings,'CinematicTimeDilation'))
end})
local function GetMaxHP(actor)
if not engineValid(actor) then return nil end
local attributes=actor.AttributeSetBase
if not engineValid(attributes) then return nil end
return attributes.Health_Max.CurrentValue
end
function arenaSupport.hunVitalsFor(unit)
local body=arenaSupport.hunBody
if not body or unit.class_path~=require('hun_body').path then return end
local key=UEObserve.key(unit.actor)
if not key then return end
local values=arenaSupport.hudSamples
if not values then return body:hudVitals(unit) end
if values[key]==nil then values[key]=body:hudVitals(unit) or false end
return values[key] or nil
end
arenaSupport.hudMenu=require('arena_menu').new({world=GetCurrentWorld,player=GetRealPlayerController,log=log})
bossHUD=BossHUD.new({getController=GetRealPlayerController,getWorld=GetCurrentWorld,hp=GetHP,maxHP=GetMaxHP,vitals=arenaSupport.hunVitalsFor,
menuHidden=function(active)return arenaSupport.hudMenu:hidden(active)end,
codexPath=Config.RuntimePath..'/codex.tsv',log=log,
extraBossName=function(unit)
local hun=arenaSupport.hunBody and arenaSupport.hunBody:teamBarName(unit)
if hun then return hun end
local story=arenaSupport.standaloneStoryUnits
return story and story:teamBossName(unit.actor)
end})
-- Companions show the game's own health bar above their heads, as enemies do (companion_bars.lua).
local companionBars=Config.ShowCompanionHealthBars and CompanionBars.new({log=log,hp=GetHP,maxHP=GetMaxHP,
vitals=arenaSupport.hunVitalsFor,
arenaBar=function(unit)return arenaSupport.hunBody and unit.class_path==require('hun_body').path and arenaSupport.hunBody:owns(unit.actor) end}) or nil
-- One copy of the arena's members and status per support tick: a dozen modules ask for them, and each
-- call re-checks every unit with the engine (50 units made the support tick take 20-50 ms in v0.37.2).
-- Outside a tick the arena is asked directly.
local tickMembers,tickStatus
local function ArenaMembers()return tickMembers or arena:members() end
local function ArenaStatus()return tickStatus or arena:status() end
statMatch=StatMatch.new({path=Config.RuntimePath,log=log})
arenaSupport.companionStats=StatMatch.new({path=Config.RuntimePath,log=log,tag='[CompanionStats]',customOnly=true,
settings='companion-stats-settings.tsv',request='companion-stats-request.tsv'})
spawnDifficulty=SpawnDifficulty.new({path=Config.RuntimePath,log=log,getWorld=GetCurrentWorld,
ready=function()return runtimeSession:status().game_ready==true end})
statProbe=Config.EnableStatFormulaProbe and StatFormulaProbe.new({log=log}) or nil
fieldProbe=Config.EnableStatFieldProbe and StatFieldProbe.new({log=log}) or nil
-- The game cycle (new game plus count): the game adds 25 levels per cycle to its own enemies (BP_RenewalNPC
-- "Init Level"). Read with the same library call, at most every 10 s, logged when it changes.
local cycleRead={}
local function GameCycle()
local world=GetCurrentWorld()
local key=UEObserve.key(world)
if not key then cycleRead={};return nil end
local now=os.clock()
if cycleRead.world==key and now-cycleRead.at<10 then return cycleRead.value end
local library=StaticFindObject('/Script/ProjectPBZ.Default__PBZBlueprintFunctionLibrary')
if not safeValid(library) then return nil end
local ok,value=pcall(function()return library:GetGameCycle(world)end)
local cycle=ok and tonumber(UEObserve.unwrap(value)) or nil
if cycleRead.world~=key or cycle~=cycleRead.value then
log('[HomeLevels] 读游戏周目 调用='..tostring(ok)..' 读回='..tostring(cycle)..(ok and '' or ' 错误='..tostring(value)))
end
cycleRead={world=key,at=now,value=cycle}
return cycle
end
-- Where a summon's level comes from: its home (default), the map enemies near the player, or one level (home_levels.lua).
local homeLevels=HomeLevels.new({log=log,path=Config.RuntimePath,
context=function(actor)
local slot=actor and spawnDifficulty and spawnDifficulty:levelOf(actor) or (spawnDifficulty and spawnDifficulty:status().game) or nil
return {difficulty=slot~='' and slot or nil,cycle=GameCycle()}
end,
cycleExempt=function(actor)
if not summonActorLive(actor) then return nil end
local asc=UEObserve.field(actor,'AbilitySystemComponent')
if not safeValid(asc) then return nil end
local ok,value=pcall(function()return asc:GetGameplayTagCount({TagName=FName('CharacterState.NotUpgradeLevel')})end)
local count=ok and tonumber(UEObserve.unwrap(value))
if count then return count>0 end
end})
spawnLevel=SpawnLevel.new({log=log,path=Config.RuntimePath,getPlayer=GetPlayerPawn,getLocation=GetLocation,collect=CollectNPCs,homeLevels=homeLevels,
-- The loaded world's name (PBZ_Xigu_WP): spawner places and the remembered level are per world.
getWorldName=function()
local world=GetCurrentWorld()
if not safeValid(world) then return nil end
local ok,name=pcall(function()return world:GetFName():ToString()end)
return ok and type(name)=='string' and name or nil
end,
ours=function()
-- A summoned rider's mount came out of a spawner too; it is the mod's, not a map enemy.
local keys=mounts and mounts:keys() or {}
for _,entry in ipairs(ArenaMembers())do local key=UEObserve.key(entry.actor);if key then keys[key]=true end end
return keys
end})
arenaSupport.matchReport=require('match_report').new({path=Config.RuntimePath,build=BUILD,log=log,
context=function()
local world=GetCurrentWorld()
local map
if safeValid(world) then
local ok,name=pcall(function()return world:GetFName():ToString()end)
if ok then map=name end
end
local difficulty=spawnDifficulty and spawnDifficulty:status() or {}
return {map=map,saveCycle=GameCycle(),levelMode=homeLevels:status().mode,
statsMode=statMatch and statMatch.mode,defaultDifficulty=difficulty.game,difficultyMode=difficulty.level}
end,
difficultyOf=function(actor)return spawnDifficulty and spawnDifficulty:levelOf(actor)end,
storyLinkOf=function(actor)return arenaSupport.menghuaPhase:storyLink(actor)end})
-- Riders: an empty spawner of the mod's where they are summoned, their mount found and cleared with them (mounts.lua).
mounts=Config.SummonRiderMounts and Mounts.new({log=log,location=GetLocation,isDestroying=actorIsDestroying,
player=Config.EnableSummonLockProbe==true and GetPlayerPawn or nil,
findClass=function(path)return StaticFindObject(path)end,statics=GetGameplayStatics,
findAll=function(name)return FindAllOf(name)end,hp=GetHP,attack=ForceAttack,world=GetCurrentWorld,
companionOpponent=function(actor)return arenaSupport:skillOpponent(actor,'companion')end,
syncCompanionMount=function(mount,rider,target)return arenaSupport:syncCompanionMount(mount,rider,target)end,
scripts=function(rider)return UEObserve.array(UEObserve.field(GetAIComp(rider),'SpawnedAIScripts'))end,
nativeTarget=function(mount)return arenaSupport.hunNativeTarget(mount,true)end,
assignedTarget=function(rider)
local target=arena:aggroOpponent(rider)
if target and not arenaSupport.combatContinuity:keepOpponent(rider,true) and not arenaSupport.combatContinuity:keepOpponent(target,true) then return target end
end,
inCombat=function(actor)
local sg=GetAIComp(actor)
if not sg then return nil end
local ok,tag=pcall(function()return FNameToString(sg.CurrentStateTag.TagName)end)
if not ok or type(tag)~='string' then return nil end
return tag:find('Combat',1,true)~=nil,tag
end,
engage=function(attacker,victim)return arenaSupport:engage(attacker,victim)end,
destroy=function(actor)checked(actor);actor:K2_DestroyActor()end}) or nil
-- The ground under a spot: a visibility trace from 3 m over the summon height down 30 m; nil when it hits nothing.
-- The first few misses are logged with what the trace returned.
local groundMisses,groundRead=0,false
-- up: how far over z the trace starts (a unit's own body would stop one started over it).
local function GroundZ(world,x,y,z,up,ignored)
local lib=StaticFindObject('/Script/Engine.Default__KismetSystemLibrary')
if not safeValid(lib) or not safeValid(world) then return nil end
local out,none={},{R=0,G=0,B=0,A=0}
local start,finish=z+(up or 300),z-3000
local ok,hit=pcall(function()return lib:LineTraceSingle(world,{X=x,Y=y,Z=start},{X=x,Y=y,Z=finish},0,false,ignored or {},0,out,true,none,none,0)end)
-- The table passed as OutHit comes back with the hit's own fields. bStartPenetrating reads true on every hit there
-- (seen with Distance 183 and PenetrationDepth 0), so a start inside something is told by a Distance of 0. The trace
-- goes straight down, so its Distance gives the height when the point does not read.
local found,how
local distance=ok and hit==true and UEObserve.unwrap(out.Distance)
if ok and hit==true and not (type(distance)=='number' and distance<=0) then
local okZ,impact=pcall(function()return out.ImpactPoint.Z end)
local time=UEObserve.unwrap(out.Time)
if okZ and type(impact)=='number' then found,how=impact,'ImpactPoint'
elseif type(distance)=='number' then found,how=start-distance,'Distance'
elseif type(time)=='number' then found,how=start+(finish-start)*time,'Time' end
if found and (found>start+1 or found<finish-1) then found=nil end
end
if found then
if not groundRead then
groundRead=true
log(string.format('[Ground] 地面检测读回 来源=%s Z=%.1f 起点Z=%.1f 距离=%s',how,found,start,tostring(out.Distance)))
end
return found
end
if ok and hit~=true then return nil end
groundMisses=groundMisses+1
if groundMisses<=3 then
local keys={}
for key in pairs(type(out)=='table' and out or {})do keys[#keys+1]=tostring(key) end
log(string.format('[Ground] 地面检测没结果:调用=%s 返回=%s 输出字段=[%s] 命中点Z=%s%s',tostring(ok),tostring(hit),table.concat(keys,','),
tostring(found),ok and '' or ' 错误='..tostring(hit)))
local okDump,dump=pcall(function()
local impact=out.ImpactPoint
local parts={'ImpactPoint类型='..type(impact),'Distance='..tostring(out.Distance)..'('..type(out.Distance)..')','Time='..tostring(out.Time)..'('..type(out.Time)..')',
'bStartPenetrating='..tostring(out.bStartPenetrating),'bBlockingHit='..tostring(out.bBlockingHit),'PenetrationDepth='..tostring(out.PenetrationDepth)}
if type(impact)=='table' then
local inner={}
for key,value in pairs(impact)do inner[#inner+1]=tostring(key)..'='..tostring(value) end
parts[#parts+1]='ImpactPoint内容=['..table.concat(inner,',')..']'
end
return table.concat(parts,' ')
end)
log('[Ground] 命中内容 起点Z='..tostring(start)..' '..tostring(dump))
end
-- The caller can tell a start inside something solid from nothing under the start.
return nil,(type(distance)=='number' and distance<=0) and 'inside' or nil
end
onGround=require('on_ground').new({log=log,location=GetLocation,ground=GroundZ,label=objectName,player=GetPlayerPawn,world=function()return GetCurrentWorld()end,
anchor=function()return arenaSupport.spawnSpot and arenaSupport.spawnSpot:anchor() end,
name=function(text)return FName(text)end})
-- A straight line through the world: where it hits and which way that surface faces, for the summon spot and the view.
-- Starting inside something solid reads as Distance 0.
-- channel: ETraceTypeQuery, 0 = visibility (the default), 1 = camera.
function arenaSupport:traceLine(world,from,to,channel,ignore)
local lib=StaticFindObject('/Script/Engine.Default__KismetSystemLibrary')
if not safeValid(lib) or not safeValid(world) then return nil end
local out,none={},{R=0,G=0,B=0,A=0}
local query=channel==1 and 1 or 0
local ignored=ignore and safeValid(ignore) and {ignore} or {}
local ok,hit=pcall(function()return lib:LineTraceSingle(world,from,to,query,false,ignored,0,out,true,none,none,0)end)
if not ok or hit~=true then return nil end
local distance=UEObserve.unwrap(out.Distance)
if type(distance)=='number' and distance<=0 then return {inside=true} end
local got,at=pcall(function()
local point=out.ImpactPoint
return {X=point.X,Y=point.Y,Z=point.Z}
end)
if not got or type(at.X)~='number' or type(at.Y)~='number' or type(at.Z)~='number' then
local time=UEObserve.unwrap(out.Time)
if type(time)~='number' then return nil end
at={X=from.X+(to.X-from.X)*time,Y=from.Y+(to.Y-from.Y)*time,Z=from.Z+(to.Z-from.Z)*time}
end
local okNormal,normal=pcall(function()
local face=out.ImpactNormal
return {X=face.X,Y=face.Y,Z=face.Z}
end)
-- A skeleton answers with the bone it was hit on; a wall, the ground or a capsule with None.
local okBone,bone=pcall(function()return out.BoneName:ToString() end)
return {at=at,normal=okNormal and normal or nil,distance=distance,bone=okBone and type(bone)=='string' and bone~='None' and bone~='' and bone or nil}
end
arenaSupport.spawnSpot=require('spawn_spot').new({log=log,ground=GroundZ,view=function()return freeCamera:view() end,
trace=function(world,from,to)return arenaSupport:traceLine(world,from,to) end})
-- 镜头跟踪: the free camera follows a unit and keeps its opponent in the picture (camera_track.lua).
arenaSupport.track=require('camera_track').new({log=log,world=GetCurrentWorld,path=Config.RuntimePath,members=ArenaMembers,hp=GetHP,location=GetLocation,player=GetPlayerPawn,
view=function()return freeCamera:view() end,fov=function()return freeCamera:fieldOfView() end,
activity=function(actor,other)
if arenaExecutions and (arenaExecutions:participant(actor) or arenaExecutions:participant(other)) then return 'execution' end
if arenaSupport:combatPhaseBusy(actor) or arenaSupport:combatPhaseBusy(other) then return 'phase' end
if (onGround:tagCount(actor,'Ability.Action') or 0)>0 or (onGround:tagCount(other,'Ability.Action') or 0)>0 then return 'attack' end
end,
trace=function(world,from,to,channel,ignore)return arenaSupport:traceLine(world,from,to,channel,ignore) end,
isBoss=function(actor)
local asc=UEObserve.field(actor,'AbilitySystemComponent')
if not safeValid(asc) then return false end
local ok,count=pcall(function()return asc:GetGameplayTagCount({TagName=FName('CharacterType.AI.Boss')})end)
count=ok and UEObserve.unwrap(count) or 0
return type(count)=='number' and count>0
end,
cinemaOpponentOf=function(actor)return arena:opponentOf(UEObserve.key(actor))end,
-- The arena's opponent for blue and red; a companion or a unit with no team: whoever its AI is after, unless that is the player.
opponentOf=function(actor)
local who=arena:opponentOf(UEObserve.key(actor))
if safeValid(who) then return who end
local board=UEObserve.field(GetAIComp(actor),'BlackboardComponent')
if not safeValid(board) then return nil end
local ok,value=pcall(function()return board:GetValueAsObject(FName('TargetActor'))end)
value=ok and UEObserve.unwrap(value) or nil
local player=GetPlayerPawn()
if safeValid(value) and not (safeValid(player) and value:GetAddress()==player:GetAddress()) then return value end
end})
arenaSupport.lionStage=require('lion_stage').new({log=log,location=GetLocation,player=GetPlayerPawn,
world=GetCurrentWorld,isDestroying=actorIsDestroying,hp=GetHP,now=GameSeconds,statics=GetGameplayStatics})
arenaSupport.lionWave=require('lion_challenge').new({world=GetCurrentWorld,hp=GetHP,clock=GameSeconds,findAll=FindAllOf,
paused=function()return freeCamera:isFrozen()end,
tag=function(actor,tag)return onGround:tagCount(actor,tag)end,
companionOpponent=function(actor)return arenaSupport:skillOpponent(actor,'companion')end,
fieldEnabled=function(actor)return not freeCamera:isFrozen() and arenaSupport:companionCanAct(actor)end,
focusCompanion=function(actor,cubs,boss)return arenaSupport:focusLionCubs(actor,cubs,boss)end})
arenaSupport.lionNPC=require('lion_npc').new({challenge=arenaSupport.lionWave,log=log,location=GetLocation,ground=GroundZ,
paused=function()return freeCamera:isFrozen()end,
world=GetCurrentWorld,isDestroying=actorIsDestroying,hp=GetHP,now=GameSeconds,statics=GetGameplayStatics,
area=function(actor,world)return arenaSupport.lionStage:areaFor(actor,world)end,
opponent=function(actor)return arena:opponentOf(UEObserve.key(actor))end,
busy=function(actor)
return arenaExecutions and (arenaExecutions:executing(actor) or arenaExecutions:guillotineHeld(actor)) or false
end,
carrier=function(actor)if mounts then return mounts:carrierOf(actor) end;return actor end,
library=function()return StaticFindObject('/Script/ProjectPBZ.Default__PBZAbilityBlueprintLibrary')end,
combat=require('lion_pole_combat').new({log=log,location=GetLocation,hp=GetHP,isDestroying=actorIsDestroying,
pose=function(actor,clip,looping)if arenaExecutions then return arenaExecutions:borrowPolePose(actor,clip,looping) end end}),
range=function(actor)
local controller=UEObserve.field(GetAIComp(actor),'AIController')
local library=StaticFindObject('/Script/SGameAI.Default__SGameAIFunctionLibrary')
if not safeValid(library) or not safeValid(controller) then return nil end
local ok,value=pcall(function()return library:FindFloatParameter(controller,FName('立回-近距离分界线'))end)
return ok and type(value)=='number' and value>0 and value or nil
end})
-- Staged bosses: the markers of their own arena placed around them, and their phase marks logged (boss_stages.lua).
bossStages=BossStages.new({log=log,location=GetLocation,isDestroying=actorIsDestroying,player=GetPlayerPawn,hp=GetHP,
world=GetCurrentWorld,
idleCompanion=function(actor)return arenaSupport:canMoveCompanionCenter(actor)end,
onUsed=function(actor)if playerAim then playerAim:lockAbilityOf(actor) end end,
saveData=function(id)return arenaSupport:actorSaveData(id)end,
-- The save-repair button asks for 冷荼's old checkpoint to be cleared (save_repair.lua).
checkpoint={wants=function(id)return arenaSupport.saveRepair~=nil and arenaSupport.saveRepair:wantsCheckpoint(id)end,
done=function(id,ok,read)if arenaSupport.saveRepair then arenaSupport.saveRepair:checkpointDone(id,ok,read) end end},
findClass=function(path)return StaticFindObject(path)end,loadClass=function(path)return LoadAsset(path)end,
statics=GetGameplayStatics,findAll=function(name)return FindAllOf(name)end,ground=GroundZ,
-- How many actors of a targeting type are registered in this world (左殇's ground weapons, what CA_02 will find).
targetsByTag=function(tag)
local world=GetCurrentWorld()
local ok,sub=pcall(FindFirstOf,'TargetingWorldSubsystem')
if not ok or not safeValid(sub) or not UEObserve.inWorld(sub,world) then return nil end
local out={}
local called=pcall(function()sub:GetTargetsByTag({TagName=FName(tag)},true,out)end)
local list=called and UEObserve.array(out.OutTargets) or nil
return list and #list or nil
end,
tagCount=function(actor,tag)
local asc=UEObserve.field(actor,'AbilitySystemComponent')
if not safeValid(asc) then return nil end
local ok,n=pcall(function()return asc:GetGameplayTagCount({TagName=FName(tag)})end)
return ok and type(n)=='number' and n or nil
end,
destroy=function(actor)checked(actor);actor:K2_DestroyActor()end})
local grabStudy=Config.EnableGrabStudy and GrabStudy.new({path=Config.RuntimePath,log=log,ready=function()return runtimeSession:status().game_ready==true end}) or nil
arenaGrabs=ArenaGrabs.new({path=Config.RuntimePath,log=log,hp=GetHP,world=GetCurrentWorld,player=GetPlayerPawn,inGameThread=IsInGameThread,ready=function()return runtimeSession:status().game_ready==true end,
isHun=function(actor)return arenaSupport.hunBody~=nil and arenaSupport.hunBody:owns(actor)end})
-- Sends a unit that left combat back at its opponent: hatred entry and ForceIntoCombat. The faction
-- relation and blackboard target written by ForceAttack at the start still hold.
function arenaSupport:engage(attacker,victim)
local sg=GetAIComp(attacker)
if not sg or not safeValid(victim) then return false,'AI组件或目标无效' end
local hm=GetHatredComp(attacker)
local hatred='?';pcall(function()hatred=#hm.HatredList end)
AddHatred(attacker,victim)
local ok=pcall(function()sg:ForceIntoCombat(victim)end)
local state='?';pcall(function()state=FNameToString(sg.CurrentStateTag.TagName)end)
local a,b=GetLocation(attacker),GetLocation(victim)
local d=a and b and math.sqrt(DistSq(a,b))/100
return ok,state,'迎敌前仇恨数='..tostring(hatred)..' 距目标='..(d and string.format('%.1fm',d) or '?')
end
-- A summon sent to fight its own summoner's side (opposing: SummonCombatTargetMode EncounterSummons or Summoner, its
-- faction set to the player's) is the player's help in that story fight: 冷荼's 彭猛, 峨眉/华山, 风雪刀客, 舞狮 and
-- 雷当, 梦华's 虚空. In the arena it is taken out as it comes; true once it is gone or going.
function arenaSupport:removeHelper(link)
if self.menghuaPhase and self.menghuaPhase:handle(link) then return true end
local actor=link.actor
if not safeValid(actor) then return true end
local name=objectName(actor)
local called,callError=pcall(function()actor:K2_DestroyActor()end)
local okRead,going=pcall(actorIsDestroying,actor)
local gone=not safeValid(actor) or (okRead and going==true)
if gone then self.helpersRemoved=(self.helpersRemoved or 0)+1 end
self.helperLines=(self.helperLines or 0)+1
if self.helperLines<=30 then
log(string.format('[SummonLinks] 移除剧情帮手 %s(召唤者 %s;%s;原版是来帮玩家打召唤者的)调用=%s%s 读回 正在销毁=%s 累计=%d',
name,objectName(link.parent),tostring(link.evidence and link.evidence:match('SummonCombatTargetMode=[%w_]+') or '?'),tostring(called),
called and '' or '('..tostring(callError)..')',tostring(gone),self.helpersRemoved or 0))
end
return gone
end
function arenaSupport:discover(background)
for _,link in ipairs(summonLinks:scan(ArenaMembers(),function(ability)self.summonKeep:passive(ability);self.entourage:passive(ability)end,background)) do
if not (link.opposing and self:removeHelper(link)) then
-- A summon's own summon that writes story progress: its summoner was let in only with the story holding
-- that already; logged once here if not (story_writes.lua says it once per class).
if self.storyWrites then self.storyWrites:allowsUnit(link.class_path) end
-- A helper that could not be taken out joins the team it fights for (arena_controller.lua aid).
local result=arena:adoptSummon(link.actor,link.parent,link.class_path,link.evidence,link.opposing and 'opposing' or nil)
if not result.ok then log('[SummonLinks] 接管未确认:'..tostring(result.message)) end
end
end
end
arenaSupport.stands=require('arena_stands').new({log=log,members=ArenaMembers,aiOf=GetAIComp})
function arenaSupport:cameraAt()
local lib,world=GetGameplayStatics(),GetCurrentWorld()
if not safeValid(lib) or not safeValid(world) then return nil end
local ok,manager=pcall(function()return lib:GetPlayerCameraManager(world,0)end)
if not ok or not safeValid(manager) then return nil end
local okLocation,location=pcall(function()return manager:GetCameraLocation()end)
return okLocation and location or nil
end
arenaSupport.standKeep=require('stand_keep').new({log=log,members=ArenaMembers,clock=LiveSeconds,location=GetLocation,ground=onGround,label=objectName,
camera=function()return arenaSupport:cameraAt() end})
-- The loaded world's subsystem of a class (its outer chain reaches the world; the class default object's does not), kept per world.
arenaSupport.subsystems={}
function arenaSupport:worldSubsystem(name)
local world=GetCurrentWorld()
local worldKey=safeValid(world) and UEObserve.key(world)
if not worldKey then return nil end
local kept=self.subsystems[name]
if kept and kept.world==worldKey and safeValid(kept.object) then return kept.object end
self.subsystems[name]=nil
local ok,list=pcall(FindAllOf,name)
if not ok or type(list)~='table' then return nil end
for _,object in ipairs(list)do
if safeValid(object) and UEObserve.inWorld(object,world) then
self.subsystems[name]={world=worldKey,object=object}
return object
end
end
end
arenaSupport.summonTargetRegistration=require('summon_target_registration').new({
world=GetCurrentWorld,hp=GetHP,isDestroying=actorIsDestroying,inGameThread=IsInGameThread,log=log,
subsystem=function()return arenaSupport:worldSubsystem('TargetingWorldSubsystem')end})
-- A summoned phase-one 雷当 must not write the story's 雷当-killed tag, and a save that already has it does not keep phase one's spawner on (story_guard.lua).
arenaSupport.storyGuard=require('story_guard').new({log=log,members=ArenaMembers,clock=LiveSeconds,label=objectName,
tagCount=function(actor,tag)return onGround:tagCount(actor,tag)end,
aiSubsystem=function()return arenaSupport:worldSubsystem('SGameAIWorldSubsystem')end,
pipeline=function()return arenaSupport:worldSubsystem('EventPipelineManager')end})
-- Finishers and units that write story progress (story_writes.lua) and the fifth 龙柱 trial's ending (longzhu_check.lua).
arenaSupport.storyWrites=require('story_writes').new({log=log,clock=LiveSeconds,
pipeline=function()return arenaSupport:worldSubsystem('EventPipelineManager')end})
arenaSupport.longzhu=require('longzhu_check').new({log=log,clock=LiveSeconds,
pipeline=function()return arenaSupport:worldSubsystem('EventPipelineManager')end})
-- Whether the save holds an entry under this actor ID (PBZLevelActorManager): true, false, or nil when unread.
function arenaSupport:actorSaveData(id)
local manager=self:worldSubsystem('PBZLevelActorManager')
if not safeValid(manager) then return nil end
local ok,value=pcall(function()return manager:HasSaveDataByActorID(FName(id))end)
if ok then value=UEObserve.unwrap(value) else value=nil end
if type(value)=='boolean' then return value end
return nil
end
-- The app's save-repair button (save_repair.lua): arms the repairs above and 冷荼's, and reports what it found.
arenaSupport.saveRepair=require('save_repair').new({log=log,longzhu=arenaSupport.longzhu,guard=arenaSupport.storyGuard,
has=function(text)return arenaSupport.storyWrites:has(text)end,
pipeline=function()return arenaSupport:worldSubsystem('EventPipelineManager')end,
hasSaveData=function(id)return arenaSupport:actorSaveData(id)end})
arenaSupport.summonKeep=require('summon_keep').new({log=log,members=ArenaMembers,aiOf=GetAIComp})
-- A fighter locked on a boss the game keeps out of reach is moved to its opponent (lock_release.lua).
arenaSupport.lockRelease=require('lock_release').new({log=log,
actionBusy=function(actor)return arenaSupport.combatContinuity:actionBusy(actor)end,
untargetable=function(actor)return bossStages~=nil and bossStages:untargetable(actor)end})
companions=Companion.new({log=log,busy=function(actor)
local r=arenaSupport.companionManager and arenaSupport.companionManager:lookup(actor)
return r and (r.swapping or r.blocked or r.pose or r.waiting or r.lease) or arenaSupport.menghuaPhase:busy(actor)
or arenaSupport.lionNPC:engaged(actor) or arenaExecutions and arenaExecutions:participant(actor)
or arenaSupport.teleport and arenaSupport.teleport:relocating() or false
end,beforeRecall=function(actor)
return not arenaSupport.companionManager or arenaSupport.companionManager:prepareRecall(actor)
end,profile=function(actor)return arenaSupport.companionManager and arenaSupport.companionManager:forActor(actor)end,
hostile=function(actor,enemy)
return summonActorLive(enemy) and UEObserve.inWorld(enemy,GetCurrentWorld()) and ReadRelation(actor,enemy)==2
end,getPlayer=GetPlayerPawn,getWorld=GetCurrentWorld,aiLib=GetAILib,getLocation=GetLocation,hp=GetHP,
combatTarget=function(actor)
if arenaSupport.companionCombatTarget then return arenaSupport.companionCombatTarget(actor) end
end,
canRecover=function(actor,target)
local intent=arenaSupport.combatContinuity
if not intent or freeCamera:isFrozen() or intent:protected(actor,true)~=false or intent:actionBusy(actor) then return false end
local speed=UEObserve.field(actor,'CustomTimeDilation')
if type(speed)=='number' and speed<.1 then return false end
if target and (intent:protected(target,true)~=false or intent:threatProtected(target)) then return false end
local brain=UEObserve.field(UEObserve.field(actor,'Controller'),'BrainComponent')
if not UEObserve.valid(brain) then return false end
local ok,ready=pcall(function()return brain:IsRunning()==true and brain:IsPaused()==false end)
return ok and ready
end,
members=ArenaMembers,clock=LiveSeconds})
-- Read-only: which of a companion's attacks may hit the player, and why (companion_hit_probe.lua).
companionHitProbe=Config.EnableCompanionHitProbe and CompanionHitProbe.new({log=log,getPlayer=GetPlayerPawn,hp=GetHP,location=GetLocation,
members=ArenaMembers,factionSubsystem=function()local ok,found=pcall(FindFirstOf,'FactionSubSystem');return ok and found or nil end}) or nil
-- Read-only: every loaded attack that can reach the attacker's own allies (attack_faction_scan.lua).
attackScan=Config.EnableAttackFactionScan and AttackFactionScan.new({log=log,path=Config.RuntimePath,
ready=function()return runtimeSession:status().game_ready==true end}) or nil
-- Experiment: save a few codex pictures as PNG on this PC (codex_art_probe.lua).
codexArt=Config.EnableCodexArtProbe and CodexArtProbe.new({log=log,path=Config.RuntimePath,getWorld=GetCurrentWorld,
ready=function()return runtimeSession:status().game_ready==true end}) or nil
-- The codex busts for the app's unit cards, saved on this PC from the player's own game (codex_icons.lua).
codexIcons=Config.EnableCodexIcons and CodexIcons.new({log=log,path=Config.RuntimePath,getWorld=GetCurrentWorld,
extraTextures=require('hun_icon_catalog'),paused=function()return ArenaStatus().battle_active==true end,
ready=function()return runtimeSession:status().game_ready==true end}) or nil
-- Units summoned at a chosen difficulty also get that difficulty when their AI asks for it.
aiDifficulty=AIDifficulty.new({log=log,getWorld=GetCurrentWorld,
ready=function()return runtimeSession:status().game_ready==true end,members=ArenaMembers,
levelOf=function(actor)return spawnDifficulty:levelOf(actor)end})
-- Infinite Shachi and auto deflect/dodge for the player only; paused while the free camera observes.
funFeatures=FunFeatures.new({log=log,path=Config.RuntimePath,getPlayer=GetPlayerPawn,getController=GetRealPlayerController,
members=ArenaMembers,
ready=function()return runtimeSession:status().game_ready==true end,paused=function()return freeCamera:isActive()end})
-- 不倒下: units of a switched-on team keep a health floor; after a reload the journal frees the old ones.
immortalTeams=ImmortalTeams.new({log=log,path=Config.RuntimePath,members=ArenaMembers,collect=CollectNPCs,hp=GetHP,
isDestroying=actorIsDestroying,
ready=function()return runtimeSession:status().game_ready==true end})
-- The fight time at the top centre of the game screen, when switched on in the app (battle_clock_hud.lua).
clockHUD=BattleClockHUD.new({log=log,path=Config.RuntimePath,getController=GetRealPlayerController,getWorld=GetCurrentWorld,
getPlayer=GetPlayerPawn,ready=function()return runtimeSession:status().game_ready==true end,
clock=function()local s=ArenaStatus();return s.battle_clock,s.battle_seconds end})
-- 不死不休: while a fight runs, blue and red do not leave combat after an action and may hate each
-- other through the game's own hatred checks (combat_lock.lua).
-- The Hun body takes the count, attribute values and accessory effects of the profile the panel last saved.
local hunLoadout=require('hun_loadout').new({path=Config.RuntimePath,log=log})
arenaSupport.hunLoadout=function()return hunLoadout:read()end
function arenaSupport.hunNativeTarget(actor,privateOnly)
local ai=GetAIComp(actor)
local pawn=UEObserve.field(ai,'Pawn')
if UEObserve.valid(pawn) and UEObserve.key(pawn)~=UEObserve.key(actor) then return end
local board=UEObserve.field(ai,'BlackboardComponent')
local boardKey=UEObserve.key(board)
if not boardKey then return end
local handler
if privateOnly then
handler=UEObserve.field(UEObserve.field(actor,'Targeting Component'),'DefaultTargetHandler')
if UEObserve.key(UEObserve.field(handler,'Blackboard'))~=boardKey then return end
else handler=arenaSupport:targetHandler(actor,board) end
local key
if UEObserve.valid(handler) then key=UEObserve.field(handler,'Target Key') else key=FName('TargetActor') end
if key==nil then return end
local ok,target=pcall(function()return UEObserve.unwrap(board:GetValueAsObject(key))end)
if not ok then return end
if UEObserve.valid(target) then return target end
local sensed=UEObserve.field(handler,'LastSensedActorKey')
if sensed==nil or UEObserve.key(UEObserve.field(handler,'Blackboard'))~=boardKey
or UEObserve.key(UEObserve.field(ai,'BlackboardComponent'))~=boardKey then return end
ok,target=pcall(function()return UEObserve.unwrap(board:GetValueAsObject(sensed))end)
if ok and UEObserve.valid(target) then
if not arenaSupport.loggedSensedLock then
arenaSupport.loggedSensedLock=true
log('[ArenaTarget] 原生主目标为空,最后感知目标读回 '..objectName(actor)..' -> '..objectName(target))
end
return target
end
end
function arenaSupport.gamePaused()
local lib,world=GetGameplayStatics(),GetCurrentWorld()
if not safeValid(lib) or not safeValid(world) then return false end
local ok,value=pcall(function()return UEObserve.unwrap(lib:IsGamePaused(world))end)
return ok and value==true
end
arenaSupport.hunBody=require('hun_body').new({log=log,probe=Config.EnableHunBodyProbe==true,world=GetCurrentWorld,player=GetPlayerPawn,hp=GetHP,aiOf=GetAIComp,loadout=arenaSupport.hunLoadout,
paused=arenaSupport.gamePaused,
requireProfile=true,nativeTarget=arenaSupport.hunNativeTarget,
target=function(actor,team)
if team=='blue' or team=='red' then return arena:opponentOf(UEObserve.key(actor)) end
if team=='companion' then return arenaSupport.hunCompanionTarget and arenaSupport.hunCompanionTarget(actor) end
if team=='neutral' then
local target=arenaSupport.hunNativeTarget(actor)
if target and UEObserve.key(target)==UEObserve.key(GetPlayerPawn()) and (GetHP(target) or 0)>0 then return target end
end
end,
pairProtected=function(r,target)
return (r.team=='blue' or r.team=='red') and
(arenaSupport.combatContinuity:keepOpponent(r.actor) or arenaSupport.combatContinuity:keepOpponent(target))
end,
challenge=function(actor)
if spectator:status().enabled_requested or not arenaSupport.hunBody:owns(actor) then return end
local player=GetPlayerPawn()
if not UEObserve.valid(player) or (GetHP(player) or 0)<=0 or (GetHP(actor) or 0)<=0 then return end
local faction=UEObserve.field(actor,'Faction Component')
if not UEObserve.valid(faction) then return end
local ok,relation=pcall(function()return UEObserve.unwrap(faction:GetFactionRelation(player))end)
if ok and tonumber(relation)==HOSTILE then
local sent,state=arenaSupport:engage(actor,player)
if sent then HoldSensedTarget(actor,player,'魂挑战') end
log('[HunBrain] 挑战目标=玩家 NPC迎敌='..tostring(sent)..' AI状态='..tostring(state))
end
end,
distance=function(actor,target)
local a,b=GetLocation(actor),GetLocation(target)
if a and b then return math.sqrt(DistSq(a,b)) end
end,
now=GameSeconds,loop=function(ms,fn)return LoopInGameThreadWithDelay(ms,fn)end,cancel=function(handle)return CancelDelayedAction(handle)end})
arenaSupport.hunStats=StatMatch.new({path=Config.RuntimePath,log=log,tag='[HunStats]',customOnly=true,
settings='hun-stats-settings.tsv',request='hun-stats-request.tsv'})
arenaSupport.hunStatFields={};for _,field in ipairs(require('character_stats').allFields)do arenaSupport.hunStatFields[field]=true end
arenaSupport.combatContinuity=require('combat_continuity').new({log=log,clock=LiveSeconds,world=GetCurrentWorld,
executionParticipant=function(actor)return arenaExecutions and arenaExecutions:participant(actor)end,
stageUntargetable=function(actor)return bossStages and bossStages:untargetable(actor)end,
context=function()return arena:intentContext()end,
deferTargetHold=true,
hp=GetHP,aiOf=GetAIComp,hatredOf=GetHatredComp,hates=HatredListContains,addHatred=AddHatred,
holdTarget=HoldSensedTarget,engage=function(actor,target)return arenaSupport:engage(actor,target)end,
phaseBusy=function(actor)return arenaSupport:combatPhaseBusy(actor)end,
ordinary=function(actor)
local cfg=UEObserve.field(actor,'Actor Config')
local value=UEObserve.struct(UEObserve.field(cfg,'Difficulty Tag'),'TagName')
if value==nil then return nil end
local ok,label=pcall(FNameToString,value)
if not ok or type(label)~='string'or not label:find('^CharacterType.Difficulty%.')then return nil end
return label:match('Boss$')==nil
end,
track=function(key,restore)battle:remember(key,restore);return true end})
function arenaSupport:restoreProtectedHatred(actor,target)
local world=GetCurrentWorld()
if not UEObserve.inWorld(actor,world) or not UEObserve.inWorld(target,world) then return false end
local hm=GetHatredComp(actor)
if not UEObserve.valid(hm) then return false end
local k=UEObserve.key
local ok,restored=pcall(function()
if k(hm:GetOwner())~=k(actor) or k(arena:aggroOpponent(actor))~=k(target) then return false end
for _,unit in ipairs({actor,target})do
local asc=UEObserve.field(unit,'AbilitySystemComponent')
if not UEObserve.valid(asc) or asc:GetGameplayTagCount({TagName=FName('CharacterState.Dead')})~=0 then return false end
end
if not self.combatContinuity:threatProtected(actor,true) and not self.combatContinuity:threatProtected(target,true) then return false end
local before=HatredListContains(hm,target)
if before~=false then return before==true end
self:rememberHatred(hm,target)
if not engineValid(hm) or not engineValid(target) or k(arena:aggroOpponent(actor))~=k(target) then return false end
local current=HatredListContains(hm,target)
if current~=false then return current==true end
local list=hm.HatredList
list[#list+1]=target
return HatredListContains(hm,target)==true
end)
return ok and restored==true
end
arenaSupport.aggroGuard=require('arena_aggro_guard').new({aiOf=GetAIComp,log=log,clock=LiveSeconds,
keepOpponent=function(actor,fresh)return arenaSupport.combatContinuity:keepOpponent(actor,fresh)end,
threatProtected=function(actor,fresh)return arenaSupport.combatContinuity:threatProtected(actor,fresh)end,
repairHatred=function(actor,target)return arenaSupport:restoreProtectedHatred(actor,target)end,
hates=function(actor,target)return HatredListContains(GetHatredComp(actor),target)end,
opponent=function(actor)return arena:aggroOpponent(actor)end,
protected=function(actor,fresh)return arenaSupport.combatContinuity:protected(actor,fresh)end,
ready=function()return runtimeSession:status().game_ready==true end})
function arenaSupport:finalDeath(actor,wholeGroup)
local hp=GetHP(actor)
if type(hp)~='number' or not (hp<=0 and hp> -math.huge) or not UEObserve.inWorld(actor,GetCurrentWorld()) then return false end
if self.hunBody:holdsDeath(actor) or (onGround:tagCount(actor,'CharacterState.Dead') or 0)<=0
or self.combatContinuity:inExecution(actor)~=false then return false end
if wholeGroup then
-- The formation's permanent forbid-vanish flag survives death. Resurrection abilities own Ability.Action.
return onGround:tagCount(actor,'Ability.Action')==0
end
return onGround:tagCount(actor,'CharacterState.Forbid.Vanish.CanRsurrect')==0
and onGround:tagCount(actor,'CharacterState.AbilityState.Troop.ReadyForResurrection')==0
end
combatLock=CombatLock.new({log=log,members=ArenaMembers,aiOf=GetAIComp,hatredOf=GetHatredComp,hp=GetHP,label=objectName,
finalDeath=function(actor,wholeGroup)return arenaSupport:finalDeath(actor,wholeGroup)end,
forgetTargets=function(actor,corpses,team)return arenaSupport.lockRelease:forgetDefeated(actor,corpses,team)end,
guard=arenaSupport.aggroGuard,inGameThread=IsInGameThread,
phaseBusy=function(actor)return arenaSupport:combatPhaseBusy(actor)end,
hates=HatredListContains,vehicles=function(members)return mounts and mounts:vehicles(members) or {} end,
-- Called inside the game's transition; the send-back runs on the next game-thread tick instead.
defer=ExecuteInGameThread,context=function()return arena:intentContext()end,
onDropped=function(key)if not (mounts and mounts:dropped(key)) then arena:reengage(key) end end,
onSensed=function(key)arena:holdSensed(key)end,
fighting=function()local s=ArenaStatus();return s.battle_active==true and s.blue_count>0 and s.red_count>0 end})
-- 招式锁玩家(二): while a fight runs, a skill of a blue or red unit that asks GameplayStatics for the player gets the
-- unit's opponent instead; executions keep the player (player_aim.lua).
fightWatch=require('fight_watch').new({log=log,members=ArenaMembers,location=GetLocation,hp=GetHP,
dropContext=function(actor,s)
local player,target=GetPlayerPawn(),arena:opponentOf(UEObserve.key(actor))
local body=safeValid(player) and GetLocation(player)
local other=safeValid(target) and GetLocation(target)
local ignored={actor};if safeValid(target) then ignored[2]=target end
local floor=GroundZ(GetCurrentWorld(),s.x,s.y,s.z,0,ignored)
return string.format(' 玩家Z=%s 对手Z=%s 下方地面Z=%s',tostring(body and body.Z),tostring(other and other.Z),tostring(floor))
end,
camera=function()return arenaSupport:cameraAt() end,
read=function(actor)
local ai=GetAIComp(actor)
local state
if ai then pcall(function()state=FNameToString(ai.CurrentStateTag.TagName)end) end
return {mode=(onGround:mode(actor)),hidden=UEObserve.field(actor,'bHidden')==true,state=state,blocked=onGround:blocked(actor)}
end,
scripts=function(actor)
local ai=GetAIComp(actor)
return ai and UEObserve.array(UEObserve.field(ai,'SpawnedAIScripts')) or nil
end})
local companionTargets=require('companion_target').new({log=log,world=GetCurrentWorld,player=GetPlayerPawn,hp=GetHP,
boardOf=function(actor)
local ai=GetAIComp(actor)
local pawn=UEObserve.field(ai,'Pawn')
if UEObserve.valid(pawn) and UEObserve.key(pawn)~=UEObserve.key(actor) then return end
return UEObserve.field(ai,'BlackboardComponent')
end,
boundHandler=function(actor,bb)return arenaSupport:targetHandler(actor,bb)end,
stillOwned=function(actor)return UEObserve.key(arena:actorOf(UEObserve.key(actor)))==UEObserve.key(actor)end})
arenaSupport.hunCompanionTarget=function(actor)return companionTargets:current(actor)end
arenaSupport.companionCombatTarget=function(actor)return companionTargets:inspect(actor)end
function arenaSupport:companionCanAct(actor)
local manager=self.companionManager
local row=manager and manager:lookup(actor)
return not row or not (row.p.behavior=='peace' or row.p.behavior=='assist' and not row.defending
or row.lease or row.pose or row.waiting or row.swapping or row.blocked)
end
function arenaSupport:skillOpponent(actor,team,castTarget,castName)
if team=='companion' then
if self:companionCanAct(actor) then return companionTargets:current(actor,castTarget,castName) end
elseif team=='blue' or team=='red' then
return arena:aggroOpponent(actor)
end
end
-- An owned follower or its own mount may acquire a verified target through native combat entry.
-- Unlike arena setup this adds no bilateral faction override and records no map actor in the arena ledger.
function arenaSupport:engageFieldNPC(actor,target)
if ReadRelation(actor,target)~=HOSTILE or self.combatContinuity:actionBusy(actor) then return false end
local ai,hatred=GetAIComp(actor),GetHatredComp(actor)
if not safeValid(ai) or not safeValid(hatred) then return false end
local ok=pcall(function()
if not HatredListContains(hatred,target) then hatred:AddActorToHatredList(target,false) end
if HatredListContains(hatred,target)==true then ai:ForceIntoCombat(target) end
end)
if not ok then return false end
local key=UEObserve.key(target)
if UEObserve.key(self.hunNativeTarget(actor,true))==key then return true end
if HatredListContains(hatred,target)~=true then return false end
local board=UEObserve.field(ai,'BlackboardComponent')
local targeting=UEObserve.field(actor,'Targeting Component')
if not safeValid(targeting) then return false end
local gotOwner,owner=pcall(function()return targeting:GetOwner()end)
if not gotOwner or UEObserve.key(owner)~=UEObserve.key(actor) then return false end
local handler=UEObserve.field(targeting,'DefaultTargetHandler')
local boardKey=UEObserve.key(board)
local slot=UEObserve.field(handler,'Target Key')
if not boardKey or UEObserve.key(UEObserve.field(handler,'Blackboard'))~=boardKey or not slot then return false end
local written,targetRead=pcall(function()
board:SetValueAsObject(slot,target)
return UEObserve.unwrap(board:GetValueAsObject(slot))
end)
return written and UEObserve.key(targetRead)==key
end
function arenaSupport:focusLionCubs(actor,cubs,boss)
if UEObserve.key(self:skillOpponent(actor,'companion'))~=UEObserve.key(boss) then return false end
local from=GetLocation(actor)
if not from then return false end
local closest,distance
for _,cub in ipairs(cubs)do
if ReadRelation(actor,cub)==HOSTILE then
local destination=GetLocation(cub)
local d=destination and DistSq(from,destination)
if d and (not distance or d<distance) then closest,distance=cub,d end
end
end
return closest~=nil and self:engageFieldNPC(actor,closest)
end
function arenaSupport:canMoveCompanionCenter(actor)
if not runtimeSession:status().game_ready or not arena:ownsDirectCompanion(actor)
or freeCamera:isFrozen() or self.teleport:relocating()
or self.lionNPC:engaged(actor) or self:combatPhaseBusy(actor) or self.combatContinuity:actionBusy(actor) then return false end
local tag=UEObserve.struct(UEObserve.field(GetAIComp(actor),'CurrentStateTag'),'TagName')
if not tag then return false end
local state=FNameToString(tag)
if state~='AI.State.Idle' and state:sub(1,#'AI.State.Idle.')~='AI.State.Idle.' then return false end
local enemy,known=companionTargets:inspect(actor)
return not enemy and known==true
end
function arenaSupport:syncCompanionMount(mount,rider,target)
local player=GetPlayerPawn()
local own=GetFactionComp(mount)
local side=GetFactionComp(rider)
if not own or not side or ReadRelation(rider,player)~=0 or freeCamera:isFrozen() then return false end
if ReadRelation(mount,player)~=0 or ReadRelation(mount,target)~=HOSTILE then
local copied=pcall(function()
local tag=side:GetCurrnetFaction()
if UEObserve.struct(tag,'TagName')~=nil then own:SetFaction(tag) end
end)
if not copied or ReadRelation(mount,player)~=0 or ReadRelation(mount,target)~=HOSTILE then return false end
end
if UEObserve.key(self.hunNativeTarget(mount,true))==UEObserve.key(target) then
local ai=GetAIComp(mount)
local item=UEObserve.struct(UEObserve.field(ai,'CurrentStateTag'),'TagName')
local tag=item and FNameToString(item)
if tag and (tag=='AI.State.Combat' or tag:sub(1,#'AI.State.Combat.')=='AI.State.Combat.') then return true end
end
return self:engageFieldNPC(mount,target)
end
arenaSupport.yubiArena=require('companion_yubi').new({log=log,world=GetCurrentWorld,player=GetPlayerPawn,
current=function(actor)return companionTargets:current(actor)end,location=GetLocation,ground=GroundZ,
arenaOpponent=function(actor)return arena:aggroOpponent(actor)end,
statics=GetGameplayStatics,clock=LiveSeconds,inGameThread=IsInGameThread})
arenaSupport.attackFlash=require('attack_flash').new({path=Config.RuntimePath,log=log})
playerAim=require('player_aim').new({log=log,members=ArenaMembers,statics=GetGameplayStatics,world=function()return GetCurrentWorld() end,
hp=GetHP,inGameThread=IsInGameThread,attackFlash=arenaSupport.attackFlash,readRelation=ReadRelation,
prepareMembers=function(members)
if not arenaSupport.frameContext or members~=arenaSupport.frameContext.targetRoster then companionTargets:sync(members) end
end,
companionTargetOf=function(actor,target,name)return companionTargets:current(actor,target,name)end,
companionLastEnemyOf=function(actor)return companionTargets:lastEnemy(actor)end,
boundaryCharacter=function(context,index)return arenaSupport.yubiArena:character(context,index)end,
formationPlayerLookup=function(ability)return arenaSupport.swordFormation:localPlayerLookup(ability)end,
formationCast=function(ability,name)arenaSupport.swordFormation:started(ability,name)end,
xukongCast=function(actor,name)arenaSupport.xukongPipa:started(actor,name)end,
boundaryPending=function()return arenaSupport.yubiArena:hasPending()end,
phaseBusyKey=function(key)return arenaSupport.menghuaPhase:busyKey(key) or arenaSupport.swordFormation:supporting(key)end,
abilityTargets=function()return StaticFindObject('/Script/PBZAbilityTargetRuntime.Default__PBZPlayerAbilityTargetLibrary')end,
player=GetPlayerPawn,
opponentOf=function(key)return arena:opponentOf(key)end,actorOf=function(key)return arena:actorOf(key)end,
phaseAimOpponent=function(key,target)return arena:phaseOpponent(key,target)end,
paused=function()return arenaExecutions and arenaExecutions:status().active==true or false end,
fighting=function()local s=ArenaStatus();return s.battle_active==true and s.blue_count>0 and s.red_count>0 end})
arenaSupport.effectAim=require('effect_instance_aim').new({log=log,clock=LiveSeconds,world=GetCurrentWorld,
ownerOf=function(object)return playerAim:ownerOf(object)end,targetOf=function(key)return playerAim:targetOf(key)end,
actorOf=function(key)return arena:actorOf(key)end,allowed=function(key)return playerAim:canRedirect(key)end,
active=function()return playerAim:hasSources()end,
paused=function()return arenaExecutions and arenaExecutions:status().active==true or false end,
inGameThread=IsInGameThread})
playerAim.effects=arenaSupport.effectAim
-- AI 行为参数: the panel's values for the AI's named parameters (ai_params.lua).
bossCombos=require('boss_combos').new({path=Config.RuntimePath,log=log,members=ArenaMembers,
companionTarget=function(actor)return companionTargets:current(actor)end,
fighting=function()local s=ArenaStatus();return s.battle_active==true and s.blue_count>0 and s.red_count>0 end})
aiParams=require('ai_params').new({path=Config.RuntimePath,log=log,members=ArenaMembers,aiComp=GetAIComp,
privateValues=function(actor)
local profile=arenaSupport.hunBody:profile(actor)
return profile and profile.ai_parameters
end,
tension=function()return StaticFindObject('/Script/TensionMeter.Default__TensionLibrary'),GetCurrentWorld() end})
-- 怪对怪处决(实验): a boss stuck on its health lock is executed by the nearest enemy with the game's own pair of
-- abilities; the enemy borrows the player's skeleton for its half (arena_executions.lua).
-- 处决镜头: the app switch; during an execution the view plays that execution's own camera (execution_camera.lua).
executionCamera=ExecutionCamera.new({log=log,path=Config.RuntimePath,getController=GetRealPlayerController,
getWorld=GetCurrentWorld,getPlayer=GetPlayerPawn,freeCamera=freeCamera})
arenaSupport.companionExecutions=require('companion_executions').new({log=log,path=Config.RuntimePath})
-- 玩家可以穿过随从 (companion_passage.lua): companions' capsules ignore the player's collision channel.
arenaSupport.companionPassage=require('companion_passage').new({log=log,path=Config.RuntimePath,members=ArenaMembers,player=GetPlayerPawn,
mount=function(actor)return UEObserve.field(UEObserve.field(actor,'BP_SGameDriverComponent'),'DrivingVehicle')end})
-- What a unit's card says (unit_rules.lua), and 琴女's 虚化, which nothing an NPC does can break (phantom_break.lua).
arenaSupport.swordFormation=require('huashan_formation').new({world=GetCurrentWorld,statics=GetGameplayStatics,
hp=GetHP,aiOf=GetAIComp,location=GetLocation,log=log,now=GameSeconds,retryClock=os.clock,
opponent=function(actor)return arena:aggroOpponent(actor)end,
companionOpponent=function(actor)return arenaSupport:skillOpponent(actor,'companion')end,
companionFighting=function(actor)
local item=UEObserve.field(GetAIComp(actor),'CurrentStateTag')
local value=UEObserve.struct(item,'TagName')
if value==nil then return nil end
local tag=FNameToString(value)
return tag=='AI.State.Combat' or tag:sub(1,#'AI.State.Combat.')=='AI.State.Combat.'
end,
busy=function(actor)return arenaSupport.combatContinuity:actionBusy(actor)end})
arenaSupport.entourage=require('boss_entourage').new({nativeAssignment=function(task,actor)arenaSupport.swordFormation:observe(task,actor)end,
adopt=function(child,parent,path)
local result=arena:adoptSummon(child,parent,path,'原生召唤完成回调')
if not result.ok then log('[Entourage] 队员接管未确认 '..tostring(result.message)) end
end,world=GetCurrentWorld,hp=GetHP,find=StaticFindObject,register=RegisterHook,unregister=UnregisterHook,log=log,now=os.clock})
arenaSupport.unitRules=require('unit_rules').new({log=log,path=Config.RuntimePath})
arenaSupport.xukongPipa=require('xukong_pipa').new({log=log,members=ArenaMembers,clock=LiveSeconds,
mapOpponent=function(actor)
local target=companionTargets:current(actor)
local key=UEObserve.key(target)
if key and not arena:actorOf(key) then return target end
end,
actionBusy=function(actor)return arenaSupport.combatContinuity:actionBusy(actor)end})
arenaSupport.xianzhePhantom=require('xianzhe_phantom').new({log=log,members=ArenaMembers,clock=LiveSeconds,
ready=function()return runtimeSession:status().game_ready==true end,
rule=function(id)return arenaSupport.unitRules:get(id,'phantom')end})
arenaSupport.offCombatRegen=require('offcombat_regen').new({log=log,path=Config.RuntimePath,clock=LiveSeconds,members=ArenaMembers,
actorOf=function(key)return arena:actorOf(key)end,
customActive=function()return arenaSupport.companionManager and arenaSupport.companionManager.customCount>0 end,
custom=function(actor)local p=arenaSupport.companionManager and arenaSupport.companionManager:forActor(actor);return p and p.regen=='custom' end,
ready=function()return runtimeSession:status().game_ready==true end})
-- Teleport (experimental, teleport.lua): the game's own PBZSaveLoadSubsystem:TeleportTo with the level name
-- GetCurrentLevelName gives, as the game's teleporter device does.
arenaSupport.teleport=require('teleport').new({log=log,player=GetPlayerPawn,
worldKey=function()return UEObserve.key(GetCurrentWorld())end,
loop=function(ms,fn)return LoopInGameThreadWithDelay(ms,fn)end,cancel=function(handle)return CancelDelayedAction(handle)end,
worldName=function()
local world=GetCurrentWorld()
if not safeValid(world) then return nil end
local lib=GetGameplayStatics()
if safeValid(lib) then
local ok,name=pcall(function()return lib:GetCurrentLevelName(world,true):ToString()end)
if ok and type(name)=='string' and name~='' then return name end
end
local ok,full=pcall(function()return world:GetFullName()end)
return ok and type(full)=='string' and full:match('%.([%w_]+)$') or nil
end,
blocked=function()
if freeCamera:isActive() then return '自由观战中不能传送,请先退出观战' end
end})
arenaSupport.weather=require('map_weather').new({world=GetCurrentWorld,findAll=FindAllOf,load=LoadAsset,log=log,
mapActor=function(world)
local cls=StaticFindObject('/Weather/UltraDynamicSky/Blueprints/Ultra_Dynamic_Weather.Ultra_Dynamic_Weather_C')
local lib=GetGameplayStatics()
if safeValid(lib) and safeValid(cls) then return UEObserve.unwrap(lib:GetActorOfClass(world,cls)) end
end})
arenaSupport.battleMusic=require('battle_music').new({log=log,
moYuanPhaseTwo=function(actor)
local asc=UEObserve.field(actor,'AbilitySystemComponent')
if not UEObserve.valid(asc)then return false end
local ok,n=pcall(function()return asc:GetGameplayTagCount({TagName=FName('CharacterState.AbilityState.MoYuan.P2')})end)
return ok and type(n)=='number' and n>0
end,
path=Config.RuntimePath,clock=os.clock,
session=function()return runtimeSession:status().game_session end,
members=ArenaMembers,status=ArenaStatus,hp=GetHP,world=GetCurrentWorld,
ready=function()return runtimeSession:status().game_ready==true end,
subsystem=function()return arenaSupport:worldSubsystem('MusicSubsystem')end,
inGameThread=IsInGameThread})
arenaSupport.remoteReflect=require('remote_reflect').new({log=log,members=ArenaMembers,
ready=function()return runtimeSession:status().game_ready==true end,
rule=function(id)return arenaSupport.unitRules:get(id,'remote_reflect')end})
arenaSupport.moYuanPillar=require('moyuan_pillar').new(log)
arenaSupport.phantom=require('phantom_break').new({log=log,members=ArenaMembers,rule=function(actor)return arenaSupport.unitRules:get(actor,'phantom') end})
-- Read only: what a monster's grab did to the unit it hit (grab_probe.lua).
arenaSupport.grabProbe=Config.EnableGrabProbe and require('grab_probe').new({log=log,members=ArenaMembers,location=GetLocation,
isPlayer=function(actor)
local player=GetPlayerPawn()
return safeValid(player) and safeValid(actor) and player:GetAddress()==actor:GetAddress()
end}) or nil
-- Sample native lock candidates only when detailed diagnostics are requested.
if Config.EnableSummonLockProbe==true then
arenaSupport.leiDangLockProbe=require('leidang_lock_probe').new({log=log,clock=os.clock,
world=GetCurrentWorld,player=GetPlayerPawn,relation=ReadRelation,inGameThread=IsInGameThread,
spectator=function()return spectator:status()end,freeCam=function()return freeCamera:isActive()end,
utils=function()return StaticFindObject('/Script/SGameCombatSystem.Default__TargetingUtils')end,
camera=function()
local pc=GetRealPlayerController()
return UEObserve.field(pc,'PlayerCameraManager')
end})
end
function arenaSupport.hunImmune(actor,kind)
local profile=arenaSupport.hunBody and arenaSupport.hunBody:profile(actor)
return profile and profile.survival and profile.survival[kind]=='immune' or false
end
arenaSupport.executionAppearance=Config.EnableArenaExecutions and require('execution_appearance').new({path=Config.RuntimePath}) or nil
arenaExecutions=Config.EnableArenaExecutions and ArenaExecutions.new({log=log,members=ArenaMembers,now=GameSeconds,
legacyBorrowedAppearance=function()return arenaSupport.executionAppearance.on end,
paused=function()return freeCamera:isFrozen()end,
immune=arenaSupport.hunImmune,
hunProfile=function(actor)return arenaSupport.hunBody:profile(actor)end,
hunWeapon=function(actor)return arenaSupport.hunBody:weaponConfig(actor)end,
hunPoleHead=function(actor)
local profile=arenaSupport.hunBody:profile(actor)
if not profile or not profile.variants then return nil end
return require('hun_weapon_rotation').allowsPoleHead(profile)
end,
executionPolicyConfigured=function()return arenaSupport.unitRules:hasExecutionOverrides()end,
executionPolicy=function(id)return arenaSupport.unitRules:get(id,'execution_minions')end,
phaseBusy=function(actor)return arenaSupport:combatPhaseBusy(actor)end,
companionCanAct=function(actor)return arenaSupport:companionCanAct(actor)end,
companions=function()return arenaSupport.companionExecutions.on end,companionMinions=function()return arenaSupport.companionExecutions.minions end,isStand=require('arena_stands').isStand,
nativeExecution=function(actor)return arenaSupport.combatContinuity:inExecution(actor)end,
killOnLock=function(actor)return arenaSupport.unitRules:get(actor,'lock')=='kill' end,
getPlayer=GetPlayerPawn,getWorld=GetCurrentWorld,getLocation=GetLocation,camera=executionCamera,
onPole=function(actor)return arenaSupport.lionNPC:holds(actor)end,
lionPickup=function(actor,victim)return arenaSupport.lionNPC:beginPickup(actor,victim,ArenaMembers(),ArenaStatus())end,
assignedOpponent=function(actor)return arena:aggroOpponent(actor)end,
lastLionOwner=function(actor)return arenaSupport.lionWave:lastOwner(actor)end,
fieldLastCubs=function()return arenaSupport.lionWave:fieldLastCubs()end,
fieldLionTarget=function(actor,victim)return arenaSupport.lionWave:canFieldTarget(actor,victim)end,
inGameThread=IsInGameThread,
lionHeadSeen=function(actor)return arenaSupport.lionNPC:observeHead(actor)end,
lionPickupReady=function(actor)return arenaSupport.lionNPC:pickupReady(actor)end,
lionPickupEnded=function(actor,completed)arenaSupport.lionNPC:pickupEnded(actor,completed)end,
fighting=function()local s=ArenaStatus();return s.battle_active==true and s.blue_count>0 and s.red_count>0 end,
storyAllows=function(ability)return arenaSupport.storyWrites:allows(ability)end,
isHun=function(actor)return arenaSupport.hunBody~=nil and arenaSupport.hunBody:owns(actor)end,
isImmortal=function(team)return immortalTeams.on[team]==true end}) or nil
arenaSupport.guillotine=Config.EnableNPCGrabs and require('arena_guillotine').new({log=log,live=summonActorLive,
paused=function()return freeCamera:isFrozen()end,
immune=arenaSupport.hunImmune,
opponentOf=function(key)return arena:opponentOf(key)end,
companionOpponent=function(actor,castTarget,castName)
if not freeCamera:isFrozen() then return arenaSupport:skillOpponent(actor,'companion',castTarget,castName) end
end,
mapVictim=function(actor)
local key=UEObserve.key(actor)
return key~=nil and summonActorLive(actor) and not UEObserve.valid(arena:actorOf(key))
and key~=UEObserve.key(GetPlayerPawn()) and UEObserve.inWorld(actor,GetCurrentWorld())
and arenaSupport.combatContinuity:inExecution(actor)==false and not arenaSupport:combatPhaseBusy(actor)
end,
session=function()return runtimeSession:status()end,now=GameSeconds,
playGrab=function(actor,stillValid)
if not arenaExecutions then return false,'借用骨架模块已关闭' end
return arenaExecutions:startGuillotineHold(actor,stillValid)
end,
grabHeld=function(actor)
if not arenaExecutions then return false end
return arenaExecutions:guillotineHeld(actor)
end,
finishGrab=function(actor)
if not arenaExecutions then return false end
return arenaExecutions:finishGuillotineHold(actor)
end,
stopGrab=function(why,actor)
if not arenaExecutions then return true end
return arenaExecutions:stopGrabPose(why,actor)
end,
isImmortal=function(team)return immortalTeams.on[team]==true end}) or nil
arenaSupport.standaloneStoryUnits=require('standalone_story_units').new({log=log,statics=GetGameplayStatics,
boardOf=function(actor)return UEObserve.field(GetAIComp(actor),'BlackboardComponent')end,
remember=function(key,restore)return battle:remember(key,restore)end,
companionOpponent=function(actor)return arenaSupport:skillOpponent(actor,'companion')end,
clock=LiveSeconds,live=summonActorLive,isDestroying=actorIsDestroying})
-- A support tick slower than this is logged with the time of each step, to find the source of stutter (60 a session);
-- every minute a summary of all ticks and their costliest steps (perf_meter.lua) keeps coming after that.
do -- Keep the support tick and its private state out of the remaining bootstrap scope.
local SLOW_TICK_MS,slowTicks=10,0
arenaSupport.muChildGroups=function(actors,world)
local owners,groups={},{}
local queen=require('companion_profile').second
for _,actor in ipairs(actors)do
local key=UEObserve.key(actor)
if not key or not UEObserve.inWorld(actor,world) or UEObserve.npcPath(actor)~=queen then return nil end
owners[#owners+1]={actor=actor,team='companion'};groups[key]={}
end
local found,scan=summonLinks:scan(owners)
if not scan or scan.errors~=0 or scan.conflicts~=0 then return nil end
for _,link in ipairs(found)do
local group=groups[link.parentKey]
if group and require('arena_stands').isStand(link.actor) then group[#group+1]=link.actor end
end
return groups
end
arenaSupport.muChildren=function(actor,world)
local path=UEObserve.npcPath(actor)
if not path then return nil end
if path~=require('companion_profile').second then return {} end
local groups=arenaSupport.muChildGroups({actor},world)
return groups and groups[UEObserve.key(actor)]
end
arenaSupport.companionNative=require('companion_native').new({path=Config.RuntimePath,log=log,world=GetCurrentWorld,player=GetPlayerPawn,
ai=GetAIComp,hp=GetHP,maxHP=GetMaxHP,location=GetLocation,tagName=FNameToString,destroying=actorIsDestroying,
session=function()local s=runtimeSession:status();return s.game_session,s.game_ready end,now=function()return GameSeconds() or 0 end,
blocked=function(actor)return freeCamera:isFrozen() or arenaSupport.teleport:relocating()
or arenaSupport.combatContinuity:inExecution(actor)~=false or arenaSupport.menghuaPhase:busy(actor)
or arenaSupport.lionNPC:engaged(actor) end,
actionBusy=function(actor)return arenaSupport.combatContinuity:actionBusy(actor)end,
owned=function(actor)return arena:ownsDirectCompanion(actor)end,
target=function(actor)return companionTargets:inspect(actor)end,
aimedAt=function(actor,target)return companionTargets:aimedAt(actor,target)end,
canHeal=function(actor)return arenaSupport.offCombatRegen:canCustomHeal(actor)end,
onDeath=function(actor)return arena:clearCompanionHelpers(actor)end,
keepFollowing=function(actor,player)companions:keepControlled(actor,player)end,
recovered=function(actor)return arena:companionRollbackReady(actor)end,
recall=function(actor)return companions:recall(actor)end,
spawn=function(path)return arena:spawn(path,'companion',1,true,true)end,
swap=function(...)return arena:replaceCompanion(...)end})
arenaSupport.companionManager=arenaSupport.companionNative.manager
arenaSupport.selfie=require('selfie').new({camera=freeCamera,world=GetCurrentWorld,player=GetPlayerPawn,getController=GetRealPlayerController,path=Config.RuntimePath,
members=ArenaMembers,hp=GetHP,location=GetLocation,live=summonActorLive,log=log,
blocked=function(actor)
if arenaSupport.teleport:relocating() or arenaSupport.combatContinuity:inExecution(actor)~=false
or arenaSupport.menghuaPhase:busy(actor) or arenaSupport.lionNPC:engaged(actor) then return true end
local asc=UEObserve.field(actor,'AbilitySystemComponent')
if not safeValid(asc) then return true end
for _,tag in ipairs({'Ability.Action','CharacterState.Unselectable.Force.Perform','CharacterState.Dead'})do
local ok,count=pcall(function()return asc:GetGameplayTagCount({TagName=FName(tag)})end)
if not ok or UEObserve.unwrap(count)~=0 then return true end
end
local tag=UEObserve.struct(UEObserve.field(GetAIComp(actor),'CurrentStateTag'),'TagName')
local tagName=tag and FNameToString(tag)
if tagName and (tagName=='AI.State.Combat' or tagName:sub(1,#'AI.State.Combat.')=='AI.State.Combat.') then return true end
local ok,velocity=pcall(function()return actor:GetVelocity()end)
local x,y,z=UEObserve.struct(velocity,'X'),UEObserve.struct(velocity,'Y'),UEObserve.struct(velocity,'Z')
return not ok or type(x)~='number' or type(y)~='number' or type(z)~='number' or x*x+y*y+z*z>900
end,
blockedView=function(world,from,to,player,other)
local lib=StaticFindObject('/Script/Engine.Default__KismetSystemLibrary')
if not safeValid(lib) or not safeValid(world) then return true end
local none={R=0,G=0,B=0,A=0}
local ignored={player}
if safeValid(other) then ignored[2]=other end
local ok,hit=pcall(function()return lib:LineTraceSingle(world,from,to,0,false,ignored,0,{},true,none,none,0)end)
return not ok or UEObserve.unwrap(hit)~=false
end,
focusFromCamera=function(from,view,camera)
local lib=StaticFindObject('/Script/Engine.Default__KismetSystemLibrary')
local world=GetCurrentWorld()
if not safeValid(lib) or not safeValid(world) or not safeValid(camera) then return end
local yaw,pitch=math.rad(view.Yaw),math.rad(view.Pitch)
local to={X=from.X+math.cos(yaw)*math.cos(pitch)*15000,Y=from.Y+math.sin(yaw)*math.cos(pitch)*15000,Z=from.Z+math.sin(pitch)*15000}
local out,none={},{R=0,G=0,B=0,A=0}
local ok,hit=pcall(function()return lib:LineTraceSingle(world,from,to,0,false,{camera},0,out,true,none,none,0)end)
if ok and UEObserve.unwrap(hit)==true then return UEObserve.struct(out,'Distance') end
end,
capture=function(world,settings)
local lib=StaticFindObject('/Script/Engine.Default__KismetSystemLibrary')
local pc=GetRealPlayerController()
if not safeValid(lib) or not safeValid(pc) or not safeValid(world) then return false end
local command='Shot'
if settings and settings.captureHDR then command='HighResShot 1 0 0 0 0 0 0 1 1'
elseif settings and (settings.border>1 or settings.mark>1) then command='Shot SHOWUI' end
return pcall(function()lib:ExecuteConsoleCommand(world,command,pc)end)
end})
local supportMeter=require('perf_meter').new({label='支持循环',log=log,slow=SLOW_TICK_MS,hitch=1000})
-- These modules observe or present the fight. Failure of one must not starve combat or cleanup.
-- Combat/control steps keep their original fail-fast order and frame-context restoration.
local observers={grabStudy=true,fieldProbe=true,companionHit=true,attackScan=true,codexArt=true,codexIcons=true,
battleMusic=true,grabProbe=true,leiDangLockProbe=true,fightWatch=true,bossHUD=true,clockHUD=true,companionBars=true,selfie=true,
summonTargetRegistration=true}
local observerFailures={}
local function supportSteps(self)
self.hudSamples={}
local started,parts,costs=os.clock(),{},{}
local function step(name,fn)
local t=os.clock()
if observers[name] then
local failure=observerFailures[name]
if failure and t<failure.nextTry then return end
local ok,why=pcall(fn)
if ok then
if failure then observerFailures[name]=nil;log('[Support] '..name..' 已恢复') end
else
local delay=failure and math.min(failure.delay*2,8) or .5
if not failure then log('[Support] '..name..' 暂停,稍后重试:'..tostring(why)) end
observerFailures[name]={delay=delay,nextTry=t+delay}
end
else fn() end
local spent=(os.clock()-t)*1000
parts[#parts+1]=name;costs[name]=spent
end
step('roster',function()tickMembers,tickStatus=arena:snapshot()end)
if self.selfie then step('selfie',function()self.selfie:tick()end) end
step('menghuaPhase',function()self.menghuaPhase:tick()end)
step('combatIntent',function()self.combatContinuity:beginTick(tickMembers,tickStatus.battle_active==true)end)
step('hunBody',function()self.hunBody:tick(tickMembers,tickStatus.battle_active==true)end)
step('prune',function()
local memberKeys={}
for _,entry in ipairs(tickMembers)do local key=UEObserve.key(entry.actor);if key then memberKeys[key]=true end end
if onGround then onGround:prune(memberKeys) end
spawnDifficulty:prune(memberKeys)
if self.matchReport then self.matchReport:forgetMissing(memberKeys) end
end)
step('aiDifficulty',function()aiDifficulty:tick()end)
step('companionManager',function()
arena:recoverCompanionCleanup()
companionTargets:sync(tickMembers);self.frameContext.targetRoster=tickMembers
self.companionManager:tick(tickMembers)
if self.companionManager.replaced==true then
self.companionManager.replaced=nil;tickMembers,tickStatus=arena:snapshot();companionTargets:sync(tickMembers);self.frameContext.targetRoster=tickMembers
end
end)
step('companions',function()companions:tick()end)
step('companionPassage',function()self.companionPassage:tick()end)
step('fun',function()funFeatures:tick()end)
step('freeCamera',function()freeCamera:recover()end)
if grabStudy then step('grabStudy',function()grabStudy:tick()end) end
if fieldProbe then step('fieldProbe',function()fieldProbe:tick()end) end
if companionHitProbe then step('companionHit',function()companionHitProbe:tick()end) end
if attackScan then step('attackScan',function()attackScan:tick()end) end
if codexArt then step('codexArt',function()codexArt:tick()end) end
if codexIcons then step('codexIcons',function()codexIcons:tick()end) end
step('summonKeep',function()self.summonKeep:tick()end)
step('phantom',function()self.phantom:tick()end)
step('moYuanPillar',function()self.moYuanPillar:tick(tickMembers)end)
step('remoteReflect',function()self.remoteReflect:tick()end)
step('xianzhePhantom',function()self.xianzhePhantom:tick()end)
step('storyCompanionAim',function()self.standaloneStoryUnits:tickCompanions()end)
step('xukongPipa',function()self.xukongPipa:tick()end)
step('offCombatRegen',function()self.offCombatRegen:tick()end)
if self.teleport and self.teleport:needsSupportTick() then step('teleport',function()self.teleport:tick()end) end
step('battleMusic',function()
local now=os.clock()
if not self.musicNext or now>=self.musicNext then self.musicNext=now+0.25;self.battleMusic:tick(tickMembers,tickStatus)end
end)
if self.grabProbe then step('grabProbe',function()self.grabProbe:tick()end) end
step('summonTargetRegistration',function()self.summonTargetRegistration:tick()end)
if self.leiDangLockProbe then step('leiDangLockProbe',function()self.leiDangLockProbe:sync(tickMembers)end) end
step('summonLinks',function()self:discover(not tickStatus.battle_active)end)
step('stands',function()self.stands:tick()end)
step('standKeep',function()self.standKeep:tick()end)
step('storyGuard',function()self.storyGuard:tick()end)
step('longzhu',function()self.longzhu:tick()end)
if mounts then step('mounts',function()mounts:tick(tickMembers)end) end
if bossStages then step('bossStages',function()bossStages:tick(tickMembers)end) end
-- Before reinforcements: a unit joining an immortal team is locked before it is sent at the enemy.
step('immortal',function()immortalTeams:tick()end)
step('activity',function()arenaActivity:sync(tickMembers)end)
step('grabs',function()arenaGrabs:sync(Config.EnableNPCGrabs and tickMembers or {},tickStatus.battle_active)end)
step('combatLock',function()combatLock:tick()end)
step('playerAim',function()playerAim:tick()end)
step('yubiArena',function()self.yubiArena:tick()end)
step('effectAim',function()self.effectAim:tick()end)
step('aiParams',function()aiParams:tick()end)
step('entourage',function()self.entourage:tick();self.swordFormation:tick()end)
step('bossCombos',function()bossCombos:tick()end)
step('fightWatch',function()fightWatch:tick()end)
step('lionWave',function()self.lionWave:sync(tickMembers,tickStatus.battle_active)end)
step('reinforce',function()arena:tickReinforcements()end)
if self.guillotine then step('guillotine',function()self.guillotine:tick(tickMembers,tickStatus)end) end
if arenaExecutions then step('executions',function()arenaExecutions:tick()end) end
step('lionNPC',function()self.lionNPC:tick(tickMembers,tickStatus)end)
if self.lionStage then step('lionStage',function()self.lionStage:tick()end) end
step('executionCamera',function()executionCamera:sweep()end)
step('bossHUD',function()
local state=tickStatus.state
if state=='cleanup_pending' or state=='restore_pending' or state=='spawn_uncertain' then bossHUD:clear()
else bossHUD:sync(tickMembers) end
end)
step('clockHUD',function()clockHUD:tick()end)
if companionBars then step('companionBars',function()companionBars:sync(tickMembers)end) end
step('formationCleanup',function()arena:tickDefeatedFormations()end)
local total=(os.clock()-started)*1000
if total>=SLOW_TICK_MS and slowTicks<60 then
slowTicks=slowTicks+1
for i,name in ipairs(parts)do parts[i]=string.format('%s=%.1f',name,costs[name])end
log(string.format('[Perf] 支持循环耗时 %.1fms:%s',total,table.concat(parts,' ')))
end
supportMeter:add(total,started,costs)
end
function arenaSupport:tick()
local previous=self.frameContext
local previousMembers,previousStatus=tickMembers,tickStatus
self.frameContext={}
local ok,err=pcall(supportSteps,self)
tickMembers,tickStatus=previousMembers,previousStatus
self.frameContext=previous
if not ok then error(err,0) end
end
end
function arenaSupport:cycleBattleHUD()
return bossHUD:cycleMode()
end
function arenaSupport:status()
local result=bossHUD:status();local activity=arenaActivity:status()
result.battle_hud_mode=bossHUD:mode()
result.full_update_count=activity.full_update_count;result.bone_refresh_count=activity.bone_refresh_count;result.free_camera=activity.free_camera
local grabs=arenaGrabs:status()
result.grab_events=grabs.events;result.grab_pairs=grabs.observed_pairs;result.grab_restore_pending=grabs.restore_pending
local observer=observerGuard:status()
result.observer_health_verified=observer.health_verified;result.observer_message=observer.message
if mounts then for key,value in pairs(mounts:status())do result[key]=value end end
if bossStages then for key,value in pairs(bossStages:status())do result[key]=value end end
return result
end
-- Every hotkey of this mod is read once a frame in the game thread (key_poll.lua); none is a UE4SS key bind, whose
-- callback would run this mod's Lua on UE4SS's own thread.
local keyPoll=KeyPoll.new({log=log,controller=GetRealPlayerController,
isCurrentController=function(pc)return arenaSupport:controllerCurrent(pc,arenaSupport:viewportWorld())end,
meter=require('perf_meter').new({label='按键读取',log=log,slow=2,hitch=1000})})
local keyRouter=KeyRouter.new({log=log,register=keyPoll.register,occupied=keyPoll.occupied,registerXbox=keyPoll.registerXbox})
local unitKeys=UnitKeys.new({path=Config.RuntimePath,log=log,router=keyRouter,
queue=function(callback,path,team,count)
if panelRuntime then panelRuntime:queueSummon(callback,path,team,count) end
end,
reserved=function(vk,mask)return panelRuntime and panelRuntime:unitKeyReserved(vk,mask) end,
shared=function(vk)return panelRuntime and panelRuntime:unitKeyShared(vk) end,
ready=function()local status=runtimeSession:status();return status.game_ready,status.game_ready_reason end,
-- A unit key carries its own team and count; a key saved before that follows the panel selection.
spawn=function(path,team,count)
return panelRuntime:summon(path,team,count)
end})
-- Developer probes are opt-in, never hidden default key reservations.
if Config.EnableDeveloperKeybinds then
keyPoll.register(Key.F1,{ModifierKey.SHIFT},DumpBrain)
keyPoll.register(Key.F2,{ModifierKey.SHIFT},TargetDiag)
keyPoll.register(Key.F3,{ModifierKey.SHIFT},DumpCollisionMatrix)
keyPoll.register(Key.F9,{ModifierKey.SHIFT},function()
ExecuteInGameThread(function()
for _,path in ipairs(SpawnPolicy.knownPaths()) do
local result=arena:select(path,"blue",1)
log("验证目录切换="..tostring(result.ok)..";"..tostring(result.message))
break
end
end)
end)
end
panelRuntime=PanelRuntime.new({arena=arena,exporter=exporter,path=Config.RuntimePath,hunLoadout=arenaSupport.hunLoadout,
build=BUILD,log=log,unitRules=arenaSupport.unitRules,track=arenaSupport.track,autoScan=true,fullInventory=true,spectator=spectator,statMatch=statMatch,companionStats=arenaSupport.companionStats,aiParams=aiParams,bossCombos=bossCombos,spawnDifficulty=spawnDifficulty,aiDifficulty=aiDifficulty,companions=companions,funFeatures=funFeatures,immortal=immortalTeams,clockHUD=clockHUD,executionCamera=executionCamera,companionExecutions=arenaSupport.companionExecutions,session=runtimeSession,codex=codexExporter,spawnPolicy=SpawnPolicy,support=arenaSupport,unitKeys=unitKeys,
router=keyRouter,camera={status=function()return {active=freeCamera:isActive(),pending=freeCamera:hasPending(),
frozen=freeCamera:isFrozen(),settings=freeCamera:settings()}end,
toggle=ToggleFreeCam,exit=ForceExitFreeCam,
-- 时停 (the app's switch and its function key) and the app's speed, turn and smoothing (free_camera.lua).
freeze=function(_,on)return freeCamera:freeze(on)end,
configure=function(_,speed,turn,smooth)return freeCamera:configure(speed,turn,smooth)end},
spawnCatalog=SpawnCatalog.new({log=log,path=Config.RuntimePath,getWorld=GetCurrentWorld}),
tableCatalog=TableCatalog.new({log=log,path=Config.RuntimePath,maps=worldMaps}),
areaLevels=AreaLevels.new({log=log,path=Config.RuntimePath}),
spawnLevel=spawnLevel,
homeLevels=homeLevels,
references=ReferenceAudit.new({log=log,path=Config.RuntimePath})})
panelRuntime:start()
keyPoll:start()
if ModRef then
ModRef.OnUnload=function()
local function stop(name,module,...)
if module then
local ok,why=pcall(module.silence,module,...)
if not ok then log('[Unload] '..name..':'..tostring(why)) end
end
end
local checkedThread,onGameThread=pcall(IsInGameThread)
local restoreNative=checkedThread and onGameThread==true
stop('selfie',arenaSupport.selfie,restoreNative)
stop('freeCamera',freeCamera)
stop('lionNPC',arenaSupport.lionNPC)
stop('keyPoll',keyPoll)
stop('panelRuntime',panelRuntime)
probeSampleGen=probeSampleGen+1
stop('probe',probe,"Mod卸载")
stop('aiDifficulty',aiDifficulty,"Mod卸载")
stop('companions',companions)
stop('funFeatures',funFeatures)
stop('immortalTeams',immortalTeams)
stop('clockHUD',clockHUD)
stop('combatLock',combatLock,'Mod卸载')
stop('stands',arenaSupport.stands)
stop('summonKeep',arenaSupport.summonKeep)
stop('remoteReflect',arenaSupport.remoteReflect)
stop('xianzhePhantom',arenaSupport.xianzhePhantom)
stop('xukongPipa',arenaSupport.xukongPipa)
stop('menghuaPhase',arenaSupport.menghuaPhase)
stop('offCombatRegen',arenaSupport.offCombatRegen)
stop('teleport',arenaSupport.teleport)
stop('battleMusic',arenaSupport.battleMusic)
stop('grabProbe',arenaSupport.grabProbe)
stop('weather',arenaSupport.weather,restoreNative)
stop('companionManager',arenaSupport.companionManager,restoreNative)
stop('companionPassage',arenaSupport.companionPassage,restoreNative)
stop('entourage',arenaSupport.entourage,restoreNative)
stop('swordFormation',arenaSupport.swordFormation,restoreNative)
stop('aggroGuard',arenaSupport.aggroGuard,restoreNative)
stop('yubiArena',arenaSupport.yubiArena,restoreNative)
stop('playerAim',playerAim,'Mod卸载',restoreNative)
stop('combatContinuity',arenaSupport.combatContinuity)
stop('hunBody',arenaSupport.hunBody,restoreNative)
stop('effectAim',arenaSupport.effectAim)
stop('aiParams',aiParams,restoreNative)
stop('bossCombos',bossCombos,restoreNative)
stop('arenaGrabs',arenaGrabs)
stop('guillotine',arenaSupport.guillotine)
stop('standaloneStoryUnits',arenaSupport.standaloneStoryUnits,restoreNative)
stop('arenaExecutions',arenaExecutions)
local cancelled,why=pcall(battle.cancel,battle,"Mod卸载")
if not cancelled then log('[Unload] battle: '..tostring(why)) end
if battle:pendingCount()>0 or #arenaActors>0 then
log("卸载时仍有参赛者或恢复记录;重载不会替代停止清理")
end
if mounts and mounts:count()>0 then
log('[Mount] 卸载时仍有 '..mounts:count()..' 个骑兵的坐骑记录;重载后它们的坐骑和刷怪点不会随清理移除')
end
if arenaSupport.lionStage and arenaSupport.lionStage:count()>0 then
log('[LionStage] 卸载前还有召唤舞狮场地,请先停止并清理')
end
if arenaSupport.lionNPC:count()>0 then log('[LionNPC] 卸载前还有NPC独立桩,请先停止并清理') end
if bossStages and bossStages:count()>0 then
log('[BossStage] 卸载时仍有 '..bossStages:count()..' 个 BOSS 的场地物件记录;重载后这些物件不会随清理移除')
end
local spectatorState=spectator:status()
if spectatorState.pending_relations>0 or spectatorState.pending_flags>0 then
log("无仇恨快照尚未恢复;热重载前必须先关闭无仇恨并等待恢复读回")
end
end
end
log("loaded ✓ "..BUILD..";全部功能键默认未绑定,可在面板自定义;自由观战包含无仇恨、隐身、无敌锁血及镜头收音。")