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

[Trigger] [Solved] Trigger malfunctions when an Integer variable is set to the HandleID of a unit

Status
Not open for further replies.
Level 6
Joined
Jul 12, 2021
Messages
95
Trigger malfunctions when an Integer variable is set to the HandleID of a unit.

Works:
  • IntegerOfRemovingUnitsValue
    • Events
      • Player - Player 1 (Red) types a chat message containing run as An exact match
    • Conditions
    • Actions
      • Set VariableSet Unit[1] = Paladin 0000 <gen>
      • Hashtable - Save Handle OfUnit[1] as 1 of 1 in (Last created hashtable).
      • Set VariableSet TestInteger_Copy = 1
      • Quest - Display to (All players) the Quest Update message: (String(TestInteger_Copy))
      • Set VariableSet IntegerOfRemovingUnits[TestInteger_Copy] = 4
      • Quest - Display to (All players) the Quest Update message: (String(IntegerOfRemovingUnits[TestInteger_Copy]))
Doesn't work, the last line of the trigger prints 0 instead of 4:
  • IntegerOfRemovingUnitsValue
    • Events
      • Player - Player 1 (Red) types a chat message containing run as An exact match
    • Conditions
    • Actions
      • Set VariableSet Unit[1] = Paladin 0000 <gen>
      • Hashtable - Save Handle OfUnit[1] as 1 of 1 in (Last created hashtable).
      • Set VariableSet TestInteger_Copy = (Key (Load 1 of 1 in (Last created hashtable).).)
      • Quest - Display to (All players) the Quest Update message: (String(TestInteger_Copy))
      • Set VariableSet IntegerOfRemovingUnits[TestInteger_Copy] = 4
      • Quest - Display to (All players) the Quest Update message: (String(IntegerOfRemovingUnits[TestInteger_Copy]))
Works:
  • IntegerOfRemovingUnitsValue
    • Events
      • Player - Player 1 (Red) types a chat message containing run as An exact match
    • Conditions
    • Actions
      • Set VariableSet Unit[1] = Paladin 0000 <gen>
      • Hashtable - Save Handle OfUnit[1] as 1 of 1 in (Last created hashtable).
      • Set VariableSet TestInteger_Copy = (Key (Load 1 of 1 in (Last created hashtable).).)
      • Set VariableSet TestInteger_Copy = (TestInteger_Copy / 1000)
      • Quest - Display to (All players) the Quest Update message: (String(TestInteger_Copy))
      • Set VariableSet IntegerOfRemovingUnits[TestInteger_Copy] = 4
      • Quest - Display to (All players) the Quest Update message: (String(IntegerOfRemovingUnits[TestInteger_Copy]))
Why doesn't it work when the TestInteger_Copy is set to the HandleId of the Unit[1]?
What can I do to solve this problem? Do I have to divide it by 1000 for it to work?
 

Attachments

  • Hiveworkshop Integer variable is set to the HandleID of a unit.w3m
    16.7 KB · Views: 22

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,557
The index limit is 32,768, which I guess you know on account of the division. Would that method really be necessary though? Why use an Array when you can use the Hashtable for everything?

Anyway, using Custom Script I got it to display the Paladin's handle id:
  • IntegerOfRemovingUnitsValue
    • Events
      • Player - Player 1 (Red) types a chat message containing run as An exact match
    • Conditions
    • Actions
      • Set VariableSet Unit = Paladin 0000 <gen>
      • Custom script: set udg_Handle = udg_Unit
      • Hashtable - Save (Key Handle.) as 1 of 1 in (Last created hashtable).
      • -------- --------
      • Set VariableSet Int = (Load 1 of 1 from (Last created hashtable).)
      • Quest - Display to (All players) the Quest Update message: (String(Int))
      • -------- --------
      • Set VariableSet Array[Int] = 4
      • Quest - Display to (All players) the Quest Update message: (String(Array[Int]))
Array[Int] won't display though since Int is set to a value larger than 32,768 (Index Limit). Instead, it displays Array[0] which has a default value of 0.
 
Last edited:
Status
Not open for further replies.
Top