Help me with math....pleeease :D

Started by Mouth for war, Thu 27/08/2015 01:04:10

Previous topic - Next topic

Mouth for war

Hey! I'm facing a little problem...I'm making a RPG (It's shaping up real nice) and it features a turnbased battle system. There are different types of grenades you can throw. If you throw a firegrenade, it reduces your enemy's defence. I have a variable set to 25, meaning that your current skill allows you to reduce your enemy's defence by 25 % if you throw a fire grenade. However...I don't know how to make a calculation so the game understand that the number 25 is percentage...not 25 points...the enemy's stats will be different depending on which ones you meet...so I want to have a calculation that will always remove 25% (or 30,35,40 etc, depending on how much you level up the skill) from the enemy's current defence stat. Is there anyone here who can teach this moron some math? :D Maybe it is really simple but my mind is fried right now haha
mass genocide is the most exhausting activity one can engage in, next to soccer

Crimson Wizard

#1
Remember what "percent" means? - a part of 100. One percent is 1/100. Two percents is 1/100 + 1/100 = 2/100. 25 percents is 25/100.
X percents is X/100.

Calculating a fraction of something when knowing percent value:

RESULT = VALUE * PERCENTS_NUMBER / 100

Mouth for war

mass genocide is the most exhausting activity one can engage in, next to soccer

Mouth for war

#3
Ahhh..stupid program won't do what I say...maybe I didn't quite understand your expression :D Well...I do understand it but the program won't do it hehe
mass genocide is the most exhausting activity one can engage in, next to soccer

selmiak

maybe you have to use floats or convert the result to an integer?

Mouth for war

hmm yeah maybe!!! I'll check that out!
mass genocide is the most exhausting activity one can engage in, next to soccer

Mouth for war

I got it working!!! Had to write 100.0 instead of 100 :D
mass genocide is the most exhausting activity one can engage in, next to soccer

Stupot

They're aaaall floats down here...

Mouth for war

Haha yeah :-D just glad to get it working
mass genocide is the most exhausting activity one can engage in, next to soccer

selmiak


SMF spam blocked by CleanTalk