HL2 Puzzle Entity Logic Help aaaaaarhgh

Discussion in 'Mapping Questions & Discussion' started by Corvatile, Aug 3, 2015.

1. aaCorvatileeyes open at all times

Messages:
354
Positive Ratings:
960
bonjour

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

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:

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

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:

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).

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:

pls

2. aaYMLVL100 YM

Messages:
7,099
Positive Ratings:
5,920
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.

• Thanks x 1
3. wiseguy149Emperor of Entities and Amateur of Aesthetics

Messages:
103
Positive Ratings:
160
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.

• Thanks x 1
4. wiseguy149Emperor of Entities and Amateur of Aesthetics

Messages:
103
Positive Ratings:
160
This wouldn't work if you connected the left or right socket before the power socket.

• Thanks x 2
5. aaCorvatileeyes open at all times

Messages:
354
Positive Ratings:
960
6. wiseguy149Emperor of Entities and Amateur of Aesthetics

Messages:
103
Positive Ratings:
160
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.

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.

• Thanks x 1
Last edited: Aug 3, 2015
7. happsL1: Registered

Messages:
5
Positive Ratings:
3
Turn on some development tools:

PHP:
``` developer 2ent_messages_draw 1ent_text openrightdoorent_text openleftdoor ```
Is your logic_branch_listener - openrightdoor / openleftdoor firing its OnAllTrue Output?

What about the logic_branch - connectleft / connectright / connectpower SetValueTest Output?

• Thanks x 1
8. aaCorvatileeyes open at all times

Messages:
354
Positive Ratings:
960
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.

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.

9. happsL1: Registered

Messages:
5
Positive Ratings:
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.

• Thanks x 1
Last edited: Aug 4, 2015
10. aaCorvatileeyes open at all times

Messages:
354
Positive Ratings:
960
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!

• Thanks x 1
Last edited by a moderator: Aug 29, 2015