King of the Hill Help.

M

Macintuss

Guest
Hi. Thanks for reading. This might be hard to explain and/or read, I'll try my best to make it clear.

My Goal: When a unit enters region "center" starts a 30 second timer/display for owner of triggering unit. If that unit leaves it clears the timer/display. If another players unit enters while someone else is in the "center" it will pause until there is only one person in the "center". When a players timer reaches 0 for being in the center it will create 1 unit (somewhere doesn't matter) and then restart the timer for 30 seconds again.

My Current Triggers For This: (only triggered for red and blue for now) Warning: You will laugh at how primative my coding skill is & there are 7 triggers here
Code:
UnitEntersCenter
    Events
        Time - Every 1.00 seconds of game time
    Conditions
    Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                MiddleOwned Equal to 1
                ismiddlered Equal to 1
                Redtimeractive Equal to 0
            Then - Actions
                Set Redtimeractive = 1
                Countdown Timer - Start Kingofthehilltimer[(Player number of Player 1 (Red))] as a One-shot timer that will expire in 30.00 seconds
                Countdown Timer - Create a timer window for Kingofthehilltimer[(Player number of Player 1 (Red))] with title ((Name of Player 1 (Red)) +  Middle:)
                Set KingOfHillWindow[(Player number of Player 1 (Red))] = (Last created timer window)
            Else - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        MiddleOwned Equal to 1
                        ismiddleblue Equal to 1
                        Bluetimeractive Equal to 0
                    Then - Actions
                        Set Bluetimeractive = 1
                        Countdown Timer - Start Kingofthehilltimer[(Player number of Player 2 (Blue))] as a One-shot timer that will expire in 30.00 seconds
                        Countdown Timer - Create a timer window for Kingofthehilltimer[(Player number of Player 2 (Blue))] with title ((Name of Player 2 (Blue)) +  Middle:)
                        Set KingOfHillWindow[(Player number of Player 2 (Blue))] = (Last created timer window)
                    Else - Actions
                        Do nothing
Code:
UnitExitsCenter
    Events
        Time - Every 1.00 seconds of game time
    Conditions
    Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                ismiddlered Equal to 0
            Then - Actions
                Countdown Timer - Pause Kingofthehilltimer[(Player number of Player 1 (Red))]
                Countdown Timer - Destroy KingOfHillWindow[(Player number of Player 1 (Red))]
                Set Redtimeractive = 0
            Else - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        ismiddleblue Equal to 0
                    Then - Actions
                        Countdown Timer - Pause Kingofthehilltimer[(Player number of Player 2 (Blue))]
                        Countdown Timer - Destroy KingOfHillWindow[(Player number of Player 2 (Blue))]
                        Set Bluetimeractive = 0
                    Else - Actions
                        Do nothing
Code:
Own Middle
    Events
        Time - Every 1.00 seconds of game time
    Conditions
        MiddleOwned Equal to 1
    Actions
        Unit Group - Pick every unit in (Units in Center <gen>) and do (Actions)
            Loop - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        (Owner of (Picked unit)) Equal to Player 1 (Red)
                    Then - Actions
                        Set ismiddlered = 1
                    Else - Actions
                        Set ismiddlered = 0
                        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            If - Conditions
                                (Owner of (Picked unit)) Equal to Player 2 (Blue)
                            Then - Actions
                                Set ismiddleblue = 1
                            Else - Actions
                                Set ismiddleblue = 0
Code:
Own Middle2
    Events
        Time - Every 1.00 seconds of game time
    Conditions
        MiddleOwned Equal to 0
    Actions
        Set ismiddlered = 0
        Set ismiddleblue = 0
Code:
AnyoneInMiddle
    Events
        Time - Every 1.00 seconds of game time
    Conditions
    Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                (Number of units in (Units in Center <gen> matching ((Life of (Matching unit)) Greater than or equal to 1.00))) Less than 1
            Then - Actions
                Set MiddleOwned = 0
            Else - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        (Number of units in (Units in Center <gen> matching ((Life of (Matching unit)) Greater than or equal to 1.00))) Greater than or equal to 1
                    Then - Actions
                        Set MiddleOwned = 1
                    Else - Actions
Code:
TimerExpiresRed
    Events
        Time - Kingofthehilltimer[(Player number of Player 1 (Red))] expires
    Conditions
    Actions
        Countdown Timer - Destroy KingOfHillWindow[(Player number of Player 1 (Red))]
        Set Redtimeractive = 0
        Game - Display to (All players) the text: ((Name of Player 1 (Red)) +  Has Achieved King of The Hill!)
        Unit - Create 1 Golem Part for Player 1 (Red) at (Random point in GolemPartsSpawn1 <gen>) facing Default building facing degrees
        Sound - Play KingoftheHill <gen>
        Special Effect - Create a special effect at (Random point in Center <gen>) using Abilities\Spells\Human\Resurrect\ResurrectCaster.mdl
        Special Effect - Destroy (Last created special effect)
        Special Effect - Create a special effect at (Random point in Center <gen>) using Abilities\Spells\Human\Resurrect\ResurrectCaster.mdl
        Special Effect - Destroy (Last created special effect)
        Special Effect - Create a special effect at (Random point in Center <gen>) using Abilities\Spells\Human\Resurrect\ResurrectCaster.mdl
        Special Effect - Destroy (Last created special effect)
        Special Effect - Create a special effect at (Random point in Center <gen>) using Abilities\Spells\Human\Resurrect\ResurrectCaster.mdl
        Special Effect - Destroy (Last created special effect)
Code:
TimerExpiresBlue
    Events
        Time - Kingofthehilltimer[(Player number of Player 2 (Blue))] expires
    Conditions
    Actions
        Countdown Timer - Destroy KingOfHillWindow[(Player number of Player 2 (Blue))]
        Set Bluetimeractive = 0
        Game - Display to (All players) the text: ((Name of Player 2 (Blue)) +  Has Achieved King of The Hill!)
        Unit - Create 1 Golem Part for Player 2 (Blue) at (Random point in GolemPartsSpawn1 <gen>) facing Default building facing degrees
        Sound - Play KingoftheHill <gen>
        Special Effect - Create a special effect at (Random point in Center <gen>) using Abilities\Spells\Human\Resurrect\ResurrectCaster.mdl
        Special Effect - Destroy (Last created special effect)
        Special Effect - Create a special effect at (Random point in Center <gen>) using Abilities\Spells\Human\Resurrect\ResurrectCaster.mdl
        Special Effect - Destroy (Last created special effect)
        Special Effect - Create a special effect at (Random point in Center <gen>) using Abilities\Spells\Human\Resurrect\ResurrectCaster.mdl
        Special Effect - Destroy (Last created special effect)
        Special Effect - Create a special effect at (Random point in Center <gen>) using Abilities\Spells\Human\Resurrect\ResurrectCaster.mdl
        Special Effect - Destroy (Last created special effect)

Problem With My Code: When player 1 Red goes in the region everything works perfect like a charm (so far). But when Player 2 Blue enters it just shows the window and no timer is going, also when blue leaves the region it keeps the timer window and doesn't destroy it, red cannot enter the middle and start a timer after blue has been in it :(

Solution: Find the problem in my code (if you have the time to read it) or if your super cool you could find a easier way to code this and post it for me. Either way suggestions are wanted and answers are rep'd. Thanks.
 

LoveTD's

New Member
Reaction score
34
I think this will work:

Code:
Enter
    Events
        Unit - A unit enters King of the hill <gen>
    Conditions
        ((Triggering unit) is A Hero) Equal to True
    Actions
        Set Players_in_region = (Players_in_region + 1)
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                Players_in_region Greater than 1
            Then - Actions
                Countdown Timer - Pause King_timer[(Player number of (Owner of First_unit_entering))]
            Else - Actions
                Set First_unit_entering = (Triggering unit)
                If (Players_in_region Equal to 1) then do (Countdown Timer - Start King_timer[(Player number of (Owner of First_unit_entering))] as a One-shot timer that will expire in 30.00 seconds) else do (Do nothing)
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        Has_already_been_in_region[(Player number of (Owner of First_unit_entering))] Equal to True
                    Then - Actions
                        Countdown Timer - Resume King_timer[(Player number of (Owner of First_unit_entering))]
                    Else - Actions
                        Countdown Timer - Start King_timer[(Player number of (Owner of (Triggering unit)))] as a One-shot timer that will expire in 30.00 seconds
                        Countdown Timer - Create a timer window for King_timer[(Player number of (Owner of First_unit_entering))] with title Midle:
                        Countdown Timer - Show King_timer_window[(Player number of (Owner of First_unit_entering))] for (Owner of First_unit_entering)
                        Set Has_already_been_in_region[(Player number of (Owner of First_unit_entering))] = True

Code:
Leave
    Events
        Unit - A unit leaves King of the hill <gen>
    Conditions
        ((Triggering unit) is A Hero) Equal to True
    Actions
        Set Players_in_region = (Players_in_region - 1)
        Countdown Timer - Pause King_timer[(Player number of (Owner of (Triggering unit)))]

Code:
Win for player 1
    Events
        Time - King_timer[1] expires
    Conditions
    Actions
        Countdown Timer - Destroy King_timer_window[1]
        Game - Display to (All players) the text: ((Name of Player 1 (Red)) + Has Achieved King of The Hill!)
        -------- Add all the blablabla you want (make this trigger for every player) --------

didn't test it yet, I'm testing it now so don't be pissed if there are bugs for now ^^ and also I'm not sure about memory leaks, this is beta version of my trigs ^^

EDIT: hmmz didn't work :S lemme think few secs..

EDIT: does work now, small problem with resuming the timer... lemme work on it :D
 
M

Macintuss

Guest
K cool let me know if you figure it out. Thanks for trying in any case.
 

LoveTD's

New Member
Reaction score
34
seems like it's not that easy, I'm trying a different way which works but still has a few flaws which I have to put straight, might take a while...
 
M

Macintuss

Guest
Alright man, thanks for taking the time to try and figure it out. I'll look forward to hearing from you.
 

LoveTD's

New Member
Reaction score
34
After a lot of work i've made it's flawless :D unless you count memmory leaks :( dunno if they are in if they do you can try to remove em by yourself, i don't think there are leaks but if there are please double check it :D ) here are the triggers:

Code:
Win for player 1
    Events
        Time - King_timer[1] expires
    Conditions
    Actions
        Set Timer_is_dead[1] = True
        Countdown Timer - Destroy King_timer_window[1]
        Game - Display to (All players) the text: ((Name of Player 1 (Red)) + Has Achieved King of The Hill!)
        -------- Add all the blablabla you want (make this trigger for every player) --------

Code:
Init
    Events
        Map initialization
    Conditions
    Actions
        Set Hero_of_player[1] = Mountain King 0002 <gen>
        Set Hero_of_player[2] = Blood Mage 0003 <gen>
        -------- (don't stop untill you reached your last hero) ow and if you used a hero pick system then just set your hero's into this variable or a variable that you already have... --------

Code:
Player 1 timer
    Events
        Time - Every 0.70 seconds of game time
    Conditions
    Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                (King of the hill <gen> contains Hero_of_player[1]) Equal to False
            Then - Actions
                Countdown Timer - Pause King_timer[1]
                Countdown Timer - Hide King_timer_window[1] for Player 1 (Red)
            Else - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        More_then_one_in_rect Equal to True
                    Then - Actions
                        Countdown Timer - Pause King_timer[1]
                    Else - Actions
                        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            If - Conditions
                                Has_already_been_in_region[1] Equal to True
                            Then - Actions
                                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                    If - Conditions
                                        Timer_is_dead[1] Equal to False
                                    Then - Actions
                                        Countdown Timer - Resume King_timer[1]
                                        Countdown Timer - Show King_timer_window[1] for Player 1 (Red)
                                    Else - Actions
                                        Do nothing
                            Else - Actions
                                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                    If - Conditions
                                        Timer_is_dead[1] Equal to False
                                    Then - Actions
                                        Countdown Timer - Start King_timer[1] as a One-shot timer that will expire in 30.00 seconds
                                        Countdown Timer - Create a timer window for King_timer[1] with title Midle:
                                        Set King_timer_window[1] = (Last created timer window)
                                        Countdown Timer - Show King_timer_window[1] for Player 1 (Red)
                                        Set Has_already_been_in_region[1] = True
                                    Else - Actions
                                        Do nothing
        -------- (has to be done for every player) --------

Code:
Enter
    Events
        Unit - A unit enters King of the hill <gen>
    Conditions
        ((Triggering unit) is A Hero) Equal to True
    Actions
        Set Players_in_region = (Players_in_region + 1)
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                Players_in_region Greater than 1
            Then - Actions
                Set More_then_one_in_rect = True
            Else - Actions
                Set More_then_one_in_rect = False

Code:
Leave
    Events
        Unit - A unit leaves King of the hill <gen>
    Conditions
        ((Triggering unit) is A Hero) Equal to True
    Actions
        Set Players_in_region = (Players_in_region - 1)
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                Players_in_region Greater than 1
            Then - Actions
                Set More_then_one_in_rect = True
            Else - Actions
                Set More_then_one_in_rect = False


small description of what it does: every time you enter the *hill* you will have your timer go down

(unless there are more then 1 players in the hill then the timer will stop for all players in the hill untill there is 1 left)

If you leave the hill your window will be hided (but still have the nessecary count so for example you have 10 secs to go and leave the hill you won't see your timer but when you return to the hill the window returns with the 10 secs left)

I hope you have fun with this :D

ow and erm... I made it so that it can only be used once (because of a bug which lets you win the hill every 0.7 secs), if you have any
problems with that please tell me and I will try to fix it ok?
(or if you want to you can even let me make rounds, so when player 1 wins he wins round 1, player with most rounds won wins)
 

the Lumpy

►►►
Reaction score
53
Code:
        -------- (has to be done for every player) --------
Ouch, that'll take forever... Instead, put all those actions inside of a For each (Integer player_number) from 1 to ... and then use the player_number variable for the array indexes.
 

LoveTD's

New Member
Reaction score
34
tryed that, but no goods because you will have to mess with all the triggers then... You can try it if you like but I'm not sure if it will work :D
if you meant something like this than I don't think it is going to work (I'm not completely new to loops but I'm a bit new, tell me if I'm doing it wrong :D):

Code:
Player 1 timer
    Events
        Time - Every 0.70 seconds of game time
    Conditions
    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
                        (King of the hill <gen> contains Hero_of_player[(Integer A)]) Equal to False
                    Then - Actions
                        Countdown Timer - Pause King_timer[(Integer A)]
                        Countdown Timer - Hide King_timer_window[(Integer A)] for (Player((Integer A)))
                    Else - Actions
                        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            If - Conditions
                                More_then_one_in_rect Equal to True
                            Then - Actions
                                Countdown Timer - Pause King_timer[(Integer A)]
                            Else - Actions
                                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                    If - Conditions
                                        Has_already_been_in_region[(Integer A)] Equal to True
                                    Then - Actions
                                        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                            If - Conditions
                                                Timer_is_dead[(Integer A)] Equal to False
                                            Then - Actions
                                                Countdown Timer - Resume King_timer[(Integer A)]
                                                Countdown Timer - Show King_timer_window[(Integer A)] for (Player((Integer A)))
                                            Else - Actions
                                                Do nothing
                                    Else - Actions
                                        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                            If - Conditions
                                                Timer_is_dead[(Integer A)] Equal to False
                                            Then - Actions
                                                Countdown Timer - Start King_timer[(Integer A)] as a One-shot timer that will expire in 30.00 seconds
                                                Countdown Timer - Create a timer window for King_timer[(Integer A)] with title Midle:
                                                Set King_timer_window[(Integer A)] = (Last created timer window)
                                                Countdown Timer - Show King_timer_window[(Integer A)] for (Player((Integer A)))
                                                Set Has_already_been_in_region[(Integer A)] = True
                                            Else - Actions
                                                Do nothing

Code:
Win for player 1
    Events
        Time - King_timer[1] expires
        Time - King_timer[2] expires
        Time - King_timer[3] expires
        Time - King_timer[4] expires
        Time - King_timer[5] expires
        Time - King_timer[6] expires
        Time - King_timer[7] expires
        Time - King_timer[8] expires
    Conditions
    Actions
        For each (Integer A) from 1 to 8, do (Actions)
            Loop - Actions
                Set Timer_is_dead[(Integer A)] = True
                Countdown Timer - Destroy King_timer_window[(Integer A)]
                Game - Display to (All players) the text: ((Name of (Player((Integer A)))) + Has Achieved King of The Hill!)
 
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

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top