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

  1.  
  2. #ifndef __GAME_TRIGGER_H__
  3. #define __GAME_TRIGGER_H__
  4.  
  5. extern const idEventDef EV_Enable;
  6. extern const idEventDef EV_Disable;
  7.  
  8. /*
  9. ===============================================================================
  10.  
  11.   Trigger base.
  12.  
  13. ===============================================================================
  14. */
  15.  
  16. class idTrigger : public idEntity {
  17. public:
  18.     CLASS_PROTOTYPE( idTrigger );
  19.  
  20.     static void            DrawDebugInfo( void );
  21.  
  22.                         idTrigger();
  23.     void                Spawn( void );
  24.  
  25.     const function_t *    GetScriptFunction( void ) const;
  26.  
  27.     void                Save( idSaveGame *savefile ) const;
  28.     void                Restore( idRestoreGame *savefile );
  29.  
  30.     virtual void        Enable( void );
  31.     virtual void        Disable( void );
  32.  
  33. protected:
  34. // RAVEN BEGIN
  35. // abahr: removed const from function
  36.     void                CallScript( idEntity* scriptEntity );
  37. // RAVEN END
  38.  
  39.     void                Event_Enable( void );
  40.     void                Event_Disable( void );
  41.  
  42. // RAVEN BEGIN
  43. // abahr: changed to allow parms to be passed
  44.     idList<rvScriptFuncUtility> scriptFunctions;
  45.     //const function_t *    scriptFunction;
  46. // RAVEN END
  47. };
  48.  
  49.  
  50. /*
  51. ===============================================================================
  52.  
  53.   Trigger which can be activated multiple times.
  54.  
  55. ===============================================================================
  56. */
  57.  
  58. class idTrigger_Multi : public idTrigger {
  59. public:
  60.     CLASS_PROTOTYPE( idTrigger_Multi );
  61.  
  62.                         idTrigger_Multi( void );
  63.  
  64.     void                Spawn( void );
  65.  
  66.     void                Save( idSaveGame *savefile ) const;
  67.     void                Restore( idRestoreGame *savefile );
  68.  
  69. private:
  70.     float                wait;
  71.     float                random;
  72.     float                delay;
  73.     float                random_delay;
  74.     int                    nextTriggerTime;
  75.     idStr                requires;
  76.     int                    removeItem;
  77.     bool                touchClient;
  78.     bool                touchOther;
  79.     bool                touchVehicle;
  80.     bool                triggerFirst;
  81.     bool                triggerWithSelf;
  82.  
  83.     bool                CheckFacing( idEntity *activator );
  84.  
  85. // RAVEN BEGIN
  86. // kfuller: want trigger_relays entities to be able to respond to earthquakes
  87.     void                Event_EarthQuake                (float requiresLOS);
  88. // RAVEN END
  89.  
  90.     void                TriggerAction( idEntity *activator );
  91.     void                Event_TriggerAction( idEntity *activator );
  92.     void                Event_Trigger( idEntity *activator );
  93.     void                Event_Touch( idEntity *other, trace_t *trace );
  94. };
  95.  
  96.  
  97. /*
  98. ===============================================================================
  99.  
  100.   Trigger which can only be activated by an entity with a specific name.
  101.  
  102. ===============================================================================
  103. */
  104.  
  105. class idTrigger_EntityName : public idTrigger {
  106. public:
  107.     CLASS_PROTOTYPE( idTrigger_EntityName );
  108.  
  109.                         idTrigger_EntityName( void );
  110.  
  111.     void                Save( idSaveGame *savefile ) const;
  112.     void                Restore( idRestoreGame *savefile );
  113.  
  114.     void                Spawn( void );
  115.  
  116. private:
  117.     float                wait;
  118.     float                random;
  119.     float                delay;
  120.     float                random_delay;
  121.     int                    nextTriggerTime;
  122.     bool                triggerFirst;
  123.     idStr                entityName;
  124.  
  125.     void                TriggerAction( idEntity *activator );
  126.     void                Event_TriggerAction( idEntity *activator );
  127.     void                Event_Trigger( idEntity *activator );
  128.     void                Event_Touch( idEntity *other, trace_t *trace );
  129. };
  130.  
  131. /*
  132. ===============================================================================
  133.  
  134.   Trigger which repeatedly fires targets.
  135.  
  136. ===============================================================================
  137. */
  138.  
  139. class idTrigger_Timer : public idTrigger {
  140. public:
  141.     CLASS_PROTOTYPE( idTrigger_Timer );
  142.  
  143.                         idTrigger_Timer( void );
  144.  
  145.     void                Save( idSaveGame *savefile ) const;
  146.     void                Restore( idRestoreGame *savefile );
  147.  
  148.     void                Spawn( void );
  149.  
  150.     virtual void        Enable( void );
  151.     virtual void        Disable( void );
  152.  
  153. private:
  154.     float                random;
  155.     float                wait;
  156.     bool                on;
  157.     float                delay;
  158.     idStr                onName;
  159.     idStr                offName;
  160.  
  161.     void                Event_Timer( void );
  162.     void                Event_Use( idEntity *activator );
  163. };
  164.  
  165.  
  166. /*
  167. ===============================================================================
  168.  
  169.   Trigger which fires targets after being activated a specific number of times.
  170.  
  171. ===============================================================================
  172. */
  173.  
  174. class idTrigger_Count : public idTrigger {
  175. public:
  176.     CLASS_PROTOTYPE( idTrigger_Count );
  177.  
  178.                         idTrigger_Count( void );
  179.  
  180.     void                Save( idSaveGame *savefile ) const;
  181.     void                Restore( idRestoreGame *savefile );
  182.  
  183.     void                Spawn( void );
  184.  
  185. private:
  186.     int                    goal;
  187.     int                    count;
  188.     float                delay;
  189.  
  190.     void                Event_Trigger( idEntity *activator );
  191.     void                Event_TriggerAction( idEntity *activator );
  192. };
  193.  
  194.  
  195. /*
  196. ===============================================================================
  197.  
  198.   Trigger which hurts touching entities.
  199.  
  200. ===============================================================================
  201. */
  202.  
  203. class idTrigger_Hurt : public idTrigger {
  204. public:
  205.     CLASS_PROTOTYPE( idTrigger_Hurt );
  206.  
  207.                         idTrigger_Hurt( void );
  208.  
  209.     void                Save( idSaveGame *savefile ) const;
  210.     void                Restore( idRestoreGame *savefile );
  211.  
  212.     void                Spawn( void );
  213.  
  214. private:
  215.     bool                on;
  216.     float                delay;
  217.     int                    nextTime;
  218.  
  219. // RAVEN BEGIN
  220. // kfuller: added playeronly
  221.     bool                playerOnly;
  222. // RAVEN END
  223.  
  224.     void                Event_Touch( idEntity *other, trace_t *trace );
  225.     void                Event_Toggle( idEntity *activator );
  226. };
  227.  
  228.  
  229. /*
  230. ===============================================================================
  231.  
  232.   Trigger which fades the player view.
  233.  
  234. ===============================================================================
  235. */
  236.  
  237. class idTrigger_Fade : public idTrigger {
  238. public:
  239.  
  240.     CLASS_PROTOTYPE( idTrigger_Fade );
  241.  
  242. private:
  243.     void                Event_Trigger( idEntity *activator );
  244. };
  245.  
  246.  
  247. /*
  248. ===============================================================================
  249.  
  250.   Trigger which continuously tests whether other entities are touching it.
  251.  
  252. ===============================================================================
  253. */
  254.  
  255. class idTrigger_Touch : public idTrigger {
  256. public:
  257.  
  258.     CLASS_PROTOTYPE( idTrigger_Touch );
  259.  
  260.                         idTrigger_Touch( void );
  261.  
  262.     void                Spawn( void );
  263.     virtual void        Think( void );
  264.  
  265.     void                Save( idSaveGame *savefile );
  266.     void                Restore( idRestoreGame *savefile );
  267.  
  268.     virtual void        Enable( void );
  269.     virtual void        Disable( void );
  270.  
  271.     void                TouchEntities( void );
  272.  
  273. private:
  274.     idClipModel *        clipModel;
  275.     int                    filterTeam;
  276.  
  277.     void                Event_Trigger( idEntity *activator );
  278. };
  279.  
  280. #endif /* !__GAME_TRIGGER_H__ */
  281.