AI.H 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. #ifndef __AI_H
  2. #define __AI_H
  3. #include "actor.h"
  4. #include "db.h"
  5. #include "seq.h"
  6. extern int gDudeSlope[kMaxXSprites];
  7. /*
  8. // Movement states
  9. enum {
  10. kMoveDead = 0,
  11. kMoveStill,
  12. kMoveWalk,
  13. kMoveFall,
  14. kMoveLand,
  15. kMoveStand,
  16. kMoveSwim,
  17. kMoveFly,
  18. kMoveHang,
  19. };
  20. // this stuff needed for dudes
  21. unsigned moveState : 8; // same as player move states
  22. unsigned aiState : 8;
  23. unsigned health : 12;
  24. unsigned dudeDeaf : 1;
  25. unsigned dudeAmbush : 1;
  26. unsigned dudeGuard : 1;
  27. unsigned dudeFlag4 : 1;
  28. signed target : 16;
  29. signed targetX : 32;
  30. signed targetY : 32;
  31. signed targetZ : 32;
  32. signed avel : 16;
  33. unsigned weaponTimer : 16;
  34. unsigned stateTimer : 16;
  35. */
  36. /** Monster AI States **/
  37. enum {
  38. kAIScan = 0, // wait to be activated
  39. kAIGoto = 1, // move to target x,y,z
  40. kAIFollow = 2, // move to target sprite
  41. kAIFlee = 3, // move away from target sprite
  42. kAIMorph = 4, // transforming (i.e., statue to gargoyle)
  43. kAIRecoil = 5,
  44. kAISearch = 6,
  45. kAIAttack = 7,
  46. };
  47. typedef void (*AISTATEFUNC)( SPRITE *sprite, XSPRITE *xsprite);
  48. struct AISTATE
  49. {
  50. int seqId;
  51. SEQCALLBACK seqCallback;
  52. int ticks;
  53. AISTATEFUNC enter;
  54. AISTATEFUNC move;
  55. AISTATEFUNC think;
  56. AISTATE *next;
  57. };
  58. extern void aiInit( void );
  59. extern void aiProcessDudes( void );
  60. extern void aiActivateDude( SPRITE *pSprite, XSPRITE *pXSprite );
  61. extern void aiMoveForward( SPRITE *pSprite, XSPRITE *pXSprite );
  62. extern void aiMoveTurn( SPRITE *pSprite, XSPRITE *pXSprite );
  63. extern void aiMoveDodge( SPRITE *pSprite, XSPRITE *pXSprite );
  64. extern void aiThinkTarget( SPRITE *pSprite, XSPRITE *pXSprite );
  65. extern void aiChooseDirection( SPRITE *pSprite, XSPRITE *pXSprite, int ang );
  66. extern void aiNewState( SPRITE *pSprite, XSPRITE *pXSprite, AISTATE *pState );
  67. extern void aiSetTarget( XSPRITE *pXSprite, int x, int y, int z );
  68. extern void aiSetTarget( XSPRITE *pXSprite, int nTarget );
  69. extern void aiDamageSprite( SPRITE *pSprite, XSPRITE *pXSprite, int nSource, DAMAGE_TYPE nDamageType, int nDamage );
  70. #endif