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

[Mapping] Item Level Requirement

Level 9
Joined
Sep 15, 2012
Messages
311
Introduction

This is my very first Tutorial. While I think it's but a little pebble in comparison with other Tutorials which are the mountains, I still wanted to help, as a small tribute to the numerous people that helped me in my few years, here in HiveWorkshop.

I really hope it's a useful addition, even a small one.

Months ago, while searching information on the matter I noticed that many people had problem with setting a Level Requirement for items sold in shops.
While it is possible to link an item requirement to a Town Hall level, you can't link them to a hero.

The simple solution to this problem was creating a trigger that checks the level of a Hero and if the conditions were not met, the item would be removed. Something like this:

  • Events
    • Unit - A unit Acquires an item
    • Conditions
      • (Item-type of (Item being manipulated)) Equal to Claws of Attack +15
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Hero level of (Hero manipulating item)) Less than 5
        • Then - Actions
          • Item - Remove (Item being manipulated)
        • Else - Actions
Then you have to remember to add a text to each item's descritpion, to warn the player of the level requirement and to refound its gold cost, so the player doesn't waste the money.
Long story short, the item is clickable and purchasable; we just use the triggers to manualy remove if the requirements are not met.

There is actually a way to set a level requirement for items, so the player can't click to purchase the item until he meets the level requirements. It still uses triggers but it's more handy and less confusing to the player trying to buy the item.

Let's do an example. The merchant has the super cool item Mace of Demigods but I don't want my hero to be able to buy it until he is level 5.
He also has an even cooler item Mace of Gods but I don't want my hero to be able to buy it until he is level 10.


What we need

For my example I will use:

1) An Integer named HeroLvL
2) A fake Upgrade named Hero Level.
3) Our two items.

How we do it

First we set our variable:
Open your Trigger Editor and click Variables.
Click New Variable and name it HeroLvL. On variable type, chose Integer.

Now open your Object Editor and go to Upgrades.
Click New Custom Upgrade and pick a random. (for my example I used Glyph of Fortification upgrade, which is in Neutral race)
Remove Art Effects, set bonuses to 0, delete requirements and generaly everything you need to do to make the Upgrade give nothing. The only thing you can leave untouched is an icon but this is not required either.

Then change the following:
Go to Level 1 - Text Name and type Hero Level
Go to Level 2 - Text Name and type Hero Level 5
Go to Level 3 - Text Name and type Hero Level 10

What we just did: Our fake Upgrade has 3 levels. The first is the default level, while the other two will be used when our hero reaches level 5 and 10 respectively.

Open your Trigger Editor again and click New Trigger. I named it LvL Increase and did the following:
  • LvL Increase
    • Events
      • Unit - A unit owned by Player 1 (Red) Gains a level
    • Conditions
    • Actions
      • Set HeroLvL = (HeroLvL + 1.00)
Everytime our Hero gains a level, our previously created Integer, named HeroLvL will go up by 1.

Click New Trigger. I named it LvL5 and did the following:
  • LvL5
    • Events
      • Game - HeroLvL becomes Equal to 5.00
    • Conditions
    • Actions
      • Player - Set the current research level of Hero Level to 2 for Player 5 (Yellow)
This trigger makes our fake Upgrade, named Hero Level, to go up by one level, when our Hero is level 5.

Note that I used Player 5 for my example because that was the owner of the shop that had the items I wanted to buy. You can change that according to your map.

Click New Trigger. I named it LvL10 and did the following:
  • LvL10
    • Events
      • Game - HeroLvL becomes Equal to 10.00
    • Conditions
    • Actions
      • Player - Set the current research level of Hero Level to 3 for Player 5 (Yellow)
This trigger makes our fake Upgrade, named Hero Level, to go up by one level, when our Hero is level 10.

Note that I used Player 5 for my example because that was the owner of the shop that had the items I wanted to buy. You can change that according to your map.

Then I open the Object Editor and find my items.
First Mace of the Demigods.
Go to Techtree - Requirements and change to Hero Level (the fake Upgrade)
Go to Techtree - Levels and change to 2

We just linked the item in our fake upgrade, named Hero Level.
When my Hero reaches level 5, the trigger we previously created will upgrade this fake upgrade to level 2 which is the level requirement we used in Techtree - Levels. Our item will then become clickable and available for buying.

Then we do the same for the Mace of the Gods.
Go to Techtree - Requirements and change to Hero Level (the fake Upgrade)
Go to Techtree - Levels and change to 3

We just linked the item in our fake upgrade, named Hero Level.
When my Hero reaches level 10, the trigger we previously created will upgrade this fake upgrade to level 3 which is the level requirement we used in Techtree - Levels. Our item will then become clickable and available for buying.


YOU ARE READY!
 
Last edited:
Level 14
Joined
Nov 17, 2010
Messages
1,265
This looks like the right place for it to me. I like this system. A much better alternative to the first method you talked about.
 
Top