• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

How to create an artificial level-up system

Level 4
Joined
Jan 19, 2012
Messages
52
How to create a level-up system

Why create a level-up system?

A level-up system would let non-heroes level up. It is very useful to make units stronger after every kill. It allows you to let the player create "veterans", who are units who deal higher damage due to the unit's experience in combat. Popular maps who use this system include YouTD (towers) and Werewolf: Transylvania (non-hero veteran bonus).

So how do I make it?

First, you need to create a hashtable.

  • Hashtable Creation
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Hashtable - Create a hashtable
      • Set Level = (Last created hashtable)
Then, you need to create a trigger which increases the level of the unit every time it kills something.

  • Level Up System
    • Events
      • Unit - A unit Dies
    • Conditions
    • Actions
      • Hashtable - Save ((Load (Key (Killing unit)) of 1 from Level) + 1) as (Key (Killing unit)) of 1 in Level
Replace 1 with the name of a spell if you are leveling up a spell.

If you feel like it, you can turn the system into a "kill X for rank" system, by adding these few lines to the end of the trigger.

  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • (Load (Key (Killing unit)) of 1 from Level) Equal to 50
    • Then - Actions
      • Hashtable - Save 5 as (Key (Killing unit)) of 1 in Rank
    • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Load (Key (Killing unit)) of 1 from Level) Equal to 29
        • Then - Actions
          • Hashtable - Save 4 as (Key (Killing unit)) of 1 in Rank
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Load (Key (Killing unit)) of 1 from Level) Equal to 28
            • Then - Actions
              • Hashtable - Save 3 as (Key (Killing unit)) of 1 in Rank
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Load (Key (Killing unit)) of 1 from Level) Equal to 3
                • Then - Actions
                  • Hashtable - Save 2 as (Key (Killing unit)) of 1 in Rank
                • Else - Actions
                  • -------- etc... --------
NOTE: The if/then/elses for the higher ranks be executed first, or it will bug!

Also, add these lines to the end of Hashtable Creation.

  • Hashtable - Create a hashtable
  • Set Rank = (Last created hashtable)
The final Level Up System trigger will look like this.

  • Level Up System
    • Events
      • Unit - A unit Dies
    • Conditions
    • Actions
      • Hashtable - Save ((Load (Key (Killing unit)) of 1 from Level) + 1) as (Key (Killing unit)) of 1 in Level
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Load (Key (Killing unit)) of 1 from Level) Equal to 50
        • Then - Actions
          • Hashtable - Save 5 as (Key (Killing unit)) of 1 in Rank
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Load (Key (Killing unit)) of 1 from Level) Equal to 29
            • Then - Actions
              • Hashtable - Save 4 as (Key (Killing unit)) of 1 in Rank
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Load (Key (Killing unit)) of 1 from Level) Equal to 28
                • Then - Actions
                  • Hashtable - Save 3 as (Key (Killing unit)) of 1 in Rank
                • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Load (Key (Killing unit)) of 1 from Level) Equal to 3
                    • Then - Actions
                      • Hashtable - Save 2 as (Key (Killing unit)) of 1 in Rank
                    • Else - Actions
                      • -------- etc... --------
Now, how do I actually use this system?

You can use it for a variety of things, like increasing the damage of a unit for every level or rank he has, or increasing the spell potency, or simply adding more abilities. Just use this segment of a line to load levels,

  • ((Load (key([INSERT UNIT HERE])))) of 1 from Level)
and this to load ranks.

  • ((Load (key([INSERT UNIT HERE])))) of 1 from Rank)
 

Attachments

  • Levelupsystemtutorial.w3x
    21.7 KB · Views: 298
Last edited:
Level 4
Joined
Jan 19, 2012
Messages
52
Hope it hadn't been done before! If it had been done before, I will feel so stupid for going all the way to the Hashtables page in hope that hashtables can do this properly instead of just going to the tutorial page.

Also, this post is not part of the tutorial.
 
since you only use one childkey (which is 1), this can be done using an array instead of hashtable... they work much faster and are also easier to deal with...

also those If-then-elses are better off when nested [put the next if-then on the else of the higher one]... because right now, if a unit is greater than rank 50, it will also trigger the actions for >12,>10,>5 so in the end, the rank 50 unit will have a value of 2 instead of 5...
 
Level 4
Joined
Jan 19, 2012
Messages
52
Arrays cap at 8192. The cap of units are 1080x12=12960, which is bigger than 8192.

I don't believe that the number of keys in a hashtable caps.

Furthermore, I want to go to extremely great lengths to make the system both GUI and MUI, which means no 8192-capping arrays.
 
Last edited:
it's just that you can only have a limited hashtable amount (256), a pretty big number...

8192 is a really huge amount already, remember that this is a level up system which uses 1 instance per unit. I'm sure your map will most probably lag so bad or get a fatal error before you reach 8192 units to use this system on the map... of course you should also be using recycling if you do that to free up spaces occupied by dead units... :)

anyway, lots of systems/spells here cap at 8192 but they are still considered as MUI...

you can use game caches too if you really want to avoid caps I think...
 
Level 19
Joined
Aug 8, 2007
Messages
2,765
why game caches? if i remember correctly they wont function properly on multiplayer. either use hashtables or arrays.

arrays wont cap out because the graphical limit for units is closer to 6 grand even if the solid is near 12 grand

the max for physical hashtables is 256, not hashtable keys. keys are infinite
 
Top