Simple Trigger Issue

Discussion in 'Starcraft 2 (SC2) Editor Help' started by hallidalli, May 1, 2014.

  1. hallidalli

    hallidalli New Member

    Ratings:
    +0 / 0 / -0
    Hello,

    I just started triggering and can't find the issue in the following Action:

    Player Group - Add player (Owner of (Triggering ability target unit)) to TempPlayer
    Player Group - Pick each player in TempPlayer and do (Actions)
    Actions
    Unit Group - Pick each unit in (Units in PlayersUnitGroup owned by player (Picked player), with at most Any Amount) and do (Actions)
    Actions
    Unit - Set (Picked unit) Maximum Life to (((Picked unit) Maximum Life (Current)) + 50.0)
    Player Group - Reset TempPlayer to have no players

    The trigger and action runs, it just has no effect to the maximum life. What am I doing wrong?
     
  2. X-maul

    X-maul AKA: Demtrod

    Ratings:
    +200 / 0 / -0
    As far as I remember, PlayersUnitGroup is the units put in unit groups.

    I might be wrong, but you should just use units in entire map owned by picked player.

    It might also be easier to give the units a behavior which increases max hp by 50. Then just add the behavior with the trigger :)
     
    • Like Like x 1
  3. hallidalli

    hallidalli New Member

    Ratings:
    +0 / 0 / -0
    Thanks alot, this did indeed the trick. However I really don't understand why this works and the other doesn't. To my logic the trigger I used is more correct then the one I use now.
    Code:
    Unit Group - Pick each unit in (Units in (Any units in (Entire map) owned by player (Picked player) matching Excluded: Missile, Dead, Hidden, with at most Any Amount) owned by player (Picked player), with at most Any Amount) and do (Actions)
    The Description of Unit Group - Pick each is: Runs the contained actions once for each unit in the unit group. Use the "Picked Unit" function to refer to the unit for which the actions are being run.
    Now the Unitgroup I've used absolutely contained the Unit I wanted to alter...
     
  4. Siretu

    Siretu Starcraft 2 Editor Moderator Staff Member

    Ratings:
    +295 / 0 / -0
    What is "PlayersUnitGroup"? It's not defined by default so I'm assuming it's your own variable that you're defining somewhere else. In that case, show that code as well.

    I'm not completely sure what you want, but if you're just looking to buff all units on the map owned by the Triggering ability target unit, there's an easier and more compact way to do it.

    Trigger:
    • Buff stuff
      • Events
        • Unit - Any Unit uses *YOUR ABILITY* at Generic3 - Execute stage (Ignore shared abilities)
      • Local Variables
      • Conditions
      • Actions
        • Unit Group - Pick each unit in (Any units in (Entire map) owned by player (Owner of (Triggering ability target unit)) matching Excluded: Missile, Dead, Hidden, with at most Any Amount) and do (Actions)
          • Actions
            • Unit - Set (Picked unit) Maximum Life to (((Picked unit) Maximum Life (Current)) + 50.0)


    In other words, you don't need to nest Units in Region / Units in Unit Group and if you're not doing something else as well, there's no need to save the player in a player group if it's only going to contain one player.

    Even if you had to use a unit group, you could probably have it be a local variable, which means it will be reset everytime the trigger runs and you wont have to reset the player group manually at the end.
     
    • Like Like x 1
  5. hallidalli

    hallidalli New Member

    Ratings:
    +0 / 0 / -0
    PlayersUnitGroup is a Unit Group Variable containing all Units of Human Players. Other triggers refer to it as well (which work), so I'm sure the triggering ability target Unit is actually in that Group. I see no reason why It didn't work that way.

    Thank you for the compact way, it was also my first attempt, however I couldn't get access to the (Owner of..) Action when I attempted to use it, so I used the Tempgroup var.
     
  6. Siretu

    Siretu Starcraft 2 Editor Moderator Staff Member

    Ratings:
    +295 / 0 / -0
    You're welcome.

    As for, why it didn't work, I can't really tell. It looks fine to me. In situations like these, the best way to debug it (imo) would be to just add debug message actions to print out things in each iteration of the loop. Try printing the picked player and the picked unit.

    When you're printing unit names and such, it might be a good idea to use "Combine text" to print "Picked unit = " + (Picked Unit). Since otherwise if (Picked Unit) is undefined, it wont show up at all. I'm not sure if this makes sense to you or if I'm just rambling, but yeah.
     
    • Like Like x 2

Share This Page