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 weapontype, 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_HIDDEN;
25 e.spawnflags |= WEPSPAWNFLAG_CANCLIMB;
27 e.weapon_type = weapontype;
28 e.bot_pickupbasevalue = pickupbasevalue;
30 float w_null(float dummy)
34 void register_weapons_done()
38 dummy_weapon_info = spawn();
39 dummy_weapon_info.classname = "weapon_info";
40 dummy_weapon_info.weapon = 0; // you can recognize dummies by this
41 dummy_weapon_info.weapons = 0; // you can recognize dummies by this too
42 dummy_weapon_info.netname = "@!#%'n Tuba";
43 dummy_weapon_info.items = 0;
44 dummy_weapon_info.weapon_func = w_null;
45 dummy_weapon_info.mdl = "";
46 dummy_weapon_info.model = "";
47 dummy_weapon_info.spawnflags = 0;
48 dummy_weapon_info.impulse = -1;
49 dummy_weapon_info.weapon_type = WEP_TYPE_OTHER;
50 dummy_weapon_info.bot_pickupbasevalue = 0;
51 dummy_weapon_info.model2 = "";
54 weaponpriority_hudselector_0 = "";
55 for(i = 24; i >= 1; --i)
57 weaponpriority_hudselector_0 = strcat(weaponpriority_hudselector_0, " ", ftos(i));
60 weaponpriority_hudselector_1 = "";
61 for(i = 1; i <= 24; ++i)
63 wi = weapon_info[i-1];
64 if(wi && wi.impulse == 0)
65 weaponpriority_hudselector_1 = strcat(weaponpriority_hudselector_1, " ", ftos(i));
67 for(imp = 9; imp > 0; --imp)
68 for(i = 1; i <= 24; ++i)
70 wi = weapon_info[i-1];
71 if(wi && wi.impulse == imp)
72 weaponpriority_hudselector_1 = strcat(weaponpriority_hudselector_1, " ", ftos(i));
75 weaponpriority_hudselector_0 = strzone(substring(weaponpriority_hudselector_0, 1, strlen(weaponpriority_hudselector_0) - 1));
76 weaponpriority_hudselector_1 = strzone(substring(weaponpriority_hudselector_1, 1, strlen(weaponpriority_hudselector_1) - 1));
78 entity get_weaponinfo(float id)
81 if(id < WEP_FIRST || id > WEP_LAST)
82 return dummy_weapon_info;
83 w = weapon_info[id - 1];
86 return dummy_weapon_info;
88 string W_FixWeaponOrder(string order, float complete)
90 return fixPriorityList(order, WEP_FIRST, WEP_LAST, 230 - WEP_FIRST, complete);
94 #define register_weapon(id,func,ammotype,i,normalweapon,canclimb,weapontype,pickupbasevalue,modelname,shortname,wname) \
95 register_weapon_real(id,func,ammotype,i,normalweapon,canclimb,weapontype,pickupbasevalue,modelname,shortname,wname)
97 // no weapon funcs here!
98 #define register_weapon(id,func,ammotype,i,normalweapon,canclimb,weapontype,pickupbasevalue,modelname,shortname,wname) \
99 register_weapon_real(id,w_null,ammotype,i,normalweapon,canclimb,weapontype,pickupbasevalue,modelname,shortname,wname)
102 void RegisterWeapons()
105 register_weapon(WEP_LASER, w_laser, 0, 1, 1, 1, WEP_TYPE_SPLASH, 0, "laser", "laser", "Laser");
106 register_weapon(WEP_SHOTGUN, w_shotgun, IT_SHELLS, 2, 1, 0, WEP_TYPE_HITSCAN, BOT_PICKUP_RATING_LOW, "shotgun", "shotgun", "Shotgun");
107 register_weapon(WEP_UZI, w_uzi, IT_NAILS, 3, 1, 0, WEP_TYPE_HITSCAN, BOT_PICKUP_RATING_MID, "uzi", "uzi", "Machine Gun");
108 register_weapon(WEP_GRENADE_LAUNCHER, w_glauncher, IT_ROCKETS, 4, 1, 1, WEP_TYPE_SPLASH, BOT_PICKUP_RATING_MID, "gl", "grenadelauncher", "Mortar");
109 register_weapon(WEP_ELECTRO, w_electro, IT_CELLS, 5, 1, 0, WEP_TYPE_SPLASH, BOT_PICKUP_RATING_MID, "electro", "electro", "Electro");
110 register_weapon(WEP_CRYLINK, w_crylink, IT_CELLS, 6, 1, 0, WEP_TYPE_SPLASH, BOT_PICKUP_RATING_MID, "crylink", "crylink", "Crylink");
111 register_weapon(WEP_NEX, w_nex, IT_CELLS, 7, 1, 0, WEP_TYPE_HITSCAN, BOT_PICKUP_RATING_HIGH, "nex", "nex", "Nex");
112 register_weapon(WEP_HAGAR, w_hagar, IT_ROCKETS, 8, 1, 1, WEP_TYPE_SPLASH, BOT_PICKUP_RATING_MID, "hagar", "hagar", "Hagar");
113 register_weapon(WEP_ROCKET_LAUNCHER, w_rlauncher, IT_ROCKETS, 9, 1, 1, WEP_TYPE_SPLASH, BOT_PICKUP_RATING_HIGH, "rl", "rocketlauncher", "Rocket Launcher");
114 register_weapon(WEP_PORTO, w_porto, 0, 0, 0, 0, WEP_TYPE_OTHER, 0, "porto" , "porto", "Port-O-Launch");
115 register_weapon(WEP_MINSTANEX, w_minstanex, IT_CELLS, 7, -1, 1, WEP_TYPE_HITSCAN, BOT_PICKUP_RATING_HIGH, "minstanex", "minstanex", "MinstaNex");
116 register_weapon(WEP_HOOK, w_hook, IT_CELLS|IT_FUEL, 0, 0, 1, WEP_TYPE_SPLASH, 0, "hookgun", "hook", "Grappling Hook");
117 register_weapon(WEP_HLAC, w_hlac, IT_CELLS, 6, 1, 0, WEP_TYPE_SPLASH, BOT_PICKUP_RATING_MID, "hlac", "hlac", "Heavy Laser Assault Cannon");
118 register_weapon(WEP_TUBA, w_tuba, 0, 1, -1, 0, WEP_TYPE_SPLASH, BOT_PICKUP_RATING_MID, "tuba", "tuba", "@!#%'n Tuba");
119 register_weapon(WEP_CAMPINGRIFLE, w_campingrifle, IT_NAILS, 3, 1, 0, WEP_TYPE_HITSCAN, BOT_PICKUP_RATING_MID, "campingrifle", "campingrifle", "Rifle");
121 register_weapons_done();