5 /* ammotype */ IT_NAILS,
7 /* flags */ WEP_FLAG_NORMAL | WEP_FLAG_RELOADABLE | WEP_TYPE_HITSCAN,
8 /* rating */ BOT_PICKUP_RATING_MID,
11 /* fullname */ _("Machine Gun")
14 #define UZI_SETTINGS(w_cvar,w_prop) \
15 w_cvar(WEP_UZI, uzi, MO_NONE, speed) \
16 w_cvar(WEP_UZI, uzi, MO_NONE, spread_min) \
17 w_cvar(WEP_UZI, uzi, MO_NONE, spread_max) \
18 w_cvar(WEP_UZI, uzi, MO_NONE, spread_add) \
19 w_cvar(WEP_UZI, uzi, MO_NONE, mode) \
20 w_cvar(WEP_UZI, uzi, MO_NONE, bulletconstant) \
21 w_cvar(WEP_UZI, uzi, MO_NONE, first) \
22 w_cvar(WEP_UZI, uzi, MO_NONE, first_damage) \
23 w_cvar(WEP_UZI, uzi, MO_NONE, first_force) \
24 w_cvar(WEP_UZI, uzi, MO_NONE, first_refire) \
25 w_cvar(WEP_UZI, uzi, MO_NONE, first_spread) \
26 w_cvar(WEP_UZI, uzi, MO_NONE, first_ammo) \
27 w_cvar(WEP_UZI, uzi, MO_NONE, sustained_damage) \
28 w_cvar(WEP_UZI, uzi, MO_NONE, sustained_force) \
29 w_cvar(WEP_UZI, uzi, MO_NONE, sustained_refire) \
30 w_cvar(WEP_UZI, uzi, MO_NONE, sustained_spread) \
31 w_cvar(WEP_UZI, uzi, MO_NONE, sustained_ammo) \
32 w_cvar(WEP_UZI, uzi, MO_NONE, burst) \
33 w_cvar(WEP_UZI, uzi, MO_NONE, burst_refire) \
34 w_cvar(WEP_UZI, uzi, MO_NONE, burst_refire2) \
35 w_cvar(WEP_UZI, uzi, MO_NONE, burst_animtime) \
36 w_cvar(WEP_UZI, uzi, MO_NONE, burst_speed) \
37 w_cvar(WEP_UZI, uzi, MO_NONE, burst_ammo) \
38 w_prop(WEP_UZI, uzi, float, reloading_ammo, reload_ammo) \
39 w_prop(WEP_UZI, uzi, float, reloading_time, reload_time) \
40 w_prop(WEP_UZI, uzi, float, switchdelay_raise, switchdelay_raise) \
41 w_prop(WEP_UZI, uzi, float, switchdelay_drop, switchdelay_drop) \
42 w_prop(WEP_UZI, uzi, string, weaponreplace, weaponreplace) \
43 w_prop(WEP_UZI, uzi, float, weaponstart, weaponstart)
46 UZI_SETTINGS(WEP_ADD_CVAR, WEP_ADD_PROP)
51 void spawnfunc_weapon_uzi()
53 if(autocvar_sv_q3acompat_machineshotgunswap)
54 if(self.classname != "droppedweapon")
56 weapon_defaultspawnfunc(WEP_SHOCKWAVE);
59 weapon_defaultspawnfunc(WEP_UZI);
62 // leilei's fancy muzzleflash stuff
65 self.frame = self.frame + 2;
66 self.scale = self.scale * 0.5;
67 self.alpha = self.alpha - 0.25;
68 self.nextthink = time + 0.05;
72 self.think = SUB_Remove;
73 self.nextthink = time;
74 self.realowner.muzzle_flash = world;
82 if (self.muzzle_flash == world)
83 self.muzzle_flash = spawn();
85 // muzzle flash for 1st person view
86 setmodel(self.muzzle_flash, "models/uziflash.md3"); // precision set below
88 self.muzzle_flash.scale = 0.75;
89 self.muzzle_flash.think = UZI_Flash_Go;
90 self.muzzle_flash.nextthink = time + 0.02;
91 self.muzzle_flash.frame = 2;
92 self.muzzle_flash.alpha = 0.75;
93 self.muzzle_flash.angles_z = random() * 180;
94 self.muzzle_flash.effects = EF_ADDITIVE | EF_FULLBRIGHT | EF_LOWPRECISION;
95 self.muzzle_flash.owner = self.muzzle_flash.realowner = self;
98 void W_UZI_Attack (float deathtype)
100 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)));
101 if (!autocvar_g_norecoil)
103 self.punchangle_x = random () - 0.5;
104 self.punchangle_y = random () - 0.5;
107 // this attack_finished just enforces a cooldown at the end of a burst
108 ATTACK_FINISHED(self) = time + WEP_CVAR(uzi, first_refire) * W_WeaponRateFactor();
110 if (self.misc_bulletcounter == 1)
111 fireBallisticBullet(w_shotorg, w_shotdir, WEP_CVAR(uzi, first_spread), WEP_CVAR(uzi, speed), 5, WEP_CVAR(uzi, first_damage), WEP_CVAR(uzi, first_force), deathtype, 0, WEP_CVAR(uzi, bulletconstant));
113 fireBallisticBullet(w_shotorg, w_shotdir, WEP_CVAR(uzi, sustained_spread), WEP_CVAR(uzi, speed), 5, WEP_CVAR(uzi, sustained_damage), WEP_CVAR(uzi, sustained_force), deathtype, 0, WEP_CVAR(uzi, bulletconstant));
114 endFireBallisticBullet();
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(ammo_nails, WEP_CVAR(uzi, first_ammo), autocvar_g_balance_uzi_reload_ammo);
128 W_DecreaseAmmo(ammo_nails, WEP_CVAR(uzi, sustained_ammo), autocvar_g_balance_uzi_reload_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(ammo_nails, WEP_CVAR(uzi, sustained_ammo), autocvar_g_balance_uzi_reload_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 fireBallisticBullet(w_shotorg, w_shotdir, uzi_spread, WEP_CVAR(uzi, speed), 5, WEP_CVAR(uzi, sustained_damage), WEP_CVAR(uzi, sustained_force), WEP_UZI, 0, WEP_CVAR(uzi, bulletconstant));
186 endFireBallisticBullet();
188 self.misc_bulletcounter = self.misc_bulletcounter + 1;
190 pointparticles(particleeffectnum("uzi_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
193 W_AttachToShotorg(self.muzzle_flash, '5 0 0');
195 if (autocvar_g_casings >= 2) // casing code
196 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);
198 ATTACK_FINISHED(self) = time + WEP_CVAR(uzi, first_refire) * W_WeaponRateFactor();
199 weapon_thinkf(WFRAME_FIRE1, WEP_CVAR(uzi, sustained_refire), uzi_mode1_fire_auto);
202 void uzi_mode1_fire_burst()
204 W_SetupShot (self, TRUE, 0, "weapons/uzi_fire.wav", CH_WEAPON_A, WEP_CVAR(uzi, sustained_damage));
205 if (!autocvar_g_norecoil)
207 self.punchangle_x = random () - 0.5;
208 self.punchangle_y = random () - 0.5;
211 fireBallisticBullet(w_shotorg, w_shotdir, WEP_CVAR(uzi, burst_speed), WEP_CVAR(uzi, speed), 5, WEP_CVAR(uzi, sustained_damage), WEP_CVAR(uzi, sustained_force), WEP_UZI, 0, WEP_CVAR(uzi, bulletconstant));
212 endFireBallisticBullet();
215 pointparticles(particleeffectnum("uzi_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
218 W_AttachToShotorg(self.muzzle_flash, '5 0 0');
220 if (autocvar_g_casings >= 2) // casing code
221 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);
223 self.misc_bulletcounter = self.misc_bulletcounter + 1;
224 if (self.misc_bulletcounter == 0)
226 ATTACK_FINISHED(self) = time + WEP_CVAR(uzi, burst_refire2) * W_WeaponRateFactor();
227 weapon_thinkf(WFRAME_FIRE2, WEP_CVAR(uzi, burst_animtime), w_ready);
231 weapon_thinkf(WFRAME_FIRE2, WEP_CVAR(uzi, burst_refire), uzi_mode1_fire_burst);
236 float w_uzi(float req)
243 if(vlen(self.origin-self.enemy.origin) < 3000 - bound(0, skill, 10) * 200)
244 self.BUTTON_ATCK = bot_aim(1000000, 0, 0.001, FALSE);
246 self.BUTTON_ATCK2 = bot_aim(1000000, 0, 0.001, FALSE);
252 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
253 WEP_ACTION(self.weapon, WR_RELOAD);
254 else if(WEP_CVAR(uzi, mode) == 1)
256 if (self.BUTTON_ATCK)
257 if (weapon_prepareattack(0, 0))
259 self.misc_bulletcounter = 0;
260 uzi_mode1_fire_auto();
263 if(self.BUTTON_ATCK2)
264 if(weapon_prepareattack(1, 0))
266 if (!WEP_ACTION(self.weapon, WR_CHECKAMMO2))
267 if (!(self.items & IT_UNLIMITED_WEAPON_AMMO))
269 W_SwitchWeapon_Force(self, w_getbestweapon(self));
274 W_DecreaseAmmo(ammo_nails, WEP_CVAR(uzi, burst_ammo), autocvar_g_balance_uzi_reload_ammo);
276 self.misc_bulletcounter = WEP_CVAR(uzi, burst) * -1;
277 uzi_mode1_fire_burst();
283 if (self.BUTTON_ATCK)
284 if (weapon_prepareattack(0, 0))
286 self.misc_bulletcounter = 1;
287 W_UZI_Attack(WEP_UZI); // sets attack_finished
288 weapon_thinkf(WFRAME_FIRE1, WEP_CVAR(uzi, sustained_refire), uzi_fire1_02);
291 if (self.BUTTON_ATCK2 && WEP_CVAR(uzi, first))
292 if (weapon_prepareattack(1, 0))
294 self.misc_bulletcounter = 1;
295 W_UZI_Attack(WEP_UZI | HITTYPE_SECONDARY); // sets attack_finished
296 weapon_thinkf(WFRAME_FIRE2, WEP_CVAR(uzi, first_refire), w_ready);
304 precache_model ("models/uziflash.md3");
305 precache_model ("models/weapons/g_uzi.md3");
306 precache_model ("models/weapons/v_uzi.md3");
307 precache_model ("models/weapons/h_uzi.iqm");
308 precache_sound ("weapons/uzi_fire.wav");
309 UZI_SETTINGS(WEP_SKIPCVAR, WEP_SET_PROP)
314 self.current_ammo = ammo_nails;
319 if(WEP_CVAR(uzi, mode) == 1)
320 ammo_amount = self.ammo_nails >= WEP_CVAR(uzi, sustained_ammo);
322 ammo_amount = self.ammo_nails >= WEP_CVAR(uzi, first_ammo);
324 if(autocvar_g_balance_uzi_reload_ammo)
326 if(WEP_CVAR(uzi, mode) == 1)
327 ammo_amount += self.(weapon_load[WEP_UZI]) >= WEP_CVAR(uzi, sustained_ammo);
329 ammo_amount += self.(weapon_load[WEP_UZI]) >= WEP_CVAR(uzi, first_ammo);
335 if(WEP_CVAR(uzi, mode) == 1)
336 ammo_amount = self.ammo_nails >= WEP_CVAR(uzi, burst_ammo);
338 ammo_amount = self.ammo_nails >= WEP_CVAR(uzi, first_ammo);
340 if(autocvar_g_balance_uzi_reload_ammo)
342 if(WEP_CVAR(uzi, mode) == 1)
343 ammo_amount += self.(weapon_load[WEP_UZI]) >= WEP_CVAR(uzi, burst_ammo);
345 ammo_amount += self.(weapon_load[WEP_UZI]) >= WEP_CVAR(uzi, first_ammo);
351 UZI_SETTINGS(WEP_CONFIG_WRITE_CVARS, WEP_CONFIG_WRITE_PROPS)
356 W_Reload(min(max(WEP_CVAR(uzi, sustained_ammo), WEP_CVAR(uzi, first_ammo)), WEP_CVAR(uzi, burst_ammo)), "weapons/reload.wav");
359 case WR_SUICIDEMESSAGE:
361 return WEAPON_THINKING_WITH_PORTALS;
365 if(w_deathtype & HITTYPE_SECONDARY)
366 return WEAPON_UZI_MURDER_SNIPE;
368 return WEAPON_UZI_MURDER_SPRAY;
375 float w_uzi(float req)
379 case WR_IMPACTEFFECT:
382 org2 = w_org + w_backoff * 2;
383 pointparticles(particleeffectnum("machinegun_impact"), org2, w_backoff * 1000, 1);
386 sound(self, CH_SHOTS, "weapons/ric1.wav", VOL_BASE, ATTN_NORM);
387 else if(w_random < 0.1)
388 sound(self, CH_SHOTS, "weapons/ric2.wav", VOL_BASE, ATTN_NORM);
389 else if(w_random < 0.2)
390 sound(self, CH_SHOTS, "weapons/ric3.wav", VOL_BASE, ATTN_NORM);
396 precache_sound("weapons/ric1.wav");
397 precache_sound("weapons/ric2.wav");
398 precache_sound("weapons/ric3.wav");