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. More... | |
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. More... | |
ChaseOperation () | |
Constructor for this operation. More... | |
virtual bool | GetEndPosition (NPC *npc, const csVector3 &myPos, const iSector *mySector, csVector3 &endPos, iSector *&endSector) |
Calculate the end position for this chase. More... | |
virtual float | GetOffset (NPC *npc) const |
Resolve the offset attribute. More... | |
virtual float | GetVelocity (NPC *npc) |
Return the velocity adjusted by adaptivVelScale. More... | |
virtual bool | Load (iDocumentNode *node) |
Load Operation Parameters from xml. More... | |
virtual ScriptOperation * | MakeCopy () |
Make a deep copy of this operation. More... | |
virtual gemNPCActor * | UpdateChaseTarget (NPC *npc, const csVector3 &myPos, const iSector *mySector) |
Call to update the target to chase. More... | |
virtual bool | UpdateEndPosition (NPC *npc, const csVector3 &myPos, const iSector *mySector, csVector3 &endPos, iSector *&endSector) |
Update end position for moving targets. More... | |
virtual | ~ChaseOperation () |
Destructor for this operation. More... | |
![]() | |
virtual OperationResult | Advance (float timedelta, NPC *npc) |
bool | EndPointChanged (const csVector3 &endPos, const iSector *endSector) const |
virtual void | InterruptOperation (NPC *npc) |
MovementOperation (const char *name) | |
virtual OperationResult | Run (NPC *npc, bool interrupted) |
virtual | ~MovementOperation () |
![]() | |
void | AddRandomRange (csVector3 &dest, float radius, float margin=0.0) |
Move a point somwhere random within radius of the orignial point. More... | |
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 |
bool | LoadCheckMoveOk (iDocumentNode *node) |
Load attributes for the CheckMoveOk check. More... | |
bool | LoadVelocity (iDocumentNode *node) |
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 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. More... | |
![]() | |
MovementOperation (const MovementOperation *other) | |
![]() | |
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) |
Protected Attributes | |
Instance varaibles | |
These parameters are local to one instance of the operation. | |
EID | targetEID |
The EID of the chased target. More... | |
float | offsetAngle |
The actual offset angle in radians. More... | |
csVector3 | offsetDelta |
The actual delta relative to target. More... | |
float | adaptivVelScale |
Scale of velocity for adaptive vel. More... | |
MathScript * | calcAdaptivVelocity |
This is the particular calculation for adaptiv velocity. More... | |
Operation Parameters | |
These parameters are initialized by the Load function and copied by the MakeCopy function. | |
int | type |
The type of chase to perform. More... | |
float | searchRange |
Search for targets within this range. More... | |
float | chaseRange |
Chase as long targets are within this range. < Chase forever if set to -1. More... | |
csString | offsetAttribute |
Used to stop a offset from the target. More... | |
float | offsetAngleMax |
The maximum offset angle in radians. More... | |
float | sideOffset |
Add a offset to the side of the target. More... | |
bool | offsetRelativeHeading |
Set to true will make the offset relative target heading. More... | |
csString | adaptivVelocityScript |
Script to do adaptiv velocity adjustments. More... | |
![]() | |
csString | action |
The animation used during chase. More... | |
float | currentDistance |
The distance to the current local destination. More... | |
csVector3 | endPos |
iSector * | endSector |
csRef< iCelHPath > | path |
![]() | |
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... | |
Behavior * | parent |
State | state |
float | vel |
Shared linear velocity, used by all that moves. More... | |
VelSource | velSource |
Source used for velocity. More... | |
Static Protected Attributes | |
static const char * | typeStr [] |
Additional Inherited Members | |
![]() | |
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 } |
![]() | |
static void | StopMovement (NPC *npc) |
Utility function used by many operation to stop movement of an NPC. More... | |
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.
|
protected |
Enumerator | |
---|---|
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.
|
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
|
inlinevirtual |
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 |
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 |
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 |
Make a deep copy of this operation.
MakeCopy will make a copy of all Operation Parameters and reset each Instance Variable.
Implements ScriptOperation.
|
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 |
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.
|
protected |
Script to do adaptiv velocity adjustments.
Definition at line 501 of file npcoperations.h.
|
protected |
Scale of velocity for adaptive vel.
Definition at line 484 of file npcoperations.h.
|
protected |
This is the particular calculation for adaptiv velocity.
Definition at line 485 of file npcoperations.h.
|
protected |
Chase as long targets are within this range. < Chase forever if set to -1.
Definition at line 495 of file npcoperations.h.
|
protected |
The actual offset angle in radians.
Definition at line 482 of file npcoperations.h.
|
protected |
The maximum offset angle in radians.
Definition at line 498 of file npcoperations.h.
|
protected |
Used to stop a offset from the target.
Definition at line 497 of file npcoperations.h.
|
protected |
The actual delta relative to target.
Definition at line 483 of file npcoperations.h.
|
protected |
Set to true will make the offset relative target heading.
Definition at line 500 of file npcoperations.h.
|
protected |
Search for targets within this range.
Definition at line 494 of file npcoperations.h.
|
protected |
Add a offset to the side of the target.
Definition at line 499 of file npcoperations.h.
|
protected |
The EID of the chased target.
Definition at line 481 of file npcoperations.h.
|
protected |
The type of chase to perform.
Definition at line 493 of file npcoperations.h.
|
staticprotected |
Definition at line 512 of file npcoperations.h.