c1_lua/lua/app/module/battle/helper/battle_formula.lua

61 lines
3.5 KiB
Lua
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

local BattleHelper = require "app/module/battle/helper/battle_helper"
local BattleConst = require "app/module/battle/battle_const"
local BattleFormula = {}
local DEFAULT_FACTOR = 10000
local HURT_STATE_CRIT = BattleConst.HURT_STATE_CRIT
function BattleFormula:getDamageOrCureResult(unitComp, buff, targetUnitComp)
local func = self.calculateFormula[buff:getFormula()]
if func then
return func(unitComp, buff, targetUnitComp)
end
return 0
end
BattleFormula.calculateFormula = {
-- (攻击)*技能倍率*(1+(攻击者元素伤害增加+所有伤害增加)(攻击者)- (攻击者元素伤害降低+所有伤害降低) +(受到元素伤害增加+受到所有伤害增加(受击)-受到元素伤害降低-受到所有伤害降低(受击) + 主动技能增伤)*暴击伤害*(1-最终造成伤害降低%+最终造成伤害增加%)
[1] = function(unitComp, buff, targetUnit)
local skillHurtAdd = 0
local hostSkill = buff:getHostSkill()
if hostSkill and hostSkill:getIsActiveType() and unitComp.unitEntity:getSkillHurt() > 0 then -- 是主动技能携带的buff且拥有技能伤害加成
skillHurtAdd = unitComp.unitEntity:getSkillHurt()
end
local matchType = unitComp.unitEntity:getMatchType()
local result = unitComp.unitEntity:getAtk() * buff:getEffectNum() // DEFAULT_FACTOR *
(DEFAULT_FACTOR + unitComp.unitEntity:getDmgAddition() - unitComp.unitEntity:getDmgDec() + targetUnit.unitEntity:getWeakness(matchType) - targetUnit.unitEntity:getDecDmg(matchType) + skillHurtAdd) // DEFAULT_FACTOR
local hurtState = 0
local crit = unitComp.unitEntity:getCrit()
if crit > 0 then
if BattleHelper:random(1, DEFAULT_FACTOR) <= crit then -- 暴击了
result = result * (BattleHelper:getDefaultCrittime() + unitComp.unitEntity:getCrittime()) // DEFAULT_FACTOR
hurtState = HURT_STATE_CRIT
end
end
-- 最终伤害
result = result * (DEFAULT_FACTOR - unitComp.unitEntity:getEndDmgDecAll() + unitComp.unitEntity:getEndDmgAddtionAll()) // DEFAULT_FACTOR
return result, hurtState
end,
-- 生命值*回合开始时的回血系数*(1 + 治疗效果增加)
[2] = function(unitComp, buff, targetUnit)
local result = targetUnit.unitEntity:getMaxHp() * buff:getEffectNum() // DEFAULT_FACTOR * (unitComp.unitEntity:getCureAddition() - unitComp.unitEntity:getCureDec() + DEFAULT_FACTOR) // DEFAULT_FACTOR
return result, 0
end,
-- 角色攻击力*技能倍率*(1+治疗效果增加)
[3] = function(unitComp, buff, targetUnit)
local result = unitComp.unitEntity:getAtk() * buff:getEffectNum() // DEFAULT_FACTOR * (unitComp.unitEntity:getCureAddition() - unitComp.unitEntity:getCureDec() + DEFAULT_FACTOR) // DEFAULT_FACTOR
return result, 0
end,
-- 释放者攻击*技能系数*(1+(攻击者元素伤害增加+所有伤害增加-攻击者元素伤害降低-所有伤害降低+受到元素伤害增加+受到所有伤害增加(受击)-受到元素伤害降低-受到所有伤害降低(受击))
[4] = function(unitComp, buff, targetUnit)
local matchType = unitComp.unitEntity:getMatchType()
local result = unitComp.unitEntity:getAtk() * buff:getEffectNum() // DEFAULT_FACTOR *
(DEFAULT_FACTOR + unitComp.unitEntity:getDmgAddition() - unitComp.unitEntity:getDmgDec() + targetUnit.unitEntity:getWeakness(matchType) - targetUnit.unitEntity:getDecDmg(matchType)) // DEFAULT_FACTOR
-- 最终伤害
result = result * (DEFAULT_FACTOR - unitComp.unitEntity:getEndDmgDecAll() + unitComp.unitEntity:getEndDmgAddtionAll()) // DEFAULT_FACTOR
return result, 0
end,
}
return BattleFormula