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
 
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
 
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 :>
 
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
 
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
 
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 ;(
 
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!
 
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.
 
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
  • No one is chatting at the moment.
  • V-SNES V-SNES:
    Happy Friday!
    +1
  • The Helper The Helper:
    News portal has been retired. Main page of site goes to Headline News forum now
  • The Helper The Helper:
    I am working on getting access to the old news portal under a different URL for those that would rather use that for news before we get a different news view.
  • Ghan Ghan:
    Easily done
    +1
  • The Helper The Helper:
    https://www.thehelper.net/pages/news/ is a link to the old news portal - i will integrate it into the interface somewhere when i figure it out
  • Ghan Ghan:
    Need to try something
  • Ghan Ghan:
    Hopefully this won't cause problems.
  • Ghan Ghan:
    Hmm
  • Ghan Ghan:
    I have converted the Headline News forum to an Article type forum. It will now show the top 20 threads with more detail of each thread.
  • Ghan Ghan:
    See how we like that.
  • The Helper The Helper:
    I do not see a way to go past the 1st page of posts on the forum though
  • The Helper The Helper:
    It is OK though for the main page to open up on the forum in the view it was before. As long as the portal has its own URL so it can be viewed that way I do want to try it as a regular forum view for a while
  • Ghan Ghan:
    Yeah I'm not sure what the deal is with the pagination.
  • Ghan Ghan:
    It SHOULD be there so I think it might just be an artifact of having an older style.
  • Ghan Ghan:
    I switched it to a "Standard" article forum. This will show the thread list like normal, but the threads themselves will have the first post set up above the rest of the "comments"
  • The Helper The Helper:
    I don't really get that article forum but I think it is because I have never really seen it used on a multi post thread
  • Ghan Ghan:
    RpNation makes more use of it right now as an example: https://www.rpnation.com/news/
  • The Helper The Helper:
  • The Helper The Helper:
    What do you think Tom?
  • tom_mai78101 tom_mai78101:
    I will have to get used to this.
  • tom_mai78101 tom_mai78101:
    The latest news feed looks good

      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