Cafu Engine
ComponentCarriedWeaponT Class Reference

This component represents a weapon that a player can pick up and use. More...

Inheritance diagram for ComponentCarriedWeaponT:

Public Attributes

string Label
 A short informational name for this weapon. More...
 
boolean IsAvail
 Is this weapon available to the player? Normally false when the player spawns. More...
 
string Script
 The filename of the script that implements the behaviour of this weapon. More...
 
number PrimaryAmmo
 The current amount of ammo for the primary fire of this weapon. More...
 
number MaxPrimaryAmmo
 The maximum amount of ammo for the primary fire of this weapon. More...
 
number SecondaryAmmo
 The current amount of ammo for the secondary fire of this weapon. More...
 
number MaxSecondaryAmmo
 The maximum amount of ammo for the secondary fire of this weapon. More...
 

Event Handlers (Callbacks)

See the Event Handlers (Callbacks) overview page for additional information about the methods in this group.

boolean IsIdle ()
 This method is called in order to learn if this weapon is currently idle. More...
 
 Draw ()
 This method is called in order to let this weapon know that it is drawn. More...
 
boolean Holster ()
 This method is called in order to have this weapon holstered. More...
 
 FirePrimary (boolean ThinkingOnServerSide)
 This method is called in order to have this weapon emit primary fire. More...
 
 FireSecondary (boolean ThinkingOnServerSide)
 This method is called in order to have this weapon emit secondary fire. More...
 
 PreCache ()
 This method is called in order to have the weapon pre-cache its resources. More...
 
bool PickedUp ()
 This method is called when the player walks over an instance of this weapon in the world. More...
 
tuple GetCrosshairInfo ()
 This method is called by the HUD GUI in order to learn which cross-hair should currently be shown. More...
 
string GetAmmoString ()
 This method is called by the HUD GUI in order to learn which info should currently be shown in the "ammo" field. More...
 

Additional Inherited Members

- Public Member Functions inherited from ComponentBaseT
any get (string var_name)
 Returns the value of an attribute (a member variable) of this class. More...
 
 set (string var_name, any new_value)
 Sets an attribute (a member variable) of this class to a new value. More...
 
string GetExtraMessage (string var_name)
 Returns the result of VarBaseT::GetExtraMessage() for the given member variable. More...
 
 interpolate (string var_name, number start_value, number end_value, number time)
 Schedules a value for interpolation between a start and end value over a given period of time. More...
 
EntityT GetEntity ()
 Returns the entity that this component is a part of (or nil if the component is currently "stand-alone", not a part of any entity). More...
 
 InitClientApprox (string VarName)
 Registers the given attribute (a member variable) of this class for interpolation over client frames in order to bridge the larger intervals between server frames. More...
 
 OnInit ()
 This method is called for each component of each entity as the last step of initializing a newly loaded map. More...
 
 OnClientFrame (number t)
 This method is called for each component of each entity before the client renders the next frame. More...
 

Detailed Description

This component represents a weapon that a player can pick up and use.

Note that the variables of this class (also referred to as "Public Attributes" or "Member Data") must be used with the get() and set() methods at this time – see get() and set() for details.

If you would like to create a new component of this type explicitly (those defined in the CaWE Map Editor are instantiated automatically), use WorldT::new():

local comp = world:new("ComponentCarriedWeaponT")
Implementing C++ Class:
cf::GameSys::ComponentCarriedWeaponT
See Also
Carried Weapons Overview

Member Function Documentation

Draw ( )

This method is called in order to let this weapon know that it is drawn.

It is reponsible for setting up the entity's 1st-person weapon model for drawing this weapon. This possibly includes setting up the 1st-person weapon model's ComponentModelT::OnSequenceWrap_Sv() callback, which must be implemented to "operate" this weapon.

See Also
Carried Weapons Overview
FirePrimary ( boolean  ThinkingOnServerSide)

This method is called in order to have this weapon emit primary fire.

FireSecondary ( boolean  ThinkingOnServerSide)

This method is called in order to have this weapon emit secondary fire.

string GetAmmoString ( )

This method is called by the HUD GUI in order to learn which info should currently be shown in the "ammo" field.

tuple GetCrosshairInfo ( )

This method is called by the HUD GUI in order to learn which cross-hair should currently be shown.

boolean Holster ( )

This method is called in order to have this weapon holstered.

It is reponsible for setting up the entity's 1st-person weapon model for holstering this weapon. It must return true if successful, or false to indicate that holstering is not possible, e.g. because a holstering sequence is not available.

See Also
Carried Weapons Overview
boolean IsIdle ( )

This method is called in order to learn if this weapon is currently idle.

The implementation usually determines the idle state of the weapon by the animation sequence that the related 1st-person weapon model is currently playing.

See Also
Carried Weapons Overview
bool PickedUp ( )

This method is called when the player walks over an instance of this weapon in the world.

Its implementation is reponsible for picking up the weapon and for re-stocking the weapon and the player's inventory with the related ammunition. (This method is usually not called directly from Cafu's C++ code, but rather from other script code.)

See Also
Carried Weapons Overview
PreCache ( )

This method is called in order to have the weapon pre-cache its resources.

Member Data Documentation

boolean IsAvail

Is this weapon available to the player? Normally false when the player spawns.

Switched to true when the player picks up the weapon for the first time, whereupon it can be selected and drawn.

Related C++ type:
bool
string Label

A short informational name for this weapon.

Used for reference e.g. in the Map Editor, in log output, or in script code (therefore, changing it for existing weapons may require a review of the related script code).

Related C++ type:
std::string
number MaxPrimaryAmmo

The maximum amount of ammo for the primary fire of this weapon.

Related C++ type:
uint16_t
number MaxSecondaryAmmo

The maximum amount of ammo for the secondary fire of this weapon.

Related C++ type:
uint16_t
number PrimaryAmmo

The current amount of ammo for the primary fire of this weapon.

Related C++ type:
uint16_t
string Script

The filename of the script that implements the behaviour of this weapon.

Related C++ type:
std::string
number SecondaryAmmo

The current amount of ammo for the secondary fire of this weapon.

Related C++ type:
uint16_t