mapinfo: don't refuse unsupported game types if they at least require no special...
[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 weapontype, 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.weapon_type = weapontype;
28         e.bot_pickupbasevalue = pickupbasevalue;
29 }
30 float w_null(float dummy)
31 {
32         return 0;
33 }
34 void register_weapons_done()
35 {
36         entity wi;
37
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 = "";
52
53         float i;
54         weaponpriority_hudselector_0 = "";
55         for(i = 24; i >= 1; --i)
56                 if(weapon_info[i-1])
57                         weaponpriority_hudselector_0 = strcat(weaponpriority_hudselector_0, " ", ftos(i));
58
59         float imp;
60         weaponpriority_hudselector_1 = "";
61         for(i = 1; i <= 24; ++i)
62         {
63                 wi = weapon_info[i-1];
64                 if(wi && wi.impulse == 0)
65                         weaponpriority_hudselector_1 = strcat(weaponpriority_hudselector_1, " ", ftos(i));
66         }
67         for(imp = 9; imp > 0; --imp)
68                 for(i = 1; i <= 24; ++i)
69                 {
70                         wi = weapon_info[i-1];
71                         if(wi && wi.impulse == imp)
72                                 weaponpriority_hudselector_1 = strcat(weaponpriority_hudselector_1, " ", ftos(i));
73                 }
74
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));
77 }
78 entity get_weaponinfo(float id)
79 {
80         entity w;
81         if(id < WEP_FIRST || id > WEP_LAST)
82                 return dummy_weapon_info;
83         w = weapon_info[id - 1];
84         if(w)
85                 return w;
86         return dummy_weapon_info;
87 }
88 string W_FixWeaponOrder(string order, float complete)
89 {
90         return fixPriorityList(order, WEP_FIRST, WEP_LAST, 230 - WEP_FIRST, complete);
91 }
92
93 #ifdef SVQC
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)
96 #else
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)
100 #endif
101
102 void RegisterWeapons()
103 {
104         // %weaponaddpoint
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");
120         register_weapon(WEP_FIREBALL,         w_fireball,     IT_ROCKETS,       9,  0, 0, WEP_TYPE_SPLASH,  BOT_PICKUP_RATING_MID,  "fireball",     "fireball",        "Fireball");
121
122         register_weapons_done();
123 }