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

Hero Respawn Timer Issue

Status
Not open for further replies.
Level 10
Joined
Sep 25, 2013
Messages
521
Why does this work?
When i put the arrary of the timer as a player number, then the timer works. It shows the time remaining, 60 for example.

  • Untitled Trigger 001
    • Events
    • Conditions
    • Actions
      • Countdown Timer - Start HeroRespawn_Timer[(Player number of (Owner of (Triggering unit)))] as a One-shot timer that will expire in (Real(HeroRespawn_Duration)) seconds
But, when i do this

  • Untitled Trigger 001 Copy
    • Events
    • Conditions
    • Actions
      • Countdown Timer - Start HeroRespawn_Timer[1] as a One-shot timer that will expire in (Real(HeroRespawn_Duration)) seconds
It doesnt show a number in the timer window. I was trying to use unit custom values so i could have MUI hero respawn timers, but custom values dont work. not even just putting a predefined integer works.
Thank you for your time
 
Level 12
Joined
Mar 13, 2020
Messages
421
I Check
I mean, I've always used triggering unit for when a unit dies and its works

My misunderstand i read it wrong you Want to Use a simple number as Array ?

can i ask How much Players do your map have and How much (Computer) You Use and which Color They have or how much Forces/Teams ist have...

because i think there is a was to easy Trigger all of this in one...
 
Last edited:
Level 10
Joined
Sep 25, 2013
Messages
521
No i want to use a units custom value, which will be set with a unit indexer, as the array number for the timer. This way if a player has multiple heroes and they all die there can be a respawn timer and timer window for each one of them that wont conflict with eachother. It shouldn't matter how many players i don't think but there are 8 players on my map. No computers.
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,503
You need to initialize timer arrays manually, unlike most other variable arrays. See -> How can I deal with timer array ?

Basically, in the Variable Editor, change the Array Size of your Timer variable to however many you need (if it's a 24 player game and you want 1 timer per player then set it's Size to 24).

Then I believe you have to create the timers using Custom Script (jass):
  • Custom script: set udg_MyTimer[1] = CreateTimer()
If you plan to use this with Custom Value then you might need to clean up your timers when they're done to avoid leaks:
  • Custom script: call DestroyTimer(udg_MyTimer[1])
But if these Custom Values don't change then you DON'T have to destroy the Timer. That'd be the case with Heroes since they never truly "die", therefore their Custom Value never changes.
Then again that may not be true depending on which Unit Indexing system you use. I recommend using Bribe's Unit Indexer.
 
Last edited:

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,503
The Getters/Setters:

SetUnitUserData(put unit here)
GetUnitUserData(put unit here)

Trigger example of setting a unit's custom value to 100 and then getting this value from the unit and storing it in a global Integer variable for easy use.
  • Custom script: call SetUnitUserData(udg_SomeUnit, 100)
  • Custom script: set udg_SomeInteger = GetUnitUserData(udg_SomeUnit)
udg_ is a prefix that tells the Custom Script that you're talking about a User Declared Global variable. This is needed so that the code can read the difference between a user declared global variable and one written purely in Jass.
In other words, the code knows that the variable came from the Variable Editor (in GUI) because it has the _udg prefix.
 
Level 10
Joined
Sep 25, 2013
Messages
521
The Getters/Setters:

SetUnitUserData(put unit here)
GetUnitUserData(put unit here)

Trigger example of setting a unit's custom value to 100 and then getting this value from the unit and storing it in a global Integer variable for easy use.
  • Custom script: call SetUnitUserData(udg_SomeUnit, 100)
  • Custom script: set udg_SomeInteger = GetUnitUserData(udg_SomeUnit)
udg_ is a prefix that tells the Custom Script that you're talking about a User Declared Global variable. This is needed so that the code can read the difference between a user declared global variable and one written purely in Jass.
In other words, the code knows that the variable came from the Variable Editor (in GUI) because it has the _udg prefix.

I have a question. I wanted to index heroes so i made a basic indexer. How would I use custom script like you have shown to take the custom value and add +1 for each entering unit.
  • Hero Custom Value Enters Map
    • Events
      • Unit - A unit enters (Playable map area)
    • Conditions
      • ((Triggering unit) is A Hero) Equal to True
    • Actions
      • Set VariableSet HeroCustomValue = (HeroCustomValue + 1)
      • Unit - Set the custom value of (Triggering unit) to HeroCustomValue
      • Game - Display to (All players) the text: (String((Custom value of (Triggering unit))))
I know this example doesnt make sense but i dont know anything about jass

  • Untitled Trigger 003
    • Events
    • Conditions
    • Actions
      • Custom script: call SetUnitUserData (udg_triggeringunit, customvalueinteger + 1)
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,503
I don't see why you would need to do that, your first trigger works just fine. The first hero will be given a Custom Value of 1, the second a value of 2, etc... You may want to add a Boolean Array like "hasBeenIndexed" to the trigger, which you set to True when you index a new hero, this way a hero doesn't get indexed twice by accident (say if it enters the map a second time).
  • Events:
  • Unit - A unit enters (Playable map area)
  • Conditions:
  • ((Triggering unit) is A Hero) Equal to True
  • hasBeenIndexed[Custom value of Triggering unit] Equal to False
  • Actions:
  • Set Variable CustomValue = CustomValue + 1
  • Unit - Set the custom value of (Triggering unit) to CustomValue
  • Set Variable hasBeenIndexed[CustomValue] = True
So again, I'm not sure why you'd need to remake your first trigger. Can you explain what you're trying to achieve?


Anyway, it would look something like this, unless I'm misunderstanding what you want:
  • Set Variable SomeUnit = Triggering unit
  • Set Variable CV = Custom value of Triggering unit
  • Custom script: call SetUnitUserData ( udg_SomeUnit, udg_CV + 1 )
Or if you didn't want to use global variables:
  • Custom script: call SetUnitUserData ( GetTriggerUnit(), GetUnitUserData(GetTriggerUnit()) + 1 )
GetTriggerUnit() = Triggering unit

If you are ever unsure about the Jass names for things, you can convert a trigger to custom text and see what everything looks like in Jass form. For example, make a copy of your first trigger, then convert it to custom text.
 
Last edited:
Status
Not open for further replies.
Top