L2: Junior Member
- Dec 27, 2018
Hello, is it somehow possible to make 2 ways for the payload in Hammer and make the main path change every game?
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.
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.
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.