[Trigger] Restoring Owner Of Unit After Being Transported.

Level 3
Joined
May 3, 2008
Messages
29
Im trying to make this action. There are X players from 1 to 8. with 1 hero as unit

I made a zeppelin pick every hero and transport them, by changing the owner, now i cant get the heroes to have their owners restored.. how do i do it???

First to change owner i did

  • Unit Group - Pick every unit in (Units in Region 034 <gen>) and do (Actions)
    • Loop - Actions
      • Unit - Change ownership of (Picked unit) to Player 1 (Red) and Retain color
        • Set unitscustomvalue[(Player number of (Owner of (Picked unit)))] = (Player number of (Owner of (Picked unit)))
Now to unload and change owner // not working
  • Unit - Order Goblin Zeppelin 1184 <gen> to Unload All At (Center of Region 035 <gen>)
  • Unit Group - Pick every unit in (Units in Region 035 <gen>) and do (Actions)
    • Loop - Actions
      • For each (Integer A) from 1 to 8, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Custom value of (Picked unit)) Equal to (Player number of (Player((Integer A))))
            • Then - Actions
              • Unit - Change ownership of (Picked unit) to (Player((Integer A))) and Change color
            • Else - Actions
      • Game - Display to (All players) the text: changed owner
// and previous owner not working too
 
Level 18
Joined
Aug 23, 2008
Messages
2,319
Step 1: When you've picked them, set them to TempGroup[1].
Step 2: Pick a random unit from TempGroup[1] and set it to Hero[(Player number of (Owner of(Picked Unit)))]. So the hero of player 1 will become Hero[1], the hero of player 2 will become Hero[2], the hero of player 7 will become Hero[7], etc.
Step 3: Remove Picked Unit from TempGroup[1] and add it to TempGroup[2].
Step 4: Repeat step 2 and 3 unit you've transferred all heroes to TempGroup[2]. TempGroup[1] was to prevent confusion in Picked Unit. TempGroup[2] is to keep all sorted heroes away from the unsorted heroes.

Step 5: Load the units into the transport and move them to wherever you want them to move. Then run your second posted trigger.
Step 6: Change ownership of Hero[1] to Player 1, of Hero[2] to Player 2, of Hero[3] to Player 3, etc.

Mission accomplished!
 
Level 3
Joined
May 3, 2008
Messages
29
Step 1: When you've picked them, set them to TempGroup[1].
Step 2: Pick a random unit from TempGroup[1] and set it to Hero[(Player number of (Owner of(Picked Unit)))]. So the hero of player 1 will become Hero[1], the hero of player 2 will become Hero[2], the hero of player 7 will become Hero[7], etc.
Step 3: Remove Picked Unit from TempGroup[1] and add it to TempGroup[2].
Step 4: Repeat step 2 and 3 unit you've transferred all heroes to TempGroup[2]. TempGroup[1] was to prevent confusion in Picked Unit. TempGroup[2] is to keep all sorted heroes away from the unsorted heroes.

Step 5: Load the units into the transport and move them to wherever you want them to move. Then run your second posted trigger.
Step 6: Change ownership of Hero[1] to Player 1, of Hero[2] to Player 2, of Hero[3] to Player 3, etc.

Mission accomplished!

I had already tried using unitarray but nothing works...
and i cant LOAD them without making all have same owner thats why the second trigger to try restore them to normal
its

  • Unit Group - Pick every unit in (Units in Region 034 <gen>) and do (Actions)
    • Loop - Actions
      • Unit - Change ownership of (Picked unit) to Player 1 (Red) and Retain color
      • Set tempunits = (Picked unit) // unit variable
        • Unit - Order Goblin Zeppelin 1184 <gen> to Load (tempunits)
      • Set unitscustomvalue[(Player number of (Owner of (Picked unit)))] = (Player number of (Owner of (Picked unit)))
and

  • Unit Group - Pick every unit in (Units in Region 035 <gen>) and do (Actions)
    • Loop - Actions
      • For each (Integer unitscustomvalue[(Integer A)]) from 1 to 8, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Custom value of (Picked unit)) Equal to (Player number of (Player((Integer A))))
            • Then - Actions
              • Unit - Change ownership of (Picked unit) to (Player((Integer A))) and Change color
              • Unit - Change ownership of tempunits[(Integer A)] to (Player((Integer A))) and Change color
              • Unit - Change ownership of (Picked unit) to (Player((Custom value of (Picked unit)))) and Change color
            • Else - Actions
      • Game - Display to (All players) the text: changed owner
the actions in THEN off corse im not using all at the same time they are disabled just left to show that i already tried the 3 of them and none work.
This a trigger that u definetly needs to test in game no assumptions will make it work.
 
Level 3
Joined
May 3, 2008
Messages
29
You do change owner when in the transport, but before you load them in, you give them an array equal to the player number of their owners. When you unload them, you give them their owners back, which you can check by it's array index.

i already did that , and not working

lines

Set unitscustomvalue[(Player number of (Owner of (Picked unit)))] = (Player number of (Owner of (Picked unit)))


If - Conditions

(Custom value of (Picked unit)) Equal to (Player number of (Player((Integer A))))

Then - Actions

Unit - Change ownership of (Picked unit) to (Player((Custom value of (Picked unit)))) and Change color
 
Level 18
Joined
Aug 23, 2008
Messages
2,319
1: You picked new units, so Picked Unit is not usable in the If/Then/Else trigger.
2: You need to make a unit variable, not an integer. Hero[1] is the hero that player 1 uses.
3: You set a variable named 'unitscustomvalue' to a number, but you need to set the Custom Value of the unit to a number, not a variable. Instead, change '(Player((Custom value of (Picked unit))))' to '(Player(unitcustomvalue))'.

Also keep in mind that this If/Then/Else trigger you just posted doesn't have a Pick Unit command. I assume you already have it, but just didn't post it.
 
Top