• 🏆 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!

Stats when lvling up

Status
Not open for further replies.
Level 3
Joined
May 24, 2008
Messages
53
Hi everyone
I have a little problem with a trigger here...
The trigger is supposed to give a random number of str between 8 and 12
also add 3 to agi if the hero is lvl below 35, and 2 if not...
The thing is that in the map, some units give much more exp than the required for the lvl of the hero...
assuming that the hero can kill that unit, it should lvl up like 2 or 3 lvls...
when this happens i need to do the same process for the number of lvls the hero gains..

i've come up with this, that works only fine for a 1 lvl gain...
if the hero gains 2, 3, 50 lvls it doesn't work...

hope you can give me a hand
  • Stats del hero
    • Events
      • Unit - A unit Gains a level
    • Conditions
      • ((Triggering unit) is A Hero) Equal to True
    • Actions
      • Set level = (Hero level of (Leveling Hero))
      • Unit - Set life of (Leveling Hero) to 100.00%
      • Hero - Modify Strength of (Leveling Hero): Add (Random integer number between 8 and 12)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Hero level of (Triggering unit)) Less than or equal to 35
        • Then - Actions
          • Hero - Modify Agility of (Leveling Hero): Add 3
        • Else - Actions
          • Hero - Modify Agility of (Leveling Hero): Add 2
      • Set level = (Hero level of (Triggering unit))
Thanks!
 
Level 19
Joined
Aug 8, 2007
Messages
2,765
Ya thats a problem with alot of people. What i do to prevent that is i put level requirements on areas(one of the reasons ppl do that).

And ya what sole said. If you dont rly want to add lvl reqs for areas than give them less exp + or make levels harder to get.
 
Level 3
Joined
May 24, 2008
Messages
53
i'm trying to make the map more like the real game i can..
in the real game if you kill a unit that gives idk, 500 exp and your lvl and the next, both need a total of 300, you would get 2 lvls and 200 exp...
and get the "stats" right...
but idk how to do this here U.U
 
Level 3
Joined
May 24, 2008
Messages
53
What about using a point-value reference?
i start all heroes point-values on 1
when they lvlup, add 1 to the point-value of the hero..
check if point-value is greater than HEROLVL
in that case do something like this

Hero - Modify Strength of (Leveling Hero): Add (((Random integer number between 8 and 12) x ((Hero level of (Leveling Hero)) - (Point-value of (Leveling Hero)))) - (Point-value of (Leveling Hero)))
 
Level 19
Joined
Aug 8, 2007
Messages
2,765
Ok let me redo this whole post. give me a second.

JASS:
let him do it :)

Gui will take a while.
 
Last edited:
Level 12
Joined
Apr 15, 2008
Messages
1,063
  • Stats hero
    • Events
      • Unit - A unit Gains a level
    • Conditions
    • Actions
      • Unit - Set life of (Triggering unit) to 100.00%
      • For each (Integer A) from 1 to ((Hero level of (Triggering unit)) - Level[(Key (Triggering unit))]), do (Actions)
        • Loop - Actions
          • Hero - Modify Strength of (Triggering unit): Add (Random integer number between 8 and 12)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Level[(Key (Triggering unit))] + (Integer A)) Less than or equal to 35
            • Then - Actions
              • Hero - Modify Agility of (Triggering unit): Add 3
            • Else - Actions
              • Hero - Modify Agility of (Triggering unit): Add 2
      • Set Level[(Key (Triggering unit))] = (Hero level of (Triggering unit))
This is a simple solution using global integer array "Level", where levels of all heroes are kept, so that when leveling up, you can easily find out how many levels the hero got. I use ( Key (Triggering unit) ) as the index of array, because you haven't specified whether you need it to work for 1 hero per player or more (if only for one, you can use player number).
You will have to set Level[Key (unit)] to 1 when spawning the hero in order to get this to work.
 
Level 19
Joined
Aug 8, 2007
Messages
2,765
Is it possible to obtain a previous level>?

Edit: im out, no idea why im even doing this :s i got bored
 
Level 3
Joined
May 24, 2008
Messages
53
<nothing here anymore>

MORT:
What do you mean with player number?
i need it for 1 hero per player..
i'm trying to find out how would that be..
haven't used "KEY" yet so no idea on how to do that.part..
 
Level 19
Joined
Aug 8, 2007
Messages
2,765
1. look at the guy inbetween my post's answer.

2. im not setting herored = level of leveling unit. Im setting herored = hero red + 1. If you obtain too many levels, it will keep adding to herored untill herored = level of triggering unit.

3. This is so much easier than we are making it.

Hero obtains a level

Set strength of leveling unit to (level of triggering unit) x (random integer number between 8 and 12) + whatever he started with.

One sec lemme look at the main thing

Edit : If (hero level) equal to or greater than 35 than add (level of triggering unit) x 3 + whatever started with. Else than (do same thing except x3 = x2)
 
Level 3
Joined
May 24, 2008
Messages
53
1. look at the guy inbetween my post's answer.

2. im not setting herored = level of leveling unit. Im setting herored = hero red + 1. If you obtain too many levels, it will keep adding to herored untill herored = level of triggering unit.

3. This is so much easier than we are making it.

Hero obtains a level

Set strength of leveling unit to (level of triggering unit) x (random integer number between 8 and 12) + whatever he started with.

One sec lemme look at the main thing

Edit : If (hero level) equal to or greater than 35 than add (level of triggering unit) x 3 + whatever started with. Else than (do same thing except x3 = x2)

yep but "whatever he started with" is a random number between 15 and 22
(also it's different for different heroes)
also if i multiply herolvl * number between 8 and 12
the number would be chosen just 1 time.. and be multiplied by the herolvl..
the loop thing would work better...
but idk what Mort means with (key (Player number))
 
Level 19
Joined
Aug 8, 2007
Messages
2,765
I tested the loop thing. It gave me 5000 strength.

W.E wont let me do what this trigger needs. I cant loop into a IF/THEN/ELSE trigger... one sec.

God, W.E wont do the required steps to do this. Whenever i start going on one trigger, it jerks me out and prevents me from doing it. Sry i cant help u on this one. Anything ive posted so far is worthless. Its all broke.

And for the record, i dont know crap about JASS aswell :)
 
Level 19
Joined
Feb 25, 2009
Messages
2,004
  • Blah
    • Events
      • Unit - A unit Gains a level
    • Conditions
      • ((Triggering unit) is A Hero) Equal to True
    • Actions
      • Set TempInt = (Random integer number between 8 and 12)
      • Hero - Modify Strength of (Triggering unit): Add TempInt
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Hero level of (Triggering unit)) Less than or equal to 35
        • Then - Actions
          • Hero - Modify Agility of (Triggering unit): Add 3
        • Else - Actions
          • Hero - Modify Agility of (Triggering unit): Add 2
Gaining multiple levels at one time, won't make it work, since the event is (Gains a level) not levels.

What about using a point-value reference?
i start all heroes point-values on 1
when they lvlup, add 1 to the point-value of the hero..
check if point-value is greater than HEROLVL
in that case do something like this

Hero - Modify Strength of (Leveling Hero): Add (((Random integer number between 8 and 12) x ((Hero level of (Leveling Hero)) - (Point-value of (Leveling Hero)))) - (Point-value of (Leveling Hero)))

Point-value cannot be edit with triggers.
 
Level 3
Joined
May 24, 2008
Messages
53
  • Blah
    • Events
      • Unit - A unit Gains a level
    • Conditions
      • ((Triggering unit) is A Hero) Equal to True
    • Actions
      • Set TempInt = (Random integer number between 8 and 12)
      • Hero - Modify Strength of (Triggering unit): Add TempInt
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Hero level of (Triggering unit)) Less than or equal to 35
        • Then - Actions
          • Hero - Modify Agility of (Triggering unit): Add 3
        • Else - Actions
          • Hero - Modify Agility of (Triggering unit): Add 2
Gaining multiple levels at one time, won't make it work, since the event is (Gains a level) not levels.

well, there is no such event as: Hero gain LEVELS
but there's still the posibility to gain more than 1 lvl, after killing a unit or finishing a quest..
anyways i appreciate you took the time of doing the trigger :)

ILLIDANS911:
i don't know much JASS, but i belive i can change variables xD
shure, take your time :p
 
Level 19
Joined
Aug 8, 2007
Messages
2,765
Ya i got nothin. Id suggest my thing a couple posts up about setting the stats instead of adding. Id just do something simple like put each stat at 10. Thats bout the only way u can do it w/o me spending 2 hrs. making a HUGE trigger for one function.

Afk + working on Feathers of Angels RPG.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,202
Simple solution, have a variable store what level the hero currently is and default it to 1 as all heroes start at level 1.
Then on level up, you get the heroes new level and subtract it by the previous level.

Congratulations, you now have the number of levels the hero gained. So what do you do with that number? Well you plug it into a loop so you loop for that many times the hero level up actions. Ofcourse if you are really smart you design the loop so that the number being manipulated is the heroes level and each loop you add one to it, that way your level up bonouses will be right as well.

If MUI is a problem, use hashtables and store an integer representing the hero level to the hero (make sure to remove it before removing the hero to prevent leaks).

I can not stress it enough, you look at the problem and break it down into basic elements until you get a solution.

i've come up with this, that works only fine for a 1 lvl gain...
if the hero gains 2, 3, 50 lvls it doesn't work...
This imediatly said in my head, "ah, I need a loop as the event will fire once yet I want a variable number of levels".

Next I thought, "but to do that I will need to know from what level the hero has leveled up, thus an integer variable is needed to store that information".
Next you do not need a degree in computer science to see that you can combine the 2 together to obtain a loop with the functionality you are after.
 
Level 3
Joined
May 24, 2008
Messages
53
excelent, i've thought about that when i was having dinner, but didn't really know how to do it
it has worked so far, so problem solved
thanks a lot!

+r
 
Level 12
Joined
Apr 15, 2008
Messages
1,063
Key: it's the "Hashtable - Handle ID" function. It returns an integer, which is unique for each handle (unit, unit group, player, special effect... these are all handles), and here I used it as index of the array. Since you have 1 hero per player, you can replace the "Key (triggering unit)" with "Player number of (Owner of (Triggering unit))".
Also, you need to initialize the array to 1, or what level heroes start on, so they won't get too much str on first level-up.
 
Status
Not open for further replies.
Top