Entities with this component are associated with a client connection at whose end is a human player who provides input to control the entity. More...
Public Member Functions | |
GetActiveWeapon () | |
Returns the ComponentCarriedWeaponT component of the currently active weapon, or nil if currently no weapon is active. More... | |
SelectWeapon (any NextWeapon, bool Force) | |
This method initiates the holstering of the currently active weapon and the subsequent drawing of the given weapon. More... | |
SelectNextWeapon () | |
This method draws the next weapon as previously prepared by SelectWeapon(). More... | |
FireRay (number Damage, number Random=0.0) | |
Traces a ray through the world and causes damage to the hit entity (if any). More... | |
GetRandom (number n) | |
Returns a pseudo-random number. More... | |
SpawnWeaponChild (string EntityName) | |
An auxiliary method for spawning entities for thrown hand grenades, thrown face-huggers, launched AR grenades, or launched rockets (RPGs). More... | |
RegisterParticle (number Type) | |
An auxiliary method for spawning new particles. More... | |
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... | |
Public Attributes | |
string | PlayerName |
The name that the player chose for himself. More... | |
number | RandomCount |
Keeps track of the next random number that is returned by the GetRandom() method. More... | |
number | State |
For the player's main state machine, e.g. More... | |
number | Health |
Health. More... | |
number | Armor |
Armor. More... | |
number | Frags |
Frags. More... | |
number | ActiveWeaponNr |
The index number into the CarriedWeapon components of this entity, starting at 1, indicating the currently active weapon. More... | |
number | NextWeaponNr |
The next weapon to be drawn by SelectNextWeapon(). More... | |
number | HeadSway |
The progress of one "head swaying" cycle in state FrozenSpectator. More... | |
Entities with this component are associated with a client connection at whose end is a human player who provides input to control the entity.
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():
FireRay | ( | number | Damage, |
number | Random = 0.0 |
||
) |
Traces a ray through the world and causes damage to the hit entity (if any).
This method can be used to implement the "fire" action of weapons that cause instantaneous damage, such as pistols, guns, rifles, etc. The ray is traced from the camera's origin along the camera's view vector, which can be randomly scattered (used to simulate inaccurate human aiming) by the given parameter Random
. If an entity is hit, its TakeDamage() method is called with the human player as the originator and the amount of damage as given by parameter Damage
.
Damage | The damage to inflict to a possibly hit entity. |
Random | The maximum amount of random scatter to apply to the traced ray. |
GetActiveWeapon | ( | ) |
Returns the ComponentCarriedWeaponT component of the currently active weapon, or nil
if currently no weapon is active.
GetRandom | ( | number | n | ) |
Returns a pseudo-random number.
If n
is 0, 1, or absent (nil
), this method returns a pseudo-random number in range [0.0, 1.0]
(inclusive). Otherwise, a pseudo-random integer in range 0 ... n-1
is returned.
The important aspect of this method is that it returns pseudo-random numbers that are reproducible in the context of the "client prediction" feature of the Cafu Engine. All random numbers that are used in human player code must be obtained from this method.
RegisterParticle | ( | number | Type | ) |
An auxiliary method for spawning new particles.
This is only a clumsy auxiliary method – the entire particle system needs a thorough revision instead!
SelectNextWeapon | ( | ) |
This method draws the next weapon as previously prepared by SelectWeapon().
It is intended to be called at the end of the holstering sequence of the previous weapon, either directly from SelectWeapon() when it found that holstering can entirely be skipped, or indirectly when SelectWeapon() calls the previous weapon's Holster()
callback, the end of the holster sequence is detected in the OnSequenceWrap_Sv()
script callback, and its implementation in turn calls this method.
SelectWeapon | ( | any | NextWeapon, |
bool | Force | ||
) |
This method initiates the holstering of the currently active weapon and the subsequent drawing of the given weapon.
If the current weapon is unknown or not available to the player (e.g. because it has never been picked up), or if it turns out that the weapon does not support holstering (e.g. because there is no holstering sequence available), the holstering is skipped and the next weapon is drawn immediately. If the current weapon is fine but is not idle at the time that this method is called (e.g. reloading or firing), the call is ignored, that is, the weapon is not changed.
NextWeapon | This can be the index number into the CarriedWeapon components of this entity, starting at 1. Use 0 to select "no" weapon. Alternatively, pass an instance of the carried weapon that is to be selected next. |
Force | If true , forces the drawing of the next weapon immediately, ignoring the idle state and holstering sequence of the current weapon. This is normally only used if, for example, the last hand grenade has been thrown and bare-handed animation sequences for idle and holster are not available. |
SpawnWeaponChild | ( | string | EntityName | ) |
An auxiliary method for spawning entities for thrown hand grenades, thrown face-huggers, launched AR grenades, or launched rockets (RPGs).
This is only an auxiliary method – it should in fact be removed and entirely be implemented in Lua instead!
number ActiveWeaponNr |
The index number into the CarriedWeapon components of this entity, starting at 1, indicating the currently active weapon.
The weapon must also be available (have been picked up) before the player can use it. A value of 0 means that "no" weapon is currently active.
uint8_t
number Armor |
Armor.
uint8_t
number Frags |
Frags.
uint8_t
number HeadSway |
The progress of one "head swaying" cycle in state FrozenSpectator.
float
number Health |
Health.
uint8_t
number NextWeaponNr |
The next weapon to be drawn by SelectNextWeapon().
Like ActiveWeaponNr, this is an index number into the CarriedWeapon components of this entity, starting at 1. A value of 0 means "none".
uint8_t
string PlayerName |
The name that the player chose for himself.
std::string
number RandomCount |
Keeps track of the next random number that is returned by the GetRandom() method.
uint16_t
number State |
For the player's main state machine, e.g.
spectator, dead, alive, ...
uint8_t