c1_lua/lua/app/module/battle/helper/battle_passive.lua
2023-05-11 19:11:21 +08:00

65 lines
1.8 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
local function _checkUseNormalSkill(unitComp, skill, targetComp)
return 1
end
local function _checkActiveSkillHit(unitComp, skill, targetComp)
return 1
end
local function _checkOnDead(unitComp, skill, targetComp)
return 1
end
BattlePassive.checkTrigger = {
[PASSIVE_EVENT.ON_UNIT_PREPARE_OVER] = _checkOnUnitPrepareOver,
[PASSIVE_EVENT.ON_UNI_ATTACK_START] = _checkOnUniAttackStart,
[PASSIVE_EVENT.HP_LOWER_THAN] = _checkhpLowerThan,
[PASSIVE_EVENT.USE_NORMAL_SKILL] = _checkUseNormalSkill,
[PASSIVE_EVENT.ACTIVE_SKILL_HIT] = _checkActiveSkillHit,
[PASSIVE_EVENT.ON_DEAD] = _checkOnDead,
}
return BattlePassive