HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Experience Equation

02-22-2004, 04:37 PM#1
Shimrra
Does anyone know the equation Blizzard uses for kill experience? I've been using something along the lines of ((Point Value of (Unit)) - ((Hero Level of (Killing Hero)) x 2), but it isn't perfectly accurate... Any thanks would be appreciated.
02-22-2004, 05:26 PM#2
linkmaster23
I do that except x2.2 instead of 2. It's closer.

Otherwise... Hero - Add (((Point-value of (Dying unit)) - (Hero level of (Killing unit))) x (Integer(2.20))) experience to (Killing unit), Hide level-up graphics
02-22-2004, 07:38 PM#3
Cubasis
Erhm,

Link: You aren't using "2.20" with that line. When you convert "2.20" to integer, it gets reduced to 2. You have to convert the other value (pointvalue - herolevel) into Real to be able to calculate it correctly.

However, I am currently investigating it's exact algorithm to find the exact XP, to release a SpellMakers API where when you create spells, you just use a action like "Deal Damage to unit", and it keeps track of XP and Gold if the unit dies. It will also have alot of advanced settings, f.ex. Bounty-Sharing and stuff (for Arenas and other game-types).

Cubasis
02-22-2004, 07:40 PM#4
linkmaster23
Cubasis your cool, I converted it to a REAL INTERGER. HAHA I WIN. (omg I just say your cool to section leader)

[edited by Cubasis......]
02-22-2004, 08:55 PM#5
weaaddar
I have to ask why you guys just don't use the information given to you in MiscGame.txt:

GrantHeroXP=100,120,160,220,300
GrantNormalXP=25
// Formula constants for hero levels beyond the tables...
// The three constants are used to define a table as:
//
// f(x) = A*f(x-1) + B*x + C
//
// where A,B,C are the constants given below
//
NeedHeroXPFormulaA=1
NeedHeroXPFormulaB=100
NeedHeroXPFormulaC=0
GrantHeroXPFormulaA=1
GrantHeroXPFormulaB=0
GrantHeroXPFormulaC=100
GrantNormalXPFormulaA=1
GrantNormalXPFormulaB=5
GrantNormalXPFormulaC=5

There for for a normal use the formula is:
n being the level of the unit killed.
f(n)=f(n-1)+5*n+5
and f(1)=25

So a jass function compute the normal xp to grant for a unit killed would look like this
Code:
function getXpFromUnit takes integer n returns integer
 if(n>1)then
   return getXpFromUnit(n-1)+5*n+5
 else
   return 25
 endif
endfunction
Now the formula for hero xp is even easier:
n being the level of the unit killed
f(n)=f(n-1)+100
and f(1)=100, f(2)=120,f(3)=160,f(4)=220,f(5)=300

so a jass function to compute the xp to grant for a hero would look like this
Code:
function getXpFromHero takes integer n returns integer
 if(n>5)then
   return getXpFromHero(n-1)+100
 elseif(n==5)then
   return 300
 elseif(n==4)then
   return 220
 elseif(n==3)then
   return 160
 elseif(n==2)then
   return 120
 else
   return 100
 endif
endfunction
I believe recursively is easier on the eyes, you can if you want to be a wierdo convert it to be iteratively computed.

**Note my functions will treat level 0 as level 1, You can add another base case for level 0 but I don't really think its worth it as how often will you have level 0 units?
02-22-2004, 09:15 PM#6
Cubasis
LinkMaster

wtf do you mean?

Quote:
Hero - Add (((Point-value of (Dying unit)) - (Hero level of (Killing unit))) x (Integer(2.20))) experience to (Killing unit), Hide level-up graphics


Let's see, PointValues are Integers. Hero Levels are integers. And thus, you convert 2.20 into a Integer to be able to calculate the two values together. Now, please tell me, what are Integers?... they are WHOLE number values. 1, 7, 32136. Not 3.51 ... So when you convert a 2.20 real value into a integer value... it becomes "2".

So don't call me dumb, you n00b.

weaaddar: That's awesome, i have looked through miscdata alot of time, but somehow i never noticed that. Anyways, Thanks for pointing it out.

Cubasis
02-22-2004, 09:21 PM#7
weaaddar
Its in MiscGame.txt thats why you never noticed it!

These are changable by the Gameplay Constants but it feels funny that the formula is nowhere to be found.
02-22-2004, 09:25 PM#8
Cubasis
ahh, that explains

Btw, if i complete my SpellMakers API, i'll ofcourse have these constants apparently setupable if players would have edited them in "Gameplay Constants"

Cubasis
02-22-2004, 09:29 PM#9
weaaddar
I'm hoping that blizzard will give us functions to read gameplay constants. It seems very odd that you can not.

If you do allow people to manually input these things you have to remember that you need to add a loop and a string tokenizer to get all the basecases.
02-22-2004, 09:40 PM#10
Shimrra
Code:
function getXpFromHero takes integer n returns integer
 if(n>5)then
   return getXpFromHero(n-1)+100
 elseif(n==5)then
   return 300
 elseif(n==4)then
   return 220
 elseif(n==3)then
   return 160
 elseif(n==2)then
   return 120
 else
   return 100
 endif
endfunction

OK, thanks for the code but, how do you use it? I don't understand jass, and work in GUI, so could you please explain who to run this run this? Is it just a separate trigger and run through run trigger, or is it a custom script?
02-22-2004, 09:55 PM#11
weaaddar
Alright I really hate doing this but I guess I need to a give another quick jass 101.
Copy that function the Custom script section of your map. (When you click the map Icon in the trigger editor).

Now let say you have an integer variable called L:
First you would go:
set L=Hero Level of Dying/Attacked Hero.
Now using a custom script action type:
set udg_L=getXpFromHero(udg_L)
After doing so you can add L to the experience of the Killing/Attacking unit.
02-22-2004, 10:01 PM#12
Shimrra
Alright... I'll see if I can get this working. Thank you for all your assistance!