jump.tf Forums
Welcome B)

[VScript] regen.nut: Better Ammo Regen (limited regen + more!)

Kingstripes

  • Newbie
  • *
    • Posts: 6
    • Frags: +0/-0
    • View Profile
regen.nut: Better Ammo Regen

regen.nut is VScript to help with ammo regeneration, particularly limited regen jumps.
The script is broken into 3 parts, which are all shown in the following demonstration video:



1. Simple Limited Regen
In existing limited regen jumps, func_regenerate triggers operate on a 3 second, per-player cycle (m_flNextRegenerateTime). On jumps such as jump_soar level 16, it's possible to wallshot too fast and miss being regenerated if you were regenerated less than 3 seconds ago. Furthermore, you sometimes have to wait around at the start of a level to have full ammo if you were regenerated slightly before failing.

Simple limited regen provides a better alternative to func_regenerate for limited regen jumps:
  • Instantly regenerates the player upon touching a simple regen trigger (e.g. at any point during the level or immediately after failing), with no 3 second timer
  • Unlike func_regenerate, you can prevent lingering indefinitely inside a trigger for unlimited ammo because simple regen triggers only regenerate each player once per attempt at a level (by default)
  • Unlike func_regenerate, simple regen triggers can be filtered by class either with a filter_activator_class entity or by supplying an optional class type when calling the main simple regen function (see Usage section)

Usage:
Spoiler (click to show/hide)



2. Projectile Limit Regen
Inspired by Momentum Mod's (proposed) system for dealing with limited regen, projectile limit regen allows you to give the player X number of projectiles to complete a jump, for any soldier or demoman primary/secondary weapon. In this limited state, reloading is blocked and once reaching 0 clip ammo, the weapon turns translucent and becomes unusable until more ammo is given or the weapon is reset. All rocket launchers are supported, including the Cow Mangler and Beggar's Bazooka (both in its unmodified form, and when it is modified to function like stock). You can also limit shotgun/Righteous Bison ammo. All demoman sticky launchers are supported as well as primary grenade launchers.

Projectile limit regen offers:
  • Opportunity for novel jump ideas (e.g. creating levels/bonuses that require careful resourcefulness of a specific amount of ammo, fine control when forcing a jump to be completed in a maximum number of rockets, etc.)
  • Ability to create a 1:1 experience with a Momentum Mod map port for limited regen jumps
  • Optional, built-in anti-cheat to prevent a jump being completed in more than the specified limit amount (i.e. with "destroy" triggers: see Usage section)

Usage:
Spoiler (click to show/hide)



3. func_regenerate Re-implementation
A VScript re-implementation of a func_regenerate trigger, made by ficool2 with some modifications.

Typical func_regenerate triggers cannot be filtered by class (or any other filter entity). Since this func_regenerate re-implementation runs on trigger_multiple triggers instead, filtering is supported. Furthermore, for added convenience, you can filter regen by supplying an optional class type when calling the main FuncRegen function. This would allow you to, for example, cover the entire map in a trigger_multiple for unlimited demoman regen, but have limited regen for soldier jumps in your map. Prior to VScript, doing something like that was not possible and only achievable with plugins (e.g. +regen on Tempus).

Usage:
Spoiler (click to show/hide)



Miscellaneous: Useful Functions

These are standalone versions of functions that are used within the script that you may find useful. They include:
  • DestroySoldierProjectiles() - Destroys all soldier projectiles. This function is used by "destroy" limit triggers but you may find it useful outside of that context. E.g. use on your level's fail trigger_teleport to prevent telesyncs. Projectiles are destroyed on the server frame after this function is called. Add KillVelocity() to your trigger if you want to prevent the player from being able to receive knockback during that very small window (e.g. if the telesync rocket(s) hit the player at the same time as being teleported to the start of the level).
  • DestroyDemomanProjectiles() - Destroys all demoman projectiles. This function is used by "destroy" limit triggers but you may find it useful outside of that context. Projectiles are destroyed on the server frame after this function is called. In some cases, you will want to add KillVelocity() to your trigger to prevent the player from receiving sticky/pipe knockback during that very small window.
  • KillVelocity() - kills all player velocity. It also accepts an optional class argument so that it will only kill velocity for a certain class (e.g. KillVelocity(soldier) or KillVelocity(demoman)). E.g. you can use this on trigger_teleports (tele doors, fail triggers) to prevent telehops. This offers a convenient alternative to creating trigger_catapult entities.
  • KillVelocityEx() - An "extended" version of KillVelocity() that only kills the player's velocity when their X/Y velocity exceeds walk speed + 30 units, and only cancels Z velocity when it is greater than initial jump speed (277u/s). This is the logic used by "destroy" limit trigger anti-cheat. You can use this function along with DestroySoldierProjectiles() or DestroyDemomanProjectiles() to re-create "destroy" anti-cheat on a separate trigger_multiple. Like KillVelocity(), it also supports the optional class argument (e.g. KillVelocityEx(soldier)).

Usage:
Spoiler (click to show/hide)
« Last Edit: August 26, 2023, 10:52:08 AM by Kingstripes »


879m

  • Proficient
  • ****
    • Posts: 402
    • Frags: +2/-0
  • Techa mengu, go!
    • View Profile