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
  • No one is chatting at the moment.
  • Ghan Ghan:
    Howdy
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though
  • Ghan Ghan:
    Heard Houston got hit pretty bad by storms last night. Hope all is well with TH.
  • The Helper The Helper:
    Power back on finally - all is good here no damage
    +2
  • V-SNES V-SNES:
    Happy Friday!
    +1

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top