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 /** M: modelname : name of model (without g_ v_ or h_ prefixes) */
33 ATTRIB(Weapon, mdl, string, "");
34 /** M: model MDL_id_ITEM */
35 ATTRIB(Weapon, m_model, entity, NULL);
36 /** M: crosshair : per-weapon crosshair: "CrosshairImage Size" */
37 ATTRIB(Weapon, w_crosshair, string, "gfx/crosshair1");
38 /** A: crosshair : per-weapon crosshair size (argument two of "crosshair" field) */
39 ATTRIB(Weapon, w_crosshair_size, float, 1);
40 /** M: wepimg : "weaponfoobar" side view image file of weapon. WEAPONTODO: Move out of skin files, move to common files */
41 ATTRIB(Weapon, model2, string, "");
42 /** M: refname : reference name name */
43 ATTRIB(Weapon, netname, string, "");
44 /** M: wepname : human readable name */
45 ATTRIB(Weapon, message, string, "AOL CD Thrower");
47 /** (SERVER) setup weapon data */
48 METHOD(Weapon, wr_setup, void(Weapon this)) {}
49 /** (SERVER) logic to run every frame */
50 METHOD(Weapon, wr_think, void(Weapon this, entity actor, int slot, int fire)) {}
51 /** (SERVER) checks ammo for weapon primary */
52 METHOD(Weapon, wr_checkammo1, bool(Weapon this)) {return false;}
53 /** (SERVER) checks ammo for weapon second */
54 METHOD(Weapon, wr_checkammo2, bool(Weapon this)) {return false;}
55 /** (SERVER) runs bot aiming code for this weapon */
56 METHOD(Weapon, wr_aim, void(Weapon this)) {}
57 /** (BOTH) precaches models/sounds used by this weapon, also sets up weapon properties */
58 METHOD(Weapon, wr_init, void(Weapon this)) {}
59 /** (SERVER) notification number for suicide message (may inspect w_deathtype for details) */
60 METHOD(Weapon, wr_suicidemessage, int(Weapon this)) {return 0;}
61 /** (SERVER) notification number for kill message (may inspect w_deathtype for details) */
62 METHOD(Weapon, wr_killmessage, int(Weapon this)) {return 0;}
63 /** (SERVER) handles reloading for weapon */
64 METHOD(Weapon, wr_reload, void(Weapon this)) {}
65 /** (SERVER) clears fields that the weapon may use */
66 METHOD(Weapon, wr_resetplayer, void(Weapon this)) {}
67 /** (CLIENT) impact effect for weapon explosion */
68 METHOD(Weapon, wr_impacteffect, void(Weapon this)) {}
69 /** (SERVER) called whenever a player dies */
70 METHOD(Weapon, wr_playerdeath, void(Weapon this)) {}
71 /** (SERVER) logic to run when weapon is lost */
72 METHOD(Weapon, wr_gonethink, void(Weapon this)) {}
73 /** (ALL) dump weapon cvars to config in data directory (see: sv_cmd dumpweapons) */
74 METHOD(Weapon, wr_config, void(Weapon this)) {}
75 /** (CLIENT) weapon specific zoom reticle */
76 METHOD(Weapon, wr_zoomreticle, bool(Weapon this)) {
77 // no weapon specific image for this weapon
80 /** (SERVER) the weapon is dropped */
81 METHOD(Weapon, wr_drop, void(Weapon this)) {}
82 /** (SERVER) a weapon is picked up */
83 METHOD(Weapon, wr_pickup, void(Weapon this)) {}
85 METHOD(Weapon, display, void(entity this, void(string name, string icon) returns)) {
86 returns(this.message, this.model2 ? sprintf("/gfx/hud/%s/%s", cvar_string("menu_skin"), this.model2) : string_null);
90 CLASS(OffhandWeapon, Object)
91 METHOD(OffhandWeapon, offhand_think, void(OffhandWeapon this, entity player, bool key_pressed)) {}
92 ENDCLASS(OffhandWeapon)
95 .OffhandWeapon offhand;
98 const int MAX_SHOT_DISTANCE = 32768;
100 // weapon pickup ratings for bot logic
101 const int BOT_PICKUP_RATING_LOW = 2500;
102 const int BOT_PICKUP_RATING_MID = 5000;
103 const int BOT_PICKUP_RATING_HIGH = 10000;
106 const int WEP_TYPE_OTHER = 0x00; // not for damaging people
107 const int WEP_TYPE_SPLASH = 0x01; // splash damage
108 const int WEP_TYPE_HITSCAN = 0x02; // hitscan
109 const int WEP_TYPEMASK = 0x0F;
110 const int WEP_FLAG_CANCLIMB = 0x10; // can be used for movement
111 const int WEP_FLAG_NORMAL = 0x20; // in "most weapons" set
112 const int WEP_FLAG_HIDDEN = 0x40; // hides from menu
113 const int WEP_FLAG_RELOADABLE = 0x80; // can has reload
114 const int WEP_FLAG_SUPERWEAPON = 0x100; // powerup timer
115 const int WEP_FLAG_MUTATORBLOCKED = 0x200; // hides from impulse 99 etc. (mutators are allowed to clear this flag)
118 string weaponorder_byid;
121 string W_FixWeaponOrder(string order, float complete);
122 string W_UndeprecateName(string s);
123 string W_NameWeaponOrder(string order);
124 string W_NumberWeaponOrder(string order);
125 string W_FixWeaponOrder_BuildImpulseList(string o);
126 string W_FixWeaponOrder_AllowIncomplete(string order);
127 string W_FixWeaponOrder_ForceComplete(string order);
128 void W_RandomWeapons(entity e, float n);
130 string GetAmmoPicture(.int ammotype);
133 .int GetAmmoFieldFromNum(int i);
134 int GetAmmoStat(.int ammotype);
137 string W_Sound(string w_snd);
138 string W_Model(string w_mdl);
141 // other useful macros
142 #define WEP_AMMO(wpn) (WEP_##wpn.ammo_field) // only used inside weapon files/with direct name, don't duplicate prefix
143 #define WEP_NAME(wpn) ((get_weaponinfo(wpn)).message)