Warcraft III resources & community, 2003–2006 · archived

Select unit trigger

16 posts
#1

Select unit trigger

When you trigger a command and you want that something happen with the unit that you selected in game, how you do to trigger it?
#2
condition: Triggering unit equals to selected unit
#3
apocalypse_dudecondition: Triggering unit equals to selected unit


I'm not sure that will work. I think that Selected Unit will only refer to an Event or an Action [i.e., you select a unit with a trigger action]

I'm not sure how you would do it, I'm pretty sure there's a JASS code...function...thingy for it, [like smart is for right clicking], then you could use that for an Event in a trigger that would have an Action that would set the unit to a variable with an array according to the owning player of the selected unit. Anyways...I hope you get what you need!
#4
Well that is not working
#5
I just use "random unit from group: units selected". Of course, that only works if you're selecting enemy units.
#6
Well that work with all units but its only 1 unit at a time and i would want for whole selected units
#7
make 2 trigger:

event: unit is selected:

action: set UnitIsSelected = true


event: unit is unselected:

action: set UnitIsSelected = False


Then when you run your trigger you can use the variable to check if you had selected the unit
#8
it works even easier

condition:
integer - Count units in group(Units selected by Player(whatEver) matching (whatEver = owner of matching unit)) > 0

if true - the player has selected a unit of himself, else he hasn't

that way you can even to 'pick every unit in group(units selected by (whatEver) do...' or stuff like that
#9
Well is that a separeted trigger? and what is the if true in this?
#10
its a simple condition
you can either use that in an if or in the condition section of any trigger you want.

It is ONLY a condition and NOT a trigger.
#11
Well I trying this but I don't really understand so I'll write you what I have in my trigger ( it's a removing trigger ) and u'll simpely tell me what wrong (or not).

Trigger: Player - Player 1 (red) types a chat message containing remove as an exact match

Condition: ((Number of units in(Unit selected by player 1 (red))) greater than 0) and ( its a condition with and) (player 1 (red) equal to owner of (triggering unit)))

Action: Unit - remove (triggering unit) from game
#12
You need three triggers

=========================================

SelectionTrigger

Events
Player - Player 1 (Red) Selects a unit

Conditions
(Owner of (Triggering unit)) Equal to Player 1 (Red)

Actions
Unit Group - Pick every unit in (Units currently selected by Player 1 (Red)) and do (Unit Group - Add (Picked unit) to UnitGroup)

===============================

TextTrigger

Events
Player - Player 1 (Red) types a chat message containing remove as An exact match

Conditions
-

Actions
Unit Group - Pick every unit in UnitGroup and do (Unit - Remove (Picked unit) from the game)

=================================

RemoveUnitsFromGroup

Events
Player - Player 1 (Red) Deselects a unit

Conditions
-

Actions
Unit Group - Remove (Triggering unit) from UnitGroup



=====================================

Should work. You can deselect units, if you change your mind. Doesn't remove enemy units.
#13
i would do it like this:

action:
- Player X types '-remove' as exact match
- <you might do this for all players - doesn't matter for the rest of the code>
condition:
- Integer - Number of Units in Group (Units selected by TriggeringPlayer matching (Owner of matching Unit = TriggeringPlayer)) > 0
actions:
- Unitgroup - Pick every unit in group(Units selected by TriggeringPlayer matching (Owner of Matching Unit = Triggering Player)) and do actions
- - remove picked unit from game
#14
Well it's not working, I didn't put matching owner of matching unit cause I want that when red select a unit and type remove it remove it no need to be his units.
#15
Master_AngelWell it's not working, I didn't put matching owner of matching unit cause I want that when red select a unit and type remove it remove it no need to be his units.


Did you try my triggers? If you want to remove also other player's units, just remove the condition from the first trigger.

Try it, myt triggers do work.