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 idPhysics_RigidBody physicsObj; // physics object
69 idStr brokenModel; // model set when health drops down to or below zero
70 idStr damage; // if > 0 apply damage to hit entities
71 idStr fxCollide; // fx system to start when collides with something
72 int nextCollideFxTime; // next time it is ok to spawn collision fx
73 float minDamageVelocity; // minimum velocity before moveable applies damage
74 float maxDamageVelocity; // velocity at which the maximum damage is applied
75 idCurve_Spline<idVec3> *initialSpline; // initial spline path the moveable follows
76 idVec3 initialSplineDir; // initial relative direction along the spline path
77 bool explode; // entity explodes when health drops down to or below zero
78 bool unbindOnDeath; // unbind from master when health drops down to or below zero
79 bool allowStep; // allow monsters to step on the object
80 bool canDamage; // only apply damage when this is set
81 int nextDamageTime; // next time the movable can hurt the player
82 int nextSoundTime; // next time the moveable can make a sound
84 const idMaterial * GetRenderModelMaterial( void ) const;
85 void BecomeNonSolid( void );
86 void InitInitialSpline( int startTime );
87 bool FollowInitialSplinePath( void );
89 void Event_Activate( idEntity *activator );
90 void Event_BecomeNonSolid( void );
91 void Event_SetOwnerFromSpawnArgs( void );
92 void Event_IsAtRest( void );
93 void Event_EnableDamage( float enable );
98 ===============================================================================
100 A barrel using rigid body physics. The barrel has special handling of
101 the view model orientation to make it look like it rolls instead of slides.
103 ===============================================================================
106 class idBarrel : public idMoveable {
109 CLASS_PROTOTYPE( idBarrel );
114 void Save( idSaveGame *savefile ) const;
115 void Restore( idRestoreGame *savefile );
117 void BarrelThink( void );
118 virtual void Think( void );
119 virtual bool GetPhysicsToVisualTransform( idVec3 &origin, idMat3 &axis );
120 virtual void ClientPredictionThink( void );
123 float radius; // radius of barrel
124 int barrelAxis; // one of the coordinate axes the barrel cylinder is parallel to
125 idVec3 lastOrigin; // origin of the barrel the last think frame
126 idMat3 lastAxis; // axis of the barrel the last think frame
127 float additionalRotation; // additional rotation of the barrel about it's axis
128 idMat3 additionalAxis; // additional rotation axis
133 ===============================================================================
135 A barrel using rigid body physics and special handling of the view model
136 orientation to make it look like it rolls instead of slides. The barrel
137 can burn and explode when damaged.
139 ===============================================================================
142 class idExplodingBarrel : public idBarrel {
144 CLASS_PROTOTYPE( idExplodingBarrel );
147 ~idExplodingBarrel();
151 void Save( idSaveGame *savefile ) const;
152 void Restore( idRestoreGame *savefile );
154 virtual void Think( void );
155 virtual void Damage( idEntity *inflictor, idEntity *attacker, const idVec3 &dir,
156 const char *damageDefName, const float damageScale, const int location );
157 virtual void Killed( idEntity *inflictor, idEntity *attacker, int damage, const idVec3 &dir, int location );
159 virtual void WriteToSnapshot( idBitMsgDelta &msg ) const;
160 virtual void ReadFromSnapshot( const idBitMsgDelta &msg );
161 virtual bool ClientReceiveEvent( int event, int time, const idBitMsg &msg );
164 EVENT_EXPLODE = idEntity::EVENT_MAXEVENTS,
175 explode_state_t state;
179 qhandle_t particleModelDefHandle;
180 qhandle_t lightDefHandle;
181 renderEntity_t particleRenderEntity;
187 void AddParticles( const char *name, bool burn );
188 void AddLight( const char *name , bool burn );
189 void ExplodingEffects( void );
191 void Event_Activate( idEntity *activator );
192 void Event_Respawn();
193 void Event_Explode();
194 void Event_TriggerTargets();
197 #endif /* !__GAME_MOVEABLE_H__ */