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

help: Detecting LOCAL buttons in an action thread

Status
Not open for further replies.
Level 5
Joined
Jul 10, 2010
Messages
124
I am trying to make a simple hero selection with dialog using an action definition. Here I set up a dialog action definition thread which triggers
for any player who presses the hero selection key (F6 for testing)

It makes the dialog and 6 hero buttons. I want this thread to then wait
until one of the 6 buttons is pressed. Can I do this in the same action
thread without using globals? I don't know how to keep track of the buttons
or wait until one of them is pressed.

attachment.php
 

Attachments

  • button.jpg
    button.jpg
    588.3 KB · Views: 424
Level 19
Joined
Aug 8, 2007
Messages
2,765
?...

as far as im concerned, you want to use locals in 2 triggers but dont want to use globals..? sux 4 u.

Edit : reread the post, you might be able to but idk how. You would need to track the button being pressed via a event in a new action.
 
Level 5
Joined
Jul 10, 2010
Messages
124
can I do a "wait for" line in this action that has a dialog item used? I cant make this a global because each player can bring up hero selection any time (like TF2)
 
Level 8
Joined
May 31, 2009
Messages
439
Why don't you just create a new trigger?

What is happening in your trigger right now (And the reason why it won't work) is because the system will run through your trigger as a whole (and just skip the "wait for" if the conditions aren't met) Afterwards, unless you create another trigger with the "event - a dialog button is used", that "wait for" will be completely useless.

Honestly, just replace those two buttons with globals of the same kind and create a new trigger. At the very least, combine both button actions into one trigger.
 
Level 11
Joined
Aug 1, 2009
Messages
963
can I do a "wait for" line in this action that has a dialog item used? I cant make this a global because each player can bring up hero selection any time (like TF2)
Pretty sure SC2 doesn't actually support local events or threading (everything is executed for everyone simultaneously), thus no GetLocalPlayer blocks from WC3.

At the same point in time, dialog items are specifically built to be able to have their properties different for each player. Show/hide the menu only for the players that need to see it, and you are good.

Also: globals are a necessity. :\
 
Level 5
Joined
Jul 10, 2010
Messages
124
so can I do this:

create this dialog at map initialization, save it global Dial_SelectHero
save each button as DItem_Hero[array index 0-5]

hide dialog for everyone

show dialog to players who invoke hero selection by pressing F6



I have another question now. I have the following global array of unit types, 6 unit types the correspond to each hero:

UType_Hero[0] = Marine
UType_Hero[1] = Marauder
UType_Hero[2] = Reaper
UType_Hero[3] = Ghost
UType_Hero[4] = Siege Tank
UType_Hero[5] = Thor

And the hero dialog buttons in the above dialog are also an array.

Can I detect the array index of the button pressed, or do I have to run 6 "if" statements?

What I want to do:

Event - dialog item is used
Conditions (OR)
- used item is DItem_Hero[0]
- used item is DItem_Hero[1]
- used item is DItem_Hero[2]
- used item is DItem_Hero[3]
- used item is DItem_Hero[4]
- used item is DItem_Hero[5]
Actions
- set local integer = array index of used dialog item {0,1,2,3,4,5}
- Create 1 UType_Hero[local integer] for triggering player


The alternative:

Actions
- if pressed button = DItem_Hero[x]
then created UType[x] for triggering player



And finally to be clear, the difference between modal and non-modal is that modal prevents you from controlling units while they are active right?
 
Level 11
Joined
Aug 1, 2009
Messages
963
You probably would be best off using a for loop, checking which item in the array was pressed.

Alternatively, you can use dynamic event adding + setting the current value of the dialog item to it's array position.

IE,
create dialog items (0 - 5)
save dialog items to an array
set dialog item value to its position in the array
add a "dialog item clicked" event for the dialog item to a trigger (need to use galaxy for this)
have the trigger get the dialog item's value to find its position in the array.
 
Level 5
Joined
Jul 10, 2010
Messages
124
think i figured the loop solution thats pretty efficient for my array problem

I would use the "Replace unit" action, but it breaks when either:
- player selects for first time = no unit to replace
- player tries to change class while dead = no unit to replace

so I have to use remove unit + create unit

attachment.php
 

Attachments

  • buttons.jpg
    buttons.jpg
    134 KB · Views: 180
Level 12
Joined
Apr 15, 2008
Messages
1,063
What I often do is store a dialog item's custom value in the style of the dialog item.
So what you can do is create a trigger for the hero selection with NO EVENTS. Then, when you create the dialog buttons, set each buttons style to the ID it is representing and add it to trigger events for the first trigger. Then simply convert the style to integer to get hero ID.
 
Status
Not open for further replies.
Top