Complex Trigger Problem

Discussion in 'Starcraft 2 (SC2) Editor Help' started by Kyuft, May 27, 2013.

  1. Phubar

    Phubar Well-Known Member

    Ratings:
    +30 / 0 / -0
    To avoid comanding unit before whole group is selected add
    -make triggering unit uncommandable
    at the very start of selection group trigger and
    -make triggering unit commandable
    after the group selection is done.
     
  2. Phubar

    Phubar Well-Known Member

    Ratings:
    +30 / 0 / -0
    To instant select you need a function that gives the group where the unit is in (cant find it... you need a custom function)
    Then you have to use "select group" base function and refer to the group (group in which the triggering unit is).
    Siretu may help with this custom function, try to tell him to take a look at this discussion (if he does not alteady done it) :)
     
  3. Dave312

    Dave312 Censored for your safe viewing

    Ratings:
    +269 / 0 / -0
    You don't need a custom function. Just use the Selected Units function to get the currently selected units for that player.

    I personally would be just using the Custom Value attribute on each unit to store which squad they belong to. Then when you need to select a squad, just cycle through all the units owned by that player and if the custom value matches the value from the unit selected, add that unit to the units selection. Should be pretty fast if a player doesn't have too many units in the game at once. I personally see data table as being quite slow but where this is actually true or not I don't know. Ofcourse this still won't solve your problem with the delay.
     
  4. Kyuft

    Kyuft Member

    Ratings:
    +11 / 0 / -0
    I have a working system right now, with custom values, but it still has a delay. very short, but its still a delay...

    -Kyuft:cool:
     
  5. Phubar

    Phubar Well-Known Member

    Ratings:
    +30 / 0 / -0
    Dave i was talking about another thing.
    If you have 3 groups (A, B and C) when you select any unit the trigger will
    -Select all unit in group (the one where the selected unit is)
    So it will select A, B or C.
     
  6. Dave312

    Dave312 Censored for your safe viewing

    Ratings:
    +269 / 0 / -0
    After some testing, it seems the delay comes from the time difference between the unit being physically selected in the game and available for orders and the Unit Selected event firing. In which case, you will never be able to remove the delay.

    As Phubar suggested, you can stop a unit being quickly given orders which the rest of his squad doesn't receive by making the unit uncommandable. To get this to work correctly, each unit needs to be made uncommandable when they are create, and then when selected, make them commandable. If a player attempts to issue an order to quickly to the unit, then the player will receive a "Unit is Uncommadable" error.
     
  7. Siretu

    Siretu Starcraft 2 Editor Moderator Staff Member

    Ratings:
    +295 / 0 / -0
    Couldn't you make another trigger that runs when a unit is selected that checks if the amount of units selected by the triggering player == 1 and if so, orders all units in that unit's group to do the same thing.

    I only skimmed throuh the thread so I might be missing some big parts of the problem.
     
  8. Phubar

    Phubar Well-Known Member

    Ratings:
    +30 / 0 / -0
    Siretu, the "problem" is that there is no function that selects or returns the group of a given unit.
    Or i cant find it..
     
  9. Siretu

    Siretu Starcraft 2 Editor Moderator Staff Member

    Ratings:
    +295 / 0 / -0
    I'm not sure what you mean.

    - Do you mean that there's no event that triggers when a unit is selected? There's the "Unit is Selected" event which should work.

    - Do you mean that there's no way to get all the other units in Kyuft's own unit groups? There should be, how else can he select all of them when one is selected?

    - Do you mean that there's no way to get all units selected by a player? Use the "Selected Units" function.

    I think I'm missing the actual problem here.
     
  10. Phubar

    Phubar Well-Known Member

    Ratings:
    +30 / 0 / -0
    None of them :)
    I mean im not able to do a thing like
    myGroup= group of (myUnit)
    ie
    unit "mom" is in group "family", unit "carl" is in group "friends".
    myGroup= group of (mom) will do myGroup=family
    If i change mom with carl myGroup=friends.

    Kyuft made a trigger for group selection but he asked to chsnge it.
     
  11. Siretu

    Siretu Starcraft 2 Editor Moderator Staff Member

    Ratings:
    +295 / 0 / -0
    The reason there's no such action is that a unit can be in several unit groups at once. Kyuft doesn't want to use real unit groups iirc, because there's going to be potentially infinite amounts of unit groups.
     
  12. Phubar

    Phubar Well-Known Member

    Ratings:
    +30 / 0 / -0
    Kyuft has already a working set of triggers but he wants to change it becouse of:

    So i think he has to keep his triggers as they are and find a way to bypass the problem of commanding a unit before the whole group is selected.
    I suggested this (to add in the trigger triggered by "Unit is selected")

    Dave said that this can be source of some bugs but i dont understand why. I keep thinking about it but i dont see wrong things.
     
  13. Siretu

    Siretu Starcraft 2 Editor Moderator Staff Member

    Ratings:
    +295 / 0 / -0
    Exactly, and my suggestion was that he keeps the triggers he already has and use my suggestion to fix his new problem.
     
  14. Phubar

    Phubar Well-Known Member

    Ratings:
    +30 / 0 / -0
    Sry but i think that your trigger wont work if he selects 2 or more units (by selection box).
    Btw he solved the "reselect a unit that is alredy selected" (using his or my solution, that are similar) and now has the problem that in the time gap between he selects a unit and the whole group is selected, he can order that unit to do something and of course the rest of the group wont take the order becouse it's not selected.
    Am i wrong? :)

    PS Kyuft can you post your map on the bnet? So we can test it and see how big is that delay.
     
  15. Kyuft

    Kyuft Member

    Ratings:
    +11 / 0 / -0
    Guys, my system works, but I guess I'll just have to get used to the .02-.05 second delay that is slightly inconvenient. Thanks though!

    -Kyuft:cool:
     
  16. Kyuft

    Kyuft Member

    Ratings:
    +11 / 0 / -0
    I will upload it soon.

    EDIT: Phubar, you have it exactly correct, however, using your solution, I can set the units invulnerable until all of the units in the squad are selected. I was just hoping that there wasn't a delay, because I want someone to be able to select the unit (and its squad) and move them instantly, rather than having to wait for the units to all be selected.

    -Kyuft:cool:
     
  17. Siretu

    Siretu Starcraft 2 Editor Moderator Staff Member

    Ratings:
    +295 / 0 / -0
    I'm sorry, this is slightly frustrating. I might just be missing the point, but I am trying to suggest a way to fix the delay problem. That's what I'm trying to solve, nothing else.

    It shouldn't be a problem if you select more units because I said to add a condition that checks that there's only one selected unit, so it excludes drag selecting several units.

    Edit:

    Here's what I'm talking about:
    Trigger:
    • Single Unit order
      • Events
        • Unit - Any Unit is issued an order to Any Ability Command
      • Local Variables
        • DataValue = "" <String>
      • Conditions
        • (Number of Living units in (Selected units for player (Triggering player))) == 1
      • Actions
        • Variable - Set DataValue = (String((Custom value 0 of (Triggering unit))) with Any Precision decimal places)
        • Unit - Order all units in ("MarineSquad[" + lv_dataValue + "]" from the Global data table) to ((Ability command for (Triggering order))) (Replace Existing Orders)

    So if you manage to select a unit and give it an order before it selects all units in the group, it automatically tells the group to do the same thing as you told the single unit. Is there any reason why this wont work?
     
  18. Kyuft

    Kyuft Member

    Ratings:
    +11 / 0 / -0
    What if i drag select 2 units in the squad?

    -Kyuft:cool:
     
  19. Siretu

    Siretu Starcraft 2 Editor Moderator Staff Member

    Ratings:
    +295 / 0 / -0
    Good point. When I think about it, my solution has some problems. I think it'll cause an infinite loop. I suggest you try it out but remove the condition and turn off the trigger first and turn it on at the end.
     
  20. Kyuft

    Kyuft Member

    Ratings:
    +11 / 0 / -0
    What do you mean by turn it off?

    -Kyuft:cool:
     

Share This Page