86 lines
3.1 KiB
Lua
86 lines
3.1 KiB
Lua
local BuffActive_RespiratoryRegurgitation = LuaClass("BuffActive_RespiratoryRegurgitation")
|
|
BuffActive_RespiratoryRegurgitation.BuffActive_RespiratoryRegurgitation = nil
|
|
BuffActive_RespiratoryRegurgitation.WaitHandle = nil
|
|
BuffActive_RespiratoryRegurgitation.RecoveryPerSecond = 10.
|
|
BuffActive_RespiratoryRegurgitation.HitDelayExecution = 3.
|
|
BuffActive_RespiratoryRegurgitation.TargetPlayerKey = -1
|
|
-- {
|
|
-- RespiratoryRegurgitationHandle = nil;
|
|
-- WaitHandle = nil;
|
|
-- RecoveryPerSecond = 10.;
|
|
-- HitDelayExecution = 3.;
|
|
-- TargetPlayerKey = -1;
|
|
-- };
|
|
function BuffActive_RespiratoryRegurgitation:ctor()
|
|
-- body
|
|
end
|
|
|
|
function BuffActive_RespiratoryRegurgitation:EnableRespiratoryRegurgitation(TargetPlayerKey, InHitDelayExecution, InRecoveryPerSecond)
|
|
UGCLogSystem.Log("[BuffActive_RespiratoryRegurgitation_BuffActive]")
|
|
if InHitDelayExecution ~= nil then
|
|
self.HitDelayExecution = InHitDelayExecution
|
|
end
|
|
if InRecoveryPerSecond ~= nil then
|
|
self.RecoveryPerSecond = InRecoveryPerSecond
|
|
end
|
|
|
|
|
|
self.TargetPlayerKey = TargetPlayerKey
|
|
self:RespiratoryRegurgitation()
|
|
self:GetPlayerPanw().OnPostTakeDamage:Add(self.TargetPlayerTakeDamage, self)
|
|
end
|
|
|
|
function BuffActive_RespiratoryRegurgitation:DisableRespiratoryRegurgitation()
|
|
self:ClearWaitHandle()
|
|
self:ClearRespiratoryRegurgitationHandle()
|
|
end
|
|
|
|
function BuffActive_RespiratoryRegurgitation:GetPlayerPanw()
|
|
return UGCGameSystem.GetPlayerPawnByPlayerKey(self.TargetPlayerKey)
|
|
end
|
|
|
|
function BuffActive_RespiratoryRegurgitation:TargetPlayerTakeDamage()
|
|
UGCLogSystem.Log("[BuffActive_RespiratoryRegurgitation_TargetPlayerTakeDamage]")
|
|
if self.HitDelayExecution > 0 then
|
|
self:ClearRespiratoryRegurgitationHandle()
|
|
self:ClearWaitHandle()
|
|
self.WaitHandle = UGCEventSystem.SetTimer(
|
|
UGCGameSystem.GameState,
|
|
function ()
|
|
self:RespiratoryRegurgitation()
|
|
end,
|
|
self.HitDelayExecution
|
|
)
|
|
end
|
|
end
|
|
|
|
function BuffActive_RespiratoryRegurgitation:ClearWaitHandle()
|
|
if self.WaitHandle then
|
|
UGCEventSystem.StopTimer(self.WaitHandle)
|
|
self.WaitHandle = nil
|
|
end
|
|
end
|
|
|
|
function BuffActive_RespiratoryRegurgitation:ClearRespiratoryRegurgitationHandle()
|
|
if self.RespiratoryRegurgitationHandle then
|
|
UGCEventSystem.StopTimer(self.RespiratoryRegurgitationHandle)
|
|
self.RespiratoryRegurgitationHandle = nil
|
|
end
|
|
end
|
|
|
|
function BuffActive_RespiratoryRegurgitation:RespiratoryRegurgitation()
|
|
self:ClearRespiratoryRegurgitationHandle()
|
|
self.RespiratoryRegurgitationHandle = UGCEventSystem.SetTimerLoop(
|
|
UGCGameSystem.GameState,
|
|
function ()
|
|
if not UE.IsValid(self:GetPlayerPanw()) or not self:GetPlayerPanw():IsAlive() then
|
|
self:ClearRespiratoryRegurgitationHandle()
|
|
return
|
|
end
|
|
UGCPawnAttrSystem.SetHealth(self:GetPlayerPanw(), UGCPawnAttrSystem.GetHealth(self:GetPlayerPanw()) + self.RecoveryPerSecond)
|
|
end,
|
|
1.0
|
|
)
|
|
end
|
|
|
|
return BuffActive_RespiratoryRegurgitation |