rename LICENSE to COPYING and add a more complete LICENSE file.
[rofl0r-openDOW.git] / weapon.c
blob99b04f1fe71c8d1047e40ac57bdc94df05a847bf
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 #define STR(x, y) [x] = y
58 static const char *weapon_names[] = {
59 STR(WP_COLT45, "COLT.45"),
60 STR(WP_BROWNING, "BROWNING HP"),
61 STR(WP_SA80, "SA80"),
62 STR(WP_MP5, "HKMP5"),
63 STR(WP_UZI, "UZI"),
64 STR(WP_STEYR, "STEYR AUG"),
65 STR(WP_AK47, "AKM"),
66 STR(WP_M16A2, "M16"),
67 STR(WP_M203, "M16+M203"),
68 STR(WP_RPK, "RPK"),
69 STR(WP_L7A2, "L7A2"),
70 STR(WP_HK21, "HK21"),
71 STR(WP_M60, "M60"),
72 STR(WP_MG42, "MG42"),
73 STR(WP_M134, "M134 MINIGUN"),
74 STR(WP_RPG7, "RPG-7"),
75 STR(WP_LAW, "LAW"),
76 STR(WP_MAW, "MAW"),
77 STR(WP_ABC, "FLAME THROWER"),
78 STR(WP_GRENADES, "APG"),
81 const char* weapon_name(enum weapon_id id) {
82 if(id >= WP_MAX) return 0;
83 return weapon_names[id];
86 static const char *ammo_names[] = {
87 STR(AMMO_45ACP, ".45 ACP"),
88 STR(AMMO_9MMPARABELLUM, "9MM PAR"),
89 STR(AMMO_556, "5.54"),
90 STR(AMMO_762, "7.62"),
91 STR(AMMO_10MM, "MINIGUN"),
92 STR(AMMO_ROCKET83MM, "MAW"),
93 STR(AMMO_ROCKET40MM, "RPG7"),
94 STR(AMMO_K200GRENADE40MM, "M203"),
95 STR(AMMO_GAS, "GAS"),
96 STR(AMMO_GRENADE, "APG"),
99 const char* ammo_name(enum ammo_id id) {
100 if(id >= AMMO_MAX) return 0;
101 return ammo_names[id];