Planeshift
ScriptOperation Class Referenceabstract

This is the base class for all operations in action scripts. More...

#include <npcoperations.h>

Public Types

enum  OperationResult { OPERATION_NOT_COMPLETED, OPERATION_COMPLETED, OPERATION_FAILED }
 
enum  State { READY_TO_RUN, RUNNING, INTERRUPTED, COMPLETED }
 
enum  VelSource { VEL_DEFAULT, VEL_USER, VEL_WALK, VEL_RUN }
 

Public Member Functions

void AddRandomRange (csVector3 &dest, float radius, float margin=0.0)
 Move a point somwhere random within radius of the orignial point. More...
 
virtual OperationResult Advance (float timedelta, NPC *npc)
 
virtual bool AtInterruptedAngle (const csVector3 &pos, const iSector *sector, float angle)
 
virtual bool AtInterruptedAngle (NPC *npc)
 
virtual bool AtInterruptedPosition (const csVector3 &pos, const iSector *sector)
 
virtual bool AtInterruptedPosition (NPC *npc)
 
virtual bool CheckEndPointOk (NPC *npc, const csVector3 &myPos, iSector *mySector, const csVector3 &endPos, iSector *endSector)
 Check if the end point where ok. More...
 
virtual bool CheckMoveOk (NPC *npc, csVector3 oldPos, iSector *oldSector, const csVector3 &newPos, iSector *newSector, int resultFromExtrapolate)
 Check if the move where ok. More...
 
void CopyCheckMoveOk (ScriptOperation *source)
 Copy CheckMoveOk paramters from the source script. More...
 
virtual void Failure (NPC *npc)
 Called when the run operation return OPERATION_FAILED. More...
 
virtual float GetAngularVelocity (NPC *npc)
 
virtual const csString & GetCollisionPerception (NPC *npc)
 Return the Collision perception event name. More...
 
virtual const csString & GetFallingPerception (NPC *npc)
 Return the Falling perception event name. More...
 
virtual const csString & GetInBoundsPerception (NPC *npc)
 Return the In Bounds perception event name. More...
 
virtual const char * GetName () const
 
virtual const csString & GetOutOfBoundsPerception (NPC *npc)
 Return the Out of Bounds perception event name. More...
 
virtual State GetState () const
 
virtual float GetVelocity (NPC *npc)
 Return the velocity for the npc. More...
 
virtual void InterruptOperation (NPC *npc)
 
virtual bool Load (iDocumentNode *node)
 
bool LoadCheckMoveOk (iDocumentNode *node)
 Load attributes for the CheckMoveOk check. More...
 
bool LoadVelocity (iDocumentNode *node)
 
virtual ScriptOperationMakeCopy ()=0
 
virtual OperationResult Run (NPC *npc, bool interrupted)=0
 
 ScriptOperation (const char *sciptName)
 
 ScriptOperation (const ScriptOperation *other)
 
void SetAnimation (NPC *npc, const char *name)
 This function will set an animation for the NPC, the animation will play once. More...
 
void SetParent (Behavior *behavior)
 Set the parent behavior for this operation. More...
 
virtual void SetState (State state)
 
virtual ~ScriptOperation ()
 

Protected Member Functions

int StartMoveTo (NPC *npc, const csVector3 &dest, iSector *sector, float vel, const char *action, float &angle)
 This function is used by MoveTo AND Navigate operations. More...
 
void TurnTo (NPC *npc, const csVector3 &dest, iSector *destsect, csVector3 &forward, float &angle)
 

Static Protected Member Functions

static void StopMovement (NPC *npc)
 Utility function used by many operation to stop movement of an NPC. More...
 

Protected Attributes

float ang_vel
 Shared angular velocity, used by all that rotates. More...
 
bool checkTribeHome
 Set to true if the tribe home should be checked by CheckMoveOk. More...
 
csString collision
 Perception names to use for collision detected by CheckMoveOk. More...
 
int consecCollisions
 Shared by move functions. Used by CheckMoveOk to detect collisions. More...
 
csString failurePerception
 The Perception to fire when a operation return OPERATION_FAILED. More...
 
csString falling
 Perception names to use for fall detected by CheckMoveOk. More...
 
csString inBounds
 Perception names to use for in bounds detected by CheckMoveOk. More...
 
float interrupted_angle
 
csVector3 interrupted_position
 
iSector * interrupted_sector
 
csString name
 
csString outOfBounds
 Perception names to use for out of bounds detected by CheckMoveOk. More...
 
Behaviorparent
 
State state
 
float vel
 Shared linear velocity, used by all that moves. More...
 
VelSource velSource
 Source used for velocity. More...
 

Detailed Description

This is the base class for all operations in action scripts.

We will use these to set animation actions, move and rotate the mob, attack and so forth. These should be mostly visual or physical things, except for the ability to create new perceptions, which can kick off other actions.

Definition at line 69 of file npcoperations.h.

Member Enumeration Documentation

Enumerator
OPERATION_NOT_COMPLETED 

Used to indicate that an operation will complete at a later stage.

OPERATION_COMPLETED 

All parts of this operation has been completed.

OPERATION_FAILED 

The operation failed.

Definition at line 81 of file npcoperations.h.

Enumerator
READY_TO_RUN 
RUNNING 
INTERRUPTED 
COMPLETED 

Definition at line 88 of file npcoperations.h.

Enumerator
VEL_DEFAULT 
VEL_USER 
VEL_WALK 
VEL_RUN 

Definition at line 72 of file npcoperations.h.

Constructor & Destructor Documentation

ScriptOperation::ScriptOperation ( const char *  sciptName)
ScriptOperation::ScriptOperation ( const ScriptOperation other)
virtual ScriptOperation::~ScriptOperation ( )
inlinevirtual

Definition at line 149 of file npcoperations.h.

Member Function Documentation

void ScriptOperation::AddRandomRange ( csVector3 &  dest,
float  radius,
float  margin = 0.0 
)

Move a point somwhere random within radius of the orignial point.

Will add a random part to the dest. The margin can be used to prevent using the margin around the edge of the circle.

Parameters
destThe center position of the cicle. Will return with the new position.
radiusThe radius of the circle.
marginA margin around the circle that will not be used.
virtual OperationResult ScriptOperation::Advance ( float  timedelta,
NPC npc 
)
virtual
virtual bool ScriptOperation::AtInterruptedAngle ( const csVector3 &  pos,
const iSector *  sector,
float  angle 
)
virtual
virtual bool ScriptOperation::AtInterruptedAngle ( NPC npc)
virtual
virtual bool ScriptOperation::AtInterruptedPosition ( const csVector3 &  pos,
const iSector *  sector 
)
virtual
virtual bool ScriptOperation::AtInterruptedPosition ( NPC npc)
virtual
virtual bool ScriptOperation::CheckEndPointOk ( NPC npc,
const csVector3 &  myPos,
iSector *  mySector,
const csVector3 &  endPos,
iSector *  endSector 
)
virtual

Check if the end point where ok.

Check if a move operation has collided and not ended in right position. Fire perceptions if not at end position.

virtual bool ScriptOperation::CheckMoveOk ( NPC npc,
csVector3  oldPos,
iSector *  oldSector,
const csVector3 &  newPos,
iSector *  newSector,
int  resultFromExtrapolate 
)
virtual

Check if the move where ok.

Check if a move operation has collided, walked out of bounds, or walked in bound. Will fire perceptions at these events with the names given by

See also
LoadCheckMoveOk
void ScriptOperation::CopyCheckMoveOk ( ScriptOperation source)

Copy CheckMoveOk paramters from the source script.

Parameters
sourceThe script to copy from.
virtual void ScriptOperation::Failure ( NPC npc)
virtual

Called when the run operation return OPERATION_FAILED.

Default implementation will percept with the failure perception

virtual float ScriptOperation::GetAngularVelocity ( NPC npc)
virtual
virtual const csString& ScriptOperation::GetCollisionPerception ( NPC npc)
virtual

Return the Collision perception event name.

Will use the perception of the operation if defined, or it will check if a global perception event name is defined for the brain.

virtual const csString& ScriptOperation::GetFallingPerception ( NPC npc)
virtual

Return the Falling perception event name.

Will use the falling perception of the operation if defined, or it will check if a global fall perception event name is defined for the brain.

virtual const csString& ScriptOperation::GetInBoundsPerception ( NPC npc)
virtual

Return the In Bounds perception event name.

Will use the perception of the operation if defined, or it will check if a global perception event name is defined for the brain.

virtual const char* ScriptOperation::GetName ( ) const
inlinevirtual

Definition at line 271 of file npcoperations.h.

virtual const csString& ScriptOperation::GetOutOfBoundsPerception ( NPC npc)
virtual

Return the Out of Bounds perception event name.

Will use the perception of the operation if defined, or it will check if a global perception event name is defined for the brain.

virtual State ScriptOperation::GetState ( ) const
inlinevirtual

Definition at line 164 of file npcoperations.h.

virtual float ScriptOperation::GetVelocity ( NPC npc)
virtual

Return the velocity for the npc.

Determined by the script this could be the walk, run, or a defined velocity.

Reimplemented in ChaseOperation.

virtual void ScriptOperation::InterruptOperation ( NPC npc)
virtual
bool ScriptOperation::LoadCheckMoveOk ( iDocumentNode *  node)

Load attributes for the CheckMoveOk check.

Parameters
nodeThe node to load attributes from.
bool ScriptOperation::LoadVelocity ( iDocumentNode *  node)
void ScriptOperation::SetAnimation ( NPC npc,
const char *  name 
)

This function will set an animation for the NPC, the animation will play once.

void ScriptOperation::SetParent ( Behavior behavior)

Set the parent behavior for this operation.

virtual void ScriptOperation::SetState ( State  state)
inlinevirtual

Definition at line 160 of file npcoperations.h.

int ScriptOperation::StartMoveTo ( NPC npc,
const csVector3 &  dest,
iSector *  sector,
float  vel,
const char *  action,
float angle 
)
protected

This function is used by MoveTo AND Navigate operations.

static void ScriptOperation::StopMovement ( NPC npc)
staticprotected

Utility function used by many operation to stop movement of an NPC.

void ScriptOperation::TurnTo ( NPC npc,
const csVector3 &  dest,
iSector *  destsect,
csVector3 &  forward,
float angle 
)
protected

Member Data Documentation

float ScriptOperation::ang_vel
protected

Shared angular velocity, used by all that rotates.

Definition at line 122 of file npcoperations.h.

bool ScriptOperation::checkTribeHome
protected

Set to true if the tribe home should be checked by CheckMoveOk.

Definition at line 130 of file npcoperations.h.

csString ScriptOperation::collision
protected

Perception names to use for collision detected by CheckMoveOk.

Definition at line 126 of file npcoperations.h.

int ScriptOperation::consecCollisions
protected

Shared by move functions. Used by CheckMoveOk to detect collisions.

Definition at line 105 of file npcoperations.h.

csString ScriptOperation::failurePerception
protected

The Perception to fire when a operation return OPERATION_FAILED.

Definition at line 117 of file npcoperations.h.

csString ScriptOperation::falling
protected

Perception names to use for fall detected by CheckMoveOk.

Definition at line 129 of file npcoperations.h.

csString ScriptOperation::inBounds
protected

Perception names to use for in bounds detected by CheckMoveOk.

Definition at line 128 of file npcoperations.h.

float ScriptOperation::interrupted_angle
protected

Definition at line 103 of file npcoperations.h.

csVector3 ScriptOperation::interrupted_position
protected

Definition at line 101 of file npcoperations.h.

iSector* ScriptOperation::interrupted_sector
protected

Definition at line 102 of file npcoperations.h.

csString ScriptOperation::name
protected

Definition at line 99 of file npcoperations.h.

csString ScriptOperation::outOfBounds
protected

Perception names to use for out of bounds detected by CheckMoveOk.

Definition at line 127 of file npcoperations.h.

Behavior* ScriptOperation::parent
protected

Definition at line 107 of file npcoperations.h.

State ScriptOperation::state
protected

Definition at line 109 of file npcoperations.h.

float ScriptOperation::vel
protected

Shared linear velocity, used by all that moves.

Definition at line 121 of file npcoperations.h.

VelSource ScriptOperation::velSource
protected

Source used for velocity.

Definition at line 120 of file npcoperations.h.


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