The logic of koth_leveled - How everything works

DrLambda

L69: Teeheehee, Member
aa
Feb 18, 2015
458
475
Although it wasn't exactly requested a lot, i wanted to give a summary of how everything works in koth_leveled. Partially because i'm quite proud of how it works, partially because i think it might help other mappers with both their serious and not-so-serious mapping projects.

Leveled uses quite a bit of custom logic, although with the help of the TF2Maps chat and forum, i was able to keep it down to reasonable levels. The teleportation framework is kinda lightweight, and it becomes quite easy to add additional levels, which is something i'm considering for next year, especially because most players seemed to like guessing which game they are on now quite a lot, and adding more games was the most requested feature during the demos.
yellow.PNG

I don't expect to have done everything in the most optimized fashion and will explain what i would do differently now should i redo the logic again.
I expect you to know the basics of input/output logic. I also won't explain how every entity i'm using works. If you have questions about them, you can either check the Valve Developer Community or ask inside this thread, where i will try to answer each question to my best knowledge.
So, let's get to the meaty stuff, shall we?

How does the timer work?
timer.PNG
As you may already know, the event happens after a set time on the koth clocks. I used the following limits for that:
1. It happens the first time for each team after the team controlled the cap point for 45 seconds combined (not necessarily continuously.)
2. After that, it happens after a team controls the cap point for 1 minute combined (Again, not necessarily continuously.)

At first, i was using two logic_timers. The problem with those is that enabling and disabling them resets the timer, which is something i didn't want to do, because i consider a maximum time of ~2 minutes enough to see everything in every single, kinda small stage, and not having the event happen for longer might make playing in the same area a bit boring (also, because i wasn't able to test the layouts because of developing in secret, having everyone only be there for a short time should make layout weaknesses less obvious.) So, instead of having two logic_timers with 45/60 seconds refire interval, i'm using a 1 second refire interval, triggering a math_counter whenever it fires. This way, the math counter increases by 1 every second, and the logic_timer can be turned on and off at any time.
timer_logictimer_properties.PNGtimer_logictimer_output.PNG

Inside the math_counter, you can get the effect of triggering after 45 seconds the first time and 60 seconds after that simply by setting the initial time to 15.
timer_counter_properties.PNG

When the math_counter hits it's maximum, it resets itself, turns off the koth clocks, locks the point, readjusts the spawn time, disables both logic_timers, and starts the countdown sounds for the resonance cascade.
timer_counter_outputs.PNG

Finally, i just set up the capture point to (aside from the things you have to do for KotH gameplay) enable and disable the respective timers upon capture.
timer_trigger.PNG

What happens during the resonance cascade?
The first thing that happens is the announcer starting the countdown. When the countdown reaches zero, a random level is picked with a logic_case. Then, every player is teleported into the teleport tube of his respective team, which is simply a displacement with a flickering green/black texture (and some stuff in it) and a trigger_push, pushing the floating player at maximum speed into another trigger_teleport, which teleports the player to the real location.
cascade_logic.PNG

The logic_case has a simple setup, simply triggering a logic_relay to "activate" a level, which then completes the logic for each level.
cascade_case_properties.PNGcascade_case_logic.PNG

The relays first trigger a relay which disables all spawnpoints and destroys all buildings with a trigger_hurt. There is seperate logic for each level, mostly because most of the levels actually are instances, but you could simply give the trigger_hurt the same name and trigger them all at once. After 0.1 seconds, the control point is teleported over to it's destination, the spawn points within the new world become enabled, and the teleport location for the players is set. After 0.2 seconds, the player teleporters get activated (and instantly deactivated again,) teleporting everyone alive over into the new world.
cascade_enable_output.PNG
cascade_disable_output.PNG

How does teleporting the capture point work?
There were some educated guesses during the games on April Fools day, but noone got it completely right. I didn't just copy + paste the complete point and activate and deactivate them (which could also cause some wonky capture behaviour and add redundancy,) but i rather parented the three capture point entities (the prop, the CP, the trigger_capture_area) to an info_target placed at the bottom center of the prop. I then added a point_teleport to where i want the capture point to be inside each level and set the entity to teleport to the info_target. When i now trigger the point_teleport, all the entities get moved over.
Note: While this works, it has a small bug - The parenting offset doesn't reset properly upon round restart, but rather sets the offset to where the entities were at round end, which will cause the control point to get out of bounds when teleported, being unreachable by the players. To fix this, i teleport the point back home (with a point_teleport with the "Teleport home" flag) when the round is won by a team. Another solution, which i wasn't able to test because i was running out of time, would be to reparent the entities after round restart.)
point_teleport.PNG

How does teleporting the players work?
As you may know, trigger_teleport requires a remote destination, which to my best knowledge can't be change over input/output. So, what i'm doing here is basically the same as for the capture points. I put two point_teleports into each level, one for each team, set the remote destination to an info_target, then trigger the point_teleports to change the place where the info_target is 0.1 seconds before teleporting the players. To get everyone, there are two trigger_teleports, spanning the entire play area for each map, filtered by team and with the "Clients" flag set, which will upon the resonance cascade activate for 0.1 seconds (during that time, the player is still inside the teleport tube and won't be teleported multiple times.)

How does destruction of buildings work?
This one is pretty easy. For each play area, i have a trigger_hurt with exactly the same dimensions as the trigger_teleports, with the flag set to "Everything" and a filter that excludes players. It starts disabled, then gets enabled for the same timeframe as the teleports. This is exactly the same setup you'd be using to destroy buildings in the path of payload carts.
buildings_properties.PNGbuildings_flags.PNG buildings_filter.PNG

And this is pretty much everything there is to know about the logic of koth_leveled. Should you have any questions or suggestions, feels free to post. I hope i was able to help someone with this and look forward to improving upon the logic for next years April Fools day.