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"));
19 e.model2 = strzone(strcat("wpn-", e.mdl));
21 e.spawnflags |= WEPSPAWNFLAG_NORMAL;
23 e.spawnflags |= WEPSPAWNFLAG_CANCLIMB;
25 e.bot_pickupbasevalue = pickupbasevalue;
27 float w_null(float dummy)
31 void register_weapons_done()
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 = "";
50 weaponpriority_hudselector_0 = "";
51 for(i = 24; i >= 1; --i)
53 weaponpriority_hudselector_0 = strcat(weaponpriority_hudselector_0, " ", ftos(i));
56 weaponpriority_hudselector_1 = "";
57 for(i = 1; i <= 24; ++i)
59 wi = weapon_info[i-1];
60 if(wi && wi.impulse == 0)
61 weaponpriority_hudselector_1 = strcat(weaponpriority_hudselector_1, " ", ftos(i));
63 for(imp = 9; imp > 0; --imp)
64 for(i = 1; i <= 24; ++i)
66 wi = weapon_info[i-1];
67 if(wi && wi.impulse == imp)
68 weaponpriority_hudselector_1 = strcat(weaponpriority_hudselector_1, " ", ftos(i));
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));
74 entity get_weaponinfo(float id)
77 if(id < WEP_FIRST || id > WEP_LAST)
78 return dummy_weapon_info;
79 w = weapon_info[id - 1];
82 return dummy_weapon_info;
84 string W_FixWeaponOrder(string order, float complete)
86 return fixPriorityList(order, WEP_FIRST, WEP_LAST, 230 - WEP_FIRST, complete);
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)
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)
98 void RegisterWeapons()
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");
117 register_weapons_done();