GUI Equipment Manager
by Donach
Difficulty - Easy/Medium
What does it basically do?
This EM replaces usual way of items giving you bonuses. It's optimized for 1 unit only at a time for each player.
- I could also make it working for more number of units, if there will be enough interest for it. But experienced users can remake it on their own.
The thing is, that the items does not have any bonus to give it to you hero.
It works like this:
You gain some item. Whenever you click on it (it has to be useable - so all items will have ability to be clicked), it "puts the item on you" which gives you certain bonus. Then to unequip it, you just simply click on certain icon for the item used at your inventory, which gives you the item back to you inventory.
What does it really do is, that it moves the item you use on predefined place, then gives "full slot" ability to dummy unit and the ability to your unit. The unequipping is just opposite process.
What are we going to need? Dummy unit
Create custom unit, set its Art - Scaling, Selection values to 0. - (you may have to hold SHIFT and left-click some of it, because it normally won't allow you to set it lower than 0.1)
Also set its Art - Model file: "none.mdl". (without "")
Then Stats - Sight Radius (both) values to 0.
Now give the unit Abilities - Normal: Inventory (Hero), Invulnerable(Neutral).
Spells and abilities
1) You’ll need custom spell for each item-type. I use 11 types: Amulet, Armor, Boots, Gloves, Helmet, Legs, Main-hand, Shield(Offhand), Ring, Shoulder, Special
Empty slot - Amulet
- just Empty slot for Amulet example
2) You'll need ability for every item you want to use. So 100 items = 100 abilities for them (And another 100 as hero abilities :-)).
Dummy Ability
- Set all your Dummy abilities like this, just change name to: "BTN 'YourItemName'"
3) Next thing you'll need are abilities, that gives that certain bonus that item should actually provide. It goes the same as with Dummy ability, 100 items = 100 hero abilities.
For demonstration I'll use "Item Damage Bonus" ability called: ABI "Item name".
Hero Ability
- it should be sth like this one
4) Ability called "[clickable item]" - base for this is "Item Temporary Speed Bonus".
Just set:
Clickable item - stats
And give this ability to all your items.
5) Spells Equipment - to select Dummy unit; Exit - to select back hero
- based on spell "Channel" too
- almost same as the BTN abilities for dummy, just change names, icons etc.
6) The Items it self
Item - Amulet
- the item stats look like this - you can do this for all your items, just change Icon, Name and Tooltips
- notice, that the item actually does NOTHING, its used only as “tracker” for ability added, when you use the item
Variables
- I'll demonstrate only on Amulet type of item.
InventoryDummy - Unit Array (1)
CurrentHero - Unit Array (1)
ItemAmuletUsed - Item-Type Array (1) - if destroying
or
ItemAmuletUsed - Item Array (1) - if moving
ItemAmuletUsed2 - Item
- This depends, if you destroy or just move item from unit using it
- I’ve noticed, that when I move the item, it’s a lot faster when I’m giving it back to hero, because when you have to create new item, it takes more time than moving an existing one
Point_DummyCreation – Point
Point_ItemEquipRemove - Point
Regions
1 - Region, where Dummy unit will be created
- variable Point_DummyCreation will be set to center of this region
2 - Region, where items will be moved (not need if you're destroying them)
- variable Point_ItemEquipRemove will be set to center of this region
Initialization
Create dummy
Dummy create
Dummy Create
Events
Time - Elapsed game time is 0.20 seconds
Conditions Actions
Set Point_DummyCreation = (Center of Equipment Dummy Region <gen>)
Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Player 1 (Red) controller) Equal to (==) User
Then - Actions
Unit - Create 1 Inventory - |cffff0000Red|r for Player 1 (Red) at Point_DummyCreation facing Default building facing (270.0) degrees Set InventoryDummy[(Player number of (Owner of (Last created unit)))] = (Last created unit) Set InventoryDummyUnittype[(Player number of (Owner of (Last created unit)))] = (Unit-type of (Last created unit))
Else - Actions
Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Player 2 (Blue) controller) Equal to (==) User
Then - Actions
Unit - Create 1 Inventory - |cff0000ffBlue|r for Player 2 (Blue) at Point_DummyCreation facing Default building facing (270.0) degrees Set InventoryDummy[(Player number of (Owner of (Last created unit)))] = (Last created unit) Set InventoryDummyUnittype[(Player number of (Owner of (Last created unit)))] = (Unit-type of (Last created unit))
Else - Actions
Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Player 3 (Teal) controller) Equal to (==) User
Then - Actions
Unit - Create 1 Inventory - |cff008080Teal|r for Player 3 (Teal) at Point_DummyCreation facing Default building facing (270.0) degrees Set InventoryDummy[(Player number of (Owner of (Last created unit)))] = (Last created unit) Set InventoryDummyUnittype[(Player number of (Owner of (Last created unit)))] = (Unit-type of (Last created unit))
Else - Actions
Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Player 4 (Purple) controller) Equal to (==) User
Then - Actions
Unit - Create 1 Inventory - |cff800080Purple|r for Player 4 (Purple) at Point_DummyCreation facing Default building facing (270.0) degrees Set InventoryDummy[(Player number of (Owner of (Last created unit)))] = (Last created unit) Set InventoryDummyUnittype[(Player number of (Owner of (Last created unit)))] = (Unit-type of (Last created unit))
Else - Actions
Do Multiple ActionsFor each (Integer A) from 1 to 4, do (Actions)
Loop - Actions
Unit - Add Empty Slot Amulet to InventoryDummy[(Integer A)] Unit - Add Empty Slot Armor to InventoryDummy[(Integer A)] Unit - Add Empty Slot Boots to InventoryDummy[(Integer A)] Unit - Add Empty Slot Gloves to InventoryDummy[(Integer A)] Unit - Add Empty Slot Helmet to InventoryDummy[(Integer A)] Unit - Add Empty Slot Legs to InventoryDummy[(Integer A)] Unit - Add Empty Slot Mainhand to InventoryDummy[(Integer A)] Unit - Add Empty Slot Shield to InventoryDummy[(Integer A)] Unit - Add Empty Slot Ring to InventoryDummy[(Integer A)] Unit - Add Empty Slot Shoulder to InventoryDummy[(Integer A)] Unit - Add Empty Slot Special to InventoryDummy[(Integer A)] Unit - Add Exit to InventoryDummy[(Integer A)]
- creates dummy at dummy region if player 1-4 is user - 4 players to make it shorter (I’ve got players 1 – 10 as user, so it creates 10 dummies every time it starts a map)
- sets variable to track the dummy
- and finnaly adds all required abilities to all dummies for each player using loop
Add Equipment spell to hero
Add spell - Equipment
Equipment Spell Add
Events
Unit - A unit enters (Playable map area)
Conditions
((Entering unit) is A Hero) Equal to (==) True
Actions
Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
Multiple ConditionsOr - Any (Conditions) are true
Conditions
(Unit-type of (Entering unit)) Equal to (==) Female (Unit-type of (Triggering unit)) Equal to (==) Male
Then - Actions
Unit - Add Equipment to (Triggering unit) Set CurrentHero[(Player number of (Owner of (Triggering unit)))] = (Triggering unit) Set CurrentHeroType[(Player number of (Owner of (Triggering unit)))] = (Unit-type of (Triggering unit))
Else - Actions
- pretty simple. In the If/then/else conditions I use only Unit-types that are players able to have.
- also sets variable CurrentHero to hero, that was just Created/Loaded.
- at setting the variable it HAS to be Owner of(Triggering unit) - you can't exchange it just for (Triggering player)
Dummy/Hero Selection
Selection
Select Inventory
Events
Unit - A unit Begins casting an ability
Conditions Actions
Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Ability being cast) Equal to (==) Equipment
Then - Actions
Unit - Change ownership of InventoryDummy[(Player number of (Triggering player))] to (Triggering player) and Change color Selection - Select InventoryDummy[(Player number of (Triggering player))] for (Triggering player)
Else - Actions
Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Ability being cast) Equal to (==) Exit (CurrentHero[(Player number of (Triggering player))] is alive) Equal to (==) True
Then - Actions
Camera - Pan camera for (Triggering player) to (Position of CurrentHero[(Player number of (Triggering player))]) over 0.00 seconds Selection - Select CurrentHero[(Player number of (Triggering player))] for (Triggering player)
Else - Actions
- Whenever player uses Equipment spell, it selects the Dummy for him
- Whenever player uses Exit spell, it selects Hero for him
- added condition for checking, if player even have his hero alive - it would pan the camera to center of map, if the condition wasn't there
- the ownership change is due to changing ownership to any player via command - this is more explained at end of this tutorial
Define variables
Amulet - item
Item 1 Initialization Item 1 Initialization
Events
Time - Elapsed game time is 0.20 seconds
Conditions Actions
-------- Amulets -------- Set ItemAmulet[1] = Amulet of Darkness Set ItemAmulet[2] = Amulet of Brightness
-------- Amulets Hero Abilities -------- Set ItemAmuletHeroAbility[1] = ABI Amulet of Darkness Set ItemAmuletHeroAbility[2] = ABI Amulet of Brightness
- and do this again for all your Hero Abilities
- NEVER forget that the numbers in arrays at this init is MAX LIFE of target item - you have to set it for every item and it cannot be same for 2 items
How does my Equipment Manager work?
Let's see the magic:
Hero - Amulet Equip - old version
HeroAmulet Equip Item
HeroAmulet Equip Item
Events
Unit - A unit Uses an item
Conditions Actions
Item - Set life of (Item being manipulated) to 1000000.00 -------- 1st - check, if there isn't another amulet used at the moment. --------
Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
Multiple ConditionsOr - Any (Conditions) are true
Conditions
((Triggering unit) is A Hero) Equal to (==) True (Unit-type of (Triggering unit)) Equal to (==) InventoryDummyUnittype[(Player number of (Triggering player))]
ItemAmuletIsUsed[(Player number of (Triggering player))] Equal to (==) False
Multiple ConditionsOr - Any (Conditions) are true
Conditions
(Current life of (Item being manipulated)) Less than or equal to (<=) 100.00
Then - Actions
Set Point_ItemEquipRemove = (Center of Item Remove Region <gen>) -------- 1st - Adds amulet abillity to DUMMY; 2nd - Adds amulet bonus to HERO; 3rd - Removes Empty Slot Amulet from DUMMY -------- Unit - Add ItemAmuletAbility[(Integer((Current life of (Item being manipulated))))] to InventoryDummy[(Player number of (Triggering player))] Unit - Add ItemAmuletHeroAbility[(Integer((Current life of (Item being manipulated))))] to CurrentHero[(Player number of (Triggering player))] Unit - Remove Empty Slot Amulet from InventoryDummy[(Player number of (Triggering player))] -------- 1st - Sets variable, to track back the item; 2nd - sets boolean, that amulet is now used; 3rd - sets current amulet item is now used -------- Set ItemAmuletLifeInteger[(Player number of (Triggering player))] = (Integer((Current life of (Item being manipulated)))) Set ItemAmuletIsUsed[(Player number of (Triggering player))] = True Set ItemAmuletUsed[(Player number of (Triggering player))] = (Item being manipulated) -------- Drops and moves the item to Region for item moving -------- Hero - Drop ItemAmuletUsed[(Player number of (Triggering player))] from (Triggering unit) Item - Move (Last dropped item) to Point_ItemEquipRemove Custom script: call RemoveLocation(udg_Point_ItemEquipRemove)
Else - Actions
-------- ELSE: Checks if amulet is used (It is), and return message --------
Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
ItemAmuletIsUsed[(Player number of (Triggering player))] Equal to (==) True
Multiple ConditionsOr - Any (Conditions) are true
Conditions
(Current life of (Item being manipulated)) Less than or equal to (<=) 100.00
Then - Actions
Game - Display to (Player group((Triggering player))) the text: |CFFFF0000You alrea...
Else - Actions
Hero - Amulet equip - NEW version
HeroAmulet Equip Item v2
HeroAmulet Equip Item v2
Events
Unit - A unit Uses an item
Conditions Actions
Item - Set life of (Item being manipulated) to 1000000.00 -------- 1st - check, if there isn't another amulet used at the moment. --------
Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
ItemAmuletIsUsed[(Player number of (Triggering player))] Equal to (==) False
Multiple ConditionsOr - Any (Conditions) are true
Conditions
(Current life of (Item being manipulated)) Less than or equal to (<=) 100.00
Multiple ConditionsOr - Any (Conditions) are true
Conditions
((Triggering unit) is A Hero) Equal to (==) True (Unit-type of (Triggering unit)) Equal to (==) InventoryDummyUnittype[(Player number of (Triggering player))]
Then - Actions
-------- Changes owner of the item equipped so played can't give the item to anyone else (It's your choice if you're willing to have this in your map) -------- Item - Change ownership of (Item being manipulated) to (Triggering player) and Retain color -------- Sets point for later item remove. -------- Set Point_ItemEquipRemove = (Center of Item Remove Region <gen>) -------- 1st - Adds amulet abillity to DUMMY; 2nd - Adds amulet bonus to HERO; 3rd - Removes Empty Slot Amulet from DUMMY -------- Unit - Add ItemAmuletAbility[(Integer((Current life of (Item being manipulated))))] to InventoryDummy[(Player number of (Triggering player))] Unit - Add ItemAmuletHeroAbility[(Integer((Current life of (Item being manipulated))))] to CurrentHero[(Player number of (Triggering player))] Unit - Remove Empty Slot Amulet from InventoryDummy[(Player number of (Triggering player))] -------- 1st - Sets variable, to track back the item; 2nd - sets boolean, that amulet is now used; 3rd - sets current amulet item is now used -------- Set ItemAmuletLifeInteger[(Player number of (Triggering player))] = (Integer((Current life of (Item being manipulated)))) Set ItemAmuletIsUsed[(Player number of (Triggering player))] = True Set ItemAmuletUsed[(Player number of (Triggering player))] = (Item being manipulated) -------- Drops and moves the item to Region for item moving -------- Hero - Drop ItemAmuletUsed[(Player number of (Triggering player))] from (Triggering unit) Item - Move (Last dropped item) to Point_ItemEquipRemove Custom script: call RemoveLocation(udg_Point_ItemEquipRemove) -------- This is just essential - it displays: You have equipped "Item name" - the color of item name will be based on its rarity. -------- Game - Display to (Player group((Triggering player))) the text: (|CFFFFCC00You have + (|r|CFF00FF00equipped|r |CFF9400D3 + (Name of ItemAmuletUsed[(Player number of (Triggering player))])))
Else - Actions
-------- ELSE: Checks if amulet is used (It is), and return message --------
Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
ItemAmuletIsUsed[(Player number of (Triggering player))] Equal to (==) True
Multiple ConditionsOr - Any (Conditions) are true
Conditions
(Current life of (Item being manipulated)) Less than or equal to (<=) 100.00
Multiple ConditionsOr - Any (Conditions) are true
Conditions
((Triggering unit) is A Hero) Equal to (==) True (Unit-type of (Triggering unit)) Equal to (==) InventoryDummyUnittype[(Player number of (Triggering player))]
Then - Actions
-------- These actions will actually exchange item used for the one we have equipped. -------- -------- Changes owner of the item equipped so played can't give the item to anyone else (It's your choice if you're willing to have this in your map) -------- Item - Change ownership of (Item being manipulated) to (Triggering player) and Retain color -------- Sets point for later item remove. -------- Set Point_ItemEquipRemove = (Center of Item Remove Region <gen>) -------- Remove item ability + hero ability -------- Unit - Remove ItemAmuletAbility[ItemAmuletLifeInteger[(Player number of (Triggering player))]] from InventoryDummy[(Player number of (Triggering player))] Unit - Remove ItemAmuletHeroAbility[ItemAmuletLifeInteger[(Player number of (Triggering player))]] from CurrentHero[(Player number of (Triggering player))] -------- Adds item ability and hero ability -------- Unit - Add ItemAmuletAbility[(Integer((Current life of (Item being manipulated))))] to InventoryDummy[(Player number of (Triggering player))] Unit - Add ItemAmuletHeroAbility[(Integer((Current life of (Item being manipulated))))] to CurrentHero[(Player number of (Triggering player))] -------- This is item we have had equipped. It has to be saved into another variable just for use in this trigger. -------- Set ItemAmuletUsed2 = ItemAmuletUsed[(Player number of (Triggering player))] -------- Sets variables -------- Set ItemAmuletLifeInteger[(Player number of (Triggering player))] = (Integer((Current life of (Item being manipulated)))) Set ItemAmuletIsUsed[(Player number of (Triggering player))] = True Set ItemAmuletUsed[(Player number of (Triggering player))] = (Item being manipulated) -------- Drops and moves the item to Region for item moving -------- Hero - Drop ItemAmuletUsed[(Player number of (Triggering player))] from (Triggering unit) Item - Move (Last dropped item) to Point_ItemEquipRemove -------- After we have our item we clicked equipped, this adds to your hero inventory the item dropped (which was equipped before). -------- Hero - Give ItemAmuletUsed2 to CurrentHero[(Player number of (Triggering player))] Custom script: call RemoveLocation(udg_Point_ItemEquipRemove) Set ItemAmuletUsed2 = No item -------- Displays which item have you equipped and which unequipped. Color of item names will again be based on their rarity. -------- Game - Display to (Player group((Triggering player))) the text: (|CFFFFCC00You have + (|r|CFF00FF00equipped|r |CFF9400D3 + (Name of ItemAmuletUsed[(Player number of (Triggering player))]))) Game - Display to (Player group((Triggering player))) the text: (|CFFFFCC00You have + (|r|CFFFF0000unequipped|r |CFF9400D3 + (Name of ItemAmuletUsed2)))
Else - Actions
Easy to see it, but I'll explain it:
Old Version
Old version:
First of all: sets items life to its maximum - this can be really high number, since items have their maximum set. - This is to prevent damaging items with let's say +1k HP, so you would equip another insted of the one you got
1) If unit uses item, that has life =< 100 (100 is Amulet life cap, 101+ is Armor life) AND If Amulet is NOT used, then here comes the actions:
1. sets point for item remove in item region
-comment-
2. Adds certain ability to Dummy
3. Adds certain ability to Hero
4. Removes Empty slot Amulet from Dummy
-comment-
5. Sets Variable(ItemAmuletLifeInteger) to hold the number = life of item being manipulated
5. Sets Variable (ItemAmuletIsUsed) to see if amulet is now used (which is)
6. Sets Variable (ItemAmuletUsed) to the item, that is manipulated with
-comment-
7. Drops the item being manipulated from Triggering unit
8. And finally moving it to region prepared for it (using point variable)
2) If the conditions fail, here comes check, If Variable (ItemAmuletIsUsed) boolean = true AND if the life of the Item being manipulated is >= 100 (to check, if its Amulet), then
1.Displays to player message: You're already using an amulet!
- here are the conditions due to more items, that are to be added in this trigger (or can be in another trigger, its your call)
New version
Newer version:
1) part is the same, let's see the second (longer) one
Since there are comments everywhere (I've added them for purpose of use in this tutorial) it's easier to understand than before but let's see it closely:
2)
1. changes owner of the item used (I use this in map map, so players won't be able to wear super good items and then give it to another ones
-comment-
2. sets point for item remove
-comment-
3. removes certain ability from DUMMY
4. removes certain ability from HERO
-comment-
5. adds new ability of item used to DUMMY
6. adds new ability of item used to HERO
-comment-
7. sets the old item into variable to be able to give it hero after we remove the clicked one
- notice, that there is new variable - ItemAmuletUsed2 WITHOUT array - this variable serves only in this new equip trigger and isn't used anywhere else
-comment-
8. Sets Variable(ItemAmuletLifeInteger) to hold the number = life of item being manipulated
9. Sets Variable (ItemAmuletIsUsed) to see if amulet is now used (which is)
10. Sets Variable (ItemAmuletUsed) to the item, that is manipulated with
-comment-
11. Drops the item being manipulated from Triggering unit
12. And finally moving it to region prepared for it (using point variable)
-comment-
13. now this gives the old item we have had equipped back to hero inventory
14. point remove to prevent leaks
15. sets the variable (ItemAmuletUsed2) to no item, since we're not using this variable in any other trigger
-comment-
16. displays message with text: You have equipped "item name".
17. displays message with text: You have unequipped "item name".
- the newer version is better by my opinion - you don't have to manually unequip amulet if you have one equipped, but insted if you use another amulet it drops the currently equpped and gives it back to you while equipping the item used
- PS: Notice, that in conditions I also use condition for InventoryDummy - It's due to my Save/Load system, since I save those abilities as Items giving them to dummy and using them right away after load.
Pretty easy, huh?
So, what about putting the item back to hero?
Dummy - Amulet UnEquip
HeroUnEquip Item
Events
Unit - A unit Begins casting an ability
Conditions Actions
-------- 1st condition - Checks if the ability being cast is equal to Amulet type; then 2nd condition: check, if it is still used and if yes, it continues to actions --------
Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Ability being cast) Equal to (==) ItemAmuletAbility[ItemAmuletLifeInteger[(Player number of (Triggering player))]] ItemAmuletIsUsed[(Player number of (Triggering player))] Equal to (==) True
Then - Actions
-------- 1. Remove ability of current Amulet from Dummy; 2. Remove ability provided by item from Hero; 3. Add Empty Amulet slot to Dummy -------- Unit - Remove ItemAmuletAbility[ItemAmuletLifeInteger[(Player number of (Triggering player))]] from InventoryDummy[(Player number of (Triggering player))] Unit - Remove ItemAmuletHeroAbility[ItemAmuletLifeInteger[(Player number of (Triggering player))]] from CurrentHero[(Player number of (Triggering player))] Unit - Add Empty Slot Amulet to InventoryDummy[(Player number of (Triggering player))] -------- Shows text: You have unequipped "item name" - the item name's color will be based on its rarity. -------- Game - Display to (Player group((Triggering player))) the text: (|CFFFFCC00You have + (|r|CFFFF0000unequipped|r |CFF9400D3 + (Name of ItemAmuletUsed[(Player number of (Triggering player))]))) -------- This is new action, making this unequipping working, even if you have full inventory. -------- -------- 1. checks if hero has 5 or less items. If so, it gives him the item immediately. --------
Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Number of items carried by CurrentHero[(Player number of (Triggering player))]) Less than or equal to (<=) 5
Then - Actions
Hero - Give ItemAmuletUsed[(Player number of (Triggering player))] to CurrentHero[(Player number of (Triggering player))]
Else - Actions
-------- But, if the hero has 6 items, it can't give him the item, he would lose it. So instead, it will move to position of your hero. --------
Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Number of items carried by CurrentHero[(Player number of (Triggering player))]) Equal to (==) 6
Then - Actions
Set Point_CurrentHero = (Position of CurrentHero[(Player number of (Triggering player))]) Item - Move ItemAmuletUsed[(Player number of (Triggering player))] to Point_CurrentHero Custom script: call RemoveLocation(udg_Point_CurrentHero)
Else - Actions
-------- Sets variables to null/0 etc. -------- Set ItemAmuletUsed[(Player number of (Triggering player))] = No item Set ItemAmuletLifeInteger[(Player number of (Triggering player))] = 0 Set ItemAmuletIsUsed[(Player number of (Triggering player))] = False
Else - Actions
This is simply just opposite process than putting the item "on" hero.
1) If ability being cast is equal to Variable(ItemAmuletAbility[Life integer of Amulet that is currently active{Player number}]) AND Variable (ItemAmuletIsUsed[PlayerNumber]) boolean = true, returns actions:
- this one is maybe a bit confusing - This took me the most time to set it correct
- 1) ItemAmuletAbility - this is ability, that is declared at Initialization (look it up)
- 2) Life integer of amulet = Variable(ItemAmuletLifeInteger) - which is declared, when we are putting the Amulet on and is equal to life, the Amulet has
Now the actions:
-comment
1.Removes certain ability to Dummy
2.Removes certain ability to Hero
3.Adds Empty slot Amulet from Dummy
-comment-
4. Shows text: You have unequipped "item name".
-comment-
-comment-
5. Now this is new and it should be here since beggining - what this If/then/else does is, that it checks if here has some space in his inventory - in older version, if hero had full inventory, the item wouldn't show up and you would lose it.
5.1 - if items hero has is 5 or less, it normally gives him the item he has dropped from equipment
5.2 - if hero has 6 items, this creates point which is position of our hero, moves the item at the position and then removes the point
-comment-
6.Sets Variable(ItemAmuletUsed2) to No item
7.Sets Variable(ItemAmuletLifeInteger) to 0
8.Sets Variable(ItemAmuletIsUsed) to boolean = false
Here it is. If you want to add more types of items, just continue in Else and add another If/then/else and put the conditions to check, if the Ability being cast is one of that certain type.
Features
Viewing another player's inventory
As the title says: this will allow you to see what other players have on them equipped (but still, you cannot drop their items or do anything with their equip).
Here is how it goes: You type "-inv 1" for example, it checks if the player (1 stands for Red) isn't using his inventory right now, and then it selects it for you and making you the owner of the inventory. This allows you to see all items the player has equipped.
Let's see what will we need:
Variables
IntegerSelect - Integer (Base 0)
Player - Player Array (1)
Initialization
During map initialization (or short after) you have to attach Player[] variable to certain players like this:
Map initialization
MapInitialization
Events
Time - Elapsed game time is 0.50 seconds
Conditions Actions
Player Group - Pick every player in (All players) and do (Actions)
Loop - Actions
Set Player[(Player number of (Picked player))] = (Picked player)
The selection
This is the selection itself. Although I normally use it for 10 players, here is shorter version for 4 players.
Friends inventory select
Select Friends Inventory
Events
Player - Player 1 (Red) types a chat message containing -inv as A substring Player - Player 2 (Blue) types a chat message containing -inv as A substring Player - Player 3 (Teal) types a chat message containing -inv as A substring Player - Player 4 (Purple) types a chat message containing -inv as A substring
Conditions
(Substring((Entered chat string), 1, 5)) Equal to (==) (Matched chat string) (Length of (Entered chat string)) Greater than (>) 5
Actions
Set IntegerSelect = 0 -------- PLAYER 1 - RED -------- Set IntegerSelect = (IntegerSelect + 1)
Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(InventoryDummy[IntegerSelect] is selected by Player[IntegerSelect]) Equal to (==) False
Multiple ConditionsOr - Any (Conditions) are true
Conditions
(Substring((Entered chat string), 6, (Length of (Entered chat string)))) Equal to (==) red (Substring((Entered chat string), 6, (Length of (Entered chat string)))) Equal to (==) 1
Then - Actions
Unit - Change ownership of InventoryDummy[IntegerSelect] to (Triggering player) and Retain color Selection - Select InventoryDummy[IntegerSelect] for (Triggering player)
Else - Actions
Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(InventoryDummy[IntegerSelect] is selected by Player[IntegerSelect]) Equal to (==) True
Multiple ConditionsOr - Any (Conditions) are true
Conditions
(Substring((Entered chat string), 6, (Length of (Entered chat string)))) Equal to (==) red (Substring((Entered chat string), 6, (Length of (Entered chat string)))) Equal to (==) 1
Then - Actions
Game - Display to (Player group((Triggering player))) the text: (|CFFFFCC00 + ((Name of Player[IntegerSelect]) + |r is using his inventory right now.))
Else - Actions
-------- PLAYER 2 - BLUE -------- Set IntegerSelect = (IntegerSelect + 1)
Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(InventoryDummy[IntegerSelect] is selected by Player[IntegerSelect]) Equal to (==) False
Multiple ConditionsOr - Any (Conditions) are true
Conditions
(Substring((Entered chat string), 6, (Length of (Entered chat string)))) Equal to (==) blue (Substring((Entered chat string), 6, (Length of (Entered chat string)))) Equal to (==) 2
Then - Actions
Unit - Change ownership of InventoryDummy[IntegerSelect] to (Triggering player) and Retain color Selection - Select InventoryDummy[IntegerSelect] for (Triggering player)
Else - Actions
Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(InventoryDummy[IntegerSelect] is selected by Player[IntegerSelect]) Equal to (==) True
Multiple ConditionsOr - Any (Conditions) are true
Conditions
(Substring((Entered chat string), 6, (Length of (Entered chat string)))) Equal to (==) blue (Substring((Entered chat string), 6, (Length of (Entered chat string)))) Equal to (==) 2
Then - Actions
Game - Display to (Player group((Triggering player))) the text: (|CFFFFCC00 + ((Name of Player[IntegerSelect]) + |r is using his inventory right now.))
Else - Actions
-------- PLAYER 3 - TEAL -------- Set IntegerSelect = (IntegerSelect + 1)
Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(InventoryDummy[IntegerSelect] is selected by Player[IntegerSelect]) Equal to (==) False
Multiple ConditionsOr - Any (Conditions) are true
Conditions
(Substring((Entered chat string), 6, (Length of (Entered chat string)))) Equal to (==) teal (Substring((Entered chat string), 6, (Length of (Entered chat string)))) Equal to (==) 3
Then - Actions
Unit - Change ownership of InventoryDummy[IntegerSelect] to (Triggering player) and Retain color Selection - Select InventoryDummy[IntegerSelect] for (Triggering player)
Else - Actions
Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(InventoryDummy[IntegerSelect] is selected by Player[IntegerSelect]) Equal to (==) True
Multiple ConditionsOr - Any (Conditions) are true
Conditions
(Substring((Entered chat string), 6, (Length of (Entered chat string)))) Equal to (==) teal (Substring((Entered chat string), 6, (Length of (Entered chat string)))) Equal to (==) 3
Then - Actions
Game - Display to (Player group((Triggering player))) the text: (|CFFFFCC00 + ((Name of Player[IntegerSelect]) + |r is using his inventory right now.))
Else - Actions
-------- PLAYER 4 - PURPLE -------- Set IntegerSelect = (IntegerSelect + 1)
Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(InventoryDummy[IntegerSelect] is selected by Player[IntegerSelect]) Equal to (==) False
Multiple ConditionsOr - Any (Conditions) are true
Conditions
(Substring((Entered chat string), 6, (Length of (Entered chat string)))) Equal to (==) purple (Substring((Entered chat string), 6, (Length of (Entered chat string)))) Equal to (==) 4
Then - Actions
Unit - Change ownership of InventoryDummy[IntegerSelect] to (Triggering player) and Retain color Selection - Select InventoryDummy[IntegerSelect] for (Triggering player)
Else - Actions
Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(InventoryDummy[IntegerSelect] is selected by Player[IntegerSelect]) Equal to (==) True
Multiple ConditionsOr - Any (Conditions) are true
Conditions
(Substring((Entered chat string), 6, (Length of (Entered chat string)))) Equal to (==) purple (Substring((Entered chat string), 6, (Length of (Entered chat string)))) Equal to (==) 4
Then - Actions
Game - Display to (Player group((Triggering player))) the text: (|CFFFFCC00 + ((Name of Player[IntegerSelect]) + |r is using his inventory right now.))
Else - Actions
OK, so how does it work?
Event:
Player types "-inv" with and addition of number or name of color for target players inventory he wants to see.
Conditions:
1. Checks if "-inv " is entered correctly.
2. Checks if the message player wrote is longer than "-inv " which is 5 letters (notice that space " " is also a letter!).
Actions:
1. We set variable IntegerSelect to 0 - this will be used as player number as the trigger will go on
2. Right after we set the variable IntegerSelect to itself + 1 - as 1 stands for red player
Multiple Actions:
Conditions:
1. checks, if target inventory isn't used by origin player of that inventory (you may add another condition which won't allow select the inventory even if someone else than the original owner has the inventory selected)
2. and 3. - check of the written substring behing "-inv " is either "red" or "1"
Then Actions:
1. changes ownership of target inventory for player writing the message
2. selects the inventory
Else Actions
- checks for same conditions as before but at the 1st condition, it checks if the player HAS the inventory selected
- returns message, which says that certain player is just right now using his inventory
Pretty simple and works well (atleast as far as I'm able to test on my 2 computers :-))
I hope there are no leaks in this selecting. If I'm wrong, please, tell me where are the bugs and I'll repair them.
Item property restriction
This is very simple trigger - no variables etc. needed.
It works like this: You pick up an item, if you're picking it up for the first time, it sets the item property to you.
If you're picking it for more times, it does practically nothing.
But then, if somebody wants to pick up your item, it will post message to him, that the item isn't his and drops it from him.
Item property
Item Pickup Owner
Events
Unit - A unit Acquires an item
Conditions Actions
Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
Multiple ConditionsOr - Any (Conditions) are true
Conditions
(Owner of (Item being manipulated)) Equal to (==) (Player(16)) (Owner of (Item being manipulated)) Equal to (==) (Triggering player)
Then - Actions
Item - Change ownership of (Item being manipulated) to (Triggering player) and Retain color
Else - Actions
Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Owner of (Item being manipulated)) Not equal to (!=) (Triggering player)
Then - Actions
Hero - Drop (Item being manipulated) from (Triggering unit) Game - Display to (Player group((Triggering player))) the text: (This item belongs to + (|CFFFFCC00 + ((Name of (Owner of (Item being manipulated))) + |r.)))
Else - Actions
So just simply:
1. it checks if the item is owned by triggering player or by noone (in WC3 it is player 16 by default)
2. if so, it changes owner to the triggering player
3. if not, it checks if the triggering player isn't owner, and if so, returns actions
3.1. drops the item manipulated from triggering unit
3.2. posts message to triggering player, that the item he picked up isn't his
Final Disposition
I checked the spelling, everything should be OK now.
If there are still leaks, I'm very sorry and I'll check it again :-).
There is also test map included, so you can test it on your own - sorry for the size (which is not much in these days anyway :-D), it's mostly due to the pictures I've used that are included.
Enjoy!
- there is now new map uploaded with the upgraded and hopefully leak-less version
- also, if you've used the equipment before, I recommend you to remove it and use this updated one - it should be leak-less and it has better essential functionality than the older one
- if there are still any bugs, I'll repair them
PS:
If you want to use this in Save/Load map, then I recommend saving Items instead of abilities and then to give them to dummy, that will use them right when he gets the item, which will result in the same action, as if the Hero used the item.
- if there will be interest, I'll show how I changed AceHarts Save/Load system to fit this Equipment System.
I hope that you'll enjoy this as much as I do.
If you use this in your map, give credits, please, but not only to me, but also to The_Witcher, as he is mine inspiration for creating this system, based on his.
Credits: The_Witcher's Advanced Equipment System - I based my Equipment on his (and I also took some ideas like 11 item types). Thanks to his work, I made this completely JASS-free Equipment for people (like me), who aren't familiar with JASS. Adiktuz - Pointing out for 1 bug, that would occur if the item would be damaged - it's now prevented by setting items life to max right after it's used.
EDIT: New version of demo map added - it should now contain everything posted here;
Added action into both equipping triggers, that will prevent glitch if you'd attack the item, and it's life would be different from its max life;
Added new feature in the tutorial (which was already implemented in demo map V2), which changes property of items being picked up - this is also implemented in equipping items, so it doesn't have to be there. The reason I'm adding this here is, that, for example I, don't want players to switch items between them - to prevent making shitloads of money, etc... It just your choice which one of there property changing system to keep, or just delete both;
Last edited by Donach; 05-14-2012 at 07:11 PM.
Reason: Edit reason will be alwas shown in my post, just below credits.
Some of the triggers are leaking. They have locations used that are not removed. (such as Random point in region... for the "dummy create" trigger and a "center of region..." in another trigger)
For future reference, you can use [TRIGGER][/TRIGGER] tags to make posting triggers a lot easier. Simply right click the trigger in the editor, click "Copy as text", and then paste the result into the trigger tags.
Also, the attachments must be attached to the hiveworkshop rather than imageshack. Sorry. :(
If you fix those things, this will be approved! Great tutorial overall and nice explanations. There are a few misspellings but it is still readable so it shouldn't matter.
Ok, I had to rework the equipment (mostly the unequipping phase) - it's all explained in the tutorial.
There is also new variable used: ItemAmuletUsed2 - which is without array and is used only in newer type of equipping items - so if you want to use older one (both are in the tutorial), you don't need it.
If there are still any misspellings, bugs or misunderstandings, just tell me and I'll fix it.
I hope that this will be last update and everything works fine, so I'd be glad if you could check it your self in new updated demo map.
Images aren't working for the first few hidden tags. :(
Some of the triggers could be optimized to be in loops a bit with some creative techniques, but in my opinion it isn't completely necessary since without it there is more clarity.
So just fix those images and it should be okay for approval!
It is unreliable, you use max life for the array but current life for the checks... what if the item is attacked?
and also, you check if the item life is <= 100, which means this can only have 100 items registered... anyway, not much of a problem with this since the user can change it... XD
anyway, not much of a problem with this since the user can change it... XD
you should add the trigger for the attack here at the tutorial and tell them to use it because if someone uses this without that, then you know the results...
Overall, it looks good though it requires a bit much work than just using The_Witcher's system... and oh, I get that this is for GUIers who cannot use that system...
It is unreliable, you use max life for the array but current life for the checks... what if the item is attacked?
and also, you check if the item life is <= 100, which means this can only have 100 items registered... anyway, not much of a problem with this since the user can change it... XD
In mine map, the 100 is limit for AMULETS (that can be raised, if you just change the condition)... 101 - 200 will be Armor for example and so on...
- as it is at the top, I say that this is only AMULET example. For more armor types you just copy these triggers, change variables and use higher life limit (or you can put it in single trigger, it's just your choice)
Also, I'm using trigger that unables you to attack others items... I can also add condition, that if the item you are attacking you own, then it will be destroyed immediately.
Or just simply change the condition :-).
And since items max life can be almost unlimited, this is only limited by array max number, which is 8192
- this limit is for EACH item type, so 11x8192 = 90 112 items
- I guarantee you, that you won't even reach the 8k for all your items.
EDIT: And, I've been looking into WE, but it seems that I can't really find condition for Max life of item. If you can find it, please, post it here, so I may learn something new and upgrade the tutorial.
Quote:
Originally Posted by Adiktuz
That is why I said
you should add the trigger for the attack here at the tutorial and tell them to use it because if someone uses this without that, then you know the results...
Overall, it looks good though it requires a bit much work than just using The_Witcher's system... and oh, I get that this is for GUIers who cannot use that system...
EDIT2: ... If this still isn't satisfying for you, just create another trigger, that sets life of every item you pick up to its maximum:
Item Life Set
Events
Unit - A unit Acquires an item
Conditions Actions
Item - Set life of (Item being manipulated) to 1000000.00
- I suppose this is the easiest the user can do
- another thing is, that not everybody want to have invulnerable items for others. The thing is, when there are more thing in this tutorial, the more it becomes messy for others.
I could also add it. - and even more features, if I'll find them
- if so, I'll try to make it as simple as possible (all the features will have its own "section" in the tutorial)
Maybe that trigger would suffice, add it to the tut [if id hadn't been added yet]
the tutorial is fine by itself, its just that the method has lots of triggers to create and such... but anyways, I think you could always improve them if you find an easier way... :)