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, void(Weapon this)) {}
51 /** (SERVER) logic to run every frame */
52 METHOD(Weapon, wr_think, void(Weapon this, bool fire1, bool fire2)) {}
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, void(Weapon this)) {}
59 /** (BOTH) precaches models/sounds used by this weapon, also sets up weapon properties */
60 METHOD(Weapon, wr_init, void(Weapon this)) {}
61 /** (SERVER) notification number for suicide message (may inspect w_deathtype for details) */
62 METHOD(Weapon, wr_suicidemessage, int(Weapon this)) {return 0;}
63 /** (SERVER) notification number for kill message (may inspect w_deathtype for details) */
64 METHOD(Weapon, wr_killmessage, int(Weapon this)) {return 0;}
65 /** (SERVER) handles reloading for weapon */
66 METHOD(Weapon, wr_reload, void(Weapon this)) {}
67 /** (SERVER) clears fields that the weapon may use */
68 METHOD(Weapon, wr_resetplayer, void(Weapon this)) {}
69 /** (CLIENT) impact effect for weapon explosion */
70 METHOD(Weapon, wr_impacteffect, void(Weapon this)) {}
71 /** (SERVER) called whenever a player dies */
72 METHOD(Weapon, wr_playerdeath, void(Weapon this)) {}
73 /** (SERVER) logic to run when weapon is lost */
74 METHOD(Weapon, wr_gonethink, void(Weapon this)) {}
75 /** (ALL) dump weapon cvars to config in data directory (see: sv_cmd dumpweapons) */
76 METHOD(Weapon, wr_config, void(Weapon this)) {}
77 /** (CLIENT) weapon specific zoom reticle */
78 METHOD(Weapon, wr_zoomreticle, bool(Weapon this)) {
79 // no weapon specific image for this weapon
82 /** (SERVER) the weapon is dropped */
83 METHOD(Weapon, wr_drop, void(Weapon this)) {}
84 /** (SERVER) a weapon is picked up */
85 METHOD(Weapon, wr_pickup, void(Weapon this)) {}
87 METHOD(Weapon, display, void(entity this, void(string name, string icon) returns)) {
88 returns(this.message, this.model2 ? sprintf("/gfx/hud/%s/%s", cvar_string("menu_skin"), this.model2) : string_null);
91 void register_weapon(entity this, int id, WepSet bit)
95 this.wpmodel = strzone(strcat("wpn-", ftos(id)));
102 CLASS(OffhandWeapon, Object)
103 METHOD(OffhandWeapon, offhand_think, void(OffhandWeapon this, entity player, bool key_pressed)) {}
104 ENDCLASS(OffhandWeapon)
107 .OffhandWeapon offhand;
110 const int MAX_SHOT_DISTANCE = 32768;
112 // weapon pickup ratings for bot logic
113 const int BOT_PICKUP_RATING_LOW = 2500;
114 const int BOT_PICKUP_RATING_MID = 5000;
115 const int BOT_PICKUP_RATING_HIGH = 10000;
118 const int WEP_TYPE_OTHER = 0x00; // not for damaging people
119 const int WEP_TYPE_SPLASH = 0x01; // splash damage
120 const int WEP_TYPE_HITSCAN = 0x02; // hitscan
121 const int WEP_TYPEMASK = 0x0F;
122 const int WEP_FLAG_CANCLIMB = 0x10; // can be used for movement
123 const int WEP_FLAG_NORMAL = 0x20; // in "most weapons" set
124 const int WEP_FLAG_HIDDEN = 0x40; // hides from menu
125 const int WEP_FLAG_RELOADABLE = 0x80; // can has reload
126 const int WEP_FLAG_SUPERWEAPON = 0x100; // powerup timer
127 const int WEP_FLAG_MUTATORBLOCKED = 0x200; // hides from impulse 99 etc. (mutators are allowed to clear this flag)
130 string weaponorder_byid;
133 string W_FixWeaponOrder(string order, float complete);
134 string W_UndeprecateName(string s);
135 string W_NameWeaponOrder(string order);
136 string W_NumberWeaponOrder(string order);
137 string W_FixWeaponOrder_BuildImpulseList(string o);
138 string W_FixWeaponOrder_AllowIncomplete(string order);
139 string W_FixWeaponOrder_ForceComplete(string order);
140 void W_RandomWeapons(entity e, float n);
142 string GetAmmoPicture(.int ammotype);
145 .int GetAmmoFieldFromNum(int i);
146 int GetAmmoStat(.int ammotype);
149 string W_Sound(string w_snd);
150 string W_Model(string w_mdl);
153 // other useful macros
154 #define WEP_AMMO(wpn) (WEP_##wpn.ammo_field) // only used inside weapon files/with direct name, don't duplicate prefix
155 #define WEP_NAME(wpn) ((get_weaponinfo(wpn)).message)