ID:173988
 
ok so Im no math major so I need to know how to figure this out.

I have 2 vars in my game MaxStat which is 100 and FocusStat which for this example we'll say is 30 for the usr and 20 for the mob in refrence. Now what I need is a way to determine the difference between the focusstats and the maxstat to determine another var.

Basically what should happen is the FocusStats should in some way be used with the MaxStat to determine the XP award for the winner. If the usr FocusStat is higher or equal to the other FocusStat then the award should be lower because your better than what your fighting. It should be higher if its focusstat is higher than yours because its better than you.

What Im lookin at so far is if yours is higher than its then MaxStat - (Attacker.FocusStat + Defender.FocusStat) that would be 100 - (30+20) = 50 so lets say your FocusStat is 50 thats 100 - (50+20) = 30 And this works fine as long as your better than it is but how would I go about making it higher if its better than you?? I hope I havent utterly confused anyone here
Aridale wrote:
ok so Im no math major so I need to know how to figure this out.

I have 2 vars in my game MaxStat which is 100 and FocusStat which for this example we'll say is 30 for the usr and 20 for the mob in refrence. Now what I need is a way to determine the difference between the focusstats and the maxstat to determine another var.

Basically what should happen is the FocusStats should in some way be used with the MaxStat to determine the XP award for the winner. If the usr FocusStat is higher or equal to the other FocusStat then the award should be lower because your better than what your fighting. It should be higher if its focusstat is higher than yours because its better than you.

What Im lookin at so far is if yours is higher than its then MaxStat - (Attacker.FocusStat + Defender.FocusStat) that would be 100 - (30+20) = 50 so lets say your FocusStat is 50 thats 100 - (50+20) = 30 And this works fine as long as your better than it is but how would I go about making it higher if its better than you?? I hope I havent utterly confused anyone here

Just what exactly is it in these three cases?
In response to Delita12345
<s>The outcome of the formula. :)</s> Err, a couple of different its. :P

You could just scale off your current formula so that if your too much higher than the other person you get nothing.
In response to Jnco904
Its not the if Im higher its the if ITS higher that I need the formula for.
Aridale wrote:
What Im lookin at so far is if yours is higher than its then MaxStat - (Attacker.FocusStat + Defender.FocusStat) that would be 100 - (30+20) = 50 so lets say your FocusStat is 50 thats 100 - (50+20) = 30 And this works fine as long as your better than it is but how would I go about making it higher if its better than you?? I hope I havent utterly confused anyone here

Why dont you try something like
if(Attacker.FocusStat >= Defender.FocusStat)
exp(whatever your exp var is) = MaxStat - (Attacker.FocusStat + Defender.FocusStat)
else
exp = MaxStat - (Defender.FocusStat - Attacker.FocusStat)
What that does is basically if the attacker is higher or equal, then your equation is used, otherwise, the new one is used.
Say defender is 50 and attack is 20, then 100 - (50 - 20) = 70, and so forth.
In response to Aridale
Don't mind me, I'm usually one of the utterly confused ones. :)
Your formula would depend on what the typical values of FocusStat are and by how much they differ. My gut says some kind of exponential formula is the way to go.

In the case of an RPG, where level is a big deal, then it should have a big deal in your EXP reward. In an RPG, level is always a positive integer (1 or more), so it's easy to come up with something.
var/ratio = monster.level / src.level
var/exp_gain = max(1, round(monster.exp * ratio * ratio, 1))
There I've chosen the formula, R=RM×(LM÷L0)2.

So if you defeat a monster twice your level, you get 4× as much experience from it; beat one at half the level, and you get only ¼. However this may not be the best formula, since levels are rather exponential in RPGs; the difference in levels, not the ratio, tends to be more important. That being the case, I'd try this:
var/ratio = monster.level - src.level
var/exp_gain = max(1, round(monster.exp * (2 ** ratio), 1))
And this formula is, R=RM×2LM-L0.

Thus by beating a monster 1 level higher, you get twice as much experience as normal; 1 level lower, you get half as much.

I your case I suspect you'd do something similar to this last formula, but you probably would want to divide the difference in FocusStat by 10 or so--or adjust the base accordingly. I used 2 as the base in my example, but maybe something like 1.1 would work better for you, or even 1.05.

You may also have noticed my use of max(). I wanted to make sure there was always at least 1 point in it for the victor.

Lummox JR
In response to Lummox JR
I'll try this later right now this is what I have

DetermineWorthXP(mob/Attacker, mob/Defender)
if(Attacker.FocusStat >= Defender.FocusStat)
var/Diff = MaxStat - (abs(Attacker.FocusStat + Defender.FocusStat))
src.WorthXP = Diff*0.1
else //Double XP when creature is better
var/Diff = Defender.FocusStat
src.WorthXP = Diff*0.2

if(src.WorthXP < 0)
src.WorthXP = 0
usr << "You gained [src.WorthXP] Xp!"


the abs() is just there where I was testing different things still dont mind it.