Quick Logic_Case question

Discussion in 'Mapping Questions & Discussion' started by 【EmNudge】, Oct 11, 2016.

  1. 【EmNudge】

    【EmNudge】 L4: Comfortable Member

    Messages:
    179
    Positive Ratings:
    35
    I've got a whole ton of relays, triggers, counters, and buttons set up in this one area.
    I'm not too familiar with setting up Logic_case's though.

    a basic layout of what I'm dealing with:
    there are 4 buttons on each side of a room with a divider in middle. One player on one team gets teleported into one room, while another player from the opposing team teleports into the other half of the room.
    As it's currently set up, once a player hits a button, a light shines on it and all 4 buttons are locked.
    If the other player does not hit a button within 10 seconds, he gets teleported to a certain area.
    diagram of what currently exists:
    [​IMG]
    here's what I'd like to do:
    I'd like for it to be that once a player hits one of the 4 buttons, the corresponding trigger_teleport is "prepped" to be enabled once the other player hits a button or once it has passed 10 seconds from when the player hit the button.
    [​IMG]

    I could probably do this using around 10 more entities, but I'd rather not and use a logic_case instead.
    I don't completely know how this would work and asking here would get me an answer much faster than by testing it, so here I am.
     
  2. worMatty

    aa worMatty Repacking Evangelist

    Messages:
    1,071
    Positive Ratings:
    832
    logic_case won't help you, here. You use logic_case when you have a single input (one button) and want to select a random output from a range (many teleporters). Or, you use logic_case to fire a certain output based on the value of a math_counter.

    To reduce it somewhat, it sounds like you want a teleporter to be enabled ten seconds after one button is pressed, but enabled immediately if the second button is pressed, removing the delay.

    Presuming your first button has an output to enable the trigger_teleport with a delay of ten seconds, you can use a logic_branch to immediately enable the teleporter when the other button is pressed.

    Both buttons:
    OnPressed > Enable teleporter in ten seconds
    OnPressed > Test the logic_branch
    OnPressed > Set the value of the logic_branch to True (1) with a delay of 0.1 seconds.

    logic_branch
    Test > If true, enable the teleporter.

    This starts the countdown to the teleporter being enabled, checks the logic_branch to see if it's already been set to True by the other button and if so, enables the teleporter immediately. If it's set to false nothing will happen, but the button will set it to True 0.1 seconds later so that when the other button is pressed, its test will pass. If both players hit the button within 0.1 seconds of each other, the teleporter wouldn't be enabled immediately, but that's unlikely to happen.

    Advanced Method
    This method eliminates any possibility of the trigger not being enabled immediately and doesn't need any extra entities.

    Give each button an output that adds an output to the other button to enable the teleporter immediately when pressed, using AddOutput. When the other button is pressed, it will then enable the trigger immediately, thanks to the new output that was added to it.

    Both buttons:
    OnPressed > Other button > AddOutput > OnPressed, enable the teleporter

    It would look something like this:
    [​IMG]
    Breaking it down:

    OnPressed teleporter:Enable:0:0:1
    1. OnPressed is the other button's new output type.
    2. teleporter is the name of the trigger.
    3. Enable is the input to the trigger.
    4. 0 is the parameter override, which is unneeded for this operation.
    5. 0 is the delay in seconds before the input is sent to the trigger.
    6. 1 is the number of times the output can be fired (equivalent to Fire once only).
     
    • Thanks Thanks x 2
  3. 【EmNudge】

    【EmNudge】 L4: Comfortable Member

    Messages:
    179
    Positive Ratings:
    35
    I really like the advanced method, so I think I'll go with that one, many thanks!

    Another question:
    In this situation, I'd have 2 sets of 4 teleport triggers stacked on top of each other. It's a bit messy and makes selecting a certain one a tad difficult. This situation may be better by adding another AddOutput, one that sets the players origin.

    So, would this work:
    Code:
    OnPressed>other_button>AddOutput>OnPressed !activator:AddOutput:origin 5462 -4052 2816:0:1
    
    Furthermore, I need both buttons to teleport the players at the same time. I.E. if player2 hits his button within the 10 seconds from when player1 hits his button, both are teleported to the locations that they set.
    Therefore I'd need other_button to enable the teleport trigger that player1 set to be enabled when he hits his button. I'd also like the same to happen if player2 hit his button before player1.

    You may have already answered that question, but just by looking at what you showed me, it only seems to work one way.

    EDIT: I figured out a way and a problem with what I said.
    will update once I get it working
     
    Last edited: Oct 11, 2016
  4. worMatty

    aa worMatty Repacking Evangelist

    Messages:
    1,071
    Positive Ratings:
    832
    I'm not sure you can teleport a player by using AddOutput to set their origin.

    You can use the Page Up and Page Down keys to switch between overlaid brush volumes in Hammer.

    If only one player is to be teleported per side, you could switch to using point_teleport entities for your destinations, and then just use one trigger_multiple per side, sending the trigger its destination via AddOutput from each button. That would reduce the number of entities quite a bit. I use a system like this to teleport all the players in a deathrun map to a minigame or arena, and use a logic_case to distribute them to different 'spawn points'.
     
  5. 【EmNudge】

    【EmNudge】 L4: Comfortable Member

    Messages:
    179
    Positive Ratings:
    35
    Of course you can, I've been using it for the past 2 years. I originally got it from here

    It also allows me to teleport a player without having to have them within a trigger brush. They hit a button and BAM, they're teleported.

    I also tested it within this context and it works just fine.

    My main problem wasn't teleporting one player or the other, it was teleporting them both to 2 separate locations (based on which button they hit) on a timer and cancel that timer if the other button is hit within the time. It was then supposed to teleport both players. The bigger struggle was somehow storing a teleportation string so that it could be activated when another button was hit.
    I was to use a math_counter in conjunction with a logic_case by setting the counter a certain number based on what button one player hit.
    That number corresponds to a case that teleports the player which would be activated by the 2nd button.


    I've decided to change it so that the players must wait 10 seconds from when player1 hits the button, no matter what. This solves a couple of problems, but creates one more. Since this room will be used many times I need a way to delete an output. Your suggestion of "Fire Once" solves the problem for the button that is being used, but for the buttons that are not being used, they will auto-teleport the player for the next person that hits them.


    So, is there a way to delete an output?
     
    Last edited: Oct 12, 2016
  6. killohurtz

    aa killohurtz Distinction in Applied Carving

    Messages:
    998
    Positive Ratings:
    1,135
    You can forward the output through a logic_relay and disable the relay when you want to "delete" the output.
     
  7. 【EmNudge】

    【EmNudge】 L4: Comfortable Member

    Messages:
    179
    Positive Ratings:
    35
    obviously, but I'm trying to use as little entities as possible. That would add 8 entities, one for each button.
    If I was fine with adding 8 entities, I could solve this problem and many more.
     
  8. killohurtz

    aa killohurtz Distinction in Applied Carving

    Messages:
    998
    Positive Ratings:
    1,135
    If I'm understanding your setup right, you want to disable all 8 buttons at the same time, correct? Then you can bundle them all in 2 logic_relays and use the oft-overlooked user I/O to preserve each button's target teleporter. For example:

    (button) OnDamaged | relay | FireUser1 --> (relay) OnUser1 | teleporter1 | Enable
     
  9. 【EmNudge】

    【EmNudge】 L4: Comfortable Member

    Messages:
    179
    Positive Ratings:
    35
    You may want to give my several walls of text a re-read. It may be that I'm not understanding you correctly, but what I'm trying to do is delete an output that teleports a player.
    I'll give you screenshots of my test map in hammer:
    [​IMG][​IMG]
    I have a logic_relay on each side for organization. No point in having 20 extra outputs on each button when I can have them all just trigger a singular logic_relay.
    I also have 2 math counters and 2 logic_relays per math_counter. The third math_counter can be removed, but I'm keeping it there for later.

    That's why I want to use a few entities.

    Locking the buttons is easy, I have the logic_relays lock all the buttons, turn off lights, turn off point_spotlights, disable brushes, and play sounds.

    I'm just not too familiar with the extent of each logic type and the valve wiki for hammer gives a very brief description.
    I want to be able to "store" a teleport location, a string of letters and numbers, that can be triggered later on.
    Adding outputs is the best way to go about it, but there will be unused outputs on the other buttons which will teleport the next player to hit them.

    I need the buttons to reset, just as everything else does, handled by one of my math_counters and its 2 logic_relays


    EDIT: although you didn't directly address my question, user I/O may be what I need, I just have to read a bit more about it to get a better handle on how to use it
    (also, from what I'm told, it's better to check "Damage Activates" and use OnPressed instead)
     
  10. worMatty

    aa worMatty Repacking Evangelist

    Messages:
    1,071
    Positive Ratings:
    832
    I didn't know this. Thanks, this is very useful.