# How to make a reliable AND gate to detect multiple control points captured?

Discussion in 'Mapping Questions & Discussion' started by Whoop, Oct 20, 2016.

1. ### WhoopL1: Registered

Messages:
17
Positive Ratings:
0
Basically I'm working on a 3 point king of the hill type map and I want to make it so than when 2 points are captured by either team it enables forward spawns for their respective sides. Problem is, I cant make a reliable way to detect when the control point's are captured to save my life. The fact that all points start neutral and then are capped back and forth by each team really seems to present a problem when it comes to activation logic.

I've tried using loigc_branch and logic_branch_listener, but they seem to be extremely buggy and only work half the time even when set up seemingly correctly?

Does anyone have any solutions that could help solve my problem? Anything at all would help. This has had me stumped for 3 days. Maybe I'm over thinking it?

Last edited: Oct 20, 2016
2. ### aaSergisL666: ])oo]v[

Messages:
1,871
Positive Ratings:
1,245
math counter?

3. ### aaFrosty Scales

Messages:
85
Positive Ratings:
34
One math_counter for each team, and have it so that if say, red team caps a point, it adds 1 to red's math_counter and subtracts 1 from blu's math_counter. Then set up the outputs so that when red's math_counter hits 2, it disables blu's forward spawns and enables red's own forward spawns.

• Agree x 1
4. ### WhoopL1: Registered

Messages:
17
Positive Ratings:
0
I've tried some mouth counter solutions, but adding and subtracting always creates problems. If a point is neutral and then capped by an enemy, you can end up with negative numbers, or if you already have 1 control point captured and then the enemy caps, you can basically get your already already captured point subtracted by the other team capturing a separate control point.

5. ### WhoopL1: Registered

Messages:
17
Positive Ratings:
0
That still comes with the same problem of inaccurate point capture count when there are neutral points in plays.

6. ### aatheatreTECHIEYet another Techie for the net...

Messages:
396
Positive Ratings:
417
You can set up two math_counter entities which send their values to logic_compare entities, which can compare it to 2. Then have the greater than and equal outputs to enable the forward spawn and disable the original spawn, and the less than output disables the forward spawn and enables the original spawn.

7. ### PowerlordL3: Member

Messages:
124
Positive Ratings:
59
Did you set "Minimum Legal Value" to 0?

Mind you, if you set "Minimum Legal Value" to 0, you also have to set "Maximum Legal Value" to something other than 0 or it will just ignore them.

• Agree x 2
8. ### WhoopL1: Registered

Messages:
17
Positive Ratings:
0
Do you think you can explain this a little more in depth? I'm attempting to implement this in game and I'm getting extremely lost :/
From what I'm seeing it still has the problem with having to add and subtract.

9. ### aatheatreTECHIEYet another Techie for the net...

Messages:
396
Positive Ratings:
417
As a starting note, I just want to ask why you couldn't just use respawn times to balance out the game depending on how many capture points each team has? This makes logic simpler, since you just need the AddRedTeamRespawnWaveTime and AddBlueTeamRespawnWaveTime inputs into the tf_gamerules entity to do this, and these inputs can take negative numbers, so can be used to reduce a team's respawn time as well.
Also doing it with respawn times means that engineers don't need to constantly make new teleport entrances, as their team's spawn isn't changing.

Anyway, onto the logic setup:

I'm going to walk you through the setup for all the logic for red's counter, and once you've set all of this up, you'll need to copy
Take this step by step, as there's a few things that you will need.

The Entities

To start off with, set up a math_counter. (Let's call this red_counter) Don't worry about setting max or min values for either of these.

You will also need a logic_compare entity. (Let's call this red_compare) The initial value should be 0, and the compare value should be 2.

For each control point, you will need a logic_relay (let's call this red_lost_point_a for capture point A), which is to start disabled (set in the class info). This relay will be triggered when red loses the capture point.

The Logic

Now to set inputs and outputs for all of these.
For your trigger_capture_area for point A, the outputs should be as follows:
My output named Target entities named Via this input With a parameter override of After a delay in seconds of Fire only once
OnCapTeam1 red_counter Add 1 0 No
OnCapTeam2 red_lost_point_a Trigger - 0 No
OnCapTeam1 red_lost_point_a Enable - 1 Yes
Make sure that for each point, the a's are replaced with the corresponding letter (e.g. for point B, replace blu_lost_point_a with blu_lost_point_b). Also make special note of which outputs are OnCapTeam1 and which ones are OnCapTeam2. (Team 1 is RED and Team 2 is BLU)

My output named Target entities named Via this input With a parameter override of After a delay in seconds of Fire only once
OnTrigger red_counter Subtract 1 0 No

My output named Target entities named Via this input With a parameter override of After a delay in seconds of Fire only once
OutValue red_compare SetValue - 0 No
OutValue red_compare Compare - 0.1 No
Make sure that you have the delay for the compare, otherwise unexpected results can happen (with the comparison happening with the previous value of the counter)

My output named Target entities named Via this input With a parameter override of After a delay in seconds of Fire only once
OnEqualTo [Red forward spawn entities] Enable - 0 No
OnEqualTo [Red main spawn entities] Disable - 0.1 No
OnLessThan [Red main spawn entities] Enable - 0 No
OnLessThan [Red forward spawn entities] Disable - 0.1 No
(Note: I usually like having a bit of an overlap for enabling and disabling spawn points to ensure that people will always spawn at one of their team's spawn points, rather than source stuffing up and spawning teams at opposing spawns. Not really needed, but it's what I do. Players don't tend to notice it anyway)

Once all of that is set up, make sure that you do all of blu's logic, test it out and ask again if there's any problems.

• Thanks x 1
• Like x 1
10. ### TunasL3: Member

Messages:
112
Positive Ratings:
28