47 lines
1.8 KiB
Lua
47 lines
1.8 KiB
Lua
local EventAction_RespiratoryRegurgitation = {
|
||
AddHealthFrequency = 5;
|
||
ReplyPerSecond = 10.;
|
||
WaitAddHealthTime = 5.;
|
||
PlayerVictimTime = {};
|
||
UpdateAddTime = 0;
|
||
}
|
||
|
||
-- 触发器激活时,将执行Action的Execute
|
||
function EventAction_RespiratoryRegurgitation:Execute(...)
|
||
UGCEventSystem.AddListener(EventEnum.PlayerInjuryInfo, self.PlayerInjuryInfo, self)
|
||
|
||
UGCLogSystem.Log("[EventAction_RespiratoryRegurgitation_Execute]")
|
||
|
||
self.bEnableActionTick = true
|
||
return true
|
||
end
|
||
|
||
|
||
function EventAction_RespiratoryRegurgitation:Update(DeltaSeconds)
|
||
UGCLogSystem.Log("[EventAction_RespiratoryRegurgitation_Update]")
|
||
self.UpdateAddTime = self.UpdateAddTime + DeltaSeconds
|
||
if self.UpdateAddTime >= (1. / self.AddHealthFrequency) then
|
||
self.UpdateAddTime = self.UpdateAddTime - 1. / self.AddHealthFrequency
|
||
self:AddPlayerHealth()
|
||
end
|
||
end
|
||
|
||
function EventAction_RespiratoryRegurgitation:PlayerInjuryInfo(VictimKey)
|
||
self.PlayerVictimTime[VictimKey] = UGCSystemLibrary.GetGameTime()
|
||
UGCLogSystem.Log("[EventAction_RespiratoryRegurgitation_PlayerInjuryInfo]")
|
||
end
|
||
|
||
function EventAction_RespiratoryRegurgitation:AddPlayerHealth()
|
||
local AllPlayer = UGCGameSystem.GameState:GetRespiratoryRegurgitationPlayers()
|
||
local NowTime = UGCSystemLibrary.GetGameTime()
|
||
for k, PlayerKey in pairs(AllPlayer) do
|
||
local PlayerPawn = UGCGameSystem.GetPlayerPawnByPlayerKey(PlayerKey)
|
||
if UE.IsValid(PlayerPawn) and PlayerKey and PlayerPawn:IsAlive()
|
||
and (self.PlayerVictimTime[PlayerKey] == nil or (NowTime - self.PlayerVictimTime[PlayerKey] >= self.WaitAddHealthTime)) then
|
||
UGCPawnAttrSystem.SetHealth(PlayerPawn, UGCPawnAttrSystem.GetHealth(PlayerPawn) + self.ReplyPerSecond / self.AddHealthFrequency)
|
||
end
|
||
end
|
||
end
|
||
|
||
|
||
return EventAction_RespiratoryRegurgitation |