UGCProjects/TwoOnTwo/Script/Global/BuffSystem/BuffAction/BuffAction_BeFatedNotToDie.lua
2025-01-04 23:00:19 +08:00

58 lines
2.1 KiB
Lua

local BuffActionBase = require('Script.Global.BuffSystem.BuffActionBase')
local BuffAction_BeFatedNotToDie = setmetatable(
{
-- Param ---------------------------
-- 命不该绝次数上限
MaxCount = 1;
-- 伤害修改函数的层级
ModifyDamageFuncLayer = 1e4;
-- Param End -----------------------
-- 已使用次数
UsedBuffCount = 0;
},
{ __index = BuffActionBase, __metatable = BuffActionBase }
);
function BuffAction_BeFatedNotToDie:LuaDoAction()
BuffActionBase.LuaDoAction(self)
if not UGCGameSystem.IsServer() then return true end
UGCLogSystem.Log("[BuffAction_BeFatedNotToDie_LuaDoAction]")
self:GetOwnerPawn():AddDamageModifyFunc(self.BeFatedNotToDieFunc, self, self.ModifyDamageFuncLayer)
end
function BuffAction_BeFatedNotToDie:LuaUndoAction()
BuffActionBase.LuaUndoAction(self)
if not UGCGameSystem.IsServer() then return true end
UGCLogSystem.Log("[BuffAction_BeFatedNotToDie_LuaUndoAction]")
if UE.IsValid(self:GetOwnerPawn()) then
self:GetOwnerPawn():RemoveDamageModifyFunc(self.BeFatedNotToDieFunc, self, self.ModifyDamageFuncLayer)
end
end
function BuffAction_BeFatedNotToDie:LuaResetAction()
BuffActionBase.LuaResetAction(self)
self.UsedBuffCount = 0
end
function BuffAction_BeFatedNotToDie:BeFatedNotToDieFunc(TargetPawn, DamageAmount, DamageType, EventInstigator, DamageCauser, Hit)
if self.UsedBuffCount < self.MaxCount then
local PlayerHealth = UGCPawnAttrSystem.GetHealth(TargetPawn)
if PlayerHealth - DamageAmount < 1 then
DamageAmount = PlayerHealth - 1
self.UsedBuffCount = self.UsedBuffCount + 1
UGCSendRPCSystem.RPCEvent(TargetPawn.PlayerKey, EventEnum.AddTip, TipConfig.TipType.BeFatedNotToDieOwner, self.UsedBuffCount)
if EventInstigator and EventInstigator.PlayerKey then
UGCSendRPCSystem.RPCEvent(EventInstigator.PlayerKey, EventEnum.AddTip, TipConfig.TipType.BeFatedNotToDieCauser)
end
end
end
return DamageAmount
end
return BuffAction_BeFatedNotToDie;