miduo_server/luafight/Modules/Battle/Logic/Buff/Blood.lua

79 lines
2.3 KiB
Lua
Raw Normal View History

2021-10-22 16:59:08 +08:00
Blood = Buff:New()
--初始化Buff通过传入一些自定义参数控制成长相关的数值
function Blood:SetData(...)
-- 刷新排序等级
2022-03-21 16:33:26 +08:00
--self.bloodValue=...
self.bloodValue=0
2021-10-22 16:59:08 +08:00
self.sort = 4
end
function Blood:AddValue(value)
2021-12-07 18:37:27 +08:00
local passiveChange=function(addValue)
value=value+addValue
end
2022-11-17 18:25:26 +08:00
if self.target==nil then
return
end
2021-12-07 18:37:27 +08:00
BattleLogic.Event:DispatchEvent(BattleEventName.BloodValuePassiveChange,passiveChange,self.target,self.caster,value)
2021-10-22 16:59:08 +08:00
self.bloodValue=self.bloodValue+value
self.target.Event:DispatchEvent(BattleEventName.BloodValueChange,self.bloodValue/self.target:GetRoleData(RoleDataName.MaxHp),1,value)
end
--初始化后调用一次
function Blood:OnStart()
2022-03-21 16:33:26 +08:00
--self.target.bloodShield = self
-- local passiveChange=function(addValue)
-- self.bloodValue=self.bloodValue+addValue
-- end
-- BattleLogic.Event:DispatchEvent(BattleEventName.BloodValuePassiveChange,passiveChange,self.target,self.caster,self.bloodValue)
-- self.target.Event:DispatchEvent(BattleEventName.BloodValueChange,self.bloodValue/self.target:GetRoleData(RoleDataName.MaxHp),1,self.bloodValue)
2021-10-22 16:59:08 +08:00
end
function Blood:GetCurValue()
return self.bloodValue
end
--间隔N帧触发返回true时表示继续触发返回false立刻触发OnEnd
function Blood:OnTrigger()
return true
end
--效果结束时调用一次
function Blood:OnEnd()
self.target.Event:DispatchEvent(BattleEventName.BloodValueChange,0)
self.target.bloodShield = nil
self.bloodValue=0
end
--计算血甲
2021-12-07 18:37:27 +08:00
function Blood:CountBloodValue(damage,atkRole)
2021-10-22 16:59:08 +08:00
local finalDamage=0
2022-11-17 18:25:26 +08:00
if self.target==nil then
return
end
2021-10-22 16:59:08 +08:00
self.bloodValue=self.bloodValue-damage
if self.bloodValue<=0 then
self.disperse=true
finalDamage=self.bloodValue
end
local value=0
if self.bloodValue<=0 then
value=0
2021-12-07 18:37:27 +08:00
self.bloodValue=0
2022-03-21 16:33:26 +08:00
self.target.Event:DispatchEvent(BattleEventName.BloodValueGetZero,self.bloodValue/self.target:GetRoleData(RoleDataName.MaxHp),atkRole)
2021-10-22 16:59:08 +08:00
end
2022-03-21 16:33:26 +08:00
self.target.Event:DispatchEvent(BattleEventName.BloodValueChange,self.bloodValue/self.target:GetRoleData(RoleDataName.MaxHp))
2021-10-22 16:59:08 +08:00
return finalDamage
end
--只有当cover字段为true时触发返回true则被新效果覆盖
function Blood:OnCover(newBuff)
return true
end
return Blood