Planeshift
|
Detect and chase a target until reached o out of bound. More...
#include <npcoperations.h>
Public Member Functions | |
float | AdaptivVelocity (NPC *npc, float distance) |
Return adapativ velocity adjustment. | |
csVector3 | CalculateOffsetDelta (NPC *npc, const csVector3 &myPos, const iSector *mySector, const csVector3 &endPos, const iSector *endSector, float endRot) const |
Calculate any offset from target to stop chase. | |
ChaseOperation () | |
Constructor for this operation. | |
virtual bool | GetEndPosition (NPC *npc, const csVector3 &myPos, const iSector *mySector, csVector3 &endPos, iSector *&endSector) |
Calculate the end position for this chase. | |
virtual float | GetOffset (NPC *npc) const |
Resolve the offset attribute. | |
virtual float | GetVelocity (NPC *npc) |
Return the velocity adjusted by adaptivVelScale. | |
virtual bool | Load (iDocumentNode *node) |
Load Operation Parameters from xml. | |
virtual ScriptOperation * | MakeCopy () |
Make a deep copy of this operation. | |
virtual gemNPCActor * | UpdateChaseTarget (NPC *npc, const csVector3 &myPos, const iSector *mySector) |
Call to update the target to chase. | |
virtual bool | UpdateEndPosition (NPC *npc, const csVector3 &myPos, const iSector *mySector, csVector3 &endPos, iSector *&endSector) |
Update end position for moving targets. | |
virtual | ~ChaseOperation () |
Destructor for this operation. | |
Protected Types | |
enum | { NEAREST_ACTOR, NEAREST_NPC, NEAREST_PLAYER, OWNER, TARGET } |
Protected Member Functions | |
ChaseOperation (const ChaseOperation *other) | |
Constructor for this operation, used by the MakeCopy. | |
Protected Attributes | |
Instance varaibles | |
These parameters are local to one instance of the operation. | |
EID | targetEID |
The EID of the chased target. | |
float | offsetAngle |
The actual offset angle in radians. | |
csVector3 | offsetDelta |
The actual delta relative to target. | |
float | adaptivVelScale |
Scale of velocity for adaptive vel. | |
MathScript * | calcAdaptivVelocity |
This is the particular calculation for adaptiv velocity. | |
Operation Parameters | |
These parameters are initialized by the Load function and copied by the MakeCopy function. | |
int | type |
The type of chase to perform. | |
float | searchRange |
Search for targets within this range. | |
float | chaseRange |
Chase as long targets are within this range. < Chase forever if set to -1. | |
csString | offsetAttribute |
Used to stop a offset from the target. | |
float | offsetAngleMax |
The maximum offset angle in radians. | |
float | sideOffset |
Add a offset to the side of the target. | |
bool | offsetRelativeHeading |
Set to true will make the offset relative target heading. | |
csString | adaptivVelocityScript |
Script to do adaptiv velocity adjustments. | |
Static Protected Attributes | |
static const char * | typeStr [] |
Detect and chase a target until reached o out of bound.
Chase updates periodically and turns, moving towards a certain location. This is normally used to chase a targeted player.
Definition at line 474 of file npcoperations.h.
anonymous enum [protected] |
NEAREST_ACTOR |
Sense Players and NPC's. |
NEAREST_NPC |
Sense only NPC's. |
NEAREST_PLAYER |
Sense only players. |
OWNER |
Sense only the owner. |
TARGET |
Sense only target. |
Definition at line 504 of file npcoperations.h.
ChaseOperation::ChaseOperation | ( | const ChaseOperation * | other | ) | [protected] |
Constructor for this operation, used by the MakeCopy.
This constructor will copy all the Operation Parameters from the other operation and initialize all Instance Variables to default values.
ChaseOperation::ChaseOperation | ( | ) |
Constructor for this operation.
Construct this operation and initialzie with default Instance Variables. The Operation Parameters
virtual ChaseOperation::~ChaseOperation | ( | ) | [inline, virtual] |
Destructor for this operation.
Definition at line 532 of file npcoperations.h.
Return adapativ velocity adjustment.
Should return a value percent vise adjustment. Eg. 1.1 adjust velocity up with 10%.
csVector3 ChaseOperation::CalculateOffsetDelta | ( | NPC * | npc, |
const csVector3 & | myPos, | ||
const iSector * | mySector, | ||
const csVector3 & | endPos, | ||
const iSector * | endSector, | ||
float | endRot | ||
) | const |
Calculate any offset from target to stop chase.
The chase support several different modes. The default is that the chaser ends up at the top of the target. This function calculates the offset as a 3D vector that represents the distance from the target to the end point of the chase.
virtual bool ChaseOperation::GetEndPosition | ( | NPC * | npc, |
const csVector3 & | myPos, | ||
const iSector * | mySector, | ||
csVector3 & | endPos, | ||
iSector *& | endSector | ||
) | [virtual] |
Calculate the end position for this chase.
Called by the Run function in the MovementOperation. Will calculate end positon for the chase including any offset deltas.
Implements MovementOperation.
Return the velocity adjusted by adaptivVelScale.
Reimplemented from ScriptOperation.
virtual bool ChaseOperation::Load | ( | iDocumentNode * | node | ) | [virtual] |
Load Operation Parameters from xml.
Load this operation from the given node. This will initialzie the Operation Parameters for this operation.
Reimplemented from MovementOperation.
virtual ScriptOperation* ChaseOperation::MakeCopy | ( | ) | [virtual] |
Make a deep copy of this operation.
MakeCopy will make a copy of all Operation Parameters and reset each Instance Variable.
Implements ScriptOperation.
virtual gemNPCActor* ChaseOperation::UpdateChaseTarget | ( | NPC * | npc, |
const csVector3 & | myPos, | ||
const iSector * | mySector | ||
) | [virtual] |
Call to update the target to chase.
When called the chase target will be checked to se if a new target should be selected. This mostly apply to chases of type NEAREST_*
virtual bool ChaseOperation::UpdateEndPosition | ( | NPC * | npc, |
const csVector3 & | myPos, | ||
const iSector * | mySector, | ||
csVector3 & | endPos, | ||
iSector *& | endSector | ||
) | [virtual] |
Update end position for moving targets.
Called from advance in the MovementOperation. Will update the end position for targets that move. This may include change of target as well.
Implements MovementOperation.
csString ChaseOperation::adaptivVelocityScript [protected] |
Script to do adaptiv velocity adjustments.
Definition at line 501 of file npcoperations.h.
float ChaseOperation::adaptivVelScale [protected] |
Scale of velocity for adaptive vel.
Definition at line 484 of file npcoperations.h.
MathScript* ChaseOperation::calcAdaptivVelocity [protected] |
This is the particular calculation for adaptiv velocity.
Definition at line 485 of file npcoperations.h.
float ChaseOperation::chaseRange [protected] |
Chase as long targets are within this range. < Chase forever if set to -1.
Definition at line 495 of file npcoperations.h.
float ChaseOperation::offsetAngle [protected] |
The actual offset angle in radians.
Definition at line 482 of file npcoperations.h.
float ChaseOperation::offsetAngleMax [protected] |
The maximum offset angle in radians.
Definition at line 498 of file npcoperations.h.
csString ChaseOperation::offsetAttribute [protected] |
Used to stop a offset from the target.
Definition at line 497 of file npcoperations.h.
csVector3 ChaseOperation::offsetDelta [protected] |
The actual delta relative to target.
Definition at line 483 of file npcoperations.h.
bool ChaseOperation::offsetRelativeHeading [protected] |
Set to true will make the offset relative target heading.
Definition at line 500 of file npcoperations.h.
float ChaseOperation::searchRange [protected] |
Search for targets within this range.
Definition at line 494 of file npcoperations.h.
float ChaseOperation::sideOffset [protected] |
Add a offset to the side of the target.
Definition at line 499 of file npcoperations.h.
EID ChaseOperation::targetEID [protected] |
The EID of the chased target.
Definition at line 481 of file npcoperations.h.
int ChaseOperation::type [protected] |
The type of chase to perform.
Definition at line 493 of file npcoperations.h.
const char* ChaseOperation::typeStr[] [static, protected] |
Definition at line 512 of file npcoperations.h.