5 /* ammotype */ IT_NAILS,
7 /* flags */ WEP_FLAG_NORMAL | WEP_FLAG_RELOADABLE | WEP_TYPE_HITSCAN,
8 /* rating */ BOT_PICKUP_RATING_MID,
10 /* shortname */ "uzi",
11 /* fullname */ _("Machine Gun")
18 void spawnfunc_weapon_uzi()
20 if(autocvar_sv_q3acompat_machineshotgunswap)
21 if(self.classname != "droppedweapon")
23 weapon_defaultspawnfunc(WEP_SHOTGUN);
26 weapon_defaultspawnfunc(WEP_UZI);
29 // leilei's fancy muzzleflash stuff
32 self.frame = self.frame + 2;
33 self.scale = self.scale * 0.5;
34 self.alpha = self.alpha - 0.25;
35 self.nextthink = time + 0.05;
39 self.think = SUB_Remove;
40 self.nextthink = time;
41 self.realowner.muzzle_flash = world;
49 if (self.muzzle_flash == world)
50 self.muzzle_flash = spawn();
52 // muzzle flash for 1st person view
53 setmodel(self.muzzle_flash, "models/uziflash.md3"); // precision set below
55 self.muzzle_flash.scale = 0.75;
56 self.muzzle_flash.think = UZI_Flash_Go;
57 self.muzzle_flash.nextthink = time + 0.02;
58 self.muzzle_flash.frame = 2;
59 self.muzzle_flash.alpha = 0.75;
60 self.muzzle_flash.angles_z = random() * 180;
61 self.muzzle_flash.effects = EF_ADDITIVE | EF_FULLBRIGHT | EF_LOWPRECISION;
62 self.muzzle_flash.owner = self.muzzle_flash.realowner = self;
65 void W_UZI_Attack (float deathtype)
67 W_SetupShot (self, autocvar_g_antilag_bullets && autocvar_g_balance_uzi_speed >= autocvar_g_antilag_bullets, 0, "weapons/uzi_fire.wav", CH_WEAPON_A, ((self.misc_bulletcounter == 1) ? autocvar_g_balance_uzi_first_damage : autocvar_g_balance_uzi_sustained_damage));
70 self.punchangle_x = random () - 0.5;
71 self.punchangle_y = random () - 0.5;
74 // this attack_finished just enforces a cooldown at the end of a burst
75 ATTACK_FINISHED(self) = time + autocvar_g_balance_uzi_first_refire * W_WeaponRateFactor();
77 if (self.misc_bulletcounter == 1)
78 fireBallisticBullet(w_shotorg, w_shotdir, autocvar_g_balance_uzi_first_spread, autocvar_g_balance_uzi_speed, 5, autocvar_g_balance_uzi_first_damage, autocvar_g_balance_uzi_first_force, deathtype, 0, 1, autocvar_g_balance_uzi_bulletconstant);
80 fireBallisticBullet(w_shotorg, w_shotdir, autocvar_g_balance_uzi_sustained_spread, autocvar_g_balance_uzi_speed, 5, autocvar_g_balance_uzi_sustained_damage, autocvar_g_balance_uzi_sustained_force, deathtype, 0, 1, autocvar_g_balance_uzi_bulletconstant);
81 endFireBallisticBullet();
83 pointparticles(particleeffectnum("uzi_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
86 W_AttachToShotorg(self.muzzle_flash, '5 0 0');
89 if (autocvar_g_casings >= 2)
90 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);
92 if (self.misc_bulletcounter == 1)
93 W_DecreaseAmmo(ammo_nails, autocvar_g_balance_uzi_first_ammo, autocvar_g_balance_uzi_reload_ammo);
95 W_DecreaseAmmo(ammo_nails, autocvar_g_balance_uzi_sustained_ammo, autocvar_g_balance_uzi_reload_ammo);
101 if(self.weapon != self.switchweapon) // abort immediately if switching
106 if (self.BUTTON_ATCK)
108 if (!weapon_action(self.weapon, WR_CHECKAMMO2))
109 if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
111 W_SwitchWeapon_Force(self, w_getbestweapon(self));
115 self.misc_bulletcounter = self.misc_bulletcounter + 1;
116 W_UZI_Attack(WEP_UZI);
117 weapon_thinkf(WFRAME_FIRE1, autocvar_g_balance_uzi_sustained_refire, uzi_fire1_02);
120 weapon_thinkf(WFRAME_FIRE1, autocvar_g_balance_uzi_sustained_refire, w_ready);
124 void uzi_mode1_fire_auto()
128 if (!self.BUTTON_ATCK)
134 if (!weapon_action(self.weapon, WR_CHECKAMMO1))
135 if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
137 W_SwitchWeapon_Force(self, w_getbestweapon(self));
142 W_DecreaseAmmo(ammo_nails, autocvar_g_balance_uzi_sustained_ammo, autocvar_g_balance_uzi_reload_ammo);
144 W_SetupShot (self, autocvar_g_antilag_bullets && autocvar_g_balance_uzi_speed >= autocvar_g_antilag_bullets, 0, "weapons/uzi_fire.wav", CH_WEAPON_A, autocvar_g_balance_uzi_sustained_damage);
147 self.punchangle_x = random () - 0.5;
148 self.punchangle_y = random () - 0.5;
151 uzi_spread = bound(autocvar_g_balance_uzi_spread_min, autocvar_g_balance_uzi_spread_min + (autocvar_g_balance_uzi_spread_add * self.misc_bulletcounter), autocvar_g_balance_uzi_spread_max);
152 fireBallisticBullet(w_shotorg, w_shotdir, uzi_spread, autocvar_g_balance_uzi_speed, 5, autocvar_g_balance_uzi_sustained_damage, autocvar_g_balance_uzi_sustained_force, WEP_UZI, 0, 1, autocvar_g_balance_uzi_bulletconstant);
153 endFireBallisticBullet();
155 self.misc_bulletcounter = self.misc_bulletcounter + 1;
157 pointparticles(particleeffectnum("uzi_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
160 W_AttachToShotorg(self.muzzle_flash, '5 0 0');
162 if (autocvar_g_casings >= 2) // casing code
163 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);
165 ATTACK_FINISHED(self) = time + autocvar_g_balance_uzi_first_refire * W_WeaponRateFactor();
166 weapon_thinkf(WFRAME_FIRE1, autocvar_g_balance_uzi_sustained_refire, uzi_mode1_fire_auto);
169 void uzi_mode1_fire_burst()
171 W_SetupShot (self, autocvar_g_antilag_bullets && autocvar_g_balance_uzi_speed >= autocvar_g_antilag_bullets, 0, "weapons/uzi_fire.wav", CH_WEAPON_A, autocvar_g_balance_uzi_sustained_damage);
174 self.punchangle_x = random () - 0.5;
175 self.punchangle_y = random () - 0.5;
178 fireBallisticBullet(w_shotorg, w_shotdir, autocvar_g_balance_uzi_burst_spread, autocvar_g_balance_uzi_speed, 5, autocvar_g_balance_uzi_sustained_damage, autocvar_g_balance_uzi_sustained_force, WEP_UZI, 0, 1, autocvar_g_balance_uzi_bulletconstant);
179 endFireBallisticBullet();
182 pointparticles(particleeffectnum("uzi_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
185 W_AttachToShotorg(self.muzzle_flash, '5 0 0');
187 if (autocvar_g_casings >= 2) // casing code
188 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);
190 self.misc_bulletcounter = self.misc_bulletcounter + 1;
191 if (self.misc_bulletcounter == 0)
193 ATTACK_FINISHED(self) = time + autocvar_g_balance_uzi_burst_refire2 * W_WeaponRateFactor();
194 weapon_thinkf(WFRAME_FIRE2, autocvar_g_balance_uzi_burst_animtime, w_ready);
198 weapon_thinkf(WFRAME_FIRE2, autocvar_g_balance_uzi_burst_refire, uzi_mode1_fire_burst);
203 float w_uzi(float req)
210 if(vlen(self.origin-self.enemy.origin) < 3000 - bound(0, skill, 10) * 200)
211 self.BUTTON_ATCK = bot_aim(1000000, 0, 0.001, FALSE);
213 self.BUTTON_ATCK2 = bot_aim(1000000, 0, 0.001, FALSE);
219 if(autocvar_g_balance_uzi_reload_ammo && self.clip_load < min(max(autocvar_g_balance_uzi_sustained_ammo, autocvar_g_balance_uzi_first_ammo), autocvar_g_balance_uzi_burst_ammo)) // forced reload
220 weapon_action(self.weapon, WR_RELOAD);
221 else if(autocvar_g_balance_uzi_mode == 1)
223 if (self.BUTTON_ATCK)
224 if (weapon_prepareattack(0, 0))
226 self.misc_bulletcounter = 0;
227 uzi_mode1_fire_auto();
230 if(self.BUTTON_ATCK2)
231 if(weapon_prepareattack(1, 0))
233 if (!weapon_action(self.weapon, WR_CHECKAMMO2))
234 if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
236 W_SwitchWeapon_Force(self, w_getbestweapon(self));
241 W_DecreaseAmmo(ammo_nails, autocvar_g_balance_uzi_burst_ammo, autocvar_g_balance_uzi_reload_ammo);
243 self.misc_bulletcounter = autocvar_g_balance_uzi_burst * -1;
244 uzi_mode1_fire_burst();
250 if (self.BUTTON_ATCK)
251 if (weapon_prepareattack(0, 0))
253 self.misc_bulletcounter = 1;
254 W_UZI_Attack(WEP_UZI); // sets attack_finished
255 weapon_thinkf(WFRAME_FIRE1, autocvar_g_balance_uzi_sustained_refire, uzi_fire1_02);
258 if (self.BUTTON_ATCK2 && autocvar_g_balance_uzi_first)
259 if (weapon_prepareattack(1, 0))
261 self.misc_bulletcounter = 1;
262 W_UZI_Attack(WEP_UZI | HITTYPE_SECONDARY); // sets attack_finished
263 weapon_thinkf(WFRAME_FIRE2, autocvar_g_balance_uzi_first_refire, w_ready);
271 precache_model ("models/uziflash.md3");
272 precache_model ("models/weapons/g_uzi.md3");
273 precache_model ("models/weapons/v_uzi.md3");
274 precache_model ("models/weapons/h_uzi.iqm");
275 precache_sound ("weapons/uzi_fire.wav");
280 weapon_setup(WEP_UZI);
281 self.current_ammo = ammo_nails;
286 if(autocvar_g_balance_uzi_mode == 1)
287 ammo_amount = self.ammo_nails >= autocvar_g_balance_uzi_sustained_ammo;
289 ammo_amount = self.ammo_nails >= autocvar_g_balance_uzi_first_ammo;
291 if(autocvar_g_balance_uzi_reload_ammo)
293 if(autocvar_g_balance_uzi_mode == 1)
294 ammo_amount += self.(weapon_load[WEP_UZI]) >= autocvar_g_balance_uzi_sustained_ammo;
296 ammo_amount += self.(weapon_load[WEP_UZI]) >= autocvar_g_balance_uzi_first_ammo;
302 if(autocvar_g_balance_uzi_mode == 1)
303 ammo_amount = self.ammo_nails >= autocvar_g_balance_uzi_burst_ammo;
305 ammo_amount = self.ammo_nails >= autocvar_g_balance_uzi_first_ammo;
307 if(autocvar_g_balance_uzi_reload_ammo)
309 if(autocvar_g_balance_uzi_mode == 1)
310 ammo_amount += self.(weapon_load[WEP_UZI]) >= autocvar_g_balance_uzi_burst_ammo;
312 ammo_amount += self.(weapon_load[WEP_UZI]) >= autocvar_g_balance_uzi_first_ammo;
318 W_Reload(min(max(autocvar_g_balance_uzi_sustained_ammo, autocvar_g_balance_uzi_first_ammo), autocvar_g_balance_uzi_burst_ammo), autocvar_g_balance_uzi_reload_ammo, autocvar_g_balance_uzi_reload_time, "weapons/reload.wav");
321 case WR_SUICIDEMESSAGE:
323 return WEAPON_THINKING_WITH_PORTALS;
327 if(w_deathtype & HITTYPE_SECONDARY)
328 return WEAPON_UZI_MURDER_SNIPE;
330 return WEAPON_UZI_MURDER_SPRAY;
337 float w_uzi(float req)
341 case WR_IMPACTEFFECT:
344 org2 = w_org + w_backoff * 2;
345 pointparticles(particleeffectnum("machinegun_impact"), org2, w_backoff * 1000, 1);
348 sound(self, CH_SHOTS, "weapons/ric1.wav", VOL_BASE, ATTN_NORM);
349 else if(w_random < 0.1)
350 sound(self, CH_SHOTS, "weapons/ric2.wav", VOL_BASE, ATTN_NORM);
351 else if(w_random < 0.2)
352 sound(self, CH_SHOTS, "weapons/ric3.wav", VOL_BASE, ATTN_NORM);
358 precache_sound("weapons/ric1.wav");
359 precache_sound("weapons/ric2.wav");
360 precache_sound("weapons/ric3.wav");