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