• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Make a Simple Control-Point System

Level 14
Joined
Jan 5, 2009
Messages
1,127

Control-Point System

What is a control-point system?
A control-point system is where there are multiple forces going after certain areas to control, known as "control points". Every few seconds, you will get points from controlling those points, but there's a catch; only the team with the most control points gets the points. It detects whoever has the most and uses the amount of control points to calculate the points the team gets by: counting them, taking away the amount the other team has, and getting the result to add to the total.​

This tutorial will show you how to create an effective control-point system using GUI Triggering.
What you need:
  • WE Editor (Any type, whether it be regular, JNGP, or WEU)
  • Basic GUI Knowledge.
  • WE Experience.

Making the System:
  • First, open the World Editor.
  • Open your map that you want to have a control-point system in, or create a new map.
  • I suggest you separate the players into opposing forces for these particular triggers to work properly. In this tutorial, we will be using 2 opposing forces of 2 players, Player 1 and Player 7.
  • Open the object editor.
  • Create a new unit (Use the Circle of Power as a base. [any size]).
  • Name it Capture Point. Change the life to something decent, because this will be the deciding factor on how fast the control point can be taken. Make sure you remove the ability Invulnerable from the unit to make sure it can be attacked.
  • Put however many you want around the map. Make sure you are careful where you place them due to balancing issues.
  • Open the trigger editor.
  • Create triggers named Capture CP and CP Points.
  • Open the variable editor, and create the following variables:
    Variable NameType
    [tr][td]CP_Group1[/td][TD]Unit Group[/TD][/tr]
    [tr][td]CP_Group2[/td][TD]Unit Group[/TD][/tr]
    [tr][td]CP_Points1[/td][TD]Integer[/TD][/tr]
    [tr][td]CP_Points2[/td][TD]Integer[/TD][/tr]

What variable does what?
  • CP_Group1 - This unit group will contain all the control points owned by Force 1.
  • CP_Group2 - This unit group will contain all the control points owned by Force 2.
  • CP_Points1 - This will track Force 1's points.
  • CP_Points2 - This will track Force 2's points.

Trigger:Capture CP

  • Capture CP
    • Events
      • Unit - A unit Is attacked
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Unit-type of (Attacked unit)) Equal to Capture Point
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Owner of (Attacked unit)) Equal to Player 1 (Red)
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Percentage life of (Attacked unit)) Less than or equal to 25.00
                • Then - Actions
                  • Unit - Set life of (Attacked unit) to (Max life of (Attacked unit))
                  • Unit - Change ownership of (Attacked unit) to Player 7 (Green) and Change color
                • Else - Actions
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Owner of (Attacked unit)) Equal to Player 7 (Green)
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Percentage life of (Attacked unit)) Less than or equal to 25.00
                • Then - Actions
                  • Unit - Set life of (Attacked unit) to (Max life of (Attacked unit))
                  • Unit - Change ownership of (Attacked unit) to Player 1 (Red) and Change color
                • Else - Actions
            • Else - Actions
        • Else - Actions
This trigger shows how units capture control points. When an enemy attacks a control point, it checks the life of the control point, and it will be claimed by the attacking player when the control point reaches below 25% health. For example, the red player attacks a point controlled by green. When the control point reaches below 25% health, the possession will be switched and the red player will now have control, with the point at 100% health.​

  • CP Points
    • Events
      • Time - Every 20.00 seconds of game time
    • Conditions
    • Actions
      • Set CP_Group1 = (Units owned by Player 1 (Red) of type Control Point)
      • Set CP_Group2 = (Units owned by Player 7 (Green) of type Control Point)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of units in CP_Group1) Greater than (Number of units in CP_Group2)
        • Then - Actions
          • Set CP_Points1 = (CP_Points1 + ((Number of units in CP_Group1) - (Number of units in CP_Group2)))
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of units in CP_Group2) Greater than (Number of units in CP_Group1)
        • Then - Actions
          • Set CP_Points2 = (CP_Points2 + ((Number of units in CP_Group2) - (Number of units in CP_Group1)))
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of units in CP_Group2) Equal to (Number of units in CP_Group1)
        • Then - Actions
          • Set CP_Points1 = (CP_Points1 + 1)
          • Set CP_Points2 = (CP_Points2 + 1)
        • Else - Actions
      • Custom script: call DestroyGroup(udg_CP_Group1)
      • Custom script: call DestroyGroup(udg_CP_Group2)
You may be wondering what call DestroyGroup(udg_CP_Group1) is for; it is for removing leaks from creating handles. For more information on leaks, view this tutorial:
Basic Memory Leaks

In the trigger above, it collects all the control points owned by the red player and all the control points owned by the green player, and counts them. Whoever has the most control points gets literal "points" in the game. (for scoring) If they have an equal amount of points, each team will get the same amount of points. You can make the number of control points odd if you want to prevent people from getting ties. (for the most part) It will make people have to go for the last base instead of just holding half the bases.

Be sure there is nothing that kills the control point within one hit. If you do insist on having something like that, make sure that in the first trigger, you add something to check if the unit is dead, and revive it if so. Then you can change the ownership. It is best to have the control points have enough health, that way people will have a chance to defend.​
 

Attachments

  • demon portal.w3x
    90.8 KB · Views: 2,695
Last edited:
Level 7
Joined
Mar 2, 2008
Messages
180
In the first couple of lines in the "CP Points" trigger, you set CP_Group1 twice, instead of setting that, and then CP_Group2.

There should probably be a trigger to deal with the possibility of the control point being killed, as well. It's unlikely, of course, but you can never be too careful. Giving the control point some health regen might be a good idea, too.

Also, it might be good to explain why 5 control points is ideal (just for some extra depth). ie: "With five control points, each team will likely end up with two that are firmly under their control, while the remaining central point will be fiercely contested. As the whole idea of a control point system is to focus the action into certain areas, this is the effect we're striving for."

I think you did a good job with the colour and formatting of the tutorial, and it seems informative and useful. You should probably rename it to something along the lines of "Simple Control Point System", since as there are definitely better ways of doing this, which are a bit more complex. This is definitely a tried and true system, though. :thumbs_up:
 
Level 17
Joined
Jun 17, 2007
Messages
1,433
  • Instead of attacked unit, use triggering unit.
  • Store the unit in a variable, it's far faster than calling GetTriggerUnit() several times.
  • Only supports two forces.
  • There are a few spelling mistakes (whos, experiance), and weird spacing in some cases.
  • This is less a tutorial and more of "here's your code, copy and paste it into your map".
  • Remove your signature.
 
Level 1
Joined
Dec 28, 2015
Messages
2
All right, this might seem like a really dumb question, but is there anyway I can just copy and paste this without finding all the triggers? I am way too inexperienced with advanced triggers and a bit lazy...
 
Unfortunately, he didn't provide a test map so there isn't a way to easily get the triggers into your map. :(

It is really more of a sample than a full system though. If you really want it to work well, you'll have to have a bit of knowledge to tweak it yourself. I recommend checking out our other tutorials first, e.g.:
http://www.hiveworkshop.com/forums/...als-279/complete-concise-gui-tutorial-111863/

It won't be too hard to find the triggers and create a working copy. For example, the actions prefixed as "Unit - " are under the "unit" category for actions. Most of them are labeled that way, except for conditions and if/then/else or loops.
 
Level 1
Joined
Dec 28, 2015
Messages
2
Unfortunately, he didn't provide a test map so there isn't a way to easily get the triggers into your map. :(

It is really more of a sample than a full system though. If you really want it to work well, you'll have to have a bit of knowledge to tweak it yourself. I recommend checking out our other tutorials first, e.g.:
http://www.hiveworkshop.com/forums/...als-279/complete-concise-gui-tutorial-111863/

It won't be too hard to find the triggers and create a working copy. For example, the actions prefixed as "Unit - " are under the "unit" category for actions. Most of them are labeled that way, except for conditions and if/then/else or loops.

Well, I do know most of the triggers, however I do not yet understand the concept of Variables and what not... Also in my map I would want a sorta different Trigger. If Players 1-5 get the Control Point then it goest to Player 6 and if 8-12 get it, it goes to player 7. However the gold bonus goes to all players in a Force.
 
Top