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

[GUI] Basic Modifiable Item Bonuses

Level 4
Joined
Jan 19, 2012
Messages
52
What is this guide about/why would I need this?
This guide is about giving items of the same type different bonuses. In other words, it teaches you how to create items with different bonuses without creating a ton of items.

This system might be useful for people who want to create material-based crafting systems but do not want to create a ton of items for each of the possible combinations of materials.

However, I will not teach you how to create a crafting system in this guide.
So how do I do this?
First of all, you should create a Hashtable. If you do not know how to create a Hashtable, just use this code:

  • Initialization
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Hashtable - Create a hashtable
      • Set Hashtable = (Last created hashtable)
After that, you will want to save the bonuses of the items to the hashtable by adding to the previous trigger. The trigger below is how your trigger should look like after you are finished with it.

  • Initialization
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Hashtable - Create a hashtable
      • Set Hashtable = (Last created hashtable)
      • -------- Below actions not really needed --------
      • Set tempPoint = (Center of (Playable map area))
      • Item - Create Enchanted Gemstone at (tempPoint)
      • Custom script: call removeLocation(tempPoint)
      • -------- Above actions not really needed --------
      • Hashtable - Save 10 as (Key Armor Bonus) of (Key (Last created item)) in Hashtable
Now you want to create a trigger that adds the bonuses of the item to the hero when he pick the item and another trigger that removes the bonuses of the item when the hero drops the item.

  • Item Add Bonuses
    • Events
      • Unit - A unit Acquires an item
    • Conditions
    • Actions
      • Set tempUnit = (Triggering unit)
      • Unit - Add Item Bonus Armor (+X) to (tempUnit)
      • Unit - Set level of Item Bonus Armor (+X) for (tempUnit) to ((Level of Item Bonus Armor (+X) for (tempUnit)) + (Load (Key Armor Bonus) of (Key (Item being manipulated)) from Hashtable))
  • Item Remove Bonuses
    • Events
      • Unit - A unit Loses an item
    • Conditions
    • Actions
      • Set tempUnit = (Triggering unit)
      • Unit - Set level of Item Bonus Armor (+X) for (tempUnit) to ((Level of Item Bonus Armor (+X) for (tempUnit)) - (Load (Key Armor Bonus) of (Key (Item being manipulated)) from Hashtable))
Now all you have to do is create the 'Item Bonus' ability (Set the level 1 value to 0, increase the value by 1 every level and set the max level to 100) and you are done!
 

Attachments

  • Custom Item Bonuses.w3x
    18.1 KB · Views: 111
Last edited:

Chaosy

Tutorial Reviewer
Level 40
Joined
Jun 9, 2011
Messages
13,182
Merge the two hashtable triggers. (the ones at init)

Check if level of the ability already exist before adding it. Aka checking if level is greater than 0

Instead of using "your item" as a variable you should use real examples since using variables in a hashtable is impossible unless you do it in JASS. Using key(your_item) wont work, in GUI wc3 only supports stuff like Key(Item Being Manipulated)

Don't use a loop and increase the level by 1 X times, you should save the current level of the ability and save it into the hashtable.

also use a variable for triggering unit.

Overall it can be useful but I think it's kinda complicated compared to how simple the feature actually is. I might show the triggers myself if I am bored enough later on today.
 
Last edited:
Level 4
Joined
Jan 19, 2012
Messages
52
Merge the two hashtable triggers. (the ones at init)

Check if level of the ability already exist before adding it. Aka checking if level is greater than 0

Instead of using "your item" as a variable you should use real examples since using variables in a hashtable is impossible unless you do it in JASS. Using key(your_item) wont work, in GUI wc3 only supports stuff like Key(Item Being Manipulated)

Don't use a loop and increase the level by 1 X times, you should save the current level of the ability and save it into the hashtable.

also use a variable for triggering unit.

Overall it can be useful but I think it's kinda complicated compared to how simple the feature actually is. I might show the triggers myself if I am bored enough later on today.

#1: They are the same trigger at different stages of completion.

#2: That will remove the MUI aspect of it.

#3: Done.

#4: Done.

#5: Why? Does Triggering Unit leak now? I won't compromise MUI for a neater code.

Oh wait. I forgot WCIII is not multithreaded.
 

Chaosy

Tutorial Reviewer
Level 40
Joined
Jun 9, 2011
Messages
13,182
More like the processor can handle variables faster. It's no different from real programming languages.

If you want a more indeph explaination you can just head over to google.
>Link<

Edit:
#2: That will remove the MUI aspect of it.

No. But the thing is, your trigger in the tutorial made no sense. It seems like you're using a variable as a key which should be impossible. However in the actual map you use last created item, which makes total sense. The key was called bonus something, but it's updated now, so I am happy :p
 
Last edited:
But your method is limited by +100. I mean, you can make another ability, but it isn't too efficient. You should use a binary system, e.g. +1, +2, +4, +8, +16, +32, etc. That way you can form any number with only a combination of a few abilities! For example, if you want to support any number up to 100, you only need to have 7 abilities. (1, 2, 4, 8, 16, 32, 64) This may seem like a lot, but it actually creates a much lighter load time than a single ability with 100 levels. Plus, I think widgetizer historically has had some issues with abilities with levels > 4.
 
Top