-// =====================
-// Weapon Registration
-// =====================
-
-bool w_null(int) { return false; }
-
-/** fields which are explicitly/manually set are marked with "M", fields set automatically are marked with "A" */
-CLASS(Weapon, Object)
- ATTRIB(Weapon, m_id, int, 0)
- /**
- * M: WEP_id : WEP_...
- * you can recognize dummies when this == 0
- */
- ATTRIB(Weapon, weapon, int, 0);
- /** A: WEPSET_id : WEPSET_... */
- ATTRIB(Weapon, weapons, WepSet, '0 0 0');
- /** M: function : w_... */
- ATTRIB(Weapon, weapon_func, bool(int), w_null);
- /** M: ammotype : main ammo field */
- ATTRIB(Weapon, ammo_field, .int, ammo_none);
- /** M: impulse : weapon impulse */
- ATTRIB(Weapon, impulse, int, -1);
- /** M: flags : WEPSPAWNFLAG_... combined */
- ATTRIB(Weapon, spawnflags, int, 0);
- /** M: rating : bot weapon priority */
- ATTRIB(Weapon, bot_pickupbasevalue, float, 0);
- /** M: color : waypointsprite color */
- ATTRIB(Weapon, wpcolor, vector, '0 0 0');
- /** A: wpn-id : wpn- sprite name */
- ATTRIB(Weapon, wpmodel, string, "");
- /** M: modelname : name of model (without g_ v_ or h_ prefixes) */
- ATTRIB(Weapon, mdl, string, "");
- /** A: modelname : full path to g_ model */
- ATTRIB(Weapon, model, string, "");
- /** M: simplemdl : simpleitems weapon model/image */
- ATTRIB(Weapon, w_simplemdl, string, "foobar");
- /** M: crosshair : per-weapon crosshair: "CrosshairImage Size" */
- ATTRIB(Weapon, w_crosshair, string, "gfx/crosshair1");
- /** A: crosshair : per-weapon crosshair size (argument two of "crosshair" field) */
- ATTRIB(Weapon, w_crosshair_size, float, 1);
- /** M: wepimg : "weaponfoobar" side view image file of weapon. WEAPONTODO: Move out of skin files, move to common files */
- ATTRIB(Weapon, model2, string, "");
- /** M: refname : reference name name */
- ATTRIB(Weapon, netname, string, "");
- /** M: wepname : human readable name */
- ATTRIB(Weapon, message, string, "AOL CD Thrower");
-
- METHOD(Weapon, display, void(entity this, void(string name, string icon) returns)) {
- returns(this.message, this.model2 ? sprintf("/gfx/hud/%s/%s", cvar_string("menu_skin"), this.model2) : string_null);
- }
-
- CONSTRUCTOR(Weapon,
- bool(int) function,
- .int ammotype,
- int i,
- int weapontype,
- float pickupbasevalue,
- vector clr,
- string modelname,
- string simplemdl,
- string crosshair,
- string wepimg,
- string refname,
- string wepname
- ) {
- CONSTRUCT(Weapon);
- this.weapon_func = function;
- this.ammo_field = ammotype;
- this.impulse = i;
- this.spawnflags = weapontype;
- this.bot_pickupbasevalue = pickupbasevalue;
- this.wpcolor = clr;
- this.mdl = modelname;
- #ifdef SVQC
- this.model = strzone(W_Model(strcat("g_", modelname, ".md3")));
- #elif defined(CSQC)
- this.model = strzone(strcat("models/weapons/g_", modelname, ".md3"));
- #endif
- this.w_simplemdl = strzone(simplemdl); // simpleitems weapon model/image
- this.w_crosshair = strzone(car(crosshair));
- string s = cdr(crosshair);
- this.w_crosshair_size = ((s != "") ? stof(s) : 1); // so that we can scale the crosshair from code (for compat)
- this.model2 = strzone(wepimg);
- this.netname = refname;
- this.message = wepname;
- }
- void register_weapon(entity this, int id, WepSet bit)
- {
- this.classname = "weapon_info";
- this.weapon = id;
- this.weapons = bit;
- this.wpmodel = strzone(strcat("wpn-", ftos(id)));
- #ifdef CSQC
- this.weapon_func(WR_INIT);
- #endif
- }
-ENDCLASS(Weapon)
-
-void RegisterWeapons();
-REGISTER_REGISTRY(RegisterWeapons)
-entity weapon_info[WEP_MAXCOUNT], weapon_info_first, weapon_info_last;
-entity dummy_weapon_info;
-
-#define _REGISTER_WEAPON(id, function, ammotype, impulse, flags, rating, color, modelname, simplemdl, crosshair, wepimg, refname, wepname) \
- WepSet WEPSET_##id; \
- REGISTER(RegisterWeapons, WEP, weapon_info, WEP_COUNT, id, m_id, \
- NEW(Weapon, function, ammotype, impulse, flags, rating, color, modelname, simplemdl, crosshair, wepimg, refname, wepname) \
- ) { \
- this.m_id++; \
- WEPSET_ALL |= (WEPSET_##id = WepSet_FromWeapon(this.m_id)); \
- if ((flags) & WEP_FLAG_SUPERWEAPON) WEPSET_SUPERWEAPONS |= WEPSET_##id; \
- register_weapon(this, this.m_id, WEPSET_##id); \
- }
-
-#ifndef MENUQC
- #define REGISTER_WEAPON(id, function, ammotype, impulse, flags, rating, color, modelname, simplemdl, crosshair, wepimg, refname, wepname) \
- bool function(int); \
- _REGISTER_WEAPON(id, function, ammotype, impulse, flags, rating, color, modelname, simplemdl, crosshair, wepimg, refname, wepname)
-#else
- #define REGISTER_WEAPON(id, function, ammotype, impulse, flags, rating, color, modelname, simplemdl, crosshair, wepimg, refname, wepname) \
- _REGISTER_WEAPON(id, w_null, ammotype, impulse, flags, rating, color, modelname, simplemdl, crosshair, wepimg, refname, wepname)
-#endif