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