RMMZ Creating a Method to use in Skill Damage Formula

nathanlink169

Game Dev by Career, no idea what I'm doing
Veteran
Joined
Aug 15, 2013
Messages
72
Reaction score
32
First Language
English
Primarily Uses
RMMV
Hello all!

I'm looking to make some "easy of access" methods for the Skill Damage Formula. The damage formula I'm planning on using are based a lot of D&D, so there are a lot of "dice rolls" rather than calculating a direct number and just varying it by a certain percentage.

Rather than writing out Math.round(rand() * 6) for a d6 every time (I know that's probably wrong, just pseudocode), it would be easier if I could just write out d6() to get a random number between 1-6. Anyone know how I could do that.

I should clarify, it's not the contents of the function I need help with (i.e. I know how to get a random number), it's actually being able to access the method from the Skill Damage Formula section.
 

Tsukihime

Veteran
Veteran
Joined
Jun 30, 2012
Messages
8,564
Reaction score
3,846
First Language
English
If you want to be able to use the user/target information conveniently, define it inside Game_Battler so you can say

Code:
a.yourMethod
b.yourMethod
If you just need to be able to reference it as a global function, you can just define it in global space

Code:
function d(num) {
   return Math.round(rand() * num)
}
And then you can just use it in your formula.

Code:
d(4) - b.def
It's just a JS eval after all.
 

nathanlink169

Game Dev by Career, no idea what I'm doing
Veteran
Joined
Aug 15, 2013
Messages
72
Reaction score
32
First Language
English
Primarily Uses
RMMV
If you just need to be able to reference it as a global function, you can just define it in global space

Code:
function d(num) {
   return Math.round(rand() * num)
}
And then you can just use it in your formula.

Code:
d(4) - b.def
It's just a JS eval after all.
That was exactly what I was looking for! Thank you kindly :)
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Lately when I listen to 1970s songs, I always think that the "real world" is still at mid 70s. What we experience now is a futuristic dream. With this point of view, even 80s and 90s looks super futuristic. :D

The GIF of this seemed too cool to bury in replies. :LZSwink:
You may have slept with my aunt... but, given the circumstances, cheers.

- Professor Ian Duncan, 2013
Ami
--- Swimming ---

F.Knight: This Shrine always Flood. We don't have a choice,we have to Swimming in this place
F.Healer: That Insane!
F.Mage: We can use…Boat,rather than Swimming
F.Knight: You guys…Can't Swim?
F.Healer & F.Mage: (Shocked) Eehh??

Forum statistics

Threads
105,525
Messages
1,014,391
Members
137,209
Latest member
RowanWolf
Top