# RMMZCreating a Method to use in Skill Damage Formula

##### Game Dev by Career, no idea what I'm doing
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
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.

##### Game Dev by Career, no idea what I'm doing
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

### 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.

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

- Professor Ian Duncan, 2013
--- 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??