相互反击的bug
This commit is contained in:
parent
bff772a1de
commit
db985c714c
@ -128,6 +128,11 @@ BattleConst.UNIT_STATE = {
|
||||
VERITGO = 12, -- 昏睡
|
||||
}
|
||||
|
||||
BattleConst.ATTACK_ACTION_STATE = {
|
||||
NORMAL = "normal",
|
||||
COUNTERATTACK = "counterattack",
|
||||
}
|
||||
|
||||
BattleConst.MATCH_DMG_ADDITION_NAME = {
|
||||
[0] = "dmg_addition_none",
|
||||
[1] = "dmg_addition_red",
|
||||
@ -194,7 +199,6 @@ BattleConst.EFFECT_TYPE = {
|
||||
HEAL = 101,
|
||||
HOT = 102,
|
||||
REBOUND = 201, -- 反弹
|
||||
COUNTERATTACK = 301, -- 反击
|
||||
}
|
||||
|
||||
---- 特殊的伤害类型,其余都是buffname
|
||||
|
||||
@ -286,12 +286,14 @@ function BattleUnitComp:getIsCentralizedAttack()
|
||||
return self.team:getCentralizedAttack()
|
||||
end
|
||||
|
||||
function BattleUnitComp:beforeAttack(effectType)
|
||||
function BattleUnitComp:getCurAttackActionState()
|
||||
return self.curAttackActionState
|
||||
end
|
||||
|
||||
function BattleUnitComp:beforeAttack(actionState)
|
||||
self.team:setCentralizedAttack(true)
|
||||
self.battleController:setIsPauseHpProgress(true)
|
||||
if effectType == BattleConst.EFFECT_TYPE.DIRECT then
|
||||
self:checkPassiveEvent(PASSIVE_EVENT.ON_UNI_ATTACK_START, self)
|
||||
end
|
||||
self.curAttackActionState = actionState
|
||||
end
|
||||
|
||||
function BattleUnitComp:useAssistingSkill(count, delay, callback)
|
||||
@ -1509,6 +1511,15 @@ function BattleUnitComp:takeDamageOrCure(atker, num, effectType, effectStatus, d
|
||||
self:showEffectNumber(effectColor, direction, damageStr, x, y, delayTime)
|
||||
end
|
||||
end
|
||||
if atker:getCurAttackActionState() == BattleConst.ATTACK_ACTION_STATE.NORMAL then
|
||||
if self.unitEntity:getCounterAttack() > 0 then -- 触发反击
|
||||
local counterattack = self.unitEntity:getCounterAttack()
|
||||
if counterattack > DEFAULT_FACTOR or BattleHelper:random(1, DEFAULT_FACTOR) <= counterattack then -- 通过命中概率
|
||||
self.unitEntity:addCounterAttackCount(1)
|
||||
self.battleController:showCounterAttack(self.unitEntity:getCounterAttackCount(), self.side)
|
||||
end
|
||||
end
|
||||
end
|
||||
if effectType == EFFECT_TYPE.DIRECT then
|
||||
if hp > 0 and self.unitEntity:getShieldRebound() then -- 伤害反弹
|
||||
atker:takeDamageOrCure(self, num*self.unitEntity:getShieldRebound() // DEFAULT_FACTOR, EFFECT_TYPE.REBOUND, 0, BattleConst.BUFF_NAME.SHIELD_REBOUND_200)
|
||||
@ -1522,13 +1533,6 @@ function BattleUnitComp:takeDamageOrCure(atker, num, effectType, effectStatus, d
|
||||
if self.unitEntity:getThorns() > 0 then -- 反伤
|
||||
atker:takeDamageOrCure(self, num*self.unitEntity:getThorns() // DEFAULT_FACTOR, EFFECT_TYPE.REBOUND, 0, BattleConst.BUFF_NAME.THORNS)
|
||||
end
|
||||
if self.unitEntity:getCounterAttack() > 0 then -- 触发反击
|
||||
local counterattack = self.unitEntity:getCounterAttack()
|
||||
if counterattack > DEFAULT_FACTOR or BattleHelper:random(1, DEFAULT_FACTOR) <= counterattack then -- 通过命中概率
|
||||
self.unitEntity:addCounterAttackCount(1)
|
||||
self.battleController:showCounterAttack(self.unitEntity:getCounterAttackCount(), self.side)
|
||||
end
|
||||
end
|
||||
end
|
||||
elseif num > 0 then -- 治疗
|
||||
self:showEffectNumber(BattleConst.EFFECT_COLOR_GREEN, BattleConst.EFFECT_TYPE_BUFF, "+" .. num, x, y, 0)
|
||||
|
||||
@ -556,7 +556,7 @@ function BattleController:enterBattleStep()
|
||||
|
||||
local defAction = function()
|
||||
self.roundStep = BattleConst.BATTLE_ROUND_STEP.ON_DEF_STEP
|
||||
self.defTeam:mainUnitUseAllSkills(function()
|
||||
self.defTeam:mainUnitUseAllSkills(BattleConst.ATTACK_ACTION_STATE.NORMAL, function()
|
||||
self:enterNextTeamAction()
|
||||
end)
|
||||
end
|
||||
@ -1206,9 +1206,6 @@ function BattleController:generateInstructions(skillEntity, elementType, lineCou
|
||||
end
|
||||
|
||||
function BattleController:exeInstructions(callback)
|
||||
if EDITOR_MODE then
|
||||
Logger.logHighlight("--------exeInstructions----------")
|
||||
end
|
||||
if not self.instructions or #self.instructions <= 0 then
|
||||
callback()
|
||||
return
|
||||
@ -2520,11 +2517,11 @@ local function _assisting(self, instruction, callback)
|
||||
end
|
||||
|
||||
local function _generalAttack(self, instruction, callback)
|
||||
self.atkTeam:useNormalSkill(instruction.skillMatch, instruction.count, #self.instructions == 0, BattleConst.EFFECT_TYPE.DIRECT, callback)
|
||||
self.atkTeam:useNormalSkill(instruction.skillMatch, instruction.count, #self.instructions == 0, BattleConst.EFFECT_TYPE.DIRECT, BattleConst.ATTACK_ACTION_STATE.NORMAL, callback)
|
||||
end
|
||||
|
||||
local function _playSkill(self, instruction, callback)
|
||||
self.atkTeam:useSkill(instruction.skillMatch, instruction.count, #self.instructions == 0, BattleConst.EFFECT_TYPE.DIRECT, callback)
|
||||
self.atkTeam:useSkill(instruction.skillMatch, instruction.count, #self.instructions == 0, BattleConst.EFFECT_TYPE.DIRECT, BattleConst.ATTACK_ACTION_STATE.NORMAL, callback)
|
||||
end
|
||||
|
||||
BattleController._doInstruction = {
|
||||
|
||||
@ -58,7 +58,7 @@ function BattleTeam:removeAllUnits()
|
||||
self.mainUnit = nil
|
||||
end
|
||||
|
||||
function BattleTeam:useNormalSkill(matchType, count, isFinalAction, effectType, callback)
|
||||
function BattleTeam:useNormalSkill(matchType, count, isFinalAction, effectType, actionState, callback)
|
||||
self.isFinalAction = isFinalAction
|
||||
local unit = nil
|
||||
if matchType == nil then
|
||||
@ -73,12 +73,12 @@ function BattleTeam:useNormalSkill(matchType, count, isFinalAction, effectType,
|
||||
return callback()
|
||||
end
|
||||
self.mainUnit = unit
|
||||
unit:beforeAttack(effectType)
|
||||
unit:beforeAttack(actionState)
|
||||
unit:resetBeforeAttack()
|
||||
unit:useNormalSkill(count, effectType, callback)
|
||||
end
|
||||
|
||||
function BattleTeam:useSkill(matchType, count, isFinalAction, effectType, callback)
|
||||
function BattleTeam:useSkill(matchType, count, isFinalAction, effectType, actionState, callback)
|
||||
self.isFinalAction = isFinalAction
|
||||
local unit = nil
|
||||
if matchType == nil then
|
||||
@ -94,7 +94,7 @@ function BattleTeam:useSkill(matchType, count, isFinalAction, effectType, callba
|
||||
end
|
||||
local lastMainUnit = self.mainUnit
|
||||
self.mainUnit = unit
|
||||
unit:beforeAttack(effectType)
|
||||
unit:beforeAttack(actionState)
|
||||
unit:resetBeforeAttack()
|
||||
if unit:useSkill(1, count, callback) then
|
||||
if lastMainUnit and lastMainUnit ~= unit then
|
||||
@ -140,7 +140,7 @@ function BattleTeam:useAssistingSkill(assistingList, isFinalAction, callback)
|
||||
end
|
||||
end
|
||||
|
||||
function BattleTeam:mainUnitUseAllSkills(callback)
|
||||
function BattleTeam:mainUnitUseAllSkills(actionState, callback)
|
||||
self.isFinalAction = true
|
||||
if self.mainUnit == nil then
|
||||
return callback()
|
||||
@ -148,7 +148,7 @@ function BattleTeam:mainUnitUseAllSkills(callback)
|
||||
if self.mainUnit:getIsLimit() then
|
||||
return callback()
|
||||
end
|
||||
self.mainUnit:beforeAttack()
|
||||
self.mainUnit:beforeAttack(actionState)
|
||||
self.mainUnit:resetBeforeAttack()
|
||||
self.mainUnit:useAllSkills(callback)
|
||||
end
|
||||
@ -565,7 +565,7 @@ function BattleTeam:onActionOver()
|
||||
self.battleController.curTeam = self.battleController.defTeam
|
||||
end
|
||||
|
||||
self:useNormalSkill(skillMatch, counterAttackCount, true, BattleConst.EFFECT_TYPE.COUNTERATTACK, function()
|
||||
self:useNormalSkill(skillMatch, counterAttackCount, true, BattleConst.EFFECT_TYPE.DIRECT, BattleConst.ATTACK_ACTION_STATE.COUNTERATTACK, function()
|
||||
self.battleController:enterNextTeamAction()
|
||||
end)
|
||||
end
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user