Custom Script: %XP?

jnZ

I
Reaction score
64
Hey there my first post here - honestly i only registered to ask the following question:

Is there any way to recieve the percentage experience value of a hero in order to use it as an integer.
I found the scripts for %HP and %MP but %XP was missing:

Set IntegerMultiboardStatusHP = (Integer((Percentage life of UnitHero)))
Set IntegerMultiboardStatusMP = (Integer((Percentage mana of UnitHero)))

Any custom scripts or something to handle with in GUI would be okay but JASS wouldnt be a real help to me.

thx in advance
 

jonadrian619

-___-
Reaction score
242
To find the percentage of the Hero's experience, you have to first find out the hero's max experience (you know, when he reaches level 10 or the maximum level, you can read his max experience.). To easily find the max experience of a hero, set the hero's level to the max level and test it in-game to see his max experience.

In melee maps, the hero's max experience at lvl 10 is 5400.

Then observe and study this formula. (it's just like the percentage formula)

Hero's Current Experience/Max Experience of Hero x 100.

You can now find the percentage of the experience of the Hero. (in this case, 5400 is the max experience of the hero)

Set IntegerMultiboardStatusXP = (((Hero experience of XPHero) / 5400) x 100)

Offtopic: Welcome to The Helper jnZ!! Even though you've registered just to ask this question you can do alot of stuff here such as asking more questions and showing off your maps and projects and go along w/ the community. Enjoy your stay.:D
 

jnZ

I
Reaction score
64
Hey jonadrian619 thanks for the nice welcoming, but anyway I am afraid that your answer wasn't the one I was looking for.

Maybe I should explain why I need the XP%:

I am currently working on visual HP/MP/XP bars used in a multiboard.
As far as I got HP and MP is working well and was kinda a peace of cake.
As you see my system is used to observe the units percentages in order to create visual bars.

A hero in a meele map levels up 10 times, that means there are 10 different XP'caps for each level and I need to know the current XP% for the current cap to create the bar.

I just thought there is an easier way than looking up all 10 caps and use them in individual formulas.

greetings :>
 

hoeyad

New Member
Reaction score
3
In the gameplay constants you can find out how much experience the hero will have at the end of the levels by looking where it says "Hero XP Required - ..." The formula is Experience required = "Previous value" * "Previous value factor" + "Level" * "Level factor" + "Constant factor" (which i took from Aceharts tutorial on hero xp btw). You need to set the previous value factor to 0 for what I am thinking. This will probably upset the balance of your map (and by probably i mean yes it will), so you may not want to do this, in which case I can't help you.

Ok, so the formula is now: Max XP = "Level" * "Level factor" + "Constant factor", and you know all that, so just make your GUI like so:

Code:
Set MaxXP = ((Level of UnitHero)*(Level Factor)) + (Constant Factor)
Set XP% = ((MaxXP)/(Hero Experience of UnitHero)

I think thats right.


You can probably do some complicated formula and keep the previous level factor, but I dunno how. Here's a tutorial on hero xp if it helps: http://www.thehelper.net/forums/showthread.php?t=68382
 

jnZ

I
Reaction score
64
Thank you hoeyad your post gave me a point to think about.
Till now i try to get the current XP% via the formula out of AceHarts post - I created an integer with an array index from 1 - 9 for every level cap: index 1 cap for level 2, index 2 cap for level 3 and so on...

But I have a problem with using the formula in triggers.
This is a trigger I used to test the formula:

Set IntegerExperiencePercentage = (Hero experience of UnitHero)
Game - Display to (All players) the text: (String(IntegerExperiencePercentage))

// this trigger displays the experience properly and AceHarts formula tought me how to calculate the XP caps so the trigger to get the percentage value of a hero at level one would be like this:

Set IntegerExperiencePercentage = (((Hero experience of UnitHero) / 200) x 100)

Example: Hero XP: 100 100 / 200 x 100 = 50
XP Cap: 200

//But if I use the following trigger to show me the percentage value...

Game - Display to (All players) the text: (String(IntegerExperiencePercentage))

//...the text that appears says everytime "0" till the hero reaches a level it says "X + 200"

Example: Level 1 the text says: 0
Level 2 the text says: 200
Level 3 the text says: 400
and so on...

I dont really care about the values at level 2 or 3 because the formula calculates with the levelcap for level 1 all the time but why says the text constant values every level and why does it only change on levelup.

Please help and thanks 4 all the help so far and in advance
 

jnZ

I
Reaction score
64
thx for your post too flare but i read it after i wrote the reply above >.<

Set IntegerExperiencePercentage = ((Hero experience of UnitHero) / IntegerExperienceCap[(Hero level of UnitHero)])
Game - Display to (All players) the text: (String(IntegerExperiencePercentage))

This if how I tested your idea flare but it says "0" all the time too. I think I am doing something wrong :>

sorry but need some more help ;(
 

jnZ

I
Reaction score
64
I think I figured out that the formula crashes everytime a value gets below zero; meaning the XP from 0-200 (200 level up level 2) / 200 (levelcap level 2) results in a 0 everytime since you reach 200 XP.

How to fix this? Help please!
 

Alphabet

New Member
Reaction score
12
Do you know what's the difference between reals and integers?

Well, reals got decimals, integers don't. And when you transform a real into an integer, it just leaves the decimals out, it doesn't round the value.

So if you seriously need to use integer, make it like this: 'Set IntegerExperiencePercentage = (((Hero experience of UnitHero) / IntegerExperienceCap[(Hero level of UnitHero)]) * 100)'. That also gives you the percentage value instead of something between 0 and 1.
 

jnZ

I
Reaction score
64
oh man, thanks a lot i really didn't know the difference between reals and integers or just didnt think about them. Its working with reals thank you.
/closed
 
General chit-chat
Help Users

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top