1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Dismiss Notice
  3. After a long wait, the results for Terraining Contest #18 are finally out! Drop by and congratulate the winners!
    Dismiss Notice
  4. The poll for Concept Art Contest #9 is up! Cast your vote for your favourite entry!
    Dismiss Notice
  5. Hero Contest #8 is up and running! This time it's a joint contest between artists and coders. Go here for team matchmaking.
    Dismiss Notice
  6. Our first StarCraft contest, The Galaxy Terraining Contest #1 - World Wonders has started. Enter to show off your Galaxy Editor skills and win a custom rank icon among other things.
    Dismiss Notice
  7. Ever wanted to get your sets ready for fast texturing while still having fun? Now it is possible with our newest Mini-Texturing Contest.
    The Skeleton Units need your dire help!
    Dismiss Notice
  8. The poll for Techtree Contest #11 is up! Cast your vote for your favorite entry.
    Dismiss Notice
  9. Take part in a Futuristic musical experience with our very own Music Contest. The 5th edition has finally arrived after a long time.
    Dismiss Notice
  10. Dismiss Notice

[Trigger] Hero Revival Timer

Discussion in 'Triggers & Scripts' started by Foronisus, Apr 16, 2012.

  1. Foronisus

    Foronisus
    Joined:
    Jul 5, 2010
    Messages:
    750
    guys i was working on revival system allmost 100% of the system works except the timer it shows. I make 2 triggers. The first one is for force 1 and second for force 2.when i make the first one it goes very good:
    • Events
      • Unit - A unit Dies
    • Conditions
      • ((Owner of (Killing unit)) controller) Not equal to User
      • ((Owner of (Triggering unit)) controller) Equal to User
      • ((Triggering unit) is A Hero) Equal to True
      • ((Owner of (Triggering unit)) is in FightingPvPGroup) Equal to False
    • Actions
      • Game - Display to (Player group((Owner of (Triggering unit)))) for 8.00 seconds the text: |cffffcc00You will ...
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Level of (Triggering unit)) Less than or equal to 40
        • Then - Actions
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Owner of (Triggering unit)) Equal to Player 1 (Red)
        • Then - Actions
          • Countdown Timer - Start TimerRed as a One-shot timer that will expire in 60.00 seconds
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Owner of (Triggering unit)) Equal to Player 2 (Blue)
        • Then - Actions
          • Countdown Timer - Start TimerBlue as a One-shot timer that will expire in 60.00 seconds
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Owner of (Triggering unit)) Equal to Player 3 (Teal)
        • Then - Actions
          • Countdown Timer - Start TimerTeal as a One-shot timer that will expire in 60.00 seconds
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Owner of (Triggering unit)) Equal to Player 4 (Purple)
        • Then - Actions
          • Countdown Timer - Start TimerPurple as a One-shot timer that will expire in 60.00 seconds
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Owner of (Triggering unit)) Equal to Player 5 (Yellow)
        • Then - Actions
          • Countdown Timer - Start TimerYellow as a One-shot timer that will expire in 60.00 seconds
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Owner of (Triggering unit)) Equal to Player 6 (Orange)
        • Then - Actions
          • Countdown Timer - Start TimerOrange as a One-shot timer that will expire in 60.00 seconds
        • Else - Actions
      • Countdown Timer - Create a timer window for (Last started timer) with title (Name of (Triggering player))
      • Set RevivalTimerWindow[(Player number of (Owner of (Triggering unit)))] = (Last created timer window)
      • Countdown Timer - Show RevivalTimerWindow[(Player number of (Owner of (Triggering unit)))]
      • Wait 60.00 game-time seconds
      • Set ModeGroup = (Units owned by (Owner of (Triggering unit)) matching (((Matching unit) is A Hero) Equal to True))
      • Unit Group - Pick every unit in ModeGroup and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Picked unit) is dead) Equal to True
            • Then - Actions
              • Hero - Instantly revive (Picked unit) at (Center of DOBRI POCETOK <gen>), Show revival graphics
              • Unit - Set mana of (Picked unit) to 80.00%
              • Unit - Make (Picked unit) Vulnerable
              • Selection - Select (Picked unit) for (Owner of (Triggering unit))
              • Camera - Pan camera for (Owner of (Picked unit)) to (Center of DOBRI POCETOK <gen>) over 0.00 seconds
            • Else - Actions
      • Custom script: call DestroyGroup (udg_ModeGroup)
      • Countdown Timer - Destroy RevivalTimerWindow[(Player number of (Owner of (Triggering unit)))]
      • If (((Owner of (Triggering unit)) is in NOSAVING) Equal to True) then do (Player Group - Remove (Owner of (Triggering unit)) from NOSAVING) else do (Do nothing)


    And when i put the same system for force 2 and change the Owner of triggering unit to the other 5 colors then when the hero dies 2 timers will be shown one doing right counting from 60 - 0 and on other it just stays on 0.
    First i want just one timer. second to work to go from 60 - 0. Can you see the leak i made?
     
  2. Starquizer

    Starquizer
    Joined:
    Mar 3, 2006
    Messages:
    1,530
    Save triggering unit in a unit variable and use that variable instead of triggering unit in your actions. Remember that you are using a wait so when another unit dies triggering unit will no longer be the first dying unit.
     
  3. Maker

    Maker
    Joined:
    Mar 6, 2006
    Messages:
    9,192
    Triggering unit works just fine with wait.
     
  4. Foronisus

    Foronisus
    Joined:
    Jul 5, 2010
    Messages:
    750
    so any problem?? because when i make 2 triggers 1 for Force 1 and one for Force 2 than when you play any class... when you die it shows 2 timers instead of one and one is working and other is not.

    Edit: Can you remake this trigger and put it here?
     
  5. Spartipilo

    Spartipilo
    Joined:
    Jul 14, 2011
    Messages:
    3,190
    · You should create a timer array with size = number of players (6).
    · Use variables insted of calling the same units/players/values over and over
    · You could create a group for dead heroes, and pick units in that group, instead of looking units owned by the player matching (Is a Hero = True).
    · A far as I know, destroying a timer without stopping it first leaks or bugs or something.

    Why don't you revive when the timer stops, instead of using a Wait? I don't know... I feel it's better :p Doesn't require creating a timer everytime the hero dies, it's more flexible, more accurate... etc.

    The same trigger, done in a "nearly" efficient way, would be something like:
    • Events
      • Unit - A unit Dies
    • Conditions
    • Actions
      • Set TUnit = Triggering Unit
      • Set TPlayer = Owner of TUnit
      • Set IntVar = Player Number of Player
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Owner of (Killing unit)) controller) Not equal to User
          • (TPlayer controller) Equal to User
          • (TUnit is A Hero) Equal to True
          • (TPlayer) is in FightingPvPGroup) Equal to False
        • Then - Actions
          • Set TForce = (Player Group(TPlayer))
          • Game - Display to TForce for 8.00 seconds the text: |cffffcc00You will ...
          • Custom script: call DestroYForce(udg_TForce)
          • Countdown Timer - Start Timer[IntVar] as a One-shot timer that will expire in 60.00 seconds
          • Countdown Timer - Create a timer window for Timer[IntVar] with title (Name of TPlayer)
          • Set RevivalTimerWindow[IntVar] = (Last created timer window)
          • Wait 60.00 game-time seconds
          • Set ModeGroup = (Units owned by (Owner of (Triggering unit)) matching (((Matching unit) is A Hero) Equal to True))
          • Unit Group - Pick every unit in ModeGroup and do (Actions)
            • Loop - Actions
              • Set TUnit = (Picked Unit)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (TUnit is dead) Equal to True
                • Then - Actions
                  • Set TPlayer = Owner of TUnit
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • Player number of TPlayer Lower than or equal to 6
                    • Then - Actions
                      • Set TPoint = (Team1 Revival Point <gen>)
                    • Else - Actions
                      • Set TPoint = (Team2 Revival point <gen>)
                  • Hero - Instantly revive TUnit at TPoint , Show revival graphics
                  • Unit - Set mana of TUnit to 80.00%
                  • Unit - Make TUnit Vulnerable
                  • Selection - Select TUnit for TPlayer
                  • Camera - Pan camera for TPlayer to TPoint over 0.00 seconds
                  • Custom script: call RemoveLocation(udg_TPoint)
          • Custom script: call DestroyGroup (udg_ModeGroup)
          • Set TPlayer = (Owner of (Triggering Unit))
          • Set IntVar = Player Number of TPlayer
          • Countdown Timer - Stop RevivalTimerWindow[IntVar]
          • Countdown Timer - Destroy RevivalTimerWindow[IntVar]
          • If (TPlayer is in NOSAVING Equal to True) then do (Player Group - Remove TPlayer from NOSAVING) else do (Do nothing)
        • Else - Actions
     
    Last edited: Apr 17, 2012
  6. Foronisus

    Foronisus
    Joined:
    Jul 5, 2010
    Messages:
    750
    so i should just copy that... hmm can you tell me the variables?
     
  7. -Kobas-

    -Kobas-
    Joined:
    Jan 17, 2010
    Messages:
    5,959
    TUnit = Unit
    TPlayer = Player
    IntVar = Integer
    FightingPvPGroup = PlayerGroup (Force)
    TForce = PlayerGroup (Force)
    RevivalTimerWindow = TimerWindow
    ModeGroup = UnitGroup (Group)
    TPoint = Point (Location)
    NOSAVING = PlayerGroup (Force)
     
  8. Foronisus

    Foronisus
    Joined:
    Jul 5, 2010
    Messages:
    750
    Guys can you make it as map? so i can open it and see how it is made?
     
  9. Spartipilo

    Spartipilo
    Joined:
    Jul 14, 2011
    Messages:
    3,190
    It's made exactly as you see. Just create those variable types (Which -Kobas- specified) and do the same functions as they're showed. It's easy, and doing it by yourself will help you with oncoming triggers.
     
  10. Foronisus

    Foronisus
    Joined:
    Jul 5, 2010
    Messages:
    750
    i tried but i failed can you make them in map. For Example, when it says: IntVar = Player number of players (I suppose Int should be integer). But below, on countdown, it must be timer. I'm confused...
     
  11. Spartipilo

    Spartipilo
    Joined:
    Jul 14, 2011
    Messages:
    3,190
    Made a mistake. I did it here in hive, not copy/paste from WC.

    Set TUnit = Triggering Unit
    Set TPlayer = Owner of TUnit
    Set IntVar = Player Number of TPlayer

    You have to understand than, after you set the varaibles, you no longer need (Triggering Unit) since you have "TUnit". You no longer need (Owner of Triggering Unit) since you have "TPlayer" and no longer need "Player number of Owner of Triggering Unit" since you hve "IntVar".

    IntVar = Player number of TPlayer it's the same than "IntVar = (Player Number of (Owner of (Triggering Unit)))"

    Be aware of the timer array. It's Timer[IntVar] You have to createa Timer with size = 6 (or the max players you use).

    Timer[IntVar] is the same than : Timer[(Player Number of (Owner of (Triggering Unit)))].
     
  12. Foronisus

    Foronisus
    Joined:
    Jul 5, 2010
    Messages:
    750
    ok but i have 2 forces so i think this trigger doesnt work for 2 forces(tried doesnt work for 2 forces) shows 2 timers when you make for both forces
     
    Last edited: Apr 17, 2012
  13. Spartipilo

    Spartipilo
    Joined:
    Jul 14, 2011
    Messages:
    3,190
    Depends.
    · Which players are in Force1 and Wich players are in Force2?
     
  14. Foronisus

    Foronisus
    Joined:
    Jul 5, 2010
    Messages:
    750
    from color red to color orange to force 1 and from green to brown to force 2 ;) please remake it ;)
     
  15. Spartipilo

    Spartipilo
    Joined:
    Jul 14, 2011
    Messages:
    3,190
    Create an If/Then/Else after "IntVar" is set. And if IntVar (Which is the player number) is greater than 6, then do your actions for that group, else, do the actions for players 1-6.

    But there's no need to copy all the actions and else for each group... What's the difference between the Team1 and Team2 in the trigger?

    Wich actions differ from one team to another?
     
  16. Foronisus

    Foronisus
    Joined:
    Jul 5, 2010
    Messages:
    750
    The difference are the different revival points.
    Team 1 revives in one zone, Team 2 in other.
     
  17. Spartipilo

    Spartipilo
    Joined:
    Jul 14, 2011
    Messages:
    3,190
    There, I fixed the trigger in the post http://www.hiveworkshop.com/forums/2134117-post5.html

    The only difference is the "If Then Else" that sets a different point based on player index. If player number is 1, 2, 3, 4, 5, 6 then set the Team1 Revival Point. Else, set the Team2 revival point.