From 431c57c3530a4ea8cbf72db244b480a709684fa7 Mon Sep 17 00:00:00 2001 From: chenxi Date: Wed, 19 Apr 2023 10:47:02 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8A=A0=E4=B8=80=E4=B8=AA=E8=A2=AB=E5=8A=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lua/app/module/battle/battle_const.lua | 1 + .../module/battle/component/battle_unit_comp.lua | 14 +++++++++++--- lua/app/module/battle/helper/battle_passive.lua | 5 +++++ .../userdata/battle/skill/battle_skill_entity.lua | 7 ++++++- .../userdata/battle/team/battle_team_entity.lua | 4 ++++ .../userdata/battle/team/battle_unit_entity.lua | 4 ++++ 6 files changed, 31 insertions(+), 4 deletions(-) diff --git a/lua/app/module/battle/battle_const.lua b/lua/app/module/battle/battle_const.lua index 8fcf179b..4051846c 100644 --- a/lua/app/module/battle/battle_const.lua +++ b/lua/app/module/battle/battle_const.lua @@ -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 = { diff --git a/lua/app/module/battle/component/battle_unit_comp.lua b/lua/app/module/battle/component/battle_unit_comp.lua index 73c692d5..7bfbd837 100644 --- a/lua/app/module/battle/component/battle_unit_comp.lua +++ b/lua/app/module/battle/component/battle_unit_comp.lua @@ -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) diff --git a/lua/app/module/battle/helper/battle_passive.lua b/lua/app/module/battle/helper/battle_passive.lua index 4c24d36c..12beb35e 100644 --- a/lua/app/module/battle/helper/battle_passive.lua +++ b/lua/app/module/battle/helper/battle_passive.lua @@ -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 \ No newline at end of file diff --git a/lua/app/userdata/battle/skill/battle_skill_entity.lua b/lua/app/userdata/battle/skill/battle_skill_entity.lua index db387a03..b3e06231 100644 --- a/lua/app/userdata/battle/skill/battle_skill_entity.lua +++ b/lua/app/userdata/battle/skill/battle_skill_entity.lua @@ -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) diff --git a/lua/app/userdata/battle/team/battle_team_entity.lua b/lua/app/userdata/battle/team/battle_team_entity.lua index 00672b56..184ec4b3 100644 --- a/lua/app/userdata/battle/team/battle_team_entity.lua +++ b/lua/app/userdata/battle/team/battle_team_entity.lua @@ -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 diff --git a/lua/app/userdata/battle/team/battle_unit_entity.lua b/lua/app/userdata/battle/team/battle_unit_entity.lua index 657fb9be..efe05787 100644 --- a/lua/app/userdata/battle/team/battle_unit_entity.lua +++ b/lua/app/userdata/battle/team/battle_unit_entity.lua @@ -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 = {}