魔力宝贝cgmsv
有没有大佬知道如何修改必杀伤害呀? 没玩过,帮顶一下 本帖最后由 epyanlove 于 2026-2-10 23:24 编辑前提是你要看懂写的这些 否则洗洗睡吧
docs.lua里面找到的
---修改暴击时伤害计算
-----@param mode number|boolean 取值: 0 = 普通模式 1 = 倍率模式 2 = 无 true = 普通模式 false = 无
-----@param val number 倍率,默认1.5倍
function NLG.SetCriticalDamageAddition(mode, val) end
或者自己去写个脚本 内容如下
---模块类
local CriticalMod = ModuleBase:createModule('criticalMod')
local comboCount = {}
local comboCriticalDamage = {}
local retributionSide = {}
local retributionRate = {}
local randomshotCount = {}
local randomshotDamage = {0.45,0.30,0.15,0.05}
local billiardDefender = {}
local guardRate1 = {0, 0.1, 0.2, 0.3, 0.4, 0.5}
local guardProb1 = {25, 50, 70, 85, 95, 100}
local guardRate2 = {0, 0.2, 0.3, 0.4, 0.5}
local guardProb2 = {5, 20, 40, 70, 100}
local function Conver_240(num)
if num >= 240 then
num = math.floor((num - 240 ) * 0.3 + 240)
end
return num
end
local function randomRate(rate, prob)
local randNum = NLG.Rand(1, 100)
for i = 1, #rate do
if prob >= randNum then
return rate
end
end
end
local function getWeaponType(playerIndex)
for itemSlot = 2, 3 do
local itemIndex = Char.GetItemIndex(playerIndex, itemSlot)
if itemIndex < 0 then
goto continue
end
local itemType = Item.GetData(itemIndex, CONST.道具_类型)
if itemType <= CONST.ITEM_TYPE_回力镖 then
return itemType
end
:: continue ::
end
end
function CriticalMod:afterBattleTurnEvent(battleIndex)
for slot = 0, 19 do
local charIndex = Battle.GetPlayer(battleIndex, slot)
billiardDefender = nil
randomshotCount = nil
end
end
function CriticalMod:criticalDamageCalculateEvent(charIndex, defCharIndex, oriDamage, damage, battleIndex, com1, com2, com3, defCom1, defCom2, defCom3, flg)
--print('battleIndex', battleIndex)
--如果是合击则记录合击人数
if flg == CONST.DamageFlags.Combo or flg == CONST.DamageFlags.ComboCritical then
comboCount = comboCount and (comboCount + 1) or 1
--print('comboCount', comboCount)
end
--如果是因果则记录第一个防守方side
if com1 == CONST.BATTLE_COM.BATTLE_COM_RETRIBUTION then
retributionSide = retributionSide or math.floor((Battle.GetPos(battleIndex, defCharIndex) / 10))
--print('retributionSide', retributionSide)
end
--如果是一石二鸟则记录前排
if com1 == CONST.BATTLE_COM.BATTLE_COM_BILLIARD then
billiardDefender = billiardDefender or defCharIndex
--print('billiardDefender', billiardDefender)
end
--如果是乱射则记录防守方所受箭数
if com1 == CONST.BATTLE_COM.BATTLE_COM_P_RANDOMSHOT then
randomshotCount = randomshotCount or {}
randomshotCount = randomshotCount and (randomshotCount + 1) or 1
--print('randomshotCount', charIndex, defCharIndex, randomshotCount)
end
--如果不是必杀或伤害很低则返回原值
if damage <= 0 or (flg ~= CONST.DamageFlags.Critical and flg ~= CONST.DamageFlags.ComboCritical) then
--print('不是必杀或无伤害')
return damage
end
if damage <= 1 then
--print('伤害很低')
return 1
end
--如果是合击最后一击,合并合击伤害
if not Char.GetTempData(charIndex, 'haveCritical') then
local comboFinalCritical = math.floor(comboCriticalDamage * (1 + comboCount / 10))
--print('合击最后一击', comboCriticalDamage, comboCount, comboDamage)
--之前的合击伤害记录清除
comboCriticalDamage = nil
comboCount = nil
return damage + comboFinalCritical
end
--必杀时额外补充原版必杀的一半伤害
local attackLevel = Char.GetData(charIndex, CONST.对象_等级)
local defLevel = Char.GetData(defCharIndex, CONST.对象_等级)
local defDefense = Char.GetData(defCharIndex, CONST.对象_防御力)
local modDefDefense = Conver_240(defDefense)
local criticalDamage = math.floor(modDefDefense * attackLevel / defLevel / 4)
local techDD = Battle.GetTechOption(charIndex, "DD:")
--print('techDD', techDD)
--如果是反击(未考虑阳炎反击,因为觉得是bug)
if Char.GetTempData(charIndex, 'haveCounter') then
--反击rate
local counterRate = com1 == CONST.BATTLE_COM.BATTLE_COM_P_CROSSCOUNTER and ((techDD + 100) / 100) or 0.75
--print('反击rate', damage, criticalDamage, counterRate, math.floor(damage + criticalDamage * counterRate))
Char.SetTempData(charIndex, 'haveCounter', nil)
return math.floor(damage + criticalDamage * counterRate)
end
--技能倍率rate(气功弹及追月数量修正暂未考虑,因为无法获取发出弹数量)
local techRate = 1
--气功弹或者追月rate
if com1 == CONST.BATTLE_COM.BATTLE_COM_P_SPIRACLESHOT or com1 == CONST.BATTLE_COM.BATTLE_COM_BLASTWAVE then
techRate = math.min(1, techDD / 100)
--print('气功弹或者追月rate', techRate)
--崩击rate
elseif (defCom1 == CONST.BATTLE_COM.BATTLE_COM_GUARD or defCom1 == CONST.BATTLE_COM.BATTLE_COM_P_SPECIALGARD) and com1 == CONST.BATTLE_COM.BATTLE_COM_P_GUARDBREAK then
techRate = (1 + techDD / 100) * (1 + techDD / 100)
--print('崩击rate', techRate)
--因果报应rate
elseif com1 == CONST.BATTLE_COM.BATTLE_COM_RETRIBUTION then
local techIndex = Tech.GetTechIndex(com3)
local techLv = Tech.GetData(techIndex, CONST.TECH_NECESSARYLV)
retributionRate = retributionRate or (0.55 * techDD + 100) / 100 * NLG.Rand((4000 - 180 * (10 - techLv)), 6999) / 10000
techRate = retributionRate
--print('因果报应rate', techRate)
if charIndex == defCharIndex or retributionSide ~= math.floor((Battle.GetPos(battleIndex, defCharIndex) / 10)) then
techRate = techRate * Battle.GetTechOption(charIndex, "AR:") / 100
--print('因果报应自伤rate', techRate)
retributionSide = nil
retributionRate = nil
end
--一石二鸟后排rate
elseif com1 == CONST.BATTLE_COM.BATTLE_COM_BILLIARD and billiardDefender ~= defCharIndex then
techRate = Battle.GetTechOption(charIndex, "SR:") / 100
--print('一石二鸟后排rate', techRate)
--乱射rate
elseif com1 == CONST.BATTLE_COM.BATTLE_COM_P_RANDOMSHOT then
techRate = randomshotDamage, 4)]
--print('乱射rate', techRate)
--其他情况rate
else
local techOption = Tech.GetData(Tech.GetTechIndex(com3), CONST.TECH_OPTION)
techDD = type(techOption) == 'string' and string.find(techOption, 'DD:') and techDD or (techDD + 1)
techRate = (techDD + 100) / 100
--print('其他情况rate', techRate)
end
--武器rate
local weaponRate = 1
local weaponType = getWeaponType(charIndex)
--小刀rate
if weaponType == CONST.ITEM_TYPE_小刀 then
weaponRate = NLG.Rand(5, 8) * 0.1
--回力rate,因果无视(此处暂有问题,因为无法获取普攻回力倍率,因此普攻的回力倍率和额外必杀的回力倍率未必一致)
elseif weaponType == CONST.ITEM_TYPE_回力镖 and com1 ~= CONST.BATTLE_COM.BATTLE_COM_RETRIBUTION then
weaponRate = NLG.Rand(1, 6) * 0.1
end
--print('武器rate', weaponRate)
--多动rate
local multipleActionRate = 1
for itemSlot = 0, 7 do
local itemIndex = Char.GetItemIndex(charIndex, itemSlot)
if itemIndex < 0 or Item.GetData(itemIndex, CONST.道具_最小攻击数量) <= 1 or Item.GetData(itemIndex, CONST.道具_最大攻击数量) <= 1 then
goto continue
end
multipleActionRate = 1 / math.max(Item.GetData(itemIndex, CONST.道具_最小攻击数量), Item.GetData(itemIndex, CONST.道具_最大攻击数量))
:: continue ::
end
--print('多动rate', multipleActionRate)
--防御rate
local guardRate = 1
if defCom1 == CONST.BATTLE_COM.BATTLE_COM_GUARD and com1 ~= CONST.BATTLE_COM.BATTLE_COM_P_GUARDBREAK and Char.GetData(defCharIndex, CONST.对象_类型) == CONST.对象类型_人 and Char.GetData(defCharIndex, CONST.对象_战宠) < 0 then
guardRate = randomRate(guardRate1, guardProb1)
elseif defCom1 == CONST.BATTLE_COM.BATTLE_COM_GUARD and com1 ~= CONST.BATTLE_COM.BATTLE_COM_P_GUARDBREAK then
guardRate = randomRate(guardRate2, guardProb2)
end
--print('防御rate', guardRate)
--圣盾rate
local specialguardRate = 1
if defCom1 == CONST.BATTLE_COM.BATTLE_COM_P_SPECIALGARD and com1 ~= CONST.BATTLE_COM.BATTLE_COM_P_GUARDBREAK then
specialguardRate = 1 - NLG.Rand(Battle.GetTechOption(defCharIndex, "RS:"), Battle.GetTechOption(defCharIndex, "RE:")) / 100
end
--print('圣盾rate', specialguardRate)
--必杀伤害总修正(未考虑精灵变身倍率及制御巫术伤害倍率)
local modCriticalDamage = math.floor(criticalDamage * weaponRate * multipleActionRate * techRate * guardRate * specialguardRate)
--print('必杀伤害总修正', criticalDamage, modCriticalDamage)
--清除必杀标记,以便可以找到合击最后一击
if (flg == CONST.DamageFlags.Critical and Char.GetTempData(charIndex, 'haveCritical')) or flg == CONST.DamageFlags.ComboCritical then
Char.SetTempData(charIndex, 'haveCritical', nil)
end
--如果是合击必杀则记录本次必杀伤害,最后一击时再合并计算
if flg == CONST.DamageFlags.ComboCritical then
comboCriticalDamage = comboCriticalDamage and (comboCriticalDamage + modCriticalDamage) or modCriticalDamage
--print('记录本次必杀伤害', damage, modCriticalDamage, comboCriticalDamage)
return damage
end
--print('最终伤害', damage, modCriticalDamage, damage + modCriticalDamage)
return damage + modCriticalDamage
end
function CriticalMod:battleCounterRateEvent(battleIndex, attIndex, defIndex, rate)
Char.SetTempData(attIndex, 'haveCounter', defIndex)
end
function CriticalMod:calcCriticalRateEvent(attIndex, defIndex, rate)
Char.SetTempData(attIndex, 'haveCritical', defIndex)
end
--- 加载模块钩子
function CriticalMod:onLoad()
self:logInfo('load')
self:regCallback('DamageCalculateEvent', Func.bind(self.criticalDamageCalculateEvent, self))
self:regCallback('AfterBattleTurnEvent', Func.bind(self.afterBattleTurnEvent, self))
self:regCallback('BattleCounterRateEvent', Func.bind(self.battleCounterRateEvent, self))
self:regCallback('CalcCriticalRateEvent', Func.bind(self.calcCriticalRateEvent, self))
end
--- 卸载模块钩子
function CriticalMod:onUnload()
self:logInfo('unload')
end
return CriticalMod
页:
[1]