加一个被动

This commit is contained in:
chenxi 2023-04-19 10:47:02 +08:00
parent 92edaa2a73
commit 431c57c353
6 changed files with 31 additions and 4 deletions

View File

@ -129,6 +129,7 @@ BattleConst.PASSIVE_EVENT = {
ON_UNIT_PREPARE_OVER = 2, -- 新单位出场时
ON_UNI_ATTACK_START = 3, -- 攻击开始前
HP_LOWER_THAN = 4, -- 血量低于X%
USE_NORMAL_SKILL = 5, -- 使用普攻
}
local BUFF_NAME = {

View File

@ -812,9 +812,6 @@ end
function BattleUnitComp:onSkillTakeEffect(skill)
skill:endUse()
if self.side == GConst.BattleConst.SIDE_ATK and skill == self.unitEntity:getNormalSkill() then
self.battleController:addBattleExp(self.side)
end
local effectList = skill:getEffectList()
if effectList == nil then
return
@ -825,6 +822,14 @@ function BattleUnitComp:onSkillTakeEffect(skill)
target = self
else
target = self.battleController:getOtherSideMainUnit(self.side)
if skill:getIsNormalType() then -- 普攻要计算一下格挡
local block = target.unitEntity:getBlock()
if block > 0 then
if BattleHelper:random(1, DEFAULT_FACTOR) <= block then -- 格挡成功
return
end
end
end
end
local succ = false
@ -833,6 +838,9 @@ function BattleUnitComp:onSkillTakeEffect(skill)
succ = true
end
end
if succ and skill:getIsNormalType() then -- 普攻攻击成功的话
self:checkPassiveEvent(BattleConst.PASSIVE_EVENT_TYPE.USE_NORMAL_SKILL, target)
end
end
function BattleUnitComp:takeEffect(buff, target)

View File

@ -41,10 +41,15 @@ local function _checkhpLowerThan(unitComp, skill, targetComp, hpPercent)
return 0
end
local function _checkUseNormalSkill(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,
}
return BattlePassive

View File

@ -1,4 +1,5 @@
local BattleBuffEntity = require "app/userdata/battle/skill/battle_buff_entity"
local BattleConst = require "app/module/battle/battle_const"
local BattleSkillEntity = class("BattleSkillEntity", BaseData)
@ -104,7 +105,11 @@ function BattleSkillEntity:getSkillid()
end
function BattleSkillEntity:getIsPassiveType()
return self.skillType == GConst.BattleConst.SKILL_TYPE_PASSIVE
return self.skillType == BattleConst.SKILL_TYPE_PASSIVE
end
function BattleSkillEntity:getIsNormalType()
return self.skillType == BattleConst.SKILL_TYPE_NORMAL
end
function BattleSkillEntity:changeSkillId(skillId)

View File

@ -191,6 +191,10 @@ function BattleTeamEntity:getShieldHp()
return self.shieldHp
end
function BattleTeamEntity:getBlock()
return self.attr.block or 0
end
function BattleTeamEntity:takeDamageOrCure(num)
if self.isDead then
return 0

View File

@ -233,6 +233,10 @@ function BattleUnitEntity:addMaxHp(num)
self.team:addMaxHp(num)
end
function BattleUnitEntity:getBlock()
return self.team:getBlock()
end
function BattleUnitEntity:addSkillExtraUseTimes(skillId, count)
if self.skillExtraUseTimes == nil then
self.skillExtraUseTimes = {}