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