26 #ifndef SAGA2_MOTION_H 27 #define SAGA2_MOTION_H 29 #include "saga2/actor.h" 34 struct StandingTileInfo;
36 extern const StaticTilePoint dirTable[];
37 extern const StaticTilePoint incDirTable[];
40 const int kGravity = 2;
41 const int kWalkSpeed = 4;
42 const int kSlowWalkSpeed = 2;
43 const int kRunSpeed = 8;
44 const int kWalkSpeedDiag = 3;
45 const int kRunSpeedDiag = 6;
46 const int kAngleThresh = 24;
48 enum MotionThreadReturnValues {
68 void setObjectSurface(GameObject *obj, StandingTileInfo &sti);
94 friend class PathRequest;
95 friend class DestinationPathRequest;
96 friend class WanderPathRequest;
98 friend void RequestPath(
MotionTask *mTask, int16 smartness);
99 friend void RequestWanderPath(
MotionTask *mTask, int16 smartness);
119 kMfPathFind = (1 << 0),
120 kMfFinalPath = (1 << 1),
121 kMfInWater = (1 << 2),
123 kMfBlocked = (1 << 4),
124 kMfRequestRun = (1 << 5),
125 kMfWandering = (1 << 6),
126 kMfTethered = (1 << 7),
127 kMfNextAnim = (1 << 8),
128 kMfTurnDelay = (1 << 9),
129 kMfTAGTarg = (1 << 10),
130 kMfLocTarg = (1 << 11),
131 kMfAgitated = (1 << 12),
132 kMfAgitatable = (1 << 13),
133 kMfOnStairs = (1 << 14),
134 kMfPrivledged = (1 << 15)
137 Direction _direction;
142 PathRequest *_pathFindTask;
150 uint8 _combatMotionType;
163 enum defenseMotionFlags {
164 kDfBlocking = (1 << 0)
188 enum TwoHandedSwingTypes {
191 kTwoHandedSwingLeftHigh,
192 kTwoHandedSwingLeftLow,
193 kTwoHandedSwingRightHigh,
194 kTwoHandedSwingRightLow
197 enum OneHandedSwingTypes {
203 enum OneHandedParryTypes {
219 kMotionTypeClimbDown,
222 kMotionTypeLandBadly,
231 kMotionTypeUseObject,
232 kMotionTypeUseObjectOnObject,
233 kMotionTypeUseObjectOnTAI,
234 kMotionTypeUseObjectOnLocation,
236 kMotionTypeDropObject,
237 kMotionTypeDropObjectOnObject,
238 kMotionTypeDropObjectOnTAI,
241 kMotionTypeTwoHandedSwing,
242 kMotionTypeOneHandedSwing,
244 kMotionTypeCastSpell,
248 kMotionTypeTwoHandedParry,
249 kMotionTypeOneHandedParry,
250 kMotionTypeShieldParry,
254 kMotionTypeAcceptHit,
268 void remove(int16 returnVal = kMotionInterrupted);
277 if (_flags & kMfReset) {
278 a->setAction(kActionStand, 0);
282 if (a->_currentFacing != _direction)
285 remove(kMotionCompleted);
288 void ballisticAction();
292 void upLadderAction();
293 void downLadderAction();
296 void genericAnimationAction(uint8 actionType);
299 void twoHandedSwingAction();
300 void oneHandedSwingAction();
301 void fireBowAction();
302 void castSpellAction();
303 void useWandAction();
306 void twoHandedParryAction();
307 void oneHandedParryAction();
308 void shieldParryAction();
312 void acceptHitAction();
313 void fallDownAction();
317 void offensiveMeleeAction();
321 void useMagicWeaponAction();
325 void defensiveMeleeAction();
329 bool checkWalk(int16, int16, int16,
TilePoint &);
332 void calcVelocity(
const TilePoint &vector, int16 turns);
340 static void shootObject(
349 bool canAgitate =
true);
355 bool canAgitate =
true);
356 static void walkToDirect(
360 bool canAgitate =
true);
361 static void walkToDirect(
366 bool canAgitate =
true);
367 static void wander(
Actor &obj,
bool run =
false);
368 static void tetheredWander(
Actor &obj,
const TileRegion &tether,
bool run =
false);
371 static void upLadder(
Actor &obj);
372 static void downLadder(
Actor &obj);
373 static void talk(
Actor &obj);
374 static void jump(
Actor &obj);
375 static void turn(
Actor &obj, Direction dir);
376 static void turn(ThreadID th,
Actor &obj, Direction dir);
378 static void turnTowards(ThreadID th,
Actor &obj,
const TilePoint &where);
380 static void give(ThreadID th,
Actor &obj,
Actor &givee);
383 static void wait(
Actor &a);
385 static void useObjectOnObject(
389 static void useObjectOnTAI(
393 static void useObjectOnLocation(
398 static void dropObject(
404 static void dropObjectOnObject(
410 static void dropObjectOnTAI(
426 static void twoHandedParry(
430 static void oneHandedParry(
434 static void shieldParry(
438 static void dodge(
Actor &obj,
Actor &opponent);
441 static void acceptHit(
Actor &obj,
Actor &opponent);
442 static void fallDown(
Actor &obj,
Actor &opponent);
443 static void die(
Actor &obj);
445 static void updatePositions();
455 bool isWalkToDest() {
456 return isWalk() && !(_flags & kMfWandering);
461 return isWalk() && (_flags & kMfWandering);
466 return isWander() && (_flags & kMfTethered);
470 return (_flags & kMfRequestRun) && _runCount == 0;
474 return _motionType == kMotionTypeTurn;
486 void changeTarget(
const TilePoint &newPos,
bool run =
false);
487 void changeDirectTarget(
const TilePoint &newPos,
bool run =
false);
490 if (isTurn())
remove();
492 void finishTalking();
501 void finishDefense() {
502 if (isDefense())
remove();
509 bool isMeleeAttack();
513 uint16 framesUntilStrike();
516 void finishAttack() {
517 if (isAttack())
remove();
525 bool isDodging(
Actor *thisAttacker) {
526 return _motionType == kMotionTypeDodge && thisAttacker == _d.attacker;
529 static void initMotionTasks();
531 bool isPrivledged() {
532 return _flags & kMfPrivledged;
566 inline void MotionTask::walkTo(
572 walkTo(actor, target, run, canAgitate);
573 if (actor._moveTask != NULL)
574 actor._moveTask->_thread = th;
577 inline void MotionTask::walkToDirect(
583 walkToDirect(actor, target, run, canAgitate);
584 if (actor._moveTask != NULL)
585 actor._moveTask->_thread = th;
588 inline void MotionTask::turn(ThreadID th,
Actor &actor, Direction dir) {
590 if (actor._moveTask != NULL)
591 actor._moveTask->_thread = th;
594 inline void MotionTask::turnTowards(
598 turnTowards(actor, where);
599 if (actor._moveTask != NULL)
600 actor._moveTask->_thread = th;
603 inline void MotionTask::give(ThreadID th,
Actor &actor,
Actor &givee) {
605 if (actor._moveTask != NULL)
606 actor._moveTask->_thread = th;
616 void pauseInterruptableMotions();
617 void resumeInterruptableMotions();
624 void initMotionTasks();
630 void cleanupMotionTasks();
Definition: objproto.h:105
Definition: savefile.h:54
Definition: memstream.h:194
Definition: tcoords.h:127
Definition: tcoords.h:222
Definition: objects.h:118
Definition: list_intern.h:51
Definition: objproto.h:1493