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

[Trigger] Help With Duel Trigger

Status
Not open for further replies.
Level 3
Joined
Aug 9, 2009
Messages
27
I need a way to store the position of every player's hero right before the duel and then a way to pan the camera back to that point after the duel.
I don't think it should be too hard, but I'm kind of new at this so I couldn't figure it out. Also I would like to know how to clear unit variables with custom script. My duel triggers so far are:

  • Duel Timer
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Wait 60.00 seconds
      • Countdown Timer - Start Duel_Timer as a Repeating timer that will expire in 180.00 seconds
      • Countdown Timer - Create a timer window for (Last started timer) with title Time Until Duel
      • Set Duel_TW = (Last created timer window)
      • Countdown Timer - Show Duel_TW
  • Duel
    • Events
      • Time - Duel_Timer expires
    • Conditions
    • Actions
      • Countdown Timer - Pause Duel_Timer
      • Unit - Pause all units
      • Unit Group - Pick every unit in Death_Units and do (Wait until (((Picked unit) is alive) Equal to True), checking every 1.00 seconds)
      • Unit Group - Pick every unit in Life_Units and do (Wait until (((Picked unit) is alive) Equal to True), checking every 1.00 seconds)
      • Unit - Pause all units
      • Player Group - Pick every player in (All players) and do (Camera - Pan camera for (Picked player) to (Center of Duel Center <gen>) over 1.00 seconds)
      • Set Life_Duelist = (Random unit from Life_Units)
      • Set Death_Duelist = (Random unit from Death_Units)
      • Unit - Unpause Life_Duelist
      • Unit - Unpause Death_Duelist
      • Unit - Move Life_Duelist instantly to (Center of Life Duel <gen>), facing 0.00 degrees
      • Unit - Move Death_Duelist instantly to (Center of Death Duel <gen>), facing 180.00 degrees
      • Unit - Set life of Death_Duelist to 100.00%
      • Unit - Set life of Life_Duelist to 100.00%
      • Unit - Set mana of Death_Duelist to 100.00%
      • Unit - Set mana of Life_Duelist to 100.00%
      • Unit - Pause Life_Duelist
      • Unit - Pause Death_Duelist
      • Game - Display to (All players) the text: 3...
      • Wait 1.00 seconds
      • Game - Display to (All players) the text: 2...
      • Wait 1.00 seconds
      • Game - Display to (All players) the text: 1...
      • Wait 1.00 seconds
      • Unit - Unpause Death_Duelist
      • Unit - Unpause Life_Duelist
      • Countdown Timer - Start Duel_Timer as a One-shot timer that will expire in 100.00 seconds
  • Life Win
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Triggering unit) Equal to Death_Duelist
    • Actions
      • Unit - Unpause all units
      • Countdown Timer - Resume Duel_Timer
      • Countdown Timer - Pause Duel_Time

  • Death Win
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Triggering unit) Equal to Life_Duelist
    • Actions
      • Unit - Unpause all units
      • Countdown Timer - Resume Duel_Timer
      • Countdown Timer - Pause Duel_Time
  • Timer Expires
    • Events
      • Time - Duel_Time expires
    • Conditions
    • Actions
      • Trigger - Turn off Life Win <gen>
      • Trigger - Turn off Death Win <gen>
      • Game - Display to (All players) the text: For wasting time th...
      • Unit - Create 1 zach807 for Neutral Hostile at (Center of Death Duel <gen>) facing Default building facing degrees
      • Unit Group - Add (Last created unit) to Original_BADASS
      • Unit Group - Order Original_BADASS to Attack-Move To (Center of Life Duel <gen>)
      • Player - Set (Owner of Life_Duelist) Current gold to 0
      • Player - Set (Owner of Death_Duelist) Current gold to 0
 
Level 12
Joined
Aug 31, 2008
Messages
1,121
Umm, why would you want to clean unit variables with custom script.
Jsut set them to -no unit. That is equal to null in jass.
If everyone has a hero, use some kinda loop wiht arrays to get every hero (In some other trigger, you probably already have set them to a unit array. If not, do it.) and set their position to another array. (Location array.)
After the fight, return everyone to the stored positions, use a camera action to set the camera target to teh position, and kill the leaks.
Love your use of group names = Original_BADASS
Sorry if I couldn't show it to you ing GUI text. I don't write that very well away from my comp.
 
Level 3
Joined
Aug 9, 2009
Messages
27
I have absolutely no experience with arrays could you explain what they are exactly and how to use them?

Edit: Is this the proper setup for a unit array (for heroes)?

  • Hero Array
    • Events
      • Unit - A unit Dies
    • Conditions
      • (All units of Hero_Chooser are dead) Equal to True
    • Actions
      • Unit Group - Pick every unit in Heroes and do (Actions)
        • Loop - Actions
          • Set Hero_Array[(Number of players)] = (Picked unit)
 
Level 6
Joined
Oct 31, 2008
Messages
229
I found a bug in yor code:

Unit Group - Pick every unit in Death_Units and do (Wait until (((Picked unit) is alive) Equal to True), checking every 1.00 seconds)

Unit Group - Pick every unit in Life_Units and do (Wait until (((Picked unit) is alive) Equal to True), checking every 1.00 seconds).

This two (and i think there are more of them)are lines existing in world editor unlimited, a tool that we all love but isnt supported anymore by warcraft. I am sure there are more of these kinda bugs in your script ( i didnt havbe much time to check them all). You better revive all the units in light and dark force before starting the duel.

The answer in your problem now, is this: you can make an array of size 12 of type "point" and store the heroes in it with the Integer - Player number. after that you pick with a "for" loop everyone from number 1 - 12,make the duel. After its complited, revive them all and pan you camera in the point[for loop integer whatever] and move the hero of player[for loop integer] in this point. you might also need a variable array for the heroes of each player

Note: i assumed that 12 are the players. change this number if less.

Good luck with your map
 
Level 3
Joined
Aug 9, 2009
Messages
27
Revised Duel Triggers

So here's my revised system. Can anyone find any bugs (let me know yes or no). And feel free to make any suggestions.

First Set Up Hero Array
  • Hero Array
    • Events
      • Unit - A unit Dies
    • Conditions
      • (All units of Hero_Chooser are dead) Equal to True
    • Actions
      • Unit Group - Pick every unit in Heroes and do (Actions)
        • Loop - Actions
          • Set Hero_Array[(Number of players)] = (Picked unit)
Then Timer Until Duel Starts
  • Duel Timer
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Wait 60.00 seconds
      • Countdown Timer - Start Duel_Timer as a Repeating timer that will expire in 300.00 seconds
      • Countdown Timer - Create a timer window for (Last started timer) with title Time Until Duel
      • Set Duel_TW = (Last created timer window)
      • Countdown Timer - Show Duel_TW
Then start duel and store hero positions in a point array
  • Duel
    • Events
      • Time - Duel_Timer expires
    • Conditions
    • Actions
      • Countdown Timer - Pause Duel_Timer
      • Unit - Pause all units
      • Unit Group - Pick every unit in Life_Units and do (Actions)
        • Loop - Actions
          • Hero - Instantly revive (Picked unit) at (Center of Life Base <gen>), Hide revival graphics
      • Unit Group - Pick every unit in Death_Units and do (Actions)
        • Loop - Actions
          • Hero - Instantly revive (Picked unit) at (Center of Death Base <gen>), Hide revival graphics
      • Unit - Pause all units
      • Player Group - Pick every player in (All players) and do (Camera - Pan camera for (Picked player) to (Center of Duel Center <gen>) over 1.00 seconds)
      • Set Life_Duelist = (Random unit from Life_Units)
      • Set Death_Duelist = (Random unit from Death_Units)
      • Set Duel_Pos[(Number of players)] = (Position of Hero_Array[(Number of players)])
      • Unit - Unpause Life_Duelist
      • Unit - Unpause Death_Duelist
      • Unit - Move Life_Duelist instantly to (Center of Life Duel <gen>), facing 0.00 degrees
      • Unit - Move Death_Duelist instantly to (Center of Death Duel <gen>), facing 180.00 degrees
      • Unit - Set life of Death_Duelist to 100.00%
      • Unit - Set life of Life_Duelist to 100.00%
      • Unit - Set mana of Death_Duelist to 100.00%
      • Unit - Set mana of Life_Duelist to 100.00%
      • Unit - Pause Life_Duelist
      • Unit - Pause Death_Duelist
      • Trigger - Turn on Life Win <gen>
      • Trigger - Turn on Death Win <gen>
      • Trigger - Turn on Timer Expires <gen>
      • Game - Display to (All players) the text: 3...
      • Wait 1.00 seconds
      • Game - Display to (All players) the text: 2...
      • Wait 1.00 seconds
      • Game - Display to (All players) the text: 1...
      • Wait 1.00 seconds
      • Unit - Unpause Death_Duelist
      • Unit - Unpause Life_Duelist
      • Countdown Timer - Start Duel_Timer as a One-shot timer that will expire in 100.00 seconds
Victory for Life Side
  • Life Win
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Triggering unit) Equal to Death_Duelist
    • Actions
      • Unit - Unpause all units
      • Countdown Timer - Resume Duel_Timer
      • Countdown Timer - Pause Duel_Time
      • Unit - Move Hero_Array[(Number of players)] instantly to Duel_Pos[(Number of players)]
      • Player Group - Pick every player in (All players) and do (Actions)
        • Loop - Actions
          • Camera - Pan camera for (Picked player) to Duel_Pos[(Number of players)] over 1.00 seconds
      • Set Life_Duelist = No unit
      • Set Death_Duelist = No unit
Victory for Death Side
  • Death Win
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Triggering unit) Equal to Life_Duelist
    • Actions
      • Unit - Unpause all units
      • Countdown Timer - Resume Duel_Timer
      • Countdown Timer - Pause Duel_Time
      • Unit - Move Hero_Array[(Number of players)] instantly to Duel_Pos[(Number of players)]
      • Player Group - Pick every player in (All players) and do (Actions)
        • Loop - Actions
          • Camera - Pan camera for (Picked player) to Duel_Pos[(Number of players)] over 1.00 seconds
      • Set Life_Duelist = No unit
      • Set Death_Duelist = No unit
Duel Time Expires
  • Timer Expires
    • Events
      • Time - Duel_Time expires
    • Conditions
    • Actions
      • Trigger - Turn off Life Win <gen>
      • Trigger - Turn off Death Win <gen>
      • Trigger - Turn off Life Side <gen>
      • Trigger - Turn off Death Side <gen>
      • Game - Display to (All players) the text: For wasting time th...
      • Unit - Create 1 zach807 for Neutral Hostile at (Center of Death Duel <gen>) facing Default building facing degrees
      • Unit Group - Add (Last created unit) to Original_BADASS
      • Unit Group - Order Original_BADASS to Attack-Move To (Center of Life Duel <gen>)
      • Player - Set (Owner of Life_Duelist) Current gold to 0
      • Player - Set (Owner of Death_Duelist) Current gold to 0
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Death_Duelist is dead) Equal to True
          • (Life_Duelist is dead) Equal to True
        • Then - Actions
          • Unit - Unpause all units
          • Player Group - Pick every player in (All players) and do (Actions)
            • Loop - Actions
              • Camera - Pan camera for (Picked player) to Duel_Pos[(Number of players)] over 1.00 seconds
          • Hero - Instantly revive Life_Duelist at (Center of Life Base <gen>), Show revival graphics
          • Hero - Instantly revive Death_Duelist at (Center of Death Base <gen>), Show revival graphics
          • Countdown Timer - Resume Duel_Timer
          • Unit Group - Pick every unit in Original_BADASS and do (Actions)
            • Loop - Actions
              • Unit - Kill (Picked unit)
          • Set Life_Duelist = No unit
          • Set Death_Duelist = No unit
          • Trigger - Turn on Life Side <gen>
          • Trigger - Turn on Death Side <gen>
          • Trigger - Turn off (This trigger)
        • Else - Actions
          • Do nothing
 
Level 12
Joined
Aug 31, 2008
Messages
1,121
Your hero array is a bit messed up. It will only store the last guy.
When the player picks the hero, set the array unit to the number of the picking player.
For all teh parts where you use (Number of players), make some kind of loop ( The each integer A kind from 1 to number of players. Sorry if that isn't very easy) and you and use the:
Set location[integer A] to location of unit[integer A]
This also leaks, you may want to touch up on leaks.
Jsut say if you need me to say more.
 
Level 3
Joined
Aug 9, 2009
Messages
27
Ok i think i got it figured out. These are my new lines of code that pertain to the arrays.

So this should put the hero into the array under the player number. As in:
1-Grim Reaper
2-Samurai
6-Ninja
7-Ancient of Stone

  • Set Hero_Array[(Player number of (Owner of (Triggering unit)))] = (Last created unit)
This should set the position of each Unit into the Point array matching the player number. As in
1 - Position of Grim Reaper
2 - Position of Samurai
6 - Position of Ninja
7 - Position of Ancient of Stone

  • Set Duel_Pos[Integer] = (Position of Hero_Array[Integer])
And this should pan the camera for every player to the position of their unit, because the camera pans to the point stored under each player's player number.
  • Player Group - Pick every player in (All players) and do (Actions)
    • Loop - Actions
      • Camera - Pan camera for (Picked player) to Duel_Pos[(Player number of (Picked player))] over 1.00 seconds
Will this work?

P.S. I've been giving +rep for all this help.
 
Level 12
Joined
Aug 31, 2008
Messages
1,121
Yeah that should work pretty well. Just use a loop to set the position's, or do it manually (More lines of code.)
I'm repping you for trying out my (Bad) instructions. Hope you learned something.
 
Status
Not open for further replies.
Top