1 // WEAPON PLUGIN SYSTEM
2 entity weapon_info[24];
3 entity dummy_weapon_info;
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)
8 weapon_info[id - 1] = e = spawn();
9 e.classname = "weapon_info";
11 e.weapons = power2of(id - 1);
12 e.netname = shortname;
17 e.model = strzone(strcat("models/weapons/g_", modelname, ".md3"));
20 e.spawnflags |= WEPSPAWNFLAG_NORMAL;
22 e.spawnflags |= WEPSPAWNFLAG_CANCLIMB;
24 e.bot_pickupbasevalue = pickupbasevalue;
26 float w_null(float dummy)
30 void register_weapons_done()
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;
48 weaponpriority_hudselector_0 = "";
49 for(i = 24; i >= 1; --i)
51 weaponpriority_hudselector_0 = strcat(weaponpriority_hudselector_0, " ", ftos(i));
54 weaponpriority_hudselector_1 = "";
55 for(i = 1; i <= 24; ++i)
57 wi = weapon_info[i-1];
58 if(wi && wi.impulse == 0)
59 weaponpriority_hudselector_1 = strcat(weaponpriority_hudselector_1, " ", ftos(i));
61 for(imp = 9; imp > 0; --imp)
62 for(i = 1; i <= 24; ++i)
64 wi = weapon_info[i-1];
65 if(wi && wi.impulse == imp)
66 weaponpriority_hudselector_1 = strcat(weaponpriority_hudselector_1, " ", ftos(i));
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));
72 entity get_weaponinfo(float id)
75 if(id < WEP_FIRST || id > WEP_LAST)
76 return dummy_weapon_info;
77 w = weapon_info[id - 1];
80 return dummy_weapon_info;
82 string W_FixWeaponOrder(string order, float complete)
84 return fixPriorityList(order, WEP_FIRST, WEP_LAST, complete);
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)
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)
96 void RegisterWeapons()
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, IT_SUPERWEAPON, 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");
114 register_weapons_done();