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

[Spell] force hero to use random item from inventory

Status
Not open for further replies.
Level 21
Joined
Mar 29, 2020
Messages
1,237
hey there,

I am trying to make a spell that will make the targeted hero use a random item from its inventory. being as different items use different types of activation (unit,point,instant), not to mention passive items, i'm having a hard time triggering this without specifying pretty much every possible item and what to do if the hero has that in the selected inventory slot. is there a simpler way to do this than a seemingly endless stream of "if then else"?

is there a way to rig the AI (which knows how to appropriately use all the items) to do this for me?
 
Well, A first step is the correct direction is to select what item to use.

You can loop though all items, something along the line of:

  • GetRandomActivatableItem
    • Events
    • Conditions
    • Actions
      • Set numberOfSelectableItems = 0
      • For each (Integer loopInt) from 1 to 6, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Item: (Picked item)'s Boolean Field: Actively Used ('iusa')) Equal to True
            • Then - Actions
              • Set selectableItemsArray[numberOfSelectableItems] = (Item carried by (Triggering unit) in slot loopInt)
              • Set numberOfSelectableItems = (numberOfSelectableItems + 1)
            • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • numberOfSelectableItems Greater than 0
        • Then - Actions
          • Set tempInteger = (Random integer number between 0 and numberOfSelectableItems)
          • Set item = selectableItemsArray[tempInteger]
        • Else - Actions
Then you HAVE a random activatable item, after this, you probably need the help of Uncle or Warseeker :p
 
Ohh, with this, you can order hero to use the selected item. But the problem is the targeting and knowing the targeting mechanics of that item...

My "just solve the problem" solution would be to store an integer for each item in a hashtable, representing a "target type" (I.E. 0 for "no target", 1 for "unit", etc).
Then you can look-up the item, and just have 4 "if-else" checks, if(target type == 1), Hero - order use item targeting unit, for example.
Then you have to solve the problem of finding a target...

-- Edit --
Forgot about checking that the item is actually usable (that is, is it already on cooldown? if it costs mana, does the hero have enough mana?)
Also, you'd have to check if there is a valid target within range when "selecting item", rather than after, making it a bit harder nut to crack than my first "how would I approach the problem".
 
Last edited:

Uncle

Warcraft Moderator
Level 63
Joined
Aug 10, 2018
Messages
6,456
Here's something I threw together. It's not bug free and leaks here and there but it works with the selected Items and covers most issues you might run into.

It takes into consideration:
-Item Cooldown
-Item Cast Range
-Item Mana Cost
-Item Targeting (LIMITED functionality. Targeting works for ONLY Allies, Enemies, Both, or Self. And it will run into problems with invalid targets like Structures. This could be improved with more isBoolean variables and If Then Else checks.)

And this is rather weird but it was an easy way for me to differentiate between Point abilities and Target Unit abilities.

You'll see I use Art - Targets Attachments as a value to differentiate between Point abilities and Target Unit abilities. This is because every POINT ability in the game has a default Target Attachment of 0. It's also a value that you can safely increase on UNIT abilities without repercussions.

So what you're going to want to do is make sure that all of your UNIT-TARGETING abilities used by this system have a Target Attachment value of 2 or greater, and make sure all of your POINT-TARGETING abilities have a Target Attachment value of 0 (they should by default).

Of course Blizzard managed to screw this one up when using triggers. If you Get the Target Attachments of an Ability it will get you the Value + 1. So when I check to see if Target Attachments = 0 (so I'm checking if it's a Point ability), I actually have check to see if it's equal to 1 (0 + 1). You don't need to worry about this though as it works as long as you follow the instructions above.
 

Attachments

  • Force Use Item 1.w3m
    31.4 KB · Views: 84
Last edited:
Level 21
Joined
Mar 29, 2020
Messages
1,237
Here's something I threw together....

I assume this is great... :gg::hohum:

can you just post the trigger here since I'm using WE from the stone ages? also.. are there any functions here that are new patch specific?

So what you're going to want to do is make sure that all of your UNIT abilities used by this system have a Target Attachment value of 2 or greater, and make sure all of your POINT abilities have a Target Attachment value of 0 (they should by default).
so this should be fine with standard items, right?
 
Level 21
Joined
Mar 29, 2020
Messages
1,237
Here's something I threw together. It's not bug free and leaks here and there but it works with the selected Items and covers most issues you might run into.

It takes into consideration:
-Item Cooldown
-Item Cast Range
-Item Mana Cost
-Item Targeting (LIMITED functionality. Targeting works for ONLY Allies, Enemies, Both, or Self. And it will run into problems with invalid targets like Structures. This could be improved with more isBoolean variables and If Then Else checks.)

And this is rather weird but it was an easy way for me to differentiate between Point abilities and Target Unit abilities.

You'll see I use Art - Targets Attachments as a value to differentiate between Point abilities and Target Unit abilities. This is because every POINT ability in the game has a default Target Attachment of 0. It's also a value that you can safely increase on UNIT abilities without repercussions.

So what you're going to want to do is make sure that all of your UNIT abilities used by this system have a Target Attachment value of 2 or greater, and make sure all of your POINT abilities have a Target Attachment value of 0 (they should by default).

Of course Blizzard managed to screw this one up when using triggers. If you Get the Target Attachments of an Ability it will get you the Value + 1. So when I check to see if Target Attachments = 0 (so I'm checking if it's a Point ability), I actually have check to see if it's equal to 1 (0 + 1). You don't need to worry about this though as it works as long as you follow the instructions above.

can you post the trigger here so I can salvage the parts I can use?
 

Uncle

Warcraft Moderator
Level 63
Joined
Aug 10, 2018
Messages
6,456
Uses this system: Item Indexer v1.4.0 [GUI friendly]

  • Setup Items
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set VariableSet setup_totalItems = 4
      • -------- --------
      • Set VariableSet setup_itemType[1] = Wand of Illusion
      • Set VariableSet setup_itemAbility[1] = Item Illusions
      • Set VariableSet setup_isAlly[1] = True
      • Set VariableSet setup_isEnemy[1] = True
      • -------- --------
      • Set VariableSet setup_itemType[2] = Storm Bolter
      • Set VariableSet setup_itemAbility[2] = Storm Bolt (Item)
      • Set VariableSet setup_isAlly[2] = False
      • Set VariableSet setup_isEnemy[2] = True
      • -------- --------
      • Set VariableSet setup_itemType[3] = Crystal Ball
      • Set VariableSet setup_itemAbility[3] = Item Area Detection
      • -------- --------
      • Set VariableSet setup_itemType[4] = Roar Stick
      • Set VariableSet setup_itemAbility[4] = Roar (Item)
  • ItemCreateEvent
    • Events
      • Game - ItemEvent becomes Equal to 1.00
    • Conditions
    • Actions
      • -------- This links the Item's Ability to the Item when it's created --------
      • For each (Integer setupInt) from 1 to setup_totalItems, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Item-type of IDexItems[IDex]) Equal to setup_itemType[setupInt]
            • Then - Actions
              • Set VariableSet itemAbility[IDex] = setup_itemAbility[setupInt]
              • Set VariableSet isAlly[IDex] = setup_isAlly[setupInt]
              • Set VariableSet isEnemy[IDex] = setup_isEnemy[setupInt]
            • Else - Actions
  • Force Use Item
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Force Use Item
    • Actions
      • -------- Get the Target's Activatable Items --------
      • Set VariableSet numberOfSelectableItems = 0
      • For each (Integer loopInt) from 1 to 6, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Item carried by (Target unit of ability being cast) in slot loopInt) Not equal to No item
            • Then - Actions
              • Set VariableSet item = (Item carried by (Target unit of ability being cast) in slot loopInt)
              • Set VariableSet IDex = (Custom value of item)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Item: item's Boolean Field: Actively Used ('iusa')) Equal to True
                  • (Ability: (Item: item's Ability at index: 0)'s Boolean Field: Item Ability ('aite')) Equal to True
                  • (Ability: (Item: item's Ability at index: 0)'s Integer Level Field Mana Cost ('amcs'), of Level: 0) Less than or equal to (Integer((Mana of (Target unit of ability being cast))))
                  • onCooldown[IDex] Equal to False
                • Then - Actions
                  • Set VariableSet numberOfSelectableItems = (numberOfSelectableItems + 1)
                  • Set VariableSet selectableItems[numberOfSelectableItems] = item
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Ability: (Item: item's Ability at index: 0)'s Real Level Field Cast Range ('aran'), of Level: 0) Less than or equal to 0.00
                    • Then - Actions
                      • Set VariableSet isInstant[numberOfSelectableItems] = True
                    • Else - Actions
                      • Set VariableSet isInstant[numberOfSelectableItems] = False
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • (Ability: (Item: item's Ability at index: 0)'s Integer Field: Target Attachments ('atac')) Equal to 1
                        • Then - Actions
                          • Set VariableSet isPoint[numberOfSelectableItems] = True
                        • Else - Actions
                          • Set VariableSet isPoint[numberOfSelectableItems] = False
                • Else - Actions
            • Else - Actions
      • -------- --------
      • -------- Make the Target use a random one of these Item --------
      • Set VariableSet integer = (Random integer number between 1 and numberOfSelectableItems)
      • Set VariableSet item = selectableItems[integer]
      • Set VariableSet IDex = (Custom value of item)
      • -------- --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • isInstant[integer] Equal to True
        • Then - Actions
          • Hero - Order (Target unit of ability being cast) to use item
        • Else - Actions
          • Set VariableSet castRange[integer] = (Ability: (Item: item's Ability at index: 0)'s Real Level Field Cast Range ('aran'), of Level: 0)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • isPoint[integer] Equal to True
            • Then - Actions
              • Set VariableSet usePoint = ((Position of (Target unit of ability being cast)) offset by (Random real number between 0.00 and castRange[integer]) towards (Random angle) degrees.)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • ((Playable map area) contains usePoint) Equal to False
                • Then - Actions
                  • Custom script: call RemoveLocation (udg_usePoint)
                  • Set VariableSet usePoint = (Random point in (Playable map area))
                • Else - Actions
              • Hero - Order (Target unit of ability being cast) to use item on usePoint
              • Custom script: call RemoveLocation (udg_usePoint)
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • isAlly[IDex] Equal to True
                  • isEnemy[IDex] Equal to True
                • Then - Actions
                  • -------- Any Target --------
                  • Hero - Order (Target unit of ability being cast) to use item on (Random unit from (Units within castRange[integer] of (Position of (Target unit of ability being cast)) matching (((Matching unit) is alive) Equal to True).))
                • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • isAlly[IDex] Equal to True
                      • isEnemy[IDex] Equal to False
                    • Then - Actions
                      • -------- Ally Only --------
                      • Hero - Order (Target unit of ability being cast) to use item on (Random unit from (Units within castRange[integer] of (Position of (Target unit of ability being cast)) matching ((((Matching unit) is alive) Equal to True) and (((Matching unit) belongs to an ally of (Triggering player).) Equal to True)).))
                    • Else - Actions
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • isAlly[IDex] Equal to False
                          • isEnemy[IDex] Equal to True
                        • Then - Actions
                          • -------- Enemy Only --------
                          • Hero - Order (Target unit of ability being cast) to use item on (Random unit from (Units within castRange[integer] of (Position of (Target unit of ability being cast)) matching ((((Matching unit) is alive) Equal to True) and (((Matching unit) belongs to an ally of (Triggering player).) Equal to False)).))
                        • Else - Actions
                          • -------- Self Only --------
                          • Hero - Order (Target unit of ability being cast) to use item on (Target unit of ability being cast)
  • Set Item Cooldown
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
      • (Ability: (Unit: (Triggering unit)'s Ability with Ability Code: (Ability being cast))'s Boolean Field: Item Ability ('aite')) Equal to True
      • (Ability: (Unit: (Triggering unit)'s Ability with Ability Code: (Ability being cast))'s Real Level Field Cooldown ('acdn'), of Level: 0) Greater than 0.00
    • Actions
      • Set VariableSet real = (Cooldown of (Ability being cast), Level: 0.)
      • For each (Integer cdInt) from 1 to 6, do (Actions)
        • Loop - Actions
          • Set VariableSet item = (Item carried by (Triggering unit) in slot cdInt)
          • Set VariableSet IDex = (Custom value of item)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • itemAbility[IDex] Equal to (Ability being cast)
              • onCooldown[IDex] Equal to False
            • Then - Actions
              • Set VariableSet onCooldown[IDex] = True
              • Trigger - Run Item Cooldown Timer <gen> (ignoring conditions)
            • Else - Actions
  • Item Cooldown Timer
    • Events
    • Conditions
    • Actions
      • Custom script: local item UsedItem = udg_item
      • Wait real seconds
      • Custom script: set udg_onCooldown[GetItemUserData(UsedItem)] = false
      • Custom script: set UsedItem = null

Important Notes:
1) Make sure that all of your UNIT-TARGETING abilities used by this system have a Target Attachment value of 2 or greater, and make sure all of your POINT-TARGETING abilities used by this system have a Target Attachment value of 0 (they should by default).

2) Make sure that the Cast Range of your Instant abilities is set to 0.

3) Make sure that the abilities used by your Items are set as Item Abilities.
 
Last edited:

Uncle

Warcraft Moderator
Level 63
Joined
Aug 10, 2018
Messages
6,456
I use the Item Indexer to keep track of when an Item is on Cooldown and also to keep track of an Item's Ability/Targeting settings.

That being said, I forgot a very important step. You need to edit the ItemCreateEvent trigger that comes with the Item Indexer to work like so:
  • ItemCreateEvent
    • Events
      • Game - ItemEvent becomes Equal to 1.00
    • Conditions
    • Actions
      • -------- This links the Item's Ability to the Item when it's created --------
      • For each (Integer setupInt) from 1 to setup_totalItems, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Item-type of IDexItems[IDex]) Equal to setup_itemType[setupInt]
            • Then - Actions
              • Set VariableSet itemAbility[IDex] = setup_itemAbility[setupInt]
              • Set VariableSet isAlly[IDex] = setup_isAlly[setupInt]
              • Set VariableSet isEnemy[IDex] = setup_isEnemy[setupInt]
            • Else - Actions
So whenever an Item is created, it references the variables in the Setup Items trigger, and applies these settings to the Item. This will only occur if the Item is actually used in the Setup Items trigger.
 
Level 21
Joined
Mar 29, 2020
Messages
1,237
Uses this system: Item Indexer v1.4.0 [GUI friendly]

  • Setup Items
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set VariableSet setup_totalItems = 4
      • -------- --------
      • Set VariableSet setup_itemType[1] = Wand of Illusion
      • Set VariableSet setup_itemAbility[1] = Item Illusions
      • Set VariableSet setup_isAlly[1] = True
      • Set VariableSet setup_isEnemy[1] = True
      • -------- --------
      • Set VariableSet setup_itemType[2] = Storm Bolter
      • Set VariableSet setup_itemAbility[2] = Storm Bolt (Item)
      • Set VariableSet setup_isAlly[2] = False
      • Set VariableSet setup_isEnemy[2] = True
      • -------- --------
      • Set VariableSet setup_itemType[3] = Crystal Ball
      • Set VariableSet setup_itemAbility[3] = Item Area Detection
      • -------- --------
      • Set VariableSet setup_itemType[4] = Roar Stick
      • Set VariableSet setup_itemAbility[4] = Roar (Item)
  • ItemCreateEvent
    • Events
      • Game - ItemEvent becomes Equal to 1.00
    • Conditions
    • Actions
      • -------- This links the Item's Ability to the Item when it's created --------
      • For each (Integer setupInt) from 1 to setup_totalItems, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Item-type of IDexItems[IDex]) Equal to setup_itemType[setupInt]
            • Then - Actions
              • Set VariableSet itemAbility[IDex] = setup_itemAbility[setupInt]
              • Set VariableSet isAlly[IDex] = setup_isAlly[setupInt]
              • Set VariableSet isEnemy[IDex] = setup_isEnemy[setupInt]
            • Else - Actions
  • Force Use Item
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Force Use Item
    • Actions
      • -------- Get the Target's Activatable Items --------
      • Set VariableSet numberOfSelectableItems = 0
      • For each (Integer loopInt) from 1 to 6, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Item carried by (Target unit of ability being cast) in slot loopInt) Not equal to No item
            • Then - Actions
              • Set VariableSet item = (Item carried by (Target unit of ability being cast) in slot loopInt)
              • Set VariableSet IDex = (Custom value of item)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Item: item's Boolean Field: Actively Used ('iusa')) Equal to True
                  • (Ability: (Item: item's Ability at index: 0)'s Boolean Field: Item Ability ('aite')) Equal to True
                  • (Ability: (Item: item's Ability at index: 0)'s Integer Level Field Mana Cost ('amcs'), of Level: 0) Less than or equal to (Integer((Mana of (Target unit of ability being cast))))
                  • onCooldown[IDex] Equal to False
                • Then - Actions
                  • Set VariableSet numberOfSelectableItems = (numberOfSelectableItems + 1)
                  • Set VariableSet selectableItems[numberOfSelectableItems] = item
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Ability: (Item: item's Ability at index: 0)'s Real Level Field Cast Range ('aran'), of Level: 0) Less than or equal to 0.00
                    • Then - Actions
                      • Set VariableSet isInstant[numberOfSelectableItems] = True
                    • Else - Actions
                      • Set VariableSet isInstant[numberOfSelectableItems] = False
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • (Ability: (Item: item's Ability at index: 0)'s Integer Field: Target Attachments ('atac')) Equal to 1
                        • Then - Actions
                          • Set VariableSet isPoint[numberOfSelectableItems] = True
                        • Else - Actions
                          • Set VariableSet isPoint[numberOfSelectableItems] = False
                • Else - Actions
            • Else - Actions
      • -------- --------
      • -------- Make the Target use a random one of these Item --------
      • Set VariableSet integer = (Random integer number between 1 and numberOfSelectableItems)
      • Set VariableSet item = selectableItems[integer]
      • Set VariableSet IDex = (Custom value of item)
      • -------- --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • isInstant[integer] Equal to True
        • Then - Actions
          • Hero - Order (Target unit of ability being cast) to use item
        • Else - Actions
          • Set VariableSet castRange[integer] = (Ability: (Item: item's Ability at index: 0)'s Real Level Field Cast Range ('aran'), of Level: 0)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • isPoint[integer] Equal to True
            • Then - Actions
              • Set VariableSet usePoint = ((Position of (Target unit of ability being cast)) offset by (Random real number between 0.00 and castRange[integer]) towards (Random angle) degrees.)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • ((Playable map area) contains usePoint) Equal to False
                • Then - Actions
                  • Custom script: call RemoveLocation (udg_usePoint)
                  • Set VariableSet usePoint = (Random point in (Playable map area))
                • Else - Actions
              • Hero - Order (Target unit of ability being cast) to use item on usePoint
              • Custom script: call RemoveLocation (udg_usePoint)
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • isAlly[IDex] Equal to True
                  • isEnemy[IDex] Equal to True
                • Then - Actions
                  • -------- Any Target --------
                  • Hero - Order (Target unit of ability being cast) to use item on (Random unit from (Units within castRange[integer] of (Position of (Target unit of ability being cast)) matching (((Matching unit) is alive) Equal to True).))
                • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • isAlly[IDex] Equal to True
                      • isEnemy[IDex] Equal to False
                    • Then - Actions
                      • -------- Ally Only --------
                      • Hero - Order (Target unit of ability being cast) to use item on (Random unit from (Units within castRange[integer] of (Position of (Target unit of ability being cast)) matching ((((Matching unit) is alive) Equal to True) and (((Matching unit) belongs to an ally of (Triggering player).) Equal to True)).))
                    • Else - Actions
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • isAlly[IDex] Equal to False
                          • isEnemy[IDex] Equal to True
                        • Then - Actions
                          • -------- Enemy Only --------
                          • Hero - Order (Target unit of ability being cast) to use item on (Random unit from (Units within castRange[integer] of (Position of (Target unit of ability being cast)) matching ((((Matching unit) is alive) Equal to True) and (((Matching unit) belongs to an ally of (Triggering player).) Equal to False)).))
                        • Else - Actions
                          • -------- Self Only --------
                          • Hero - Order (Target unit of ability being cast) to use item on (Target unit of ability being cast)
  • Set Item Cooldown
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
      • (Ability: (Unit: (Triggering unit)'s Ability with Ability Code: (Ability being cast))'s Boolean Field: Item Ability ('aite')) Equal to True
      • (Ability: (Unit: (Triggering unit)'s Ability with Ability Code: (Ability being cast))'s Real Level Field Cooldown ('acdn'), of Level: 0) Greater than 0.00
    • Actions
      • Set VariableSet real = (Cooldown of (Ability being cast), Level: 0.)
      • For each (Integer cdInt) from 1 to 6, do (Actions)
        • Loop - Actions
          • Set VariableSet item = (Item carried by (Triggering unit) in slot cdInt)
          • Set VariableSet IDex = (Custom value of item)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • itemAbility[IDex] Equal to (Ability being cast)
              • onCooldown[IDex] Equal to False
            • Then - Actions
              • Set VariableSet onCooldown[IDex] = True
              • Trigger - Run Item Cooldown Timer <gen> (ignoring conditions)
            • Else - Actions
  • Item Cooldown Timer
    • Events
    • Conditions
    • Actions
      • Custom script: local item UsedItem = udg_item
      • Wait real seconds
      • Custom script: set udg_onCooldown[GetItemUserData(UsedItem)] = false
      • Custom script: set UsedItem = null

Important Notes:
1) Make sure that all of your UNIT-TARGETING abilities used by this system have a Target Attachment value of 2 or greater, and make sure all of your POINT-TARGETING abilities used by this system have a Target Attachment value of 0 (they should by default).

2) Make sure that the Cast Range of your Instant abilities is set to 0.

3) Make sure that the abilities used by your Items are set as Item Abilities.

what part of this will only work on later patches?
 

Uncle

Warcraft Moderator
Level 63
Joined
Aug 10, 2018
Messages
6,456
Edit:
Anything with the Field values that check the object editor fields of an ability. As well getting the Abilities Cooldown and most of these Ability related checks.

So mainly the 2 keys trigger, Force Use Item and Set Item Cooldown.

Your current patch came out in 2005 so who knows what else has changed since then.
 
Last edited:
Level 21
Joined
Mar 29, 2020
Messages
1,237
I use the Item Indexer to keep track of when an Item is on Cooldown and also to keep track of an Item's Ability/Targeting settings.

That being said, I forgot a very important step. You need to edit the ItemCreateEvent trigger that comes with the Item Indexer to work like so:
  • ItemCreateEvent
    • Events
      • Game - ItemEvent becomes Equal to 1.00
    • Conditions
    • Actions
      • -------- This links the Item's Ability to the Item when it's created --------
      • For each (Integer setupInt) from 1 to setup_totalItems, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Item-type of IDexItems[IDex]) Equal to setup_itemType[setupInt]
            • Then - Actions
              • Set VariableSet itemAbility[IDex] = setup_itemAbility[setupInt]
              • Set VariableSet isAlly[IDex] = setup_isAlly[setupInt]
              • Set VariableSet isEnemy[IDex] = setup_isEnemy[setupInt]
            • Else - Actions
So whenever an Item is created, it references the variables in the Setup Items trigger, and applies these settings to the Item. This will only occur if the Item is actually used in the Setup Items trigger.
how much of this is variables that are already supposed to be included and which of these should I create for this? (assuming they are integers). also does the name matter to the dot for further reference, or is it only used here?
 
Level 21
Joined
Mar 29, 2020
Messages
1,237
For each (Integer setupInt) from 1 to setup_totalItems, do (Actions)

Equal to setup_itemType[setupInt]

  • join.gif
    set.gif
    Set VariableSet itemAbility[IDex] = setup_itemAbility[setupInt]
  • empty.gif
    empty.gif
    empty.gif
    empty.gif
    line.gif
    join.gif
    set.gif
    Set VariableSet isAlly[IDex] = setup_isAlly[setupInt]
  • empty.gif
    empty.gif
    empty.gif
    empty.gif
    line.gif
    joinbottom.gif
    set.gif
    Set VariableSet isEnemy[IDex] = setup_isEnemy[setupInt]

IDex is the only one I could find. I couldn't figue out how to replicate any of this... (is it all just creating new variables? what kinds?)
 
Level 21
Joined
Mar 29, 2020
Messages
1,237
For each (Integer setupInt) from 1 to setup_totalItems, do (Actions)

are these Integers I'm suposed to set up? bc I can't find them... (I'm assuming this is "for each integer variable do X" )

(Item-type of IDexItems[IDex]) Equal to setup_itemType[setupInt]
is this an Item type comparison? if so what is the second half (I can't find it so I'm assumng I need to create it?)

thanks!

[and mayeb now that I have updated software I won't give you a week to forget how you made a trigger before I start bombarding you with questions about it...:hohum::wink:]
 

Uncle

Warcraft Moderator
Level 63
Joined
Aug 10, 2018
Messages
6,456
You're not going to see any blizzard functions by the name of setup_itemType. The variables should be very straightforward. You can also see where I created the variables in the triggers.
 
Level 21
Joined
Mar 29, 2020
Messages
1,237
what item is "stormbolter"? I was unable to find this so I used crown of the deathlord with "finger of death(item)" as this has the same type of targeting as stormbolt and I assumed that is what matters. will this work?

also I switched "roar stick"??? with scroll of the beast...
 
Last edited:

Uncle

Warcraft Moderator
Level 63
Joined
Aug 10, 2018
Messages
6,456
Those are supposed to be your map's Items. I just created a bunch of examples for testing.

You need to put in all of your Items/Item Abilities that will use the system. So basically any Item that a Hero can be forced to use. Then you adjust it's settings depending on the circumstances.

The example items were meant to show off the targeting/usage of different Ability mechanics:

Storm Bolter = Target enemy unit
Roar Stick = Instant AoE (You can rely on this abilities Targets Allowed instead of needing to code it)
Wand of Illusion = Any target unit
Crystal Ball = Target point (You can rely on this abilities Targets Allowed instead of needing to code it)

Now like I said before, the system isn't perfect. It doesn't take into consideration many things. For instance, I don't filter out Structures, so a unit may try to Wand of Illusion a nearby Structure (failing to do so). You'll have to add your own conditions for these, you can use my Boolean approach that I use with IsAlly, IsEnemy, etc...
 
Last edited:
Level 21
Joined
Mar 29, 2020
Messages
1,237
so now I recreated what you sent (and who know, maybe by some chance I did it right...). since I just copied this mechanically without really understanding the process properly I have some more questions -

a. do I have to insert every single item in the right category? like where you put storm bolter i put seperate lines of script fo each "target enemy unit" item and it's respective abilities? or does every item need a completely individual set-up? :hohum: [as in to have four lines of script for each item or just two...]

b. all the variables - setup_... - are those new independent variables or is there a function that links me to the existing variables like that? (currently I have it as multiple variables - I.E. - there is a "isEnemy" variable array, and a "setup_isEnemy" variable array)

thanks!
 
Level 21
Joined
Mar 29, 2020
Messages
1,237
I was debating if to have this as a separate thread or not, but I think bc the mechanics are so similar I'll just stick it here (definitely not a double post though...)

another similar, but much simpler ability I want to make which can probably "hitch a ride" on the systems already incorporated in the previous spell (If i ever manage to get that up and running) is a random item swap. the caster and the target hero switch random items from their inventories. whats the simplest way to go about that? the part I need help with is mainly selecting a random -but full- inventory slot. I don't understand enough of the previous spell to know how to snip out the right parts, and i assume this is much simpler anyways...

thanks again!
 

Uncle

Warcraft Moderator
Level 63
Joined
Aug 10, 2018
Messages
6,456
a. Each item needs to be Indexed along with it's ability. Follow the pattern in my Setup trigger. The default values for the Booleans is false, so you can leave the Boolean fields blank if your ability doesn't need them. I do this with Roar and Item Area Detection as these don't require Filters for targeting.

b. Yes, they're separate variables. Setup is for the setup trigger, the non-setup versions are used in the Item Create Event triggers.

Look at ThompZon's post, it shows you the code for counting the number of selectable items a unit has and storing them in an Array. Once you have that information for one unit you can pick a random item from the Array of selectable items, store it as a Variable like SwapItem[1], then repeat this process for your other unit. But instead of storing that other unit's Item as SwapItem[1], store it as SwapItem[2]. After this process is over for both units you will have SwapItem[1] and SwapItem[2].

Note that you can remove the Actively used check from his code as you just want to swap any type of Item.

You would also want an If Then Else that prevents the trade from happening if either of the units have 0 selectable items. A boolean called SwapFailure could be used, which you set to False at the top of your trigger (before anything else), and set to True if number of selectable items is equal to 0 for either of the units.

The last action in the trigger after SwapItem[1] and SwapItem[2] have been set (or attempted to be set) would be: If SwapFailure is equal to False, then Swap the Items.

And when swapping Items, make sure to drop them first from both units, this way the units have inventory space.
 
Last edited:

Uncle

Warcraft Moderator
Level 63
Joined
Aug 10, 2018
Messages
6,456
You can reuse them, I literally copied what he did with my own variables. Just about anything that doesn't use Waits is re-usable (under the correct circumstances). And of course the setup variables cannot be reused as they're meant to keep track of your Items/Abilities for the rest of the game.

Just remember that stuff I told you about Actions causing other Events to go off. It doesn't apply here and I don't use any Waits so that should tell you that it's safe.
 
Last edited:
Level 21
Joined
Mar 29, 2020
Messages
1,237
this is the Item swap spell. Its not working. what did I do wrong?

  • Swap Item
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to The Old Switcheroo
    • Actions
      • Set Temptarget = (Target unit of ability being cast)
      • Set numberOfInventoryItems = 0
      • For each (Integer loopInt) from 1 to 6, do (Actions)
        • Loop - Actions
          • Set selectableItems[numberOfInventoryItems] = (Item carried by (Triggering unit) in slot loopInt)
          • Set numberOfInventoryItems = (numberOfInventoryItems + 1)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • numberOfInventoryItems Greater than 0
        • Then - Actions
          • Set tempinteger = (Random integer number between 0 and numberOfInventoryItems)
          • Set SwapItem[1] = SelectableItems[tempinteger]
        • Else - Actions
      • Set numberOfInventoryItems = 0
      • For each (Integer loopInt) from 1 to 6, do (Actions)
        • Loop - Actions
          • Set selectableItems[numberOfInventoryItems] = (Item carried by Temptarget in slot loopInt)
          • Set numberOfInventoryItems = (numberOfInventoryItems + 1)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • numberOfInventoryItems Greater than 0
        • Then - Actions
          • Set tempinteger = (Random integer number between 0 and numberOfInventoryItems)
          • Set SwapItem[2] = SelectableItems[tempinteger]
        • Else - Actions
      • Hero - Drop SwapItem[1] from (Triggering unit)
      • Hero - Drop SwapItem[2] from Temptarget
      • Hero - Give SwapItem[1] to Temptarget
      • Hero - Give SwapItem[2] to (Triggering unit)
 

Uncle

Warcraft Moderator
Level 63
Joined
Aug 10, 2018
Messages
6,456
My mistake, I forgot I had added extra stuff to my version. In order to ensure that an inventory slot actually has an Item, you need an If Then Else inside of your loops:
  • (Item carried by (Target unit of ability being cast) in slot loopInt) Not equal to No item
If it's true THEN you should run the Loop - Actions

This way you're only increasing numberOfInventoryItems if an Item was found in that Inventory slot. Same goes for setting selectableItems[numberOfInventoryItems].

You're also missing the Boolean I suggested that prevents cases where one or both of the units don't have any Items to swap.
 
Level 21
Joined
Mar 29, 2020
Messages
1,237
where exactly does that go?


i'm guessing this is wrong...bc it didn't work
  • Swap Item
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to The Old Switcheroo
    • Actions
      • Set Temptarget = (Target unit of ability being cast)
      • Set numberOfInventoryItems = 0
      • For each (Integer loopInt) from 1 to 6, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Item carried by (Triggering unit) in slot loopInt) Not equal to No item
            • Then - Actions
              • Set selectableItems[numberOfInventoryItems] = (Item carried by (Triggering unit) in slot loopInt)
              • Set numberOfInventoryItems = (numberOfInventoryItems + 1)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • numberOfInventoryItems Greater than 0
                • Then - Actions
                  • Set tempinteger = (Random integer number between 0 and numberOfInventoryItems)
                  • Set SwapItem[1] = SelectableItems[tempinteger]
                • Else - Actions
            • Else - Actions
      • Set numberOfInventoryItems = 0
      • For each (Integer loopInt) from 1 to 6, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Item carried by Temptarget in slot loopInt) Not equal to No item
            • Then - Actions
              • Set selectableItems[numberOfInventoryItems] = (Item carried by Temptarget in slot loopInt)
              • Set numberOfInventoryItems = (numberOfInventoryItems + 1)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • numberOfInventoryItems Greater than 0
                • Then - Actions
                  • Set tempinteger = (Random integer number between 0 and numberOfInventoryItems)
                  • Set SwapItem[2] = SelectableItems[tempinteger]
                • Else - Actions
            • Else - Actions
      • Hero - Drop SwapItem[1] from (Triggering unit)
      • Hero - Drop SwapItem[2] from Temptarget
      • Hero - Give SwapItem[1] to Temptarget
      • Hero - Give SwapItem[2] to (Triggering unit)
 
Level 21
Joined
Mar 29, 2020
Messages
1,237
did that, still not working

  • Swap Item
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to The Old Switcheroo
    • Actions
      • Set Temptarget = (Target unit of ability being cast)
      • Set numberOfInventoryItems = 0
      • For each (Integer loopInt) from 1 to 6, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Item carried by (Triggering unit) in slot loopInt) Not equal to No item
            • Then - Actions
              • Set selectableItems[numberOfInventoryItems] = (Item carried by (Triggering unit) in slot loopInt)
              • Set numberOfInventoryItems = (numberOfInventoryItems + 1)
            • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • numberOfInventoryItems Greater than 0
        • Then - Actions
          • Set tempinteger = (Random integer number between 0 and numberOfInventoryItems)
          • Set SwapItem[1] = SelectableItems[tempinteger]
        • Else - Actions
      • Set numberOfInventoryItems = 0
      • For each (Integer loopInt) from 1 to 6, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Item carried by Temptarget in slot loopInt) Not equal to No item
            • Then - Actions
              • Set selectableItems[numberOfInventoryItems] = (Item carried by Temptarget in slot loopInt)
              • Set numberOfInventoryItems = (numberOfInventoryItems + 1)
            • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • numberOfInventoryItems Greater than 0
        • Then - Actions
          • Set tempinteger = (Random integer number between 0 and numberOfInventoryItems)
          • Set SwapItem[2] = SelectableItems[tempinteger]
        • Else - Actions
      • Hero - Drop SwapItem[1] from (Triggering unit)
      • Hero - Drop SwapItem[2] from Temptarget
      • Hero - Give SwapItem[1] to Temptarget
      • Hero - Give SwapItem[2] to (Triggering unit)
I know I still didn't add the boolean you suggested... first I just want to get it working basically and the I will polish it up...
 

Uncle

Warcraft Moderator
Level 63
Joined
Aug 10, 2018
Messages
6,456
Try moving:
  • Set numberOfInventoryItems = (numberOfInventoryItems + 1)
To above:
  • Set selectableItems[numberOfInventoryItems] = (Item carried by (Triggering unit) in slot loopInt)
And then set:
  • Set tempinteger = (Random integer number between 0 and numberOfInventoryItems)
To a random integer number between 1 and numberOfInventoryItems

Then at the end of the trigger display the names of SwapItem[1] and SwapItem[2]
 
Level 21
Joined
Mar 29, 2020
Messages
1,237
still nothing... getting (null)(null) as text.


  • Swap Item
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to The Old Switcheroo
    • Actions
      • Set Temptarget = (Target unit of ability being cast)
      • Set numberOfInventoryItems = 0
      • For each (Integer loopInt) from 1 to 6, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Item carried by (Triggering unit) in slot loopInt) Not equal to No item
            • Then - Actions
              • Set numberOfInventoryItems = (numberOfInventoryItems + 1)
              • Set selectableItems[numberOfInventoryItems] = (Item carried by (Triggering unit) in slot loopInt)
            • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • numberOfInventoryItems Greater than 0
        • Then - Actions
          • Set tempinteger = (Random integer number between 1 and numberOfInventoryItems)
          • Set SwapItem[1] = SelectableItems[tempinteger]
          • Game - Display to (All players) for 5.00 seconds the text: (Name of SwapItem[1])
        • Else - Actions
      • Set numberOfInventoryItems = 0
      • For each (Integer loopInt) from 1 to 6, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Item carried by Temptarget in slot loopInt) Not equal to No item
            • Then - Actions
              • Set numberOfInventoryItems = (numberOfInventoryItems + 1)
              • Set selectableItems[numberOfInventoryItems] = (Item carried by Temptarget in slot loopInt)
            • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • numberOfInventoryItems Greater than 0
        • Then - Actions
          • Set tempinteger = (Random integer number between 1 and numberOfInventoryItems)
          • Set SwapItem[2] = SelectableItems[tempinteger]
          • Game - Display to (All players) for 5.00 seconds the text: (Name of SwapItem[2])
        • Else - Actions
      • Hero - Drop SwapItem[1] from (Triggering unit)
      • Hero - Drop SwapItem[2] from Temptarget
      • Hero - Give SwapItem[1] to Temptarget
      • Hero - Give SwapItem[2] to (Triggering unit)
 
Level 21
Joined
Mar 29, 2020
Messages
1,237
wow. crazy catch. that did it. once again thanks a ton!

I just put the boolean in and it also works of course, but is there any way I could have the spell not agree to cast (like when you try casting on the wrong kind of target type) when swapfailure=true?
 

Uncle

Warcraft Moderator
Level 63
Joined
Aug 10, 2018
Messages
6,456
You could reset the cooldown of the ability and refund the mana cost when Failure = True.
  • Actions
    • Unit - For Unit (Triggering unit), end cooldown of ability (Ability being cast)
    • Unit - Set mana of (Triggering unit) to ((Mana of (Triggering unit)) + (Real((For (Triggering unit), Mana cost of (Ability being cast), Level ((Level of (Ability being cast) for (Triggering unit)) - 1).))))
If that has unwanted results, you can run the Failure check in another trigger that uses the "A unit begins casting an ability" Event. Then order the Caster to "stop" if Failure = True. Just make sure you don't actually Swap the Items in this one, since we only want that to happen in the "A unit starts the effect of an ability" trigger.

So it'd be something like:
  • Untitled Trigger 001
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
      • (Ability being cast) Equal to Switcheroo
    • Actions
      • -------- Check each unit's Inventory and Set SwapItem[1] and SwapItem[2] --------
      • -------- If SwapFailure = True then Order triggering unit to "stop" --------
 
Last edited:
Level 21
Joined
Mar 29, 2020
Messages
1,237
I just copied the previous trigger and took out the things that seemed unnecessary. it works great now! thank you!!!

final results:

  • Swap Item
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to The Old Switcheroo
    • Actions
      • Set SwapFailure = False
      • Set Temptarget = (Target unit of ability being cast)
      • Set numberOfInventoryItems = 0
      • For each (Integer loopInt) from 1 to 6, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Item carried by (Triggering unit) in slot loopInt) Not equal to No item
            • Then - Actions
              • Set numberOfInventoryItems = (numberOfInventoryItems + 1)
              • Set selectableItems[numberOfInventoryItems] = (Item carried by (Triggering unit) in slot loopInt)
            • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • numberOfInventoryItems Greater than 0
        • Then - Actions
          • Set tempinteger = (Random integer number between 1 and numberOfInventoryItems)
          • Set SwapItem[1] = selectableItems[tempinteger]
          • Game - Display to (All players) for 5.00 seconds the text: (Name of SwapItem[1])
        • Else - Actions
          • Set SwapFailure = True
      • Set numberOfInventoryItems = 0
      • For each (Integer loopInt) from 1 to 6, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Item carried by Temptarget in slot loopInt) Not equal to No item
            • Then - Actions
              • Set numberOfInventoryItems = (numberOfInventoryItems + 1)
              • Set selectableItems[numberOfInventoryItems] = (Item carried by Temptarget in slot loopInt)
            • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • numberOfInventoryItems Greater than 0
        • Then - Actions
          • Set tempinteger = (Random integer number between 1 and numberOfInventoryItems)
          • Set SwapItem[2] = selectableItems[tempinteger]
          • Game - Display to (All players) for 5.00 seconds the text: (Name of SwapItem[2])
        • Else - Actions
          • Set SwapFailure = True
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • SwapFailure Equal to False
        • Then - Actions
          • Hero - Drop SwapItem[1] from (Triggering unit)
          • Hero - Drop SwapItem[2] from Temptarget
          • Hero - Give SwapItem[1] to Temptarget
          • Hero - Give SwapItem[2] to (Triggering unit)
        • Else - Actions
  • dont Swap Item
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
      • (Ability being cast) Equal to The Old Switcheroo
    • Actions
      • Set SwapFailure = False
      • Set Temptarget = (Target unit of ability being cast)
      • Set numberOfInventoryItems = 0
      • For each (Integer loopInt) from 1 to 6, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Item carried by (Triggering unit) in slot loopInt) Not equal to No item
            • Then - Actions
              • Set numberOfInventoryItems = (numberOfInventoryItems + 1)
              • Set selectableItems[numberOfInventoryItems] = (Item carried by (Triggering unit) in slot loopInt)
            • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • numberOfInventoryItems Less than 1
        • Then - Actions
          • Set SwapFailure = True
        • Else - Actions
      • Set numberOfInventoryItems = 0
      • For each (Integer loopInt) from 1 to 6, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Item carried by Temptarget in slot loopInt) Not equal to No item
            • Then - Actions
              • Set numberOfInventoryItems = (numberOfInventoryItems + 1)
              • Set selectableItems[numberOfInventoryItems] = (Item carried by Temptarget in slot loopInt)
            • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • numberOfInventoryItems Less than 1
        • Then - Actions
          • Set SwapFailure = True
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • SwapFailure Equal to True
        • Then - Actions
          • Unit - Order (Triggering unit) to Stop
          • Game - Display to (Player group((Triggering player))) for 1.00 seconds the text: |cffffff00Can only ...
          • Wait 0.00 seconds
          • Animation - Play (Triggering unit)'s stand animation
        • Else - Actions


thank you!!!

[and eventually I'll be back to the first part of this thread when I get around to indexing every item on my map...]
 
Level 21
Joined
Mar 29, 2020
Messages
1,237
and eventually I'll be back to the first part of this thread when I get around to indexing every item on my map...

I'm a man of my word.

hey, @Uncle I'm back to finally finish this ability. There are still a few building blocks in this trigger which I don't really understand enough to feel comfortable tinkering around with freely.

Now like I said before, the system isn't perfect. It doesn't take into consideration many things. For instance, I don't filter out Structures, so a unit may try to Wand of Illusion a nearby Structure (failing to do so). You'll have to add your own conditions for these, you can use my Boolean approach that I use with IsAlly, IsEnemy, etc...

where in the triggers do I need to stick these booleans?

thanks a lot. and I'm pretty sure this is the last round of bugging you about this trigger.... and really thanks a lot.
 

Uncle

Warcraft Moderator
Level 63
Joined
Aug 10, 2018
Messages
6,456
Look at the Force Use Item trigger, at the bottom it has all of possible outcomes in a big If Then Else.

If isInstant then do X, else if isPoint then do X, else if isTarget then do X, else, etc...

You'll see that I was pretty lazy with the execution, leaking unit groups and not taking into consideration many things. It was intended to be a proof of concept rather than a fully functional system.

Anyway, that's where you'll need to check your new boolean variables, and the setting of these Booleans should be in the Setup Item trigger where I link them to their associated Item-type.

Note that it could get crazy convoluted and messy, so you've been forewarned.

You're essentially recreating the "Targets Allowed" system that you find on Abilities in the Object Editor, but through triggers.

I imagine there's a better way of going about this (there always is), but GUI is rather limiting.
 
Last edited:
Status
Not open for further replies.
Top