jetpack fuel HUD
[divverent/nexuiz.git] / data / qcsrc / common / items.qc
1 // WEAPON PLUGIN SYSTEM
2 entity weapon_info[24];
3 entity dummy_weapon_info;
4
5 void register_weapon_real(float id, float(float) func, float ammotype, float i, float normalweapon, float canclimb, float pickupbasevalue, string modelname, string shortname, string wname)
6 {
7         entity e;
8         weapon_info[id - 1] = e = spawn();
9         e.classname = "weapon_info";
10         e.weapon = id;
11         e.weapons = power2of(id - 1);
12         e.netname = shortname;
13         e.message = wname;
14         e.items = ammotype;
15         e.weapon_func = func;
16         e.mdl = modelname;
17         e.model = strzone(strcat("models/weapons/g_", modelname, ".md3"));
18         e.spawnflags = 0;
19         e.model2 = strzone(strcat("wpn-", e.mdl));
20         if(normalweapon)
21                 e.spawnflags |= WEPSPAWNFLAG_NORMAL;
22         if(canclimb)
23                 e.spawnflags |= WEPSPAWNFLAG_CANCLIMB;
24         e.impulse = i;
25         e.bot_pickupbasevalue = pickupbasevalue;
26 }
27 float w_null(float dummy)
28 {
29         return 0;
30 }
31 void register_weapons_done()
32 {
33         entity wi;
34
35         dummy_weapon_info = spawn();
36         dummy_weapon_info.classname = "weapon_info";
37         dummy_weapon_info.weapon = 0;
38         dummy_weapon_info.weapons = 0;
39         dummy_weapon_info.netname = "@!#%'n Tuba";
40         dummy_weapon_info.items = 0;
41         dummy_weapon_info.weapon_func = w_null;
42         dummy_weapon_info.mdl = "";
43         dummy_weapon_info.model = "";
44         dummy_weapon_info.spawnflags = 0;
45         dummy_weapon_info.impulse = -1;
46         dummy_weapon_info.bot_pickupbasevalue = 0;
47         dummy_weapon_info.model2 = "";
48
49         float i;
50         weaponpriority_hudselector_0 = "";
51         for(i = 24; i >= 1; --i)
52                 if(weapon_info[i-1])
53                         weaponpriority_hudselector_0 = strcat(weaponpriority_hudselector_0, " ", ftos(i));
54
55         float imp;
56         weaponpriority_hudselector_1 = "";
57         for(i = 1; i <= 24; ++i)
58         {
59                 wi = weapon_info[i-1];
60                 if(wi && wi.impulse == 0)
61                         weaponpriority_hudselector_1 = strcat(weaponpriority_hudselector_1, " ", ftos(i));
62         }
63         for(imp = 9; imp > 0; --imp)
64                 for(i = 1; i <= 24; ++i)
65                 {
66                         wi = weapon_info[i-1];
67                         if(wi && wi.impulse == imp)
68                                 weaponpriority_hudselector_1 = strcat(weaponpriority_hudselector_1, " ", ftos(i));
69                 }
70
71         weaponpriority_hudselector_0 = strzone(substring(weaponpriority_hudselector_0, 1, strlen(weaponpriority_hudselector_0) - 1));
72         weaponpriority_hudselector_1 = strzone(substring(weaponpriority_hudselector_1, 1, strlen(weaponpriority_hudselector_1) - 1));
73 }
74 entity get_weaponinfo(float id)
75 {
76         entity w;
77         if(id < WEP_FIRST || id > WEP_LAST)
78                 return dummy_weapon_info;
79         w = weapon_info[id - 1];
80         if(w)
81                 return w;
82         return dummy_weapon_info;
83 }
84 string W_FixWeaponOrder(string order, float complete)
85 {
86         return fixPriorityList(order, WEP_FIRST, WEP_LAST, 230 - WEP_FIRST, complete);
87 }
88
89 #ifdef SVQC
90 #define register_weapon(id,func,ammotype,i,normalweapon,canclimb,pickupbasevalue,modelname,shortname,wname) \
91         register_weapon_real(id,func,ammotype,i,normalweapon,canclimb,pickupbasevalue,modelname,shortname,wname)
92 #else
93 // no weapon funcs here!
94 #define register_weapon(id,func,ammotype,i,normalweapon,canclimb,pickupbasevalue,modelname,shortname,wname) \
95         register_weapon_real(id,w_null,ammotype,i,normalweapon,canclimb,pickupbasevalue,modelname,shortname,wname)
96 #endif
97
98 void RegisterWeapons()
99 {
100         // %weaponaddpoint
101         register_weapon(WEP_LASER,            w_laser,        0,          1, 1, 1, 0,                      "laser",        "laser",           "Laser");
102         register_weapon(WEP_SHOTGUN,          w_shotgun,      IT_SHELLS,  2, 1, 0, BOT_PICKUP_RATING_LOW,  "shotgun",      "shotgun",         "Shotgun");
103         register_weapon(WEP_UZI,              w_uzi,          IT_NAILS,   3, 1, 0, BOT_PICKUP_RATING_MID,  "uzi",          "uzi",             "Machine Gun");
104         register_weapon(WEP_GRENADE_LAUNCHER, w_glauncher,    IT_ROCKETS, 4, 1, 1, BOT_PICKUP_RATING_MID,  "gl",           "grenadelauncher", "Mortar");
105         register_weapon(WEP_ELECTRO,          w_electro,      IT_CELLS,   5, 1, 0, BOT_PICKUP_RATING_MID,  "electro",      "electro",         "Electro");
106         register_weapon(WEP_CRYLINK,          w_crylink,      IT_CELLS,   6, 1, 0, BOT_PICKUP_RATING_MID,  "crylink",      "crylink",         "Crylink");
107         register_weapon(WEP_NEX,              w_nex,          IT_CELLS,   7, 1, 0, BOT_PICKUP_RATING_HIGH, "nex",          "nex",             "Nex");
108         register_weapon(WEP_HAGAR,            w_hagar,        IT_ROCKETS, 8, 1, 1, BOT_PICKUP_RATING_MID,  "hagar",        "hagar",           "Hagar");
109         register_weapon(WEP_ROCKET_LAUNCHER,  w_rlauncher,    IT_ROCKETS, 9, 1, 1, BOT_PICKUP_RATING_HIGH, "rl",           "rocketlauncher",  "Rocket Launcher");
110         register_weapon(WEP_PORTO,            w_porto,        0,          0, 0, 0, 0,                      "porto" ,       "porto",           "Port-O-Launch");
111         register_weapon(WEP_MINSTANEX,        w_minstanex,    IT_CELLS,   7, 0, 1, BOT_PICKUP_RATING_HIGH, "minstanex",    "minstanex",       "MinstaNex");
112         register_weapon(WEP_HOOK,             w_hook,         IT_CELLS,   0, 0, 1, 0,                      "hookgun",      "hook",            "Grappling Hook");
113         register_weapon(WEP_SEEKER,           w_seeker,       IT_ROCKETS, 8, 0, 0, BOT_PICKUP_RATING_HIGH, "seeker",       "seeker",          "T.A.G. Seeker");
114         register_weapon(WEP_HLAC,             w_hlac,         IT_CELLS,   6, 1, 0, BOT_PICKUP_RATING_MID,  "hlac",         "hlac",            "Heavy Laser Assault Cannon");
115         register_weapon(WEP_CAMPINGRIFLE,     w_campingrifle, IT_NAILS,   3, 1, 0, BOT_PICKUP_RATING_MID,  "campingrifle", "campingrifle",    "Rifle");
116
117         register_weapons_done();
118 }