Items - Basics

Tutorial By Tinki3

Items & Item Triggers

This tutorial was written for people who want to fill their knowledge from alot of things about items and using item triggers. I will be covering things relating to items in the Object Editor, item triggers in general, and also item recipes specifically, for all those people who wanted to know how to create them.

Please note that to be able to understand the full concepts of this tutorial, you will need some decent knowledge in GUI of how to use variables, custom scripts, and have some basic understanding of how to use the Items tab of the Object Editor.

Let's begin!


Contents

Chapter 1
[LIST]
1. Creating Items
2. Removing Items
3. Hiding/Showing Items
4. Moving Items
5. Setting the life of Items
6. Setting the charges remaining of Items
7. Making Items invulnerable/vulnerable
8. Making Items pawnable/unpawnable
9. Making Items droppable/undroppable
10. Making Items Drop/Stay with heroes upon death
11. Changing the ownership of Items
12. Setting the custom value of Items
13. Picking every Item in a region & doing multiple actions
14. Making an Item Recipe

Chapter 2

15. Item Classifications
16. Item Abilities
17. Items in the Object Editor

[/LIST]



-------------------------------------------------------------------------------

Chapter 1

1. Creating Items

What could this function be used for?
-Creating a key to open a gate
-Creating an item when a hero uses an ability


Lets start our first item trigger, using the simple event "Unit enters region" and the basic action "Item - Create":
Creating Items 1 Events Unit - A unit enters Region <gen> Conditions Actions Set TempPoint = (Center of Region <gen>) Item - Create Gate Key at TempPoint Custom script: call RemoveLocation(udg_TempPoint)

Next, we will be using the following trigger to understand how to create an Item at a point after a hero uses an ability (note that we want to use a "clean" trigger by preventing memory leaks. You can make the ability specific by adding in an ability comparison condition):
Creating Items 2 Events Unit - A unit Starts the effect of an ability Conditions Actions Set TempPoint = (Position of (Triggering unit)) Item - Create Claws of Attack +15 at TempPoint Custom script: call RemoveLocation(udg_TempPoint)

For our next trigger, we will be creating an item at the position of a dead destructible.
This trigger could be useful for a custom melee map that when a destructible dies, players can acquire the destructible's soul and sell it for 50 gold or something:
Creating Items 3 Events Time - Every 1.00 seconds of game time Conditions Actions Destructible - Pick every destructible in (Playable map area) and do (Actions) Loop - Actions If (All Conditions are True) then do (Then Actions) else do (Else Actions) If - Conditions ((Picked destructible) is dead) Equal to True Then - Actions Set TempPoint = (Position of (Picked destructible)) Item - Create Destructible's Soul at TempPoint Custom script: call RemoveLocation(udg_TempPoint) Destructible - Remove (Picked destructible) //We remove the dest. so it can't have more than 1 item created on it Else - Actions

Other possible item creations:
Creating Items 4 Events Time - RandomItemTimer expires Conditions Actions For each (Integer A) from 1 to 2, do (Actions) Loop - Actions Wait 2.00 seconds Set RandomPoint = (Random point in (Playable map area)) Item - Create Orb of Frost at RandomPoint Custom script: call RemoveLocation(udg_RandomPoint)
Creates 2 Orbs of Frost at random points on the map after a timer has expired ^
Note that you might want to specify these points inside a large region that doesn't contain places that
make the items impossible to reach.
Creating Items 5 Events Time - RandomItemTimer expires Conditions Actions Custom script: set bj_wantDestroyGroup = true Unit Group - Pick every unit in (Units in (Playable map area) matching (((Matching unit) is A Hero) Equal to True)) and do (Actions) Loop - Actions Hero - Create Orb of Frost and give it to (Picked unit)
Creates an Orb of Frost for every hero on the map and gives it to them after a timer has expired ^


-------------------------------------------------------------------------------

2. Removing Items

What could this function be used for?
-Removing items so units can't acquire them unless they do some actions to make it so they can
-Removing specific items


We need to start here, using the following trigger to make it so a unit can NOT acquire an item (can be specific),
unless they are a certain level and they are a certain type of hero (melee or ranged in this case):
Removing Items 1 Events Unit - A unit Acquires an item Conditions (Item-type of (Item being manipulated)) Equal to Orb of Frost Actions If (All Conditions are True) then do (Then Actions) else do (Else Actions) If - Conditions ((Triggering unit) is A melee attacker) Equal to True Then - Actions Hero - Drop (Item being manipulated) from (Triggering unit) Game - Display to (All players matching ((Owner of (Triggering unit)) Equal to (Owner of (Triggering unit)))) for 5.00 seconds the text: Only ranged heros c... Else - Actions If (All Conditions are True) then do (Then Actions) else do (Else Actions) If - Conditions (Level of (Triggering unit)) Greater than or Equal to 6 and ((Triggering unit) is A ranged attacker) Equal to True Then - Actions //If the level and type of the trig unit is of the conds above, we don't do anything to them, as they are of satisfaction Else - Actions Hero - Drop (Item being manipulated) from (Triggering unit) Game - Display to (All players matching ((Owner of (Triggering unit)) Equal to (Owner of (Triggering unit)))) for 5.00 seconds the text: You are not a high ...
The above trigger is fired when a hero acquired an Orb of Frost.
If the hero is a:
-Ranged attacker
and
-Level of 6 or greater,

We don't remove the item from them.

Else if the hero is a:
-Melee attacker
or
-Level of less then 6,

We remove the item from them, as they don't meet the conditions of the trigger.

For our next trigger, we are going to make it so that an item is removed from the game
(this is just a simple version of the previous trigger):
Removing Items 2 Events Unit - A unit Acquires an item Conditions (Item-type of (Item being manipulated)) Equal to Orb of Frost Actions Item - Remove (Item being manipulated)
Not much point to the above trigger, but it gives you an idea none the less ^

Other possible item removal triggers:

This one is quite handy if a group of players is going to face a boss and they are moved to a region and
are not allowed to use any items aganist it for some reason (ie, to make the situation harder).
Note that this trigger would only really be useful if the game ends after the boss dies, as the heroes would not get their items back:
Removing Items 3 Events Unit - A unit enters Region <gen> Conditions ((Triggering unit) is A Hero) Equal to True Actions For each (Integer A) from 1 to 6, do (Actions) Loop - Actions Item - Remove (Item carried by (Triggering unit) in slot (Integer A))


-------------------------------------------------------------------------------

3. Hiding/Showing Items

What could this function be used for?
-Hiding keys for gates and then unhiding them after a unit enters a region


Let's use the "Map initialization" event to start off, then we are going to use the hide item function multiple times to hide all 3 of some random gate keys. After each key is created, we need to store that created item into a variable array, so we can reference it for later use, if need be.
Hiding or Showing Items 1 Events Map initialization Conditions Actions Item - Create Gate Key at A Set LastCreatedItem[1] = (Last created item) Item - Create Gate Key at B Set LastCreatedItem[2] = (Last created item) Item - Create Gate Key at C Set LastCreatedItem[3] = (Last created item)

And now let's unhide each key after a unit enters A, B, or C:
Unhide Keys Events Unit - A unit enters A <gen> Unit - A unit enters B <gen> Unit - A unit enters C <gen> Conditions ((Triggering unit) is A Hero) Equal to True Actions If (All Conditions are True) then do (Then Actions) else do (Else Actions) If - Conditions (A <gen> contains (Triggering unit)) Equal to True //If the trig unit is in region A, LCI[1] will be shown Then - Actions Item - Show LastCreatedItem[1] Else - Actions If (All Conditions are True) then do (Then Actions) else do (Else Actions) If - Conditions (B <gen> contains (Triggering unit)) Equal to True //If the trig unit is in region B, LCI[2] will be shown Then - Actions Item - Show LastCreatedItem[2] Else - Actions If (All Conditions are True) then do (Then Actions) else do (Else Actions) If - Conditions (C <gen> contains (Triggering unit)) Equal to True //If the trig unit is in region C, LCI[3] will be shown Then - Actions Item - Show LastCreatedItem[3] Else - Actions


-------------------------------------------------------------------------------

4. Moving Items

What could this function be used for?
-Moving an item to specific points (obviously). I have whipped up a few triggers for this function to show people what things it is capable of.


In this first trigger, I came up with an idea of the item "moving" around continuously
in a region just to make it harder to acquire by a unit (quite harsh):
Moving Items 1 Events Time - Every 1.00 seconds of game time Conditions Actions Set TempPoint = (Random point in Region <gen>) Item - Move Orb of Frost 0003 <gen> to TempPoint Custom script: call RemoveLocation(udg_TempPoint)

This next trigger will move the Orb of Frost from its current location offset by 10, towards an angle equal to its current hit points.
(quite creative IMO, but also extremely lame):
Moving Items 2 Events Time - Every 1.00 seconds of game time Conditions Actions Set TempPoint[1] = (Position of Orb of Frost 0003 <gen>) Set TempPoint[2] = TempPoint[1] offset by 10.00 towards (Current life of Orb of Frost 0003 <gen>) degrees Item - Move Orb of Frost 0003 <gen> to TempPoint[2] Custom script: call RemoveLocation(udg_TempPoint[1]) Custom script: call RemoveLocation(udg_TempPoint[2])

-------------------------------------------------------------------------------

5. Setting the Life of Items

Fact: the default life value for any item is 75

What could this function be used for?
-An idea would be to have a number of seconds to reach an item that opens the last gate so they can complete the game.
If the item dies, everyone loses (or something devastating should take place).


The following trigger will set the life of the Orb of Frost, to its current life - 1.
In other words, or, should I say, in other numbers, its life would end up looking like the following over 3 seconds:
74
73
72
...

Remember that if the item 'dies', we defeat all players:
Setting the Life of Items 1 Events Time - Every 1.00 seconds of game time Conditions Actions Item - Set life of Orb of Frost 0003 <gen> to ((Current life of Orb of Frost 0003 <gen>) - 1.00) If (All Conditions are True) then do (Then Actions) else do (Else Actions) If - Conditions (Current life of (Orb of Frost 0003 <gen>)) Equal to 0.00 Then - Actions For each (Integer A) from 1 to 12, do (Actions) Loop - Actions Game - Defeat (Player((Integer A))) with the message: Defeat! Else - Actions

-------------------------------------------------------------------------------

6. Setting the Charges Remaining of Items

Fact: Using a value of 0 for charges of an item will give the item unlimited charges, regardless if it was set through triggers,
or the Object Editor. Cooldown and mana are still used however.


What could this function be used for?
-Combining Charges of items into one inventory slot


The following trigger "combines" the charges of 2 items together to save inventory slots.
(very useful):
function Combine_Items_Conditions takes nothing returns boolean
    return GetItemCharges(GetManipulatedItem()) > 0 
endfunction

function Combine_Items_Actions takes nothing returns nothing
    local item NEWITEM = GetManipulatedItem()
    local unit OURUNIT = GetManipulatingUnit()
    local integer MAXIMUM = 15  //The max no. of charges allowed
    local integer ITEMCOUNT = 0
    local integer ITEMLOOP = 0
    local integer CHARGES = 0
    
    loop
        exitwhen ITEMLOOP > 6
        if GetItemTypeId(NEWITEM) == GetItemTypeId(UnitItemInSlot(OURUNIT, ITEMLOOP)) then
            if GetItemCharges(UnitItemInSlot(OURUNIT, ITEMLOOP)) + GetItemCharges(NEWITEM) <= MAXIMUM then
                if not (UnitItemInSlot(OURUNIT, ITEMLOOP) == NEWITEM) then                
                    set CHARGES = GetItemCharges(UnitItemInSlot(OURUNIT, ITEMLOOP)) + GetItemCharges(NEWITEM)
                    call SetItemCharges(UnitItemInSlot(OURUNIT, ITEMLOOP), CHARGES)
                    call RemoveItem(NEWITEM)
                    set ITEMLOOP = 7
                endif
            endif
        endif
        if (ITEMLOOP < 7) then
            set ITEMLOOP = ITEMLOOP + 1
        endif
    endloop

    set NEWITEM = null
    set OURUNIT = null
endfunction

function InitTrig_Combine_Items takes nothing returns nothing
    set gg_trg_Combine_Items = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Combine_Items, EVENT_PLAYER_UNIT_PICKUP_ITEM )
    call TriggerAddCondition( gg_trg_Combine_Items, Condition( function Combine_Items_Conditions ) )
    call TriggerAddAction( gg_trg_Combine_Items, function Combine_Items_Actions )
endfunction

To implement this trigger into your map, simply create a new trigger called "Combine Items",
then go to Edit > Convert to custom script > hit ok > delete everything > copy + paste the above trigger into your's.

Credits go to SD_Ryoko for the original trigger.


-------------------------------------------------------------------------------


7. Making Items invulnerable/vulnerable

Fact: Items are not damaged by non-triggered spells AT ALL, regardless if the ability can target items.

What could this function be used for?
-Making items invulnerable or vulnerable, of course! I havn't been too creative here, so you'd have to decide what you'd use it for.


How to make an item invulnerable (for novices):
Making Items Invulnerable Events Map initialization Conditions Actions Item - Make Orb of Frost 0003 <gen> Invulnerable
Makes the Orb of Frost invulnerable ^


-------------------------------------------------------------------------------

8. Making Items pawnable/unpawnable

Fact: A pawnable item can be sold to item vendors, whilst an unpawnable one cannot.

What could this function be used for?
-To make an extremely rare/powerfull item unpawnable


Pawnable/unpawnable triggers:
Making Items pawnable or unpawnable 1 Events Unit - A unit Acquires an item Conditions (Item-type of (Item being manipulated)) Equal to Orb of Frost Actions Item - Make Orb of Frost 0003 <gen> Unpawnable
Makes the Orb of Frost unpawnable; it can't be sold to item vendors ^

Making Items pawnable or unpawnable 2 Events Unit - A unit Acquires an item Conditions (Item-type of (Item being manipulated)) Equal to Orb of Frost Actions Item - Make Orb of Frost 0003 <gen> Pawnable
Makes the Orb of Frost pawnable; it can be sold to item vendors ^

-------------------------------------------------------------------------------

9. Making Items droppable/undroppable

What could this function be used for?
-Every played DotA? Well, that game has an item called 'Aghanims Scepter'. This item permanantly upgrades the ultimate ability of the holder.
The item is not droppable, for obvious reasons, one of which is because it would be too pesky changing the hero's ability around
every time the item was manipulated.


Here is a suitable trigger for that item trigger function idea:
Making Items droppable or undroppable 1 Events Unit - A unit Acquires an item Conditions (((Triggering unit) is A Hero) Equal to True) and ((Item-type of (Item being manipulated)) Equal to Aghanim's Scepter) Actions If (All Conditions are True) then do (Then Actions) else do (Else Actions) If - Conditions ((Unit-type of (Triggering unit)) Equal to Mountain King) and ((Level of Avatar for (Triggering unit)) Greater than 0) Then - Actions Unit - Remove Avatar from (Triggering unit) Unit - Add Avatar (Upgraded) to (Triggering unit) Else - Actions If (All Conditions are True) then do (Then Actions) else do (Else Actions) If - Conditions ((Unit-type of (Triggering unit)) Equal to Archmage) and ((Level of Mass Teleport for (Triggering unit)) Greater than 0) Then - Actions Unit - Remove Mass Teleport from (Triggering unit) Unit - Add Mass Teleport (Upgraded) to (Triggering unit) Else - Actions If (All Conditions are True) then do (Then Actions) else do (Else Actions) If - Conditions ((Unit-type of (Triggering unit)) Equal to Blood Mage) and ((Level of Phoenix for (Triggering unit)) Greater than 0) Then - Actions Unit - Remove Phoenix from (Triggering unit) Unit - Add Phoenix (Upgraded) to (Triggering unit) Else - Actions
The above trigger basically checks what type of hero/unit is manipulating the upgrader item,
and if that specific hero's ultimate is learned.

And, if that ultimate was learned, it was removed, and the upgraded ultimate was added to the hero.


-------------------------------------------------------------------------------

10. Making Items Drop/Stay with heroes upon death

What could this function be used for?
-Like in DotA, an ultra item like the Divine Rapier that gives you +250 damage is so powerfull, that it drops upon death because otherwise your hero could go on an unstoppable rampage.


I have made a trigger for this function below:
Making Items Drop from heroes upon death Events Unit - A unit Acquires an item Conditions (Item-type of (Item being manipulated)) Equal to Divine Rapier Actions Item - Make (Item being manipulated) Drop from Heroes upon death
This can also be done via Object Editor.


-------------------------------------------------------------------------------

11. Changing the ownership of Items

What could this function be used for?
-This function doesn't do much. It will usually only change the colour of the item.


<If anyone discovers something new for this function, please tell me via PM>

-------------------------------------------------------------------------------

12. Setting the custom value of Items

Fact: Custom values are used only in triggers and can be used to store any integer value.

What could this function be used for?
-To store an integer value of course!


A simple trigger showing you how to store a custom value to an item:
Setting the Custom Value of an Item 1 Events Unit - A unit Acquires an item Conditions ((Triggering unit) is A Hero) Equal to True and (Item-type of (Item being manipulated)) Equal to (Item-type of Orb of Frost <gen>) Actions Item - Set the custom value of (Item being manipulated) to 1
I havn't been very creative here, but I'm sure you can be!


-------------------------------------------------------------------------------

13. Picking every Item & doing multiple actions

What could this function be used for?
-Tiny to Gigantic amounts of things.
We can use this function to include all of the stuff you have read about above and all of the functions of an item in a trigger (note that this function does not pick any item(s) in a hero('s) item slot - only items that are on the ground. However, items can be added to a hero's item slot using this function)


Example overview trigger using this function:
Picking Every Item in a Region and doing multiple actions 1 Events Unit - A unit enters Region <gen> Conditions Actions Item - Pick every item in (Playable map area) and do (Actions) Loop - Actions Set PickedItem = (Picked item) -------- What we could do with this picked item: -------- -------- create an item at the position of it -------- -------- remove the picked item -------- -------- hide/show the picked item -------- -------- move the picked item -------- -------- set the life of the picked item -------- -------- set the charges remaining of the picked item -------- -------- set the custom value of the picked item -------- -------- change the ownership of the picked item -------- -------- give the picked item to a hero -------- -------- make the picked item invulnerable/vulnerable -------- -------- make the picked item pawnable/unpawnable -------- -------- make the picked item droppable/undroppable -------- -------- make the picked item drop from heroes upon death --------


-------------------------------------------------------------------------------

14. Making an Item Recipe


What could this function be used for?
-To look like it combines a certain number of items into 1 powerfull one, with "upgraded" abilities from the original items


Item recipe trigger:
Item Recipe 1 Events Unit - A unit Acquires an item Conditions ((Hero manipulating item) has an item of type Orb of Frost) Equal to True ((Hero manipulating item) has an item of type Claws of Attack +15) Equal to True ((Hero manipulating item) has an item of type Kelen's Dagger of Escape) Equal to True Actions Item - Remove (Item carried by (Hero manipulating item) of type Orb of Frost) Item - Remove (Item carried by (Hero manipulating item) of type Claws of Attack +15) Item - Remove (Item carried by (Hero manipulating item) of type Kelen's Dagger of Escape) Hero - Create Shield of the Deathlord and give it to (Hero manipulating item) Special Effect - Create a special effect attached to the origin of (Hero manipulating item) using Abilities\Spells\Orc\FeralSpirit\feralspiritdone.mdl Special Effect - Destroy (Last created special effect)
What is does:
It checks that if the hero manipulating the item has all 3 needed to create the 'Shield of the Deathlord'.
If it does have all 3 needed, they are removed, and the Shield is created and given to the hero.
Special Effects are also created for eye-candy.


-------------------------------------------------------------------------------

Chapter 2

15. Item Classifications

Info on Classifications:


-Item Classifications can be used in triggers
-Item Classifications do not actually physically do anything to the item themselves
-Item Classifications help to classify an item to make it easier to find in the Object Editor
-Item Classifications categorise items in the object editor

Example trigger using item classifications:
Item Classifications 1 Events Map initialization Conditions Actions Item - Pick every item in (Playable map area) and do (Actions) Loop - Actions If (All Conditions are True) then do (Then Actions) else do (Else Actions) If - Conditions (Item-class of (Picked item)) Equal to Permanent Then - Actions Item - Remove PickedItem Else - Actions Player - Add 200 gold to Player 1 (Red) current gold


-------------------------------------------------------------------------------

16. Item Abilities

Info on Item Abilities:

-Item Abilities can use mana, can have a cooldown and can have a set amount of charges which tells you how many times you can use the item ability
-As a charge for an item decreases, the item's value will decrease as well
-Items can have up to 4 abilities. All can be passive. If an item has more than 1 castable ability (like shockwave), it will only be able to let the caster use 1 castable ability
-For a castable item ability to be used, the item must have this option set as true: Stats- Activley Used true/false
-Item abilities can have no cooldown and an unlimited amount of charges (use 0)


-------------------------------------------------------------------------------

17. Items in the Object Editor

Abilities- Abilities: What abilities the item can have
Art- Button Position (X) Works the same as a hero ability button position when the item is in a shop, and only when an item is in a shop.
Art- Button Position (Y) " " "
Art- Interface Icon What icon is assigned to the item
Art- Model Used What the item looks like when it is on the ground. eg: treasure chest
Art- Scaling Value How big the item's model file looks when it is on the ground
Art- Selection Size- Editor: How big the selection scale of the item is in the World Editor.
Art- Tinting Color 1 (Red): How much of the color red is in the model file of the item
Art- Tinting Color 2 (Green): How much of the color green is in the model file of the item
Art- Tinting Color 3 (Blue): How much of the color blue is in the model file of the item
Combat- Armor Type The armour type of the item(only used when the item is on the ground)
Stats- Activley Used True: 1 of the abilities of the item is castable. False: the abilities of the item are all passive or the item has no abilities
Stats- Can Be Dropped If False: the item cannot be dropped
Stats- Can Be Sold By Merchants If False: the item cannot be sold by merchants
Stats- Can Be Sold To Merchants If False: the item cannot be sold to merchants
Stats- Classification How the item is categorised in the object editor
Stats- Cooldown Group What cooldown group the item is in after it uses a castable ability like shockwave
Stats- Dropped When Carrier Dies If False: the item will not drop when the carrier dies
Stats- Gold Cost How much gold is needed to purchase the item
Stats- Hit Points How much life the item has when it is on the ground
Stats- Ignore Cooldown If False: after a castable ability of that item is used, the ability will need to cooldown as hero abilities do
Stats- Include As A Random Choice Used for item tables
Stats- Level The level of the item
Stats- Level(Unclassified) The level of the item that is used if the above Stats have been set to 0
Stats- Lumber Cost How much lumber is needed to purchase the item
Stats- Number Of Charges: How many times the castable abilities of the item can be used
Stats- Perishable If False: the item will not be destroyed after all charges have been used
Stats- Priority Not Important
Stats- Stock Maximum The quantity that the item can be reached to when in stock
Stats- Stock Replenish Interval How long the item takes to replenish it's stock after been purchased
Stats- Stock Start Delay How much time it takes before the item is in stock
Stats- Use Automatically When Acquired Automatically used when it is acquired.(It doesn't matter whether tomes have this stat as true OR false; the hero will always be able to gain +1 str,agi,int if the tome has the tome ability for that stat increase)
Stats- Valid For Target Transformation Not sure, however, this option is not needed 99% of the time
Stats- Techtree Requirements If Yes: do you need an Orc Fortress to use this item?
Stats- Techtree Requirements- Levels: What levels of tech are used for the above Stats. In this examples's case, 3
Text- Description Tells the user what the item is capable of
Text- Hotkey What hotkey is used to purchase the item
Text- Name The name of the item
Text- Tooltip- Basic Example: Purchase Boots Of Speed
Text- Tooltip- Extended What description the user sees when he is looking at the item in a shop

Please see also:
Item Stacking System, by SFilip
Item Restrictions, by AceHart

Tinki3

Click here to comment on this tutorial.
 
 
Blizzard Entertainment, Inc.
Silkroad Online Forums
Team Griffonrawl Trains Muay Thai and MMA fighters in Ohio.
Apex Steel Pipe - Buys and sells Steel Pipe.