Submit Your Article


 
RPG Maker

Welcome Guest ( Log In | Register )


  Games Resources RPG Maker VX RPG Maker XP Scripts Tutorials Downloads

 
Reply to this topicStart new topic
> Damage Formula, What am I missing, here?
Pillanious
post Jun 5 2012, 07:19 AM
Post #1


Level 8
Group Icon

Group: Revolutionary
Posts: 125
Type: Musician
RM Skill: Beginner




Hey, everyone!

I'm playing around with a damage formula I saw that I really liked in terms of functionality - but it isn't working properly in vxace.

I wonder if someone with a little understanding of the mechanics behind the engine might be able to explain something for me.

The formula I'm playing around with is:

((a.atk+(a.atk/10*2))*(100/(100+b.def))+(a.atk-b.def))*5

When I plug in 86 attack and 20 Defense, I should come out with a result of 760

Instead, it comes out with a result of 330, which is only about 43% of what it should be. (and, coincidentally, only the (a.atk-b.def) portion of the formula)

Is there something I'm missing in terms of how ace's attack formulae work?

Edit: I think I kind of get it... the editor doesn't recognize parenthesis. Not sure what to do in terms of making this formula work without them ><

This post has been edited by Pillanious: Jun 5 2012, 09:51 AM
Go to the top of the page
 
+Quote Post
   
Tsukihime
post Jun 5 2012, 11:33 AM
Post #2


Level 25
Group Icon

Group: Revolutionary
Posts: 559
Type: None
RM Skill: Undisclosed
Rev Points: 25




So when you change the formula does the result also change?
If parentheses aren't recognized, then (a.atk - b.def)*5 would be evaluated as a.atk - (b.def * 5)

EDIT: here's your problem:

CODE
100/(100+b.def)


That evaluates to 0 since it's integer division.
It is standard ruby math operations.

This post has been edited by Tsukihime: Jun 5 2012, 11:48 AM


__________________________
My Scripts
Go to the top of the page
 
+Quote Post
   
Pillanious
post Jun 5 2012, 11:52 AM
Post #3


Level 8
Group Icon

Group: Revolutionary
Posts: 125
Type: Musician
RM Skill: Beginner




QUOTE (Tsukihime @ Jun 5 2012, 03:33 PM) *
So when you change the formula does the result also change?
If parentheses aren't recognized, then (a.atk - b.def)*5 would be evaluated as a.atk - (b.def * 5)

EDIT: here's your problem:

CODE
100/(100+b.def)


That evaluates to 0 since it's integer division.
It is standard ruby math operations.


I didn't realize it was integer division.

Is there a means of getting around this in Ruby so that it's standard division?


This post has been edited by Pillanious: Jun 5 2012, 12:06 PM
Go to the top of the page
 
+Quote Post
   
Thallion
post Jun 5 2012, 12:02 PM
Post #4


Level 5
Group Icon

Group: Member
Posts: 68
Type: Scripter
RM Skill: Skilled
Rev Points: 10




Just change it to this:

CODE
100.to_f/(100 + b.def)


It should work.
Go to the top of the page
 
+Quote Post
   
Tsukihime
post Jun 5 2012, 12:09 PM
Post #5


Level 25
Group Icon

Group: Revolutionary
Posts: 559
Type: None
RM Skill: Undisclosed
Rev Points: 25




CODE
100.0 / (100 + b.def)


Explicitly writing it as a float would also work.

This post has been edited by Tsukihime: Jun 5 2012, 12:10 PM


__________________________
My Scripts
Go to the top of the page
 
+Quote Post
   
Pillanious
post Jun 5 2012, 12:30 PM
Post #6


Level 8
Group Icon

Group: Revolutionary
Posts: 125
Type: Musician
RM Skill: Beginner




QUOTE (Thallion @ Jun 5 2012, 04:02 PM) *
Just change it to this:

CODE
100.to_f/(100 + b.def)


It should work.



That fixed it all - Thanks guys smile.gif
Go to the top of the page
 
+Quote Post
   

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 

Lo-Fi Version Time is now: 18th May 2013 - 01:23 AM
RPG RPG Revolution is an Privacy Policy and Legal
eXTReMe Tracker