HL2 Puzzle Entity Logic Help aaaaaarhgh

Nov 2, 2010
355
1,048
bonjour

I tried to ask about this in the chat but it got swamped by people talking about the contest. I doubt anyone will have any clue about this but here goes.

I'm making a HL2 puzzle which looks like this:

8619803343.jpg


There's two doors which are closed by default. The player has to get to the other side of these doors. They have to use a crate and a two-plug cable which looks like this:

887aded46b.jpg


There are three sockets and you can connect the cable's plugs into any of them.

564b3c5645.jpg


What I'm having trouble with is setting it up so that combinations of different sockets has different outputs. For example, if the player connects the left socket and the power socket on the other side, the left door will open. If the player connects the right socket and the power socket, the right door will open. What the player has to do is open the first door, block it with the crate and then open the other door to ensure both doors are open at the same time. Sounds simple right?

Here's what it would look like ingame when solved, with the far door connected to be open and the closest door blocked with the crate:

3a757a6c5e.jpg


My initial assumption was to use math_counters to determine which sockets had a plug in them and which didn't. These are the outputs of a trigger_multiple in a socket which detects if an end of the cable is in. (There are two in each socket, one to detect either end of the cable).

4d348b59a0.png


When a plug is connected to the socket, it adds a unique number to the math_counters and subtracts the same number when removed. One socket adds/subtracts 3, the second adds/subtracts 5 and the last one adds/subtracts 7. By reading the sum of the numbers, you can tell which sockets are connected.

Doorcombocounter10 is a math_counter which checks if the left socket (3) and the power socket (7) are connected because it reaches its max legal value (10) and sends and output to open the left door.

Doorcombocounter12 is a math_counter which checks if the left socket (5) and the power socket (7) are connected because it reaches its max legal value (12) and sends and output to open the right door.

So what am I doing wrong? When I connect the plugs ingame, nothing happens. The doors don't move at all. Also I have no idea how to make it so you can take a plug out of a socket again. Also one end of the plugs floats away from the cable rather than anchoring to it for some reason. I textured them red ingame in the download so you can see them if they drift off or something.

If anyone thinks they can help me with this then I'd be very grateful. Here's a dropbox link to the VMF and the BSP if you think you can get it to work:

https://www.dropbox.com/s/pfyfcc7kads206m/corvas plug puzzle.rar?dl=0

pls
 

YM

LVL100 YM
aa
Dec 5, 2007
7,135
6,056
power socket has a relay that enables/disables a pair of relays for each of the left/right sockets. It enables all four of these relays when a plug is in the power socket and disables them all when it's removed.

those pair of relays break down into:
Left on
Left off
Right on
Right off


The left/right on relays open the door, and are triggered when the plug is in the left/right socket.
The left/right off relays close the door, and are triggered when the plug is removed from the left/right socket.

These on/off relays are -only- active while the power is connected, so connecting left to right will do nothing.

If I have done a terrible job of explaining this, let me know and I'll retry.
 

wiseguy149

Emperor of Entities and Amateur of Aesthetics
May 12, 2009
103
220
Rather than a counter, I'd suggest using a logic_branch for each socket and a logic_branch_listener to determine connections between them.

So for each of the three sockets, create a logic_branch, and make the OnStartTouch output of the trigger set the branch to True and the OnEndTouch set it to False.
Then, for each configuration that you want to trigger an action, make a logic_branch_listener and have it listen to the two relevant branches. So you'd want one listener for the left & power sockets, and one for the right & power sockets. Then add an OnAllTrue output to open the relevant door and OnAllFalse output to close it.

This should be a more intuitive logic system and should be easier for you to debug and pinpoint the problem.
If you're not using the developer console command to show entity I/O in the console, you should be.


I've never used the plugs and wires in HL2 mapping myself so I'm not really sure if you've done the rest of the entity setup correctly. I'd strongly suggest decompiling a VALVe HL2 map that uses these plugs to take a look and see how they're done if you haven't already.
 

wiseguy149

Emperor of Entities and Amateur of Aesthetics
May 12, 2009
103
220
power socket has a relay that enables/disables a pair of relays for each of the left/right sockets. It enables all four of these relays when a plug is in the power socket and disables them all when it's removed.

those pair of relays break down into:
Left on
Left off
Right on
Right off


The left/right on relays open the door, and are triggered when the plug is in the left/right socket.
The left/right off relays close the door, and are triggered when the plug is removed from the left/right socket.

These on/off relays are -only- active while the power is connected, so connecting left to right will do nothing.

If I have done a terrible job of explaining this, let me know and I'll retry.

This wouldn't work if you connected the left or right socket before the power socket.
 

wiseguy149

Emperor of Entities and Amateur of Aesthetics
May 12, 2009
103
220
I don't have HL2 installed or the sdk configured so I'll test this in-game later when I have the time but just taking a quick look at your vmf there's one thing I straight up don't understand.
You disable the triggers when they're first touched, and never re-enable them, so you've only got one shot at each socket. This also means that the OnEndTouch outputs will never be called. I don't understand the purpose of disabling these triggers.


Anyway, you've said that the doors aren't opening, but there are a lot of entities and commands between the plug and the doors and your problem could be anywhere in-between.

Use "developer 2" to take a look at the entity I/O in the console, test out your plugs, and see what happens.
Are your triggers detecting the plugs? Are your branches updating? Are your listeners firing? Are your doors being called at all?

When it comes to debugging entities, it's really important to figure out exactly how much of your setup is working and how much isn't.
 
Last edited:

happs

L1: Registered
Nov 6, 2014
5
3
I tried using three logic_branches; one for each socket, and two logic_branch_listeners; one for each door. I thought I set it up correctly but I've clearly done something wrong.

https://www.dropbox.com/s/psbex7pvab5do6l/automatic_door.vmf?dl=0

Turn on some development tools:

PHP:
developer 2
ent_messages_draw 1
ent_text openrightdoor
ent_text openleftdoor

Is your logic_branch_listener - openrightdoor / openleftdoor firing its OnAllTrue Output?

What about the logic_branch - connectleft / connectright / connectpower SetValueTest Output?
 
Nov 2, 2010
355
1,048
The cables were messing up and being a pain so I just replaced them with two buttons.

The reason the logic_branches weren't working is cos you have to trigger them with an Input callled ToggleTest, not just Toggle. Splendid.

The doors now work perfectly with the buttons shutting each other and everything but there are problems when you try to block the door.

b63aaf150d.jpg


When the func_doors try to close with a prop_physics in the way, they do that rattling thing where dust comes out and the prop shakes and makes noise. If you nudge it or whatever it just crushes you or the box will go flying.

Is there a way to make the doors stop cleanly on the box? I tried playing with the box's mass but that didn't do anything. The func_doors have outputs called OnBlockedClosing and OnBlockedOpening but I can't seem to get them to do anything. I used Developer 2 mode and even when the crate clearly blocks them they don't trigger.

Cheers for your help so far, guys.
 

happs

L1: Registered
Nov 6, 2014
5
3
I'm not entirely sure, but you might need a connection for an output to displayed in developer 2. You can create a temporary logic_relay and call the Trigger input from the OnBlockedClosing output.


Looking at the flags at https://developer.valvesoftware.com/wiki/Func_door I see that I would also try the passable flag.

You could attach a trigger_multiple to the door with parenting and OnStartTouch call kill on the !activator entity. Ensure that the flags of the trigger allow for objects to trigger it.
 
Last edited:
Nov 2, 2010
355
1,048
Okay, it works now.


I parented triggers to the edges of the doors to detect if a crate is there and, if there is one, the doors won't close. I added some sparks too to make it a bit more obvious. Cheers to Jim Partridge for coming up with that solution.

All that effort for such a tiny puzzle!
 
Last edited by a moderator: