Complex Trigger Problem

Kyuft

Member
Reaction score
11
I want to create a system that selects a group of units, when just one of the units in the group is selected. I can just make it so when one unit in the group is selected, the whole unit group is selected. Simple, right? No. There will be an infinite amount of these groups, and so I cannot make unit group variables for all of them. Instead, I set up a very complex system which works... to a degree.
My System (simplified):
When a unit enters the map, it is assigned to a temporary (global variable) unit group and the units custom value (Index: 0) is set to a global integer variable, GroupDataValue. When the unit group becomes full (8 units), it converts the GroupDataValue (which starts at 1, by the way) to a string which is saved in a global string variable, GroupData. All of the units in the unit group are stored in the global data table (Index: Group[GroupData]) and the value of GroupDataValue is increased by 1, as to prepare for the next group. When a unit is selected, it's custom value (Index:0) is converted to a string, which is saved in a local variable, CustomData. Then, all units in the global data table (Index: Group[CustomData]) are selected. This, after many hours of work is working surprisingly well, however there is one major problem, considering I do not want to make it possible to only select one unit.

If I click on a unit, the whole group is selected, GREAT! Problem: Once the whole group is selected, if I click on ONE unit that is already selected, then it will be the only one selected. I assume this is because instead of deselecting all of the units in the group and selecting that one, it just deselects the others. Therefore, the trigger that detects the selection of a unit is not triggered.

Attempts:
1. I tried setting it so that when a unit is clicked (technically it also selects it) it will select the whole group, but for some reason this did not work.
2. I tried making a trigger that realizes when units are deselected. I was going to make a condition that checked if the deselected unit's custom value was equal to the currently selected unit's value (meaning that they are in the same group), and making it select the whole group of the currently selected unit, but there is no option that returns the unit that is currently selected.

Please help! I have spent 5 hours trying to perfect this, and I do not want to have to trash it all.
Thanks!

-Kyuft:cool:
 

Phubar

Ultra Cool Member
Reaction score
30
Is there a way to set the all units in that group unselectable?
Of course you have to create an action in the "Group selection trigger" that makes all your units selectable again OR only the units of the previous group (store the units in a temp group, same for all actuals groups, when you select them and use it to mae them selectable again when you select another unit/group)
 

Kyuft

Member
Reaction score
11
Only problem with that is, if I highlight and select two groups, and I want to only select one, the best way to do that would be to click on one of the units. However, if I made them unselectable, then I could not select only one of the groups, except by clicking on the ground, and then on the unit, which would get really annoying, considering my map requires a lot of micro skills.

-Kyuft:cool:
 

Phubar

Ultra Cool Member
Reaction score
30
For your 2nd attempt you want a functions that gives to you the unit selected OR that checks if the unit is in the selected ones?

Your problem is not simple and my undestandings not too big but if you change all your triggers activations fron "unit selected" to "unit clicked" you can make units temp unselectables and make checks on what units are selected when you click on a unit, make units selectable again an then continue. All the stuff about setting selectable/unselectable wont be needed if an unseletable unit can be still selected by trigger actions.
 

Kyuft

Member
Reaction score
11
The "Unit Is Clicked" event seems to do nothing, but if an untargetable unit can b targeted by triggers, then I might take a stab at your solution, although it is messy. But heh, my triggers are already messy :p

-Kyuft:cool:
 

Siretu

Starcraft 2 Editor Moderator
Reaction score
293
How is the grouping supposed to work? Are units placed in groups depending on when they enter the map? So the first 8 units are in the first group, and the next 8 units are in the next group?

Also, I know there's probably a lot of triggers, but you should probably post them anyway.
 

Kyuft

Member
Reaction score
11
Yes, they are placed in groups depending on when they enter the map because they are created in groups, rather that one at a time.
Triggers:

Trigger that adds them to groups (temporary):
Trigger:
  • Save Squad
    • Events
      • Trigger - Generic event named "Unit Added to Unit Group"
    • Local Variables
    • Conditions
    • Actions
      • Player Group - Pick each player in (Active Players) and do (Actions)
        • Actions
          • General - If (Conditions) then do (Actions) else do (Actions)
            • If
              • (Number of Living units in MarineSquad[(Picked player)]) == 8
            • Then
              • Variable - Set SquadData = (String(SquadDataValue[(Picked player)]))
              • Data Table - Save (Units in MarineSquad[(Picked player)] owned by player (Picked player), with at most 8) as "MarineSquad[" + gv_squadData + "]" in the Global data table
              • Variable - Modify SquadDataValue[(Picked player)]: + 1
              • Variable - Set MarineSquad[(Picked player)] = (Empty unit group)
            • Else
Trigger that saves their groups outside of a temporary variable:
Trigger:
  • Save Squad
    • Events
      • Trigger - Generic event named "Unit Added to Unit Group"
    • Local Variables
    • Conditions
    • Actions
      • Player Group - Pick each player in (Active Players) and do (Actions)
        • Actions
          • General - If (Conditions) then do (Actions) else do (Actions)
            • If
              • (Number of Living units in MarineSquad[(Picked player)]) == 8
            • Then
              • Variable - Set SquadData = (String(SquadDataValue[(Picked player)]))
              • Data Table - Save (Units in MarineSquad[(Picked player)] owned by player (Picked player), with at most 8) as "MarineSquad[" + gv_squadData + "]" in the Global data table
              • Variable - Modify SquadDataValue[(Picked player)]: + 1
              • Variable - Set MarineSquad[(Picked player)] = (Empty unit group)
            • Else
Trigger that selects the whole group when unit is selected:
Trigger:
  • Select Squad
    • Events
      • Unit Selection - Any Unit is Selected by player Any Player
    • Local Variables
      • DataValue = "" <String>
    • Conditions
      • (Owner of (Triggering unit)) == (Triggering player)
    • Actions
      • General - If (Conditions) then do (Actions) else do (Actions)
        • If
          • ((Triggering unit) has Marine) == True
        • Then
          • Variable - Set DataValue = (String((Custom value 0 of (Triggering unit))) with Any Precision decimal places)
          • Unit Selection - Select ("MarineSquad[" + lv_dataValue + "]" from the Global data table) for player (Triggering player)
        • Else

-Kyuft:cool:
 

Phubar

Ultra Cool Member
Reaction score
30
All units are flagged unclickable, you have to change it in data editor. I had same problem in one of my maps :)
 

Kyuft

Member
Reaction score
11
For some odd reason, making a trigger that selects a unit when it is clicked, even after editing the flags, makes no difference.

-Kyuft:cool:
 

Kyuft

Member
Reaction score
11
It is selectable because if they were unselectable and I changed the trigger event to "Unit Is Clicked", then you would not be able to highlight by dragging an area over units and selecting multiple groups.

-Kyuft:cool:
 

Phubar

Ultra Cool Member
Reaction score
30
Yes i was just thinking that "click unit" makes the drag box useless.. Sry i have to think a bit more... and i mean days :D
 

Phubar

Ultra Cool Member
Reaction score
30
Maybe this will work (i didnt understand your method of selecting units so i will explain in general way)

When a unit is deselected (this happens when you have a group selected and click on one of their units) peek all units in "units that are selected" an then select the group that contain that unit.

I cant find a function that gives back the group of a given unit... so maybe you have to do a custom function.
 

Kyuft

Member
Reaction score
11
I tried the following trigger, but it did not seem to work...

Trigger:
  • SquadDebug
    • Events
      • Unit Selection - Any Unit is Deselected by player Any Player
    • Local Variables
    • Conditions
      • (Owner of (Triggering unit)) == (Triggering player)
    • Actions
      • General - Pick each integer from 1 to (Number of Living units in (Selected units for player (Triggering player))), and do (Actions)
        • Actions
          • General - If (Conditions) then do (Actions) else do (Actions)
            • If
              • (Owner of (Triggering unit)) == (Owner of (Picked unit))
              • (Unit type of (Triggering unit)) == (Unit type of (Unit (Picked integer) from (Selected units for player (Triggering player))))
            • Then
              • Unit Group - Pick each unit in (Selected units for player (Triggering player)) and do (Actions)
                • Actions
                  • Unit Selection - Deselect (Picked unit) for player (Triggering player)
                  • Unit Selection - Select (Picked unit) for player (Triggering player)
            • Else


-Kyuft:cool:
 

Phubar

Ultra Cool Member
Reaction score
30
Sry for language error, i meant pick not peek :D
Btw... Solved! :)

Code:
TRIGGER Keep selection
    Events
        Unit selection - Any unit is Deselected by Any player
   
    Conditions
    Actions
        Unit group - Pick all units in (Units selected for player 1) and do (actions)
            Actions
                Unit group - Add (Picked unit) to To reselect
        Unit selection - Deselect To reselect for player 1
        General - Wait 0.01 seconds
        Unit selection - Select To reselect for player 1
        Unit group - remove all units from To reselect

you have to insert a wait time in oirder to make it work :)

PS i transleted my italian trigger so some words may not be correct
PPS Units selected for player 1 is a basic "group" function, you can find it under "unit selection", its called something like "Selected units" or "Unit selection".
 

Phubar

Ultra Cool Member
Reaction score
30
Just reselect the units currently selected after they were deselected. The other trigger (the one that selects the whole group when a unit is selected) will do all the work.
IMPORTANT add a little wait time between deselection and reselection
 

Kyuft

Member
Reaction score
11
Isn't your trigger almost identical to the one I posted that didn't work? Besides the wait time...

-Kyuft:cool:
 

Kyuft

Member
Reaction score
11
You are right, this does work, however, I have found a new problem. I want this "squad system" to be completely foolproof, neat, clean, and instant. I have realized that in the time it takes for the trigger to process all of the Actions, and select the rest of the squad (when a unit is selected), you can still command that single unit. I want to somehow make it so that the instant the unit is selected, the rest of the squad is selected, as if they are one big unit. However, I do not want to make a single unit for them with a model of 8 marines, because that would not flow well, and it would be very uptight. I realize that my system, although it was very tedious to make, cannot perform how I would like it to. Does anybody have any clue how to make an instant, neat system like the one I have described?

EDIT: If this can't be done, then the whole concept of my map (or at least, my favorite part) will be destroyed :(

-Kyuft:cool:
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though
  • Ghan Ghan:
    Heard Houston got hit pretty bad by storms last night. Hope all is well with TH.
  • The Helper The Helper:
    Power back on finally - all is good here no damage
    +2
  • V-SNES V-SNES:
    Happy Friday!
    +1
  • The Helper The Helper:
    New recipe is another summer dessert Berry and Peach Cheesecake - https://www.thehelper.net/threads/recipe-berry-and-peach-cheesecake.194169/

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top