Nuclide
Software Development Kit for id Technology
NSWeapon Class Reference

About this class

This entity class represents weapon based items.

QUAKED NSWeapon (0 0.8 0.8) (-16 -16 0) (16 16 72)

OVERVIEW

This entity class represents weapon based items. It is based on NSItem. The only difference is that the attack related keys get forwarded only to items of this class.

FireInfo

Weapon firing events are split into optional decl titled 'FireInfo' that are queried for implemented attack types.

The "def_fireInfo" key points to the decl containing the primary-attack FireInfo. If that doesn't exist, the keys that would be queried from there are read from the main decl. This goes for any key that is not present in a FireInfo.

The "def_altFireInfo" key points to the decl containing the secondary-attack FireInfo. If that does not exist, secondary attacks are not possible.

KEYS

  • "targetname" : Name
  • "weapon_scriptobject" : mapC progs with the weapon code within.
  • "clipSize" : maximum clip size
  • "mtr_flashShader" : muzzleflash material to Use.
  • "model_flash" : muzzleflash model/sprite to use.
  • "flashColor" : muzzleflash dlight color
  • "flashRadius" : muzzleflash dlight radius
  • "def_dropItem" : when this item is dropped from someones inventory, will spawn this entityDef item instead.
  • "snd_acquire" : pickup noise
  • "snd_respawn" : respawn noise
  • "snd_hum" : idle shader
  • "smoke_muzzle" : smoke particle effect name
  • "continuousSmoke" : whether the particle effect is continous
  • "clipSizeDefault" : CUSTOM: Default clip size on pickup.

FireInfo related keys

  • "def_onFire" : Def to spawn when the weapon is fired.
  • "def_onRelease" : Def to spawn when the weapon has been released.

Ammo management related keys

  • "ammoType" : name of the ammo type def entry which the weapon uses
  • "ammoRequired" : set to 1 if we require ammo.
  • "ammoPerShot" : Amount of ammo to deduct per successful shot.

Charging/Overcharging

For an overcharge effect, spawn a self-destructive explosion on "def_onFire", and rely on "def_onRelease" for delivering a lethal charge to other enemies.

  • "chargeTime" : Amount of time the weapon has to charge before "def_onFire" is spawned.

Overheating weapons

Overheating of the weapon is done when both keys are set.

  • "overheatLength" : Time in which it takes for the weapon to cool down.
  • "overheatPerShot" : Time added against "overheatLength" when a shot is fired.

Mode switching

  • "altMode" : When 1, then secondary-attack will toggle between "def_fireInfo" and "def_altFireInfo" on primary-attack.

Act overrides

Activities are used to decide which animation gets played and which actions are available for this object. If a model does not define them, you can override them here. This system is SUBJECT to change. It may be removed altogether when FTEQW adds a proper activity override format for existing models.

  • "actIdle" : Sequences to play when idle.
  • "actIdleEmpty" : Sequences to play when idle and with an empty clip.
  • "actDraw" : Sequences to play when drawing the weapon.
  • "actDrawEmpty" : Sequences to play when drawing the empty weapon.
  • "actHolster" : Sequences to play when holstering the weapon.
  • "actHolsterEmpty" : Sequences to play when holstering the empty weapon.
  • "actFire" : Sequences to play when "def_onFire" fires.
  • "actFireLast" : Sequences to play when firing the last shot in the weapon.
  • "actFireEmpty" : Sequences to play when failing to fire the weapon.
  • "actReload" : Sequences to play when reloading the weapon.
  • "actReloadEmpty" : Sequences to play when reloading the empty weapon.
  • "actReloadStart" : When set will play sequences for the start of a shotgun-style reload.
  • "actReloadEnd" : Like "actReloadStart" but for the end of the shotgun-style reload.
  • "actDelay" : Sequence to play while the weapon is charging (see "chargeTime")
  • "actLoop" : Sequence to play while the weapon is still charging, or in a firing-loop.
  • "actDetonate" : Sequences to play when "detonateOnFire" is triggered.
  • "actMeleeMiss" : Sequences to play when the melee attack fails.
  • "actMeleeHit" : Sequences to play when the melee attack hits.
  • "actFireStart" : Sequences to play at the start of a loop/charge attack.
  • "actFireStop" : Sequences to play at the end of a loop/charge attack.
  • "actRelease" : Sequences to play when "def_onRelease" fires.

Misc keys

  • "reloadTime" : Time in seconds between the start/end of a reload.
  • "detonateOnFire" : When set, will detonate all entities of specified classname.
  • "punchAngle" : Weapon punchangle to be applied to the camera when shooting "def_onFire".
  • "fireRate" : Firing rate between shots.
  • "semiAuto" : If not set to "1", the weapon will be fully automatic.
Inheritance diagram for NSWeapon:
NSItem

Public Member Functions

void NSWeapon (void)
 
virtual void InputFrame (void)
 
virtual void AddedToInventory (void)
 Called when an item was added to someones inventory. More...
 
virtual void RemovedFromInventory (void)
 Called when an item was removed from someones inventory. More...
 
virtual void Spawned (void)
 Called when the entity is fulled initialized. More...
 
virtual void SpawnKey (string, string)
 This method handles entity key/value pairs on map load. More...
 
virtual void Save (float)
 Handles saving a copy of this entity to a given filehandle. More...
 
virtual void Restore (string, string)
 Similar to NSIO::SpawnKey but for save-game fields. More...
 
virtual void EvaluateEntity (void)
 Run each tic after physics are run to determine if we need to send updates over the network. More...
 
virtual float SendEntity (entity, float)
 Called by the engine whenever we need to send a client an update about this entity. More...
 
virtual bool TestFireAbility (string)
 
virtual void UpdateViewmodel (void)
 
virtual void ClientFX (bool)
 
virtual void PredictPreFrame (void)
 
virtual void PredictPostFrame (void)
 
virtual void ReceiveEntity (float, float)
 Client: Handles network updates from the server for the associated entity. More...
 
virtual void ReceiveEvent (float)
 
virtual bool UsesSecondaryAmmo (void)
 
virtual bool IsEmpty (void)
 
virtual bool IsWeapon (void)
 
virtual bool HasReserveAmmo (void)
 
virtual void Draw (void)
 Overridable: Called when we switch to this weapon from another. More...
 
virtual void Holster (void)
 Overridable: Called when we are about to switch to another weapon. More...
 
virtual void PrimaryAttack (void)
 Overridable: On +attack execution. More...
 
virtual void SecondaryAttack (void)
 Overridable: On +attack2 execution. More...
 
virtual void Reload (void)
 Overridable: On +reload execution. More...
 
virtual void Release (void)
 Overridable: When no buttons are held, or you forcefully want to stop firing. More...
 
virtual void Idle (void)
 Overridable: When the weapon is supposed to be doing something on its own. More...
 
virtual void UpdateGUI (void)
 Overridable: When the HUD is requested to be drawn. More...
 
nonvirtual void SetViewModel (string)
 
nonvirtual void SetWorldModel (string)
 
nonvirtual void SetPlayerModel (string)
 
nonvirtual void SetWeaponFrame (float)
 
nonvirtual void PlaySound (string, float, bool)
 
nonvirtual nsweapon_state_t GetWeaponState (void)
 
virtual void SetAttackNext (float)
 
virtual void SetReloadNext (float)
 
virtual void SetIdleNext (float)
 
virtual bool CanFire (void)
 
virtual bool CanIdle (void)
 
virtual bool CanReload (void)
 
virtual bool UseAmmo (string)
 
virtual void WeaponStartedFiring (void)
 Overridable: Called once when the weapon started firing. More...
 
virtual void WeaponStoppedFiring (void)
 Overridable: Called once when the weapon stopped firing. More...
 
nonvirtual bool WeaponIsFiring (void)
 Returns whether the weapon is being actively fired by the owner. More...
 
virtual void FiredWeaponAttack (string)
 Overridable: Controls def_onFire event. More...
 
virtual void ReleasedWeaponAttack (string)
 Overridable: Controls def_onRelease event. More...
 
virtual void SwitchedToWeapon (void)
 Overridable: Called when we've switched to this weapon successfully. More...
 
virtual void SwitchedFromWeapon (void)
 Overridable: Called when we've switched from this weapon successfully. More...
 
virtual void UpdateFireInfoCache (void)
 Overridable: Called when the fireInfo changed. More...
 
nonvirtual void SwitchFireInfo (string)
 Set the active fire Info of the weapon to this one. More...
 
nonvirtual bool DetonateDef (string)
 
nonvirtual void Attack (string)
 

Constructor & Destructor Documentation

◆ NSWeapon()

void NSWeapon::NSWeapon ( void  )

Member Function Documentation

◆ AddedToInventory()

void NSWeapon::AddedToInventory ( void  )
virtual

Called when an item was added to someones inventory.

Reimplemented from NSItem.

◆ Attack()

void NSWeapon::Attack ( string  fireInfo)

◆ CanFire()

bool NSWeapon::CanFire ( void  )
virtual

◆ CanIdle()

bool NSWeapon::CanIdle ( void  )
virtual

◆ CanReload()

bool NSWeapon::CanReload ( void  )
virtual

◆ ClientFX()

void NSWeapon::ClientFX ( bool  isThirdperson)
virtual

◆ DetonateDef()

bool NSWeapon::DetonateDef ( string  defName)

◆ Draw()

void NSWeapon::Draw ( void  )
virtual

Overridable: Called when we switch to this weapon from another.

◆ EvaluateEntity()

void NSWeapon::EvaluateEntity ( void  )
virtual

Run each tic after physics are run to determine if we need to send updates over the network.

Reimplemented from NSItem.

◆ FiredWeaponAttack()

void NSWeapon::FiredWeaponAttack ( string  fireInfo)
virtual

Overridable: Controls def_onFire event.

◆ GetWeaponState()

nsweapon_state_t NSWeapon::GetWeaponState ( void  )

◆ HasReserveAmmo()

bool NSWeapon::HasReserveAmmo ( void  )
virtual

◆ Holster()

void NSWeapon::Holster ( void  )
virtual

Overridable: Called when we are about to switch to another weapon.

◆ Idle()

void NSWeapon::Idle ( void  )
virtual

Overridable: When the weapon is supposed to be doing something on its own.

◆ InputFrame()

void NSWeapon::InputFrame ( void  )
virtual

◆ IsEmpty()

bool NSWeapon::IsEmpty ( void  )
virtual

◆ IsWeapon()

bool NSWeapon::IsWeapon ( void  )
virtual

Reimplemented from NSItem.

◆ PlaySound()

void NSWeapon::PlaySound ( string  soundDef,
float  soundChannel,
bool  clientOnly 
)

◆ PredictPostFrame()

void NSWeapon::PredictPostFrame ( void  )
virtual

Reimplemented from NSItem.

◆ PredictPreFrame()

void NSWeapon::PredictPreFrame ( void  )
virtual

Reimplemented from NSItem.

◆ PrimaryAttack()

void NSWeapon::PrimaryAttack ( void  )
virtual

Overridable: On +attack execution.

◆ ReceiveEntity()

void NSWeapon::ReceiveEntity ( float  flNew,
float  flChanged 
)
virtual

Client: Handles network updates from the server for the associated entity.

Reimplemented from NSItem.

◆ ReceiveEvent()

void NSWeapon::ReceiveEvent ( float  eventID)
virtual

Reimplemented from NSItem.

◆ Release()

void NSWeapon::Release ( void  )
virtual

Overridable: When no buttons are held, or you forcefully want to stop firing.

◆ ReleasedWeaponAttack()

void NSWeapon::ReleasedWeaponAttack ( string  fireInfo)
virtual

Overridable: Controls def_onRelease event.

◆ Reload()

void NSWeapon::Reload ( void  )
virtual

Overridable: On +reload execution.

◆ RemovedFromInventory()

void NSWeapon::RemovedFromInventory ( void  )
virtual

Called when an item was removed from someones inventory.

Reimplemented from NSItem.

◆ Restore()

void NSWeapon::Restore ( string  strKey,
string  strValue 
)
virtual

Similar to NSIO::SpawnKey but for save-game fields.

Whatever you write into file handles within your NSIO::Save() method needs to be read back in here.

Reimplemented from NSItem.

◆ Save()

void NSWeapon::Save ( float  handle)
virtual

Handles saving a copy of this entity to a given filehandle.

Within you want to use the NSIO::SaveFloat() etc. methods to write the internal member attributes to the specified file handle.

Reimplemented from NSItem.

◆ SecondaryAttack()

void NSWeapon::SecondaryAttack ( void  )
virtual

Overridable: On +attack2 execution.

◆ SendEntity()

float NSWeapon::SendEntity ( entity  ,
float   
)
virtual

Called by the engine whenever we need to send a client an update about this entity.

Reimplemented from NSItem.

◆ SetAttackNext()

void NSWeapon::SetAttackNext ( float  newDelay)
virtual

◆ SetIdleNext()

void NSWeapon::SetIdleNext ( float  newDelay)
virtual

◆ SetPlayerModel()

void NSWeapon::SetPlayerModel ( string  modelPath)

◆ SetReloadNext()

void NSWeapon::SetReloadNext ( float  newDelay)
virtual

◆ SetViewModel()

void NSWeapon::SetViewModel ( string  modelPath)

◆ SetWeaponFrame()

void NSWeapon::SetWeaponFrame ( float  newSequence)

◆ SetWorldModel()

void NSWeapon::SetWorldModel ( string  modelPath)

◆ Spawned()

void NSWeapon::Spawned ( void  )
virtual

Called when the entity is fulled initialized.

Any spawn key/value info pairs have already been dealt with. So now we can make full decisions on the entity. Always make sure to call super::Spawned(); inside your method when overriding.

Reimplemented from NSItem.

◆ SpawnKey()

void NSWeapon::SpawnKey ( string  strKey,
string  strValue 
)
virtual

This method handles entity key/value pairs on map load.

You can easily convert the strValue parameter using the ReadFloat etc. methods that are part of NSIO.

Reimplemented from NSItem.

◆ SwitchedFromWeapon()

void NSWeapon::SwitchedFromWeapon ( void  )
virtual

Overridable: Called when we've switched from this weapon successfully.

◆ SwitchedToWeapon()

void NSWeapon::SwitchedToWeapon ( void  )
virtual

Overridable: Called when we've switched to this weapon successfully.

◆ SwitchFireInfo()

void NSWeapon::SwitchFireInfo ( string  newInfo)

Set the active fire Info of the weapon to this one.

◆ TestFireAbility()

bool NSWeapon::TestFireAbility ( string  fireInfo)
virtual

◆ UpdateFireInfoCache()

void NSWeapon::UpdateFireInfoCache ( void  )
virtual

Overridable: Called when the fireInfo changed.

Cache values here.

◆ UpdateGUI()

void NSWeapon::UpdateGUI ( void  )
virtual

Overridable: When the HUD is requested to be drawn.

◆ UpdateViewmodel()

void NSWeapon::UpdateViewmodel ( void  )
virtual

◆ UseAmmo()

bool NSWeapon::UseAmmo ( string  fireInfo)
virtual

◆ UsesSecondaryAmmo()

bool NSWeapon::UsesSecondaryAmmo ( void  )
virtual

◆ WeaponIsFiring()

bool NSWeapon::WeaponIsFiring ( void  )

Returns whether the weapon is being actively fired by the owner.

◆ WeaponStartedFiring()

void NSWeapon::WeaponStartedFiring ( void  )
virtual

Overridable: Called once when the weapon started firing.

◆ WeaponStoppedFiring()

void NSWeapon::WeaponStoppedFiring ( void  )
virtual

Overridable: Called once when the weapon stopped firing.


The documentation for this class was generated from the following files: