ID:163972
 
...can tell the difference between things? Like I want to set up something like this:

Difference in Level     Experience Received
-10 1
-9 2
-8 3
-5 8
0 60
1 70
2 80
//Btw those are just random numbers to show what I'm trying to do..


And so on...So how would I do this? I'm not good at formulas =P. Thanks.

Dession
Any way you want, it'd be the same as an attack/defense ratio you likely use for combat. You can do expGain=a.level/b.level or expGain=min(0, a.level-b.level) or expGain= 10 + 5*((a.level-1)/(b.level+1)) or whatever you want.

How do you want the difference to affect the gain? That's the question.
In response to Loduwijk
Loduwijk wrote:
Any way you want, it'd be the same as an attack/defense ratio you likely use for combat. You can do expGain=a.level/b.level or expGain=min(0, a.level-b.level) or expGain= 10 + 5*((a.level-1)/(b.level+1)) or whatever you want.

How do you want the difference to affect the gain? That's the question.

I don't think any of those would do what I want it to do..if your level is 10 and you kill someone thats like 5 levels higher than you or 5 levels lower than you I want to be able to know how far away it is. And if they are 5 levels lower then you than x = -5, if theyre 5 levels higher x = 5. Does that make sense? haha
In response to Dession
Dession wrote:
if your level is 10 and you kill someone thats like 5 levels higher than you or 5 levels lower than you I want to be able to know how far away it is.

If I understand you right, wouldn't you do
var/difference_in_level = src.level-enemy.level

Negative numbers would be how many levels enemy is above you.
Positive numbers would be how many levels you are above enemy.

I had to write an example =P
mob/var
level = 1
mob/verb/test(mob/M)
src<<"you [src.level] M [M.level]"
var/difference_in_level = src.level - M.level

if(difference_in_level < 0 )
difference_in_level = abs(difference_in_level)
src<<"[M.name] is [difference_in_level] levels above you."
else if(difference_in_level > 0)
src<<"You are [difference_in_level] levels above [M.name]."
else
src<<"You and [M.name] have equal strength."


If thats not what your looking for try being waay more specific.
Dession wrote:
Difference in Level     Experience Received
> -10 1
> -9 2
> -8 3
> -5 8
> 0 60
> 1 70
> 2 80
> //Btw those are just random numbers to show what I'm trying to do..


I would probably use a logistic function to match the data; it has the benefit of fairly accurately running through the required data points, and hitting a limit (so that Received experience levels off at some point. With the given data, I came up with the following formula (decimals rounded a bit): y = 96.0284 / (1 + 0.6185e-0.5528x)

That roughly translate into the following code, as I would use it:
proc
ceil(x=0)
return (x != round(x) ? round(x)+1 : x)

GetExp(x=0)
var/e = 2.718281828
return ceil(96.0284/(1 + 0.6185 * e ** (-0.5528 * x)))

// Personal debugging environment:

client
proc
PrintExp(x=0)
src << "Level Difference: [x]\tExperience: [GetExp(x)]"

New()
. = ..()
PrintExp(-100)
PrintExp(-10)
PrintExp(-9)
PrintExp(-8)
PrintExp(-5)
PrintExp(0)
PrintExp(1)
PrintExp(2)
PrintExp(100)


Which outputs the following:
Level Difference: -100      Experience: 1
Level Difference: -10    Experience: 1
Level Difference: -9     Experience: 2
Level Difference: -8     Experience: 2
Level Difference: -5     Experience: 9
Level Difference: 0      Experience: 60
Level Difference: 1      Experience: 71
Level Difference: 2      Experience: 80
Level Difference: 100    Experience: 97


Hopefully that's accurate enough?

Hiead
In response to Smokey Joe
See that's why I hate math haha simple things become the hardest tasks for me. heh. Thanks!

This is right, right?

                    var/leveldifference = src.level - M.level
if(leveldifference < 0)
if(abs(leveldifference) == 1)//If they are one level above you..etc..
src << "You gain more exp duh."
else if(leveldifference > 0)
if(leveldifference == 1)//If they are one level below you
src << "You gain less exp duh."
else
src << "You gain normal exp duh"