2 ===========================================================================
5 Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
7 This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
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.
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.
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/>.
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.
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.
26 ===========================================================================
29 #ifndef __GAME_MOVEABLE_H__
30 #define __GAME_MOVEABLE_H__
33 ===============================================================================
35 Entity using rigid body physics.
37 ===============================================================================
40 extern const idEventDef EV_BecomeNonSolid;
41 extern const idEventDef EV_IsAtRest;
43 class idMoveable : public idEntity {
45 CLASS_PROTOTYPE( idMoveable );
52 void Save( idSaveGame *savefile ) const;
53 void Restore( idRestoreGame *savefile );
55 virtual void Think( void );
57 virtual void Hide( void );
58 virtual void Show( void );
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 );
68 void SetAttacker( idEntity *ent );
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
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
92 const idMaterial * GetRenderModelMaterial( void ) const;
93 void BecomeNonSolid( void );
94 void InitInitialSpline( int startTime );
95 bool FollowInitialSplinePath( void );
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 );
106 ===============================================================================
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.
111 ===============================================================================
114 class idBarrel : public idMoveable {
117 CLASS_PROTOTYPE( idBarrel );
122 void Save( idSaveGame *savefile ) const;
123 void Restore( idRestoreGame *savefile );
125 void BarrelThink( void );
126 virtual void Think( void );
127 virtual bool GetPhysicsToVisualTransform( idVec3 &origin, idMat3 &axis );
128 virtual void ClientPredictionThink( void );
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
141 ===============================================================================
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.
147 ===============================================================================
150 class idExplodingBarrel : public idBarrel {
152 CLASS_PROTOTYPE( idExplodingBarrel );
155 ~idExplodingBarrel();
159 void Save( idSaveGame *savefile ) const;
160 void Restore( idRestoreGame *savefile );
163 bool IsStable( void );
164 void SetStability( bool stability );
165 void StartBurning( void );
166 void StopBurning( void );
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 );
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 );
179 EVENT_EXPLODE = idEntity::EVENT_MAXEVENTS,
190 explode_state_t state;
194 qhandle_t particleModelDefHandle;
195 qhandle_t lightDefHandle;
196 renderEntity_t particleRenderEntity;
205 void AddParticles( const char *name, bool burn );
206 void AddLight( const char *name , bool burn );
207 void ExplodingEffects( void );
209 void Event_Activate( idEntity *activator );
210 void Event_Respawn();
211 void Event_Explode();
212 void Event_TriggerTargets();
215 #endif /* !__GAME_MOVEABLE_H__ */