52 lines
1.4 KiB
Lua
52 lines
1.4 KiB
Lua
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; |