I just finished Onetwo's tutorial on Diablo style controls. It all works as advertised but I did run into one problem when trying to marry that tutorial with a simple hero selection dialog. Here is my Hero Selection trigger:
ChooseHero
Events
Dialog - Any Dialog Item is used by Player Any Player with event type Clicked
Local Variables
Conditions
Or
Conditions
(Used dialog item) == ChooseHero1
(Used dialog item) == ChooseHero2
(Used dialog item) == ChooseHero3
Actions
Dialog - Hide HeroDialog for (Player group((Triggering player)))
General - Switch (Actions) depending on (Used dialog item)
Cases
General - If (ChooseHero1)
Actions
Unit - Create 1 Zealot (Prisoner) for player (Triggering player) at Start Local facing 270.0 degrees (No Options)
General - If (ChooseHero2)
Actions
Unit - Create 1 Stalker for player (Triggering player) at Start Local facing 270.0 degrees (No Options)
General - If (ChooseHero3)
Actions
Unit - Create 1 Karass for player (Triggering player) at Start Local facing 270.0 degrees (No Options)
Default
And then here is the map initialization trigger:
Initialization
Events
Game - Map initialization
Local Variables
Conditions
Actions
UI - Disable mouse drag selection for (All players)
Player - Make all players in (Active Players) treat each other as Ally
Variable - Set Heros[1] = (Value)
Variable - Set Heros[2] = (Value)
Variable - Set Heros[3] = (Value)
Player Group - Pick each player in (Active Players) and do (Actions)
Actions
General - If (Conditions) then do (Actions) else do (Actions)
If
(Controller of player (Picked player)) == User
Then
Camera - Pan the camera for player (Picked player) to (Position of Heros[(Picked player)]) over 0.0 seconds with Existing Velocity% initial velocity, 10% deceleration, and Do Not use smart panning
Camera - Follow for player (Picked player) (Unit group(Heros[(Picked player)])) with the camera and Clear Current Target
Camera - Lock camera input for player (Picked player)
Variable - Set Player Spell Info[(Picked player)].Right Mouse Spell = Zeratul - Blink
Variable - Set Player Spell Info[(Picked player)].Right Mouse Spell Requires Target = False
Variable - Set Player Spell Info[(Picked player)].Right Mouse Spell Requires Ground = True
Variable - Set Player Spell Info[(Picked player)].Right Mouse Spell Cooldown = 0.5
UI - Display "Blink set to right mouse. " for (Player group((Picked player))) to Subtitle area
Else
Now, the Variable - Set Heros[1] = (Value) works when a unit (matching the value) is already on the map when I test it. But when I try to incorporate the created zealot from my hero selection trigger it doesn't seem to work. My first thought was to replace value with "last created unit" but that doesn't work. I have tried many other options but I haven't been able to solve this and I am pulling my hair our over it because it seems like it should be a very simple solution. I am still relatively new to the editor so it wouldn't surprise me if what I am looking for is right under my nose. Any immediate thoughts on what my problem would be? How can set up the variable to equal my selected/last created units?
If I need to give more information just let me know.
You'll put 3 seperate if then elses in here, one per hero. For the condition of the first one we want a comparison that compares "Unit Weapon" and you'll set it up like this:
((Created unit) weapon 1) == Zealot - Psi Blades
This will only run if the created unit uses this weapon. This might not be the best possible way to accomplish what you're trying to do, but I think it should get the job done.
Rollback Post to RevisionRollBack
Stuff I've worked on: Carbot's StarCrafts Mod (2014-present) StarCraft 2 Hotkey Trainer (2010) | Mineralz Evolution (2011+) | Dungeon Legacy (2013+) | Phoenix TLMC 4 Entry (2014) Assisted: City of Tempest (2012) | BarCraft (2013) | Poker Defense (2014) and a few more.
Not sure if I understand this right, but you want to set the variable to the unit created in the hero selection trigger? Just add the "Set Heroes[Number] == (Last Created Unit)" right after the "Create Unit" action (It *has* to be in the same trigger (Keep in mind that wait actions reset functions like "triggering unit" and "last created unit" and so on))
Always. All data relating to an event or trigger action is reset if a wait is used - There are exceptions of course, like loop related stuff ("Picked Player" and so on), but all the "Triggering" and "Last created" stuff is lost after a wait (Considering you can have waits that last for hours, keeping all that data in memory isn't really that efficient)
If you want to use one of those values after a wait, simply use a local variable to save that value before the wait. (Keep in mind that certain things simply cease to exist after time, so if you save a unit to a local variable and it gets killed before the wait is over, the variable will be empty (Unless the unit had a death time high enough to still exist))
All the contrary, actually. Both Triggering Unit/Player/whatever and Last Created whatever are stored locally for each trigger and persist through a wait. They can get lost in some cases, like the mentioned example of a dead of a unit, the triggering unit won't exist anymore after a wait, but in general, those event reactions are pretty safe to use.
However, it is still considered better to store everything in local variables to avoid any possible complications and to improve organization and readability.
@ OP: You could alter the movement system to not start at map initialization, you could incorporate it into your second trigger to start, when a hero is picked and register that hero immediately, somewhat like this:
Thanks for the replies. I got it working with TheAlmaity's suggestion. It reminded me of something Onetwo said in one of his tutorials, "Order matters"... and I feel a little dim for not considering it. And yeah, of course I had to move the camera actions to the same trigger as well... live and hopefully learn I suppose. Thanks again.
All the contrary, actually. Both Triggering Unit/Player/whatever and Last Created whatever are stored locally for each trigger and persist through a wait. They can get lost in some cases, like the mentioned example of a dead of a unit, the triggering unit won't exist anymore after a wait, but in general, those event reactions are pretty safe to use.
However, it is still considered better to store everything in local variables to avoid any possible complications and to improve organization and readability.
Okay :)
In the end it doesn't really matter because I never used "Triggering X" or "Last Created Y" anyway except for setting up a variable. Was just out of curiosity.
I just finished Onetwo's tutorial on Diablo style controls. It all works as advertised but I did run into one problem when trying to marry that tutorial with a simple hero selection dialog. Here is my Hero Selection trigger:
ChooseHero
Events
Dialog - Any Dialog Item is used by Player Any Player with event type Clicked
Local Variables
Conditions
Or
Conditions
(Used dialog item) == ChooseHero1
(Used dialog item) == ChooseHero2
(Used dialog item) == ChooseHero3
Actions
Dialog - Hide HeroDialog for (Player group((Triggering player)))
General - Switch (Actions) depending on (Used dialog item)
Cases
General - If (ChooseHero1)
Actions
Unit - Create 1 Zealot (Prisoner) for player (Triggering player) at Start Local facing 270.0 degrees (No Options)
General - If (ChooseHero2)
Actions
Unit - Create 1 Stalker for player (Triggering player) at Start Local facing 270.0 degrees (No Options)
General - If (ChooseHero3)
Actions
Unit - Create 1 Karass for player (Triggering player) at Start Local facing 270.0 degrees (No Options)
Default
And then here is the map initialization trigger:
Initialization
Events
Game - Map initialization
Local Variables
Conditions
Actions
UI - Disable mouse drag selection for (All players)
Player - Make all players in (Active Players) treat each other as Ally
Variable - Set Heros[1] = (Value)
Variable - Set Heros[2] = (Value)
Variable - Set Heros[3] = (Value)
Player Group - Pick each player in (Active Players) and do (Actions)
Actions
General - If (Conditions) then do (Actions) else do (Actions)
If
(Controller of player (Picked player)) == User
Then
Camera - Pan the camera for player (Picked player) to (Position of Heros[(Picked player)]) over 0.0 seconds with Existing Velocity% initial velocity, 10% deceleration, and Do Not use smart panning
Camera - Follow for player (Picked player) (Unit group(Heros[(Picked player)])) with the camera and Clear Current Target
Camera - Lock camera input for player (Picked player)
Variable - Set Player Spell Info[(Picked player)].Right Mouse Spell = Zeratul - Blink
Variable - Set Player Spell Info[(Picked player)].Right Mouse Spell Requires Target = False
Variable - Set Player Spell Info[(Picked player)].Right Mouse Spell Requires Ground = True
Variable - Set Player Spell Info[(Picked player)].Right Mouse Spell Cooldown = 0.5
UI - Display "Blink set to right mouse. " for (Player group((Picked player))) to Subtitle area
Else
Now, the Variable - Set Heros[1] = (Value) works when a unit (matching the value) is already on the map when I test it. But when I try to incorporate the created zealot from my hero selection trigger it doesn't seem to work. My first thought was to replace value with "last created unit" but that doesn't work. I have tried many other options but I haven't been able to solve this and I am pulling my hair our over it because it seems like it should be a very simple solution. I am still relatively new to the editor so it wouldn't surprise me if what I am looking for is right under my nose. Any immediate thoughts on what my problem would be? How can set up the variable to equal my selected/last created units?
If I need to give more information just let me know.
-Muse
Ok, here's a way to get what you want to work.
Create a trigger with the event "Unit is created"
Then do an "if then else if"
You'll put 3 seperate if then elses in here, one per hero. For the condition of the first one we want a comparison that compares "Unit Weapon" and you'll set it up like this: ((Created unit) weapon 1) == Zealot - Psi Blades
This will only run if the created unit uses this weapon. This might not be the best possible way to accomplish what you're trying to do, but I think it should get the job done.
Stuff I've worked on:
Carbot's StarCrafts Mod (2014-present) StarCraft 2 Hotkey Trainer (2010) | Mineralz Evolution (2011+) | Dungeon Legacy (2013+) | Phoenix TLMC 4 Entry (2014) Assisted: City of Tempest (2012) | BarCraft (2013) | Poker Defense (2014) and a few more.
@SC2Muse: Go
Not sure if I understand this right, but you want to set the variable to the unit created in the hero selection trigger? Just add the "Set Heroes[Number] == (Last Created Unit)" right after the "Create Unit" action (It *has* to be in the same trigger (Keep in mind that wait actions reset functions like "triggering unit" and "last created unit" and so on))
Out of curiosity, do they always do that or only after a certain amount of time?
@Bommes: Go
Always. All data relating to an event or trigger action is reset if a wait is used - There are exceptions of course, like loop related stuff ("Picked Player" and so on), but all the "Triggering" and "Last created" stuff is lost after a wait (Considering you can have waits that last for hours, keeping all that data in memory isn't really that efficient)
If you want to use one of those values after a wait, simply use a local variable to save that value before the wait. (Keep in mind that certain things simply cease to exist after time, so if you save a unit to a local variable and it gets killed before the wait is over, the variable will be empty (Unless the unit had a death time high enough to still exist))
All the contrary, actually. Both Triggering Unit/Player/whatever and Last Created whatever are stored locally for each trigger and persist through a wait. They can get lost in some cases, like the mentioned example of a dead of a unit, the triggering unit won't exist anymore after a wait, but in general, those event reactions are pretty safe to use.
However, it is still considered better to store everything in local variables to avoid any possible complications and to improve organization and readability.
@ OP: You could alter the movement system to not start at map initialization, you could incorporate it into your second trigger to start, when a hero is picked and register that hero immediately, somewhat like this:
@VindicatorDX: Go
It's a good thought but I intend to have weapon upgrade/changes with my heros. Thanks for the reply.
@TheAlmaity: Go
@Kueken531: Go
Thanks for the replies. I got it working with TheAlmaity's suggestion. It reminded me of something Onetwo said in one of his tutorials, "Order matters"... and I feel a little dim for not considering it. And yeah, of course I had to move the camera actions to the same trigger as well... live and hopefully learn I suppose. Thanks again.
@Kueken531: Go
Oh, I didn't know that. Those values kept disappearing for me and people told me they always do, so yeah...
@SC2Muse: Go
No problem, glad to have helped :)
Okay :)
In the end it doesn't really matter because I never used "Triggering X" or "Last Created Y" anyway except for setting up a variable. Was just out of curiosity.