Need help with this timer...

turok255

New Member
Reaction score
30
So im making a king of the hill map. If you go into the region (The Hill) The timer starts... First person to get their timer to X amount of seconds wins the game. The only problem with this trigger is.. If you have 20 units in the middle all yours and 1 leaves the timer stops. The timer active for the person with the most units in the middle. Heres the trigger.

Code:
activateTimer
    Events
        Unit - A unit enters Hill <gen>
        Unit - A unit leaves Hill <gen>
    Conditions
    Actions
        Leaderboard - Sort leaderBoardTimerKeeper by Value in Descending order
        Set ownerOfMostUnits = (Player in position 1 of leaderBoardTimerKeeper)
        Unit Group - Pick every unit in (Units owned by ownerOfMostUnits) and do (Actions)
            Loop - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        ((Entering unit) is in (Units owned by ownerOfMostUnits)) Equal to True
                    Then - Actions
                        Trigger - Turn on timer <gen>
                    Else - Actions
                        Trigger - Turn off timer <gen>
        Unit Group - Pick every unit in (Units owned by ownerOfMostUnits) and do (Actions)
            Loop - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        ((Leaving unit) is in (Units owned by ownerOfMostUnits)) Equal to True
                    Then - Actions
                        Trigger - Turn off timer <gen>
                    Else - Actions

Code:
timer
    Events
        Time - Every 0.01 seconds of game time
    Conditions
    Actions
        Set timeMilisecs[(Player number of ownerOfMostUnits)] = (timeMilisecs[(Player number of ownerOfMostUnits)] + 1)
        Set timeMilisecsString[(Player number of ownerOfMostUnits)] = (String(timeMilisecs[(Player number of ownerOfMostUnits)]))
        Set timeSecondsString[(Player number of ownerOfMostUnits)] = (String(timeSeconds[(Player number of ownerOfMostUnits)]))
        Set timeMinutesString[(Player number of ownerOfMostUnits)] = (String(timeMinutes[(Player number of ownerOfMostUnits)]))
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                timeMilisecs[(Player number of ownerOfMostUnits)] Equal to 100
            Then - Actions
                Set timeMilisecs[(Player number of ownerOfMostUnits)] = 0
                Set timeMilisecsString[(Player number of ownerOfMostUnits)] = (String(timeMilisecs[(Player number of ownerOfMostUnits)]))
                Set timeSeconds[(Player number of ownerOfMostUnits)] = (timeSeconds[(Player number of ownerOfMostUnits)] + 1)
                Set timeSecondsString[(Player number of ownerOfMostUnits)] = (String(timeSeconds[(Player number of ownerOfMostUnits)]))
            Else - Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                timeSeconds[(Player number of ownerOfMostUnits)] Equal to 60
            Then - Actions
                Set timeSeconds[(Player number of ownerOfMostUnits)] = 0
                Set timeSecondsString[(Player number of ownerOfMostUnits)] = (String(timeSeconds[(Player number of ownerOfMostUnits)]))
                Set timeMinutes[(Player number of ownerOfMostUnits)] = (timeMinutes[(Player number of ownerOfMostUnits)] + 1)
                Set timeMinutesString[(Player number of ownerOfMostUnits)] = (String(timeMinutes[(Player number of ownerOfMostUnits)]))
            Else - Actions
        If ((Integer(timeMilisecsString[(Player number of ownerOfMostUnits)])) Less than 10) then do (Set timeMilisecsString[(Player number of ownerOfMostUnits)] = (0 + (String(timeMilisecs[(Player number of ownerOfMostUnits)])))) else do (Do nothing)
        If ((Integer(timeSecondsString[(Player number of ownerOfMostUnits)])) Less than 10) then do (Set timeSecondsString[(Player number of ownerOfMostUnits)] = (0 + (String(timeSeconds[(Player number of ownerOfMostUnits)])))) else do (Do nothing)
        If ((Integer(timeMinutesString[(Player number of ownerOfMostUnits)])) Less than 10) then do (Set timeMinutesString[(Player number of ownerOfMostUnits)] = (0 + (String(timeMinutes[(Player number of ownerOfMostUnits)])))) else do (Do nothing)
        Multiboard - Set the text for Multiboard item in column 4, row ((Player number of ownerOfMostUnits) + 1) to ((timeMinutesString[(Player number of ownerOfMostUnits)] + :) + (timeSecondsString[(Player number of ownerOfMostUnits)] + (: + timeMilisecsString[(Player number of ownerOfMostUnits)])))

Im not exactly sure if theres an easy way to fix this so it still works. I can post all the triggers for the timer if needed but this is the main problem probabaly.
 

cleeezzz

The Undead Ranger.
Reaction score
268
oh god milliseconds, text flying through the screen.

anyway. your problem is that you turn off the time trigger when a unit leaves. Instead of turning off the trigger, just sort the leaderboard again, if Player in row 1 not equal to playermostunits, then set playermostunits = Player in row 1
 

turok255

New Member
Reaction score
30
Also when I go into combat the timer stops?


So what exactly would I need to change? I didn't make this triggerI tried and it was a bloody mess. Im afraid to change it incase it stops working :rolleyes:
 

cleeezzz

The Undead Ranger.
Reaction score
268
im kinda confused on what you want to happen

should the timer run when there are mixed players in the middle? (based on who has the most units) or only run when theres only one player?
 

WilliamPa

Active Member
Reaction score
51
Sorry, i'm so tired i didn't even have enough power to read whole trigger... Anyways i try to make you some triggers for king of the hill map...

Code:
TimerStart
    Events
        Unit - A unit enters No region
    Conditions
    Actions
        If ((Number of units in (Units in No region owned by (Owner of (Entering unit)))) Equal to 0) then do (Countdown Timer - Start Timer[(Player number of (Owner of (Entering unit)))] as a One-shot timer that will expire in 300.00 seconds) else do (Do nothing)

Code:
TimerStop
    Events
        Unit - A unit leaves No region
    Conditions
    Actions
        If ((Number of units in (Units in No region owned by (Owner of (Entering unit)))) Equal to 0) then do (Countdown Timer - Pause Timer[(Player number of (Owner of (Leaving unit)))]) else do (Do nothing)

Code:
Win
    Events
        Time - Every 1.00 seconds of game time
    Conditions
    Actions
        Leaderboard - Change the value for Player 1 (Red) in (Last created leaderboard) to (Integer((Remaining time for Timer[1])))
        Leaderboard - Change the value for Player 2 (Blue) in (Last created leaderboard) to (Integer((Remaining time for Timer[2])))
        Leaderboard - Change the value for Player 3 (Teal) in (Last created leaderboard) to (Integer((Remaining time for Timer[3])))
        Leaderboard - Sort (Last created leaderboard) by Value in Descending order
        If ((Remaining time for Timer[1]) Equal to 0.00) then do (Game - Victory Player 1 (Red) (Show dialogs, Show scores)) else do (Do nothing)
        If ((Remaining time for Timer[2]) Equal to 0.00) then do (Game - Victory Player 2 (Blue) (Show dialogs, Show scores)) else do (Do nothing)
        If ((Remaining time for Timer[3]) Equal to 0.00) then do (Game - Victory Player 3 (Teal) (Show dialogs, Show scores)) else do (Do nothing)

In the last trigger, you must do the action where you can store many actions and defeat other players, i just don't have TFT so can't make it.
The last trigger is pretty bad.
 

turok255

New Member
Reaction score
30
im kinda confused on what you want to happen

should the timer run when there are mixed players in the middle? (based on who has the most units) or only run when theres only one player?

It should run when atleast 1 player is in the middle... for the player with the most units..even while in combat.

But This trigger stops whenever I fight something, Or when 1 unit leaves the region but that player still has 20 more in it. and I don't want that.
 
M

Macintuss

Guest
sorry to revive a dead thread but i need this king of the hill code. WilliamPa your code looks PERFECT to me but i cant find
If ((Number of units in (Units in No region owned by (Owner of (Entering unit)))) Equal to 0)
ANYWHERE! i've spent like 45 min now and ive gotten frustrated enough to post in here. Thanks if you reply.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top