First, download the latest
regen.nut file and place it in your
Team Fortress 2/tf/scripts/vscripts folder. Then create a
logic_script entity somewhere in your map:
- In the logic_script object properties, set "Entity Scripts" to regen.nut (do not use "Manage..." button, it is broken)
- Give the logic_script entity a name (e.g. "regen")
Simple limited regen includes the following functions for you to use in Hammer:
- RocketLimit(amount) - Sets limit of X rocket projectiles (e.g. RocketLimit(7) = limits to 7 rockets)
- ShotgunLimit(amount) - Sets limit of X shotgun/bison shots (e.g. ShotgunLimit (2) = limits to 2 shots)
- PipeLimit(amount) - Sets limit of X pipe projectiles (e.g. PipeLimit (1) = limits to 1 pipe)
- StickyLimit(amount) - Sets limit of X sticky projectiles (e.g. PipeLimit (0) = sticky launcher is purposefully disabled but still equipable)
- LeaveLimit() - Tracks when a player leaves a limit trigger. You must use this function with an OnEndTouch output any time you use one of the limit functions (e.g. RocketLimit, StickyLimit).
- ResetLimit() - Resets the limit state of all weapons equipped by the player, but does not regenerate their ammo in the process.
- ResetTouched() - Like simple limited regen, this function resets the list of triggers that the player has touched, allowing previously touched limit triggers work again. See "Recommended Guidelines" section to understand when you need to use this function.
Using
func_regenerate/
Regen() or
anything that regenerates the player resets weapons back to their normal, pre-limit state. Hence, do not use func_regenerate during a jump that uses limit functions - only use it, for example, at the end of the jump when you want to reset the weapons back to their normal state for subsequent levels. The ResetLimit() function should only be used when you want to reset weapons back to normal but do
not want to regenerate their ammo during the process (see
this part of the demonstration video for func_regenerate resetting a weapon's limit state, and
this part for an example of
ResetLimit() being used).
You can limit ammo to
any amount between 0 and 254. You can intentionally limit a weapon to 0 ammo to disable it.
Recommended Guidelines:Like simple limited regen functions, limit triggers protect against lingering in and out of a trigger by only allowing each trigger to set an ammo limit once per attempt at a level.
ResetTouched() must be called to make limit trigger(s) work again for the level. For the best compatibility with Tempus or any servers using plugins, I recommend the following guidelines:
- For most cases, have a trigger_multiple at the start of your jump that contains limit function(s) and ResetTouched() simultaneously. For any subsequent limit function(s) used in the level, do not use ResetTouched() on those triggers. For Tempus compatibility, you must use this method for the start of bonuses or if you are using limit triggers on the first level of your map. Use the "destroy" option if you want to anti-cheat against using more than the intended projectiles (e.g. pre-placing stickies or telesyncing/prefiring rockets).
- If you want to ensure the player only has their ammo limited once at the start of a jump, and cannot re-enter the start trigger to regain ammo, then I recommend the following:
- For map levels (excluding level 1), have a trigger_multiple with only your desired limit function(s). Call ResetTouched() on the fail trigger_teleport. Keep in mind that while this works fine during map runs, if a player is practicing and teleports back to the start of the level before touching the fail teleport trigger, the limit triggers will not reset. The first method does not have this problem, so consider using that instead (potentially with the "destroy" option).
- If you have any limit triggers that can only be touched once per attempt before being reset, make sure to add a ResetTouched() trigger at the start zone of your map, so that resetting (sm_r on Tempus) will also clear the list of any touched triggers during the previous map run.
"destroy" Limit Trigger Option:Each of the limit functions (RocketLimit, ShotgunLimit, PipeLimit and StickyLimit) has an optional argument "destroy" (e.g. RocketLimit(6, destroy) or StickyLimit(12, destroy)). "destroy" limit triggers do not get added to the player's list of touched triggers. As such, a player will have their ammo limited every time they enter a "destroy" trigger. However, the bigger difference is that it has the following
anti-cheating effects:
- Leaving the limit trigger and re-entering will destroy any active projectiles (e.g. rockets or stickies that have been placed). This prevents rocket telesyncs or pre-placing stickies.
- If the players speed is above a certain threshold when entering the trigger, velocity will be reset. This prevents, for example, building a lot of speed going into the jump to cheese it (e.g. triple pre before entering the trigger).
It's up to you when you want to use this option, but it best suits map levels without connectors (i.e. tele doors), and the start of bonuses/levels where you want to ensure your desired ammo limit isn't easily cheated.
Steps for adding projectile limit functions to triggers:- Create a trigger_multiple brush entity. When using any limit funtions, you
MUST start by adding LeaveLimit() OnEndTouch to prevent potential bugs:
1. Open the trigger_multiple's object properties window
2. Go to the Outputs tab
3. Create an "OnEndTouch" output:
- Target Entity = regen (or whatever you named your logic_script entity)
- Target Input = RunScriptCode
- Parameter = LeaveLimit()
- Now add any desired limit function, e.g.:
1. Stay on the Outputs tab
2. Create an "OnStartTouch" output:
- Target Entity = regen (or whatever you named your logic_script entity)
- Target Input = RunScriptCode
- Parameter = RocketLimit(6)
- Now, for example, you might want to add ResetTouched() to the same trigger, e.g.:
1. Stay on the Outputs tab
2. Create an "OnStartTouch" output:
- Target Entity = regen (or whatever you named your logic_script entity)
- Target Input = RunScriptCode
- Parameter = ResetTouched()