3 #include "../items/item/pickup.qh"
5 const int MAX_WEAPONSLOTS = 2;
15 /** fields which are explicitly/manually set are marked with "M", fields set automatically are marked with "A" */
17 ATTRIB(Weapon, m_id, int, 0)
20 * you can recognize dummies when this == 0
22 ATTRIB(Weapon, weapon, int, 0);
23 /** A: WEPSET_id : WEPSET_... */
24 ATTRIB(Weapon, weapons, WepSet, '0 0 0');
25 /** M: ammotype : main ammo field */
26 ATTRIB(Weapon, ammo_field, .int, ammo_none);
27 /** M: impulse : weapon impulse */
28 ATTRIB(Weapon, impulse, int, -1);
29 /** M: flags : WEPSPAWNFLAG_... combined */
30 ATTRIB(Weapon, spawnflags, int, 0);
31 /** M: rating : bot weapon priority */
32 ATTRIB(Weapon, bot_pickupbasevalue, float, 0);
33 /** M: color : waypointsprite color */
34 ATTRIB(Weapon, wpcolor, vector, '0 0 0');
35 /** M: modelname : name of model (without g_ v_ or h_ prefixes) */
36 ATTRIB(Weapon, mdl, string, "");
37 /** M: model MDL_id_ITEM */
38 ATTRIB(Weapon, m_model, entity, NULL);
39 /** M: crosshair : per-weapon crosshair: "CrosshairImage Size" */
40 ATTRIB(Weapon, w_crosshair, string, "gfx/crosshair1");
41 /** A: crosshair : per-weapon crosshair size (argument two of "crosshair" field) */
42 ATTRIB(Weapon, w_crosshair_size, float, 1);
43 /** M: wepimg : "weaponfoobar" side view image file of weapon. WEAPONTODO: Move out of skin files, move to common files */
44 ATTRIB(Weapon, model2, string, "");
45 /** M: refname : reference name name */
46 ATTRIB(Weapon, netname, string, "");
47 /** M: wepname : human readable name */
48 ATTRIB(Weapon, m_name, string, "AOL CD Thrower");
50 ATTRIB(Weapon, m_pickup, entity, NULL);
52 /** (SERVER) setup weapon data */
53 METHOD(Weapon, wr_setup, void(Weapon this)) {}
54 /** (SERVER) logic to run every frame */
55 METHOD(Weapon, wr_think, void(Weapon this, entity actor, int slot, int fire)) {}
56 /** (SERVER) checks ammo for weapon primary */
57 METHOD(Weapon, wr_checkammo1, bool(Weapon this)) {return false;}
58 /** (SERVER) checks ammo for weapon second */
59 METHOD(Weapon, wr_checkammo2, bool(Weapon this)) {return false;}
60 /** (SERVER) runs bot aiming code for this weapon */
61 METHOD(Weapon, wr_aim, void(Weapon this)) {}
62 /** (BOTH) precaches models/sounds used by this weapon, also sets up weapon properties */
63 METHOD(Weapon, wr_init, void(Weapon this)) {}
64 /** (SERVER) notification number for suicide message (may inspect w_deathtype for details) */
65 METHOD(Weapon, wr_suicidemessage, int(Weapon this)) {return 0;}
66 /** (SERVER) notification number for kill message (may inspect w_deathtype for details) */
67 METHOD(Weapon, wr_killmessage, int(Weapon this)) {return 0;}
68 /** (SERVER) handles reloading for weapon */
69 METHOD(Weapon, wr_reload, void(Weapon this)) {}
70 /** (SERVER) clears fields that the weapon may use */
71 METHOD(Weapon, wr_resetplayer, void(Weapon this)) {}
72 /** (CLIENT) impact effect for weapon explosion */
73 METHOD(Weapon, wr_impacteffect, void(Weapon this)) {}
74 /** (SERVER) called whenever a player dies */
75 METHOD(Weapon, wr_playerdeath, void(Weapon this)) {}
76 /** (SERVER) logic to run when weapon is lost */
77 METHOD(Weapon, wr_gonethink, void(Weapon this)) {}
78 /** (ALL) dump weapon cvars to config in data directory (see: sv_cmd dumpweapons) */
79 METHOD(Weapon, wr_config, void(Weapon this)) {}
80 /** (CLIENT) weapon specific zoom reticle */
81 METHOD(Weapon, wr_zoomreticle, bool(Weapon this)) {
82 // no weapon specific image for this weapon
85 /** (SERVER) the weapon is dropped */
86 METHOD(Weapon, wr_drop, void(Weapon this)) {}
87 /** (SERVER) a weapon is picked up */
88 METHOD(Weapon, wr_pickup, void(Weapon this)) {}
90 METHOD(Weapon, display, void(entity this, void(string name, string icon) returns)) {
91 returns(this.m_name, this.model2 ? sprintf("/gfx/hud/%s/%s", cvar_string("menu_skin"), this.model2) : string_null);
95 #include "../items/all.qh"
96 CLASS(WeaponPickup, Pickup)
97 ATTRIB(WeaponPickup, m_weapon, Weapon, NULL)
98 ATTRIB(WeaponPickup, m_name, string, string_null)
100 ATTRIB(WeaponPickup, m_sound, Sound, SND_WEAPONPICKUP)
103 ATTRIB(WeaponPickup, m_itemflags, int, FL_WEAPON)
104 float weapon_pickupevalfunc(entity player, entity item);
105 ATTRIB(WeaponPickup, m_pickupevalfunc, float(entity player, entity item), weapon_pickupevalfunc)
107 CONSTRUCTOR(WeaponPickup, Weapon w) {
108 CONSTRUCT(WeaponPickup);
110 this.m_name = w.m_name;
112 this.m_model = w.m_model;
115 this.m_botvalue = w.bot_pickupbasevalue;
119 METHOD(WeaponPickup, giveTo, bool(entity this, entity item, entity player))
121 bool b = Item_GiveTo(item, player);
123 LOG_TRACEF("entity %i picked up %s\n", player, this.m_name);
128 ENDCLASS(WeaponPickup)
130 CLASS(OffhandWeapon, Object)
131 METHOD(OffhandWeapon, offhand_think, void(OffhandWeapon this, entity player, bool key_pressed)) {}
132 ENDCLASS(OffhandWeapon)
135 .OffhandWeapon offhand;
138 const int MAX_SHOT_DISTANCE = 32768;
140 // weapon pickup ratings for bot logic
141 const int BOT_PICKUP_RATING_LOW = 2500;
142 const int BOT_PICKUP_RATING_MID = 5000;
143 const int BOT_PICKUP_RATING_HIGH = 10000;
146 const int WEP_TYPE_OTHER = 0x00; // not for damaging people
147 const int WEP_TYPE_SPLASH = 0x01; // splash damage
148 const int WEP_TYPE_HITSCAN = 0x02; // hitscan
149 const int WEP_TYPEMASK = 0x0F;
150 const int WEP_FLAG_CANCLIMB = 0x10; // can be used for movement
151 const int WEP_FLAG_NORMAL = 0x20; // in "most weapons" set
152 const int WEP_FLAG_HIDDEN = 0x40; // hides from menu
153 const int WEP_FLAG_RELOADABLE = 0x80; // can has reload
154 const int WEP_FLAG_SUPERWEAPON = 0x100; // powerup timer
155 const int WEP_FLAG_MUTATORBLOCKED = 0x200; // hides from impulse 99 etc. (mutators are allowed to clear this flag)
158 string weaponorder_byid;
161 string W_FixWeaponOrder(string order, float complete);
162 string W_UndeprecateName(string s);
163 string W_NameWeaponOrder(string order);
164 string W_NumberWeaponOrder(string order);
165 string W_FixWeaponOrder_BuildImpulseList(string o);
166 string W_FixWeaponOrder_AllowIncomplete(string order);
167 string W_FixWeaponOrder_ForceComplete(string order);
168 void W_RandomWeapons(entity e, float n);
170 string GetAmmoPicture(.int ammotype);
173 .int GetAmmoFieldFromNum(int i);
174 int GetAmmoStat(.int ammotype);
177 string W_Sound(string w_snd);
178 string W_Model(string w_mdl);
181 // other useful macros
182 #define WEP_AMMO(wpn) (WEP_##wpn.ammo_field) // only used inside weapon files/with direct name, don't duplicate prefix
183 #define WEP_NAME(wpn) ((get_weaponinfo(wpn)).m_name)