Solar_Flare

Veteran
Veteran
Joined
Jun 6, 2020
Messages
650
Reaction score
264
First Language
English
Primarily Uses
RMMV
Code:
Math.min(5, your formula here)
 

Solar_Flare

Veteran
Veteran
Joined
Jun 6, 2020
Messages
650
Reaction score
264
First Language
English
Primarily Uses
RMMV
Math.min will work in MZ, at least. It's part of core JavaScript.
 

MerlinCross

Veteran
Veteran
Joined
Jun 8, 2015
Messages
226
Reaction score
95
First Language
English
Primarily Uses
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?
 

MetalKing11417

Veteran
Veteran
Joined
Jul 7, 2018
Messages
129
Reaction score
85
First Language
english
Primarily Uses
RMMV
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?
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

Veteran
Veteran
Joined
Jun 8, 2015
Messages
226
Reaction score
95
First Language
English
Primarily Uses
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.
I'm talking about this.

Guard Skill
Formula: a.setTp(a.tp / 2)

This should cut TP in half. What happens when it's left over as a Decimal? Well I don't know what the fix is but would like to as I get this. Not sure what would happen if I tried it for HP as well.
2020_10_16_22_49_58_684_4775.png
 

Soulrender

Jack Of All Trades
Veteran
Joined
Jan 12, 2019
Messages
1,243
Reaction score
719
First Language
Poland
Primarily Uses
RMMV
@MerlinCross
Math.floor( a.setTp(a.tp / 2) ) but preferable way is

Math.floor( a.setTp(a.tp * 0.5) )
 

MerlinCross

Veteran
Veteran
Joined
Jun 8, 2015
Messages
226
Reaction score
95
First Language
English
Primarily Uses
@MerlinCross
Math.floor( a.setTp(a.tp / 2) ) but preferable way is

Math.floor( a.setTp(a.tp * 0.5) )

No that still doesn't seem to work. And it's not a plugin problem before people suggest that, I'm trying this with an empty new project.
 

Soulrender

Jack Of All Trades
Veteran
Joined
Jan 12, 2019
Messages
1,243
Reaction score
719
First Language
Poland
Primarily Uses
RMMV
Aaahhh now I see where is error:

a.gainTp(Math.floor( a.maxTp()*0.5) )
 

MerlinCross

Veteran
Veteran
Joined
Jun 8, 2015
Messages
226
Reaction score
95
First Language
English
Primarily Uses
Aaahhh now I see where is error:

a.gainTp(Math.floor( a.maxTp()*0.5) )

And now I just gain a flat 50.

I'm just gonna deal with Decimal being there for this little demo idea thing. Hopefully shouldn't break the game.
 

Solar_Flare

Veteran
Veteran
Joined
Jun 6, 2020
Messages
650
Reaction score
264
First Language
English
Primarily Uses
RMMV
Try a.setTp(Math.floor(a.tp / 2)), or maybe a.gainTp(-Math.floor(a.tp / 2)).
 

Titanor

Veteran
Veteran
Joined
Jul 22, 2013
Messages
39
Reaction score
5
First Language
english
Primarily Uses
N/A
ok so I have done something wrong with my formula and I have no idea what,
my formula is (a.atk * 4 * (Math.floor (Math.random() * v[20] ) + 1)) - (b.def * 2),
but I know for a fact it is not working because on the test enemy it is giving a solid 50 to 60 each time with actor attack being 18 and enemy defense 25 with the dice variable (v[20]) being at 48, now it should be randomized with the maths between 22 and 3406 but it is not, does anyone know what is going on here.

ps. the dice variable is controlled by a custom armor slot with different types of dice and in this example, I am using a pair of 24 sided dice and I know that function works.

edit. ok, I am an idiot, I did not realize there was an error in my code the several times I looked at it. :hswt2:
 
Last edited:

Andyest

Villager
Member
Joined
Jul 7, 2020
Messages
15
Reaction score
0
First Language
Portuguese
Primarily Uses
RMMV
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).

I will give a little simplified explanation, but...

Being "i" the weapon ('cause you can use 2):

JavaScript:
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
        };
    };

Hope it helps someone.
 

Frostorm

[]D[][]V[][]D aka "Staf00"
Veteran
Joined
Feb 22, 2016
Messages
2,033
Reaction score
1,709
First Language
English
Primarily Uses
RMMV
Are there any good programs/tools for visualizing a 3 variable function? (i.e. ATK, AGI, & LVL)
 

Frostorm

[]D[][]V[][]D aka "Staf00"
Veteran
Joined
Feb 22, 2016
Messages
2,033
Reaction score
1,709
First Language
English
Primarily Uses
RMMV
So I've been thinking about changing my base damage formula that I would base most physical skills on. I currently use this simple formula: (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
What are your guys' thoughts on these potential formulas? Should I stick w/ what I'm currently using or switch to one of these? I'm kind of leaning towards the formula in the last bullet point. Keep in mind, I can wrap the entire formula in parenthesis to add a coefficient to scale for various skills.

Edit: Maybe this one?
Math.cbrt(a.atk ** 2 * a.agi) + (a.atk + a.agi / 2)

Here's what I want from my formulas...
  • ATK & AGI synergy (i.e. greater effect if both ATK/AGI are high)
  • ATK should contribute the majority of dmg, AGI a minor boost
  • Bonus if we can get a Sigmoid function going lol
Update: Ok, I finally settled on a formula... (a.atk * a.agi) / (a.atk + a.level) + a.atk
It checks all the boxes for me, making sure that Strength contributes more damage than Dexterity while also including an instance of a.atk*a.agi somewhere for some synergistic oomph.
 
Last edited:

Solar_Flare

Veteran
Veteran
Joined
Jun 6, 2020
Messages
650
Reaction score
264
First Language
English
Primarily Uses
RMMV
  • 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)
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 ^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 write Math.pow(a.atk, 2) or a.atk ** 2.
 

Frostorm

[]D[][]V[][]D aka "Staf00"
Veteran
Joined
Feb 22, 2016
Messages
2,033
Reaction score
1,709
First Language
English
Primarily Uses
RMMV
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 ^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 write 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 as 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.
 

Gorgutz777

Warper
Member
Joined
Dec 22, 2016
Messages
2
Reaction score
1
First Language
Spanish
Primarily Uses
Until now, one of the damage formulas I've been using is something like this:
a.atk * 1 * (a.isStateAffected(10) ? 2 : 1)
so as long as the character is affected by that state, the skill will double its damage. Now I've been wondering if there is a way to make a damage formula that checks for multiple states instead of one. Basically, what i'm trying to figure it out is one of the following (or both if possible).

1) Check if the character/target has one of two possible state, and if it does, then increase damage. For example, if a character is afflicted with poison OR blind then the skill does double damage (not stacking)

2) Similar to the previous one, but in this case, the damage will be boosted for each state. For example, if the character is afflicted with poison, increase the damage +20% (or whatever value). Then, if it's also affected by blind, increase another 20%. If it's also affected by silence, another 20% and... etc.
 

Frostorm

[]D[][]V[][]D aka "Staf00"
Veteran
Joined
Feb 22, 2016
Messages
2,033
Reaction score
1,709
First Language
English
Primarily Uses
RMMV
It would look something like this:
a.atk * 1 * (a.isStateAffected(10) || a.isStateAffected(11) ? 2 : 1)
 

Latest Threads

Latest Posts

Latest Profile Posts

To be released 2021/10/21
Now that I made this "What the MZ RTP is missing" spreadsheet it's itching me to fill some the gaps D:
Aaaaand I completely forgot about the RMMV Chicken Rave my brother decided to implement in a parody of my VERY FIRST UNFINISHED project. We could not escape the chicken rave... The chickens would block the ladder...
I love how I can look up a problem I'm having with my game, find a post from like six years ago that addresses the issue, and the solution provided still works in RPG Maker.
It's times like those that my life feels really easy XD
Change costumes with equipment!

Forum statistics

Threads
115,949
Messages
1,094,262
Members
151,205
Latest member
Vertette
Top