设为首页收藏本站同能贴吧 切换语言 繁体中文
开启辅助访问 切换到窄版
扫描二维码关注官方公众号
返回列表
+ 发新帖
查看: 58|回复: 0

[制作教程] [VX Ace] Making DEF and MDEF work as damage resist percentage

[复制链接]
累计送礼:
0 个
累计收礼:
1 个
  • TA的每日心情
    开心
    前天 04:10
  • 签到天数: 209 天

    连续签到: 2 天

    [LV.7]常住居民III

    4456

    主题

    864

    回帖

    2万

    积分

    管理员

    Rank: 9Rank: 9Rank: 9

    VIP
    7
    卡币
    22919
    OK点
    16
    推广点
    0
    同能卷
    50
    积分
    28269

    灌水之王

    发表于 前天 07:18 | 显示全部楼层 |阅读模式
    This is going to be a rather simple, minor tutorial on how to make your DEF and MDEF stats (whatever you call them in your game) act as a percentile to damage resistance rather than a classic flat subtraction to damage dealt. Something similar to this was done in Dark Souls 2 with the elemental resistances, where each point of an elemental resistance would net 0.1% total damage resistance to that specifically, though this will actually do that to the main defensive stats in most RPG Maker games.


            Now, we're obviously going to be using the damage formulas for this, and I'd like to point out before explaining the process that this only works on skills and items that you actually use this formula on, it won't magically make every type of damage in the game treat DEF and MDEF as percentage. This also can work with any scale of stats, whether it be 1-100, 1-1000, or anything smaller or greater. All you need to do is mess with the numbers a little. Those with Yanfly's Adjust Limits script will be able to raise the cap far above that to allow for more accuracy.


            Without further rambling, here is the full formula:

                    Code:        
    1. (1000 - b.def) * a.atk / 1000
    复制代码


            Now, this looks relatively simple. I'll break down what does what. First comes...


    (1000 - b.def)


            Now, this is assuming a hard/soft cap of 1000 for the actor's DEF. If yours is lower or higher, adjust the 1000 in this section to be the cap. I use 1000 here because it allows for accuracy to the tenths and 999 is the hard cap without scripts. What this section basically does is subtracts the target of your normal attack's DEF from the cap, creating the representative number for a percentage. All you have to remember is to move the decimal one place to the left to get a 100% model. (i.e A result of 850 would mean a 15% damage resistance, since it would mean the foe DEF is 150. Moving a decimal to the left from a 150 makes it 15, or 15%. 100 - 15 = 85.) This is used in...


    * a.atk


            ...where the difference of the previous calculation is multiplied by the user's ATK stat. You may adjust this section as you see fit, either changing what stats are involved or adding more to the section. This is basically the offensive area of the formula where the damage the actor will be dealing is calculated. When editing this section, ignore all other parts of the formula. Now for the last part...


    / 1000


            This section will divide the previously multiplied actor damage by the cap that you previously set. You can make this not the cap from the beginning of the formula, but I recommend you do as that can lead to some funky results. The reason we're being so roundabout for this is that RPG Maker has a bad habit of rounding things down. I can't actually remember what my original formula for doing this was, which was simpler and should achieve the same thing, but was limited by the mathematical flaws in the engine.


            Anyways, this division by 1000 basically tones the damage back down without the rounding occurring that would screw up the calculation if we had not multiplied the damage beforehand. Now for a hypothetical!


            Let's say your actor has an ATK of 50 and the foe has a DEF of 300. What this would mean is that the actor should deal 50 base damage to the foe, but they have 30% resistance to normal attacks via the formula we are using. This would make it:


    (1000 - 300) * 50 / 1000
    1000 - 300 = 700
    700 * 50 = 35000
    35000 / 1000 = 35


            The actor's final damage is 30% of 50, or 35 damage. On normal attack, the actor will deal 35 damage flat to the foe if variation is not in play. You can also do this with MDEF in spells if you like. One little piece I enjoy adding on is a bit more complex:


    [((1000 - b.def) * a.atk / 1000), 1].max


            What the .max does is it takes the array with a the brackets I just added, then chooses the highest number of them. This makes sure that if the damage your actor would deal is below one, it will cap at 1 damage instead of saying "No Damage". This is useful if you use a soft cap instead of a hard cap, allowing characters to have over 100% resistance, but still have everyone at least deal minimum damage. Another neat thing you can do is factor in both of the foe's defensive stats by...


    (1000 - (b.def + b.mdf)) * a.atk / 1000


            ...adding their DEF and MDEF together and subtracting that from 1000! Now the attacker's ATK is defended by BOTH defensive stats. You can also...


    (10 - b.def) a.atk / 10
    (1000000 - b.def) a.atk / 1000000
    (500 - b.def) a.atk / 500


            ...change the worth of DEF and MDEF! The first formula makes each point worth 10%, the next 0.0001%, and the last one does something odd and makes each point worth 0.2%! You can change the scale/worth as much as you want. You could also do something with the damage like Dark Souls does with magic...


    (1000 - b.mdf) * (a.mtk * 1.35) / 1000


            What this does is it takes the defender's MDEF percentage resistance, calculated in the first part, and then multiplies the attacker's MATK by 1.35, giving them a bonus 35% damage for that particular spell. It then multiplies THAT by the difference of the previous part and divides it back down to a reasonable number.


            I'm currently using this little trick in my RPGVX Ace project in order to give the player a better sense of what their DEF and MDEF are worth, and let them calculate the damage they'll be doing more reliably. Of course, this is very modifiable, and you could even have something like Fallout: NV's Damage Threshold system and have a flat reduction based on either a variable or the defensive stats added onto this as well. You could, for example, mess with the beginning percentage calculation to make it pump out some gimmicky damage numbers.


            But that's about it. It's just a simple formula for something that I think at least a niche group would want. I just wanted to mimic another game's system that I liked. If you feel the need to add anything interesting to this, do reply and don't be shy.


    本贴来自国际rpgmaker官方论坛作者:Darkbeetlebot处,因国际论坛即将永久关站,为了存档多年珍贵资料,署名转载到本论坛存档,由于官方帖子为英文原帖,需要中文翻译请点击论坛顶部切换语言为中文就可以将帖子翻译成中文浏览,方便大家随时查看,原文地址:https://forums.rpgmakerweb.com/threads/vx-ace-making-def-and-mdef-work-as-damage-resist-percentage.58143/
    天天去同能,天天有童年!
    回复 送礼论坛版权

    使用道具 举报

    文明发言,和谐互动
    文明发言,和谐互动
    高级模式
    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

    简体中文
    繁體中文
    English(英语)
    日本語(日语)
    Deutsch(德语)
    Русский язык(俄语)
    بالعربية(阿拉伯语)
    Türkçe(土耳其语)
    Português(葡萄牙语)
    ภาษาไทย(泰国语)
    한어(朝鲜语/韩语)
    Français(法语)
    关闭

    幸运抽奖

    社区每日抽奖来袭,快来试试你是欧皇还是非酋~

    立即查看

    聊天机器人
    Loading...

    QQ|Archiver|手机版|小黑屋|同能RPG制作大师 ( 沪ICP备12027754号-3 )

    GMT+8, 2026-7-14 15:44 , Processed in 0.062832 second(s), 57 queries .

    Powered by Discuz! X3.4

    Copyright © 2001-2020, Tencent Cloud.

    快速回复 返回顶部 返回列表