19 #ifndef __NPCOPERATIONS_H__ 20 #define __NPCOPERATIONS_H__ 27 #include <csgeom/vector3.h> 28 #include <csutil/csstring.h> 39 #include <tools/celhpf.h> 138 int StartMoveTo(
NPC* npc,
const csVector3 &dest, iSector* sector,
float vel,
const char* action,
float &angle);
140 void TurnTo(
NPC* npc,
const csVector3 &dest, iSector* destsect, csVector3 &forward,
float &angle);
156 virtual bool AtInterruptedAngle(
const csVector3 &pos,
const iSector* sector,
float angle);
178 void SendCollitionPerception(
NPC* npc);
187 virtual bool CheckMoveOk(
NPC* npc, csVector3 oldPos, iSector* oldSector,
188 const csVector3 &newPos, iSector* newSector,
int resultFromExtrapolate);
197 const csVector3 &endPos, iSector* endSector);
227 virtual bool Load(iDocumentNode* node);
264 void AddRandomRange(csVector3 &dest,
float radius,
float margin = 0.0);
273 return name.GetDataSafe();
316 virtual bool Load(iDocumentNode* node);
318 bool EndPointChanged(
const csVector3 &endPos,
const iSector* endSector)
const;
320 virtual bool GetEndPosition(
NPC* npc,
const csVector3 &myPos,
const iSector* mySector,
321 csVector3 &endPos, iSector* &endSector) = 0;
323 virtual bool UpdateEndPosition(
NPC* npc,
const csVector3 &myPos,
const iSector* mySector,
324 csVector3 &endPos, iSector* &endSector) = 0;
358 virtual bool Load(iDocumentNode* node);
376 virtual bool Load(iDocumentNode* node);
393 virtual bool Load(iDocumentNode* node);
411 virtual bool Load(iDocumentNode* node);
438 virtual bool Load(iDocumentNode* node);
464 virtual bool Load(iDocumentNode* node);
496 csString offsetAttribute;
512 static const char* typeStr[];
541 csVector3 CalculateOffsetDelta(
NPC* npc,
const csVector3 &myPos,
const iSector* mySector,
542 const csVector3 &endPos,
const iSector* endSector,
550 virtual bool GetEndPosition(
NPC* npc,
const csVector3 &myPos,
const iSector* mySector,
551 csVector3 &endPos, iSector* &endSector);
558 virtual gemNPCActor* UpdateChaseTarget(
NPC* npc,
const csVector3 &myPos,
const iSector* mySector);
565 virtual bool UpdateEndPosition(
NPC* npc,
const csVector3 &myPos,
const iSector* mySector,
566 csVector3 &endPos, iSector* &endSector);
573 virtual bool Load(iDocumentNode* node);
585 float AdaptivVelocity(
NPC* npc,
float distance);
618 virtual bool Load(iDocumentNode* node);
643 virtual bool Load(iDocumentNode* node);
678 virtual bool Load(iDocumentNode* node);
701 virtual bool Load(iDocumentNode* node);
723 virtual bool Load(iDocumentNode* node);
742 virtual bool Load(iDocumentNode* node);
764 virtual bool Load(iDocumentNode* node);
783 virtual bool Load(iDocumentNode* node);
809 virtual bool Load(iDocumentNode* node);
829 virtual bool Load(iDocumentNode* node);
852 virtual bool Load(iDocumentNode* node);
876 virtual bool Load(iDocumentNode* node);
900 virtual bool Load(iDocumentNode* node);
921 HATE_PERCEPTION = 0x0010
934 virtual bool Load(iDocumentNode* node);
951 virtual bool Load(iDocumentNode* node);
985 Waypoint* CalculateWaypoint(
NPC* npc, csVector3 located_pos, iSector* located_sector,
float located_range);
988 virtual bool Load(iDocumentNode* node);
1013 virtual bool Load(iDocumentNode* node);
1034 loopback_op = which;
1035 this->iterations = iterations;
1040 virtual bool Load(iDocumentNode* node);
1066 attackInvisible(false),attackInvincible(false)
1074 virtual bool Load(iDocumentNode* node);
1096 virtual bool Load(iDocumentNode* node);
1129 virtual bool Load(iDocumentNode* node);
1156 virtual bool GetEndPosition(
NPC* npc,
const csVector3 &myPos,
const iSector* mySector,
1157 csVector3 &endPos, iSector* &endSector);
1159 virtual bool UpdateEndPosition(
NPC* npc,
const csVector3 &myPos,
const iSector* mySector,
1160 csVector3 &endPos, iSector* &endSector);
1162 virtual bool Load(iDocumentNode* node);
1192 virtual bool GetEndPosition(
NPC* npc,
const csVector3 &myPos,
const iSector* mySector,
1193 csVector3 &endPos, iSector* &endSector);
1195 virtual bool UpdateEndPosition(
NPC* npc,
const csVector3 &myPos,
const iSector* mySector,
1196 csVector3 &endPos, iSector* &endSector);
1198 virtual bool Load(iDocumentNode* node);
1214 virtual bool Load(iDocumentNode* node);
1245 virtual void Trigger();
1246 virtual csString ToString()
const;
1269 virtual bool Load(iDocumentNode* node);
1271 virtual bool CheckCondition(
NPC* npc);
1293 virtual bool Load(iDocumentNode* node);
1311 virtual bool Load(iDocumentNode* node);
1329 virtual bool Load(iDocumentNode* node);
1355 virtual bool Load(iDocumentNode* node);
1398 op_type=ROT_UNKNOWN;
1407 virtual bool Load(iDocumentNode* node);
1414 float SeekAngle(
NPC* npc,
float targetYRot);
1431 virtual bool Load(iDocumentNode* node);
1458 virtual bool Load(iDocumentNode* node);
1487 virtual bool Load(iDocumentNode* node);
1514 virtual bool Load(iDocumentNode* node);
1532 virtual bool Load(iDocumentNode* node);
1560 virtual bool Load(iDocumentNode* node);
1587 virtual bool Load(iDocumentNode* node);
1605 virtual bool Load(iDocumentNode* node);
1627 virtual bool Load(iDocumentNode* node);
1645 virtual bool Load(iDocumentNode* node);
1663 virtual bool Load(iDocumentNode* node);
1679 virtual bool Load(iDocumentNode* node);
1709 virtual bool Load(iDocumentNode* node);
1730 virtual bool Filter(
const Waypoint* waypoint)
const;
1803 edgeList.DeleteAll();
1830 static float DistanceToDestPoint(
NPC* npc,
const csVector3 &destPos,
const iSector* destSector);
1836 virtual bool Load(iDocumentNode* node);
1863 static const char* typeStr[];
1868 type(TARGET),searchRange(0.0f),watchInvisible(false),watchInvincible(false)
1874 virtual bool Load(iDocumentNode* node);
1882 bool OutOfRange(
NPC* npc);
1906 virtual bool Load(iDocumentNode* node);
TribeType will change the need set used by the npc.
This is the base class for all operations in action scripts.
bool LoadVelocity(iDocumentNode *node)
No Operation(NOP) Operation.
This embodies any perception an NPC might have, or any game event of interest.
const T * GetOffset(const typename ElfClass::Ehdr *elf_header, typename ElfClass::Off offset)
csString random
A random duration to add to the duration.
csString locateOutsideRegion
Locate targets outside a region if a region exist. Default false.
virtual ~RewardOperation()
Resurrect will make the npc to setup a spawn point here.
iSector * endSector
The sector of the target of the navigate.
Turn on and off auto remembering of perceptions.
gemNPCActor * attacked_ent
csString adaptivVelocityScript
Script to do adaptiv velocity adjustments.
Used to indicate that an operation will complete at a later stage.
Visible will make the npc visible.
Sequence will control a named sequence in the world.
virtual OperationResult Run(NPC *npc, bool interrupted)=0
virtual const csString & GetOutOfBoundsPerception(NPC *npc)
Return the Out of Bounds perception event name.
void AddRandomRange(csVector3 &dest, float radius, float margin=0.0)
Move a point somwhere random within radius of the orignial point.
virtual ~TeleportOperation()
virtual bool CheckMoveOk(NPC *npc, csVector3 oldPos, iSector *oldSector, const csVector3 &newPos, iSector *newSector, int resultFromExtrapolate)
Check if the move where ok.
csString command
Command to percept to target if target is a NPC.
float currentDistance
The distance to the current local destination.
csString attackOutsideRegion
Attack even outside region if a region is defined.
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.
virtual ScriptOperation * MakeCopy()=0
void EdgeListClear()
Clear list of edges.
float chaseRange
Chase as long targets are within this range. < Chase forever if set to -1.
Locate is a very powerful function which will find the nearest object of the named tag...
virtual ~UnbuildOperation()
virtual const csString & GetCollisionPerception(NPC *npc)
Return the Collision perception event name.
A MathScript is a mini-program to run.
csWeakRef< gemNPCObject > watchedEnt
virtual float GetVelocity(NPC *npc)
Return the velocity for the npc.
virtual ~LoopEndOperation()
virtual ~MeleeOperation()
virtual ~MoveToOperation()
virtual ~DebugOperation()
csString duration
The duration to wait before continue.
int type
The type of chase to perform.
csString collision
Perception names to use for collision detected by CheckMoveOk.
virtual ~TribeTypeOperation()
csString outOfBounds
Perception names to use for out of bounds detected by CheckMoveOk.
Memorize will make the npc to setup a spawn point here.
virtual ~BuildOperation()
void CopyCheckMoveOk(ScriptOperation *source)
Copy CheckMoveOk paramters from the source script.
csList< Edge * > edgeList
virtual void InterruptOperation(NPC *npc)
csString cmd
The emote command.
Wait will simply set the mesh animation to something and sit there for the desired number of seconds...
ProgressScriptOperation()
csString action
The animation used during chase.
virtual ~ReproduceOperation()
Structure to hold located positions.
csString delayed
If set this perception should be delayed.
Represents the Edge in a PathNetwork.
float searchRange
Used for watch of type NEAREST_*.
float searchRange
Search for targets within this range.
A set of operations building a generic behavior for a NPC.
csVector3 offsetDelta
The actual delta relative to target.
void TurnTo(NPC *npc, const csVector3 &dest, iSector *destsect, csVector3 &forward, float &angle)
void SetParent(Behavior *behavior)
Set the parent behavior for this operation.
bool target
True if this is should go to the target of the NPC.
A waypoint is a specified circle on the map with a name, location, and a list of waypoints it is conn...
float vel
Shared linear velocity, used by all that moves.
NPC::Locate storedStaticLocated
Watch operation will tell if the targt goes out of range.
virtual bool CheckEndPointOk(NPC *npc, const csVector3 &myPos, iSector *mySector, const csVector3 &endPos, iSector *endSector)
Check if the end point where ok.
psPathPoint * currentPathPoint
The current local destination.
Implement the reward NPC script operation.
bool sit
True if sit false for stand.
virtual bool AtInterruptedAngle(const csVector3 &pos, const iSector *sector, float angle)
virtual ~MovementOperation()
csVector3 endPos
The end position of the target of the navigate.
csString resource
The name of the resource to work for.
TargetType target
Hold the target for the perception, default SELF.
Reproduce will make the npc to setup a spawn point here.
virtual const csString & GetInBoundsPerception(NPC *npc)
Return the In Bounds perception event name.
Rotating requires storing or determining the angle to rotate to, and the animation action...
virtual ~AssessOperation()
csString type
The type value of the perception.
Drop will make the NPC drop whatever he is holding.
float currentDistance
The distance to the current local destination.
csString inBounds
Perception names to use for in bounds detected by CheckMoveOk.
csString type
Type of items to loot.
virtual ~HateListOperation()
Dequip will tell the npc to dequip a item.
float ang_vel
Shared angular velocity, used by all that rotates.
virtual ~ProgressScriptOperation()
virtual ~RotateOperation()
virtual ~TransferOperation()
static void StopMovement(NPC *npc)
Utility function used by many operation to stop movement of an NPC.
virtual ~NavigateOperation()
Navigate moves the NPC to the position and orientation of the last located thing. ...
TribeHome will make the npc to setup a spawn point here.
virtual float GetAngularVelocity(NPC *npc)
Sense Players and NPC's.
SetBuffer will set a buffer for tribe or npc.
Let the NPC change brain.
csString perception
The perception name to send.
csString falling
Perception names to use for fall detected by CheckMoveOk.
Talk will tell the npc to communicate to a nearby entity.
float deltaHate
Added to hate if DELTA_HATE is set.
void SetAnimation(NPC *npc, const char *name)
This function will set an animation for the NPC, the animation will play once.
float maxRange
Is there a max range for this, 0.0 is without limit.
csString destination
Alternate destination instead of "Active" locate.
Script will make the progression script run at server.
csString condition
A condition for when the perception should be fired.
Emote will make the NPC show an emotion.
virtual ~CopyLocateOperation()
csString magicalAssessmentPerception
csString resource
The Resource to be rewarded to the tribe.
Teleport will teleport the NPC to the target position.
virtual ~LoopBeginOperation()
Edge * currentEdge
The current edge.
TalkType talkType
What kind of talk, default say.
float adaptivVelScale
Scale of velocity for adaptive vel.
csString memoryCheck
Used to keep memory name in case coordinates are taken from there.
csString attackMostHatedTribeTarget
Melee operation "tribe" attribute. When set to true the < melee operation will use the most hated of ...
virtual OperationResult Advance(float timedelta, NPC *npc)
virtual ~WatchOperation()
virtual void SetState(State state)
Wander auto-navigates randomly between a network of waypoints specified in the DB.
This object represents each NPC managed by this superclient.
csVector3 currentPointOffset
The offset used for current local dest.
csString scriptName
The name of the script to run.
float maxHate
Hate should have a max value if MAX_HATE is set.
iSector * interrupted_sector
Pickup will tell the npc to pickup a nearby entity (or fake it).
int count
The number of the resource to reward to the tribe.
csString failedPerception
A perception to fire if the condition fails.
WanderRouteFilter wanderRouteFilter
Moving to a spot entails a position vector, a linear velocity, and an animation action.
Abstract common class for Move operations that use paths.
virtual ~CircleOperation()
All parts of this operation has been completed.
virtual ~ResurrectOperation()
EID targetEID
The EID of the chased target.
virtual bool AtInterruptedPosition(const csVector3 &pos, const iSector *sector)
MoveOperation(const char *n)
virtual ~MovePathOperation()
virtual void Failure(NPC *npc)
Called when the run operation return OPERATION_FAILED.
Moving entails a circle with radius at a velocity and an animation action.
virtual ~PickupOperation()
virtual ~DequipOperation()
ShareMemories will make the npc share memoreis with tribe.
Iterator base class for Forward and Reverse Iterators.
float offsetAngleMax
The maximum offset angle in radians.
LoopEnd operation will jump back to the beginning of the loop.
Transfer will transfer a item from the NPC to a target.
bool offsetRelativeHeading
Set to true will make the offset relative target heading.
virtual ~ChangeBrainOperation()
virtual ~EquipOperation()
bool locateInvisible
Locate invisible targets.
float endAngle
The angle of the target.
virtual const csString & GetFallingPerception(NPC *npc)
Return the Falling perception event name.
psPath::Direction direction
Will unbuild a tribe building.
csString overallAssessmentPerception
Sense Players and NPC's.
float absoluteHate
Hate should be set to this value if ABS_HATE is set.
Melee will tell the npc to attack the most hated entity within range.
float offsetAngle
The actual offset angle in radians.
virtual ~DeleteNPCOperation()
Let the NPC delete it self.
Sit will make the NPC sit or stand.
Moving entails a velocity vector and an animation action.
virtual ~ControlOperation()
bool talkPublic
Should this be public or only to the target.
csVector3 interrupted_position
virtual ~PerceptOperation()
MathScript * calcAdaptivVelocity
This is the particular calculation for adaptiv velocity.
Edge::Iterator * currentPathPointIterator
The current iterator for path points.
csString talkText
The text to send to the clients.
int consecCollisions
Shared by move functions. Used by CheckMoveOk to detect collisions.
virtual const char * GetName() const
virtual ~ChaseOperation()
Destructor for this operation.
csString failurePerception
The Perception to fire when a operation return OPERATION_FAILED.
Debug will turn on and off debug for the npc.
virtual bool Load(iDocumentNode *node)
Invisible will make the npc invisible.
bool checkTribeHome
Set to true if the tribe home should be checked by CheckMoveOk.
csString physicalAssessmentPerception
Work will make the NPC work for a resource.
virtual ~VisibleOperation()
float minHate
Hate should bave a min value if MIN_HATE is set.
float sideOffset
Add a offset to the side of the target.
Loot will make the NPC loot specified items.
Template class for implementing waypoint filtering when calculating routes.
virtual ~InvisibleOperation()
Equip will tell the npc to equip a item.
csList< Edge * >::Iterator edgeIterator
bool locateInvincible
Locate invincible targets.
Vel set the velocity source of the brain to run or walk.
virtual ~SequenceOperation()
VelSource velSource
Source used for velocity.
All scheduled events must inherit from this class.
Will Set the busy indicator for an NPC.
Eat will take a bite of a nearby dead actor and add resource to tribe wealth.
ScriptOperation(const char *sciptName)
virtual ~SetBufferOperation()
virtual ~AutoMemorizeOperation()
virtual State GetState() const
LoopBegin operation will only print LoopBegin for debug purpose.
virtual ~VelSourceOperation()
MathScript * calcCondition
This is the particular calculation for condition.
Represents a point on a path between two waypoints.
psNPCCommandsMessage::PerceptionTalkType TalkType
WanderRouteFilter(WanderOperation *parent)
virtual ~ScriptOperation()
virtual ~ShareMemoriesOperation()
MovePath specifies the name of a path and an animation action.
Send a custon perception from a behavior script.
virtual ~MemorizeOperation()
Let the NPC cast a spell.
The message sent from server to superclient after successful login.
virtual ~TribeHomeOperation()
virtual ~LocateOperation()
LoopEndOperation(int which, int iterations)
Will build a tribe building.
Detect and chase a target until reached o out of bound.
bool LoadCheckMoveOk(iDocumentNode *node)
Load attributes for the CheckMoveOk check.
ControlOperation(bool control)
virtual ~EmoteOperation()
Will send an assessment request to the server.