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

Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??
Yay, now back in action Happy Christmas time, coming back!






Back in action to develop the indie game that has been long overdue... Final Fallacy. A game that keeps on giving! The development never ends as the developer thinks to be the smart cookie by coming back and beginning by saying... "Oh bother, this indie game has been long overdue..." How could one resist such? No-one c

Forum statistics

Threads
105,857
Messages
1,017,018
Members
137,563
Latest member
MinyakaAeon
Top