• 🏆 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!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[Trigger] Being Selected as a Condition?

Status
Not open for further replies.
Level 6
Joined
Aug 12, 2007
Messages
201
I have a triggered spell ability, but one of it's conditions is that it changes the unit's owner at one part and sets it back by the end of the spell, but my problem is that in doing this, it deselects the unit if I happened to be selecting it. Is there any way to set up a 'If - Player was Selecting a Unit' condition, so that I can add all the units he was selecting at the start of the trigger, and if any of the selected units was one that swapped player during this trigger that it should add them to the user selection.

Something like:

  • Set Selected Units to Unit Group Temp Selected
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • (The unit that is user changed) Equal to Part of Temp Selected
    • Then - Actions
      • Selection - Add (User Changed unit) to selection for (Owner of Unit)
    • Else - Actions
I just made all that up though, I can't figure out how to do it for real.
 
Level 6
Joined
Aug 12, 2007
Messages
201
If it is a spell, why not use "Triggering Unit", or "Casting Unit"?
If you've used multiple triggers, or a wait-command, set it to a variable (with array for MPI) and then use the variable.

Casting and triggering isn't the part I can't get, that is all fine, its doing the condition of being selected. Like, think of it this way. I move my twelve guys somewhere, and as they pass by this effect, they become belonging to player red as part of the spell, then player themselves again in the same moment. The problem with this is, they drop out of my selection if I was selecting them, even if the spell doesn't do anything in the end because the conditions weren't met. I want to set an If statement that is If The unit was being selected, then add it back to the selection. But I can't find a If Selected Condition.

EDIT: Like, Boolean Comparison - Unit is Selected Equals to True, only there is no Is Selected condition.

EDIT EDIT: I actually found the condition for user is selected, but so far I can't get the trigger to re-add the unit properly. I'll post the trigger now:

  • Auto Devour
    • Events
      • Unit - A unit Is attacked
    • Conditions
      • (Unit-type of (Attacking unit)) Equal to Pit Trap
    • Actions
      • Player Group - Pick every player in (All players) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Attacked unit) is selected by (Picked player)) Equal to True
            • Then - Actions
              • Unit Group - Add (Attacked unit) to TempSelectedUnit
            • Else - Actions
          • Set TempTeam = (Owner of (Attacked unit))
          • Unit - Order (Attacking unit) to Neutral Dark Ranger - Charm (Attacked unit)
          • Unit - Order (Attacking unit) to Load (Attacked unit)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Attacked unit) is loaded into (Attacking unit)) Equal to True
            • Then - Actions
              • Unit Group - Add (Attacked unit) to StomachContense
            • Else - Actions
          • Unit - Change ownership of (Attacked unit) to TempTeam and Change color
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Number of units in TempSelectedUnit) Greater than or equal to 1
            • Then - Actions
              • Unit Group - Pick every unit in TempSelectedUnit and do (Actions)
                • Loop - Actions
              • Selection - Add (Picked unit) to selection for (Picked player)
            • Else - Actions
              • Do nothing
It's kinda convoluted and needs optimizing and leak checking, but it does what it supposed to, except the last part where it doesn't re-add the unit to the selection.

EDIT EDIT EDIT: Third Edit wow, This trigger functions now:

  • Auto Devour
    • Events
      • Unit - A unit Is attacked
    • Conditions
      • (Unit-type of (Attacking unit)) Equal to Pit Trap
    • Actions
      • Set TempTeam = (Owner of (Attacked unit))
      • Player Group - Pick every player in (All players) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Attacked unit) is selected by (Picked player)) Equal to True
            • Then - Actions
              • Unit Group - Add (Attacked unit) to TempSelectedUnit
              • Set TempPickedPlayer = (Picked player)
            • Else - Actions
      • Unit - Order (Attacking unit) to Neutral Dark Ranger - Charm (Attacked unit)
      • Unit - Order (Attacking unit) to Load (Attacked unit)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Attacked unit) is loaded into (Attacking unit)) Equal to True
        • Then - Actions
          • Unit Group - Add (Attacked unit) to StomachContense
        • Else - Actions
      • Unit - Change ownership of (Attacked unit) to TempTeam and Change color
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of units in TempSelectedUnit) Greater than or equal to 1
        • Then - Actions
          • Unit Group - Pick every unit in TempSelectedUnit and do (Actions)
            • Loop - Actions
              • Selection - Add (Picked unit) to selection for TempPickedPlayer
        • Else - Actions
          • Do nothing
The explanation for it all being that; I have an invisible Pit, and it Devours nearby units by attacking them, and then casting Devour on the Attacked Unit. The only problem with this is there is no type of invisibility that will stay while a unit is Devouring someone, it auto-reveals them.

Now when a unit is attacked, it is had charm cast on it to be on my team, then loaded into the pit as if it were a transport. Loading and Holding units doesn't remove the Pit's invisibility, and a separate trigger damages all units in StomachContence by ten every second, which freshly loaded units are added to. The problem with this is that when the pit is full, it still charms and then gives the units right back, which de-selects them. The trigger checks for unit selection, adds the unit to a group, and then re-adds the unit to the selection after it is returned. It's probably leaky and not optimal at the moment, as I haven't set it up to remove any of the left over temp groups and everything yet, but at least it functions!
 
Last edited:
Status
Not open for further replies.
Top