1 // Emacs style mode select   -*- C++ -*-
2 //-----------------------------------------------------------------------------
3 //
4 // $Id: d_items.cpp 4469 2014-01-03 23:38:29Z dr_sean $
5 //
6 // Copyright (C) 1993-1996 by id Software, Inc.
7 // Copyright (C) 2006-2014 by The Odamex Team.
8 //
9 // This program is free software; you can redistribute it and/or
10 // modify it under the terms of the GNU General Public License
11 // as published by the Free Software Foundation; either version 2
12 // of the License, or (at your option) any later version.
13 //
14 // This program 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 // DESCRIPTION:
20 //	Items: key cards, artifacts, weapon, ammunition.
21 //
22 //-----------------------------------------------------------------------------
23 
24 
25 // We are referring to sprite numbers.
26 #include "info.h"
27 
28 #include "d_items.h"
29 
30 
31 //
32 // PSPRITE ACTIONS for waepons.
33 // This struct controls the weapon animations.
34 //
35 // Each entry is:
36 //   ammo/amunition type
37 //  upstate
38 //  downstate
39 // readystate
40 // atkstate, i.e. attack/fire/hit frame
41 // flashstate, muzzle flash
42 //
43 weaponinfo_t	weaponinfo[NUMWEAPONS] =
44 {
45 	{
46 		// fist
47 		am_noammo,
48 		S_PUNCHUP,
49 		S_PUNCHDOWN,
50 		S_PUNCH,
51 		S_PUNCH1,
52 		S_NULL,
53 		(mobjtype_t)0,
54 		0,
55 		0
56 		},
57 	{
58 		// pistol
59 		am_clip,
60 		S_PISTOLUP,
61 		S_PISTOLDOWN,
62 		S_PISTOL,
63 		S_PISTOL1,
64 		S_PISTOLFLASH,
65 		MT_CLIP,
66 		1,
67 		1
68 	},
69 	{
70 		// shotgun
71 		am_shell,
72 		S_SGUNUP,
73 		S_SGUNDOWN,
74 		S_SGUN,
75 		S_SGUN1,
76 		S_SGUNFLASH1,
77 		MT_SHOTGUN,
78 		1,
79 		1
80 	},
81 	{
82 		// chaingun
83 		am_clip,
84 		S_CHAINUP,
85 		S_CHAINDOWN,
86 		S_CHAIN,
87 		S_CHAIN1,
88 		S_CHAINFLASH1,
89 		MT_CHAINGUN,
90 		1,
91 		1
92 	},
93 	{
94 		// missile launcher
95 		am_misl,
96 		S_MISSILEUP,
97 		S_MISSILEDOWN,
98 		S_MISSILE,
99 		S_MISSILE1,
100 		S_MISSILEFLASH1,
101 		MT_MISC27,
102 		1,
103 		1
104 	},
105 	{
106 		// plasma rifle
107 		am_cell,
108 		S_PLASMAUP,
109 		S_PLASMADOWN,
110 		S_PLASMA,
111 		S_PLASMA1,
112 		S_PLASMAFLASH1,
113 		MT_MISC28,
114 		1,
115 		1
116 	},
117 	{
118 		// bfg 9000
119 		am_cell,
120 		S_BFGUP,
121 		S_BFGDOWN,
122 		S_BFG,
123 		S_BFG1,
124 		S_BFGFLASH1,
125 		MT_MISC25,
126 		40,
127 		40
128 	},
129 	{
130 		// chainsaw
131 		am_noammo,
132 		S_SAWUP,
133 		S_SAWDOWN,
134 		S_SAW,
135 		S_SAW1,
136 		S_NULL,
137 		MT_MISC26,
138 		0,
139 		0
140 	},
141 	{
142 		// super shotgun
143 		am_shell,
144 		S_DSGUNUP,
145 		S_DSGUNDOWN,
146 		S_DSGUN,
147 		S_DSGUN1,
148 		S_DSGUNFLASH1,
149 		MT_SUPERSHOTGUN,
150 		2,
151 		2
152 	},
153 };
154 
155 int num_items;
156 
157 // [RH] Guess what. These next three functions are from Quake2:
158 //	g_items.c
159 
160 /*
161 ===============
162 GetItemByIndex
163 ===============
164 */
GetItemByIndex(int index)165 gitem_t	*GetItemByIndex (int index)
166 {
167 	if (index == 0 || index >= num_items)
168 		return NULL;
169 
170 	return &itemlist[index];
171 }
172 
173 
174 /*
175 ===============
176 FindItemByClassname
177 
178 ===============
179 */
FindItemByClassname(const char * classname)180 gitem_t	*FindItemByClassname (const char *classname)
181 {
182 	int		i;
183 	gitem_t	*it;
184 
185 	it = itemlist;
186 	for (i = 0; i < num_items; i++, it++)
187 		if (it->classname && !stricmp(it->classname, classname))
188 			return it;
189 
190 	return NULL;
191 }
192 
193 /*
194 ===============
195 FindItem
196 
197 ===============
198 */
FindItem(const char * pickup_name)199 gitem_t	*FindItem (const char *pickup_name)
200 {
201 	int		i;
202 	gitem_t	*it;
203 
204 	it = itemlist;
205 	for (i = 0; i < num_items; i++, it++)
206 		if (it->pickup_name && !stricmp(it->pickup_name, pickup_name))
207 			return it;
208 
209 	return NULL;
210 }
211 
212 
213 // Item info
214 // Used mainly by the give command. Hopefully will
215 // become more general-purpose later.
216 // (Yes, this was inspired by Quake 2)
217 gitem_t itemlist[] = {
218 	{
219 		"",
220 		NULL,
221 		NULL,
222 		0,
223 		0,
224 		0,
225 		""
226 	},	// leave index 0 alone
227 
228 	{
229 		"item_armor_basic",
230 		NULL,
231 		NULL,
232 		IT_ARMOR,
233 		1,
234 		0,
235 		"Basic Armor"
236 	},
237 
238 	{
239 		"item_armor_mega",
240 		NULL,
241 		NULL,
242 		IT_ARMOR,
243 		2,
244 		0,
245 		"Mega Armor"
246 	},
247 
248 	{
249 		"item_armor_bonus",
250 		NULL,
251 		NULL,
252 		IT_ARMOR,
253 		1,
254 		0,
255 		"Armor Bonus"
256 	},
257 
258 	{
259 		"weapon_fist",
260 		NULL,
261 		NULL,
262 		IT_WEAPON,
263 		wp_fist,
264 		0,
265 		"Fist"
266 	},
267 
268 	{
269 		"weapon_chainsaw",
270 		NULL,
271 		NULL,
272 		IT_WEAPON,
273 		wp_chainsaw,
274 		0,
275 		"Chainsaw"
276 	},
277 
278 	{
279 		"weapon_pistol",
280 		NULL,
281 		NULL,
282 		IT_WEAPON,
283 		wp_pistol,
284 		0,
285 		"Pistol"
286 	},
287 
288 	{
289 		"weapon_shotgun",
290 		NULL,
291 		NULL,
292 		IT_WEAPON,
293 		wp_shotgun,
294 		0,
295 		"Shotgun"
296 	},
297 
298 	{
299 		"weapon_supershotgun",
300 		NULL,
301 		NULL,
302 		IT_WEAPON,
303 		wp_supershotgun,
304 		0,
305 		"Super Shotgun"
306 	},
307 
308 	{
309 		"weapon_chaingun",
310 		NULL,
311 		NULL,
312 		IT_WEAPON,
313 		wp_chaingun,
314 		0,
315 		"Chaingun"
316 	},
317 
318 	{
319 		"weapon_rocketlauncher",
320 		NULL,
321 		NULL,
322 		IT_WEAPON,
323 		wp_missile,
324 		0,
325 		"Rocket Launcher"
326 	},
327 
328 	{
329 		"weapon_plasmagun",
330 		NULL,
331 		NULL,
332 		IT_WEAPON,
333 		wp_plasma,
334 		0,
335 		"Plasma Gun"
336 	},
337 
338 	{
339 		"weapon_bfg",
340 		NULL,
341 		NULL,
342 		IT_WEAPON,
343 		wp_bfg,
344 		0,
345 		"BFG9000"
346 	},
347 
348 	{
349 		"ammo_bullets",
350 		NULL,
351 		NULL,
352 		IT_AMMO,
353 		am_clip,
354 		1,
355 		"Bullets"
356 	},
357 
358 	{
359 		"ammo_shells",
360 		NULL,
361 		NULL,
362 		IT_AMMO,
363 		am_shell,
364 		1,
365 		"Shells"
366 	},
367 
368 	{
369 		"ammo_cells",
370 		NULL,
371 		NULL,
372 		IT_AMMO,
373 		am_cell,
374 		1,
375 		"Cells"
376 	},
377 
378 	{
379 		"ammo_rocket",
380 		NULL,
381 		NULL,
382 		IT_AMMO,
383 		am_misl,
384 		1,
385 		"Rockets"
386 	},
387 
388 	//
389 	// POWERUP ITEMS
390 	//
391 	{
392 		"item_invulnerability",
393 		NULL,
394 		NULL,
395 		IT_POWERUP,
396 		pw_invulnerability,
397 		0,
398 		"Invulnerability"
399 	},
400 
401 	{
402 		"item_berserk",
403 		NULL,
404 		NULL,
405 		IT_POWERUP,
406 		pw_strength,
407 		0,
408 		"Berserk"
409 	},
410 
411 	{
412 		"item_invisibility",
413 		NULL,
414 		NULL,
415 		IT_POWERUP,
416 		pw_invisibility,
417 		0,
418 		"Invisibility"
419 	},
420 
421 	{
422 		"item_ironfeet",
423 		NULL,
424 		NULL,
425 		IT_POWERUP,
426 		pw_ironfeet,
427 		0,
428 		"Radiation Suit"
429 	},
430 
431 	{
432 		"item_allmap",
433 		NULL,
434 		NULL,
435 		IT_POWERUP,
436 		pw_allmap,
437 		0,
438 		"Computer Map"
439 	},
440 
441 	{
442 		"item_visor",
443 		NULL,
444 		NULL,
445 		IT_POWERUP,
446 		pw_infrared,
447 		0,
448 		"Light Amplification Visor"
449 	},
450 
451 	//
452 	// KEYS
453 	//
454 
455 	{
456 		"key_blue_card",
457 		NULL,
458 		NULL,
459 		IT_KEY,
460 		it_bluecard,
461 		0,
462 		"Blue Keycard"
463 	},
464 
465 	{
466 		"key_yellow_card",
467 		NULL,
468 		NULL,
469 		IT_KEY,
470 		it_yellowcard,
471 		0,
472 		"Yellow Keycard"
473 	},
474 
475 	{
476 		"key_red_card",
477 		NULL,
478 		NULL,
479 		IT_KEY,
480 		it_redcard,
481 		0,
482 		"Red Keycard"
483 	},
484 
485 	{
486 		"key_blue_skull",
487 		NULL,
488 		NULL,
489 		IT_KEY,
490 		it_blueskull,
491 		0,
492 		"Blue Skull Key"
493 	},
494 
495 	{
496 		"key_yellow_skull",
497 		NULL,
498 		NULL,
499 		IT_KEY,
500 		it_yellowskull,
501 		0,
502 		"Yellow Skull Key"
503 	},
504 
505 	{
506 		"key_red_skull",
507 		NULL,
508 		NULL,
509 		IT_KEY,
510 		it_redskull,
511 		0,
512 		"Red Skull Key"
513 	},
514 
515 	// ---------------------------------------------------------------------------------------------------------
516 	// [Toke - CTF] CTF Flags
517 
518 	{
519 		"blue_flag",
520 		NULL,
521 		NULL,
522 		IT_FLAG,
523 		it_blueflag,
524 		0,
525 		"Blue Flag"
526 	},
527 
528 
529 	{
530 		"red_flag",
531 		NULL,
532 		NULL,
533 		IT_FLAG,
534 		it_redflag,
535 		0,
536 		"Red Flag"
537 	},
538 
539 	// end of list marker
540 	{
541 	    "",
542 	    NULL,
543 	    NULL,
544 	    0,
545 	    0,
546 	    0,
547 	    ""
548     }
549 };
550 
InitItems(void)551 void InitItems (void)
552 {
553 	num_items = sizeof(itemlist)/sizeof(itemlist[0]) - 1;
554 }
555 
556 
557 VERSION_CONTROL (d_items_cpp, "$Id: d_items.cpp 4469 2014-01-03 23:38:29Z dr_sean $")
558 
559