2025-01-04 23:00:19 +08:00

52 lines
1.4 KiB
Lua
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

local Buff_Poison = {};
--- 下面的可以直接用,就能获取到值
Buff_Poison.OwnerPlayerKey = nil;
Buff_Poison.BuffType = nil;
Buff_Poison.Owner = nil;
Buff_Poison.BuffName = nil;
Buff_Poison.PlayerKeys = {};
function Buff_Poison:Init(Params)
return true;
end
function Buff_Poison:AddBuff(Pawn)
if Pawn then
UGCLogSystem.Log("[Buff_Poison:AddBuff] 执行Pawn = %s", UGCPawnAttrSystem.GetPlayerName(Pawn));
else
UGCLogSystem.Log("[Buff_Poison:AddBuff] 不存在 Pawn")
end
if not UE.IsValidPawn(Pawn) then return false; end
local PlayerKey = Pawn.PlayerKey;
if IsServer then
self.PoisonHandle = GlobalTickTool:AddTick(self, function(o, dt, st)
UGCLogSystem.Log("[Buff_Poison:AddBuff] 执行")
local Health = UGCPawnAttrSystem.GetHealth(Pawn);
Health = math.clamp(Health - self.Damage * self.Interval, 0, Health);
UGCPawnAttrSystem.SetHealth(Pawn, Health);
end, self.Interval, function(o)
if UE.IsValidPawn(Pawn) then
if Pawn.PlayerKey == PlayerKey then
return true;
end
end
return false;
end, self.Continue);
else
self:SpawnEmitterAttached(Pawn, VectorHelper.MakeVector(0, 0, 100));
end
return true;
end
function Buff_Poison:RemoveBuff(...)
if IsServer then
GlobalTickTool:RemoveTickByHandle(self.PoisonHandle);
else
self:RemoveParticle();
end
return true;
end
return Buff_Poison;