# How does "Need Hero XP Table" work?

Status
Not open for further replies.

#### sethmachine

Level 15
Hi,

So I set this game constants field "Need Hero XP Table" to "0" with a single entry.

The side effect is that level one heroes instantly level to level 2 whenever they get XP (it requires 0 xp).

And heroes cannot be set to level 2, even if you call "SetHeroLevel(..., 2, ...)"

However, I would like it to take xp to get from 1 to 2 and be able to set heroes to level 2.

How would I fix this?

Last edited:

E

#### EdgeOfChaos

Set NeedHeroXP to the EXP you want it to take to get to level 2. It should only affect the first level. Or you *might* be able to leave it blank and game will specify needed xp.

#### sethmachine

Level 15
This is the problem:

heroes cannot be set to level 2, even if you call "SetHeroLevel(..., 2, ...)"

So if I do this:

JASS:
``````local unit u = ...
...
call SetHeroLevel(u, 2, true)``````

The unit will actually be level 1, and not level 2!

I would like to to be level 2.

#### Zeatherann

Level 17
The "NeedHeroXpFormua<ACB>" fields are used to define a quadratic function to determine how much experience a hero needs to level up to a level. The "NeedHeroXp" table is used to overwrite the experience needed for some levels. The table overwrite the first X levels' needed experience, where X is the number of entries in the table. If there are no entries in the table then all values are taken from the function instead. Oddly enough, the default function's required experience for level 1 is 200, which is the same as the override value in the table.

#### sethmachine

Level 15
Ah so ACB are constants for which variables?

so the hero EXP formula is this, with x = the level needed

(A * x^2) + (B * x) + (C * 1)

?

#### Zeatherann

Level 17
I don't know the formula off the top of my head, but it's not hard to figure out.

#### sethmachine

Level 15
So if I do this:

JASS:
``````local unit u = ...
...
call SetHeroLevel(u, 2, true)``````

The unit will actually be level 1, and not level 2!

I would like to to be level 2.

So the OP asked why this happens. The helper site didn't explain caveats about permutations of the hero XP constants. OP still unsolved :/

#### Ceday

Level 12
This is the problem:

So if I do this:

JASS:
``````local unit u = ...
...
call SetHeroLevel(u, 2, true)``````

The unit will actually be level 1, and not level 2!

I would like to to be level 2.

Are you trying to decrease a hero's level?

No -> Make sure variable u is a valid unit.Because this works for me.
`call SetHeroLevel(CreateUnit(Player(0), 'Hblm', 0, 0, 0), 2, true)`

#### sethmachine

Level 15
Make sure variable u is a valid unit.Because this works for me

How do you think I was testing this? The OP clearly states it works for any other level except level 2.

That wouldn't make any sense: a non-valid unit can be visualized + set at any level but level 2??

Are you trying to decrease a hero's level?

Nope.

No it doesn't work when my advanced constants are like this (again it was in OP):

I can set a hero to any level BUT level 2. If I set a hero to level 2, it just gets set to level 1 instead.

The OP says:

So I set this game constants field "Need Hero XP Table" to "0" with a single entry.

The side effect is that level one heroes instantly level to level 2 whenever they get XP (it requires 0 xp).

And heroes cannot be set to level 2, even if you call "SetHeroLevel(..., 2, ...)"

However, I would like it to take xp to get from 1 to 2 and be able to set heroes to level 2.

How would I fix this?

#### Solu9

Level 25
This could be cause by the fact that you set the XP amount from level 1 to 2 to 0.
Is 0 important to you?
If not, try setting the NeedHeroXP to 1 (or whatever) and level the hero then.

#### Ceday

Level 12

Not sure you consider this as a fix, but if you need to set level to 2 you can do this.
JASS:
``````call SetHeroLevel(u, 3, true)
call UnitStripHeroLevel(u, 1)``````

Status
Not open for further replies.

Replies
4
Views
2K
Replies
3
Views
2K
Replies
2
Views
1K
Replies
3
Views
676
Replies
4
Views
581