home *** CD-ROM | disk | FTP | other *** search
/ GameStar 2006 March / Gamestar_82_2006-03_dvd.iso / DVDStar / Editace / quake4_sdkv10.exe / source / game / ai / VehicleAI.h < prev   
C/C++ Source or Header  |  2005-11-14  |  2KB  |  97 lines

  1. //----------------------------------------------------------------
  2. // rvVehicleAI.h
  3. //
  4. // Copyright 2002-2004 Raven Software
  5. //----------------------------------------------------------------
  6.  
  7. #ifndef __GAME_VEHICLEAI_H__
  8. #define __GAME_VEHICLEAI_H__
  9.  
  10. #ifndef __AI_H__
  11. #include "AI.h"
  12. #endif
  13. #ifndef __GAME_VEHICLEMONSTER_H__
  14. #include "../vehicle/VehicleMonster.h"
  15. #endif
  16.  
  17. enum VehicleAI_Flags {
  18.     VAIF_Chase        = 1,
  19.     VAIF_Avoid        = 2,
  20.     VAIF_Freeze        = 4,
  21. };
  22.  
  23. class rvVehicleAI : public idAI {
  24.     friend class rvVehicleMonster;
  25.  
  26. public:
  27.     CLASS_PROTOTYPE( rvVehicleAI );
  28.  
  29.                             rvVehicleAI                ( void );
  30.                             ~rvVehicleAI            ( void );
  31.  
  32.     void                    Spawn                    ( void );
  33.     void                    Think                    ( void );
  34.     void                    Save                    ( idSaveGame *savefile ) const;
  35.     void                    Restore                    ( idRestoreGame *savefile );
  36.  
  37.     void                    SetVehicle                ( rvVehicleMonster * vehicle );
  38.  
  39.     void                    Random                    ( void );
  40.     void                    StraightToEnemy            ( void );
  41.     void                    ChaseEnemy                ( void );
  42.     void                    AvoidEnemy                ( void );
  43.     void                    Stop                    ( void );
  44.     void                    Start                    ( void );
  45.  
  46.     int &                    GetFlags                ( void ) { return flags; }
  47.  
  48.     bool                    IsDriving                ( void ) { return driver && driver->IsDriving(); }
  49.     rvVehicleDriver*        GetDriver                ( void ) { return driver.GetEntity(); }
  50.     const rvVehicleDriver*    GetDriver                ( void ) const { return driver.GetEntity(); }
  51.  
  52. private:
  53.     virtual void            OnWakeUp                ( void );
  54.     virtual void            CustomMove                ( void );
  55.  
  56.     const idEntity *        MoveCloserTo            ( const idVec3 & point, idEntity * current );
  57.     const idEntity *        MoveAwayFrom            ( const idVec3 & point, idEntity * current );
  58.     const idEntity *        FindClosestNode            ( void ) const;
  59.  
  60.     void                    Event_ChoosePathTarget    ( idEntity * current );
  61.  
  62.     idEntityPtr<rvVehicleDriver>    driver;
  63.     int                                flags;
  64. };
  65.  
  66. ID_INLINE void rvVehicleAI::Random ( void ) {
  67.     flags = 0;
  68.     CustomMove();
  69. }
  70.  
  71. ID_INLINE void rvVehicleAI::StraightToEnemy ( void ) {
  72.     driver->ProcessEvent( &AI_ScriptedMove, enemy.ent.GetEntity(), 0.0f, 0 );
  73. }
  74.  
  75. ID_INLINE void rvVehicleAI::ChaseEnemy ( void ) {
  76.     flags = VAIF_Chase;
  77.     CustomMove();
  78. }
  79.  
  80. ID_INLINE void rvVehicleAI::AvoidEnemy ( void ) {
  81.     flags = VAIF_Avoid;
  82.     CustomMove();
  83. }
  84.  
  85. ID_INLINE void rvVehicleAI::Stop ( void ) {
  86.     flags = ( flags & 0x03 ) | VAIF_Freeze;
  87.     driver->ProcessEvent( &AI_ScriptedStop );
  88. }
  89.  
  90. ID_INLINE void rvVehicleAI::Start ( void ) {
  91.     flags = ( flags & 0x03 ) & ~VAIF_Freeze;
  92.     //driver->ProcessEvent( &EV_Activate, this );
  93.     CustomMove();
  94. }
  95.  
  96. #endif // __GAME_VEHICLEAI_H__
  97.