61 lines
1.8 KiB
Lua
61 lines
1.8 KiB
Lua
local Buff_PoisonRange = {};
|
|
|
|
--- 下面的可以直接用,就能获取到值
|
|
Buff_PoisonRange.PlayerKey = nil;
|
|
Buff_PoisonRange.BuffType = nil;
|
|
Buff_PoisonRange.Owner = nil;
|
|
Buff_PoisonRange.BuffName = nil;
|
|
|
|
Buff_PoisonRange.PlayerKeys = {};
|
|
Buff_PoisonRange.Enemies = {};
|
|
Buff_PoisonRange.Emitter = {};
|
|
|
|
function Buff_PoisonRange:Init(Params)
|
|
return true;
|
|
end
|
|
|
|
function Buff_PoisonRange:AddBuff(Location)
|
|
local TeamId = UGCPlayerStateSystem.GetTeamID(self.PlayerKey);
|
|
UE.ForeachEnemyTeam(self.PlayerKey, function(Pawn)
|
|
-- 检查是否在范围内
|
|
if VectorHelper.GetDistance2D(Location, Pawn:K2_GetActorLocation()) < self.Radius then
|
|
self.Enemies[Pawn.PlayerKey] = Pawn;
|
|
end
|
|
end)
|
|
if table.getCount(self.Enemies) == 0 then return ; end
|
|
|
|
if IsServer then
|
|
self.Handle = GlobalTickTool:AddTick(self, function(o, dt, st)
|
|
local PC = UGCGameSystem.GetPlayerControllerByPlayerKey(self.PlayerKey);
|
|
for PlayerKey, Pawn in pairs(self.Enemies) do
|
|
if not UE.IsValidPawn(Pawn) then self.Enemies[PlayerKey] = nil; end
|
|
local Damage = UGCGameSystem.ApplyDamage(Pawn, self.Damage * self.Interval, PC, UGCGameSystem.GetPlayerPawnByPlayerKey(self.PlayerKey), EDamageType.PoisonDamage);
|
|
if Damage > 0 then
|
|
UGCLogSystem.Log("[Buff_Burning:AddBuff] 产生伤害:%f", Damage);
|
|
end
|
|
end
|
|
end, self.Interval, nil, self.Continue);
|
|
else
|
|
-- 特效
|
|
self:RemoveParticle();
|
|
self.Emitter = {};
|
|
ObjectPath.AddFunc(self.Particle, function(Target)
|
|
for i, Pawn in pairs(self.Enemies) do
|
|
table.insert(self.Emitter, UE.SpawnEmitterAttached(Target, Pawn, VectorHelper.MakeVector(0, 0, 100)));
|
|
end
|
|
end);
|
|
end
|
|
|
|
return true;
|
|
end
|
|
|
|
function Buff_PoisonRange:RemoveBuff(...)
|
|
if IsServer then
|
|
GlobalTickTool:RemoveTickByHandle(self.Handle);
|
|
else
|
|
self:RemoveParticle();
|
|
end
|
|
return true;
|
|
end
|
|
|
|
return Buff_PoisonRange; |