Possibility Of Fixed Damage In RPG Maker MV Damage Formula

Ultimecio777

"I Used RPG Maker 2 (PS2) And Liked It..."
Member
Joined
Aug 30, 2020
Messages
6
Reaction score
2
First Language
English
Primarily Uses
RMMV
Hello. I am trying to work on multiple skills that would inflict fixed damage using || (or) in the formula. For example:

"Skill name" always does fixed damage, but will inflict either 100 DMG, 500 DMG, 1000 DMG, Or 2000 DMG. The formula looks like this:

100 || 500 || 1000 || 2000

Is there a way that I can do this without using || in the formula, since || belongs in a statement, rather than a function? Any feedback is much appreciated.

Edit: I'm sorry about my capitalization. I fixed it so that it would be easier to read and because I felt bad.
 
Last edited:

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
31,813
Reaction score
7,885
First Language
German
Primarily Uses
RMMV
Please don't capitalize every word - it is irritating to read and additionally reminds of a long-banned user that had the same habit and was extremely bad-mannered.

the damage formula is basically a javascript eval line, so it can do everything that can be programmed.
one way to handle this is to use a temp variable to store a random number 0-3 and then process this in a series of if-else, but that would be difficult to read.

I almost had it - unfortunately the 100 does not fit.
500*(2^rnd(2)) would give either 500, 1000 or 2000

Perheps someone else can get a formula that will get the last number without if-else
 

caethyril

^_^
Veteran
Joined
Feb 21, 2018
Messages
2,227
Reaction score
1,634
First Language
EN
Primarily Uses
RMMZ
"Skill name" always does fixed damage, but will inflict either 100 DMG, 500 DMG, 1000 DMG, Or 2000 DMG. The formula looks like this:

100 || 500 || 1000 || 2000
Note that this formula will always return 100. || is a logical OR with short-circuiting, i.e. it will stop as soon as it reaches a truthy value (e.g. any non-zero number). More details here, in case you're interested:

I'd suggest this sort of formula instead:
JavaScript:
var r = [100, 500, 1000, 2000]; r[Math.randomInt(r.length)]
This establishes a temporary list of possible values, then randomly selects one of those as the result. (It's kind of like a compact if-else.) I've written it in a way that allows you to easily add, remove, or edit the list's values. :)
 

Ultimecio777

"I Used RPG Maker 2 (PS2) And Liked It..."
Member
Joined
Aug 30, 2020
Messages
6
Reaction score
2
First Language
English
Primarily Uses
RMMV
Caethyril's method does work, and I got it working. Thank you everyone for your help!
 

Ultimecio777

"I Used RPG Maker 2 (PS2) And Liked It..."
Member
Joined
Aug 30, 2020
Messages
6
Reaction score
2
First Language
English
Primarily Uses
RMMV
Also, I would like some help with one last thing before this thread gets closed. I was wondering if fixed damage can be entered in a sequence of multiple hits (without using the repeat option) using a similar kind of formula that caethyril has shown. For example:

Enemy does a multiple hit combo that does 500 Dmg four individual hits, then does 1000 Dmg for the last hit.

Also, I was wondering if there was a way to change the timing of each hit on the target so that it won't just hit every 0.3 seconds like it does by default.
 

caethyril

^_^
Veteran
Joined
Feb 21, 2018
Messages
2,227
Reaction score
1,634
First Language
EN
Primarily Uses
RMMZ
By default the only way to hit more than once with an action is via the repeat option. There might be a workaround to get how many targets have been hit so far...? If so, you'd be able to set Repeats x5 and make the damage formula do double damage on hit 5.

I'm pretty sure changing the hit timing will require a plugin.

Plugin recommendations depend on what you're already using, but I think Yanfly's Battle Engine Core can do what you want via action sequences. Each hit is an action effect, and the timing can be customised with wait actions. There's a bit of a learning curve, though, since it's all custom syntax. More info here in case you're interested:
 

Ultimecio777

"I Used RPG Maker 2 (PS2) And Liked It..."
Member
Joined
Aug 30, 2020
Messages
6
Reaction score
2
First Language
English
Primarily Uses
RMMV
I've actually had this plugin for a while and never used it until now. I've been learning about it recently and I now know how to use it. It works perfectly. Thank you guys so much for helping me!
 

Latest Threads

Latest Profile Posts

"Man is made by his belief. As he believes, so he is."-Krishna
FastFood in my country is neither fast nor cheap like it's expected to be, but people still buy a lot of it. I don't want to imagine how much of it people would eat if it was.
Started finishing up my bosses and characters...I don't know how long...but its going to take long...

I ended up needing to do a chapter one world map remake. It's still WIP but coming along nicely. =D
Stream will be live shortly! I will be beginning a play-through of Resident Evil 4! Feel free to drop by!

Forum statistics

Threads
107,753
Messages
1,031,900
Members
139,898
Latest member
Karuu
Top