UGCProjects/OneShotKill/Script/Global/BuffSystem/BuffAction/BuffAction_DamageAddBuff.lua

45 lines
1.9 KiB
Lua
Raw Normal View History

2025-01-04 23:00:19 +08:00
local BuffActionBase = require('Script.Global.BuffSystem.BuffActionBase')
local BuffAction_DamageAddBuff = setmetatable(
{
-- Param ---------------------------
-- 每秒恢复量
BuffAssetType = nil;
-- Param End -----------------------
},
{ __index = BuffActionBase, __metatable = BuffActionBase }
);
function BuffAction_DamageAddBuff:LuaDoAction()
BuffActionBase.LuaDoAction(self)
if not UGCGameSystem.IsServer() then return true end
UGCLogSystem.Log("[BuffAction_DamageAddBuff_LuaDoAction]Params:%s, %s", self.ReplyPerSecond, self.WaitAddHealthTime)
-- 绑定Event传入的self可能有点问题需要与存储OwnerPawn才能获取到正确的OwnerPawn
UGCEventSystem.AddListener(EventEnum.PlayerInjuryInfo, self.PlayerInjuryInfo, self)
end
function BuffAction_DamageAddBuff:LuaUndoAction()
BuffActionBase.LuaUndoAction(self)
if not UGCGameSystem.IsServer() then return true end
UGCLogSystem.Log("[BuffAction_DamageAddBuff_LuaUndoAction]")
UGCEventSystem.RemoveListener(EventEnum.PlayerInjuryInfo, self.PlayerInjuryInfo, self)
end
function BuffAction_DamageAddBuff:PlayerInjuryInfo(VictimKey, CauserKey, WeaponID, DamageType, IsHeadShotDamage, Distance, DamageValue)
local Victim = UGCGameSystem.GetPlayerPawnByPlayerKey(VictimKey)
if UE.IsValid(self:GetOwnerPawn()) and self:GetOwnerPawn():IsAlive() and UE.IsValid(Victim) and Victim:IsAlive() then
if CauserKey == self:GetOwnerPawn().PlayerKey and self.BuffAssetType and UGCPlayerStateSystem.GetTeamID(CauserKey) ~= UGCPlayerStateSystem.GetTeamID(VictimKey) then
BuffSystemAPI.PlayerAddBuff(Victim, self.BuffAssetType, self:GetOwnerPawn():GetController(), self:GetOwnerPawn())
UGCLogSystem.Log("[BuffAction_DamageAddBuff_PlayerInjuryInfo] Succeed")
end
end
end
return BuffAction_DamageAddBuff;