4 const int MAX_WEAPONSLOTS = 2;
14 /** fields which are explicitly/manually set are marked with "M", fields set automatically are marked with "A" */
16 ATTRIB(Weapon, m_id, int, 0)
19 * you can recognize dummies when this == 0
21 ATTRIB(Weapon, weapon, int, 0);
22 /** A: WEPSET_id : WEPSET_... */
23 ATTRIB(Weapon, weapons, WepSet, '0 0 0');
24 /** M: ammotype : main ammo field */
25 ATTRIB(Weapon, ammo_field, .int, ammo_none);
26 /** M: impulse : weapon impulse */
27 ATTRIB(Weapon, impulse, int, -1);
28 /** M: flags : WEPSPAWNFLAG_... combined */
29 ATTRIB(Weapon, spawnflags, int, 0);
30 /** M: rating : bot weapon priority */
31 ATTRIB(Weapon, bot_pickupbasevalue, float, 0);
32 /** M: color : waypointsprite color */
33 ATTRIB(Weapon, wpcolor, vector, '0 0 0');
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, entity actor, int slot, int fire)) {}
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);
92 CLASS(OffhandWeapon, Object)
93 METHOD(OffhandWeapon, offhand_think, void(OffhandWeapon this, entity player, bool key_pressed)) {}
94 ENDCLASS(OffhandWeapon)
97 .OffhandWeapon offhand;
100 const int MAX_SHOT_DISTANCE = 32768;
102 // weapon pickup ratings for bot logic
103 const int BOT_PICKUP_RATING_LOW = 2500;
104 const int BOT_PICKUP_RATING_MID = 5000;
105 const int BOT_PICKUP_RATING_HIGH = 10000;
108 const int WEP_TYPE_OTHER = 0x00; // not for damaging people
109 const int WEP_TYPE_SPLASH = 0x01; // splash damage
110 const int WEP_TYPE_HITSCAN = 0x02; // hitscan
111 const int WEP_TYPEMASK = 0x0F;
112 const int WEP_FLAG_CANCLIMB = 0x10; // can be used for movement
113 const int WEP_FLAG_NORMAL = 0x20; // in "most weapons" set
114 const int WEP_FLAG_HIDDEN = 0x40; // hides from menu
115 const int WEP_FLAG_RELOADABLE = 0x80; // can has reload
116 const int WEP_FLAG_SUPERWEAPON = 0x100; // powerup timer
117 const int WEP_FLAG_MUTATORBLOCKED = 0x200; // hides from impulse 99 etc. (mutators are allowed to clear this flag)
120 string weaponorder_byid;
123 string W_FixWeaponOrder(string order, float complete);
124 string W_UndeprecateName(string s);
125 string W_NameWeaponOrder(string order);
126 string W_NumberWeaponOrder(string order);
127 string W_FixWeaponOrder_BuildImpulseList(string o);
128 string W_FixWeaponOrder_AllowIncomplete(string order);
129 string W_FixWeaponOrder_ForceComplete(string order);
130 void W_RandomWeapons(entity e, float n);
132 string GetAmmoPicture(.int ammotype);
135 .int GetAmmoFieldFromNum(int i);
136 int GetAmmoStat(.int ammotype);
139 string W_Sound(string w_snd);
140 string W_Model(string w_mdl);
143 // other useful macros
144 #define WEP_AMMO(wpn) (WEP_##wpn.ammo_field) // only used inside weapon files/with direct name, don't duplicate prefix
145 #define WEP_NAME(wpn) ((get_weaponinfo(wpn)).message)