5 /* ammotype */ ammo_nails,
7 /* flags */ WEP_FLAG_RELOADABLE | WEP_TYPE_HITSCAN,
8 /* rating */ BOT_PICKUP_RATING_MID,
11 /* fullname */ _("Machine Gun")
14 #define UZI_SETTINGS(w_cvar,w_prop) UZI_SETTINGS_LIST(w_cvar, w_prop, UZI, uzi)
15 #define UZI_SETTINGS_LIST(w_cvar,w_prop,id,sn) \
16 w_cvar(id, sn, NONE, spread_min) \
17 w_cvar(id, sn, NONE, spread_max) \
18 w_cvar(id, sn, NONE, spread_add) \
19 w_cvar(id, sn, NONE, mode) \
20 w_cvar(id, sn, NONE, first) \
21 w_cvar(id, sn, NONE, first_damage) \
22 w_cvar(id, sn, NONE, first_force) \
23 w_cvar(id, sn, NONE, first_refire) \
24 w_cvar(id, sn, NONE, first_spread) \
25 w_cvar(id, sn, NONE, first_ammo) \
26 w_cvar(id, sn, NONE, solidpenetration) \
27 w_cvar(id, sn, NONE, sustained_damage) \
28 w_cvar(id, sn, NONE, sustained_force) \
29 w_cvar(id, sn, NONE, sustained_refire) \
30 w_cvar(id, sn, NONE, sustained_spread) \
31 w_cvar(id, sn, NONE, sustained_ammo) \
32 w_cvar(id, sn, NONE, burst) \
33 w_cvar(id, sn, NONE, burst_refire) \
34 w_cvar(id, sn, NONE, burst_refire2) \
35 w_cvar(id, sn, NONE, burst_animtime) \
36 w_cvar(id, sn, NONE, burst_speed) \
37 w_cvar(id, sn, NONE, burst_ammo) \
38 w_prop(id, sn, float, reloading_ammo, reload_ammo) \
39 w_prop(id, sn, float, reloading_time, reload_time) \
40 w_prop(id, sn, float, switchdelay_raise, switchdelay_raise) \
41 w_prop(id, sn, float, switchdelay_drop, switchdelay_drop) \
42 w_prop(id, sn, string, weaponreplace, weaponreplace) \
43 w_prop(id, sn, float, weaponstart, weaponstart) \
44 w_prop(id, sn, float, weaponstartoverride, weaponstartoverride)
47 UZI_SETTINGS(WEP_ADD_CVAR, WEP_ADD_PROP)
52 void spawnfunc_weapon_uzi()
54 if(autocvar_sv_q3acompat_machineshotgunswap)
55 if(self.classname != "droppedweapon")
57 weapon_defaultspawnfunc(WEP_SHOCKWAVE);
60 weapon_defaultspawnfunc(WEP_UZI);
63 // leilei's fancy muzzleflash stuff
66 self.frame = self.frame + 2;
67 self.scale = self.scale * 0.5;
68 self.alpha = self.alpha - 0.25;
69 self.nextthink = time + 0.05;
73 self.think = SUB_Remove;
74 self.nextthink = time;
75 self.realowner.muzzle_flash = world;
83 if (self.muzzle_flash == world)
84 self.muzzle_flash = spawn();
86 // muzzle flash for 1st person view
87 setmodel(self.muzzle_flash, "models/uziflash.md3"); // precision set below
89 self.muzzle_flash.scale = 0.75;
90 self.muzzle_flash.think = UZI_Flash_Go;
91 self.muzzle_flash.nextthink = time + 0.02;
92 self.muzzle_flash.frame = 2;
93 self.muzzle_flash.alpha = 0.75;
94 self.muzzle_flash.angles_z = random() * 180;
95 self.muzzle_flash.effects = EF_ADDITIVE | EF_FULLBRIGHT | EF_LOWPRECISION;
96 self.muzzle_flash.owner = self.muzzle_flash.realowner = self;
99 void W_UZI_Attack (float deathtype)
101 W_SetupShot (self, TRUE, 0, "weapons/uzi_fire.wav", CH_WEAPON_A, ((self.misc_bulletcounter == 1) ? WEP_CVAR(uzi, first_damage) : WEP_CVAR(uzi, sustained_damage)));
102 if (!autocvar_g_norecoil)
104 self.punchangle_x = random () - 0.5;
105 self.punchangle_y = random () - 0.5;
108 // this attack_finished just enforces a cooldown at the end of a burst
109 ATTACK_FINISHED(self) = time + WEP_CVAR(uzi, first_refire) * W_WeaponRateFactor();
111 if (self.misc_bulletcounter == 1)
112 fireBullet(w_shotorg, w_shotdir, WEP_CVAR(uzi, first_spread), WEP_CVAR(uzi, solidpenetration), WEP_CVAR(uzi, first_damage), WEP_CVAR(uzi, first_force), deathtype, 0);
114 fireBullet(w_shotorg, w_shotdir, WEP_CVAR(uzi, sustained_spread), WEP_CVAR(uzi, solidpenetration), WEP_CVAR(uzi, sustained_damage), WEP_CVAR(uzi, sustained_force), deathtype, 0);
116 pointparticles(particleeffectnum("uzi_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
119 W_AttachToShotorg(self.muzzle_flash, '5 0 0');
122 if (autocvar_g_casings >= 2)
123 SpawnCasing (((random () * 50 + 50) * v_right) - (v_forward * (random () * 25 + 25)) - ((random () * 5 - 70) * v_up), 2, vectoangles(v_forward),'0 250 0', 100, 3, self);
125 if (self.misc_bulletcounter == 1)
126 W_DecreaseAmmo(WEP_CVAR(uzi, first_ammo));
128 W_DecreaseAmmo(WEP_CVAR(uzi, sustained_ammo));
134 if(self.weapon != self.switchweapon) // abort immediately if switching
139 if (self.BUTTON_ATCK)
141 if (!WEP_ACTION(self.weapon, WR_CHECKAMMO2))
142 if (!(self.items & IT_UNLIMITED_WEAPON_AMMO))
144 W_SwitchWeapon_Force(self, w_getbestweapon(self));
148 self.misc_bulletcounter = self.misc_bulletcounter + 1;
149 W_UZI_Attack(WEP_UZI);
150 weapon_thinkf(WFRAME_FIRE1, WEP_CVAR(uzi, sustained_refire), uzi_fire1_02);
153 weapon_thinkf(WFRAME_FIRE1, WEP_CVAR(uzi, sustained_refire), w_ready);
157 void uzi_mode1_fire_auto()
161 if (!self.BUTTON_ATCK)
167 if (!WEP_ACTION(self.weapon, WR_CHECKAMMO1))
168 if (!(self.items & IT_UNLIMITED_WEAPON_AMMO))
170 W_SwitchWeapon_Force(self, w_getbestweapon(self));
175 W_DecreaseAmmo(WEP_CVAR(uzi, sustained_ammo));
177 W_SetupShot (self, TRUE, 0, "weapons/uzi_fire.wav", CH_WEAPON_A, WEP_CVAR(uzi, sustained_damage));
178 if (!autocvar_g_norecoil)
180 self.punchangle_x = random () - 0.5;
181 self.punchangle_y = random () - 0.5;
184 uzi_spread = bound(WEP_CVAR(uzi, spread_min), WEP_CVAR(uzi, spread_min) + (WEP_CVAR(uzi, spread_add) * self.misc_bulletcounter), WEP_CVAR(uzi, spread_max));
185 fireBullet(w_shotorg, w_shotdir, uzi_spread, WEP_CVAR(uzi, solidpenetration), WEP_CVAR(uzi, sustained_damage), WEP_CVAR(uzi, sustained_force), WEP_UZI, 0);
187 self.misc_bulletcounter = self.misc_bulletcounter + 1;
189 pointparticles(particleeffectnum("uzi_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
192 W_AttachToShotorg(self.muzzle_flash, '5 0 0');
194 if (autocvar_g_casings >= 2) // casing code
195 SpawnCasing (((random () * 50 + 50) * v_right) - (v_forward * (random () * 25 + 25)) - ((random () * 5 - 70) * v_up), 2, vectoangles(v_forward),'0 250 0', 100, 3, self);
197 ATTACK_FINISHED(self) = time + WEP_CVAR(uzi, first_refire) * W_WeaponRateFactor();
198 weapon_thinkf(WFRAME_FIRE1, WEP_CVAR(uzi, sustained_refire), uzi_mode1_fire_auto);
201 void uzi_mode1_fire_burst()
203 W_SetupShot (self, TRUE, 0, "weapons/uzi_fire.wav", CH_WEAPON_A, WEP_CVAR(uzi, sustained_damage));
204 if (!autocvar_g_norecoil)
206 self.punchangle_x = random () - 0.5;
207 self.punchangle_y = random () - 0.5;
210 fireBullet(w_shotorg, w_shotdir, WEP_CVAR(uzi, burst_speed), WEP_CVAR(uzi, solidpenetration), WEP_CVAR(uzi, sustained_damage), WEP_CVAR(uzi, sustained_force), WEP_UZI, 0);
212 pointparticles(particleeffectnum("uzi_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
215 W_AttachToShotorg(self.muzzle_flash, '5 0 0');
217 if (autocvar_g_casings >= 2) // casing code
218 SpawnCasing (((random () * 50 + 50) * v_right) - (v_forward * (random () * 25 + 25)) - ((random () * 5 - 70) * v_up), 2, vectoangles(v_forward),'0 250 0', 100, 3, self);
220 self.misc_bulletcounter = self.misc_bulletcounter + 1;
221 if (self.misc_bulletcounter == 0)
223 ATTACK_FINISHED(self) = time + WEP_CVAR(uzi, burst_refire2) * W_WeaponRateFactor();
224 weapon_thinkf(WFRAME_FIRE2, WEP_CVAR(uzi, burst_animtime), w_ready);
228 weapon_thinkf(WFRAME_FIRE2, WEP_CVAR(uzi, burst_refire), uzi_mode1_fire_burst);
233 float w_uzi(float req)
240 if(vlen(self.origin-self.enemy.origin) < 3000 - bound(0, skill, 10) * 200)
241 self.BUTTON_ATCK = bot_aim(1000000, 0, 0.001, FALSE);
243 self.BUTTON_ATCK2 = bot_aim(1000000, 0, 0.001, FALSE);
249 if(autocvar_g_balance_uzi_reload_ammo && self.clip_load < min(max(WEP_CVAR(uzi, sustained_ammo), WEP_CVAR(uzi, first_ammo)), WEP_CVAR(uzi, burst_ammo))) // forced reload
250 WEP_ACTION(self.weapon, WR_RELOAD);
251 else if(WEP_CVAR(uzi, mode) == 1)
253 if (self.BUTTON_ATCK)
254 if (weapon_prepareattack(0, 0))
256 self.misc_bulletcounter = 0;
257 uzi_mode1_fire_auto();
260 if(self.BUTTON_ATCK2)
261 if(weapon_prepareattack(1, 0))
263 if (!WEP_ACTION(self.weapon, WR_CHECKAMMO2))
264 if (!(self.items & IT_UNLIMITED_WEAPON_AMMO))
266 W_SwitchWeapon_Force(self, w_getbestweapon(self));
271 W_DecreaseAmmo(WEP_CVAR(uzi, burst_ammo));
273 self.misc_bulletcounter = WEP_CVAR(uzi, burst) * -1;
274 uzi_mode1_fire_burst();
280 if (self.BUTTON_ATCK)
281 if (weapon_prepareattack(0, 0))
283 self.misc_bulletcounter = 1;
284 W_UZI_Attack(WEP_UZI); // sets attack_finished
285 weapon_thinkf(WFRAME_FIRE1, WEP_CVAR(uzi, sustained_refire), uzi_fire1_02);
288 if (self.BUTTON_ATCK2 && WEP_CVAR(uzi, first))
289 if (weapon_prepareattack(1, 0))
291 self.misc_bulletcounter = 1;
292 W_UZI_Attack(WEP_UZI | HITTYPE_SECONDARY); // sets attack_finished
293 weapon_thinkf(WFRAME_FIRE2, WEP_CVAR(uzi, first_refire), w_ready);
301 precache_model ("models/uziflash.md3");
302 precache_model ("models/weapons/g_uzi.md3");
303 precache_model ("models/weapons/v_uzi.md3");
304 precache_model ("models/weapons/h_uzi.iqm");
305 precache_sound ("weapons/uzi_fire.wav");
306 UZI_SETTINGS(WEP_SKIPCVAR, WEP_SET_PROP)
311 if(WEP_CVAR(uzi, mode) == 1)
312 ammo_amount = self.AMMO_VAL(WEP_UZI) >= WEP_CVAR(uzi, sustained_ammo);
314 ammo_amount = self.AMMO_VAL(WEP_UZI) >= WEP_CVAR(uzi, first_ammo);
316 if(autocvar_g_balance_uzi_reload_ammo)
318 if(WEP_CVAR(uzi, mode) == 1)
319 ammo_amount += self.(weapon_load[WEP_UZI]) >= WEP_CVAR(uzi, sustained_ammo);
321 ammo_amount += self.(weapon_load[WEP_UZI]) >= WEP_CVAR(uzi, first_ammo);
327 if(WEP_CVAR(uzi, mode) == 1)
328 ammo_amount = self.AMMO_VAL(WEP_UZI) >= WEP_CVAR(uzi, burst_ammo);
330 ammo_amount = self.AMMO_VAL(WEP_UZI) >= WEP_CVAR(uzi, first_ammo);
332 if(autocvar_g_balance_uzi_reload_ammo)
334 if(WEP_CVAR(uzi, mode) == 1)
335 ammo_amount += self.(weapon_load[WEP_UZI]) >= WEP_CVAR(uzi, burst_ammo);
337 ammo_amount += self.(weapon_load[WEP_UZI]) >= WEP_CVAR(uzi, first_ammo);
343 UZI_SETTINGS(WEP_CONFIG_WRITE_CVARS, WEP_CONFIG_WRITE_PROPS)
348 W_Reload(min(max(WEP_CVAR(uzi, sustained_ammo), WEP_CVAR(uzi, first_ammo)), WEP_CVAR(uzi, burst_ammo)), "weapons/reload.wav");
351 case WR_SUICIDEMESSAGE:
353 return WEAPON_THINKING_WITH_PORTALS;
357 if(w_deathtype & HITTYPE_SECONDARY)
358 return WEAPON_UZI_MURDER_SNIPE;
360 return WEAPON_UZI_MURDER_SPRAY;
367 float w_uzi(float req)
371 case WR_IMPACTEFFECT:
374 org2 = w_org + w_backoff * 2;
375 pointparticles(particleeffectnum("machinegun_impact"), org2, w_backoff * 1000, 1);
378 sound(self, CH_SHOTS, "weapons/ric1.wav", VOL_BASE, ATTN_NORM);
379 else if(w_random < 0.1)
380 sound(self, CH_SHOTS, "weapons/ric2.wav", VOL_BASE, ATTN_NORM);
381 else if(w_random < 0.2)
382 sound(self, CH_SHOTS, "weapons/ric3.wav", VOL_BASE, ATTN_NORM);
388 precache_sound("weapons/ric1.wav");
389 precache_sound("weapons/ric2.wav");
390 precache_sound("weapons/ric3.wav");