Template talk:BasicCSSweapon

From Valve Developer Community
Jump to: navigation, search


Undocumented inputs SetAmmoAmount <int>, SetReserverAmmoAmount <int> and ToggleCanBePickedUp for Counter-Strike: Global Offensive

I'm not entirely sure if my suggested change is correct and if this template is the right place to make that change, so I write here first.
These inputs are named in the first lines of Counter_Strike_Global_Offensive.fgd and are still current:

@BaseClass color(0 0 200) base(Targetname, RenderFields, Angles) = Weapon
[
	spawnflags(Flags) =
	[
		1 : "Start constrained" : 0
	]
	CanBePickedUp(boolean) : "Is this weapon allowed to be picked up?" : 1

	output OnPlayerUse(void) : "Fires when the player +uses this weapon"
	output OnPlayerPickup(void) : "Fires when the player picks up this weapon"

	input SetReserveAmmoAmount(integer) : "Set the reserve ammo on this weapon"
	input SetAmmoAmount(integer) : "Set the ammo on this weapon"
	input ToggleCanBePickedUp(void) : "Toggle CanBePickedUp"
]

I tested the following in Counter-Strike: Global Offensive by having a weapon_ak47 in the map, naming it and fireing the inputs to it.

  • The SetAmmoAmount input expects an integer and sets the ammo in the current magazine.
    • When set to 0, a player holding it will reload immediately.
    • When set congruent to -1 (mod 256), the ammo display disappears until the value changes. When shooting once, the ammo display shows up again with 254 shots left in the magazine.
    • When set congruent to 0 (mod 256) but not 0 itself, a player holding it will not reload automatically. There seems to be lag in this state. He can shoot, making a silent shot that is visible with sv_showimpacts and gets to the previous -1 (mod 256) state.
    • Any other value will behave like its congruent value between 0 and 256.
    • If set to a value above the weapon's maximum, reloading can cause undefined behavior such as overflow, depending on the reserve ammo. Usually, the ammo is set to the weapon's maximum and the difference is added to the reserve ammo.
  • The SetReserveAmmoAmount input expects an integer that sets the reserve ammo, but cannot exceed a weapon specific limit (90 for the weapon_ak47).
    • When set to a negative value, the ammo display disappears and reloading is impossible.
    • When set to a value that is above the weapon's maximum, it is clamped to the maximum.
  • The ToggleCanBePickedUp input toggles if the weapon can be picked up by players. Visually, nothing changes and there is no event if picking up fails. Hover texts like "[E] Swap for AK-47" remain in both cases!

The problem I see is that articles like weapon_ak47 use only this template, so they don't show the above inputs. Should they be added to this template or should there be an other template for them? Popcorn (talk) 19:55, 27 December 2020 (PST)