VE Hit Formula - Need help creating a formula please

Status
Not open for further replies.

Morpheus

Jack-of-Trades
Veteran
Joined
Mar 14, 2012
Messages
231
Reaction score
85
First Language
english
Primarily Uses
N/A
So I'm using VE Hit Formula and I input the formula 'result = $gameVariables.setValue(491, Math.randomInt(20) + 1); if (v[491] >= b.def){sethit (1.0)} else {sethit (0.0)} '

Essentially this is suppose to recreate the DnD way of handling hits/misses where a d20 is rolled and if the roll is higher than the defending creature, the attack hits.

As you can see, every time the player attacks, the d20 is rolled for Variable 491. Using the debug menu, I can see that yes, Variable 491 'rolls' between 1 - 20, however, when the attacks should hit, they always miss. I'm stumped for now. Any help would be greatly appreciated.

Edit: "result = $gameVariables.setValue(491, Math.randomInt(20) + 1); if (v[491] >= b.def) {result = 100} else { result = 0}" does not work either. The Variable changes every time anyone attacks according to the Console, but for some reason Hit Rate doesn't change :/
 
Last edited:

Oddball

Veteran
Veteran
Joined
Sep 4, 2014
Messages
1,923
Reaction score
535
First Language
English
Primarily Uses
N/A
where a d20 is rolled and if the roll is higher than the defending creature, the attack hits.
What did the defending creature roll?

Edit: Just noticed your facoring in the enemy creatures deffense. does that have something to do with it?

Edit edit: Ah. You have it set so that lower numbers hit, and higher numbers miss. Switch the > to a < and see if it works as nintended
 

Morpheus

Jack-of-Trades
Veteran
Joined
Mar 14, 2012
Messages
231
Reaction score
85
First Language
english
Primarily Uses
N/A
I
What did the defending creature roll?

Edit: Just noticed your facoring in the enemy creatures deffense. does that have something to do with it?

Edit edit: Ah. You have it set so that lower numbers hit, and higher numbers miss. Switch the > to a < and see if it works as nintended
I have it set so that if the roll is higher than their Defense, then the hit becomes 100%, else it’s 0%, right? That’s how it should be.

anyway, even if I put it lower the hits still always miss. No idea why. :/
 

Oddball

Veteran
Veteran
Joined
Sep 4, 2014
Messages
1,923
Reaction score
535
First Language
English
Primarily Uses
N/A
Is the enemies deffense higher than the range?
 

Morpheus

Jack-of-Trades
Veteran
Joined
Mar 14, 2012
Messages
231
Reaction score
85
First Language
english
Primarily Uses
N/A
Is the enemies deffense higher than the range?
Nope. However...

After HOURS testing all the different ways you can get it to work, I finally figured it out.

The only correct way of accomplishing it is with this line.

result = Math.randomInt(20)+ 1 >= b.def ? 100 : 0
 

hiddenone

Lurker Extraordinaire
Global Mod
Joined
Feb 19, 2014
Messages
2,497
Reaction score
5,334
First Language
english
Primarily Uses
RMMZ

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

 
Status
Not open for further replies.

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

Latest Threads

Latest Posts

Latest Profile Posts

People3_5 and People3_8 added!

so hopefully tomorrow i get to go home from the hospital i've been here for 5 days already and it's driving me mad. I miss my family like crazy but at least I get to use my own toiletries and my own clothes. My mom is coming to visit soon i can't wait to see her cause i miss her the most. :kaojoy:
Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
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.

Forum statistics

Threads
105,868
Messages
1,017,085
Members
137,585
Latest member
Reversinator
Top