52 lines
2.0 KiB
Lua
52 lines
2.0 KiB
Lua
|
local BuffActionBase = require('Script.Global.BuffSystem.BuffActionBase')
|
|||
|
|
|||
|
local BuffAction_Vampirism = setmetatable(
|
|||
|
{
|
|||
|
-- Param ---------------------------
|
|||
|
-- 每秒恢复量
|
|||
|
Vampirism = 0.2;
|
|||
|
IsHPLimit = false;
|
|||
|
-- Param End -----------------------
|
|||
|
|
|||
|
|
|||
|
|
|||
|
},
|
|||
|
{ __index = BuffActionBase, __metatable = BuffActionBase }
|
|||
|
);
|
|||
|
|
|||
|
function BuffAction_Vampirism:LuaDoAction()
|
|||
|
BuffActionBase.LuaDoAction(self)
|
|||
|
if not UGCGameSystem.IsServer() then return true end
|
|||
|
UGCLogSystem.Log("[BuffAction_Vampirism_LuaDoAction]Params:%s, %s", self.ReplyPerSecond, self.WaitAddHealthTime)
|
|||
|
|
|||
|
-- 绑定Event传入的self可能有点问题,需要与存储OwnerPawn才能获取到正确的OwnerPawn
|
|||
|
UGCEventSystem.AddListener(EventEnum.PlayerInjuryInfo, self.PlayerInjuryInfo, self)
|
|||
|
end
|
|||
|
|
|||
|
function BuffAction_Vampirism:LuaUndoAction()
|
|||
|
BuffActionBase.LuaUndoAction(self)
|
|||
|
if not UGCGameSystem.IsServer() then return true end
|
|||
|
UGCLogSystem.Log("[BuffAction_Vampirism_LuaUndoAction]")
|
|||
|
UGCEventSystem.RemoveListener(EventEnum.PlayerInjuryInfo, self.PlayerInjuryInfo, self)
|
|||
|
end
|
|||
|
|
|||
|
|
|||
|
function BuffAction_Vampirism:PlayerInjuryInfo(VictimKey, CauserKey, WeaponID, DamageType, IsHeadShotDamage, Distance, DamageValue)
|
|||
|
if UE.IsValid(self:GetOwnerPawn()) and self:GetOwnerPawn():IsAlive() then
|
|||
|
if CauserKey == self:GetOwnerPawn().PlayerKey then
|
|||
|
local AddHealth = DamageValue * self.Vampirism
|
|||
|
if self.IsHPLimit then
|
|||
|
local Health = UGCPawnAttrSystem.GetHealth(self:GetOwnerPawn())
|
|||
|
UGCPawnAttrSystem.SetHealthMax(self:GetOwnerPawn(), UGCPawnAttrSystem.GetHealthMax(self:GetOwnerPawn()) + AddHealth)
|
|||
|
UGCPawnAttrSystem.SetHealth(self:GetOwnerPawn(), Health + AddHealth)
|
|||
|
else
|
|||
|
UGCPawnAttrSystem.SetHealth(self:GetOwnerPawn(), UGCPawnAttrSystem.GetHealth(self:GetOwnerPawn()) + AddHealth)
|
|||
|
end
|
|||
|
UGCLogSystem.Log("[BuffAction_Vampirism_PlayerInjuryInfo] Succeed")
|
|||
|
end
|
|||
|
end
|
|||
|
end
|
|||
|
|
|||
|
|
|||
|
|
|||
|
return BuffAction_Vampirism;
|