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

  1. // RAVEN BEGIN
  2. // bdube: note that this file is no longer merged with Doom3 updates
  3. //
  4. // MERGE_DATE 06/02/2004
  5.  
  6. #ifndef __GAME_MOVEABLE_H__
  7. #define __GAME_MOVEABLE_H__
  8.  
  9. /*
  10. ===============================================================================
  11.  
  12.   Entity using rigid body physics.
  13.  
  14. ===============================================================================
  15. */
  16.  
  17. extern const idEventDef EV_BecomeNonSolid;
  18. extern const idEventDef EV_IsAtRest;
  19.  
  20. class idMoveable : public idDamagable {
  21. public:
  22.     CLASS_PROTOTYPE( idMoveable );
  23.  
  24.                             idMoveable( void );
  25.                             ~idMoveable( void );
  26.  
  27.     void                    Spawn( void );
  28.  
  29.     void                    Save( idSaveGame *savefile ) const;
  30.     void                    Restore( idRestoreGame *savefile );
  31.  
  32.     virtual void            Think( void );
  33.  
  34.     virtual void            Hide( void );
  35.     virtual void            Show( void );
  36.  
  37.     bool                    AllowStep( void ) const;
  38.     void                    EnableDamage( bool enable, float duration );
  39.     virtual bool            Collide( const trace_t &collision, const idVec3 &velocity );
  40.     virtual void            Damage( idEntity *inflictor, idEntity *attacker, const idVec3 &dir, const char *damageDefName, const float damageScale, const int location );
  41.     virtual void            Killed( idEntity *inflictor, idEntity *attacker, int damage, const idVec3 &dir, int location );
  42.     virtual void            WriteToSnapshot( idBitMsgDelta &msg ) const;
  43.     virtual void            ReadFromSnapshot( const idBitMsgDelta &msg );
  44.  
  45.     virtual void            AddDamageEffect( const trace_t &collision, const idVec3 &velocity, const char *damageDefName, idEntity* inflictor );
  46.  
  47. protected:
  48.  
  49.     idPhysics_RigidBody        physicsObj;                // physics object
  50.     idStr                    brokenModel;            // model set when health drops down to or below zero
  51.     idStr                    damage;                    // if > 0 apply damage to hit entities
  52.     int                        nextCollideFxTime;        // next time it is ok to spawn collision fx
  53.     float                    minDamageVelocity;        // minimum velocity before moveable applies damage
  54.     float                    maxDamageVelocity;        // velocity at which the maximum damage is applied
  55.     idCurve_Spline<idVec3> *initialSpline;            // initial spline path the moveable follows
  56.     idVec3                    initialSplineDir;        // initial relative direction along the spline path
  57.     bool                    unbindOnDeath;            // unbind from master when health drops down to or below zero
  58.     bool                    allowStep;                // allow monsters to step on the object
  59.     bool                    canDamage;                // only apply damage when this is set
  60.  
  61.     idEntityPtr<idEntity>    lastAttacker;
  62.  
  63.     virtual void            ExecuteStage    ( void );
  64.  
  65.     const idMaterial *        GetRenderModelMaterial( void ) const;
  66.     void                    BecomeNonSolid( void );
  67.     void                    InitInitialSpline( int startTime );
  68.     bool                    FollowInitialSplinePath( void );
  69.  
  70.     void                    Event_Activate( idEntity *activator );
  71.     void                    Event_BecomeNonSolid( void );
  72.     void                    Event_SetOwnerFromSpawnArgs( void );
  73.     void                    Event_IsAtRest( void );
  74.     void                    Event_CanDamage ( float enable );
  75.     void                    Event_SetHealth ( float newHealth );
  76.     void                    Event_RadiusDamage( idEntity *attacker, const char* splash );
  77. };
  78.  
  79.  
  80. /*
  81. ===============================================================================
  82.  
  83.   A barrel using rigid body physics. The barrel has special handling of
  84.   the view model orientation to make it look like it rolls instead of slides.
  85.  
  86. ===============================================================================
  87. */
  88.  
  89. class idBarrel : public idMoveable {
  90.  
  91. public:
  92.     CLASS_PROTOTYPE( idBarrel );
  93.                             idBarrel();
  94.  
  95.     void                    Spawn( void );
  96.  
  97.     void                    Save( idSaveGame *savefile ) const;
  98.     void                    Restore( idRestoreGame *savefile );
  99.  
  100.     void                    BarrelThink( void );
  101.     virtual void            Think( void );
  102.     virtual bool            GetPhysicsToVisualTransform( idVec3 &origin, idMat3 &axis );
  103.     virtual void            ClientPredictionThink( void );
  104.  
  105. private:
  106.     float                    radius;                    // radius of barrel
  107.     int                        barrelAxis;                // one of the coordinate axes the barrel cylinder is parallel to
  108.     idVec3                    lastOrigin;                // origin of the barrel the last think frame
  109.     idMat3                    lastAxis;                // axis of the barrel the last think frame
  110.     float                    additionalRotation;        // additional rotation of the barrel about it's axis
  111.     idMat3                    additionalAxis;            // additional rotation axis
  112. };
  113.  
  114.  
  115. /*
  116. ===============================================================================
  117.  
  118.   A barrel using rigid body physics and special handling of the view model
  119.   orientation to make it look like it rolls instead of slides. The barrel
  120.   can burn and explode when damaged.
  121.  
  122. ===============================================================================
  123. */
  124.  
  125. class idExplodingBarrel : public idBarrel {
  126. public:
  127.     CLASS_PROTOTYPE( idExplodingBarrel );
  128.  
  129.                             idExplodingBarrel();
  130.                             ~idExplodingBarrel();
  131.  
  132.     void                    Spawn( void );
  133.  
  134.     void                    Save( idSaveGame *savefile ) const;
  135.     void                    Restore( idRestoreGame *savefile );
  136.  
  137.     virtual void            Think( void );
  138.     virtual void            Damage( idEntity *inflictor, idEntity *attacker, const idVec3 &dir, 
  139.                                 const char *damageDefName, const float damageScale, const int location );
  140.     virtual void            Killed( idEntity *inflictor, idEntity *attacker, int damage, const idVec3 &dir, int location );
  141.  
  142.     virtual void            WriteToSnapshot( idBitMsgDelta &msg ) const;
  143.     virtual void            ReadFromSnapshot( const idBitMsgDelta &msg );
  144.  
  145. private:
  146.     typedef enum {
  147.         NORMAL = 0,
  148.         BURNING,
  149.         BURNEXPIRED,
  150.         EXPLODING,
  151.         EXPLODED
  152.     } explode_state_t;
  153.     explode_state_t            state;
  154.  
  155.     idVec3                    spawnOrigin;
  156.     idMat3                    spawnAxis;
  157.     qhandle_t                ipsHandle;
  158.     qhandle_t                lightHandle;
  159.     renderEntity_t            ipsEntity;
  160.     renderLight_t            light;
  161.     int                        ipsTime;
  162.     int                        lightTime;
  163.     float                    time;
  164.  
  165.     int                        explodeFinishTime;
  166.  
  167.     void                    AddIPS( const char *name, bool burn );
  168.     void                    AddLight( const char *name , bool burn );
  169.     void                    ExplodingEffects( void );
  170.  
  171.     void                    Event_Activate( idEntity *activator );
  172.     void                    Event_Respawn();
  173.     void                    Event_Explode();
  174.     void                    Event_TriggerTargets();
  175. };
  176.  
  177. #endif /* !__GAME_MOVEABLE_H__ */
  178.  
  179. // RAVEN END
  180.