-- Scoped NPC control for a verified pole seat. The original projectile owns damage and hit reactions. local U=require('ue_observe') local Combat={} local AI='/Script/SGameAI.Default__SGameAIFunctionLibrary' local MESH='/Script/Engine.SkeletalMeshComponent' local HEAD='/HuaShira/Characters/Monster/DaTouWaWa/HouHouHou/HouHouHou_Head.HouHouHou_Head' local FIRE='/PBZCombatAsset/ActorData/Players/Hun/Abilities/LionHeadHouHouHou/BulletData_Hun_LionDanceHead_FireBall.BulletData_Hun_LionDanceHead_FireBall' local BULLET_PACKAGE='/PBZCombatAsset/ActorData/Mobs/LionDancer/BP_Bullet_LionDancer_FlameBall_Small' local BULLET=BULLET_PACKAGE..'.BP_Bullet_LionDancer_FlameBall_Small_C' local POSE_DIR='/HuaShira/Characters/EliteBoss/LionDancer_P2/Hun_Anim/B/' local SHOOT=POSE_DIR..'Hun_LionHead_B_Attack_R.Hun_LionHead_B_Attack_R' local FIRST_HOP=POSE_DIR..'Hun_LionHead_B_Dodge_F_R.Hun_LionHead_B_Dodge_F_R' local HOP=POSE_DIR..'Hun_LionHead_B_Battle_Walk_Fwd_R.Hun_LionHead_B_Battle_Walk_Fwd_R' local IDLE=POSE_DIR..'Hun_LionHead_B_Battle_Idle_R.Hun_LionHead_B_Battle_Idle_R' local HEAD_TAG='CharacterState.HasTempWeapon.HouHouHouHead' local POLE_TAG='CharacterState.AbilityState.LionDancer.OnPole' local ABILITY_UTILS='/Script/SGameUtils.Default__AbilityUtils' local ABILITY='/Script/GameplayAbilities.Default__AbilitySystemBlueprintLibrary' local SWITCH='GameplayEvent.Ability.Action.TempWeapon.ForceSwitch' local LAUNCH_FRAME,SHOT_END=0.990279,2.766667 local PAUSE_REASON='PhantomGladiator lion pole' local function call(object,method,...) if not U.valid(object) then return false end local ok,value=pcall(function(target,key,...)return target[key](target,...)end,object,method,...) return ok,U.unwrap(value) end local function same(a,b) local key=U.key(a) return key~=nil and key==U.key(b) end local function transform(at,pitch,yaw) local cp,sp,cy,sy=math.cos(pitch/2),math.sin(pitch/2),math.cos(yaw/2),math.sin(yaw/2) return {Translation=at,Rotation={X=sp*sy,Y=-sp*cy,Z=cp*sy,W=cp*cy},Scale3D={X=1,Y=1,Z=1}} end function Combat.new(options) local self={} local find=options.find or StaticFindObject local load=options.load or LoadAsset local name=options.fname or FName local function say(text)options.log('[LionPoleCombat] '..text)end local function live(actor,world) return U.inWorld(actor,world) and not options.isDestroying(actor) end local function object(path) local ok,value=pcall(find,path) if not ok or not U.valid(value) then ok,value=pcall(load,path) end if not ok or not U.valid(value) then ok,value=pcall(find,path) end return ok and U.valid(value) and value or nil end local function brainOf(actor) return U.field(U.field(actor,'Controller'),'BrainComponent') end local function paused(brain) local ok,value=call(brain,'IsPaused') if ok and type(value)=='boolean' then return value end end local function matches(bullet,seat,control) return live(bullet,seat.world) and same(U.field(bullet,'BulletOwnerAvatar'),seat.actor) and same(U.field(bullet,'BulletData'),control.data) end local function stopPose(control) if not control.pose then return true end if not control.pose:stop() then return false end control.pose=nil control.clip=nil return true end local function headCount(actor) local ok,count=call(U.field(actor,'AbilitySystemComponent'),'GetGameplayTagCount',{TagName=name(HEAD_TAG)}) return ok and type(count)=='number' and count or nil end local function poleCount(asc) local ok,count=call(asc,'GetGameplayTagCount',{TagName=name(POLE_TAG)}) return ok and type(count)=='number' and count>=0 and count or nil end local function offerPoleTarget(seat,control) if not seat.confirmed or not seat.pickup or not seat.pickup.planned or not control.nativeHead then return end local asc=U.field(seat.actor,'AbilitySystemComponent') local count=poleCount(asc) if count==nil or count>0 then return end local utils=object(ABILITY_UTILS) local added=call(utils,'AddLooseGameplayTag',seat.actor,{TagName=name(POLE_TAG)},false) local after=poleCount(asc) if (after and after>0) or (after==nil and added) then control.poleTag={asc=asc,utils=utils} end say('已落桩挑战者通知原版舞狮选招 actor='..seat.key..' 桩标签读回='..tostring(after)) end local function restorePoleTarget(seat,control) local record=control.poleTag if not record or not live(seat.actor,seat.world) or not same(U.field(seat.actor,'AbilitySystemComponent'),record.asc) then return true end local before=poleCount(record.asc) if before==nil then return false end if before==0 or record.expected and before<=record.expected then control.poleTag=nil;return true end if record.expected then return false end local removed=call(record.utils,'RemoveLooseGameplayTag',seat.actor,{TagName=name(POLE_TAG)},false) local after=poleCount(record.asc) if after and after=LAUNCH_FRAME then if not launch(seat,control) then return false end control.fired=true end return true end if control.started and now-control.started>=SHOT_END then control.started=nil;control.fired=false if not playPose(seat,IDLE,true) then return false end if control.shots-control.hoppedAfter>=2 then return true,true end end if not control.started and not canAct then return stopPose(control) end if not control.started and not playPose(seat,IDLE,true) then return false end local bulletRunning=matches(control.bullet,seat,control) and U.field(control.bullet,'BulletStatus')==2 if not control.started and now>=control.nextAt and canAct and not bulletRunning then local _,yaw=aim(seat) local hp=options.hp(seat.actor) if yaw and type(hp)=='number' and hp>0 then call(seat.carrier,'K2_SetActorRotation',{Pitch=0,Yaw=math.deg(yaw),Roll=0},false) if not playPose(seat,SHOOT,false) then return false end control.started=now;control.hp=hp;control.fired=false end end return true end return self end return Combat