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

Prevent Hero from Using Items in Region?

Status
Not open for further replies.
Level 21
Joined
Mar 16, 2008
Messages
955
Trying to make like a starting room where heroes are when they aren't on a team. So I don't want them to use any items to teleport out.

Was thinking just move them back to room if they exit room region while not being on a team.

But could you just prevent them from using items?
 

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,871
You can change their Actively Used field to False using the Item Boolean Field functions:
  • DI Create
    • Events
      • Time - Elapsed game time is 0.00 seconds
    • Conditions
    • Actions
      • Hashtable - Create a hashtable
      • Set VariableSet DI_Hashtable = (Last created hashtable)
Disable the items whenever you want:
  • DI Disable
    • Events
    • Conditions
    • Actions
      • -------- Cache the actively used state of each item and then disable each item: --------
      • Set VariableSet DI_Unit = (Triggering unit)
      • For each (Integer DI_Loop) from 1 to 6, do (Actions)
        • Loop - Actions
          • Set VariableSet DI_Item = (Item carried by DI_Unit in slot DI_Loop)
          • Custom script: set udg_DI_Handle = udg_DI_Item
          • Set VariableSet DI_Boolean = (Item: DI_Item's Boolean Field: Actively Used ('iusa'))
          • Hashtable - Save DI_Boolean as (Key DI_Handle.) of 0 in DI_Hashtable.
          • Item - Set Item: DI_Item's Boolean Field: Actively Used ('iusa') to Value: False
Then enable the items again whenever you're ready:
  • DI Enable
    • Events
    • Conditions
    • Actions
      • -------- Enable the actively used items again: --------
      • Set VariableSet DI_Unit = (Triggering unit)
      • For each (Integer DI_Loop) from 1 to 6, do (Actions)
        • Loop - Actions
          • Set VariableSet DI_Item = (Item carried by DI_Unit in slot DI_Loop)
          • Custom script: set udg_DI_Handle = udg_DI_Item
          • Set VariableSet DI_Boolean = (Load (Key DI_Handle.) of 0 from DI_Hashtable.)
          • Item - Set Item: DI_Item's Boolean Field: Actively Used ('iusa') to Value: DI_Boolean
If the unit can acquire new Items after this disabling process then you'll need to manually disable those as well.

Edit: Updated it to use a more flexible system.
 

Attachments

  • Disable Items 2.w3m
    16.7 KB · Views: 4
Last edited:
Level 21
Joined
Mar 16, 2008
Messages
955
Thank you so much! :thumbs_up:

I could simply set the events for these to "units enters..."/"...leaves region" ? and of course GUI event responses.

The player could briefly un-ally during the game and go back to the starting room.

Perhaps I could also add in silencing the unit and making it invulnerable.

EDIT: should this also use a conditional to check if the item is 'actively used' in the first place?
 

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,871
You can do that, in my example you can see I use (Triggering unit) without an Event. Add your own Events and change (Triggering unit) to whatever you want, or probably just keep it the same since it works for pretty much everything.

The condition isn't necessary either, the item will always go back to what it originally was.
 
Level 21
Joined
Mar 16, 2008
Messages
955
what if I want to exclude one particular item-type from being disabled? could i just add a conditional at the beginning of the loop?

  • DI Disable
    • Events
      • Unit - A unit enters KR Brown <gen>
      • Unit - A unit enters KR DG <gen>
      • Unit - A unit enters KR Gray <gen>
      • Unit - A unit enters KR Green <gen>
      • Unit - A unit enters KR Lght Blue <gen>
      • Unit - A unit enters KR Lght Brwn <gen>
      • Unit - A unit enters KR Lght Purp <gen>
      • Unit - A unit enters KR Lime <gen>
      • Unit - A unit enters KR OJ <gen>
      • Unit - A unit enters KR Peach <gen>
      • Unit - A unit enters KR Pink <gen>
      • Unit - A unit enters KR Yellow <gen>
    • Conditions
    • Actions
      • -------- Cache the actively used state of each item and then disable each item: --------
      • Set VariableSet DI_Unit = (Entering unit)
      • For each (Integer DI_Loop) from 1 to 6, do (Actions)
        • Loop - Actions
          • Set VariableSet DI_Item = (Item carried by DI_Unit in slot DI_Loop)
          • Custom script: set udg_DI_Handle = udg_DI_Item
          • Set VariableSet DI_Boolean = (Item: DI_Item's Boolean Field: Actively Used ('iusa'))
          • Hashtable - Save DI_Boolean as (Key DI_Handle.) of 0 in DI_Hashtable.
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Item-type of DI_Item) Not equal to Torn Black Banner
            • Then - Actions
              • Item - Set Item: DI_Item's Boolean Field: Actively Used ('iusa') to Value: False
            • Else - Actions
 
Last edited:
Status
Not open for further replies.
Top