local Action_SingleRespiratoryRegurgitation = { -- 可配置参数定义,参数将显示在Action配置面板 -- 例: -- MyIntParameter = 0 AddHealthFrequency = 5; ReplyPerSecond = 10.; -- 每一秒增加的血量 WaitAddHealthTime = 3.; } -- 触发器激活时,将执行Action的Execute function Action_SingleRespiratoryRegurgitation:Execute(...) -- 给玩家添加 UGCEventSystem.AddListener(EventTypes.PlayerEnableRR, self.OnEnablePlayerRR, self); UGCEventSystem.AddListener(EventTypes.PlayerCause, self.PlayerVictim, self); self.Players = {}; self.UpdateAddTime = 0.; self.bEnableActionTick = true return true end function Action_SingleRespiratoryRegurgitation:Update(DeltaSeconds) self.UpdateAddTime = self.UpdateAddTime + DeltaSeconds; if self.UpdateAddTime >= (1. / self.AddHealthFrequency) then self.UpdateAddTime = self.UpdateAddTime - (1. / self.AddHealthFrequency); self:AddPlayerHealth(); end end -- 启动个人 function Action_SingleRespiratoryRegurgitation:OnEnablePlayerRR(InPlayerKey, IsAdd) local Time = KismetSystemLibrary.GetGameTimeInSeconds(UGCGameSystem.GameState); self.Players[InPlayerKey] = { Time = Time; Enable = IsAdd; }; end function Action_SingleRespiratoryRegurgitation:PlayerVictim(Damage, IsKill, CauserKey, VictimKey) if self.Players[VictimKey] == nil then return; end local Time = KismetSystemLibrary.GetGameTimeInSeconds(UGCGameSystem.GameState); self.Players[VictimKey].Time = Time; end function Action_SingleRespiratoryRegurgitation:CheckHasPlayer(InPlayerKey) return self.Players[InPlayerKey] == true; end function Action_SingleRespiratoryRegurgitation:AddPlayerHealth() local NowTime = KismetSystemLibrary.GetGameTimeInSeconds(UGCGameSystem.GameState); for PlayerKey, Table in pairs(self.Players) do if Table.Enable then local Pawn = UGCGameSystem.GetPlayerPawnByPlayerKey(PlayerKey); if UE.IsValid(Pawn) and Pawn.PlayerKey ~= nil and Pawn:IsAlive() then if NowTime - Table.Time > self.WaitAddHealthTime then UGCPawnAttrSystem.SetHealth(Pawn, Pawn:GetHealth() + self.ReplyPerSecond / self.AddHealthFrequency); end end end end end return Action_SingleRespiratoryRegurgitation;