SC2Mapster Forums

Development > Triggers

(Solved) Permanent Unit Selection.

  • 7 posts
    #1 Feb 23, 2013 at 18:36 UTC - 0 likes

    I currently got this trigger;

    Permanent Selection
        Events
            Unit Selection - Any Unit is Selected by player Any Player
        Local Variables
        Conditions
        Actions
            Unit Selection - Deselect all units for player (Triggering player)
            General - If (Conditions) then do (Actions) else do (Actions)
                If
                    (CurrentHero[(Triggering player)] is alive) == True
                Then
                    Unit Selection - Select CurrentHero[(Triggering player)] for player (Triggering player)
                Else
    

    While this works somehow okay, I want to completely prevent a player from selecting other units (as if the Unselectable flag was ticked).

    I tried setting the unit owned by the player to be the only one with the Unselectable flag unticked, but the access was denied:

                            Catalog - Set value of Units (Unit type of (Last created unit)) FlagArray[Unselectable] for player (Triggering player) to (String(0))
    

    How would I go around making a unit permanently selected?

    #2 Feb 23, 2013 at 20:52 UTC - 0 likes

    @Demtrod: Go

    After the trigger selects the unit for the player, use the action "Enable/Disable Selection Type" then change the type parameter to "all." If the permanently selected unit dies or the unit that you want selected changes, you'll have to reenable the selection types before you select it for the player. I've seen some maps a method like yours before, but I think that was to allow units to be clicked and trigger the corresponding event. So if you do it this way, I'm assuming you won't be able to use the event "unit is clicked."

    Last edited Feb 23, 2013 by Charysmatic
    #3 Feb 23, 2013 at 21:18 UTC - 0 likes

    if you want, you could also try having another trigger with the event "any unit is deselected by any player" then have the action be "select (triggering unit) for (owner of (triggering unit))"

    #4 Feb 23, 2013 at 22:30 UTC - 0 likes

    @KingRadical: Go

    Wouldn't that cause a loop? Reselecting the previously selected unit deselcts the selected one, starting the trigger again ... or does this not count for it was not the player who was deselecting the unit?

    #5 Feb 24, 2013 at 02:54 UTC - 0 likes

    @DemoniacMilk: Go

    actually it would add a unit to the selection like you were holding shift.

    what he wants is unit any unit is selected by player any player
    condition: or
    * selected unit =! playerunit
    * any unit is deselected
    actions:
    deselect all units for player triggering player
    select playerunit for player triggering player

    Last edited Feb 24, 2013 by willuwontu
    #6 Feb 24, 2013 at 09:18 UTC - 0 likes

    @willuwontu: Go

    ou right, he didn't deselect.

    Your method should work fine.

    #7 Feb 24, 2013 at 09:26 UTC - 0 likes

    @Charysmatic: Go

    I used this method. I simply disabled all selection for the player (after his unit was selected) and then I enabled it again when it died.

    Thanks for the suggestions though, but this seems to be the most clean and efficient way to do it.

  • 7 posts

You must login to post a comment. Don't have an account? Register to get one!