TenebrisCrow

The Kelphy Corp
Veteran
Joined
Oct 19, 2015
Messages
99
Reaction score
6
First Language
English
Primarily Uses
RMMZ
I'm trying to make two variables equate to a percentage. I'm trying to make a good and evil system where 1 point can be added to evil, and 1 point can be added to good. I'll show an example hopefully this makes sense what I'm trying to do.

Good Variable = 77 (Suppose they did 77 good things)
Bad Variable = 77 (And 77 bad things)
Naturally the percent would be 50%

Good Variable = 9
Bad Variable = 1
90%??? (Not 100% sure if that's correct, but I want to find out a way to solve it within game)

Good Variable = 1
Bad Variable = 9
10%??? (Not 100% sure if that's correct, but I want to find out a way to solve it within game)

Good Variable = 927
Bad Variable = 400
So the percent would be ??? I need a way using variables to work this out for me in game to figure out if the person does more evil things through %. So if they're at 90% then they do many good things, and if they are 10% they do many bad things.


I'd need the % to go downwards all the way to 0% if they ONLY did good things. Also I'd need it to go all the way up to 100% if they ONLY did good things.
Sorry this is a really tough question and really hard to explain. Hopefully you understand.
I apologize if this question annoys you I can not think of any other way to explain it.

Any help would be truly appreciated! Thank you!
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
33,909
Reaction score
8,602
First Language
German
Primarily Uses
RMMV
You'll need to get back on your mathematics.

Basically % = 100 * Value / total
and total = bad + good

In your last example that would be
good% = 100 * 927 / (400+927) or 69.8%

That can be calculated with a simple series of control variable command, although you'll need some temp variables for the intermediate parts of the calculation
 

TenebrisCrow

The Kelphy Corp
Veteran
Joined
Oct 19, 2015
Messages
99
Reaction score
6
First Language
English
Primarily Uses
RMMZ
You'll need to get back on your mathematics.

Basically % = 100 * Value / total
and total = bad + good

In your last example that would be
good% = 100 * 927 / (400+927) or 69.8%

That can be calculated with a simple series of control variable command, although you'll need some temp variables for the intermediate parts of the calculation

Worked perfectly, honestly I was starting to believe it wasn't possible with RPG Maker, you made my day thank you! You're right though, I do need to get back onto my mathematics. I knew about finding a percent with one number, that's easy, but I wasn't sure how to use two.
 

Latest Threads

Latest Posts

Latest Profile Posts

To be released 2021/10/21
Now that I made this "What the MZ RTP is missing" spreadsheet it's itching me to fill some the gaps D:
Aaaaand I completely forgot about the RMMV Chicken Rave my brother decided to implement in a parody of my VERY FIRST UNFINISHED project. We could not escape the chicken rave... The chickens would block the ladder...
I love how I can look up a problem I'm having with my game, find a post from like six years ago that addresses the issue, and the solution provided still works in RPG Maker.
It's times like those that my life feels really easy XD
Change costumes with equipment!

Forum statistics

Threads
115,949
Messages
1,094,284
Members
151,205
Latest member
Vertette
Top