Classes.CTroop Class Reference

Inherits Classes.CJGomasAgent.

Inherited by Classes.CFieldOps, Classes.CMedic, and Classes.CSoldier.

Inheritance diagram for Classes.CTroop:

Inheritance graph
[legend]
Collaboration diagram for Classes.CTroop:

Collaboration graph
[legend]
List of all members.

Static Public Attributes

static final int ARG_TEAM = 0
static final int TEAM_NONE = 0
static final int TEAM_ALLIED = 100
static final int TEAM_AXIS = 200
static final int CLASS_NONE = 0
static final int CLASS_SOLDIER = 1
static final int CLASS_MEDIC = 2
static final int CLASS_ENGINEER = 3
static final int CLASS_FIELDOPS = 4

Protected Member Functions

void setup ()
 'setup' method of jade agents.
void takeDown ()
 'takeDown' method of jade agents.
final int Move ()
final int GetHealth ()
 Get the current health of the agent.
final int GetAmmo ()
 Get the current ammunition of the agent.
final int GetStamina ()
 Get the current stamina of the agent.
final void UseStamina ()
 Use stamina from the stamina bar if possible (there is at least 5 units).
final int GetPower ()
 Get the current power of the agent.
final void UsePower ()
 Use power from the power bar if possible (there is at least 25 units).
final void AddServiceType (String _sServiceType)
 Adds a type of service to the service type list.
final boolean CheckStaticPosition ()
 Checks our position on the static map.
final boolean CheckStaticPosition (double _x, double _z)
 Checks a position on the static map.
final void AddTask (int _tTypeOfTask, AID _Owner, String _sContent)
 Adds a task to the task list.
final void AddTask (int _tTypeOfTask, AID _Owner, String _sContent, int _iPriority)
 Adds a task to the task list with a modified priority.
final void Look ()
 The agent looks in the direction he is walking.
final boolean Shot (int _iShotNum)
 The agent shoots in the direction he is aiming.
final void PerformAimAction ()
 Action to do when agent has an enemy at sight.
final boolean HaveAgentToShot ()
 To know if an enemy is aimed.
final int GetTeamFromAgentInSight (int _eType)
 To know the team of an enemy in sight.
final int GetClassFromAgentInSight (int _eType)
 To know the class of an enemy in sight.
void CallForMedic ()
 Request for medicine.
void CallForAmmo ()
 Request for ammunition.
void CallForBackup ()
 Request for backup.
void UpdateTargets ()
 Update priority of all 'prepared (to execute)' tasks.
boolean ShouldUpdateTargets ()
 Should we update now all 'prepared (to execute)' tasks?
void ObjectivePackTaken ()
 The agent has got the objective pack.
void SetUpPriorities ()
 Definition of priorities for each kind of task.
void PerformNoAmmoAction ()
 Action to do if this agent cannot shoot.
void PerformTargetReached (CTask _CurrentTask)
 Action to do when this agent reaches the target of current task.
void GenerateEscapePosition ()
 Calculates a new destiny position to escape.
boolean GeneratePath ()
 Calculates a new destiny position to walk.
void CreateControlPoints ()
 Calculates an array of positions for patrolling.
void PerformEscapeAction ()
 Action to do when the agent tries to escape.
boolean GetAgentToAim ()
 Calculates if there is an enemy at sight.
void PerformLookAction ()
 Action to do when the agent is looking at.

Protected Attributes

AID m_Manager = null
 Variable used to store the AID of Manager.
Hashtable m_TaskList
 List of prepared to execut tasks.
CTask m_CurrentTask
 Variable used to point the current task in execution.
boolean m_bObjectiveCarried
 Variable indicating if this agent is carrying the objective pack (flag).
int m_TaskPriority []
 Array of default values of priorities for each task.
Vector3D m_ControlPoints []
 Array of points used in patrolling task.
int m_iControlPointsIndex
 Current position in array m_ControlPoints.
Vector3D m_AStarPath []
 Array of points used in walking (a calculated) path task.
int m_iAStarPathIndex
 Current position in array m_AStarPath.
ArrayList m_FOVObjects
 List of objects in the agent's Field Of Vision.
CSight m_AimedAgent
 Current aimed enemy.
int m_eTeam
int m_eClass
boolean m_bFighting
 Variable indicating if agent is fighting at this moment.
boolean m_bEscaping
 Variable indicating if agent is escaping at this moment.
CMobile m_Movement
 Current position, direction, and so on.
int m_iSoldiersCount
int m_iMedicsCount
int m_iEngineersCount
int m_iFieldOpsCount
int m_iTeamCount
CThreshold m_Threshold
 Limits of some variables (to trigger some events).
CTerrainMap m_Map
 Current Map.
String m_sMedicService
String m_sAmmoService
String m_sBackupService

Static Protected Attributes

static final int TRANSITION_DEFAULT = 0
static final int TRANSITION_TO_STANDING = 1
static final int TRANSITION_TO_GOTO_TARGET = 2
static final int TRANSITION_TO_TARGET_REACHED = 3
static final int TRANSITION_TO_FIGHTING = 4
static final int MV_OK = 0
static final int MV_CANNOT_GET_POSITION = 1
static final int MV_NOT_MOVED_BY_TIME = 2

Classes

class  FSM_Fighting
class  FSM_GoToTarget
class  FSM_Quit
class  FSM_Standing
class  FSM_TargetReached

Member Function Documentation

void Classes.CTroop.setup  )  [protected]
 

'setup' method of jade agents.

This method perform actions in common to CTroop agents (and derived classes) and calls parent's setup.

Parameters:
- 
Returns:
-

Reimplemented from Classes.CJGomasAgent.

Reimplemented in Classes.CFieldOps, Classes.CMedic, and Classes.CSoldier.

void Classes.CTroop.takeDown  )  [protected]
 

'takeDown' method of jade agents.

This method calls parent's setup.

Parameters:
- 
Returns:
-

Reimplemented from Classes.CJGomasAgent.

final int Classes.CTroop.Move  )  [protected]
 

final int Classes.CTroop.GetHealth  )  [protected]
 

Get the current health of the agent.

Parameters:
- 
Returns:
m_iHealth: current value for health

final int Classes.CTroop.GetAmmo  )  [protected]
 

Get the current ammunition of the agent.

Parameters:
- 
Returns:
m_iAmmo: current value for ammo

final int Classes.CTroop.GetStamina  )  [protected]
 

Get the current stamina of the agent.

Parameters:
- 
Returns:
m_iStamina: current value for stamina bar

final void Classes.CTroop.UseStamina  )  [protected]
 

Use stamina from the stamina bar if possible (there is at least 5 units).

Parameters:
- 
Returns:
-

final int Classes.CTroop.GetPower  )  [protected]
 

Get the current power of the agent.

Parameters:
- 
Returns:
m_iPower: current value for power bar

final void Classes.CTroop.UsePower  )  [protected]
 

Use power from the power bar if possible (there is at least 25 units).

Power bar is reduced in 25 units.

Parameters:
- 
Returns:
-

final void Classes.CTroop.AddServiceType String  _sServiceType  )  [protected]
 

Adds a type of service to the service type list.

This method registers all types of services to offer in a list, excluding repeated services.

Parameters:
_sServiceType 
Returns:
-

final boolean Classes.CTroop.CheckStaticPosition  )  [protected]
 

Checks our position on the static map.

This method checks if our position on the static map is valid to walk on, and returns the result. It must be called before to update variables.

Parameters:
- 
Returns:
TRUE (agent can walk on) | FALSE (agent cannot walk on)

final boolean Classes.CTroop.CheckStaticPosition double  _x,
double  _z
[protected]
 

Checks a position on the static map.

This method checks if a position on the static map is valid to walk on, and returns the result.

Parameters:
_x 
_z 
Returns:
TRUE (agent can walk on) | FALSE (agent cannot walk on)

final void Classes.CTroop.AddTask int  _tTypeOfTask,
AID  _Owner,
String  _sContent
[protected]
 

Adds a task to the task list.

This method adds a task to the task list with the default priority in agreement to the type of task. If there is a task of same type and same owner, it doesn't create a new task: simply substitutes some attributes with newer values.

Parameters:
_tTypeOfTask one of the defined types of tasks.
_Owner the agent that induces the creation of the task.
_sContent is a position: ( x , y , z ) .
Returns:
-

final void Classes.CTroop.AddTask int  _tTypeOfTask,
AID  _Owner,
String  _sContent,
int  _iPriority
[protected]
 

Adds a task to the task list with a modified priority.

This method adds a task to the task list with the priority passed as parameter, non the standard priority. If there is a task of same type and same owner, it doesn't create a new task: simply substitutes some attributes with newer values.

Parameters:
_tTypeOfTask one of the defined types of tasks.
_Owner the agent that induces the creation of the task.
_sContent is a position: ( x , y , z ) .
_iPriority priority of task
Returns:
-

final void Classes.CTroop.Look  )  [protected]
 

The agent looks in the direction he is walking.

This method sends a FIPA INFORM message to Manager. Once message is sent, agent will be blocked waiting a response message from Manager. The content of received message is stored in the variable m_FOVObjects.

Parameters:
- 
Returns:
-

final boolean Classes.CTroop.Shot int  _iShotNum  )  [protected]
 

The agent shoots in the direction he is aiming.

This method sends a FIPA INFORM message to Manager. Once message is sent, the variable m_iAmmo is decremented.

Parameters:
_iShotNum 
Returns:
TRUE (shot done) | FALSE (cannot shoot, has no ammo)

final void Classes.CTroop.PerformAimAction  )  [protected]
 

Action to do when agent has an enemy at sight.

This method is called when agent has looked and has found an enemy, calculating (in agreement to the enemy position) the new direction where is aiming.

Parameters:
- 
Returns:
-

final boolean Classes.CTroop.HaveAgentToShot  )  [protected]
 

To know if an enemy is aimed.

This method is called just before agent can shoot. If an enemy is aimed, a value of TRUE is returned. Otherwise, the return value is FALSE. The result is used to decide if agent must shoot.

Parameters:
- 
Returns:
TRUE (aimed enemy) | FALSE (no aimed enemy)

final int Classes.CTroop.GetTeamFromAgentInSight int  _eType  )  [protected]
 

To know the team of an enemy in sight.

This method usually is called in the GetAgentToAim method to get the team of an enemy in sight from the variable _eType (which is a strange combination of m_eTeam and m_eClass variables). The result is returned.

Parameters:
_eType,: (team + class) of an agent.
Returns:
TEAM_ALLIED | TEAM_AXIS

final int Classes.CTroop.GetClassFromAgentInSight int  _eType  )  [protected]
 

To know the class of an enemy in sight.

This method usually is called in the GetAgentToAim method to get the class of an enemy in sight from the variable _eType (which is a strange combination of m_eTeam and m_eClass variables). The result is returned.

Parameters:
_eType,: (team + class) of an agent.
Returns:
CLASS_NONE | CLASS_SOLDIER | CLASS_MEDIC | CLASS_ENGINEER | CLASS_FIELDOPS

void Classes.CTroop.CallForMedic  )  [protected]
 

Request for medicine.

This method sends a FIPA REQUEST message to all agents who offers the m_sMedicService service.

The content of message is: ( x , y , z ) ( health ) .

Variable m_iMedicsCount is updated.

It's very useful to overload this method.

Parameters:
- 
Returns:
-

void Classes.CTroop.CallForAmmo  )  [protected]
 

Request for ammunition.

This method sends a FIPA REQUEST message to all agents who offers the m_sAmmoService service.

The content of message is: ( x , y , z ) ( ammo ) .

Variable m_iFieldOpsCount is updated.

It's very useful to overload this method.

Parameters:
- 
Returns:
-

void Classes.CTroop.CallForBackup  )  [protected]
 

Request for backup.

This method sends a FIPA REQUEST message to all agents who offers the m_sBackupService service.

The content of message is: ( x , y , z ) ( SoldiersCount ) .

Variable m_iSoldiersCount is updated.

It's very useful to overload this method.

Parameters:
- 
Returns:
-

void Classes.CTroop.UpdateTargets  )  [protected]
 

Update priority of all 'prepared (to execute)' tasks.

This method is invoked in the state STANDING, and it's used to re-calculate the priority of all tasks (targets) int the task list of the agent. The reason is because JGOMAS Kernel always execute the maximum priority task.

It's very useful to overload this method.

Parameters:
- 
Returns:
-

boolean Classes.CTroop.ShouldUpdateTargets  )  [protected]
 

Should we update now all 'prepared (to execute)' tasks?

This method is a decision function invoked in the state GOTO_TARGET. A value of TRUE break out the inner loop, making possible to JGOMAS Kernel extract a more priority task, or update some attributes of the current task. By default, the return value is FALSE, so we execute the current task until it finalizes.

It's very useful to overload this method.

Parameters:
- 
Returns:
FALSE

void Classes.CTroop.ObjectivePackTaken  )  [protected]
 

The agent has got the objective pack.

This method is called when this agent walks on the objective pack, getting it.

It's very useful to overload this method.

Parameters:
- 
Returns:
-

void Classes.CTroop.SetUpPriorities  )  [protected]
 

Definition of priorities for each kind of task.

This method can be implemented in CTroop's derived classes to define the task's priorities in agreement to the role of the new class. Priorities must be defined in the array m_TaskPriority.

It's very useful to overload this method.

Parameters:
- 
Returns:
-

Reimplemented in Classes.CFieldOps, Classes.CMedic, and Classes.CSoldier.

void Classes.CTroop.PerformNoAmmoAction  )  [protected]
 

Action to do if this agent cannot shoot.

This method is called when the agent try to shoot, but has no ammo. The agent will spit enemies out. :-)

It's very useful to overload this method.

Parameters:
- 
Returns:
-

void Classes.CTroop.PerformTargetReached CTask  _CurrentTask  )  [protected]
 

Action to do when this agent reaches the target of current task.

This method is called when the agent goes to state TARGET_REACHED. In agreement to current task, agent must realize some actions (for example, to get next point to walk from patrolling path). The actions in common to all roles are implemented at this level of hierarchy: TASK_PATROLLING, TASK_WALKING_PATH, TASK_RUN_AWAY.

It's very useful to overload this method.

Parameters:
_CurrentTask 
Returns:
-

Reimplemented in Classes.CFieldOps, and Classes.CMedic.

void Classes.CTroop.GenerateEscapePosition  )  [protected]
 

Calculates a new destiny position to escape.

This method is called before the agent creates a task for escaping. It generates a valid random point in a radius of 50 units. Once position is calculated, agent updates its destiny to the new position, and automatically calculates the new direction.

It's very useful to overload this method.

Parameters:
- 
Returns:
-

boolean Classes.CTroop.GeneratePath  )  [protected]
 

Calculates a new destiny position to walk.

This method is called before the agent creates a TASK_GOTO_POSITION task. It will try (for 5 attempts) to generate a valid random point in a radius of 20 units. If it doesn't generate a valid position in this cycle, it will try it in next cycle. Once a position is calculated, agent updates its destination to the new position, and automatically calculates the new direction.

It's very useful to overload this method.

Parameters:
- 
Returns:
TRUE: valid position generated / FALSE cannot generate a valid position

void Classes.CTroop.CreateControlPoints  )  [protected]
 

Calculates an array of positions for patrolling.

When this method is called, it creates an array of n random positions. For medics and fieldops, the rank of n is [1..1]. For soldiers, the rank of n is [5..10].

It's very useful to overload this method.

Parameters:
- 
Returns:
-

void Classes.CTroop.PerformEscapeAction  )  [protected]
 

Action to do when the agent tries to escape.

This method is called just before this agent creates a TASK_RUN_AWAY task. By default, the only thing it does is to reset its aimed enemy: m_AimedAgent = null. If it's overloaded, it's convenient to call parent's method.

It's very useful to overload this method.

Parameters:
- 
Returns:
-

boolean Classes.CTroop.GetAgentToAim  )  [protected]
 

Calculates if there is an enemy at sight.

This method scans the list m_FOVObjects (objects in the Field Of View of the agent) looking for an enemy. If an enemy agent is found, a value of TRUE is returned and variable m_AimedAgent is updated. Note that there is no criterion (proximity, etc.) for the enemy founded. Otherwise, the return value is FALSE.

It's very useful to overload this method.

Parameters:
- 
Returns:
TRUE: enemy found / FALSE enemy not found

void Classes.CTroop.PerformLookAction  )  [protected]
 

Action to do when the agent is looking at.

This method is called just after Look method has ended. At this point, the only thing it does is to update variable m_bFighting calling the GetAgentToAim(); method.

It's very useful to overload this method.

Parameters:
- 
Returns:
-


Member Data Documentation

AID Classes.CTroop.m_Manager = null [protected]
 

Variable used to store the AID of Manager.

Hashtable Classes.CTroop.m_TaskList [protected]
 

List of prepared to execut tasks.

CTask Classes.CTroop.m_CurrentTask [protected]
 

Variable used to point the current task in execution.

boolean Classes.CTroop.m_bObjectiveCarried [protected]
 

Variable indicating if this agent is carrying the objective pack (flag).

int Classes.CTroop.m_TaskPriority[] [protected]
 

Array of default values of priorities for each task.

Vector3D Classes.CTroop.m_ControlPoints[] [protected]
 

Array of points used in patrolling task.

int Classes.CTroop.m_iControlPointsIndex [protected]
 

Current position in array m_ControlPoints.

Vector3D Classes.CTroop.m_AStarPath[] [protected]
 

Array of points used in walking (a calculated) path task.

int Classes.CTroop.m_iAStarPathIndex [protected]
 

Current position in array m_AStarPath.

ArrayList Classes.CTroop.m_FOVObjects [protected]
 

List of objects in the agent's Field Of Vision.

CSight Classes.CTroop.m_AimedAgent [protected]
 

Current aimed enemy.

final int Classes.CTroop.ARG_TEAM = 0 [static]
 

final int Classes.CTroop.TEAM_NONE = 0 [static]
 

final int Classes.CTroop.TEAM_ALLIED = 100 [static]
 

final int Classes.CTroop.TEAM_AXIS = 200 [static]
 

final int Classes.CTroop.CLASS_NONE = 0 [static]
 

final int Classes.CTroop.CLASS_SOLDIER = 1 [static]
 

final int Classes.CTroop.CLASS_MEDIC = 2 [static]
 

final int Classes.CTroop.CLASS_ENGINEER = 3 [static]
 

final int Classes.CTroop.CLASS_FIELDOPS = 4 [static]
 

final int Classes.CTroop.TRANSITION_DEFAULT = 0 [static, protected]
 

final int Classes.CTroop.TRANSITION_TO_STANDING = 1 [static, protected]
 

final int Classes.CTroop.TRANSITION_TO_GOTO_TARGET = 2 [static, protected]
 

final int Classes.CTroop.TRANSITION_TO_TARGET_REACHED = 3 [static, protected]
 

final int Classes.CTroop.TRANSITION_TO_FIGHTING = 4 [static, protected]
 

final int Classes.CTroop.MV_OK = 0 [static, protected]
 

final int Classes.CTroop.MV_CANNOT_GET_POSITION = 1 [static, protected]
 

final int Classes.CTroop.MV_NOT_MOVED_BY_TIME = 2 [static, protected]
 

int Classes.CTroop.m_eTeam [protected]
 

int Classes.CTroop.m_eClass [protected]
 

boolean Classes.CTroop.m_bFighting [protected]
 

Variable indicating if agent is fighting at this moment.

boolean Classes.CTroop.m_bEscaping [protected]
 

Variable indicating if agent is escaping at this moment.

CMobile Classes.CTroop.m_Movement [protected]
 

Current position, direction, and so on.

..

int Classes.CTroop.m_iSoldiersCount [protected]
 

int Classes.CTroop.m_iMedicsCount [protected]
 

int Classes.CTroop.m_iEngineersCount [protected]
 

int Classes.CTroop.m_iFieldOpsCount [protected]
 

int Classes.CTroop.m_iTeamCount [protected]
 

CThreshold Classes.CTroop.m_Threshold [protected]
 

Limits of some variables (to trigger some events).

CTerrainMap Classes.CTroop.m_Map [protected]
 

Current Map.

String Classes.CTroop.m_sMedicService [protected]
 

String Classes.CTroop.m_sAmmoService [protected]
 

String Classes.CTroop.m_sBackupService [protected]
 


The documentation for this class was generated from the following file:
Generated on Fri Dec 16 20:13:56 2005 for JGomas by  doxygen 1.4.5