Nuclide
Software Development Kit for id Tech
NSWeapon Class Reference

This entity class represents weapon based items. More...

#include <NSWeapon.h>

Inheritance diagram for NSWeapon:
NSItem

Public Member Functions

void NSWeapon (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 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 IsWeapon (void)
 
virtual bool HasReserveAmmo (void)
 
virtual void Draw (void)
 Overridable: Called when we switch to this weapon. 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. 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)
 
virtual void SetAttackNext (float)
 
virtual void SetIdleNext (float)
 
virtual bool CanFire (void)
 
virtual bool CanIdle (void)
 
virtual bool UseAmmo (string)
 
virtual void FiredWeapon (string)
 Overridable: Called when the weapon has been fired. More...
 
virtual void ReleasedWeapon (string)
 Overridable: Called when the weapon has been released. 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)
 

Detailed Description

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.

KEYS

  • "targetname" : Name
  • "weapon_scriptobject" : mapC progs with the weapon code within.
  • "ammoType" : name of the ammo type def entry which the gun uses
  • "ammoRequired" : set to 1 if we require ammo.
  • "ammoPerShot" : Amount of ammo to deduct per shot.
  • "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.

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

◆ 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.

◆ 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.

◆ FiredWeapon()

void NSWeapon::FiredWeapon ( string  fireInfo)
virtual

Overridable: Called when the weapon has been fired.

◆ HasReserveAmmo()

bool NSWeapon::HasReserveAmmo ( void  )
virtual

◆ Holster()

void NSWeapon::Holster ( void  )
virtual

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

◆ IsWeapon()

bool NSWeapon::IsWeapon ( void  )
virtual

Reimplemented from NSItem.

◆ 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.

◆ ReleasedWeapon()

void NSWeapon::ReleasedWeapon ( string  fireInfo)
virtual

Overridable: Called when the weapon has been released.

◆ 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)

◆ 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.

◆ 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.

◆ UseAmmo()

bool NSWeapon::UseAmmo ( string  fireInfo)
virtual

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