RPG Xdocumentation About RPG X

Guns

Stamina per round, the one spare magazine, and changing any gun's values.

  • Spare ammo is always one magazine. Whatever gun you hold, its spare ammo is kept at exactly one magazine (one round for guns without a magazine, like the RPG), so you can always reload, and ammo pickups don't add more. rpgx_weapon_spare_magazine 0 turns this off.
  • A magazine never holds more than it fits. Some Workshop guns (M9K's) come with several magazines' worth of rounds; picked up into the inventory they come with one full magazine.
  • Grenades and SLAM are consumables (see Inventory): no spare and no stamina cost, the stack in the inventory is all you have.
  • The ammo box (bottom right) shows only what's in the magazine, in a smaller box: the spare is always one magazine, so it isn't shown. Guns without a magazine show their rounds.
  • Every round costs stamina, 1 by default (rpgx_weapon_resource, rpgx_weapon_cost). Reloading is free, but needs the stamina for a round too: without it neither trigger nor reload do anything (the bar flashes red), an empty magazine only clicks, and the spare ammo is gone until the stamina is back (so HL2's guns don't reload an empty magazine by themselves). With rpgx_weapon_spare_magazine 0 only the reload key is blocked. Spending pauses refilling like any other use, and counts towards training.
  • Changing a gun: Q > Weapons > right click a gun > Change values (owners, permission weapon_balance). Saved in the database right away and applied to everyone, guns already out included:
    • For every gun: what its shots cost (default / stamina / mana / free), cost per round, damage per bullet, bullets per shot, and a spread multiplier (2 = twice as inaccurate). Empty boxes keep the gun's own value or the server default. These work on HL2's own guns too.
    • On hit: a list of (de)buffs a hit may put on what it hits, each with its chance in percent (every buff installed on the server is offered, see Buffs from code). Each is rolled once per target per tick, so a shotgun's pellets are one roll. The list starts as the gun's own; saving a different one (an empty one too) replaces it.
    • For scripted weapons (SWEPs, from the Workshop), every value of theirs: the Primary and Secondary tables (damage, magazine size, delay, automatic, ammo type...) and their other numbers and switches (RPM and the like, depending on the weapon base). HL2's own guns keep those in the engine, so they only have the values above.
    • Back to how it comes removes every change to that gun.

A SWEP brings its own on-hit list with SWEP.HitBuffs = { slowed = 25, frozen = 5 } (buff id -> chance in percent): what its hits do unless the editor saved another list for it.

Addons: GAMEMODE:WeaponOverride( class ) is a gun's changes (nil = none), GAMEMODE:WeaponHitBuffs( class ) what its hits may apply (id -> chance), GAMEMODE:WeaponCost( class ) what its rounds cost (resource id or nil, amount), and GAMEMODE:WeaponSave( class, changes, callback ) saves new ones (server). Hooks: RPGXWeaponShot( ply, weapon, rounds, resource, cost ) (server) and RPGXWeaponChanged( class, changes ) (both sides).