-- 雷当's story fight in 戏梦山庄 (flow graphs QuestFlowGraph/QingSheDao/BPF_LeiDangOrYuer_*). -- -- Any phase-one 雷当 (/047_LeiDang/) that runs its phase-end move GA_LeiDang_CA tells the player that 雷当 is killed: 3.55 s -- into the move a GAA_DurationTags gives it CharacterState.AbilityState.LeiDang.Dead, and on that tag the move sends -- GameplayEvent.MobGroup.Clear with InstigatorTags [qsd.击杀.雷当] to GetPlayerCharacter. BP_Player_Base adds those tags to the -- story (EventPipelineManager.AddTags). Which 雷当 it is and which map it is in do not matter. With that tag, -- BPF_LeiDangOrYuer_Dead plays Seq123-4 and lets phase two out the first time the player comes near, before phase one has -- been fought; the intro then lets phase one out too. -- So while one of the mod's units is a phase-one 雷当, that event, sent while one of them has the LeiDang.Dead tag, goes to -- that unit instead of the player. Only BP_Player_Base listens for it (the native tag object is only referenced where it is -- defined). A hook on the player's handler shows whether it still got through. -- -- 雷煌 and 雷鸣 (/Game/RenewalContent/Actors/Mobs/Normal/) run the same AI config and move. -- The mod no longer summons any of them while the story lacks the tag (story_writes.lua), and the BP_Monster_LeiDang_NPC -- 冷荼's fifth round calls in is taken out as it comes (main.lua removeHelper); this covers one that was not. -- -- Once armed (the app's save-repair button, save_repair.lua), a save that already has the tag while phase one's spawner -- (LeiDang_Seq123-3) would still let it out gets what the game does when Seq123-4 starts (flow node SetSpawnerDespawn): -- the spawner is told not to spawn, saved and emptied. The tag is read from that spawner's own AIScript_AddTagOnDead, so -- no Chinese name has to be built here. local U=require('ue_observe') local Guard={} local SEND='/Script/GameplayAbilities.AbilitySystemBlueprintLibrary:SendGameplayEventToActor' local HEARD='/Game/PBZContent/Blueprint/Character/Player/BP_Player_Base.BP_Player_Base_C:EventReceived_BA05D11E4E68EAF4570C7CB73B67D54D' local CLEAR='GameplayEvent.MobGroup.Clear' local DEAD='CharacterState.AbilityState.LeiDang.Dead' local PHASE_ONE={'/047_LeiDang/','/Mobs/Normal/BP_Monster_LeiHuang.','/Mobs/Normal/BP_Monster_LeiMing.'} local SPAWNER_ID='LeiDang_Seq123-3' local TAG_TEXT='qsd.击杀.雷当' local FIGHT_OVER='qsd.Boss战.结束' -- BPF_LeiDangOrYuer_Dead's reaction to the tag is blocked once this is there local TAG_SCRIPT='AIScript_AddTagOnDead_C' local REPAIR_EVERY=3 -- seconds between looks at phase one's spawner local HEARD_WINDOW=2 -- seconds after a redirect in which the player's handler running means it got through local LINES=60 local function text(name) if type(name)=='string' then return name end local ok,value=pcall(function()return name:ToString()end) return ok and type(value)=='string' and value or nil end local function className(object) if not U.valid(object) then return '?' end return U.className(object) or '?' end function Guard.new(options) local log=options.log or function()end local clock=options.clock or os.clock local fname=options.fname or function(value)return FName and FName(value) end local register=options.registerHook or function(...)return RegisterHook(...)end local unregister=options.unregisterHook or function(...)return UnregisterHook(...)end local find=options.find or function(path)return StaticFindObject(path)end local self={redirected=0,leaked=0,passed=0,repaired=0,armed=options.repair==true} local hooks,pending,lines,repairAt,lastState,waiting=nil,nil,0,0,nil,false local function say(message) if lines0 then unit=candidate;break end end local tags=tagsOf(payload) if not unit then self.passed=self.passed+1 say('放行 '..CLEAR..' InstigatorTags=['..tags..']:召唤的一阶段雷当都不在转阶段') return nil end local before=U.unwrap(actor) local okSet=pcall(function()actor:set(unit)end) local after=U.unwrap(actor) local how,done='目标改成这只雷当',okSet and U.key(after)~=nil and U.key(after)==U.key(unit) if not done then local okTag=pcall(function()eventTag:set({TagName=fname('None')})end) how='事件标签改成 None' done=okTag and text(U.struct(U.unwrap(eventTag),'TagName'))=='None' end self.redirected=self.redirected+1 pending={at=clock(),unit=label(unit)} say(string.format('召唤的雷当 %s 放完转阶段技能,发给 %s 的 %s InstigatorTags=[%s]:%s 写入=%s 读回=%s 累计=%d', label(unit),className(before),CLEAR,tags,how,tostring(okSet),done and '已改' or '没改成',self.redirected)) return nil end -- After BP_Player_Base handled one: right after a redirect it means the story got the tags anyway. local function onHeard(_,payload) if not hooks then return nil end local tags=tagsOf(payload) if pending and clock()-pending.at0 if want and not hooks then hook() elseif not want and hooks then unhook('召唤的一阶段雷当都已离场') end if pending and now-pending.at>=HEARD_WINDOW then say('确认:玩家没收到 '..pending.unit..' 的剧情事件') pending=nil end if now>=repairAt then repairAt=now+REPAIR_EVERY repair() end end -- From the save-repair button: phase one's spawner may be turned off from now on; looked at again right away. function self:arm()self.armed=true;repairAt=0 end -- For the save-repair report: true when there is nothing to do (false when there is, nil when unread) and a short -- line. has(text) answers whether the story holds a mark (true/false/nil). function self:diagnose(has) local killed=has and has(TAG_TEXT) if killed==nil then return nil,'雷当' end if killed==false then return true,'雷当' end local over=has(FIGHT_OVER) if over==true then return true,'雷当' end if self.repaired>0 then return false,'雷当:已关掉一阶段刷怪点,只打二阶段' end return false,'雷当:已被记成打过'..(over==nil and '(读不到这一战打完没有)' or '')..',到戏梦山庄时关掉一阶段,只打二阶段' end function self:status() return {hooked=hooks~=nil,redirected=self.redirected,leaked=self.leaked,passed=self.passed,repaired=self.repaired,armed=self.armed} end return self end return Guard