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.

      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