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

  1. // RAVEN BEGIN
  2. // bdube: note that this file is no longer merged with Doom3 updates
  3. //
  4. // MERGE_DATE 09/30/2004
  5.  
  6. #ifndef __GAME_ITEM_H__
  7. #define __GAME_ITEM_H__
  8.  
  9. extern const int ARENA_POWERUP_MASK;
  10. extern const idEventDef EV_ResetFlag;
  11.  
  12. /*
  13. ===============================================================================
  14.  
  15.   Items the player can pick up or use.
  16.  
  17. ===============================================================================
  18. */
  19.  
  20. class idItem : public idEntity {
  21. public:
  22.     CLASS_PROTOTYPE( idItem );
  23.  
  24.                             idItem();
  25.     virtual                    ~idItem();
  26.  
  27.     void                    Save( idSaveGame *savefile ) const;
  28.     void                    Restore( idRestoreGame *savefile );
  29.  
  30.     void                    Spawn( void );
  31.     void                    GetAttributes( idDict &attributes );
  32.     virtual bool            GiveToPlayer( idPlayer *player );
  33.     virtual bool            Pickup( idPlayer *player );
  34.     virtual void            Think( void );
  35.     virtual void            Present();
  36.     virtual    void            InstanceJoin( void );
  37.     virtual void            InstanceLeave( void );
  38.     virtual bool            GetPhysicsToVisualTransform( idVec3 &origin, idMat3 &axis );
  39.  
  40. // RAVEN BEGIN
  41. // mekberg: added
  42.     virtual bool            Collide( const trace_t &collision, const idVec3 &velocity );
  43. // RAVEN END
  44.     
  45.     enum {
  46.         EVENT_PICKUP = idEntity::EVENT_MAXEVENTS,
  47.         EVENT_RESPAWNFX,
  48.         EVENT_MAXEVENTS
  49.     };
  50.  
  51.     virtual void            ClientPredictionThink( void );
  52.     virtual bool            ClientReceiveEvent( int event, int time, const idBitMsg &msg );
  53.  
  54.     // networking
  55.     virtual void            WriteToSnapshot( idBitMsgDelta &msg ) const;
  56.     virtual void            ReadFromSnapshot( const idBitMsgDelta &msg );
  57.  
  58.     virtual void            Hide( void );
  59.     virtual void            Show( void );
  60.  
  61.     virtual bool            ClientStale( void );
  62.     virtual void            ClientUnstale( void );
  63.  
  64. protected:
  65.  
  66.     void                    UpdateTrigger( void );
  67.     void                    SendPickupMsg( int clientNum );
  68.  
  69.     idClipModel *            trigger;
  70.     bool                    spin;
  71.     // only a small subset of idItem need their physics object synced
  72.     bool                    syncPhysics;
  73.  
  74.     bool                    pulse;
  75.     bool                    canPickUp;
  76.  
  77.     const idDeclSkin*        skin;
  78.     const idDeclSkin*        pickupSkin;
  79.  
  80. private:
  81.     idVec3                    orgOrigin;
  82.  
  83.     rvPhysics_Particle        physicsObj;
  84.  
  85.     // for item pulse effect
  86.     int                        itemShellHandle;
  87.     const idMaterial *        shellMaterial;
  88.     rvClientEntityPtr<rvClientEffect>    effectIdle;
  89.  
  90.     // used to update the item pulse effect
  91.     mutable bool            inView;
  92.     mutable int                inViewTime;
  93.     mutable int                lastCycle;
  94.     mutable int                lastRenderViewTime;
  95.  
  96.     // synced through snapshots to indicate show/hide or pickupSkin state
  97.     // -1 on a client means undef, 0 not ready, 1 ready
  98.     int                        srvReady;
  99.     int                        clReady;
  100.  
  101.     int                        itemPVSArea;
  102.  
  103.     bool                    UpdateRenderEntity    ( renderEntity_s *renderEntity, const renderView_t *renderView ) const;
  104.     static bool                ModelCallback        ( renderEntity_s *renderEntity, const renderView_t *renderView );
  105.  
  106.     void                    Event_DropToFloor    ( void );
  107.     void                    Event_Touch            ( idEntity *other, trace_t *trace );
  108.     void                    Event_Trigger        ( idEntity *activator );
  109.     void                    Event_Respawn        ( void );
  110.     void                    Event_RespawnFx        ( void );
  111.     void                    Event_Pickup        ( int clientNum );
  112.   
  113. // RAVEN BEGIN
  114. // abahr
  115.     void                    Event_SetGravity();
  116. // RAVEN END
  117. };
  118.  
  119. /*
  120. ===============================================================================
  121.  
  122.   idItemPowerup
  123.  
  124. ===============================================================================
  125. */
  126.  
  127. class idItemPowerup : public idItem {
  128. public:
  129.     CLASS_PROTOTYPE( idItemPowerup );
  130.  
  131.                             idItemPowerup();
  132.  
  133.     void                    Save( idSaveGame *savefile ) const;
  134.     void                    Restore( idRestoreGame *savefile );
  135.  
  136.     void                    Spawn();
  137.     virtual bool            GiveToPlayer( idPlayer *player );
  138.     virtual void            Think( void );
  139.     virtual bool            Pickup( idPlayer *player );
  140.  
  141. protected:
  142.  
  143.     int                        time;
  144.     int                        type;
  145.     int                        droppedTime;
  146.     int                        team;
  147.     bool                    unique;
  148. };
  149.  
  150. /*
  151. ===============================================================================
  152.  
  153.   rvItemCTFFlag
  154.  
  155. ===============================================================================
  156. */
  157.  
  158. class rvItemCTFFlag : public idItem {
  159. public:
  160.     CLASS_PROTOTYPE( rvItemCTFFlag );
  161.     
  162.                             rvItemCTFFlag();
  163.                             
  164.     void                    Spawn();
  165.     virtual bool            GiveToPlayer ( idPlayer* player );
  166.     virtual bool            Pickup( idPlayer *player );
  167.     
  168.     static void                ResetFlag( int type );
  169.     virtual void            Think( void );
  170.  
  171.     virtual bool            Collide( const trace_t &collision, const idVec3 &velocity );
  172.  
  173. private:
  174.     int                        team;
  175.     int                        powerup;
  176.     bool                    dropped;
  177.     
  178.     void                    Event_ResetFlag( void );
  179.     void                    Event_LinkTrigger( void );
  180. };
  181.  
  182. /*
  183. ===============================================================================
  184.  
  185.   idObjective
  186.  
  187. ===============================================================================
  188. */
  189.  
  190. class idObjective : public idItem {
  191. public:
  192.     CLASS_PROTOTYPE( idObjective );
  193.  
  194.                             idObjective();
  195.  
  196.     void                    Save( idSaveGame *savefile ) const;
  197.     void                    Restore( idRestoreGame *savefile );
  198.  
  199.     void                    Spawn();
  200.  
  201. private:
  202.     idVec3                    playerPos;
  203.  
  204. // RAVEN BEGIN
  205. // mekberg: store triggered time for timed removal.
  206.     int                        triggerTime;
  207. // RAVEN END
  208.  
  209.     void                    Event_Trigger( idEntity *activator );
  210.     void                    Event_HideObjective( idEntity *e );
  211.     void                    Event_GetPlayerPos();
  212.      void                    Event_CamShot();
  213. };
  214.  
  215. /*
  216. ===============================================================================
  217.  
  218.   idMoveableItem
  219.  
  220. ===============================================================================
  221. */
  222.  
  223. class idMoveableItem : public idItem {
  224. public:
  225.     CLASS_PROTOTYPE( idMoveableItem );
  226.  
  227.                             idMoveableItem();
  228.     virtual                    ~idMoveableItem();
  229.  
  230.     void                    Save( idSaveGame *savefile ) const;
  231.     void                    Restore( idRestoreGame *savefile );
  232.  
  233.     void                    Spawn( void );
  234.     virtual void            Think( void );
  235.  
  236.      static void                DropItems( idAnimatedEntity *ent, const char *type, idList<idEntity *> *list );
  237.     static idEntity*        DropItem( const char *classname, const idVec3 &origin, const idMat3 &axis, const idVec3 &velocity, int activateDelay, int removeDelay );
  238.  
  239.     virtual void            WriteToSnapshot( idBitMsgDelta &msg ) const;
  240.     virtual void            ReadFromSnapshot( const idBitMsgDelta &msg );
  241.  
  242. private:
  243.     idPhysics_RigidBody        physicsObj;
  244.  
  245.      void                    Gib( const idVec3 &dir, const char *damageDefName );
  246.      void                    Event_Gib( const char *damageDefName );
  247. };
  248.  
  249. /*
  250. ===============================================================================
  251.  
  252.   Item removers.
  253.  
  254. ===============================================================================
  255. */
  256.  
  257. class idItemRemover : public idEntity {
  258. public:
  259.     CLASS_PROTOTYPE( idItemRemover );
  260.  
  261.     void                    Spawn();
  262.     void                    RemoveItem( idPlayer *player );
  263.  
  264. private:
  265.     void                    Event_Trigger( idEntity *activator );
  266. };
  267.  
  268. /*
  269. ===============================================================================
  270.  
  271.   idObjectiveComplete
  272.  
  273. ===============================================================================
  274. */
  275.  
  276. class idObjectiveComplete : public idItemRemover {
  277. public:
  278.     CLASS_PROTOTYPE( idObjectiveComplete );
  279.  
  280.                             idObjectiveComplete();
  281.  
  282.     void                    Save( idSaveGame *savefile ) const;
  283.     void                    Restore( idRestoreGame *savefile );
  284.  
  285.     void                    Spawn();
  286.  
  287. private:
  288.     idVec3                    playerPos;
  289.  
  290. // RAVEN BEGIN
  291. // mekberg: store triggered time for timed removal.
  292.     int                        triggerTime;
  293. // RAVEN END
  294.  
  295.     void                    Event_Trigger( idEntity *activator );
  296.     void                    Event_HideObjective( idEntity *e );
  297.     void                    Event_GetPlayerPos();
  298. };
  299.  
  300. /*
  301. ===============================================================================
  302.  
  303.   rvObjectiveFailed
  304.  
  305. ===============================================================================
  306. */
  307.  
  308. class rvObjectiveFailed : public idItemRemover {
  309. public:
  310.     CLASS_PROTOTYPE( rvObjectiveFailed );
  311.  
  312.                             rvObjectiveFailed ();
  313. private:
  314.  
  315.     void                    Event_Trigger( idEntity *activator );
  316. };
  317.  
  318. #endif /* !__GAME_ITEM_H__ */
  319.  
  320.  
  321. // RAVEN END
  322.