ID:165317
 
Okay... what im trying to do is, Get the average of 2 variables (numbers), maybe in a percent value.

Ill use an example to explain myself.

If i wanted to have a flee action, from a fight, I wanna take the enemys agility var and the usr.

so, Ill say...

var/a=14

and

var/b=54


Now... I wanna subtract the 1 from the other then average them out or somthing, Or just get the average within a hundred range (like percent)

So this way i can do...

if(percent>=25)
world<<"PlayerA Fled from battle!"



any help?


Thanks.
If I understand correctly 100/b*a is what you need.
In response to YMIHere
nah. thats not right.

mob/verb/TESTME()
var/a=232
var/b=127
var/c=100/b*a
world<<"percent of [a] and [b] is [c]"


Results...


percent of 232 and 127 is 182.677.


Want the results to be a number between 0 and 100. like in a percent somehow. :P.
It seems like what you're looking for is a percentage of difference between two values. This is typically calculated using the average, so the calculation would be 2*(A-B)/(A+B). For the values 14 and 54, the difference is 80/68 or 20/17, which is roughly 118%. This means the difference between the values is about 118% of their average, which is significant. (This formula can backfire for negative values of A or B.)

Lummox JR
In response to Bladeshifter
maybe you need to word out better what you are looking to achieve.

for instance. What is the number of the comparison going to represent? Are you trying to find what percentage the lower number is of the larger?
Is there a max for this stat that sets the ceiling number. Therefor each number would be a precent of this bigger number.

as you have seen, you have gotten several different responses. You may need to be more specific with the question.