• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[Trigger] Need Help With Clicking On A unit And Type something and then the unit change sides

Status
Not open for further replies.
Level 2
Joined
Sep 2, 2006
Messages
20
I Need A Trigger That when i type <string> and click on a unit,It Will Make The Unit that was Clicked change to another player

E.g i type -changeownershipblue and the unit i click on turns to blue's unit.

Please Help!
 
Level 4
Joined
Feb 4, 2008
Messages
82
Try this it should work:
  • Ownership Change
    • Events
      • Player - Player 1 (Red) Selects a unit
      • Player - Player 1 (Red) types a chat message containing -changeownershipblue as An exact match
    • Conditions
    • Actions
      • Unit Group - Pick every unit in (Units currently selected by Player 1 (Red)) and do (Unit - Change ownership of (Picked unit) to Player 1 (Red) and Change color)
or this one

  • Ownership Change
    • Events
      • Player - Player 1 (Red) Selects a unit
    • Conditions
      • ((Unit-type of (Picked unit)) Equal to Rifleman) and ((Entered chat string) Equal to -changeownershipblue)
    • Actions
      • Unit Group - Pick every unit in (Units currently selected by Player 1 (Red)) and do (Unit - Change ownership of (Picked unit) to Player 1 (Red) and Change color)
 
Level 2
Joined
Sep 2, 2006
Messages
20
Try this it should work:
  • Ownership Change
    • Events
      • Player - Player 1 (Red) Selects a unit
      • Player - Player 1 (Red) types a chat message containing -changeownershipblue as An exact match
    • Conditions
    • Actions
      • Unit Group - Pick every unit in (Units currently selected by Player 1 (Red)) and do (Unit - Change ownership of (Picked unit) to Player 1 (Red) and Change color)
or this one

  • Ownership Change
    • Events
      • Player - Player 1 (Red) Selects a unit
    • Conditions
      • ((Unit-type of (Picked unit)) Equal to Rifleman) and ((Entered chat string) Equal to -changeownershipblue)
    • Actions
      • Unit Group - Pick every unit in (Units currently selected by Player 1 (Red)) and do (Unit - Change ownership of (Picked unit) to Player 1 (Red) and Change color)

Thank You very much!+rep
 
Level 3
Joined
Jan 31, 2008
Messages
66
nah that will have a problem.... the best advice is to use:
-Add selected units to group (your group)

then u put the event:
Player 1 types ____ as an exact match

then do actions:
-Do (actions) to First Unit Of Group (your Group)

sorry for the lousy triggers, but i dun have world editor currently, so i can't copy out exact triggers from the editor :grin:
 
Level 21
Joined
Aug 21, 2005
Messages
3,699
Those triggers won't work. You'll need separate triggers. one that detects when a chatstring is entered and turns on the second trigger (turning off itself), and one that detects when a player selects a unit, turning on the first trigger (turning off itself) and changing the ownership of that selected unit...
 
Level 2
Joined
Sep 2, 2006
Messages
20
Those triggers won't work. You'll need separate triggers. one that detects when a chatstring is entered and turns on the second trigger (turning off itself), and one that detects when a player selects a unit, turning on the first trigger (turning off itself) and changing the ownership of that selected unit...

seems difficult to me.....i am not good with triggers.....
 
Level 4
Joined
Mar 6, 2007
Messages
73
There it is :
  • OwnerChange1
    • Events
      • Player - Player 1 (Red) types a chat message containing -YourMessage as A substring
    • Conditions
    • Actions
      • Trigger - Turn off (This trigger)
      • Trigger - Turn on OwnerChange2 <gen>
and
  • OwnerChange2
    • Events
      • Player - Player 1 (Red) Selects a unit
    • Conditions
    • Actions
      • Unit Group - Pick every unit in (Units currently selected by Player 1 (Red)) and do (Unit - Change ownership of (Picked unit) to Player 1 (Red) and Change color)
      • Trigger - Turn off (This trigger)
      • Trigger - Turn on OwnerChange1 <gen>
Test it myself and it worked. Warning, ALL unit select will change owner ship not only 1 unit.
Hope it help.
 
Level 22
Joined
Feb 26, 2008
Messages
892
Or, you could try this. One trigger.
You give it the player number of the player to which you wish to change.
So, if you are player 1 (red) and want to make a unit yours, you select it, then type:

-changeownership 1

Only works when you have 1 unit selected.

  • Change Ownership
    • Events
      • Player - Player 1 (Red) types a chat message containing -changeownership as A substring
    • Conditions
    • Actions
      • Set TempGroup = (Units currently selected by (Triggering player))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of units in TempGroup) Equal to 1
        • Then - Actions
          • Unit Group - Pick every unit in TempGroup and do (Actions)
            • Loop - Actions
              • Unit - Change ownership of (Picked unit) to (Player((Integer((Substring((Entered chat string), 18, (Length of (Entered chat string)))))))) and Change color
        • Else - Actions
          • Game - Display to (Player group((Triggering player))) the text: Invalid number of u...
      • Custom script: call DestroyGroup(udg_TempGroup)
 
Status
Not open for further replies.
Top