• 🏆 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 to previous owner

Status
Not open for further replies.
Level 2
Joined
Dec 30, 2011
Messages
13
What is wrong?

  • Control
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Storm Bolt
    • Actions
      • Unit Group - Add (Target unit of ability being cast) to GrupoWea
      • Unit - Change ownership of (Target unit of ability being cast) to Player 12 (Brown) and Change color
      • Player - Make Player 12 (Brown) treat (Owner of (Target unit of ability being cast)) as an Enemy
      • Player - Make (Owner of (Target unit of ability being cast)) treat Player 12 (Brown) as an Enemy
      • Wait 5.00 seconds
      • Unit Group - Pick every unit in GrupoWea and do (Actions)
        • Loop - Actions
          • Unit - Change ownership of (Picked unit) to (Previous owner) and Change color
          • Player - Make Player 12 (Brown) treat (Previous owner) as an Ally
          • Player - Make (Previous owner) treat Player 12 (Brown) as an Ally
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,509
The Owner of Target unit of ability being cast is Player 12. So you're making Player 12 treat Player 12 as an Enemy.

You need to set their Alliance BEFORE you change the target's ownership.

Also, I don't think you need a Unit Group here, you can just use a Unit variable to track the Target unit of ability being cast. The Unit Group makes me think that you want to have multiple units in the group at a time, but that would be very buggy. You're changing the ownership of ALL of the picked units after 5.00 seconds, even if one of those units was just added to it a second ago.

And I've never used the (Previous owner) Event Response so I don't know if it works or not.
 
Level 2
Joined
Dec 30, 2011
Messages
13
Im player 1 the enemy is player 2, 3,4 .... i never use player 12 thats why i make tha target unit change to player 12

The trigger works until the wait then it never change to the previous owner :c

and nope, is only going to be one unit in that group
 
Last edited:

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,509
Use a Unit variable to track the target unit of ability being cast and a Player variable to track the original owner of that unit. No need for a unit group.

Set Variable ChangedUnit = Target unit of ability being cast
Set Variable OriginalOwner = Owner of ChangedUnit
do alliance stuff
Wait 5.00 seconds
Change ownership of ChangedUnit to OriginalOwner
do alliance stuff
 
Level 2
Joined
Dec 30, 2011
Messages
13
That works really nice ty, what about this?

In the end i make this trigger xD

map initialization
Player - Make Player 3 (Teal) treat Player 2 (Blue) as an Ally with shared vision
Player - Make Player 2 (Blue) treat Player 3 (Teal) as an Ally with shared vision
...
Player - Make Player 3 (Teal) treat Player 12 (Brown) as an Enemy
Player - Make Player 2 (Blue) treat Player 12 (Brown) as an Enemy
...

  • ControlG
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Acid Bomb
    • Actions
      • Set UnitAsd = (Target unit of ability being cast)
      • Set PlayerAsd = (Owner of UnitAsd)
      • Unit Group - Add UnitAsd to GrupoWea
      • Wait 1.00 seconds
      • Unit - Order UnitAsd to Stop
      • Wait 5.00 seconds
      • Unit Group - Remove UnitAsd from GrupoWea
  • ControlGlobal
    • Events
      • Time - Every 0.01 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in GrupoWea and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Picked unit) has buff Acid Bomb) Equal to True
            • Then - Actions
              • Unit - Change ownership of (Picked unit) to Player 12 (Brown) and Change color
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (UnitAsd has buff Acid Bomb) Equal to False
                • Then - Actions
                  • Unit - Change ownership of (Picked unit) to PlayerAsd and Change color
                • Else - Actions
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,509
No need for the Unit Group if you're only using 1 unit.

Remember, a Unit GROUP is meant for multiple units, if you're only using 1 unit then it's not needed.

  • Events:
  • Time - Every 0.01 seconds of game time
  • Actions:
  • If UnitAsd has buff Acid Bomb = True -> Change ownership of UnitAsd to Player 12 -> Turn off this trigger
  • ELSE
  • If UnitAsd has buff Acid Bomb = False and Owner of UnitAsd = Player 12 -> Change ownership of UnitAsd to PlayerAsd -> Turn off this trigger
Your current trigger's Else - Actions will constantly run so you should put an extra Condition that checks if the Owner = Player 12.

You should also Turn On and Turn Off the trigger so that it stops running when there's no active Acid Bomb.

This means that in your "Starts the effect of an ability" trigger (ControlG) you want to turn on your Periodic Interval trigger (ControlGroup). Also, make sure ControlGroup is set to Inititally OFF (The checkbox in the trigger editor next to Enabled). This will turn off the trigger by default, so that it's not running until Acid Bomb is cast. In other words, the Periodic Trigger should only ever be on when an Acid Bomb is in effect.
 
Last edited:
Status
Not open for further replies.
Top