Weapon#

Methods of the weapon class

class weapon#
string GetWeaponClassName()#

The weapon identifier

entity GetWeaponOwner()#

The entity that has the gun equipped.

int GetXP()#

Gun XP points achieved by the player.

int GetWeaponType()#

Returns the type of the weapon ( Sidearm, antitanweapon, etc. )

string GetWeaponDescription()#
bool IsWeaponOffhand()#

Wether or not the given weapon is an offhand weaponn.

int GetDamageSourceID()#
void FireWeaponBullet_Special(vector origin, vector direction, int numShots, int damageType, bool unknownPurpose1, bool unknownPurpose2, bool unknownPurpose3, bool unknownPurpose4, bool unknownPurpose5, bool activeShot, bool doTraceBrushOnly)#

The bullet fired by this has “perfect antilag” and no spread. An unknown parameter might control if this fires a fake bullet that doesn’t do any damage. According to a comment, the fake bullet still triggers a damage callback with 0 damage, which is not supposed to happen.

void SetViewmodelAmmoModelIndex(int rounds)#

Set the viewmodel for weapons that have multiple models depending on how many shots are in the clip.

int GetCurrentAltFireIndex()#
int GetShotCount()#
bool IsWeaponRegenDraining()#
void RegenerateAmmoReset()#
float GetCoreDuration()#

Titan core duration

var GetWeaponInfoFileKeyField(string field)#

Returns the content of the passed keyvalue field. Use expect to specify the return type at compile time.

int GetWeaponDamageFlags()#
bool GetAllowHeadShots()#

Wether or not the weapon is able to score critical headshot damage.

int GetAmmoPerShot()#
int GetProjectilesPerShot()#

The Amount of individual projectiles that are fired by the weapon.

float GetMaxDamageFarDist()#

The maximal distance in which the weapon is able to deal damage.

bool ShouldPredictProjectiles()#
bool GetWeaponSettingBool(unknown)#
int GetWeaponSettingInt(unknown)#
int GetWeaponSettingFloat(unknown)#
int GetWeaponSettingString(unknown)#
float GetProjectileWeaponSettingFloat(unknown)#
int GetProjectileWeaponSettingInt(unknown)#
float GetProjectileWeaponSettingFloat(unknown)
int GetProjectileWeaponSettingString(unknown)#
int GetWeaponPrimaryClipCount()#
int GetWeaponPrimaryClipCountMax()#
void SetWeaponPrimaryClipCount(int clipsize)#
void SetWeaponPrimaryClipCountAbsolute(int clipsize)#
void SetWeaponPrimaryClipCountNoRegenReset(int clipsize)#
bool IsReloading()#
int GetReloadMilestoneIndex()#

Reload Progress. Only used on the LStar

bool IsWeaponInAds()#

Returns true if the gun is aimed down sights.

bool IsWeaponAdsButtonPressed()#

Returns true as long as the button set up for aiming is pressed.

void SetForcedADS()#
bool GetForcedADS()#
void ClearForcedADS()#
array<string> GetMods()#
void AddMod(string modname)#
void SetMods(array<string>)#
bool HasMod(string modname)#
void SetModBitField(int mods)#
void SetProScreenOwner(entity player)#
void SetProScreenIntValForIndex(int index, int value)#

consts for index: PRO_SCREEN_INT_LIFETIME_KILLS & PRO_SCREEN_INT_MATCH_KILLS

bool SmartAmmo_IsEnabled()#
unknown<unknown> SmartAmmo_GetTargets()#
void SmartAmmo_TrackEntity(entity hitEnt, LMG_SMART_AMMO_TRACKER_TIME)#
void SmartAmmo_UntrackEntity(entity target)#
array<entity> SmartAmmo_GetStoredTargets()#
string GetSmartAmmoWeaponType()#

Check if weaponType is valid: Assert( weaponType in VALID_WEAPON_TYPES )

void SmartAmmo_Clear( true, false )
vector SmartAmmo_GetFirePosition(entity target, int burstIndex)#
int SmartAmmo_GetNumTrackersOnEntity(entity target)#
int GetBurstFireShotsPending()#
int GetWeaponBurstFireCount()#
void SetWeaponBurstFireCount(int amount)#
bool IsBurstFireInProgress()#
int GetWeaponCurrentEnergyCost()#
void ResetWeaponToDefaultEnergyCost()#
void SetWeaponEnergyCost()#
float GetWeaponChargeLevel()#
float GetWeaponChargeLevelMax()#
float GetWeaponChargeFraction()#
int GetChargeAnimIndex()#
void SetChargeAnimIndex()#
float SetWeaponChargeFraction()#
float SetWeaponChargeFractionForced()#
bool IsChargeWeapon()#
float GetWeaponChargeTime()#
void ForceRelease()#
bool IsForceReleaseFromServer()#
void SetSustainedDischargeFractionForced(float frac)#
bool IsSustainedDischargeWeapon()#
float GetSustainedDischargeDuration()#
void SetAttackKickScale(float scale)#
void SetAttackKickRollScale(float scale)#
entity FireWeaponBullet( vector origin, vector dir, 1, damageType )
entity FireWeaponBolt(vector origin, vector dir, float projectileSpeed, int contactDamageType, int explosionDamageType, bool predict, int index)#
entity FireWeaponMissile(vector origin, vector dir, float missileSpeed, int contactDamageType, int explosionDamageType, bool doPopup, bool predict)#
entity FireWeaponGrenade( vector attackPos, vector throwVelocity, vector angularVelocity, float fuseTime, int contactDamageType, int explosionDamageType, bool isPredicted, bool isLagCompensated, bool bounce? )
bool AllowUse()#

Allows if the weapon can be used. Independent from SetNextAttackAllowedTime.

void SetNextAttackAllowedTime(int time)#

The Weapon can’t be used until the specified time is reached.

weapon.SetNextAttackAllowedTime( Time() ) // Set the gun now usable
bool IsReadyToFire()#
void ForceDryfireEvent()#
vector GetAttackDirection()#

Barrel direction

vector GetAttackPosition()#

Barrel position

void StopWeaponEffect(asset effect1P, asset effect3P)#
void StopWeaponSound(string sound)#
void EmitWeaponNpcSound(float soundRadius, float idk)#
void PlayWeaponEffect(asset effect1P, asset effect3P, string tagName)#
void PlayWeaponEffectNoCull(asset effect1P, asset effect3P, string tagName)#
void EmitWeaponSound_1p3p(string sound1P, string sound3P)#
int PlayWeaponEffectReturnViewEffectHandle(asset fxAlias, asset asset, string tag)#
float GetGrenadeFuseTime()#

Note that fuse time of 0 means the grenade won’t explode on its own, instead it depends on OnProjectileCollision() functions to be defined and explode there. Arguably in this case grenade_fuse_time shouldn’t be 0, but an arbitrarily large number instead.

void SetWeaponSkin(int index)#
void SetSkin(int index)#
void SetWeaponCamo(int index)#
void SetCamo(int index)#
unknown GetScriptScope()#
void SetScriptTime0(float time)#
void SetScriptFlags0(int flag)#