doom3-gpl
Doom 3 GPL source release
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Item.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_ITEM_H__
30 #define __GAME_ITEM_H__
31 
32 
33 /*
34 ===============================================================================
35 
36  Items the player can pick up or use.
37 
38 ===============================================================================
39 */
40 
41 class idItem : public idEntity {
42 public:
44 
45  idItem();
46  virtual ~idItem();
47 
48  void Save( idSaveGame *savefile ) const;
49  void Restore( idRestoreGame *savefile );
50 
51  void Spawn( void );
52  void GetAttributes( idDict &attributes );
53  virtual bool GiveToPlayer( idPlayer *player );
54  virtual bool Pickup( idPlayer *player );
55  virtual void Think( void );
56  virtual void Present();
57 
58  enum {
62 #ifdef CTF
63  EVENT_TAKEFLAG,
64  EVENT_DROPFLAG,
65  EVENT_FLAGRETURN,
66  EVENT_FLAGCAPTURE,
67 #endif
69  };
70 
71  virtual void ClientPredictionThink( void );
72  virtual bool ClientReceiveEvent( int event, int time, const idBitMsg &msg );
73 
74  // networking
75  virtual void WriteToSnapshot( idBitMsgDelta &msg ) const;
76  virtual void ReadFromSnapshot( const idBitMsgDelta &msg );
77 
78 private:
80  bool spin;
81  bool pulse;
82  bool canPickUp;
83 
84  // for item pulse effect
87 
88  // used to update the item pulse effect
89  mutable bool inView;
90  mutable int inViewTime;
91  mutable int lastCycle;
92  mutable int lastRenderViewTime;
93 
96 
97  void Event_DropToFloor( void );
98  void Event_Touch( idEntity *other, trace_t *trace );
99  void Event_Trigger( idEntity *activator );
100  void Event_Respawn( void );
101  void Event_RespawnFx( void );
102 };
103 
104 class idItemPowerup : public idItem {
105 public:
107 
108  idItemPowerup();
109 
110  void Save( idSaveGame *savefile ) const;
111  void Restore( idRestoreGame *savefile );
112 
113  void Spawn();
114  virtual bool GiveToPlayer( idPlayer *player );
115 
116 private:
117  int time;
118  int type;
119 };
120 
121 class idObjective : public idItem {
122 public:
124 
125  idObjective();
126 
127  void Save( idSaveGame *savefile ) const;
128  void Restore( idRestoreGame *savefile );
129 
130  void Spawn();
131 
132 private:
134 
135  void Event_Trigger( idEntity *activator );
136  void Event_HideObjective( idEntity *e );
137  void Event_GetPlayerPos();
138  void Event_CamShot();
139 };
140 
141 class idVideoCDItem : public idItem {
142 public:
144 
145  void Spawn();
146  virtual bool GiveToPlayer( idPlayer *player );
147 };
148 
149 class idPDAItem : public idItem {
150 public:
152 
153  virtual bool GiveToPlayer( idPlayer *player );
154 };
155 
156 class idMoveableItem : public idItem {
157 public:
159 
160  idMoveableItem();
161  virtual ~idMoveableItem();
162 
163  void Save( idSaveGame *savefile ) const;
164  void Restore( idRestoreGame *savefile );
165 
166  void Spawn( void );
167  virtual void Think( void );
168 #ifdef _D3XP
169  virtual bool Collide( const trace_t &collision, const idVec3 &velocity );
170 #endif
171  virtual bool Pickup( idPlayer *player );
172 
173  static void DropItems( idAnimatedEntity *ent, const char *type, idList<idEntity *> *list );
174  static idEntity * DropItem( const char *classname, const idVec3 &origin, const idMat3 &axis, const idVec3 &velocity, int activateDelay, int removeDelay );
175 
176  virtual void WriteToSnapshot( idBitMsgDelta &msg ) const;
177  virtual void ReadFromSnapshot( const idBitMsgDelta &msg );
178 
179 #ifdef CTF
180 protected:
181 #else
182 private:
183 #endif
188 
189 #ifdef _D3XP
190  int nextSoundTime;
191 #endif
192 #ifdef CTF
193  bool repeatSmoke; // never stop updating the particles
194 #endif
195 
196  void Gib( const idVec3 &dir, const char *damageDefName );
197 
198  void Event_DropToFloor( void );
199  void Event_Gib( const char *damageDefName );
200 };
201 
202 #ifdef CTF
203 
204 class idItemTeam : public idMoveableItem {
205 public:
206  CLASS_PROTOTYPE( idItemTeam );
207 
208  idItemTeam();
209  virtual ~idItemTeam();
210 
211  void Spawn();
212  virtual bool Pickup( idPlayer *player );
213  virtual bool ClientReceiveEvent( int event, int time, const idBitMsg &msg );
214  virtual void Think(void );
215 
216  void Drop( bool death = false ); // was the drop caused by death of carrier?
217  void Return( idPlayer * player = NULL );
218  void Capture( void );
219 
220  virtual void FreeLightDef( void );
221  virtual void Present( void );
222 
223  // networking
224  virtual void WriteToSnapshot( idBitMsgDelta &msg ) const;
225  virtual void ReadFromSnapshot( const idBitMsgDelta &msg );
226 
227 public:
228  int team;
229  // TODO : turn this into a state :
230  bool carried; // is it beeing carried by a player?
231  bool dropped; // was it dropped?
232 
233 private:
234  idVec3 returnOrigin;
235  idMat3 returnAxis;
236  int lastDrop;
237 
238  const idDeclSkin * skinDefault;
239  const idDeclSkin * skinCarried;
240 
241  const function_t * scriptTaken;
242  const function_t * scriptDropped;
243  const function_t * scriptReturned;
244  const function_t * scriptCaptured;
245 
246  renderLight_t itemGlow; // Used by flags when they are picked up
247  int itemGlowHandle;
248 
249  int lastNuggetDrop;
250  const char * nuggetName;
251 
252 private:
253 
254  void Event_TakeFlag( idPlayer * player );
255  void Event_DropFlag( bool death );
256  void Event_FlagReturn( idPlayer * player = NULL );
257  void Event_FlagCapture( void );
258 
259  void PrivateReturn( void );
260  function_t * LoadScript( const char * script );
261 
262  void SpawnNugget( idVec3 pos );
263  void UpdateGuis( void );
264 };
265 
266 #endif
267 
268 
270 public:
272 
273  virtual bool GiveToPlayer( idPlayer *player );
274 };
275 
276 /*
277 ===============================================================================
278 
279  Item removers.
280 
281 ===============================================================================
282 */
283 
284 class idItemRemover : public idEntity {
285 public:
287 
288  void Spawn();
289  void RemoveItem( idPlayer *player );
290 
291 private:
292  void Event_Trigger( idEntity *activator );
293 };
294 
296 public:
298 
300 
301  void Save( idSaveGame *savefile ) const;
302  void Restore( idRestoreGame *savefile );
303 
304  void Spawn();
305 
306 private:
308 
309  void Event_Trigger( idEntity *activator );
310  void Event_HideObjective( idEntity *e );
311  void Event_GetPlayerPos();
312 };
313 
314 #endif /* !__GAME_ITEM_H__ */
renderEntity_t renderEntity
Definition: Entity.h:371
void Save(idSaveGame *savefile) const
Definition: Item.cpp:94
virtual void Present()
Definition: Item.cpp:242
virtual bool GiveToPlayer(idPlayer *player)
Definition: Item.cpp:2002
void RemoveItem(idPlayer *player)
Definition: Item.cpp:2035
CLASS_PROTOTYPE(idMoveableItem)
int lastCycle
Definition: Item.h:91
virtual bool GiveToPlayer(idPlayer *player)
Definition: Item.cpp:1589
static void DropItems(idAnimatedEntity *ent, const char *type, idList< idEntity * > *list)
Definition: Item.cpp:1873
const idDeclParticle * smoke
Definition: Item.h:186
idPhysics_RigidBody physicsObj
Definition: Item.h:184
void Spawn(void)
Definition: Item.cpp:1678
idItem()
Definition: Item.cpp:64
void Event_Trigger(idEntity *activator)
Definition: Item.cpp:1475
Definition: Vector.h:316
virtual void Think(void)
Definition: Item.cpp:1752
void Spawn()
Definition: Item.cpp:1557
void Spawn()
Definition: Item.cpp:629
idVec3 orgOrigin
Definition: Item.h:79
idObjective()
Definition: Item.cpp:1370
virtual ~idItem()
Definition: Item.cpp:82
void Spawn()
Definition: Item.cpp:1397
idVec3 playerPos
Definition: Item.h:133
virtual void Think(void)
Definition: Item.cpp:216
GLuint GLuint GLsizei GLenum type
Definition: glext.h:2845
void Event_RespawnFx(void)
Definition: Item.cpp:567
CLASS_PROTOTYPE(idItem)
CLASS_PROTOTYPE(idPDAItem)
void Event_HideObjective(idEntity *e)
Definition: Item.cpp:2152
idClipModel * trigger
Definition: Item.h:185
void Event_DropToFloor(void)
Definition: Item.cpp:1973
virtual void FreeLightDef(void)
Definition: Entity.cpp:1209
virtual bool Pickup(idPlayer *player)
Definition: Item.cpp:365
idVec3 playerPos
Definition: Item.h:307
bool canPickUp
Definition: Item.h:82
virtual bool GiveToPlayer(idPlayer *player)
Definition: Item.cpp:1565
void Save(idSaveGame *savefile) const
Definition: Item.cpp:1643
void Event_Trigger(idEntity *activator)
Definition: Item.cpp:2109
virtual bool GiveToPlayer(idPlayer *player)
Definition: Item.cpp:348
void Event_Respawn(void)
Definition: Item.cpp:548
void Spawn(void)
Definition: Item.cpp:270
CLASS_PROTOTYPE(idVideoCDItem)
bool pulse
Definition: Item.h:81
int inViewTime
Definition: Item.h:90
virtual bool Collide(const trace_t &collision, const idVec3 &velocity)
Definition: Entity.cpp:2868
void Gib(const idVec3 &dir, const char *damageDefName)
Definition: Item.cpp:1957
Definition: Dict.h:65
#define NULL
Definition: Lib.h:88
void Restore(idRestoreGame *savefile)
Definition: Item.cpp:114
bool UpdateRenderEntity(renderEntity_s *renderEntity, const renderView_t *renderView) const
Definition: Item.cpp:136
void Event_Trigger(idEntity *activator)
Definition: Item.cpp:531
CLASS_PROTOTYPE(idItemRemover)
void Event_GetPlayerPos()
Definition: Item.cpp:2139
void Event_DropToFloor(void)
Definition: Item.cpp:497
CLASS_PROTOTYPE(idMoveablePDAItem)
static bool ModelCallback(renderEntity_s *renderEntity, const renderView_t *renderView)
Definition: Item.cpp:195
int time
Definition: Item.h:117
Definition: Item.h:41
void Save(idSaveGame *savefile) const
Definition: Item.cpp:2081
void Event_Trigger(idEntity *activator)
Definition: Item.cpp:2047
void Save(idSaveGame *savefile) const
Definition: Item.cpp:609
virtual bool Pickup(idPlayer *player)
Definition: Item.cpp:1809
virtual void ReadFromSnapshot(const idBitMsgDelta &msg)
Definition: Item.cpp:1945
CLASS_PROTOTYPE(idObjectiveComplete)
int lastRenderViewTime
Definition: Item.h:92
static idEntity * DropItem(const char *classname, const idVec3 &origin, const idMat3 &axis, const idVec3 &velocity, int activateDelay, int removeDelay)
Definition: Item.cpp:1822
void Restore(idRestoreGame *savefile)
Definition: Item.cpp:2090
idItemPowerup()
Definition: Item.cpp:599
virtual void WriteToSnapshot(idBitMsgDelta &msg) const
Definition: Item.cpp:1936
virtual ~idMoveableItem()
Definition: Item.cpp:1632
renderView_t * renderView
Definition: Entity.h:129
Definition: Matrix.h:333
virtual void ClientPredictionThink(void)
Definition: Item.cpp:424
void GetAttributes(idDict &attributes)
Definition: Item.cpp:331
int type
Definition: Item.h:118
void Spawn()
Definition: Item.cpp:2027
void Save(idSaveGame *savefile) const
Definition: Item.cpp:1379
void Restore(idRestoreGame *savefile)
Definition: Item.cpp:1660
void Event_Gib(const char *damageDefName)
Definition: Item.cpp:1982
CLASS_PROTOTYPE(idItemPowerup)
virtual void WriteToSnapshot(idBitMsgDelta &msg) const
Definition: Item.cpp:437
void Event_HideObjective(idEntity *e)
Definition: Item.cpp:1528
virtual void ReadFromSnapshot(const idBitMsgDelta &msg)
Definition: Item.cpp:446
void Restore(idRestoreGame *savefile)
Definition: Item.cpp:619
bool inView
Definition: Item.h:89
void Restore(idRestoreGame *savefile)
Definition: Item.cpp:1388
void Event_GetPlayerPos()
Definition: Item.cpp:1515
virtual bool GiveToPlayer(idPlayer *player)
Definition: Item.cpp:639
void Event_Touch(idEntity *other, trace_t *trace)
Definition: Item.cpp:514
CLASS_PROTOTYPE(idObjective)
bool spin
Definition: Item.h:80
int itemShellHandle
Definition: Item.h:85
int smokeTime
Definition: Item.h:187
void Event_CamShot()
Definition: Item.cpp:1409
const idMaterial * shellMaterial
Definition: Item.h:86
virtual bool ClientReceiveEvent(int event, int time, const idBitMsg &msg)
Definition: Item.cpp:459