HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

King of the Hill

04-24-2006, 07:54 PM#1
Taco
I am trying to make a "King of the Hill" type map where there are eight players that are trying to control and hold the center of the map. I am having trouble implementing the trigger(s) to control the center:

I am trying to make it so that if there are no units in the "Center" region of the map and a unit or units enters the region for 5 secnds then control of the center goes to the owner of the entering unit/units.

I currently have these two triggers but I cannot find a condition where it counts the number of units in a certain region owned by the enemy of the entering unit. I also cannot figure out a way to count down 5 seconds before the user gains control of the center.

Can someone help me out with this?


Thank you for taking the time to read my post
04-25-2006, 05:49 PM#2
MasterofSickness
Hi!
It finally took a few hours, but I figured out a nice system that should work.
I know that it isn't perfect (-> minor mistakes, not written in JASS and tiny Memory Leaks not excluded), but if you need further help, then just ask.
For this trigger you need one variable, which I called "Integer_PlayerNumber".
Its value should be a normal integer (no array) and for starting value I propose 16.
For the Region I have chosen "RegionAtMapCentre".
And for whatever buildings you want to use, you have to add them where "BuildingsAtCentre" is written.

Attention!
The following Code was written with a german WE, so a few parts may look different, but you should still be able to understand and rewrite it:

GUI:
Trigger:
UnitEntersRegion
Collapse Ereignisse
Einheit - A unit enters RegionAtMapCentre <gen>
Bedingungen
Collapse Aktionen
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse 'IF'-Bedingungen
(Owner of (Entering unit)) Gleich (Player(Integer_PlayerNumber))
'THEN'-Aktionen
Collapse 'ELSE'-Aktionen
Set Integer_PlayerNumber = (Player number of (Owner of (Entering unit)))
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse 'IF'-Bedingungen
(Number of units in (Units in RegionAtMapCentre <gen> matching (((Matching unit) Ungleich (Entering unit)) and (((Unit-type of (Matching unit)) Ungleich BuildingsAtCentre) and ((Owner of (Matching unit)) Ungleich (Player(Integer_PlayerNumber))))))) Gleich 0
Collapse 'THEN'-Aktionen
Spiel - Display to (All players) the text: ((Name of (Player(Integer_PlayerNumber))) + tries to get control of centre!)
Wait 5.00 game-time seconds
Spiel - Display to (All players) the text: 5 sec until change!
Wait 3.00 game-time seconds
Spiel - Display to (All players) the text: Now 2 sec!
Wait 2.00 game-time seconds
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse 'IF'-Bedingungen
(Number of units in (Units in RegionAtMapCentre <gen> matching (((Unit-type of (Matching unit)) Ungleich BuildingsAtCentre) and ((Owner of (Matching unit)) Ungleich (Player(Integer_PlayerNumber)))))) Gleich 0
Collapse 'THEN'-Aktionen
Spiel - Display to (All players) the text: (Centre controlled by + (Name of (Player(Integer_PlayerNumber))))
Collapse Einheitengruppe - Pick every unit in (Units in RegionAtMapCentre <gen> matching ((Unit-type of (Matching unit)) Gleich BuildingsAtCentre)) and do (Actions)
Collapse Schleifen - Aktionen
Einheit - Change ownership of (Picked unit) to (Player(Integer_PlayerNumber)) and Farbe wechseln
Collapse 'ELSE'-Aktionen
Spiel - Display to (All players) the text: RegionAtMapCentre's...
Collapse 'ELSE'-Aktionen
Spiel - Display to (All players) the text: ((Name of (Player(Integer_PlayerNumber))) + joined fighting for the centre!)
04-26-2006, 01:36 AM#3
Exilus
traduction:

Trigger:
UnitEntersRegion
Collapse events:
Unit- A unit enters RegionAtMapCentre <gen>
conditions:
Collapse actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(Owner of (Entering unit)) equal to (Player(Integer_PlayerNumber))
Then - Actions
Collapse Else - Action
Set Integer_PlayerNumber = (Player number of (Owner of (Entering unit)))
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(Number of units in (Units in RegionAtMapCentre <gen> matching (((Matching unit) not equal to (Entering unit)) and (((Unit-type of (Matching unit)) not equal to BuildingsAtCentre) and ((Owner of (Matching unit)) not equal to (Player(Integer_PlayerNumber))))))) equal to 0
Collapse Then - Actions
Game - Display to (All players) the text: ((Name of (Player(Integer_PlayerNumber))) + tries to get control of centre!)
Wait 5.00 game-time seconds
Game - Display to (All players) the text: 5 sec until change!
Wait 3.00 game-time seconds
Game - Display to (All players) the text: Now 2 sec!
Wait 2.00 game-time seconds
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(Number of units in (Units in RegionAtMapCentre <gen> matching (((Unit-type of (Matching unit)) Not equal to BuildingsAtCentre) and ((Owner of (Matching unit)) Not equal to (Player(Integer_PlayerNumber)))))) equal 0
Collapse Then - Actions
Game - Display to (All players) the text: (Centre controlled by + (Name of (Player(Integer_PlayerNumber))))
Collapse Unit Group - Pick every unit in (Units in RegionAtMapCentre <gen> matching ((Unit-type of (Matching unit)) Equal BuildingsAtCentre)) and do (Actions)
Collapse Loop - actions
Unit - Change ownership of (Picked unit) to (Player(Integer_PlayerNumber)) and Change Color
Collapse Else - Actions
Game - Display to (All players) the text: RegionAtMapCentre's...
Collapse Else - Actions
Game - Display to (All players) the text: ((Name of (Player(Integer_PlayerNumber))) + joined fighting for the centre!)