RPG Maker MZ 戰鬥傷害公式

更新於 發佈於 閱讀時間約 10 分鐘

數值計算可以在 資料庫>技能>傷害>公式 那邊 滑鼠放著等它跑出幫助視窗

raw-image

把幫助視窗的內容打下來,如下:

公式

計算基本傷害的公式。
使用者以 a 表示,目標以 b 表示。
其中之一後面加一個點,以引用此後顯示的狀態。
例如,"a.atk"代表使用者的攻擊力。

攻擊
atk
防禦
def
魔法攻擊
mat
魔法防禦
mdf
敏捷度
agi
運氣
luk
最大 HP
mhp
最大 MP
mmp
HP
hp
MP
mp
TP
tp
等級
level


真的去看原生程式碼以後,發現 RM 內建的戰鬥判定過於簡單,

甚至閃避、命中、暴擊都沒有被基本數值(力量、敏捷、幸運)給影響

以下是我看 rmmz_objects 找到的內容:


敏捷 agi

影響 TPB 類型的戰鬥跑條速度 以及 回合制優先度

Game_Battler.prototype.tpbSpeed = function() {
    return Math.sqrt(this.agi) + 1;
};

Game_Action.prototype.speed = function() {
    const agi = this.subject().agi;
    let speed = agi + Math.randomInt(Math.floor(5 + agi / 4));
    if (this.item()) {
        speed += this.item().speed;
    }
    if (this.isAttack()) {
        speed += this.subject().attackSpeed();
    }
    return speed;
};


幸運 luk

影響上/被上狀態的成功率

Game_Action.prototype.itemEffectAddAttackState = function(target, effect) {
    for (const stateId of this.subject().attackStates()) {
        let chance = effect.value1;
        chance *= target.stateRate(stateId);
        chance *= this.subject().attackStatesRate(stateId);
        chance *= this.lukEffectRate(target);
        if (Math.random() < chance) {
            target.addState(stateId);
            this.makeSuccess(target);
        }
    }
};

Game_Action.prototype.itemEffectAddNormalState = function(target, effect) {
    let chance = effect.value1;
    if (!this.isCertainHit()) {
        chance *= target.stateRate(effect.dataId);
        chance *= this.lukEffectRate(target);
    }

    if (Math.random() < chance) {
        target.addState(effect.dataId);
        this.makeSuccess(target);
    }
};

Game_Action.prototype.itemEffectAddDebuff = function(target, effect) {
    let chance = target.debuffRate(effect.dataId) * this.lukEffectRate(target);
    if (Math.random() < chance) {
        target.addDebuff(effect.dataId, effect.value1);
        this.makeSuccess(target);
    }
};

Game_Action.prototype.lukEffectRate = function(target) {
    return Math.max(1.0 + (this.subject().luk - target.luk) * 0.001, 0.0);
};


閃避率 eva

當系統產的隨機數 < 目標的閃避率 時 閃避成功

Game_Action.prototype.apply = function(target) {
    const result = target.result();
    this.subject().clearResult();
    result.clear();
    result.used = this.testApply(target);
    result.missed = result.used && Math.random() >= this.itemHit(target);
    result.evaded = !result.missed && Math.random() < this.itemEva(target);
    result.physical = this.isPhysical();
    result.drain = this.isDrain();
    if (result.isHit()) {
        if (this.item().damage.type > 0) {
            result.critical = Math.random() < this.itemCri(target);
            const value = this.makeDamageValue(target, result.critical);
            this.executeDamage(target, value);
        }
        for (const effect of this.item().effects) {
            this.applyItemEffect(target, effect);
        }
        this.applyItemUserEffect(target);
    }
    this.updateLastTarget(target);
};


命中率 hit

物理攻擊的命中率:成功率的百分比 乘上 使用者的命中率

非物理攻擊的命中率:成功率的百分比

命中率可以在 資料庫>敵軍(或 角色/職業)>特性>能力值>追加能力值 看到

成功率可以在 資料庫>技能 看到

Game_Action.prototype.itemHit = function(/*target*/) {
    const successRate = this.item().successRate;
    if (this.isPhysical()) {
        return successRate * 0.01 * this.subject().hit;
    } else {
        return successRate * 0.01;
    }
};


暴擊率 cri

攻擊者的暴擊率 乘上(1-受擊者的暴擊迴避率)

暴擊迴避率可以在 資料庫>敵軍(或 角色/職業)>特性>能力值>追加能力值 看到

Game_Action.prototype.itemCri = function(target) {
    return this.item().damage.critical
        ? this.subject().cri * (1 - target.cev)
        : 0;
};


暴擊傷害

固定為傷害 乘上 3

Game_Action.prototype.applyCritical = function(damage) {

    return damage * 3;

};


難怪會有那麼多擴充戰鬥系統的插件,

因為想讓戰鬥變得更有系統性的話,真的是要再找插件。

avatar-img
8會員
11內容數
BL萬歲!犬貓萬歲!RM萬歲! 也可以在這裡找到我🌿 https://linktr.ee/12atan
留言
avatar-img
留言分享你的想法!
補充一下國外論壇的說明 https://forums.rpgmakerweb.com/index.php?threads/damage-formulas-101.81905/
12atan-avatar-img
1
12atan 的其他內容
分享下最近製作 RM 上用到的一些 MZ 事件腳本 // 設定此事件的自開關 A 為 OFF $gameSelfSwitches.setValue('A', false) // 設定第 1 個地圖的第 3 個事件的自開關 A 為 OFF $gameSelfSwitches.setValue([1
分享下最近製作 RM 上用到的一些 MZ 事件腳本 // 設定此事件的自開關 A 為 OFF $gameSelfSwitches.setValue('A', false) // 設定第 1 個地圖的第 3 個事件的自開關 A 為 OFF $gameSelfSwitches.setValue([1
你可能也想看
Google News 追蹤
Thumbnail
該來的終究還是來了 度過焦躁不安的一整周,學徒老人家我的不安感等比級數的襲來,自3/19寫了第一篇關於<巴克萊銀行:倉促撤退>的報告,看到市場上的機構法人有如大洪水、地震來臨前夕開始竄逃撤退。 海湖莊園協議 接著,在3/31與4/2兩天接著寫了川普與他的財經團隊在海湖莊園豪
Thumbnail
空單爆天量、技術指標超賣、情緒恐慌到極致:美股嘎空行情有機會啟動嗎? 重點摘要: 技術面極度超賣,反彈條件醞釀中,但尚未明確止穩 SPY 與 QQQ 的重要指標,如MACD、KDJ、RSI等指標進入極端超賣區,但尚未出現底部鈍化或明確反轉訊號,技術面仍屬空方主導。 連續出現跳空缺口,空方動
Thumbnail
全新 vocus 挑戰活動「方格人氣王」來啦~四大挑戰任你選,留言 / 愛心 / 瀏覽數大 PK,還有新手專屬挑戰!無論你是 vocus 上活躍創作者或剛加入的新手,都有機會被更多人看見,獲得站上版位曝光&豐富獎勵!🏆
Thumbnail
這是個自己學習的紀錄,可能會有點枯燥,但忘了時能夠當作查詢資料用:)
Thumbnail
編輯的基本功,是對文字的敏感度。
Thumbnail
該來的終究還是來了 度過焦躁不安的一整周,學徒老人家我的不安感等比級數的襲來,自3/19寫了第一篇關於<巴克萊銀行:倉促撤退>的報告,看到市場上的機構法人有如大洪水、地震來臨前夕開始竄逃撤退。 海湖莊園協議 接著,在3/31與4/2兩天接著寫了川普與他的財經團隊在海湖莊園豪
Thumbnail
空單爆天量、技術指標超賣、情緒恐慌到極致:美股嘎空行情有機會啟動嗎? 重點摘要: 技術面極度超賣,反彈條件醞釀中,但尚未明確止穩 SPY 與 QQQ 的重要指標,如MACD、KDJ、RSI等指標進入極端超賣區,但尚未出現底部鈍化或明確反轉訊號,技術面仍屬空方主導。 連續出現跳空缺口,空方動
Thumbnail
全新 vocus 挑戰活動「方格人氣王」來啦~四大挑戰任你選,留言 / 愛心 / 瀏覽數大 PK,還有新手專屬挑戰!無論你是 vocus 上活躍創作者或剛加入的新手,都有機會被更多人看見,獲得站上版位曝光&豐富獎勵!🏆
Thumbnail
這是個自己學習的紀錄,可能會有點枯燥,但忘了時能夠當作查詢資料用:)
Thumbnail
編輯的基本功,是對文字的敏感度。