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