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, m_name, string, "AOL CD Thrower");
47 ATTRIB(Weapon, m_pickup, entity, NULL);
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, entity actor, 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.m_name, this.model2 ? sprintf("/gfx/hud/%s/%s", cvar_string("menu_skin"), this.model2) : string_null);
92 #include "../items/all.qh"
93 CLASS(WeaponPickup, Pickup)
94 ATTRIB(WeaponPickup, m_weapon, Weapon, NULL)
95 ATTRIB(WeaponPickup, m_name, string, string_null)
97 ATTRIB(WeaponPickup, m_sound, Sound, SND_WEAPONPICKUP)
100 ATTRIB(WeaponPickup, m_itemflags, int, FL_WEAPON)
101 float weapon_pickupevalfunc(entity player, entity item);
102 ATTRIB(WeaponPickup, m_pickupevalfunc, float(entity player, entity item), weapon_pickupevalfunc)
104 CONSTRUCTOR(WeaponPickup, Weapon w) {
105 CONSTRUCT(WeaponPickup);
107 this.m_name = w.m_name;
109 this.m_model = w.m_model;
112 this.m_botvalue = w.bot_pickupbasevalue;
115 ENDCLASS(WeaponPickup)
117 CLASS(OffhandWeapon, Object)
118 METHOD(OffhandWeapon, offhand_think, void(OffhandWeapon this, entity player, bool key_pressed)) {}
119 ENDCLASS(OffhandWeapon)
122 .OffhandWeapon offhand;
125 const int MAX_SHOT_DISTANCE = 32768;
127 // weapon pickup ratings for bot logic
128 const int BOT_PICKUP_RATING_LOW = 2500;
129 const int BOT_PICKUP_RATING_MID = 5000;
130 const int BOT_PICKUP_RATING_HIGH = 10000;
133 const int WEP_TYPE_OTHER = 0x00; // not for damaging people
134 const int WEP_TYPE_SPLASH = 0x01; // splash damage
135 const int WEP_TYPE_HITSCAN = 0x02; // hitscan
136 const int WEP_TYPEMASK = 0x0F;
137 const int WEP_FLAG_CANCLIMB = 0x10; // can be used for movement
138 const int WEP_FLAG_NORMAL = 0x20; // in "most weapons" set
139 const int WEP_FLAG_HIDDEN = 0x40; // hides from menu
140 const int WEP_FLAG_RELOADABLE = 0x80; // can has reload
141 const int WEP_FLAG_SUPERWEAPON = 0x100; // powerup timer
142 const int WEP_FLAG_MUTATORBLOCKED = 0x200; // hides from impulse 99 etc. (mutators are allowed to clear this flag)
145 string weaponorder_byid;
148 string W_FixWeaponOrder(string order, float complete);
149 string W_UndeprecateName(string s);
150 string W_NameWeaponOrder(string order);
151 string W_NumberWeaponOrder(string order);
152 string W_FixWeaponOrder_BuildImpulseList(string o);
153 string W_FixWeaponOrder_AllowIncomplete(string order);
154 string W_FixWeaponOrder_ForceComplete(string order);
155 void W_RandomWeapons(entity e, float n);
157 string GetAmmoPicture(.int ammotype);
160 .int GetAmmoFieldFromNum(int i);
161 int GetAmmoStat(.int ammotype);
164 string W_Sound(string w_snd);
165 string W_Model(string w_mdl);
168 // other useful macros
169 #define WEP_AMMO(wpn) (WEP_##wpn.ammo_field) // only used inside weapon files/with direct name, don't duplicate prefix
170 #define WEP_NAME(wpn) ((get_weaponinfo(wpn)).m_name)