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.
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though
  • Ghan Ghan:
    Heard Houston got hit pretty bad by storms last night. Hope all is well with TH.
  • The Helper The Helper:
    Power back on finally - all is good here no damage
    +2
  • V-SNES V-SNES:
    Happy Friday!
    +1
  • The Helper The Helper:
    New recipe is another summer dessert Berry and Peach Cheesecake - https://www.thehelper.net/threads/recipe-berry-and-peach-cheesecake.194169/

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top