doom3-gpl
Doom 3 GPL source release
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Moveable.h
Go to the documentation of this file.
1 /*
2 ===========================================================================
3 
4 Doom 3 GPL Source Code
5 Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
6 
7 This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
8 
9 Doom 3 Source Code is free software: you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation, either version 3 of the License, or
12 (at your option) any later version.
13 
14 Doom 3 Source Code is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18 
19 You should have received a copy of the GNU General Public License
20 along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
21 
22 In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
23 
24 If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
25 
26 ===========================================================================
27 */
28 
29 #ifndef __GAME_MOVEABLE_H__
30 #define __GAME_MOVEABLE_H__
31 
32 /*
33 ===============================================================================
34 
35  Entity using rigid body physics.
36 
37 ===============================================================================
38 */
39 
40 extern const idEventDef EV_BecomeNonSolid;
41 extern const idEventDef EV_IsAtRest;
42 
43 class idMoveable : public idEntity {
44 public:
46 
47  idMoveable( void );
48  ~idMoveable( void );
49 
50  void Spawn( void );
51 
52  void Save( idSaveGame *savefile ) const;
53  void Restore( idRestoreGame *savefile );
54 
55  virtual void Think( void );
56 
57  virtual void Hide( void );
58  virtual void Show( void );
59 
60  bool AllowStep( void ) const;
61  void EnableDamage( bool enable, float duration );
62  virtual bool Collide( const trace_t &collision, const idVec3 &velocity );
63  virtual void Killed( idEntity *inflictor, idEntity *attacker, int damage, const idVec3 &dir, int location );
64  virtual void WriteToSnapshot( idBitMsgDelta &msg ) const;
65  virtual void ReadFromSnapshot( const idBitMsgDelta &msg );
66 
67 #ifdef _D3XP
68  void SetAttacker( idEntity *ent );
69 #endif
70 
71 protected:
72  idPhysics_RigidBody physicsObj; // physics object
73  idStr brokenModel; // model set when health drops down to or below zero
74  idStr damage; // if > 0 apply damage to hit entities
75 #ifdef _D3XP
76  idStr monsterDamage;
77  idEntity *attacker;
78 #endif
79  idStr fxCollide; // fx system to start when collides with something
80  int nextCollideFxTime; // next time it is ok to spawn collision fx
81  float minDamageVelocity; // minimum velocity before moveable applies damage
82  float maxDamageVelocity; // velocity at which the maximum damage is applied
83  idCurve_Spline<idVec3> *initialSpline; // initial spline path the moveable follows
84  idVec3 initialSplineDir; // initial relative direction along the spline path
85  bool explode; // entity explodes when health drops down to or below zero
86  bool unbindOnDeath; // unbind from master when health drops down to or below zero
87  bool allowStep; // allow monsters to step on the object
88  bool canDamage; // only apply damage when this is set
89  int nextDamageTime; // next time the movable can hurt the player
90  int nextSoundTime; // next time the moveable can make a sound
91 
92  const idMaterial * GetRenderModelMaterial( void ) const;
93  void BecomeNonSolid( void );
94  void InitInitialSpline( int startTime );
95  bool FollowInitialSplinePath( void );
96 
97  void Event_Activate( idEntity *activator );
98  void Event_BecomeNonSolid( void );
99  void Event_SetOwnerFromSpawnArgs( void );
100  void Event_IsAtRest( void );
101  void Event_EnableDamage( float enable );
102 };
103 
104 
105 /*
106 ===============================================================================
107 
108  A barrel using rigid body physics. The barrel has special handling of
109  the view model orientation to make it look like it rolls instead of slides.
110 
111 ===============================================================================
112 */
113 
114 class idBarrel : public idMoveable {
115 
116 public:
118  idBarrel();
119 
120  void Spawn( void );
121 
122  void Save( idSaveGame *savefile ) const;
123  void Restore( idRestoreGame *savefile );
124 
125  void BarrelThink( void );
126  virtual void Think( void );
127  virtual bool GetPhysicsToVisualTransform( idVec3 &origin, idMat3 &axis );
128  virtual void ClientPredictionThink( void );
129 
130 private:
131  float radius; // radius of barrel
132  int barrelAxis; // one of the coordinate axes the barrel cylinder is parallel to
133  idVec3 lastOrigin; // origin of the barrel the last think frame
134  idMat3 lastAxis; // axis of the barrel the last think frame
135  float additionalRotation; // additional rotation of the barrel about it's axis
136  idMat3 additionalAxis; // additional rotation axis
137 };
138 
139 
140 /*
141 ===============================================================================
142 
143  A barrel using rigid body physics and special handling of the view model
144  orientation to make it look like it rolls instead of slides. The barrel
145  can burn and explode when damaged.
146 
147 ===============================================================================
148 */
149 
150 class idExplodingBarrel : public idBarrel {
151 public:
153 
156 
157  void Spawn( void );
158 
159  void Save( idSaveGame *savefile ) const;
160  void Restore( idRestoreGame *savefile );
161 
162 #ifdef _D3XP
163  bool IsStable( void );
164  void SetStability( bool stability );
165  void StartBurning( void );
166  void StopBurning( void );
167 #endif
168 
169  virtual void Think( void );
170  virtual void Damage( idEntity *inflictor, idEntity *attacker, const idVec3 &dir,
171  const char *damageDefName, const float damageScale, const int location );
172  virtual void Killed( idEntity *inflictor, idEntity *attacker, int damage, const idVec3 &dir, int location );
173 
174  virtual void WriteToSnapshot( idBitMsgDelta &msg ) const;
175  virtual void ReadFromSnapshot( const idBitMsgDelta &msg );
176  virtual bool ClientReceiveEvent( int event, int time, const idBitMsg &msg );
177 
178  enum {
181  };
182 
183 private:
184  typedef enum {
185  NORMAL = 0,
189  } explode_state_t;
191 
200  float time;
201 #ifdef _D3XP
202  bool isStable;
203 #endif
204 
205  void AddParticles( const char *name, bool burn );
206  void AddLight( const char *name , bool burn );
207  void ExplodingEffects( void );
208 
209  void Event_Activate( idEntity *activator );
210  void Event_Respawn();
211  void Event_Explode();
212  void Event_TriggerTargets();
213 };
214 
215 #endif /* !__GAME_MOVEABLE_H__ */
idVec3 lastOrigin
Definition: Moveable.h:133
void InitInitialSpline(int startTime)
Definition: Moveable.cpp:434
~idMoveable(void)
Definition: Moveable.cpp:86
qhandle_t lightDefHandle
Definition: Moveable.h:195
int qhandle_t
Definition: Lib.h:81
idVec3 spawnOrigin
Definition: Moveable.h:192
bool allowStep
Definition: Moveable.h:87
idVec3 initialSplineDir
Definition: Moveable.h:84
void Event_SetOwnerFromSpawnArgs(void)
Definition: Moveable.cpp:589
GLint location
Definition: glext.h:3631
void Event_Activate(idEntity *activator)
Definition: Moveable.cpp:552
int barrelAxis
Definition: Moveable.h:132
virtual bool Collide(const trace_t &collision, const idVec3 &velocity)
Definition: Moveable.cpp:283
const idEventDef EV_BecomeNonSolid
float minDamageVelocity
Definition: Moveable.h:81
void Restore(idRestoreGame *savefile)
Definition: Moveable.cpp:224
Definition: Vector.h:316
bool FollowInitialSplinePath(void)
Definition: Moveable.cpp:455
renderEntity_t particleRenderEntity
Definition: Moveable.h:196
void ExplodingEffects(void)
Definition: Moveable.cpp:1104
int nextCollideFxTime
Definition: Moveable.h:80
bool canDamage
Definition: Moveable.h:88
bool AllowStep(void) const
Definition: Moveable.cpp:396
idPhysics_RigidBody physicsObj
Definition: Moveable.h:72
void Spawn(void)
Definition: Moveable.cpp:922
int nextSoundTime
Definition: Moveable.h:90
idStr fxCollide
Definition: Moveable.h:79
virtual void Killed(idEntity *inflictor, idEntity *attacker, int damage, const idVec3 &dir, int location)
Definition: Moveable.cpp:367
virtual void WriteToSnapshot(idBitMsgDelta &msg) const
Definition: Moveable.cpp:1316
void Save(idSaveGame *savefile) const
Definition: Moveable.cpp:195
void Restore(idRestoreGame *savefile)
Definition: Moveable.cpp:890
void Spawn(void)
Definition: Moveable.cpp:96
bool explode
Definition: Moveable.h:85
CLASS_PROTOTYPE(idBarrel)
void Save(idSaveGame *savefile) const
Definition: Moveable.cpp:865
float additionalRotation
Definition: Moveable.h:135
CLASS_PROTOTYPE(idExplodingBarrel)
float maxDamageVelocity
Definition: Moveable.h:82
virtual void Killed(idEntity *inflictor, idEntity *attacker, int damage, const idVec3 &dir, int location)
Definition: Moveable.cpp:1136
virtual bool GetPhysicsToVisualTransform(idVec3 &origin, idMat3 &axis)
Definition: Moveable.cpp:767
virtual void Think(void)
Definition: Moveable.cpp:946
void Save(idSaveGame *savefile) const
Definition: Moveable.cpp:652
float radius
Definition: Moveable.h:131
void Event_IsAtRest(void)
Definition: Moveable.cpp:602
idMat3 spawnAxis
Definition: Moveable.h:193
explode_state_t state
Definition: Moveable.h:190
virtual void ReadFromSnapshot(const idBitMsgDelta &msg)
Definition: Moveable.cpp:520
CLASS_PROTOTYPE(idMoveable)
virtual void WriteToSnapshot(idBitMsgDelta &msg) const
Definition: Moveable.cpp:511
void Event_Activate(idEntity *activator)
Definition: Moveable.cpp:1307
void Event_TriggerTargets()
Definition: Moveable.cpp:1246
qhandle_t particleModelDefHandle
Definition: Moveable.h:194
Definition: Matrix.h:333
void BarrelThink(void)
Definition: Moveable.cpp:680
const idMaterial * GetRenderModelMaterial(void) const
Definition: Moveable.cpp:496
void Event_BecomeNonSolid(void)
Definition: Moveable.cpp:532
virtual void Think(void)
Definition: Moveable.cpp:482
int nextDamageTime
Definition: Moveable.h:89
virtual void ClientPredictionThink(void)
Definition: Moveable.cpp:803
const GLcharARB * name
Definition: glext.h:3629
idStr brokenModel
Definition: Moveable.h:73
idStr damage
Definition: Moveable.h:74
Definition: Str.h:116
void BecomeNonSolid(void)
Definition: Moveable.cpp:405
virtual void Damage(idEntity *inflictor, idEntity *attacker, const idVec3 &dir, const char *damageDefName, const float damageScale, const int location)
Definition: Moveable.cpp:1227
idMat3 additionalAxis
Definition: Moveable.h:136
void Spawn(void)
Definition: Moveable.cpp:778
idCurve_Spline< idVec3 > * initialSpline
Definition: Moveable.h:83
bool unbindOnDeath
Definition: Moveable.h:86
idMat3 lastAxis
Definition: Moveable.h:134
virtual void Think(void)
Definition: Moveable.cpp:752
void Event_EnableDamage(float enable)
Definition: Moveable.cpp:611
renderLight_t light
Definition: Moveable.h:197
void AddParticles(const char *name, bool burn)
Definition: Moveable.cpp:1036
void AddLight(const char *name, bool burn)
Definition: Moveable.cpp:1078
void EnableDamage(bool enable, float duration)
Definition: Moveable.cpp:416
virtual void ReadFromSnapshot(const idBitMsgDelta &msg)
Definition: Moveable.cpp:1326
void Restore(idRestoreGame *savefile)
Definition: Moveable.cpp:666
idMoveable(void)
Definition: Moveable.cpp:64
virtual bool ClientReceiveEvent(int event, int time, const idBitMsg &msg)
Definition: Moveable.cpp:1341
virtual void Hide(void)
Definition: Moveable.cpp:261
const idEventDef EV_IsAtRest
virtual void Show(void)
Definition: Moveable.cpp:271