50 lines
1.5 KiB
Lua
50 lines
1.5 KiB
Lua
local BattleConst = require "app/module/battle/battle_const"
|
|
|
|
local BattlePassive = {
|
|
passiveSkills = {}
|
|
}
|
|
|
|
local PASSIVE_EVENT = BattleConst.PASSIVE_EVENT
|
|
local SKILL_RECORD_DATA_NAME = BattleConst.SKILL_RECORD_DATA_NAME
|
|
local DEFAULT_FACTOR = BattleConst.DEFAULT_FACTOR
|
|
|
|
function BattlePassive:init()
|
|
end
|
|
|
|
function BattlePassive:clear()
|
|
end
|
|
|
|
local function _checkOnUnitPrepareOver(unitComp, skill, targetComp)
|
|
return 1
|
|
end
|
|
|
|
local function _checkOnUniAttackStart(unitComp, skill, targetComp)
|
|
return 1
|
|
end
|
|
|
|
local function _checkhpLowerThan(unitComp, skill, targetComp, hpPercent)
|
|
local triggerValue = skill:getPassiveTriggerValue() or 0
|
|
if hpPercent*DEFAULT_FACTOR < triggerValue then -- 低于指定血量,触发技能
|
|
local data = unitComp.unitEntity:getTeamRecordData(SKILL_RECORD_DATA_NAME.HP_LOWER_THAN) or 0
|
|
if data == 1 then -- 已经触发过了
|
|
return 0
|
|
end
|
|
unitComp.unitEntity:setTeamRecordData(SKILL_RECORD_DATA_NAME.HP_LOWER_THAN, 1)
|
|
return 1
|
|
else
|
|
local data = unitComp.unitEntity:getTeamRecordData(SKILL_RECORD_DATA_NAME.HP_LOWER_THAN) or 0
|
|
if data == 1 then -- 已经触发过了,那么需要取消
|
|
unitComp.unitEntity:setTeamRecordData(SKILL_RECORD_DATA_NAME.HP_LOWER_THAN, 0)
|
|
return -1
|
|
end
|
|
end
|
|
return 0
|
|
end
|
|
|
|
BattlePassive.checkTrigger = {
|
|
[PASSIVE_EVENT.ON_UNIT_PREPARE_OVER] = _checkOnUnitPrepareOver,
|
|
[PASSIVE_EVENT.ON_UNI_ATTACK_START] = _checkOnUniAttackStart,
|
|
[PASSIVE_EVENT.HP_LOWER_THAN] = _checkhpLowerThan,
|
|
}
|
|
|
|
return BattlePassive |