54 lines
2.2 KiB
Lua
54 lines
2.2 KiB
Lua
-- Script.Global.BuffSystem.BuffAction.BuffAction_ContinuousDamage
|
|
local BuffActionBase = require('Script.Global.BuffSystem.BuffActionBase')
|
|
local BuffAction_ContinuousDamage = setmetatable(
|
|
{
|
|
-- 每秒受到的伤害
|
|
DamagePerSecond = 10;
|
|
|
|
LastDamageTime = 0;
|
|
},
|
|
{ __index = BuffActionBase, __metatable = BuffActionBase }
|
|
);
|
|
|
|
--[[
|
|
-- 常用接口
|
|
self:GetInstID() -- 获取BuffID
|
|
self:GetOwnerPawn() -- 获取拥有者
|
|
BuffSystemAPI.GetBuffCauser(self:GetInstID()) -- 获取Buff给予者
|
|
|
|
self:EnableTick() -- 开启Tick
|
|
self:StopTick() -- 会自动关
|
|
self:IsEnableTick() -- 是否已开启Tick
|
|
]]
|
|
|
|
function BuffAction_ContinuousDamage:LuaDoAction()
|
|
BuffActionBase.LuaDoAction(self)
|
|
if not UGCGameSystem.IsServer() then return true end
|
|
UGCLogSystem.Log("[BuffAction_ContinuousDamage_LuaDoAction] DamagePerSecond:%s", tostring(self.DamagePerSecond))
|
|
self:EnableTick()
|
|
end
|
|
|
|
function BuffAction_ContinuousDamage:LuaUpdateAction(DeltaSeconds)
|
|
BuffActionBase.LuaUpdateAction(self, DeltaSeconds)
|
|
self.LastDamageTime = self.LastDamageTime + DeltaSeconds
|
|
if self.LastDamageTime < 1. then return end
|
|
self.LastDamageTime = self.LastDamageTime - 1
|
|
--UGCLogSystem.Log("[BuffAction_ContinuousDamage_LuaUpdateAction] 1")
|
|
local OwnerPawn = self:GetOwnerPawn()
|
|
if UE.IsValid(OwnerPawn) then
|
|
-- UGCLogSystem.Log("[BuffAction_ContinuousDamage_LuaUpdateAction] BuffID:%s, PlayerHealth:%s",tostring(self:GetInstID()), tostring(UGCPawnAttrSystem.GetHealth(OwnerPawn)))
|
|
local BuffCauser = BuffSystemAPI.GetBuffCauser(self:GetInstID())
|
|
--UGCLogSystem.Log("[BuffAction_ContinuousDamage_LuaUpdateAction] OwnerPawn:%s", tostring(OwnerPawn))
|
|
|
|
if BuffCauser == nil then
|
|
BuffCauser = OwnerPawn:GetController()
|
|
--UGCLogSystem.Log("[BuffAction_ContinuousDamage_LuaUpdateAction] BuffCauser:%s", tostring(BuffCauser))
|
|
end
|
|
local Res = UGCGameSystem.ApplyDamage(self:GetOwnerPawn(), self.DamagePerSecond, nil, nil, EDamageType.UGCCustomDamageType + 1)
|
|
-- UGCLogSystem.Log("[BuffAction_ContinuousDamage_LuaUpdateAction] 4 Damage:%s, Res:%s", tostring(self.DamagePerSecond), Res)
|
|
end
|
|
end
|
|
|
|
|
|
|
|
return BuffAction_ContinuousDamage; |