3 #include "../items/item/pickup.qh"
13 /** fields which are explicitly/manually set are marked with "M", fields set automatically are marked with "A" */
15 ATTRIB(Weapon, m_id, int, 0)
18 * you can recognize dummies when this == 0
20 ATTRIB(Weapon, weapon, int, 0);
21 /** A: WEPSET_id : WEPSET_... */
22 ATTRIB(Weapon, weapons, WepSet, '0 0 0');
23 /** M: ammotype : main ammo field */
24 ATTRIB(Weapon, ammo_field, .int, ammo_none);
25 /** M: impulse : weapon impulse */
26 ATTRIB(Weapon, impulse, int, -1);
27 /** M: flags : WEPSPAWNFLAG_... combined */
28 ATTRIB(Weapon, spawnflags, int, 0);
29 /** M: rating : bot weapon priority */
30 ATTRIB(Weapon, bot_pickupbasevalue, float, 0);
31 /** M: color : waypointsprite color */
32 ATTRIB(Weapon, wpcolor, vector, '0 0 0');
33 /** M: modelname : name of model (without g_ v_ or h_ prefixes) */
34 ATTRIB(Weapon, mdl, string, "");
35 /** M: model MDL_id_ITEM */
36 ATTRIB(Weapon, m_model, entity, NULL);
37 /** M: crosshair : per-weapon crosshair: "CrosshairImage Size" */
38 ATTRIB(Weapon, w_crosshair, string, "gfx/crosshair1");
39 /** A: crosshair : per-weapon crosshair size (argument two of "crosshair" field) */
40 ATTRIB(Weapon, w_crosshair_size, float, 1);
41 /** M: wepimg : "weaponfoobar" side view image file of weapon. WEAPONTODO: Move out of skin files, move to common files */
42 ATTRIB(Weapon, model2, string, "");
43 /** M: refname : reference name name */
44 ATTRIB(Weapon, netname, string, "");
45 /** M: wepname : human readable name */
46 ATTRIB(Weapon, m_name, string, "AOL CD Thrower");
48 ATTRIB(Weapon, m_pickup, entity, NULL);
50 /** (SERVER) setup weapon data */
51 METHOD(Weapon, wr_setup, void(Weapon this)) {}
52 /** (SERVER) logic to run every frame */
53 METHOD(Weapon, wr_think, void(Weapon this, entity actor, bool fire1, bool fire2)) {}
54 /** (SERVER) checks ammo for weapon primary */
55 METHOD(Weapon, wr_checkammo1, bool(Weapon this)) {return false;}
56 /** (SERVER) checks ammo for weapon second */
57 METHOD(Weapon, wr_checkammo2, bool(Weapon this)) {return false;}
58 /** (SERVER) runs bot aiming code for this weapon */
59 METHOD(Weapon, wr_aim, void(Weapon this)) {}
60 /** (BOTH) precaches models/sounds used by this weapon, also sets up weapon properties */
61 METHOD(Weapon, wr_init, void(Weapon this)) {}
62 /** (SERVER) notification number for suicide message (may inspect w_deathtype for details) */
63 METHOD(Weapon, wr_suicidemessage, int(Weapon this)) {return 0;}
64 /** (SERVER) notification number for kill message (may inspect w_deathtype for details) */
65 METHOD(Weapon, wr_killmessage, int(Weapon this)) {return 0;}
66 /** (SERVER) handles reloading for weapon */
67 METHOD(Weapon, wr_reload, void(Weapon this)) {}
68 /** (SERVER) clears fields that the weapon may use */
69 METHOD(Weapon, wr_resetplayer, void(Weapon this)) {}
70 /** (CLIENT) impact effect for weapon explosion */
71 METHOD(Weapon, wr_impacteffect, void(Weapon this)) {}
72 /** (SERVER) called whenever a player dies */
73 METHOD(Weapon, wr_playerdeath, void(Weapon this)) {}
74 /** (SERVER) logic to run when weapon is lost */
75 METHOD(Weapon, wr_gonethink, void(Weapon this)) {}
76 /** (ALL) dump weapon cvars to config in data directory (see: sv_cmd dumpweapons) */
77 METHOD(Weapon, wr_config, void(Weapon this)) {}
78 /** (CLIENT) weapon specific zoom reticle */
79 METHOD(Weapon, wr_zoomreticle, bool(Weapon this)) {
80 // no weapon specific image for this weapon
83 /** (SERVER) the weapon is dropped */
84 METHOD(Weapon, wr_drop, void(Weapon this)) {}
85 /** (SERVER) a weapon is picked up */
86 METHOD(Weapon, wr_pickup, void(Weapon this)) {}
88 METHOD(Weapon, display, void(entity this, void(string name, string icon) returns)) {
89 returns(this.m_name, this.model2 ? sprintf("/gfx/hud/%s/%s", cvar_string("menu_skin"), this.model2) : string_null);
93 #include "../items/all.qh"
94 CLASS(WeaponPickup, Pickup)
95 ATTRIB(WeaponPickup, m_weapon, Weapon, NULL)
96 ATTRIB(WeaponPickup, m_name, string, string_null)
98 ATTRIB(WeaponPickup, m_sound, Sound, SND_WEAPONPICKUP)
101 ATTRIB(WeaponPickup, m_itemflags, int, FL_WEAPON)
102 float weapon_pickupevalfunc(entity player, entity item);
103 ATTRIB(WeaponPickup, m_pickupevalfunc, float(entity player, entity item), weapon_pickupevalfunc)
105 CONSTRUCTOR(WeaponPickup, Weapon w) {
106 CONSTRUCT(WeaponPickup);
108 this.m_name = w.m_name;
110 this.m_model = w.m_model;
113 this.m_botvalue = w.bot_pickupbasevalue;
117 METHOD(WeaponPickup, giveTo, bool(entity this, entity item, entity player))
119 bool b = Item_GiveTo(item, player);
121 LOG_TRACEF("entity %i picked up %s\n", player, this.m_name);
126 ENDCLASS(WeaponPickup)
128 CLASS(OffhandWeapon, Object)
129 METHOD(OffhandWeapon, offhand_think, void(OffhandWeapon this, entity player, bool key_pressed)) {}
130 ENDCLASS(OffhandWeapon)
133 .OffhandWeapon offhand;
136 const int MAX_SHOT_DISTANCE = 32768;
138 // weapon pickup ratings for bot logic
139 const int BOT_PICKUP_RATING_LOW = 2500;
140 const int BOT_PICKUP_RATING_MID = 5000;
141 const int BOT_PICKUP_RATING_HIGH = 10000;
144 const int WEP_TYPE_OTHER = 0x00; // not for damaging people
145 const int WEP_TYPE_SPLASH = 0x01; // splash damage
146 const int WEP_TYPE_HITSCAN = 0x02; // hitscan
147 const int WEP_TYPEMASK = 0x0F;
148 const int WEP_FLAG_CANCLIMB = 0x10; // can be used for movement
149 const int WEP_FLAG_NORMAL = 0x20; // in "most weapons" set
150 const int WEP_FLAG_HIDDEN = 0x40; // hides from menu
151 const int WEP_FLAG_RELOADABLE = 0x80; // can has reload
152 const int WEP_FLAG_SUPERWEAPON = 0x100; // powerup timer
153 const int WEP_FLAG_MUTATORBLOCKED = 0x200; // hides from impulse 99 etc. (mutators are allowed to clear this flag)
156 string weaponorder_byid;
159 string W_FixWeaponOrder(string order, float complete);
160 string W_UndeprecateName(string s);
161 string W_NameWeaponOrder(string order);
162 string W_NumberWeaponOrder(string order);
163 string W_FixWeaponOrder_BuildImpulseList(string o);
164 string W_FixWeaponOrder_AllowIncomplete(string order);
165 string W_FixWeaponOrder_ForceComplete(string order);
166 void W_RandomWeapons(entity e, float n);
168 string GetAmmoPicture(.int ammotype);
171 .int GetAmmoFieldFromNum(int i);
172 int GetAmmoStat(.int ammotype);
175 string W_Sound(string w_snd);
176 string W_Model(string w_mdl);
179 // other useful macros
180 #define WEP_AMMO(wpn) (WEP_##wpn.ammo_field) // only used inside weapon files/with direct name, don't duplicate prefix
181 #define WEP_NAME(wpn) ((get_weaponinfo(wpn)).m_name)