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

Whoop

L1: Registered
Feb 2, 2016
17
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:

Frosty Scales

L2: Junior Member
Mar 22, 2015
93
30
math counter?
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.
 

Whoop

L1: Registered
Feb 2, 2016
17
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.
 

Whoop

L1: Registered
Feb 2, 2016
17
0
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.

That still comes with the same problem of inaccurate point capture count when there are neutral points in plays.
 

theatreTECHIE

Yet another Techie for the net...
aa
Jun 19, 2015
446
457
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.
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.
 

Powerlord

L3: Member
May 8, 2010
127
60
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.

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.
 

Whoop

L1: Registered
Feb 2, 2016
17
0
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.

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.
 

theatreTECHIE

Yet another Techie for the net...
aa
Jun 19, 2015
446
457
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.
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)

For your red_lost_point_a, your output should be:
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

For your red_counter, your outputs should be:
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)

For your red_compare, your outputs should be:
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.