- Joined
- Feb 25, 2016
- Messages
- 23
- Reaction score
- 3
- First Language
- English
- Primarily Uses
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:
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.
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:
(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.