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)
21 // weapon states (actor.(weaponentity).state)
22 /** no weapon selected */
23 const int WS_CLEAR = 0;
25 const int WS_RAISE = 1;
26 /** deselecting frame */
27 const int WS_DROP = 2;
29 const int WS_INUSE = 3;
31 const int WS_READY = 4;
38 .int ammo_plasma = _STAT(PLASMA);
39 .int ammo_fuel = _STAT(FUEL);
51 /** fields which are explicitly/manually set are marked with "M", fields set automatically are marked with "A" */
53 ATTRIB(Weapon, m_id, int, 0)
54 /** A: WEPSET_id : WEPSET_... */
55 ATTRIB(Weapon, weapons, WepSet, '0 0 0');
56 /** M: ammotype : main ammo field */
57 ATTRIB(Weapon, ammo_field, .int, ammo_none);
58 /** M: impulse : weapon impulse */
59 ATTRIB(Weapon, impulse, int, -1);
60 /** M: flags : WEPSPAWNFLAG_... combined */
61 ATTRIB(Weapon, spawnflags, int, 0);
62 /** M: rating : bot weapon priority */
63 ATTRIB(Weapon, bot_pickupbasevalue, float, 0);
64 /** M: color : waypointsprite color */
65 ATTRIB(Weapon, wpcolor, vector, '0 0 0');
66 /** M: modelname : name of model (without g_ v_ or h_ prefixes) */
67 ATTRIB(Weapon, mdl, string, "");
68 /** M: model MDL_id_ITEM */
69 ATTRIB(Weapon, m_model, entity, NULL);
70 /** M: crosshair : per-weapon crosshair: "CrosshairImage Size" */
71 ATTRIB(Weapon, w_crosshair, string, "gfx/crosshair1");
72 /** A: crosshair : per-weapon crosshair size (argument two of "crosshair" field) */
73 ATTRIB(Weapon, w_crosshair_size, float, 1);
74 /** M: wepimg : "weaponfoobar" side view image file of weapon. WEAPONTODO: Move out of skin files, move to common files */
75 ATTRIB(Weapon, model2, string, "");
76 /** M: refname : reference name name */
77 ATTRIB(Weapon, netname, string, "");
78 /** M: wepname : human readable name */
79 ATTRIB(Weapon, m_name, string, "AOL CD Thrower");
81 ATTRIB(Weapon, m_pickup, entity, NULL);
83 /** (SERVER) setup weapon data */
84 METHOD(Weapon, wr_setup, void(Weapon this)) {}
85 /** (SERVER) logic to run every frame */
86 METHOD(Weapon, wr_think, void(Weapon this, entity actor, .entity weaponentity, int fire)) {}
87 /** (SERVER) checks ammo for weapon primary */
88 METHOD(Weapon, wr_checkammo1, bool(Weapon this)) {return false;}
89 /** (SERVER) checks ammo for weapon second */
90 METHOD(Weapon, wr_checkammo2, bool(Weapon this)) {return false;}
91 /** (SERVER) runs bot aiming code for this weapon */
92 METHOD(Weapon, wr_aim, void(Weapon this)) {}
93 /** (BOTH) precaches models/sounds used by this weapon, also sets up weapon properties */
94 METHOD(Weapon, wr_init, void(Weapon this)) {}
95 /** (SERVER) notification number for suicide message (may inspect w_deathtype for details) */
96 METHOD(Weapon, wr_suicidemessage, int(Weapon this)) {return 0;}
97 /** (SERVER) notification number for kill message (may inspect w_deathtype for details) */
98 METHOD(Weapon, wr_killmessage, int(Weapon this)) {return 0;}
99 /** (SERVER) handles reloading for weapon */
100 METHOD(Weapon, wr_reload, void(Weapon this, entity actor, .entity weaponentity)) {}
101 /** (SERVER) clears fields that the weapon may use */
102 METHOD(Weapon, wr_resetplayer, void(Weapon this)) {}
103 /** (CLIENT) impact effect for weapon explosion */
104 METHOD(Weapon, wr_impacteffect, void(Weapon this)) {}
105 /** (SERVER) called whenever a player dies */
106 METHOD(Weapon, wr_playerdeath, void(Weapon this)) {}
107 /** (SERVER) logic to run when weapon is lost */
108 METHOD(Weapon, wr_gonethink, void(Weapon this)) {}
109 /** (ALL) dump weapon cvars to config in data directory (see: sv_cmd dumpweapons) */
110 METHOD(Weapon, wr_config, void(Weapon this)) {}
111 /** (CLIENT) weapon specific zoom reticle */
112 METHOD(Weapon, wr_zoomreticle, bool(Weapon this)) {
113 // no weapon specific image for this weapon
116 /** (CLIENT) weapon specific glow */
117 METHOD(Weapon, wr_glow, vector(Weapon this)) { return '0 0 0'; }
118 /** (SERVER) the weapon is dropped */
119 METHOD(Weapon, wr_drop, void(Weapon this)) {}
120 /** (SERVER) a weapon is picked up */
121 METHOD(Weapon, wr_pickup, void(Weapon this)) {}
122 /** (SERVER) update cvar based properties */
123 METHOD(Weapon, wr_update, void(Weapon this)) {}
124 METHOD(Weapon, display, void(entity this, void(string name, string icon) returns)) {
125 returns(this.m_name, this.model2 ? sprintf("/gfx/hud/%s/%s", cvar_string("menu_skin"), this.model2) : string_null);
129 #include "../items/all.qh"
130 CLASS(WeaponPickup, Pickup)
131 ATTRIB(WeaponPickup, m_weapon, Weapon, NULL)
132 ATTRIB(WeaponPickup, m_name, string, string_null)
134 ATTRIB(WeaponPickup, m_sound, Sound, SND_WEAPONPICKUP)
137 ATTRIB(WeaponPickup, m_itemflags, int, FL_WEAPON)
138 float weapon_pickupevalfunc(entity player, entity item);
139 ATTRIB(WeaponPickup, m_pickupevalfunc, float(entity player, entity item), weapon_pickupevalfunc)
141 CONSTRUCTOR(WeaponPickup, Weapon w) {
142 CONSTRUCT(WeaponPickup);
144 this.m_name = w.m_name;
146 this.m_model = w.m_model;
149 this.m_botvalue = w.bot_pickupbasevalue;
153 METHOD(WeaponPickup, giveTo, bool(entity this, entity item, entity player))
155 bool b = Item_GiveTo(item, player);
157 LOG_TRACEF("entity %i picked up %s\n", player, this.m_name);
162 ENDCLASS(WeaponPickup)
164 CLASS(OffhandWeapon, Object)
165 METHOD(OffhandWeapon, offhand_think, void(OffhandWeapon this, entity player, bool key_pressed)) {}
166 ENDCLASS(OffhandWeapon)
169 .OffhandWeapon offhand;
172 const int MAX_SHOT_DISTANCE = 32768;
174 // weapon pickup ratings for bot logic
175 const int BOT_PICKUP_RATING_LOW = 2500;
176 const int BOT_PICKUP_RATING_MID = 5000;
177 const int BOT_PICKUP_RATING_HIGH = 10000;
180 const int WEP_TYPE_OTHER = 0x00; // not for damaging people
181 const int WEP_TYPE_SPLASH = 0x01; // splash damage
182 const int WEP_TYPE_HITSCAN = 0x02; // hitscan
183 const int WEP_TYPEMASK = 0x0F;
184 const int WEP_FLAG_CANCLIMB = 0x10; // can be used for movement
185 const int WEP_FLAG_NORMAL = 0x20; // in "most weapons" set
186 const int WEP_FLAG_HIDDEN = 0x40; // hides from menu
187 const int WEP_FLAG_RELOADABLE = 0x80; // can has reload
188 const int WEP_FLAG_SUPERWEAPON = 0x100; // powerup timer
189 const int WEP_FLAG_MUTATORBLOCKED = 0x200; // hides from impulse 99 etc. (mutators are allowed to clear this flag)
192 string weaponorder_byid;
195 string W_FixWeaponOrder(string order, float complete);
196 string W_UndeprecateName(string s);
197 string W_NameWeaponOrder(string order);
198 string W_NumberWeaponOrder(string order);
199 string W_FixWeaponOrder_BuildImpulseList(string o);
200 string W_FixWeaponOrder_AllowIncomplete(string order);
201 string W_FixWeaponOrder_ForceComplete(string order);
202 void W_RandomWeapons(entity e, float n);
204 string GetAmmoPicture(.int ammotype);
207 .int GetAmmoFieldFromNum(int i);
208 int GetAmmoStat(.int ammotype);
211 string W_Sound(string w_snd);
212 string W_Model(string w_mdl);