• 🏆 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] how to create a unit give trigger

Status
Not open for further replies.
Level 4
Joined
Feb 16, 2013
Messages
60
hello, is their a trigger that at when you begin to play a map, it gives unit's in a region to a player and one that when a hero enter's a region, it will give the owner of the hero unit's in a region and play a sound
 
Level 8
Joined
Apr 23, 2010
Messages
312
For the map initialization you want something like this...
  • Melee Initialization
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Unit Group - Pick every unit in (Units in Region 000 <gen>) and do (Actions)
        • Loop - Actions
          • Unit - Change ownership of (Picked unit) to Player 1 (Red) and Change color
When a hero enters the region you want it more like the trigger below. You can make it more specific as to a hero type, a hero owned by player etc...
  • Untitled Trigger 001
    • Events
      • Unit - A unit enters Region 000 <gen>
    • Conditions
      • ((Triggering unit) is A Hero) Equal to True
    • Actions
      • Unit Group - Pick every unit in (Units in Region 000 <gen>) and do (Actions)
        • Loop - Actions
          • Unit - Change ownership of (Picked unit) to (Owner of (Triggering unit)) and Change color
 
Level 29
Joined
Oct 24, 2012
Messages
6,543
use the event unit enters region.
use the condition to filter out the unit u want to trigger this.
in actions pick all units in the region. and for the group loop change the units owner.

edit: 13oot beat me to it.

u need to clean those group leaks tho. Also anything used twice or more should be stored in a variable. so store owner of triggering unit into a player variable.
 
Level 20
Joined
Jun 27, 2011
Messages
1,864
Here, he also wants to play a sound lol

  • Initialization
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units in Region 000 <gen>) and do (Actions)
        • Loop - Actions
          • Set Temp_Unit = (Picked unit)
          • Unit - Change ownership of Temp_Unit to Player 1 (Red) and Change color
          • Custom script: set udg_Temp_Unit = null
  • Enter
    • Events
      • Unit - A unit enters Region 000 <gen>
    • Conditions
      • ((Triggering unit) is A Hero) Equal to True
    • Actions
      • Set Temp_Unit = (Triggering unit)
      • Set Temp_Player = (Owner of Temp_Unit)
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units in Region 000 <gen>) and do (Actions)
        • Loop - Actions
          • Set Temp_Unit2 = (Picked unit)
          • Unit - Change ownership of Temp_Unit2 to Temp_Player and Change color
          • Custom script: set udg_Temp_Unit2 = null
      • Sound - Play LOL <gen>
      • Custom script: set udg_Temp_Unit = null
 
Level 21
Joined
Mar 27, 2012
Messages
3,232
Yeah I understand that but if it's only being used for one line wouldn't it be more work to set it and then remove it?

That depends on the variable. I myself use a different way of deciding. At first I don't store things in variables. Then I write them out all the times and once I get tired of writing them out THEN I use variables. I'm talking of JASS though.
 
Status
Not open for further replies.
Top