• 🏆 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!

change unit's owner

Status
Not open for further replies.
I want to change the owner of unit created by a building each 30 seconde
but i want that player 1,2,3 unit's change to player 11 and player 4,5,6 change to player 12, And i dont want that all unit change, only created unit
is it possible?
i will give you example:
Player 1 have 2 worker and 3 warrior camp: Each 30 second, a Warrior will be created on each warrior camp. I want that these warrior change to player 11 but worker stay to player 1.
PLZ HEEEEEEEEEELP MEEEEEEEEE
 
Level 14
Joined
Apr 20, 2009
Messages
1,543
if you created the trained units via triggers then just do this:

set temp_unit_var = (last created unit)
unit - change ownership for temp_unit_var to player 11...

its that easy... ;)

have you done that via triggers or is the building somekind of uncontrollable building that keeps spawning without the use of triggers?
 
Level 14
Joined
Apr 20, 2009
Messages
1,543
I know that...
do you see any function that I called ^^?

but setting to a variable can be usefull too ^^
whenever he has his spawning creature trigger in a different trigger then the change ownership trigger this is the way to do it...

and I think I confused you a bit with the name of the variable...

but it was meant to say:
whenever a unit is created it is set to a temporarely variable that is being overwrited when the new unit comes....
 
Level 14
Joined
Apr 20, 2009
Messages
1,543
operation3000 please give us your trigger if you have one...

if not:

then the next question is: do you already have a building that spawns these units? and if so how are they spawned?

give us some more information please, we cant make the trigger without you ;) ...

thx hashjie
but it's not what i want
I meant
Each unit created by a bulding owned by p1 or p2 or p3 will change their owner for p11
Each unit created by a bulding owned by p4 or p5 or p6 will change their owner for p12
thats wat i want (sry im from quebec so its normal if you dont understand)

actually it is what you want but you didn't notice ;)
lets say perhaps you have a trigger that says:

every ... seconds it creates a unit at the position of a building owned by a player...
now whenever that player is equal to 1,2 or 3 the unit thats created is put into a variable...(not necessarily unless you want to have the changing ownership to take place in a different trigger)

then you just do:
Unit - Change Ownership for "your_unit_variable" to Player - 11
or just for last created unit if your going to put it in the same trigger...
 
Level 9
Joined
Oct 22, 2006
Messages
599
Oh yeah and what I just did was copy this into trigger tags so operation3000 could see it better, I didn't write anything new.
if you created the trained units via triggers then just do this:

set temp_unit_var = (last created unit)
unit - change ownership for temp_unit_var to player 11...

its that easy... ;)

have you done that via triggers or is the building somekind of uncontrollable building that keeps spawning without the use of triggers?
 
Level 9
Joined
Oct 22, 2006
Messages
599
I believe this will do it..
  • Ownership
    • Events
      • Unit - A unit Finishes training a unit
    • Conditions
      • (Unit-type of (Trained unit)) Equal to Warrior
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Or - Any (Conditions) are true
            • Conditions
              • (Owner of (Trained unit)) Equal to Player 1 (Red)
              • (Owner of (Trained unit)) Equal to Player 2 (Blue)
              • (Owner of (Trained unit)) Equal to Player 3 (Teal)
        • Then - Actions
          • Unit - Change ownership of (Trained unit) to Player 11 (Dark Green) and Change color
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Or - Any (Conditions) are true
                • Conditions
                  • (Owner of (Trained unit)) Equal to Player 4 (Purple)
                  • (Owner of (Trained unit)) Equal to Player 5 (Yellow)
                  • (Owner of (Trained unit)) Equal to Player 6 (Orange)
            • Then - Actions
              • Unit - Change ownership of (Trained unit) to Player 12 (Brown) and Change color
            • Else - Actions
 
Level 9
Joined
Oct 22, 2006
Messages
599
Then copy the following actions to the Trigger you use to Create the Warrior. I recommend you copy them right under the line you create the unit.

  • Ownership
    • Events
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Or - Any (Conditions) are true
            • Conditions
              • (Owner of (Last Created unit)) Equal to Player 1 (Red)
              • (Owner of (Last Created unit)) Equal to Player 2 (Blue)
              • (Owner of (Last Created unit)) Equal to Player 3 (Teal)
        • Then - Actions
          • Unit - Change ownership of (Last Created unit) to Player 11 (Dark Green) and Change color
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Or - Any (Conditions) are true
                • Conditions
                  • (Owner of (Last Created unit)) Equal to Player 4 (Purple)
                  • (Owner of (Last Created unit)) Equal to Player 5 (Yellow)
                  • (Owner of (Last Created unit)) Equal to Player 6 (Orange)
            • Then - Actions
              • Unit - Change ownership of (Last Created unit) to Player 12 (Brown) and Change color
            • Else - Actions
Next time for your best service add as much info as possible.
 
Status
Not open for further replies.
Top