• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Experience Percentages

Status
Not open for further replies.
Level 12
Joined
Jan 30, 2009
Messages
1,067
Is there a way to convert Experience into percentages?

I've been playing with it, and I cannot get it to work regardless of how I do it.

I've got the EXP of the hero in a variable, the EXP needed for the level as a variable, and I convert it in a formula, but for some reason I don't get a result with the formula.

  • Initialization
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set Hero[1] = Blademaster 0000 <gen>
      • Set Hero[2] = Death Knight 0002 <gen>
      • Set Hero[3] = Demon Hunter 0001 <gen>
      • Set Hero[4] = Blood Mage 0003 <gen>
      • Set MaxEXPLvl[1] = 200
      • Set MaxEXPLvl[2] = 500
      • Set MaxEXPLvl[3] = 900
      • Set MaxEXPLvl[4] = 1400
      • Set MaxEXPLvl[5] = 2000
      • Set MaxEXPLvl[6] = 2700
      • Set MaxEXPLvl[7] = 3500
      • Set MaxEXPLvl[8] = 4400
      • Set MaxEXPLvl[9] = 5400
This is the init trigger where I set the vars needing to be set beforehand. In case you can't figure out the formatting of the variable, "MaxEXPLvl" is "Max EXP of Level _" Where index is the level that needs the assigned EXP to proceed.
  • EXP
    • Events
      • Time - Every 0.05 seconds of game time
    • Conditions
    • Actions
      • Set EXPLoop = (MB_loop[1] - 1)
        • Do Multiple ActionsFor each (Integer loopA) from 1 to EXPLoop, do (Actions)
          • Loop - Actions
            • Set EXPHero[loopA] = (Hero experience of Hero[loopA])
            • Set EXP_PercentHero[loopA] = ((EXPHero[loopA] / MaxEXPLvl[(Hero level of Hero[loopA])]) x 100)
            • Set EXP_Percent[loopA] = (String(EXP_PercentHero[loopA]))
This is the loop I have it set in, I've tried it without a loop, and it doesn't work. I get the EXPHero result, but not EXP_PercentHero result. I've tried making the percent var a Real variable, and it didn't work, either.


That's what I've done. I can't figure out why it does not work. Any suggestions or fixes?
 
Level 5
Joined
Nov 30, 2010
Messages
184
I'm using my iPhone to write this so a can't get a screen shot for you but the trigger will be like this:
Inialization:
Event: every 0.01 seconds
Action: pick a random unit in the playable map.
If picked unit equals a hero
Then add picked unit to Heroes (unit group variable).
Else do nothing
Set_exp_variables
Event: every 0.01 seconds
Action: pick a random unit in Heroes
Set exp_Current[player number of owner of picked unit] to current exp of picked unit.
If picked unit is level 1
Then set exp_Needed[player number of owner of picked unit] to 200
Else If picked unit is level 2
Then... (so on so on)
Exp_percentile
Event: every 0.01 seconds
Action: pick a random unit from Heroes
set exp_Percentile[player number of owner of picked unit] to 100/(exp_Needed[player number of owner of picked unit]/exp_Current[player number of owner of picked unit]).
 
Last edited:
Level 5
Joined
Nov 30, 2010
Messages
184
Sry but your triggers were I bit complicated and I could not understand it.
And I can't scroll with an iPhone =.= and could not read the last few parts of the trigger.
 
Last edited:
Level 12
Joined
Jan 30, 2009
Messages
1,067
No, they don't work, unfortunately.

It is a single-player Campaign, and there is anywhere between 1 and 5 heroes.

So I do NOT want it MPI. It just complicates things.

I set my heroes, no need for unit group, I have set exp needed, and I have the hero exp only thing not working is the formula. I understand you are on iphone, but please don't double, triple post.
 
Level 5
Joined
Nov 30, 2010
Messages
184
Try this:
Event: every 0.01 seconds
Action: set exp_Percentile to 100/(exp_Needed[level of hero[1]]/exp_Current[1])
This works on only one hero.
Duplicate this for your other hero by changing the indexes of the variables from 1 to 2,3,4,5
 
Last edited:
Level 5
Joined
Nov 30, 2010
Messages
184
I think the problem with your trigger is the loop part. I think it's broken. I can't be sure as I am not good at looping either but all the other actions seem alright. Did you try my second trigger yet? Also, the triggers should be a real type variable. Using integer for percentile might break the trigger.
And i'm using my computer now ^^
Does the Trigger work?
Please Reply
 
Last edited:
Level 12
Joined
Jan 30, 2009
Messages
1,067
I think the problem with your trigger is the loop part. I think it's broken. I can't be sure as I am not good at looping either but all the other actions seem alright. Did you try my second trigger yet? Also, the triggers should be a real type variable. Using integer for percentile might break the trigger.
And i'm using my computer now ^^
Does the Trigger work?
Please Reply

As I mentioned before, I tried it without the loop with the same results. I also did it as Real with no change. Neither seemed to work.

What's that?
Set EXPLoop = (MB_loop[1] - 1)

Sorry, I forgot to mention that. MB_Loop1 is Multiboard Loop 1 (number of rows). MB_loop[1]-1 is the number of heroes at any given time. This is going in a multiboard.

I told you the loop is broken ^^
Can I get some rep points?

Don't ask for rep. That is against the rules. Rep is earned. I was going to give you rep but you asked for it, so I shall not.
 
Level 37
Joined
Mar 6, 2006
Messages
9,240
( CurrentExp - MaxExp[HeroLvl] ) / ( MaxExp[HeroLvl + 1] - MaxExp[HeroLvl] ) * 100

EDIT: Use reals for the exp values, and convert the current exp to real. When you divide integers, they get "rounded down". 500 / 600 * 100 => 0, since 500/600 = 0,8333 andeverything after "," gets cut off for the next calculation.
 
Level 12
Joined
Jan 30, 2009
Messages
1,067
I'm confused where that roundabout calculation came from, but thank you, Maker.

So convert the integers to reals then do the calculations, or just convert all the vars to reals and then do the calcs?
 
Level 5
Joined
Nov 30, 2010
Messages
184
It's against the rules? Sorry I didn't know. I joined hive like a week ago and have not read through everything yet. =.=

Give rep to those who have helped you ^^
 
Level 12
Joined
Jan 30, 2009
Messages
1,067
Maker, your formula is wrong. That comes up as -66%!

Doesn't do me any good for it to come up as -66% :p

I'll try my original (calculable) formula.

EDIT: Oh. I see. The formula I had was wrong, I see now. That formula is giving the percentage of the TOTAL experience, not the EXP for that level. Maker, there was an error in your formula. It should have been:


  • ((HeroEXP - MaxEXP[HeroLvl - 1]) / (MaxEXP[HeroLvl + 1] - MaxEXP[HeroLvl])) * 100
  • So, if (at level 1; 0 exp), I pick up two Tomes of EXP (150 EXP ea). This brings me to 300 EXP. Which levels me to level 2, which is of 500 Exp.
  • By the above formula, I end up with the following equation:
  • ((300 - 200) / (900 - 500)) * 100 =
  • (100 / 400) * 100 =
  • .25 * 100 = 25 %
  • Where 300 is the current EXP, 200 is the EXP of the previous level, 900 is the EXP of the NEXT level, and 500 is the EXP of the CURRENT level. And 100, ofc to turn the decimal to percent value.[/hidden]
  • I measured (Yes, with a ruler!) the bar to verify this equation. It is indeed exactly 25% of the bar. Or, if it's off, it's so minute that I DON'T FREAKIN CARE!
  • EDIT2: Okay, apparently this equation does NOT work on Level 1. A simple If/Then/Else should relieve THAT.
  • EDIT3: Okay, the If/Then/Else DID fix that issue.
  • [B]Now, I would like to know if someone could come up with a Formula to find out what amount of EXP exactly the 1% is of a level. I've been brainstorming with others, and we can't figure it out. Once I figure this out, I can get an idea of what I need to make enemies worth experience-wise.[/B]
 
Last edited:
Level 37
Joined
Mar 6, 2006
Messages
9,240
Maker, your formula is wrong. That comes up as -66%!

Maker, there was an error in your formula. It should have been:

  • ((HeroEXP - MaxEXP[HeroLvl - 1]) / (MaxEXP[HeroLvl + 1] - MaxEXP[HeroLvl])) * 100
  • [/quote]
  • Actually my formula is correct and produces the same result. It's just that I was thinking that heroes start from level 1. The [1] in your array refers to how much the hero needs exp to level to lvl 2?
  • You should have
  • [1] = 0
  • [2] = Exp needed for lvl 2
  • [3] = Exp needed for lvl 3
  • ...
  • Then use my formula and then there's no need for IF/THEN/ELSE
  • [quote]
  • Now, I would like to know if someone could come up with a Formula to find out what amount of EXP exactly the 1% is of a level. I've been brainstorming with others, and we can't figure it out. Once I figure this out, I can get an idea of what I need to make enemies worth experience-wise.[/QUOTE]
  • (NextLevel - CurrentLevel) / 100
 
Level 5
Joined
Nov 30, 2010
Messages
184
Ok ok... I know it's wrong now... I'm new to hive and don't know that before... Further more, I keep seeing others do so so I thought it was alright. =.= please stop scolding me... If you like, I would make a public apology (if I knew what sub forum to put it in).

Wait a minute... I've already apologized to you. Sorry for posting. =.=
 
Level 12
Joined
Jan 30, 2009
Messages
1,067
Actually my formula is correct and produces the same result. It's just that I was thinking that heroes start from level 1. The [1] in your array refers to how much the hero needs exp to level to lvl 2?

You should have
[1] = 0
[2] = Exp needed for lvl 2
[3] = Exp needed for lvl 3
...

Then use my formula and then there's no need for IF/THEN/ELSE



(NextLevel - CurrentLevel) / 100

Oh. I see. Different formatting. Lol. Okay, well, the way I have it set up makes more sense to me (and it is already set up) so I will keep it.

(and next - current) /100...lol... I feel silly. My brain was not working last night, sickness stops my thinking capabilities. =\
 
Now Being Lazy as I am and only being able to understand the way I code things, Im not entirely shure if what Im about to suggest would help But nevertheless;
I feel the best way to approach all your problems is to make a custom Experience System (Which might be what you have, Idk). Such as:

Variables:
CurrentXP: The Xp Currently had by hero
XpPerKill: The amount of Exp the hero gos up with each Kill
XPLevelBase: The amount of XP it takes to get to level 2
XPLevelIncrement: The amount of Extra Xp that gets added to LevelBase to Level up past 2

Event:
A Unit Dies

Condition:
Owner of (Killing Unit) = (User, Player 1, Etc.)

Event:
Set (CurrentXP) = Arithmatic[CurrentXP + XPPerKill]

...Ok the rest I realized wasn't going to work and I'm unshure how It could work for your needs, but you get the idea, I hope I helped but, I do realize I probably didn't. and for that I do Apologize.
 
Level 12
Joined
Jan 30, 2009
Messages
1,067
Yeah, sorry, man. I don't need anything as fancy as a completely custom experience system.

As far as I know, anyway. >.>

I do like the experience bar on the heroes. :)

Thanks for trying to help though.
 
Status
Not open for further replies.
Top