Need some help, i thought i knew how to get a timer window to work, but now im not so sure. Here is the trigger, it occurs when a hero dies, and is supposed to show the respawn timer for them while they wait.
Timer - Start (New timer) as a One Shot timer that will expire in 10.0 Real Time seconds
Variable - Set Respawn Timer[Player owning unit] = (Last started timer)
Timer - Create a timer window for (Last started timer), with the title "Time until respawn", using Remaining time (initially Hidden)
Variable - Set Respawn Timer Window[Player owning unit] = (Last created timer window)
Timer - Show Respawn Timer Window[Player owning unit] for Player
Player owning unit is a local variable set because technically a player isnt triggering this trigger. I used text messages to verify that the proper player number is being saved to that variable.
On a side note, when i kill anything in the map, i get an ArrayIndex Overflow originating from this trigger, which is bizarre because the events that run this trigger are Unit - Hero[1] dies. Not sure why killing a zergling would trigger this at all (its not one of the heros). Any help would be appreciated
Now that i read that, here is the full trigger so you guys have all the facts.
Hero Death
Events
Unit - Hero[1] dies
Unit - Hero[2] dies
Unit - Hero[3] dies
Unit - Hero[4] dies
Local Variables
Player owning unit = 0 <Integer>
Player = (Empty player group) <Player Group>
Conditions
Actions
Variable - Set Player owning unit = (Owner of (Triggering unit))
Player Group - Add player Player owning unit to Player
Variable - Set Hero[Player owning unit] = No Unit
Timer - Start (New timer) as a One Shot timer that will expire in 10.0 Real Time seconds
Variable - Set Respawn Timer[Player owning unit] = (Last started timer)
Timer - Create a timer window for (Last started timer), with the title "Time until respawn", using Remaining time (initially Hidden)
Variable - Set Respawn Timer Window[Player owning unit] = (Last created timer window)
Timer - Show Respawn Timer Window[Player owning unit] for Player
General - Wait for (Last started timer) to have 0.0 seconds Remaining
General - If (Conditions) then do (Actions) else do (Actions)
If
Class[Player owning unit] == 1
Then
Unit - Create 1 Marine Hero for player Player owning unit at (Start location of player Player owning unit) facing (Center of Targeting) (No Options)
Else
General - If (Conditions) then do (Actions) else do (Actions)
If
Class[Player owning unit] == 2
Then
Unit - Create 1 Zealot Hero for player Player owning unit at (Start location of player Player owning unit) facing (Center of Targeting) (No Options)
Else
General - If (Conditions) then do (Actions) else do (Actions)
If
Class[Player owning unit] == 3
Then
Unit - Create 1 Templar Hero for player Player owning unit at (Start location of player Player owning unit) facing (Center of Targeting) (No Options)
Else
General - If (Conditions) then do (Actions) else do (Actions)
If
Class[Player owning unit] == 4
Then
Unit - Create 1 Ghost Hero for player Player owning unit at (Start location of player Player owning unit) facing (Center of Targeting) (No Options)
Else
Variable - Set Hero[Player owning unit] = (Last created unit)
Unit - Turn Hero[Player owning unit] Status Bar state Off
Unit Group - Add Hero[Player owning unit] to Hero Group[Player owning unit]
Unit - Order Hero[Player owning unit] to ( Turn targeting ((Position of Hero[Player owning unit]) offset by 1.0 towards Run angle Player 1 degrees)) (Replace Existing Orders)
Unit Selection - Deselect all units for player Player owning unit
Camera - Set camera mouse Pitch rotation speed to 0.2 for player Player owning unit
Camera - Set camera mouse Yaw rotation speed to 0.2 for player Player owning unit
Camera - Stop Following for player Player owning unit Hero Group[Player owning unit] with the camera and Clear Current Target
Camera - Follow for player Player owning unit Hero Group[Player owning unit] with the camera and Clear Current Target
why such a long trigger to respawn the hero? You can either respawn the triggering unit via a single custom script line or store the hero in a unit type variable and then respawn it using another single line.
heres is mine for comparaison
HeroDies
Events
Unit - Any Unit dies
Local Variables
Conditions
((Unit type of (Triggering unit)) has Heroic attribute) == true
(Controller of player (Owner of (Triggering unit))) == User
Actions
General - Wait 10.0 Game Time seconds
General - Custom Script: UnitRevive(EventUnit());
Unit - Set (Triggering unit) Life (Percent) to 100.0
Unit - Move (Triggering unit) instantly to HeroSpawnLocation (No Blend)
also are u sure thats the trigger that bug when u kill zergling? sounds impossible given the event.
I got array overflow only once or twice so far and it was because the size of the array didnt increase by itself for that variable as I was used to that.. I had to manually put the size to make sure the trigger dont go over the set size.
Well the revive trigger itself works fine, that was never a problem. The unit spawns after the given amount of time set, and the bulkiness of the trigger is basically set to spawn a new unit of the same class. I havent worked with custom scripts at all, being a new map maker (will probably get into it eventually), the problem is that the timer window will not show when the trigger runs. It is counting down, due to the respawn after 10 seconds as intended, but there is no visual indicator for the timer window.
Also, it should be noted that the game uses a custom UI and the normal UI is hidden. I have used Show UI to see if for some reason hiding the UI hid the timer window, and it does not show while the normal UI is visible.
@coronbale:
Your triggers are a bit messy aint they !
Change "Timer - Show Respawn Timer Window[Player owning unit] for Player"
to "Timer - Show Respawn Timer Window[Player owning unit] for Player owning unit"
Ill try that. In the mean time, if you would be so kind as to help me see the light. Im a new coder, been at this since the game released, but im trying to learn the proper way to do this stuff. Its a learning process, i know that, but I would rather learn the proper way, than practice the wrong way. Of the above trigger, the goal of the trigger is the following:
Detect when the hero dies
Start a Timer
Show the timer
Wait for the timer to expire
Spawn the unit (same class) for the player
Add the hero to the hero unit variable
Add the hero to the hero unit group
Set the camera properties for the player
From what I have learned from countless tutorials, im pretty on mark here for accomplishing all these goals. Just wondering how i can make my code less "messy" as you called it.
Also, to your suggestion. The local variables in this trigger are Player, and Player owning unit. Player owning unit is a player group that at the beginning is set to have the Player (An integer variable set to the initial value of Triggering Player).
Actually solved this problem, turns out, silly ol me, i forgot to set the initial value for Player (local Variable) to Triggering Player. Works wonderfully now thanks for the input.
I would still like to ask your opinion on coding this better. As i said, I haven't gotten into custom scripts because while i have been learning as much as i can about how to code right and proper, i have yet to come across a tutorial that effectively teaches the ability to code via custom script, or can show me the definitive reason why my code needs it.
Im not defensive in any way here. I know I have a lot to learn about this stuff, hell ive had to rewrite my entire code more than once due to learning better and more effective ways to write the code. Just looking to take the next step here.
Maybe someone else could fill in where this guy started. The timer window still isnt showing up, and he was mentioning the messiness of the trigger. Looking to improve the quality of the work, and minimize useless code.
Need some help, i thought i knew how to get a timer window to work, but now im not so sure. Here is the trigger, it occurs when a hero dies, and is supposed to show the respawn timer for them while they wait.
Timer - Start (New timer) as a One Shot timer that will expire in 10.0 Real Time seconds Variable - Set Respawn Timer[Player owning unit] = (Last started timer) Timer - Create a timer window for (Last started timer), with the title "Time until respawn", using Remaining time (initially Hidden) Variable - Set Respawn Timer Window[Player owning unit] = (Last created timer window) Timer - Show Respawn Timer Window[Player owning unit] for Player
Player owning unit is a local variable set because technically a player isnt triggering this trigger. I used text messages to verify that the proper player number is being saved to that variable.
On a side note, when i kill anything in the map, i get an ArrayIndex Overflow originating from this trigger, which is bizarre because the events that run this trigger are Unit - Hero[1] dies. Not sure why killing a zergling would trigger this at all (its not one of the heros). Any help would be appreciated
@coronbale: Go
Now that i read that, here is the full trigger so you guys have all the facts.
Hero Death Events
Unit - Hero[1] dies
Unit - Hero[2] dies
Unit - Hero[3] dies
Unit - Hero[4] dies
Local Variables
Player owning unit = 0 <Integer>
Player = (Empty player group) <Player Group>
Conditions
Actions
Variable - Set Player owning unit = (Owner of (Triggering unit))
Player Group - Add player Player owning unit to Player
Variable - Set Hero[Player owning unit] = No Unit
Timer - Start (New timer) as a One Shot timer that will expire in 10.0 Real Time seconds
Variable - Set Respawn Timer[Player owning unit] = (Last started timer)
Timer - Create a timer window for (Last started timer), with the title "Time until respawn", using Remaining time (initially Hidden)
Variable - Set Respawn Timer Window[Player owning unit] = (Last created timer window)
Timer - Show Respawn Timer Window[Player owning unit] for Player
General - Wait for (Last started timer) to have 0.0 seconds Remaining
General - If (Conditions) then do (Actions) else do (Actions)
If
Class[Player owning unit] == 1
Then
Unit - Create 1 Marine Hero for player Player owning unit at (Start location of player Player owning unit) facing (Center of Targeting) (No Options)
Else
General - If (Conditions) then do (Actions) else do (Actions)
If
Class[Player owning unit] == 2
Then
Unit - Create 1 Zealot Hero for player Player owning unit at (Start location of player Player owning unit) facing (Center of Targeting) (No Options)
Else
General - If (Conditions) then do (Actions) else do (Actions)
If
Class[Player owning unit] == 3
Then
Unit - Create 1 Templar Hero for player Player owning unit at (Start location of player Player owning unit) facing (Center of Targeting) (No Options)
Else
General - If (Conditions) then do (Actions) else do (Actions)
If
Class[Player owning unit] == 4
Then
Unit - Create 1 Ghost Hero for player Player owning unit at (Start location of player Player owning unit) facing (Center of Targeting) (No Options)
Else
Variable - Set Hero[Player owning unit] = (Last created unit)
Unit - Turn Hero[Player owning unit] Status Bar state Off
Unit Group - Add Hero[Player owning unit] to Hero Group[Player owning unit]
Unit - Order Hero[Player owning unit] to ( Turn targeting ((Position of Hero[Player owning unit]) offset by 1.0 towards Run angle Player 1 degrees)) (Replace Existing Orders)
Unit Selection - Deselect all units for player Player owning unit
Camera - Set camera mouse Pitch rotation speed to 0.2 for player Player owning unit
Camera - Set camera mouse Yaw rotation speed to 0.2 for player Player owning unit
Camera - Stop Following for player Player owning unit Hero Group[Player owning unit] with the camera and Clear Current Target
Camera - Follow for player Player owning unit Hero Group[Player owning unit] with the camera and Clear Current Target
why such a long trigger to respawn the hero? You can either respawn the triggering unit via a single custom script line or store the hero in a unit type variable and then respawn it using another single line.
heres is mine for comparaison
HeroDies
Events
Unit - Any Unit dies
Local Variables
Conditions
((Unit type of (Triggering unit)) has Heroic attribute) == true
(Controller of player (Owner of (Triggering unit))) == User
Actions
General - Wait 10.0 Game Time seconds
General - Custom Script: UnitRevive(EventUnit());
Unit - Set (Triggering unit) Life (Percent) to 100.0
Unit - Move (Triggering unit) instantly to HeroSpawnLocation (No Blend)
also are u sure thats the trigger that bug when u kill zergling? sounds impossible given the event.
I got array overflow only once or twice so far and it was because the size of the array didnt increase by itself for that variable as I was used to that.. I had to manually put the size to make sure the trigger dont go over the set size.
@Asurax: Go
Well the revive trigger itself works fine, that was never a problem. The unit spawns after the given amount of time set, and the bulkiness of the trigger is basically set to spawn a new unit of the same class. I havent worked with custom scripts at all, being a new map maker (will probably get into it eventually), the problem is that the timer window will not show when the trigger runs. It is counting down, due to the respawn after 10 seconds as intended, but there is no visual indicator for the timer window.
Also, it should be noted that the game uses a custom UI and the normal UI is hidden. I have used Show UI to see if for some reason hiding the UI hid the timer window, and it does not show while the normal UI is visible.
@Yaos01: Go
Ill try that. In the mean time, if you would be so kind as to help me see the light. Im a new coder, been at this since the game released, but im trying to learn the proper way to do this stuff. Its a learning process, i know that, but I would rather learn the proper way, than practice the wrong way. Of the above trigger, the goal of the trigger is the following:
Detect when the hero dies
Start a Timer
Show the timer
Wait for the timer to expire
Spawn the unit (same class) for the player
Add the hero to the hero unit variable
Add the hero to the hero unit group
Set the camera properties for the player
From what I have learned from countless tutorials, im pretty on mark here for accomplishing all these goals. Just wondering how i can make my code less "messy" as you called it.
@Yaos01: Go
Also, to your suggestion. The local variables in this trigger are Player, and Player owning unit. Player owning unit is a player group that at the beginning is set to have the Player (An integer variable set to the initial value of Triggering Player).
Actually solved this problem, turns out, silly ol me, i forgot to set the initial value for Player (local Variable) to Triggering Player. Works wonderfully now thanks for the input.
I would still like to ask your opinion on coding this better. As i said, I haven't gotten into custom scripts because while i have been learning as much as i can about how to code right and proper, i have yet to come across a tutorial that effectively teaches the ability to code via custom script, or can show me the definitive reason why my code needs it.
Im not defensive in any way here. I know I have a lot to learn about this stuff, hell ive had to rewrite my entire code more than once due to learning better and more effective ways to write the code. Just looking to take the next step here.
@coronbale: Go
Maybe someone else could fill in where this guy started. The timer window still isnt showing up, and he was mentioning the messiness of the trigger. Looking to improve the quality of the work, and minimize useless code.
@coronbale: Go
have you tried making an new trigger that just sets a timer and shows it....
make a plain trigger that just shows a timer first and start from there
@SouLCarveRR: Go
Thanks for the advice, ill give it a shot.