Changing ways in Hammer?

Discussion in 'Mapping Questions & Discussion' started by fbi.bmw.ultra.car, Apr 19, 2019.

  1. fbi.bmw.ultra.car

    fbi.bmw.ultra.car L2: Junior Member

    Messages:
    54
    Positive Ratings:
    2
    Hello, is it somehow possible to make 2 ways for the payload in Hammer and make the main path change every game?
     
  2. Da Spud Lord

    aa Da Spud Lord L0: Crappy Member

    Messages:
    1,027
    Positive Ratings:
    698
    In TF2, there is no way for a map to carry over data between different rounds, as the map, as well as all entities within, are reset upon a round restart, meaning there would be no way for your map to remember what route was used last round and what route should be used this round. You might be able to do some finessing with multi-stage logic: Have two stages taking place on the same part of the map, but change the payload's path based on which stage is being played. Otherwise, I don't think what you want is possible.
     
  3. henke37

    aa henke37

    Messages:
    1,999
    Positive Ratings:
    480
    There is a whitelist of entities that are not reset. Don't recall what's on it or where to find it tho.
     
  4. worMatty

    aa worMatty Repacking Evangelist

    Messages:
    1,080
    Positive Ratings:
    846
    Yes, it's possible.

    Use a couple of env_global entities to control which path gets selected each round.

    env_global stores a server-side custom global variable which is read every round and used to control whether the outputs of a connected logic_auto will fire. Using env_global you can ensure that each path is played in turn rather than chosen randomly.

    env_globals have two possible values: true or false, or 'on' and 'off'. Turning it on prior to the beginning of a new round will make any logic_auto associated with it fire its outputs when the round starts. Turning it off will prevent the outputs from firing. env_global only needs four properties to be set - its targetname, global state, initial state and the spawnflag that sets that initial state. The targetname is the name you use to send it the inputs to turn it on or off. The global 'state' is the name of the custom variable and can be whatever you like. Make it something unique so it won't interfere with any other maps using the same entity. I like to prefix the map name. For example: pl_mymap_path1, and path2. The initial state is whether the entity should be turned on or off the first time the map is run. That will control whether path 1 or 2 is played first. Enable the only spawnflag.

    Now make two logic_auto and give them the same global states as your two env_global. Give them the outputs that enable their associated path. Additionally, give each of them an output that turns on the opposite env_global and disables its own. The system will work this way:

    The env_global for path 1 is turned on. Its logic_auto will set the payload cart to use path 1. It will turn off the path 1 env_global and turn on the env_global for path 2.

    Next round:

    The env_global for path 2 is turned on. Its logic_auto will set the payload cart to use path 2. It will turn off the path 2 env_global, and turn on the env_global for path 1.

    Repeat.​

    You can probably reduce the number of entities needed to one env_global and logic_auto each if you know what you're doing, but if you aren't running out of edicts or entities it doesn't matter.

    Since the state is a global one, it will be saved across map sessions in the same server session. That means if the last path to be played before the map ends is path 1, then the next time the map is played in the same server session (the server hasn't restarted since then), it will begin with path 2 (excluding the 'waiting for players' time before a round starts, which counts as a round for anything fired from a logic_auto).

    env_global doesn't appear in the default TF2 FGD so you won't be able to place it in Hammer without adding the base Half-Life 2 FGD in the settings, or an alternative replacement FGD such as ABS's mapping pack or ficool2's FGD.

    Any questions?
     
    • Thanks Thanks x 1
  5. fbi.bmw.ultra.car

    fbi.bmw.ultra.car L2: Junior Member

    Messages:
    54
    Positive Ratings:
    2
    Woah im still pretty new in Hammer, but it makes sense to me. Also if I get it right, you said that the path will change after the "restart" of the map and not after a round finishes?
     
  6. worMatty

    aa worMatty Repacking Evangelist

    Messages:
    1,080
    Positive Ratings:
    846
    Yes. Since logic_auto only fires at the very beginning of a round, the path will changed then, and not at the end of a round. You can enable or disable env_globals as many times as you like during a round, they will not have any immediate effect. Their state is only taken into account at the start of the round when TF2 resets all the entities and checks if it's OK to fire the logic_autos.