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