-- Native group abilities read placed spawners before the behavior tree dispatches its members. local U=require('ue_observe') local Entourage=require('boss_entourage') local Party={} local ROOT='/PBZCombatAsset/ActorData/Mobs/035_HuaShan/' local BLUE='BP_Monster_HuaShan_Blue' local RED='BP_Monster_HuaShan_RedTroop_BigBro' local DOMAIN='/SGameAI/Tools/MobDomain/BP_MobDomain.BP_MobDomain_C' local SPAWNER='/SGameAI/Tools/Spawner/BP_AISpawner.BP_AISpawner_C' local GROUP='/Script/SGameAI.MobGroup' local SYSTEM='/Script/Engine.Default__KismetSystemLibrary' local AI='/Script/SGameAI.Default__SGameAIFunctionLibrary' local GAS='/Script/GameplayAbilities.Default__AbilitySystemBlueprintLibrary' local UTILS='/Script/SGameUtils.Default__AbilityUtils' local INIT=ROOT..'BehaviorTree/Troop/Init/BT_HuaShan_Troop_Init_07.BT_HuaShan_Troop_Init_07' local INTRO=ROOT..'Abilities/GA_HuaShan_Story_Intro.GA_HuaShan_Story_Intro_C' local TROOP='CharacterState.AbilityState.Troop.TroopMob' local CENTER='AI.BlackboardKey.Vector.DomainCenter' local PREFIX='PhantomGladiator_HuaShan_' local DEATH_SCRIPT='AIScript_HuaShan_Troop_Blue_Dead_C' Party.supportsCompanion=Entourage.retireFormation local function call(o,method,...) if not U.valid(o) then return false end local args=table.pack(...) local ok,value=pcall(function()return o[method](o,table.unpack(args,1,args.n))end) if ok then return true,U.unwrap(value) end return false end local function get(o,method,...) local ok,value=call(o,method,...) if ok then return value end end local function text(value) if type(value)=='string' then return value end local ok,s=pcall(function()return value:ToString()end) return ok and type(s)=='string' and s or nil end local function pathOf(o) local s=get(o,'GetFullName') return type(s)=='string' and s:match('^%S+ (/.+)$') or nil end local function same(a,b) local k=U.key(a);return k~=nil and k==U.key(b) end local function empty(o,k) local list=U.array(U.field(o,k)) return list and #list==0 end local function set(o,k,v) if not U.valid(o) then return false end local ok=pcall(function()o[k]=v end) return ok and U.field(o,k)==v end local function setObject(o,k,v) if not U.valid(o) or (v~=nil and not U.valid(v)) then return false end local ok=pcall(function()o[k]=v end) local back,read=U.field(o,k) return ok and read and (v==nil and not U.valid(back) or same(back,v)) end local function sameList(list,expected) if not list or #list~=#expected then return false end local keys={} for _,v in ipairs(list)do local k=U.key(v);if not k or keys[k] then return false end;keys[k]=true end for _,v in ipairs(expected)do if not keys[U.key(v)]then return false end end return true end local function nativeGroup(domain,slot) local map=U.struct(U.field(domain,'MobDomainConfig'),'MobGroups') if U.kind(map)=='table' then return map[slot] end local found pcall(function()map:ForEach(function(k,v) if text(U.unwrap(k))==slot then found=U.unwrap(v);return true end end)end) return found end -- Let the reflected property parse its own reference type. Never put an Actor userdata in a soft-pointer slot. local function propertyIs(p,kind) if PropertyTypes and PropertyTypes[kind] and p:IsA(PropertyTypes[kind]) then return true end -- Older UE4SS builds expose these FFields but omit soft reference kinds from the PropertyTypes table. local full=p:GetFullName() return type(full)=='string' and full:match('^(%S+) ')==kind end local function import(o,field,kind,value) local cls=get(o,'GetClass') for _=1,16 do if not U.valid(cls) or not U.valid(o) then return false end local found,wrote=false,false local ok=pcall(function()cls:ForEachProperty(function(p) if text(p:GetFName())~=field then return end found=true if not propertyIs(p,kind) then return true end if kind=='ArrayProperty' and not propertyIs(p:GetInner(),'SoftObjectProperty')then return true end local data=p:ContainerPtrToValuePtr(o,0) if data~=nil then p:ImportText(value,data,0,o);wrote=true end return true end)end) if not ok or found then return ok and wrote end cls=get(cls,'GetSuperStruct') end return false end local function point(v) if not v then return nil end local ok,x,y,z=pcall(function()return v.X,v.Y,v.Z end) local function finite(n)return type(n)=='number' and n==n and math.abs(n)=stamp and now-stamp0 then call(asset(UTILS),'RemoveLooseGameplayTag',a,tag(TROOP),false) if get(asc,'GetGameplayTagCount',tag(TROOP))~=n-1 then return false end end row.marked=nil end row.unbound=true return true end local function remove(row,r) local a=row.helper if a==nil then return true end if not U.valid(a) then return confirmedGone(a) end if not U.inWorld(a,r.world) then return false end if row.helperName then local name=pathOf(a) if not name then return false end if name~=row.helperName then return true end else local name=text(get(a,'GetFName')) local key=U.key(a) if not name or not key or not row.helperShort or not row.helperKey then return false end if name~=row.helperShort or key~=row.helperKey then return true end end if not row.classVerified then local cls=get(a,'GetClass') if not U.valid(cls) then return false end if not same(cls,row.helperClass) then return true end end if get(a,'IsActorBeingDestroyed')==true then return true end if row.binding and not detach(a,'SpawnedAI',row.actor) then return false end call(a,'K2_DestroyActor') if U.valid(a) then return get(a,'IsActorBeingDestroyed')==true end return confirmedGone(a) end local function release(r,current,force) r.retiring=true current=current or U.key(o.world()) if not current then return false end local done=true if current==r.worldKey then if not force and cooling(r.cleanupAt,1) then return false end r.cleanupAt=retryClock() or os.clock() for _,row in ipairs(r.rows)do if not unbind(row,r) then done=false end end if not done then return false end for _,row in ipairs(r.rows)do if row.helper then if remove(row,r) then row.helper=nil;row.binding=nil else done=false end end end if not done or not remove(r.site,r) then return false end end for _,row in ipairs(r.rows)do if owners[row.key]==r then owners[row.key]=nil end if casts[row.key] and casts[row.key].group==r then casts[row.key]=nil end end groups[r.token]=nil return true end function self:roster(rows) revision=revision+1;latestRows=rows if not next(groups) then return end local present,currentOwners={},{} for _,row in ipairs(rows)do if row.formationGroup then present[row.formationGroup]=true local r=groups[row.formationGroup];local k=r and U.key(row.actor) if k and owners[k]==r then currentOwners[k]=r end end end owners=currentOwners for token,r in pairs(groups)do if not present[token] and not r.building then release(r) end end end function self:abort(token) local r=groups[token] if not r then return true end -- Arena rollback can still reclaim its staged fighters if the first immediate cleanup was refused. local first=not r.abortRequested r.abortRequested=true return release(r,nil,first) end local function troopTag(row) local asc=U.field(row.actor,'AbilitySystemComponent') local before=get(asc,'GetGameplayTagCount',tag(TROOP)) if type(before)~='number' then return false end if before>0 then return true end if not call(asset(UTILS),'AddLooseGameplayTag',row.actor,tag(TROOP),false) then return false end local after=get(asc,'GetGameplayTagCount',tag(TROOP)) if after==1 then row.marked=true;return true end return false end local function nativeRoster(r) local list=U.array(get(r.group,'GetMemberInterfaces')) if not list or #list~=#r.rows then return false end local allowed,expected={},{} for _,row in ipairs(r.rows)do local key=U.key(row.helper) if not key then return false end allowed[key],allowed[row.key]=row,row end for _,member in ipairs(list)do local row=allowed[U.key(member)] if not row or expected[row] or (not same(member,row.actor) and not same(get(member,'GetPawn'),row.actor)) then return false end expected[row]=true end return true end local function populate(r) if not helper(r,r.site,DOMAIN,r.rows[1].transform) or not privateGroup(r) then return false,'专属战斗区域或原生分组未读回' end local refs={} for i,row in ipairs(r.rows)do if not helper(r,row,SPAWNER,row.transform) then return false,'第 '..i..' 个出生器未就绪' end local sp=row.helper;local cls=get(row.actor,'GetClass') local ref=reference(cls) if not ref or not import(sp,'Class','SoftClassProperty',ref) or not same(resolveSoft(sp,'Class','Conv_SoftClassReferenceToClass'),cls) then return false,'出生器角色类型未读回' end refs[i]=reference(sp) if not refs[i] then return false,'出生器路径未读回' end end for _,row in ipairs(r.rows)do row.binding=true if not owned(row.actor,row.name,r) or not owned(row.helper,row.helperName,r) or not setObject(row.helper,'MobGroup',r.group) or not setObject(row.helper,'SpawnedAI',row.actor) or not same(get(row.helper,'GetPawn'),row.actor) then return false,'出生器没有读回本组队员' end end if not import(r.group,'Members','ArrayProperty','('..table.concat(refs,',')..')') or not nativeRoster(r) then return false,'原生成员未全部读回' end for _,row in ipairs(r.rows)do if not setObject(row.actor,'Spawner',row.helper) or not setObject(row.actor,'MobGroup',r.group) or not same(get(row.actor,'GetAISpawner'),row.helper) or not same(get(row.actor,'GetMobGroup'),r.group) then return false,'角色与原生出生器未双向绑定' end if r.blue then troopTag(row) end end return true end function self:prepare(token,batch,world,team) local first=batch[1] local config=first and Entourage.nativeGroup(first.path) if not alive or not token or groups[token] or not config or #batch~=#config.members or (team~='blue' and team~='red' and team~='companion') or not same(world,o.world()) then return false,'原生编队、世界或人数未确认' end local id=Entourage.id(first.path) local r={world=world,worldKey=U.key(world),token=token,team=team,blue=id==BLUE,red=id==RED, tree=config.tree,site={},rows={},building=true} refreshRoster() local seen={} for i,item in ipairs(batch)do local expected=config.members[i] local a=item.actor;local k=U.key(a);local name=pathOf(a) local sp,spRead=U.field(a,'Spawner');local gr,groupRead=U.field(a,'MobGroup') if not k or not name or seen[k] or owners[k] or not U.inWorld(a,world) or sides[k]~=team or item.path~=expected or pathOf(get(a,'GetClass'))~=item.path or (i>1 and not same(item.parent,first.actor)) or not spRead or not groupRead or U.valid(sp) or U.valid(gr) then return false,'原生编队队员归属未确认' end seen[k]=true r.rows[i]={actor=a,key=k,name=name,transform=item.transform} end groups[token]=r for _,row in ipairs(r.rows)do owners[row.key]=r end local called,ok,why=pcall(populate,r) r.building=false if not called or not ok then local err=tostring(why or ok);local clean=release(r) say('建组未完成 '..err..';自有物件清理读回='..tostring(clean));return false,err end say('原生小队在登场前就绪 '..r.rows[1].name..' 阵营='..team..' 出生器及双向队员读回='..#r.rows..'/'..#r.rows) return true end local function center(r,verify) if not r.blue then return true end local a=r.rows[1].actor;local bb=U.field(o.aiOf(a),'BlackboardComponent') local v=r.origin local key=U.key(bb) if not key or not v then return false end if not verify and r.center==key then return true end local lib=asset(AI) local function matches() local back=point(get(lib,'GetValueAsVectorByTag',bb,tag(CENTER))) return back and math.abs(back.X-v.X)<1 and math.abs(back.Y-v.Y)<1 and math.abs(back.Z-v.Z)<1 end if matches() or (call(lib,'SetValueAsVectorByTag',bb,tag(CENTER),v) and matches()) then r.center=key;return true end r.center=nil;return false end function self:ready(token) local r=groups[token] if not r or r.retiring or not here(r) then return false,'原生编队已离场' end if not nativeRoster(r) then return false,'登场后原生成员未全部读回' end for _,row in ipairs(r.rows)do if not owned(row.actor,row.name,r) or not same(get(row.actor,'GetMobGroup'),r.group) or not same(get(row.helper,'GetPawn'),row.actor) then return false,'登场后队伍归属变化' end if r.blue and not troopTag(row) then return false,'原版白衣阵标签未读回' end end r.origin=point(o.location(r.rows[1].actor)) or point(r.rows[1].transform.Translation) center(r);r.ready=true return true end local function livingRoster(r) local expected={} for _,row in ipairs(r.rows)do if owned(row.actor,row.name,r) and (o.hp(row.actor) or 0)>0 then expected[#expected+1]=row.actor end end local members=U.array(get(r.group,'GetAliveMemberPawns')) return sameList(members,expected),members and #members,#expected end function self:activated(token) local r=groups[token] if not r or not r.ready or r.retiring or not here(r) then return false,'分组已离场' end center(r,true) local verified,n,wanted=livingRoster(r) local count=#r.rows if not verified or wanted~=count then r.livingChecks=0 say('登场时原生存活名单='..tostring(n)..'/'..count..';出生器已登记,等待游戏更新') return true,'编队队员已登记,原生存活名单正在更新' end say('原生存活名单读回='..count..'/'..count..' 主将='..r.rows[1].name) return true end local function opposes(r,foe) local id=U.key(foe) if not id then return false end if r.team=='companion' then return id==r.enemyKey and owned(foe,r.enemyName,r) end return sides[id]==(r.team=='blue' and 'red' or 'blue') end function self:beforeAttack(actor,foe) if not next(groups) then return true end local r=groupOf(actor) if not r then return true end if not r.ready or r.retiring or not here(r) or not domainMembers(r) then return false end center(r) if same(actor,r.rows[1].actor) and opposes(r,foe) then r.entering=true end return true end local opening function self:assigned(actor,foe) if not next(groups) then return end local r=groupOf(actor) if r and r.ready and same(r.rows[1].actor,actor) and opposes(r,foe) and not r.encounter then if r.team=='companion' then r.origin=point(o.location(actor)) or r.origin r.center=nil if not center(r,true) then return end end r.encounter=clock() local peers=U.array(get(r.rows[1].helper,'GetOtherAliveMembersInGroup')) say('首次交战 '..r.rows[1].name..' 原生可用队友='..tostring(peers and #peers) ..(r.team=='companion' and ' 地图敌人='..tostring(r.enemyName) or '')) if r.red and r.encounter then opening(r,r.encounter,foe) end end end local emptyActor function self:localPlayerLookup(ability) if not next(groups) then return end local actor=get(ability,'GetAvatarActorFromActorInfo');local r=groupOf(actor) if not r or not r.ready or not (r.blue or r.red) or not U.inWorld(ability,r.world) then return end if emptyActor==nil then local ok,v=pcall(o.invalid or CreateInvalidObject) if ok and v~=nil and not U.valid(v) then emptyActor=v end end return emptyActor end local function running(a) local controller=get(a,'GetController') return U.valid(controller) and get(asset(AI),'GetRunningBehaviorTree',controller) or nil end function self:started(ability,name) if not next(groups) then return end local actor=get(ability,'GetAvatarActorFromActorInfo');local r=groupOf(actor) local key=U.key(actor) if not r or not r.ready or not (r.blue or r.red) or not key then return end if name=='GA_HuaShan_Story_Intro_C' then if not r.red or not same(r.rows[1].actor,actor) then return end r.opened=true;r.introSeen=true elseif name~='GA_HuaShan_Troop_Healing_C' and name~='GA_HuaShan_Troop_Resurrection_C' then return end casts[key]={group=r,ability=ability} if (r.castLogs or 0)<8 then r.castLogs=(r.castLogs or 0)+1 say('原版技能起手 '..name..' 施术者='..tostring(pathOf(actor))..' 本组主将='..r.rows[1].name) end end function self:supporting(key) local cast=casts[key] if not cast then return false end local r,ability=cast.group,cast.ability if owners[key]==r and not r.retiring and here(r) and U.field(ability,'bIsActive')==true and U.key(get(ability,'GetAvatarActorFromActorInfo'))==key then return true end casts[key]=nil;return false end function self:supportingActor(actor) return next(casts)~=nil and self:supporting(U.key(actor)) end function self:observe(task,actor) local r=groupOf(actor) if not r or not same(r.rows[1].actor,actor) then return end local tree=pathOf(U.field(task,'TreeAsset')) if not tree or not tree:find(r.tree,1,true) then return end local peers=U.array(U.field(task,'ActorsToAssign'));local own=0 for _,a in ipairs(peers or {}) do if owners[U.key(a)]==r then own=own+1 end end local companionCombat=r.team=='companion' and o.companionFighting and o.companionFighting(actor)==true if r.blue and tree==INIT and (r.entering or r.encounter or companionCombat) and own>0 and own==#peers then r.opened=true end if not r.seen then r.seen={} end if r.seen[tree]==own or (r.reports or 0)>=24 then return end r.seen[tree]=own;r.reports=(r.reports or 0)+1 say('原生派阵 '..r.rows[1].name..' 树='..tree:match('[^%.]+$')..' 本组候选读回='..own..'/'..tostring(peers and #peers)) if peers and own>0 and #peers==own then local wanted,branches={},{} local map=U.field(task,'AssignToTransformAndBehaviorTree') local function branch(value) local path=pathOf(U.unwrap(value)) if path then branches[path]=true end end if U.kind(map)=='TMap' then pcall(function()map:ForEach(function(_,v)branch(v)end)end) elseif type(map)=='table' then for _,value in pairs(map)do branch(value)end end for _,a in ipairs(peers)do wanted[#wanted+1]={actor=a,hp=o.hp(a)} end r.receipt={tree=tree,branches=branches,peers=wanted,leaderHP=o.hp(actor),at=clock()} end end local function receipts(r,now) local trace=r.receipt if not trace or not trace.at or now-trace.at<0.5 then return end local count,changes=0,{} for _,row in ipairs(trace.peers)do local a=row.actor if owners[U.key(a)]==r then local tree=pathOf(running(a)) if tree and trace.branches[tree] then count=count+1 end local hp=o.hp(a) if type(hp)=='number' and hp~=row.hp then changes[#changes+1]=tostring(U.key(a))..' '..tostring(row.hp)..'→'..hp end end end say('派阵后采样 '..trace.tree:match('[^%.]+$')..' 当次指定子树读回='..tostring(next(trace.branches) and count or '未知')..'/'..#trace.peers ..' 主将HP='..tostring(trace.leaderHP)..'→'..tostring(o.hp(r.rows[1].actor))..' 队员HP变化='..table.concat(changes,',')) r.receipt=nil end function self:lifeChanged(token,actor,living) local r=groups[token] if not r or not r.blue or not r.ready or r.retiring or not here(r) then return end local key=U.key(actor) for i=2,#r.rows do local row=r.rows[i] if row.key==key and owned(actor,row.name,r) then if living then row.deathSent,row.deathAttempts=nil,nil end if not r.deaths then r.deaths={} end r.deaths[key]=not living and not row.deathSent and (row.deathAttempts or 0)<2 and row or nil break end end end local function memberDeaths(r,now) if not r.deaths or not next(r.deaths) or (r.nextDeathCheck and now0 then row.deathSent,row.deathAttempts=nil,nil;r.deaths[key]=nil elseif type(hp)=='number' and hp<=0 and not row.deathSent and (get(U.field(a,'AbilitySystemComponent'),'GetGameplayTagCount',tag('CharacterState.Dead')) or 0)>0 then -- Placed spawners normally broadcast from their save/respawn listener. The private one is quiet. if U.valid(U.field(sp,'WaitSpawnedAIDeadAsyncAction')) then row.deathSent=true else local ai=o.aiOf(leader) for _,script in ipairs(U.array(U.field(ai,'SpawnedAIScripts')) or {})do if U.className(script)==DEATH_SCRIPT and same(U.field(script,'Pawn'),leader) and same(U.field(leader,'MobGroup'),r.group) then row.deathAttempts=(row.deathAttempts or 0)+1 local called=call(script,'OnGroupMemberDead',sp) row.deathSent=called or nil say('白衣队员阵亡通知 '..row.name..' 原版处理调用='..tostring(called)..' 尝试='..row.deathAttempts) break end end end end if row.deathSent or (row.deathAttempts or 0)>=2 then r.deaths[key]=nil end end end end opening=function(r,now,assignedFoe) if not (r.blue or r.red) or r.opened or not r.encounter then return end if now12 then r.opened=true;say('开场窗口结束 '..r.rows[1].name..' 未读到可用开场');return end if now<(r.nextOpen or 0) then return end r.nextOpen=now+0.5 local a=r.rows[1].actor if not owned(a,r.rows[1].name,r) or (o.hp(a) or 0)<=0 then return end local foe=assignedFoe if not foe then if r.team=='companion' then foe=r.enemy else foe=o.opponent(a) end end if not opposes(r,foe) or (o.hp(foe) or 0)<=0 then return end if r.blue and pathOf(running(a))==INIT then r.opened=true;return end if r.blue and now-r.encounter<0.5 then return end if r.blue then for i=2,#r.rows do local tree=pathOf(running(r.rows[i].actor)) if tree and tree:find(ROOT..'BehaviorTree/Troop/Init/BT_HuaShan_Troop_Init_',1,true)==1 then r.opened=true;return end end end if o.busy(a) then return end if r.blue then local tree=asset(INIT,true);local lib=asset(GAS) if not U.valid(tree) or not U.valid(lib) then return end local event=tag('GameplayEvent.AI.EventTransition.CustomState') r.opened=true local sent=call(lib,'SendGameplayEventToActor',a,event,{EventTag=event,Instigator=a,OptionalObject=tree}) local matched=same(running(a),tree) if not sent and not matched and not r.openerRetried then r.opened=false;r.openerRetried=true;r.nextOpen=now+1 end say('大师兄起手 '..r.rows[1].name..' 原版树调用='..tostring(sent)..' 当前树相符='..tostring(matched)) else local asc=U.field(a,'AbilitySystemComponent');local cls=asset(INTRO,true) local specs=U.array(U.struct(U.field(asc,'ActivatableAbilities'),'Items')) if not specs or not U.valid(cls) or get(cls,'IsAnyClass')~=true then return end local spec for _,row in ipairs(specs)do if same(get(U.struct(row,'Ability'),'GetClass'),cls) then spec=row;break end end r.opened=true local accepted local refused=false if spec then local count=U.struct(spec,'ActiveCount') if type(count)=='number' then if count>0 then accepted=true else local ok,result=call(asc,'TryActivateAbilityByClass',cls,false) accepted=ok and result==true;refused=ok and result==false end end else local handle=U.struct(get(asc,'K2_GiveAbilityAndActivateOnce',cls,1,-1),'Handle') accepted=type(handle)=='number' and handle>0 refused=type(handle)=='number' and handle<=0 end if refused and not r.introSeen and not r.introRetried then r.opened=false;r.introRetried=true;r.nextOpen=now+1 end say('阿瑾爆脸转化 '..r.rows[1].name..' 原生技能受理='..tostring(accepted)) end end local function companionEncounter(r,now) local leader=r.rows[1].actor local fighting=owned(leader,r.rows[1].name,r) and o.companionFighting and o.companionFighting(leader) local enemy,key,name if fighting==true and owned(leader,r.rows[1].name,r) and (o.hp(leader) or 0)>0 and o.companionOpponent then local candidate=o.companionOpponent(leader) local id=U.key(candidate) if id and owners[id]~=r and sides[id]~='companion' and U.inWorld(candidate,r.world) and (o.hp(candidate) or 0)>0 then enemy,key,name=candidate,id,pathOf(candidate) end end r.enemy,r.enemyKey,r.enemyName=enemy,key,name if not domainMembers(r) then return end if enemy then r.idleSince=nil if not r.encounter then self:assigned(leader,enemy) end elseif fighting==false then r.idleSince=r.idleSince or now if now-r.idleSince>=1.5 then r.encounter,r.entering,r.nextOpen=nil,nil,nil if r.blue then r.opened,r.openerRetried=nil,nil end end else r.idleSince=nil end end function self:tick() if not alive or not next(groups) then return end local current=U.key(o.world());if not current then return end local now=clock() for key in pairs(casts)do self:supporting(key)end local pass for _,r in pairs(groups)do if not r.building then if r.retiring or r.worldKey~=current then release(r,current) elseif r.ready and type(now)=='number' then if r.livingChecks and now>=(r.nextLivingCheck or 0) then local verified,n,wanted=livingRoster(r) r.livingChecks=r.livingChecks+1;r.nextLivingCheck=now+1 if verified or r.livingChecks>=6 then say('登场后原生存活复核 '..r.rows[1].name..' 读回='..tostring(n)..' 当前正HP='..wanted..' 相符='..tostring(verified)) r.livingChecks=nil end end if r.team=='companion' then companionEncounter(r,now) elseif r.revision~=revision then pass=pass or {};domainMembers(r,pass)end opening(r,now);memberDeaths(r,now);receipts(r,now) end end end end function self:silence(gameThread) alive=false if not next(groups) then return end local function retire() for _,r in pairs(groups)do release(r,nil,true)end end if gameThread then retire() elseif type(o.defer or ExecuteInGameThread)=='function' then pcall(o.defer or ExecuteInGameThread,retire) end end return self end return Party