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 _checkOnActiveSkillBefore(unitComp, skill, targetComp) return 1 end local function _checkOnDeadByBurn(unitComp, skill, targetComp) return 1 end local function _checkOnDeadBySkill(unitComp, skill, targetComp) return 1 end local function _checkOnDeadWithBleed(unitComp, skill, targetComp) return 1 end local function _checkOnDead(unitComp, skill, targetComp) return 1 end local function _checkLinkX(unitComp, skill, targetComp) local triggerLimit = skill:getTriggerLimit() or 0 local data = unitComp.unitEntity:getTeamRecordData(SKILL_RECORD_DATA_NAME.LINK_X_THAN) or 0 if data >= triggerLimit then return 0 end local maxCount = 0 local eliminateMap = unitComp.battleController.totalEliminateCountMap for _, v in pairs(eliminateMap) do maxCount = maxCount + v end local triggerValue = skill:getPassiveTriggerValue() or 0 if maxCount >= (data + 1) * triggerValue then unitComp.unitEntity:setTeamRecordData(SKILL_RECORD_DATA_NAME.LINK_X_THAN, data + 1) return 1 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, [PASSIVE_EVENT.USE_NORMAL_SKILL] = _checkUseNormalSkill, [PASSIVE_EVENT.ACTIVE_SKILL_HIT] = _checkActiveSkillHit, [PASSIVE_EVENT.ON_ACTIVE_SKILL_BEFORE] = _checkOnActiveSkillBefore, [PASSIVE_EVENT.ON_DEAD_BY_BURN] = _checkOnDeadByBurn, [PASSIVE_EVENT.ON_DEAD_BY_SKILL] = _checkOnDeadBySkill, [PASSIVE_EVENT.ON_DEAD_WITH_BLEED] = _checkOnDeadWithBleed, [PASSIVE_EVENT.ON_DEAD] = _checkOnDead, [PASSIVE_EVENT.ON_LINK_X] = _checkLinkX, } return BattlePassive