12 /** fields which are explicitly/manually set are marked with "M", fields set automatically are marked with "A" */
14 ATTRIB(Weapon, m_id, int, 0)
17 * you can recognize dummies when this == 0
19 ATTRIB(Weapon, weapon, int, 0);
20 /** A: WEPSET_id : WEPSET_... */
21 ATTRIB(Weapon, weapons, WepSet, '0 0 0');
22 /** M: ammotype : main ammo field */
23 ATTRIB(Weapon, ammo_field, .int, ammo_none);
24 /** M: impulse : weapon impulse */
25 ATTRIB(Weapon, impulse, int, -1);
26 /** M: flags : WEPSPAWNFLAG_... combined */
27 ATTRIB(Weapon, spawnflags, int, 0);
28 /** M: rating : bot weapon priority */
29 ATTRIB(Weapon, bot_pickupbasevalue, float, 0);
30 /** M: color : waypointsprite color */
31 ATTRIB(Weapon, wpcolor, vector, '0 0 0');
32 /** A: wpn-id : wpn- sprite name */
33 ATTRIB(Weapon, wpmodel, string, "");
34 /** M: modelname : name of model (without g_ v_ or h_ prefixes) */
35 ATTRIB(Weapon, mdl, string, "");
36 /** M: model MDL_id_ITEM */
37 ATTRIB(Weapon, m_model, entity, NULL);
38 /** M: crosshair : per-weapon crosshair: "CrosshairImage Size" */
39 ATTRIB(Weapon, w_crosshair, string, "gfx/crosshair1");
40 /** A: crosshair : per-weapon crosshair size (argument two of "crosshair" field) */
41 ATTRIB(Weapon, w_crosshair_size, float, 1);
42 /** M: wepimg : "weaponfoobar" side view image file of weapon. WEAPONTODO: Move out of skin files, move to common files */
43 ATTRIB(Weapon, model2, string, "");
44 /** M: refname : reference name name */
45 ATTRIB(Weapon, netname, string, "");
46 /** M: wepname : human readable name */
47 ATTRIB(Weapon, message, string, "AOL CD Thrower");
49 /** (SERVER) setup weapon data */
50 METHOD(Weapon, wr_setup, bool(Weapon this)) {return false;}
51 /** (SERVER) logic to run every frame */
52 METHOD(Weapon, wr_think, bool(Weapon this, bool fire1, bool fire2)) {return false;}
53 /** (SERVER) checks ammo for weapon primary */
54 METHOD(Weapon, wr_checkammo1, bool(Weapon this)) {return false;}
55 /** (SERVER) checks ammo for weapon second */
56 METHOD(Weapon, wr_checkammo2, bool(Weapon this)) {return false;}
57 /** (SERVER) runs bot aiming code for this weapon */
58 METHOD(Weapon, wr_aim, bool(Weapon this)) {return false;}
59 /** (BOTH) precaches models/sounds used by this weapon, also sets up weapon properties */
60 METHOD(Weapon, wr_init, bool(Weapon this)) {return false;}
61 /** (SERVER) notification number for suicide message (may inspect w_deathtype for details) */
62 METHOD(Weapon, wr_suicidemessage, bool(Weapon this)) {return false;}
63 /** (SERVER) notification number for kill message (may inspect w_deathtype for details) */
64 METHOD(Weapon, wr_killmessage, bool(Weapon this)) {return false;}
65 /** (SERVER) handles reloading for weapon */
66 METHOD(Weapon, wr_reload, bool(Weapon this)) {return false;}
67 /** (SERVER) clears fields that the weapon may use */
68 METHOD(Weapon, wr_resetplayer, bool(Weapon this)) {return false;}
69 /** (CLIENT) impact effect for weapon explosion */
70 METHOD(Weapon, wr_impacteffect, bool(Weapon this)) {return false;}
71 /** (SERVER) called whenever a player dies */
72 METHOD(Weapon, wr_playerdeath, bool(Weapon this)) {return false;}
73 /** (SERVER) logic to run when weapon is lost */
74 METHOD(Weapon, wr_gonethink, bool(Weapon this)) {return false;}
75 /** (ALL) dump weapon cvars to config in data directory (see: sv_cmd dumpweapons) */
76 METHOD(Weapon, wr_config, bool(Weapon this)) {return false;}
77 /** (CLIENT) weapon specific zoom reticle */
78 METHOD(Weapon, wr_zoomreticle, bool(Weapon this)) {return false;}
79 /** (SERVER) the weapon is dropped */
80 METHOD(Weapon, wr_drop, bool(Weapon this)) {return false;}
81 /** (SERVER) a weapon is picked up */
82 METHOD(Weapon, wr_pickup, bool(Weapon this)) {return false;}
84 METHOD(Weapon, display, void(entity this, void(string name, string icon) returns)) {
85 returns(this.message, this.model2 ? sprintf("/gfx/hud/%s/%s", cvar_string("menu_skin"), this.model2) : string_null);
88 void register_weapon(entity this, int id, WepSet bit)
92 this.wpmodel = strzone(strcat("wpn-", ftos(id)));
99 CLASS(OffhandWeapon, Object)
100 METHOD(OffhandWeapon, offhand_think, void(OffhandWeapon this, entity player, bool key_pressed)) {}
101 ENDCLASS(OffhandWeapon)
104 .OffhandWeapon offhand;
107 const int MAX_SHOT_DISTANCE = 32768;
109 // weapon pickup ratings for bot logic
110 const int BOT_PICKUP_RATING_LOW = 2500;
111 const int BOT_PICKUP_RATING_MID = 5000;
112 const int BOT_PICKUP_RATING_HIGH = 10000;
115 const int WEP_TYPE_OTHER = 0x00; // not for damaging people
116 const int WEP_TYPE_SPLASH = 0x01; // splash damage
117 const int WEP_TYPE_HITSCAN = 0x02; // hitscan
118 const int WEP_TYPEMASK = 0x0F;
119 const int WEP_FLAG_CANCLIMB = 0x10; // can be used for movement
120 const int WEP_FLAG_NORMAL = 0x20; // in "most weapons" set
121 const int WEP_FLAG_HIDDEN = 0x40; // hides from menu
122 const int WEP_FLAG_RELOADABLE = 0x80; // can has reload
123 const int WEP_FLAG_SUPERWEAPON = 0x100; // powerup timer
124 const int WEP_FLAG_MUTATORBLOCKED = 0x200; // hides from impulse 99 etc. (mutators are allowed to clear this flag)
127 string weaponorder_byid;
130 string W_FixWeaponOrder(string order, float complete);
131 string W_UndeprecateName(string s);
132 string W_NameWeaponOrder(string order);
133 string W_NumberWeaponOrder(string order);
134 string W_FixWeaponOrder_BuildImpulseList(string o);
135 string W_FixWeaponOrder_AllowIncomplete(string order);
136 string W_FixWeaponOrder_ForceComplete(string order);
137 void W_RandomWeapons(entity e, float n);
139 string GetAmmoPicture(.int ammotype);
142 .int GetAmmoFieldFromNum(int i);
143 int GetAmmoStat(.int ammotype);
146 string W_Sound(string w_snd);
147 string W_Model(string w_mdl);
150 // other useful macros
151 #define WEP_AMMO(wpn) (WEP_##wpn.ammo_field) // only used inside weapon files/with direct name, don't duplicate prefix
152 #define WEP_NAME(wpn) ((get_weaponinfo(wpn)).message)