• 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.

Equipment System

Status
Not open for further replies.
Level 11
Joined
Jul 9, 2009
Messages
927
Apparently i read on a tutorial on making your own equipment system
and here is what I got

  • Equip
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Equip
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Item-type of (Target item of ability being cast)) Equal to Ordinary Sword) and (EquipWeaponCheck[(Player number of (Owner of (Casting unit)))] Equal to False)
        • Then - Actions
          • Hero - Drop (Target item of ability being cast) from (Casting unit)
          • Item - Remove (Last dropped item)
          • Set EquipWeaponCheck[(Player number of (Owner of (Casting unit)))] = True
          • Set EquipWeaponItem[(Player number of (Owner of (Casting unit)))] = (Item-type of (Target item of ability being cast))
          • Unit - Add Odd Sword to (Casting unit)
        • Else - Actions
          • Do nothing
I dont know what i did wrong, I tripled check everything before posting it here and it does exactly have the same concept like the one in the tut but it appears its not working

if anyone knows how to fix this, please help :)
 
Level 11
Joined
Jul 9, 2009
Messages
927
no its not like that, its like an equipment system, where when I click the item ( run by a dummy spell based on channeling ) the item would be equipped so that the player only gets benefits from one for every item type but if I dont find any other solution I would stick with your idea +rep for helping :)
 
Level 11
Joined
Jul 9, 2009
Messages
927
Ill just post the tutorial I got the triggers from

In this tutorial I'm going to represent you how to do equipable items in GUI.





Introducion

This is easy to make and use system alowing hero to equip items from inventory to virtual backpack

Why this is usefull?
1) It saves inventory slots
2) You can make as many equipable items as you want
3) Usually only 5 item stats allowed in abilities list. Here it's unlimited




Starting

We gonna need:
1) Channel based ability called "Equip"
2) Backpack called "Unequip" (if you are planning more than 11 equipable items, make more backpacks)
3) Several "Unequip" channel-based abilities, number depends on how many equipable items you will have
Example: In Unequip spellbook lies four channel-based abilities: Unequip Weapon ; Unequip Shield ; Unequip Chest ; Unequip Head

Variables:
For each equipable item type we will use two variables

We have equipable Weapon:

EquipWeaponCheck [boolean array]
EquipWeaponItem [item-type array]

We have equipable Shield:

EquipShieldCheck [boolean array]
EquipShieldItem [item-type array]

And so on depending how much equipable items you will make...




Triggers


Here we will only learn how to equip/unequip weapon. For other items just copy paste and change variables.



Code:

  • Equip
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Q Equip Item
    • Actions
      • -------- Weapons --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Item-type of (Target item of ability being cast)) Equal to Sharpened Sword ---Here we check which item was targeted
          • EquipWeaponCheck[(Player number of (Owner of (Casting unit)))] Not equal to True ---Here we check if equiping unit don't alredy have any weapon equiped
          • (Hero level of (Casting unit)) Greater than or equal to 2 ---It's a condition, Sharpened Sword requires level two to be equiped
        • Then - Actions
          • Hero - Drop (Target item of ability being cast) from (Random unit from (Units owned by (Owner of (Casting unit)) matching (((Matching unit) is A Hero) Equal to True)))
          • Item - Remove (Last dropped item)
          • Set EquipWeaponCheck[(Player number of (Owner of (Casting unit)))] = True ---Here we set that equiping unit now has some weapon
          • Set EquipWeaponItem[(Player number of (Owner of (Casting unit)))] = Target item of ability beeing cast ---And here which weapon type has been equiped
          • Unit - Add Item Damage Bonus (+2) to (Casting unit) ---And here we add stats that item has (ensure that you're making separate abilities for each item, couse two Inteligence +2 won't stack
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions) ---Add another weapon or shield with different variables


Code:
  • Unequip Weapon ---For each Shield/Chest/Head/So on, make DIFFERENT TRIGGERS
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Q Unequip Weapon
      • EquipWeaponCheck[(Player number of (Owner of (Casting unit)))] Equal to True ---Check if unequiping unit really has something to unequip
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • EquipWeaponItem[(Player number of (Owner of (Casting unit)))] Equal to Sharpened Sword ---In each IfThenElse action we're checking item type
        • Then - Actions
          • Unit - Remove Item Damage Bonus (+2) from (Casting unit) ---Removing ability
          • Set EquipWeaponCheck[(Player number of (Owner of (Casting unit)))] = False ---Setting that unit's weapon slot is free again
          • Hero - Create EquipWeaponSlot2[(Player number of (Owner of (Casting unit)))] and give it to (Casting unit) ---Giving back unequiped item
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions) ---Another IfThenElse with other weapon




This is all, depending on map you're creating depends and items number. In Equip trigger there's easy to classify when adding custom text like "-----weapons-----" after weapon IfThenElse actions have ended, and starts Shields IfThenElse's.
Ty for reading
 
If you want to make hero unable to have more than 1 item of given type try this:

  • Order
    • Events
      • Unit - A unit Is issued an order targeting an object
    • Conditions
      • (Issued order) Equal to (Order(smart))
      • ((Triggering unit) has an item of type (Item-type of (Target item of issued order))) Equal to True
      • (Target item of issued order) Not equal to (No item)
    • Actions
      • Set temp_point[1] = (Position of (Triggering unit))
      • Set temp_point[2] = (Position of (Target item of issued order))
      • Unit - Order (Triggering unit) to Move To (temp_point[1] offset by 0.01 towards (Angle from temp_point[1] to temp_point[2]) degrees)
      • Set force = (Player group((Owner of (Triggering unit))))
      • Game - Display to force the text: You already have th...
      • Custom script: call DestroyForce (udg_force)
      • Custom script: call RemoveLocation (udg_temp_point[1])
      • Custom script: call RemoveLocation (udg_temp_point[2])
Use Triggering unit instead of Casting unit - its faster.
 
Level 11
Joined
Jul 9, 2009
Messages
927
@Spinnaker Yeah, but then now my problem is the equipment system, where I only want the hero to benefit the stats of one weapon in his inventory by equipping it. But It seems like the trigger in the tutorial did not work.
 
Meaby try this:

  • Equip
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Equip
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Item-type of (Target item of ability being cast)) Equal to Ordinary Sword) and (EquipWeaponCheck[(Player number of (Owner of (Triggering unit)))] Equal to False)
        • Then - Actions
          • Hero - Drop (Target item of ability being cast) from (Triggering unit)
          • Item - Remove (Target item of ability being cast)
          • Set EquipWeaponCheck[(Player number of (Owner of (Triggering unit)))] = True
          • Set EquipWeaponItem[(Player number of (Owner of (Triggering unit)))] = (Item-type of (Target item of ability being cast))
          • Unit - Add Odd Sword to (Triggering unit)
        • Else - Actions
 
Level 11
Joined
Jul 9, 2009
Messages
927
Ill try it later, thank you still for the Idea Spinnaker + rep when I am able
 
Idk if this is what you want but this is an equipment system using hashtables...

You only need ONE channel ability to acquire/target item...just change the number of the child hash...

The INTEGER you see is the childhash
Custom script: call SaveItemHandle(udg_HASH, udg_ID,1, udg_Item)

But you need to make multiple channel abilities to Unequip and load the childhash respectively as shown in the example...


  • Dont Acquire Item
    • Events
      • Unit - A unit Acquires an item
    • Conditions
    • Actions
      • Hero - Drop (Item being manipulated) from (Hero manipulating item)
  • Equip Weapon
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Equip Weapon
    • Actions
      • Custom script: set udg_ID = GetHandleId(GetTriggerUnit())
      • Set Item = (Target item of ability being cast)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Item-type of (Target item of ability being cast)) Equal to Mask of Death
        • Then - Actions
          • Unit - Add Item Damage Bonus (+2) to (Triggering unit)
          • Item - Hide (Target item of ability being cast)
          • Custom script: call SaveItemHandle(udg_HASH, udg_ID, 1, udg_Item)
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Item-type of (Target item of ability being cast)) Equal to Claws of Attack +15
            • Then - Actions
              • Unit - Add Item Armor Bonus (+2) to (Triggering unit)
              • Item - Hide (Target item of ability being cast)
              • Custom script: call SaveItemHandle(udg_HASH, udg_ID, 2, udg_Item)
            • Else - Actions
  • Unequip Weapon
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
    • Actions
      • Set Caster = (Triggering unit)
      • Custom script: set udg_ID = GetHandleId(udg_Caster)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Ability being cast) Equal to Unequip Weapon
        • Then - Actions
          • Custom script: set udg_Item = LoadItemHandle(udg_HASH, udg_ID, 1)
          • Custom script: call SetItemPosition(udg_Item, GetUnitX(udg_Caster), GetUnitY(udg_Caster))
          • Custom script: call SetItemVisible(udg_Item, true)
          • Unit - Remove Item Damage Bonus (+2) from (Triggering unit)
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Ability being cast) Equal to Unequip Weapon2
            • Then - Actions
              • Custom script: set udg_Item = LoadItemHandle(udg_HASH, udg_ID, 2)
              • Custom script: call SetItemPosition(udg_Item, GetUnitX(udg_Caster), GetUnitY(udg_Caster))
              • Custom script: call SetItemVisible(udg_Item, true)
              • Unit - Remove Item Armor Bonus (+2) from (Triggering unit)
            • Else - Actions


Variables needed:

HASH = hashtable (you must initialize this)
ID = Integer
Caster = unit
Item = item

KNOWN BUG:
If you cast the spell to the same item-type, the first item will not reveal or will be lost forever...
 
Last edited:
Level 11
Joined
Jul 9, 2009
Messages
927
thanks MC ! You helped me ! I owe you a rep and Ill pay it when I am able
the only thing is, is there anyway to classify items as weapons, for example
I can only have one weapon at a time.And If i have an equipped weapon, I will not be able to equip another weapon unless I unequipped the older weapon.

EDIT :
Solved The problem myself, thanks MC and Spinnaker
 
Last edited:
Status
Not open for further replies.
Top