CCmpWeapon Class Reference

Define a weapon. Owned by GameEntity. More...

#include <cmpWeapon.h>

Inheritance diagram for CCmpWeapon:

CCmp

List of all members.

Public Member Functions

 CCmpWeapon (CGameEntity *pGE)
 Create with default values.
Virtual methods
virtual int set (const EDIT_DATA &editData)
 Set a value.
virtual int get (EDIT_DATA &editData) const
 Get a value.
virtual int act (const ACTION_DATA &actData)
 Preform an action.
virtual void update ()
 Update this Cmp for a single frame.
Interface methods
int next ()
int weapon_def ()
 
Returns:
The current weapon def index (-1 if none selected)

CWeaponweapon_add (int i)
int ammo_add (const int n, int type)
int ammo_add_weapon (int n, int index=-1)
int ammo_current () const
 
Returns:
Ammo for the current weapon

int ammo_reserve () const
 
Returns:
Reserve ammo for the current weapon

bool ammo_reserve_use (int n)
int ammo_max () const
 
Returns:
Max ammo for the current weapon

bool weapon_select (int i)
bool weapon_select_type (int type)
void reload ()
 Reload the current weapon.
void fire ()
 Fire the current weapon.
bool aim_calc (CAngle3D &aIdeal, const CVector3D &vPos, unit tolerance=1)

Static Public Attributes

Default values
static const int kAmmoTypes = 10
 the number of different ammo types the player can hold
static const int kAmmoUnknown = (kAmmoTypes-1)

Friends

class CUiWeapon
 allow to displays values


Detailed Description

Define a weapon. Owned by GameEntity.

(c) 2007-2008 oP group Germany GbR. All rights reserved.
This source code is provided "as is" with no warranty and must not be distributed without written permission.

Author:
Doug Poston
Version:
1.3
Date:
12/28/2007

Member Function Documentation

int CCmpWeapon::set ( const EDIT_DATA editData  )  [virtual]

Set a value.

If we have data of this type, use editData to set its value.

Parameters:
editData Data type and value (see EDIT_DATA struct).
Returns:
Value less than zero on error, 0 if nothing found, positive otherwise.
See also:
EDIT_DATA


Handles the following EDIT_DATA:

Implements CCmp.

int CCmpWeapon::get ( EDIT_DATA editData  )  const [virtual]

Get a value.

If we have data of this type, use editData to get its value.

Parameters:
editData Data type we are looking for, and memory to store value (see EDIT_DATA struct).
Returns:
Value less than zero on error, 0 if nothing found, positive otherwise.
See also:
EDIT_DATA


Handles the following EDIT_DATA:

Implements CCmp.

int CCmpWeapon::act ( const ACTION_DATA actData  )  [virtual]

Preform an action.

Handle the action passed in (ignore if we do not handle the action type).

Parameters:
actData The data used to preform the action (see ACTION_DATA struct).
Returns:
Value less than zero on error, 0 if no action found, positive otherwise.
See also:
ACTION_DATA


Handles the following ACTION_DATA:

Implements CCmp.

int CCmpWeapon::next (  ) 

Switch to next weapon

Returns:
New current weapon id.

CWeapon & CCmpWeapon::weapon_add ( int  i  ) 

Add a weapon

Parameters:
i Weapon Def index of weapon we are adding.
Returns:
Pointer to the weapon if added, NULL on error

int CCmpWeapon::ammo_add ( const int  n,
int  type 
)

Add ammo to the reserve

Parameters:
n Number of rounds we are trying to add.
type The type of ammo
Returns:
Number of rounds added

int CCmpWeapon::ammo_add_weapon ( int  n,
int  index = -1 
)

Add ammo to the reserve of a weapon

Parameters:
n Number of rounds we are trying to add.
index Index of the weapon to reload (-1: load current weapon)
Returns:
Number of rounds added

bool CCmpWeapon::ammo_reserve_use ( int  n  ) 

Parameters:
n Number of rounds to remove from the ammo reserve of the current weapon
Returns:
true if we had enough ammo to remove

bool CCmpWeapon::weapon_select ( int  i  ) 

Select a weapon

Parameters:
i index of the weapon to select (-1 for none)
Returns:
true if selected

bool CCmpWeapon::weapon_select_type ( int  type  ) 

Parameters:
type The type of weapon we want
Returns:
true If weapon of type is found and selected

bool CCmpWeapon::aim_calc ( CAngle3D aIdeal,
const CVector3D vPos,
unit  tolerance = 1 
)

Calculate the ideal firing angle

Parameters:
aIdeal Contains the calculated angle
vPos What we would like to hit.
tolerance How close we need to be to ideal (degrees)
Returns:
true If the GE is already aimming close to this ideal


The documentation for this class was generated from the following files:
Generated on Fri Dec 28 12:55:07 2007 for template7 by  doxygen 1.5.4