multiple outputs based on conditions

Avatar
lord_blex
96 Posts
Posted Mar 29, 2013
I have all the questions today :razz:
What I want to achieve is: If I press a button and there are at least 4 (yep, 4) players in an area, it should fire a relay, and if there are less, trigger another. How do I do this?
I've been messing around with counters and stuff, but didn't get anywhere... Thanks
Advertisement
Registered users don’t see ads! Register now!
Avatar
CamBen
973 Posts
Posted Mar 29, 2013
Replied 1 hour later
First of all, how would this relate to portal if it needs to detect 4players?
Avatar
srs bsnss
552 Posts
Posted Mar 29, 2013
Replied 48 minutes later
Well, 'trigger_playerteam' and a 'math_counter' (or 'logic_coop_manager') works well for 2 players. But I don't think there's a way to do it with four.
Avatar
FelixGriffin
2,680 Posts
Posted Mar 29, 2013
Replied 5 hours later
OnStartTouch > counter > Add > 1.
OnEndTouch > counter > Subtract > 1.
OnHitMax > do something.
Avatar
lord_blex
96 Posts
Posted Mar 29, 2013
Replied 26 minutes later

CamBen wrote:
First of all, how would this relate to portal if it needs to detect 4players?

Like this

FelixGriffin wrote:
OnStartTouch > counter > Add > 1.
OnEndTouch > counter > Subtract > 1.
OnHitMax > do something.

Yeah, I got this far. What I can't figure out is that after the counter has maxed out, I need to check if the button is pressed. Or the other way around: if the button is pressed, I need to know if there are at least 4 players.
Seriously there isn't a way to decide if a statement is true or false?
I was actually thinking about this yesterday dawn, so I couldn't really think properly, but I was trying to do it with a second counter, but something felt off about it. If there are no other ideas, I guess I'll look at it again.

EDIT: I could do two buttons for both outcomes and enable-disable them using the player counter. How haven't I thought of this before? I guess next time I shouldn't try to do productive stuff after midnight... :razz:

Avatar
srs bsnss
552 Posts
Posted Mar 29, 2013
Replied 30 minutes later

lord_blex wrote:
What I can't figure out is that after the counter has maxed out, I need to check if the button is pressed. Or the other way around: if the button is pressed, I need to know if there are at least 4 players.

That's simply an AND gate.
An AND gate can be done in 3 ways (in Hammer):

Counter Layering
||Counter #1:

OnHitMax > counter_2 > Add > 1
OnChangedFromMax > counter_2 > Subtract > 1

Button

*OnPressed > counter_2 > Add > 1
OnUnPressed > counter_2 > Subtract > 1 *


Counter #2
OnHitMax > do something||

BRANCH MONITORING
||Using the logic_branch and logic_branch_listener entities,
Counter #1:

OnHitMax > branch_1> SetValue> 1
OnChangedFromMax > branch_1 > SetValue > 0

Button

OnPressed > branch_2 > SetValue > 1
OnUnPressed > branch_2 > SetValue > 0


Logic Branch Monitor
Logic Branch 01: branch_1
Logic Branch 02: branch_2

OnAllTrue > Do something
OnMixed/AllFalse > Don't do something||

COOP MANAGING
||Using the coop_manager entity,
Counter #1:

OnHitMax > coop_manager> SetStateATrue
OnChangedFromMax > coop_manager > SetStateAFalse

Button

OnPressed > coop_manager > SetStateBTrue
OnUnPressed > coop_manager > SetStateBFalse


Coop Manager

OnAllTrue > Do something
OnMixed/AllFalse > Don't do something||

Those all work for what (it seems) you're trying to do.

EDIT: You can also look at this diagram

|
|
V

Images 1
Post image 1
Avatar
lord_blex
96 Posts
Posted Mar 29, 2013
Replied 1 hour later
Thank you, this seems helpful :smile:
I still have one problem though. I just realized, that the counter caps at the max value, right? So if the value is already 4, it can't go up one more. Which is all fine, if you play the map in ideal circumstances. But if let's say there are 5 players total in the map and they all enter the trigger, the counter caps at 4. Then one player exits and it will say 3, but there are still 4 players there..
I'm just making this more and more complicated :razz:
Avatar
srs bsnss
552 Posts
Posted Mar 29, 2013
Replied 24 minutes later
Hmm...well, I think there's 2 ways:

1. Simply make the Max Value 5. Of course, this assumes there's SUPPOSED to be 5 players in the trigger. If there's meant to be one on a button or something, then this wouldn't work.

2. Maybe these settings on the button?

*OnPressed > Counter > SetMaxValue > 4 > Delay 0.1
OnUnPressed > Counter > SetMaxValue> (something unattainable, e.g. 10) *

Theoretically, changing the MaxValue with the button means it won't fire the output until it has the correct conditions.

Avatar
lord_blex
96 Posts
Posted Mar 29, 2013
Replied 2 hours later
Thanks, I could only test it alone (2 player splitscreen) but it seems to be working fine.
I also did an "else-thingy" (a relay which activates if you press the button and there aren't enough players in the area) with another counter, it seems to be working as well. I almost started asking about it, but as I started to write the question, I figured out how to do it.

On a sort of related note: How do I get game_text work properly in multiplayer? It only shows up for one player, even if I set the all players flag. (still on splitscreen, but I assume it's no different in actual online multiplayer)Or should I use another entity?

Avatar
srs bsnss
552 Posts
Posted Mar 30, 2013
Replied 11 hours later
Maybe try 'env_message'? Though the game_text can be a bit deceptive in split-screen because it will only show for the primary player, which means it may actually be working.

EDIT: Nevermind, env_message doesn't work (as far as I know).

Avatar
Lpfreaky90
2,842 Posts
Posted Mar 30, 2013
Replied 6 hours later

lord_blex wrote:
On a sort of related note: How do I get game_text work properly in multiplayer? It only shows up for one player, even if I set the all players flag. (still on splitscreen, but I assume it's no different in actual online multiplayer)Or should I use another entity?

Game_text work for the entire screen; not per player; so as long as you have the all players flag checked it shows up for all players. On splitscreen however the texts are overlapping thus you'll only see one.

As for the cases; I would go for a combination of a trigger_multiple, math_counter, a logic_case and a coop_manager:

A trigger multiple:
OnStartTouch; math_counter; add; 1
OnEndTouch; math_counter; subtract; 1

A math_counter:
Outvalue; logic_case; Invalue

logic_case:
set the value "3" for case01
set the value "4" for case02
OnCase01; coop_manager; setstateafalse
oncase02; coop_manager; setstateatrue

button
onpressed; coop_manager; setstatebtrue
onbuttonreset; coop_manager; setstatebfalse

coop_manager:
onchangetoalltrue (DO STUFF)
onchangetoanyfalse (STOP DOING STUFF)

Hope that helps :wink:

Avatar
lord_blex
96 Posts
Posted Mar 30, 2013
Replied 1 hour later
Thanks, the logic_case was something I was looking for. It was really annoying messing around with the min and max values of the counters if I wanted a proper output..
But I have something working now, so I don't really wanna mess it up. Unless it proves to be non-functioning - then I will get back to this :razz:
Avatar
srs bsnss
552 Posts
Posted Mar 30, 2013
Replied 56 minutes later

Lpfreaky90 wrote:
I would go for...a logic_case

Of course! Why didn't I think of that >.<

Avatar
DaMaGepy
361 Posts
Posted Apr 06, 2013
Replied 6 days later
Ah I just found this topic, I see its already been solved, but the easiest way to do the 4 player in the area and a button is pressed is just make the counter max at 5, and also add a, add/substract for the button. So it only activates if all player is in the area (4) aplus the button is pressed. Thats when its 5. if its pressed but less than 4 is in the area, it will never be 5.
math_counter is the new ducttape :smile:
Advertisement
Registered users don’t see ads! Register now!
Avatar
FelixGriffin
2,680 Posts
Posted Apr 06, 2013
Replied 10 hours later
Before the PTI came out and I learned what math_counters could be used for I always had long chains of relays being enabled and disabled, with a timer constantly trying to fire a signal through the chain. If the element being activated didn't receive a signal every second one of the relays had deactivated and the element shut off. Ugh. :razz: