I need to make a timer for each player that is in a region, no clue where to start

Eyonix

TH.net Regular
Reaction score
16
Im making a King of the Hill style map mixed with a footmen style, and the victory condition is you control the hill for so long and get to the time you pick and you win. The timer would be for each team. Theres 4 teams of 3 players, the team with the most units on the hill gets time added to their timer. (Example: Team 1 has 10 units on the hill, Team 2 has 20 units on the hill, Team 2 gets time added onto their timer, and Team 1 doesn't untill they get more units than Team 2 in the region.) The timer would increase 1 second at a time. If there are no units on the hill the timer stops. Also the time has to be displayed on my multiboard in the 4th coulmn.

Another question... Would it be easier to just give every player their own timer than add the timers of the players of that team together? like...

Set TotalTeamTimer[1] = RedsTimer + BluesTimer + TealsTimer
If TotalTeamTimer[1] = 30 minutes victory Red Blue Teal?

If anyone would be brave enough to attempt this for me i'll give major credit where its due and give ya rep. If no one is brave enough could someone point me in the right direction?

Edit:Not adding time anymore, just adding a regular integer
 

Eyonix

TH.net Regular
Reaction score
16
Thanks, I took a look at it, I attempted to make a trigger but im going to bed, if anyone wants to make a trigger that actually works please do :p

My current trigger is supposed to store the amount of units in the region for each player and then select the highest integer, its not working too good :banghead:

Trigger:
  • Enter Hill
    • Events
      • Unit - A unit enters Hill <gen>
    • Conditions
    • Actions
      • Unit Group - Pick every unit in (Units in Hill <gen> owned by (Owner of (Triggering unit))) and do (Actions)
        • Loop - Actions
          • Set UnitsInHill[(Player number of (Owner of (Triggering unit)))] = ((Number of units in (Units in Hill <gen> owned by (Owner of (Picked unit)))) + 1)


Trigger:
  • Checking Units
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • Player Group - Pick every player in (All players) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • UnitsInHill[(Player number of (Picked player))] Greater than or equal to 0
            • Then - Actions
              • For each (Integer A) from 1 to Player_Count, do (Actions)
                • Loop - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • Arrray[ArrayNum] Less than or equal to Arrray[(Integer A)]
                    • Then - Actions
                      • Set ArrayNum = (Integer A)
                      • Set ArrayVal = Arrray[(Integer A)]
                    • Else - Actions
            • Else - Actions
 

Eyonix

TH.net Regular
Reaction score
16
bump, well i worked on it a little bit today and still don't have it working properly.... Can someone please tell me how in detail to check and see what integer variable is highest? I got an integer Array 12 and im trying to figure out what player has the higher integer.
 

Eyonix

TH.net Regular
Reaction score
16
I looked at those already and no mater how many times i read it don't understand how it does it... I know what its supposed to do, so it kinda confuses me when i try to implement it into my map
 

FlashDeath

New Member
Reaction score
2
don't have WC right now so i cant give u the exact triggers but u can try something like this:
-------------------------
event:
every 1 second

action:
Add all units of team 1 in the region into a group[1]
Add all units of team 2 in the region into a group[2]
Add all units of team 3 in the region into a group[3]
Add all units of team 4 in the region into a group[4]

set temp = 1

For integer A from 2 to 4 loop
-if number of units in group[A] > number of units in group[temp] then
----set temp = A

set time-for-group[temp] = time-for-group[temp] + 1
------------------

hope i've point you in the right direction. Of course, this isn't all, but i guess u know how to go on from here.
 

Eyonix

TH.net Regular
Reaction score
16
im going to have to say im horrible at triggering :(

Is this what you meant?

Trigger:
  • Checking Units
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • Set Teams[1] = (All allies of Player 1 (Red))
      • Set Teams[2] = (All allies of Player 4 (Purple))
      • Set Teams[3] = (All allies of Player 7 (Green))
      • Set Teams[4] = (All allies of Player 10 (Light Blue))
      • Player Group - Pick every player in Teams[1] and do (Actions)
        • Loop - Actions
          • Unit Group - Pick every unit in (Units in Hill <gen> owned by (Picked player)) and do (Actions)
            • Loop - Actions
              • Unit Group - Add (Picked unit) to TeamUnits[1]
      • Player Group - Pick every player in Teams[2] and do (Actions)
        • Loop - Actions
          • Unit Group - Pick every unit in (Units in Hill <gen> owned by (Picked player)) and do (Actions)
            • Loop - Actions
              • Unit Group - Add (Picked unit) to TeamUnits[2]
      • Player Group - Pick every player in Teams[3] and do (Actions)
        • Loop - Actions
          • Unit Group - Pick every unit in (Units in Hill <gen> owned by (Picked player)) and do (Actions)
            • Loop - Actions
              • Unit Group - Add (Picked unit) to TeamUnits[3]
      • Player Group - Pick every player in Teams[4] and do (Actions)
        • Loop - Actions
          • Unit Group - Pick every unit in (Units in Hill <gen> owned by (Picked player)) and do (Actions)
            • Loop - Actions
              • Unit Group - Add (Picked unit) to TeamUnits[4]
      • Set Temp_Integer = 1
      • For each (Integer A) from 2 to 4, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Number of units in TeamUnits[(Integer A)]) Greater than Temp_Integer
            • Then - Actions
              • Set Temp_Integer = (Integer A)
            • Else - Actions
 

FlashDeath

New Member
Reaction score
2
Change the last part of the trigger to this:

Trigger:
  • For each (Integer A) from 2 to 4, do (Actions)
    • Loop - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of units in TeamUnits[(Integer A)]) Greater than (Number of units in TeamUnits[(Temp_Integer)]
        • Then - Actions
          • Set Temp_Integer = (Integer A)
        • Else - Actions


We are comparing the number of units in each group and then identify which group has the most number of units. What you did was compare number of units of each group with the variable. :eek:

Also, i dont see the variable that is used to record the time in the hill. Remember to add it in or this trigger is as good as useless.

For the first four actions "Set Teams[1] = (All allies of XXXXX)", you could probably remove it and add that into map initialization trigger because you don't want this to happen every 1 second. Technically it's not wrong but it is pointless and takes abit more processing power.

Also change this part:


Trigger:
  • Player Group - Pick every player in Teams[1] and do (Actions)
    • Loop - Actions
      • Unit Group - Pick every unit in (Units in Hill <gen> owned by (Picked player)) and do (Actions)
        • Loop - Actions
          • Unit Group - Add (Picked unit) to TeamUnits[1]
    • Player Group - Pick every player in Teams[2] and do (Actions)
      • Loop - Actions
        • Unit Group - Pick every unit in (Units in Hill <gen> owned by (Picked player)) and do (Actions)
          • Loop - Actions
            • Unit Group - Add (Picked unit) to TeamUnits[2]
    • Player Group - Pick every player in Teams[3] and do (Actions)
      • Loop - Actions
        • Unit Group - Pick every unit in (Units in Hill <gen> owned by (Picked player)) and do (Actions)
          • Loop - Actions
            • Unit Group - Add (Picked unit) to TeamUnits[3]
    • Player Group - Pick every player in Teams[4] and do (Actions)
      • Loop - Actions
        • Unit Group - Pick every unit in (Units in Hill <gen> owned by (Picked player)) and do (Actions)
          • Loop - Actions
            • Unit Group - Add (Picked unit) to TeamUnits[4]


to

Trigger:
  • For each (Integer A) from 1 to 4, do (Actions)
    • Loop - Actions
    • Player Group - Pick every player in Teams[(Integer A)] and do (Actions)
      • Loop - Actions
        • Unit Group - Pick every unit in (Units in Hill <gen> owned by (Picked player)) and do (Actions)
          • Loop - Actions
            • Unit Group - Add (Picked unit) to TeamUnits[(Integer A)]


After all these, put this at the very last to prevent any units that have left the region to be counted in again.

Trigger:
  • For each (Integer A) from 1 to 4, do (Actions)
    • Loop - Actions
    • Unit Group - Remove all units from TeamUnits[(Integer A)]
 

Eyonix

TH.net Regular
Reaction score
16
So heres the trigger I have, its not working btw :banghead::banghead::banghead: I compaired it to what you gave me and I think its all the same. I added the display text in there for testing purposes.

Trigger:
  • Checking Units
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • For each (Integer A) from 1 to 4, do (Actions)
        • Loop - Actions
          • Player Group - Pick every player in Teams[(Integer A)] and do (Actions)
            • Loop - Actions
              • Unit Group - Pick every unit in (Units in Hill <gen> owned by (Picked player)) and do (Actions)
                • Loop - Actions
                  • Unit Group - Add (Picked unit) to TeamUnits[(Integer A)]
      • Set Temp_Integer = 1
      • For each (Integer A) from 2 to 4, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Number of units in TeamUnits[(Integer A)]) Greater than (Number of units in TeamUnits[Temp_Integer])
            • Then - Actions
              • Set Temp_Integer = (Integer A)
            • Else - Actions
      • Game - Display to (All players) the text: (String(Temp_Integer))
      • For each (Integer A) from 1 to 4, do (Actions)
        • Loop - Actions
          • Unit Group - Remove all units of TeamUnits[(Integer A)] from TeamUnits[(Integer A)]


Also im going to add the part to update the time in control of the hill later that should be the easy part for me :rolleyes:. If I get this working.... the biggest parts of my map will be done :D
 

FlashDeath

New Member
Reaction score
2
Which part of it isn't working? If you mean the total time did not go up, thats because you didnt add it in. Add it into the part where you put the test message.

If you mean Temp_Integer didn't come up, it's most probably you forgot to include

Set Teams[1] = (All allies of Player 1 (Red))
Set Teams[2] = (All allies of Player 4 (Purple))
Set Teams[3] = (All allies of Player 7 (Green))
Set Teams[4] = (All allies of Player 10 (Light Blue))

in your map initialization trigger.

If Temp_Integer keep popping up as 1, its most probably that you forgot to set the array size for the unit group, which is 4 in your case

Also, edit this part of your trigger to this:
Trigger:
  • For each (Integer A) from 1 to 4, do (Actions)
    • Loop - Actions
      • Player Group - Pick every player in Teams[(Integer A)] and do (Actions)
        • Loop - Actions
          • Unit Group - Pick every unit in (Units in Hill <gen> matching ((((Matching unit) is alive) Equal to True) and (((Matching unit) belongs to an ally of (Picked player)) Equal to True))) and do (Actions)
            • Loop - Actions
              • Unit Group - Add (Picked unit) to TeamUnits[(Integer A)]


EDIT: I realise that there isn't anything to handle the situation where the number of units is the same in each team. You have to decide on the .. deciding factor before we continue.
 

Eyonix

TH.net Regular
Reaction score
16
I think we should do if they are the same add points to nobody.

I set the teams...
Trigger:
  • Map Initialization for Muiltiboard
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set Teams[1] = (All allies of Player 1 (Red))
      • Set Teams[2] = (All allies of Player 4 (Purple))
      • Set Teams[3] = (All allies of Player 7 (Green))
      • Set Teams[4] = (All allies of Player 10 (Light Blue))
      • -------- Gold Color --------
      • Set Players_ColorCodes[0] = |cffffcc00
      • -------- Players Colors --------
      • Set Players_ColorCodes[1] = |c00ff0303
      • Set Players_ColorCodes[2] = |c000042ff
      • Set Players_ColorCodes[3] = |c001ce6b9
      • Set Players_ColorCodes[4] = |c00540081
      • Set Players_ColorCodes[5] = |c00fffc01
      • Set Players_ColorCodes[6] = |c00feba0e
      • Set Players_ColorCodes[7] = |c0020c000
      • Set Players_ColorCodes[8] = |c00e55bb0
      • Set Players_ColorCodes[9] = |c00959697
      • Set Players_ColorCodes[10] = |c007EBFF1
      • Set Players_ColorCodes[11] = |c00106246
      • Set Players_ColorCodes[12] = |cFF4E2A04
      • Set ColorCodes_EndTag = |r


and heres the newly modified trigger...
Trigger:
  • Checking Units
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • For each (Integer A) from 1 to 4, do (Actions)
        • Loop - Actions
          • Player Group - Pick every player in Teams[(Integer A)] and do (Actions)
            • Loop - Actions
              • Unit Group - Pick every unit in (Units in Hill <gen> matching ((((Matching unit) is alive) Equal to True) and (((Matching unit) belongs to an ally of (Picked player)) Equal to True))) and do (Actions)
                • Loop - Actions
                  • Unit Group - Add (Picked unit) to TeamUnits[(Integer A)]
      • Set Temp_Integer = 1
      • For each (Integer A) from 2 to 4, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Number of units in TeamUnits[(Integer A)]) Greater than (Number of units in TeamUnits[Temp_Integer])
            • Then - Actions
              • Set Temp_Integer = (Integer A)
            • Else - Actions
      • Game - Display to (All players) the text: (String(Temp_Integer))
      • For each (Integer A) from 1 to 4, do (Actions)
        • Loop - Actions
          • Unit Group - Remove all units of TeamUnits[(Integer A)] from TeamUnits[(Integer A)]


Still only displays a 1....

EDIT: The player group size doesn't need to be set does it? Coz i set it to 4 as well just to test and it made no difference.
PS: I figured i'd add the lines for adding the point after we got this working right...just keeps less stuff outta there till this damn thing works. :(
 

Eyonix

TH.net Regular
Reaction score
16
bump, still where I was last time I posted.... I made a copy and then messed with it but it didn't change anything... it made it worse actually xD so i just deleted the copy and have the current last trigger i posted.
 

Teach101

New Member
Reaction score
4
Eh, This is actually much simpler then what your doing.
Event- a unit enters region
action- turn on trigger "get unit"

Trigger get unit

Event- Periodic time every .1 seconds
action- Set Unit group Variable to units within range of # from point 1 (set point 1 to where the hill is at start of game)

Pick ever unit in unit group and do the following:
set point 2 = position of picked unit
set Distance = find distance between point 2 and point 1
loop 1-12
if/then/else (Do the below if picked unit is belongs to player integer A and if distance is less then the range #)
action- set variable Time[Integer A] + .1
else turn off this trigger

action custom script- call DestroyUnitGroup(udg_Unit_Group[Integer_A])
(Destroying it cause it leaks if you don't.)

Well this was made by hand and im sure i left a little out.
Btw, thing about this is that regions are squared and ranges are circular. (doubt that would matter to much. This is also Mpi not Mui)
 

trees123

New Member
Reaction score
6
Do you mind posting the triggers of how you got it to work? I'm curious to see how it was done. If not, then okay. <3
 

FlashDeath

New Member
Reaction score
2
Hey, I was busy the last few days and i'm sorry i couldn't help u out. Since its working now, congratz :eek:

Anyway what teach has suggested adds time for every unit found within range. I dunno whether I've been misunderstanding the problem or something but what i understand it as is add time only if there are more units within range of the same group than the other.
 

Eyonix

TH.net Regular
Reaction score
16
Heres the trigger (Thanks Cleeezzz for practically remaking it) for you guys, so you can see it & np flash.

Trigger:
  • Checking Units
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • Set Hill_Group = (Units in Hill &lt;gen&gt; matching (((Matching unit) is alive) Equal to True))
      • Unit Group - Pick every unit in Hill_Group and do (Actions)
        • Loop - Actions
          • For each (Integer A) from 1 to 4, do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • ((Owner of (Picked unit)) is in Teams[(Integer A)]) Equal to True
                • Then - Actions
                  • Unit Group - Add (Picked unit) to TeamUnits[(Integer A)]
                • Else - Actions
      • Set Largest = -1
      • Set LargestTeam = 0
      • Set Skip = -1
      • For each (Integer A) from 1 to 4, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Number of units in TeamUnits[(Integer A)]) Greater than Largest
            • Then - Actions
              • Set Largest = (Number of units in TeamUnits[(Integer A)])
              • Set LargestTeam = (Integer A)
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Number of units in TeamUnits[(Integer A)]) Equal to Largest
                • Then - Actions
                  • Set Skip = (Number of units in TeamUnits[(Integer A)])
                • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • LargestTeam Not equal to 0
          • Skip Not equal to Largest
        • Then - Actions
          • Set Points[LargestTeam] = (Points[LargestTeam] + 1)
          • Player Group - Pick every player in Teams[LargestTeam] and do (Actions)
            • Loop - Actions
              • Multiboard - Set the text for (Last created multiboard) item in column 4, row Multiboard_Spots[(Player number of (Picked player))] to (Players_ColorCodes[(Player number of (Picked player))] + (String(Points[LargestTeam])))
        • Else - Actions
      • For each (Integer A) from 1 to 4, do (Actions)
        • Loop - Actions
          • Unit Group - Remove all units from TeamUnits[(Integer A)]
      • Custom script: call DestroyGroup(udg_Hill_Group)
 
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