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