add misc spritesheet
[rofl0r-openDOW.git] / weapon.c
blob2b4d09d09db5cf89c82fd74b8bedbf82f35e556a
1 #include "weapon.h"
3 #define AMMO(type, mm, rounds, price) [type] = { mm, rounds, price }
4 #define MM(x) (x * 10)
5 const struct ammo ammunition[] = {
6 AMMO(AMMO_45ACP, MM(2.54 * .45), 100, 65),
7 AMMO(AMMO_9MMPARABELLUM, MM(9), 100, 60),
8 AMMO(AMMO_556, 556, 100, 50),
9 AMMO(AMMO_762, 762, 100, 55),
10 AMMO(AMMO_10MM, MM(10), 100, 80),
11 AMMO(AMMO_ROCKET83MM, MM(83), 1, 1400),
12 AMMO(AMMO_ROCKET40MM, MM(40), 1, 1300),
13 AMMO(AMMO_K200GRENADE40MM, MM(40), 1, 200),
14 AMMO(AMMO_GAS, MM(0), 50, 500),
15 AMMO(AMMO_GRENADE, MM(0), 5, 250),
17 #undef MM
18 #undef AMMO
20 #define WEAP(id, bullspeed, _rpm, _range, _ammo, _price, _flags, _sound, _shot) \
21 [id] = { \
22 .bullet_speed = bullspeed, .rpm = _rpm, .range = _range, \
23 .ammo = _ammo, .price = _price, .flags = _flags, .sound = _sound, \
24 .shot = _shot}
25 #define RPM(x) (x)
26 #define RANGE(x) (x/100)
27 const struct weapon weapons[] = {
28 WEAP(WP_COLT45, 1.75, RPM(200), RANGE(200), AMMO_45ACP, 100, WF_MUZZLEFLASH, WS_PISTOL, ST_BULLET),
29 WEAP(WP_BROWNING, 1.75, RPM(200), RANGE(200), AMMO_45ACP, 110, WF_MUZZLEFLASH, WS_PISTOL, ST_BULLET),
30 WEAP(WP_SA80, 3, RPM(800), RANGE(500), AMMO_556, 1400, WF_AUTOMATIC | WF_MUZZLEFLASH, WS_GUN, ST_BULLET),
31 WEAP(WP_MP5, 5, RPM(800), RANGE(200), AMMO_9MMPARABELLUM, 800, WF_AUTOMATIC | WF_MUZZLEFLASH, WS_MACHINEGUN, ST_BULLET),
32 WEAP(WP_UZI, 5, RPM(600), RANGE(200), AMMO_9MMPARABELLUM, 700, WF_AUTOMATIC | WF_MUZZLEFLASH, WS_MACHINEGUN, ST_BULLET),
33 WEAP(WP_STEYR, 4, RPM(650), RANGE(300), AMMO_556, 1500, WF_AUTOMATIC | WF_MUZZLEFLASH, WS_GUN, ST_BULLET),
34 WEAP(WP_AK47, 5, RPM(600), RANGE(400), AMMO_556, 800, WF_AUTOMATIC | WF_MUZZLEFLASH, WS_GUN, ST_BULLET),
35 WEAP(WP_M16A2, 4, RPM(600), RANGE(400), AMMO_556, 900, WF_AUTOMATIC | WF_MUZZLEFLASH, WS_GUN, ST_BULLET),
36 WEAP(WP_M203, 4, RPM(600), RANGE(400), AMMO_556, 1500, WF_AUTOMATIC | WF_MUZZLEFLASH, WS_GUN, ST_BULLET),
37 WEAP(WP_RPK, 4, RPM(600), RANGE(800), AMMO_762, 4900, WF_AUTOMATIC | WF_MUZZLEFLASH, WS_GUN, ST_BULLET),
38 WEAP(WP_L7A2, 6, RPM(850), RANGE(1200), AMMO_762, 5700, WF_AUTOMATIC | WF_MUZZLEFLASH, WS_MACHINEGUN, ST_BULLET),
39 WEAP(WP_HK21, 8, RPM(900), RANGE(1200), AMMO_762, 7800, WF_AUTOMATIC | WF_MUZZLEFLASH, WS_MACHINEGUN, ST_BULLET),
40 WEAP(WP_M60, 4, RPM(550), RANGE(1000), AMMO_762, 6200, WF_AUTOMATIC | WF_MUZZLEFLASH, WS_GUN, ST_BULLET),
41 WEAP(WP_MG42, 12, RPM(1200), RANGE(2000), AMMO_762, 7000, WF_AUTOMATIC | WF_MUZZLEFLASH, WS_MACHINEGUN, ST_BULLET),
42 WEAP(WP_M134, 10, RPM(3000), RANGE(2000), AMMO_10MM, 10400, WF_AUTOMATIC | WF_MUZZLEFLASH, WS_MACHINEGUN, ST_BULLET),
43 WEAP(WP_RPG7, 2.5, RPM(0), RANGE(300), AMMO_ROCKET40MM, 2600, 0, WS_NONE, ST_LAUNCHER),
44 WEAP(WP_LAW, 2.5, RPM(0), RANGE(400), AMMO_INVALID, 2900, 0, WS_NONE, ST_LAUNCHER), // comes with a single rocket preloaded, not reloadable
45 WEAP(WP_MAW, 2.5, RPM(0), RANGE(500), AMMO_ROCKET83MM, 2100, 0, WS_NONE, ST_LAUNCHER),
46 WEAP(WP_ABC, 2, RPM(800), RANGE(100), AMMO_GAS, 9900, WF_AUTOMATIC, WS_FLAMETHROWER, ST_FLAMES),
47 WEAP(WP_GRENADES, 1.75, RPM(0), RANGE(100), AMMO_GRENADE, 50, 0, WS_NONE, ST_GRENADE),
49 #undef WEAP
50 #undef RPM
51 // range 200 entspricht ca 128 pix
52 // range 400 - " - 235 pix
53 // range 500, 800 ebenso
54 // range 1000+ entspricht der diagonale von einem eck zum andern
56 #define WEAPN(x) [x] = #x
57 const char *weapon_names[] = {
58 WEAPN(WP_COLT45),
59 WEAPN(WP_BROWNING),
60 WEAPN(WP_SA80),
61 WEAPN(WP_MP5),
62 WEAPN(WP_UZI),
63 WEAPN(WP_STEYR),
64 WEAPN(WP_AK47),
65 WEAPN(WP_M16A2),
66 WEAPN(WP_M203),
67 WEAPN(WP_RPK),
68 WEAPN(WP_L7A2),
69 WEAPN(WP_HK21),
70 WEAPN(WP_M60),
71 WEAPN(WP_MG42),
72 WEAPN(WP_M134),
73 WEAPN(WP_RPG7),
74 WEAPN(WP_LAW),
75 WEAPN(WP_MAW),
76 WEAPN(WP_ABC),
77 WEAPN(WP_GRENADES),
80 const char* weapon_name(enum weapon_id id) {
81 if(id >= WP_MAX) return 0;
82 return weapon_names[id];