- Joined
- Jun 6, 2020
- Messages
- 650
- Reaction score
- 264
- First Language
- English
- Primarily Uses
- RMMV
Code:
Math.min(5, your formula here)
Math.min(5, your formula here)
I was talking about everything in generalMath.min will work in MZ, at least. It's part of core JavaScript.
Are you talking about within the formula or once the formula has ended? Because after the formula is finished, the system automatically rounds the result, because items like HP and TP only accept integers.How would I avoid getting a Decimal in my numbers?
Example; I have a skill that cuts TP in half. But it will leave me with say .5 at times. So
a.setTp(a.tp / 2)
Used at 5 TP will make the user's TP, 2.5. I'd like to avoid that but how?
I'm talking about this.Are you talking about within the formula or once the formula has ended? Because after the formula is finished, the system automatically rounds the result, because items like HP and TP only accept integers.
@MerlinCross
Math.floor( a.setTp(a.tp / 2) ) but preferable way is
Math.floor( a.setTp(a.tp * 0.5) )
Aaahhh now I see where is error:
a.gainTp(Math.floor( a.maxTp()*0.5) )
a.setTp(Math.floor(a.tp / 2))
, or maybe a.gainTp(-Math.floor(a.tp / 2))
.I was wondering how I could get a weapon that completely ignores the user's physical/magical attack stat when dealing damage (like a gun for instance), as well as a skill that lets the user deal damage while ignoring the enemy's physical/magical defense (think Luna Λ from Fire Emblem: Three Houses).
for (j=0; j<a.weapons()[i].traits.length; j++){
if (a.weapons()[i].traits[j].code == 31){
if (a.weapons()[i].traits[j].dataId == 1){ /*DO THINGS HERE */ }; //Element Physical
if (a.weapons()[i].traits[j].dataId == 2){ /*DO THINGS HERE */ }; //Element Earth
if (a.weapons()[i].traits[j].dataId == 3){ /*DO THINGS HERE */ }; //Element Ranged
};
};
(a.atk + a.atk + a.agi) * n
where "n" would be a coefficient that varies depending on the skill in question (e.g. normal attack might use n = 0.5). Oh, and these formulas won't contain any defensive modifiers since mitigation will be handle by Yanfly's ArmorScaling plugin. Anyway, my goal overall is to create a formula that is mostly affected by ATK but also minorly/secondarily affected by AGI. So here's a couple I'm considering:a.atk ** 2 / a.level + a.agi
a.atk * a.agi / a.level + a.atk
Math.sqrt(a.atk * a.agi) + a.atk
Math.cbrt(a.atk ** 2 * a.agi)
Math.cbrt(a.atk ** 2 * a.agi) + a.level
Math.cbrt(a.atk ** 2 * a.agi) + a.atk
a.atk * (a.atk + a.agi) / a.level
Math.cbrt(a.atk ** 2 * a.agi) + (a.atk + a.agi / 2)
(a.atk * a.agi) / (a.atk + a.level) + a.atk
a.atk*a.agi
somewhere for some synergistic oomph.I realize you didn't end up going with any of these formulas, but in case someone else sees this, I feel I have to point out that they don't do what you probably think they do. The error you seem to have made is that
a.atk^2 / a.level + a.agi
Math.cbrt(a.atk^2 * a.agi)
Math.cbrt(a.atk^2 * a.agi) + a.level
Math.cbrt(a.atk^2 * a.agi) + a.atk
Edit: Maybe this one?Math.cbrt(a.atk^2 * a.agi) + (a.atk + a.agi / 2)
^2
does not means "squared". It is valid JavaScript, but what it means is probably not useful for damage calculations (it performs what's called a "bitwise xor" of the attack value with the value 2).Math.pow(a.atk, 2)
or a.atk ** 2
.Yea I was writing that in mathematical/Excel notation, not javascript. Trust me, I didn't copy-paste that into the formula box lol. I just had Excel open w/ all the potential formulas I was considering, so I used that (then I just tacked on "Math."). In my database, it shows asI realize you didn't end up going with any of these formulas, but in case someone else sees this, I feel I have to point out that they don't do what you probably think they do. The error you seem to have made is that^2
does not means "squared". It is valid JavaScript, but what it means is probably not useful for damage calculations (it performs what's called a "bitwise xor" of the attack value with the value 2).
If you want to square the attack value, you need to writeMath.pow(a.atk, 2)
ora.atk ** 2
.
a.atk ** (1 + a.agi / 1000)
. I assumed people were smart enough to tell the difference lol. I fixed it in case someone came along and tried to copy-paste.