3 #include <common/resources.qh>
4 #include <common/items/item/pickup.qh>
5 #include <common/stats.qh>
8 #include <common/effects/qc/_mod.qh>
11 USING(WepSet, vector);
13 const int MAX_WEAPONSLOTS = 2;
14 .entity weaponentities[MAX_WEAPONSLOTS];
16 int weaponslot(.entity weaponentity)
18 for (int i = 0; i < MAX_WEAPONSLOTS; ++i)
20 if (weaponentities[i] == weaponentity)
28 // weapon states (actor.(weaponentity).state)
29 /** no weapon selected */
30 const int WS_CLEAR = 0;
32 const int WS_RAISE = 1;
33 /** deselecting frame */
34 const int WS_DROP = 2;
36 const int WS_INUSE = 3;
38 const int WS_READY = 4;
45 .int ammo_plasma = _STAT(PLASMA);
46 .int ammo_fuel = _STAT(FUEL);
58 /** fields which are explicitly/manually set are marked with "M", fields set automatically are marked with "A" */
60 ATTRIB(Weapon, m_id, int, 0);
61 /** A: WEPSET_id : WEPSET_... */
62 ATTRIB(Weapon, weapons, WepSet, '0 0 0');
63 /** M: ammotype : main ammo type */
64 ATTRIB(Weapon, ammo_type, int, RESOURCE_NONE);
65 /** M: impulse : weapon impulse */
66 ATTRIB(Weapon, impulse, int, -1);
67 /** M: flags : WEPSPAWNFLAG_... combined */
68 ATTRIB(Weapon, spawnflags, int, 0);
69 /** M: rating : bot weapon priority */
70 ATTRIB(Weapon, bot_pickupbasevalue, float, 0);
71 /** M: color : waypointsprite color */
72 ATTRIB(Weapon, wpcolor, vector, '0 0 0');
73 /** M: modelname : name of model (without g_ v_ or h_ prefixes) */
74 ATTRIB(Weapon, mdl, string, "");
75 /** M: model MDL_id_ITEM */
76 ATTRIB(Weapon, m_model, entity);
77 /** M: crosshair : per-weapon crosshair: "CrosshairImage Size" */
78 ATTRIB(Weapon, w_crosshair, string, "gfx/crosshairmoustache");
79 /** A: crosshair : per-weapon crosshair size (argument two of "crosshair" field) */
80 ATTRIB(Weapon, w_crosshair_size, float, 1);
81 /** A: reticle : per-weapon zoom reticle */
82 ATTRIB(Weapon, w_reticle, string, string_null);
83 /** M: wepimg : "weaponfoobar" side view image file of weapon. WEAPONTODO: Move out of skin files, move to common files */
84 ATTRIB(Weapon, model2, string, "");
85 /** M: refname : reference name name */
86 ATTRIB(Weapon, netname, string, "");
87 /** M: wepname : human readable name */
88 ATTRIB(Weapon, m_name, string, "AOL CD Thrower");
90 ATTRIB(Weapon, m_pickup, entity);
92 /** (SERVER) setup weapon data */
93 METHOD(Weapon, wr_setup, void(Weapon this, entity actor, .entity weaponentity)) {}
94 /** (SERVER) logic to run every frame */
95 METHOD(Weapon, wr_think, void(Weapon this, entity actor, .entity weaponentity, int fire)) {}
96 /** (SERVER) checks ammo for weapon primary */
97 METHOD(Weapon, wr_checkammo1, bool(Weapon this, entity actor, .entity weaponentity)) {return false;}
98 /** (SERVER) checks ammo for weapon second */
99 METHOD(Weapon, wr_checkammo2, bool(Weapon this, entity actor, .entity weaponentity)) {return false;}
100 /** (SERVER) runs bot aiming code for this weapon */
101 METHOD(Weapon, wr_aim, void(Weapon this, entity actor, .entity weaponentity)) {}
102 /** (BOTH) precaches models/sounds used by this weapon, also sets up weapon properties */
103 METHOD(Weapon, wr_init, void(Weapon this)) {}
104 /** (SERVER) notification number for suicide message (may inspect w_deathtype for details) */
105 METHOD(Weapon, wr_suicidemessage, entity(Weapon this)) {return NULL;}
106 /** (SERVER) notification number for kill message (may inspect w_deathtype for details) */
107 METHOD(Weapon, wr_killmessage, entity(Weapon this)) {return NULL;}
108 /** (SERVER) handles reloading for weapon */
109 METHOD(Weapon, wr_reload, void(Weapon this, entity actor, .entity weaponentity)) {}
110 /** (SERVER) clears fields that the weapon may use */
111 METHOD(Weapon, wr_resetplayer, void(Weapon this, entity actor)) {}
112 /** (CLIENT) impact effect for weapon explosion */
113 METHOD(Weapon, wr_impacteffect, void(Weapon this, entity actor)) {}
114 /** (SERVER) called whenever a player dies */
115 METHOD(Weapon, wr_playerdeath, void(Weapon this, entity actor, .entity weaponentity)) {}
116 /** (SERVER) logic to run when weapon is lost */
117 METHOD(Weapon, wr_gonethink, void(Weapon this, entity actor, .entity weaponentity)) {}
118 /** (ALL) dump weapon cvars to config in data directory (see: sv_cmd dumpweapons) */
119 METHOD(Weapon, wr_config, void(Weapon this)) {}
120 /** (BOTH) weapon specific zoom reticle */
121 METHOD(Weapon, wr_zoom, bool(Weapon this, entity actor)) {
122 // no weapon specific image for this weapon
125 /** (CLIENT) weapon specific view model */
126 METHOD(Weapon, wr_viewmodel, string(Weapon this, entity wep)) { return string_null; }
127 /** (CLIENT) weapon specific glow */
128 METHOD(Weapon, wr_glow, vector(Weapon this, entity actor, entity wepent)) { return '0 0 0'; }
129 /** (SERVER) the weapon is dropped */
130 METHOD(Weapon, wr_drop, void(Weapon this, entity actor, .entity weaponentity)) {}
131 /** (SERVER) a weapon is picked up */
132 METHOD(Weapon, wr_pickup, void(Weapon this, entity actor, .entity weaponentity)) {}
133 /** (SERVER) update cvar based properties */
134 METHOD(Weapon, wr_update, void(Weapon this)) {}
135 METHOD(Weapon, display, void(entity this, void(string name, string icon) returns)) {
136 returns(this.m_name, this.model2 ? sprintf("/gfx/hud/%s/%s", cvar_string("menu_skin"), this.model2) : string_null);
140 #include <common/items/_mod.qh>
141 CLASS(WeaponPickup, Pickup)
142 ATTRIB(WeaponPickup, m_weapon, Weapon);
143 ATTRIB(WeaponPickup, m_name, string);
145 ATTRIB(WeaponPickup, m_sound, Sound, SND_WEAPONPICKUP);
148 ATTRIB(WeaponPickup, m_itemflags, int, FL_WEAPON);
149 float weapon_pickupevalfunc(entity player, entity item);
150 ATTRIB(WeaponPickup, m_pickupevalfunc, float(entity player, entity item), weapon_pickupevalfunc);
152 CONSTRUCTOR(WeaponPickup, Weapon w) {
153 CONSTRUCT(WeaponPickup);
155 this.m_name = w.m_name;
157 this.m_model = w.m_model;
160 this.m_botvalue = w.bot_pickupbasevalue;
164 METHOD(WeaponPickup, giveTo, bool(entity this, entity item, entity player))
166 bool b = Item_GiveTo(item, player);
168 LOG_TRACEF("entity %i picked up %s", player, this.m_name);
173 ENDCLASS(WeaponPickup)
175 CLASS(OffhandWeapon, Object)
176 METHOD(OffhandWeapon, offhand_think, void(OffhandWeapon this, entity player, bool key_pressed)) {}
177 ENDCLASS(OffhandWeapon)
180 .OffhandWeapon offhand;
184 int max_shot_distance = 32768; // determined by world mins/maxs when map loads
188 const int WEP_TYPE_OTHER = 0x00; // not for damaging people
189 const int WEP_TYPE_SPLASH = 0x01; // splash damage
190 const int WEP_TYPE_HITSCAN = 0x02; // hitscan
191 const int WEP_TYPEMASK = 0x0F;
192 const int WEP_FLAG_CANCLIMB = 0x10; // can be used for movement
193 const int WEP_FLAG_NORMAL = 0x20; // in "most weapons" set
194 const int WEP_FLAG_HIDDEN = 0x40; // hides from menu
195 const int WEP_FLAG_RELOADABLE = 0x80; // can has reload
196 const int WEP_FLAG_SUPERWEAPON = 0x100; // powerup timer
197 const int WEP_FLAG_MUTATORBLOCKED = 0x200; // hides from impulse 99 etc. (mutators are allowed to clear this flag)
198 const int WEP_TYPE_MELEE_PRI = 0x400; // primary attack is melee swing (for animation)
199 const int WEP_TYPE_MELEE_SEC = 0x800; // secondary attack is melee swing (for animation)
200 const int WEP_FLAG_DUALWIELD = 0x1000; // weapon can be dual wielded
201 const int WEP_FLAG_NODUAL = 0x2000; // weapon doesn't work well with dual wielding (fireball etc just explode on fire), doesn't currently prevent anything
202 const int WEP_FLAG_PENETRATEWALLS = 0x4000; // weapon has high calibur bullets that can penetrate thick walls (WEAPONTODO)
205 string weaponorder_byid;
208 string W_FixWeaponOrder(string order, float complete);
209 string W_UndeprecateName(string s);
210 string W_NameWeaponOrder(string order);
211 string W_NumberWeaponOrder(string order);
212 string W_FixWeaponOrder_BuildImpulseList(string o);
213 string W_FixWeaponOrder_AllowIncomplete(entity this, string order);
214 string W_FixWeaponOrder_ForceComplete(string order);
215 void W_RandomWeapons(entity e, int n);
217 string GetAmmoPicture(int ammotype);
220 int GetAmmoTypeFromNum(int i);
221 int GetAmmoStat(int ammotype);
224 string W_Sound(string w_snd);
225 string W_Model(string w_mdl);