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")
16 // leilei's fancy muzzleflash stuff
19 self.frame = self.frame + 2;
20 self.scale = self.scale * 0.5;
21 self.alpha = self.alpha - 0.25;
22 self.nextthink = time + 0.05;
26 self.think = SUB_Remove;
27 self.nextthink = time;
28 self.realowner.muzzle_flash = world;
36 if (self.muzzle_flash == world)
37 self.muzzle_flash = spawn();
39 // muzzle flash for 1st person view
40 setmodel(self.muzzle_flash, "models/uziflash.md3"); // precision set below
42 self.muzzle_flash.scale = 0.75;
43 self.muzzle_flash.think = UZI_Flash_Go;
44 self.muzzle_flash.nextthink = time + 0.02;
45 self.muzzle_flash.frame = 2;
46 self.muzzle_flash.alpha = 0.75;
47 self.muzzle_flash.angles_z = random() * 180;
48 self.muzzle_flash.effects = EF_ADDITIVE | EF_FULLBRIGHT | EF_LOWPRECISION;
49 self.muzzle_flash.owner = self.muzzle_flash.realowner = self;
52 void W_UZI_Attack (float deathtype)
54 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));
56 self.punchangle_x = random () - 0.5;
57 self.punchangle_y = random () - 0.5;
59 // this attack_finished just enforces a cooldown at the end of a burst
60 ATTACK_FINISHED(self) = time + autocvar_g_balance_uzi_first_refire * W_WeaponRateFactor();
62 if (self.misc_bulletcounter == 1)
63 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);
65 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);
66 endFireBallisticBullet();
68 pointparticles(particleeffectnum("uzi_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
71 W_AttachToShotorg(self.muzzle_flash, '5 0 0');
74 if (autocvar_g_casings >= 2)
75 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);
77 if (self.misc_bulletcounter == 1)
78 W_DecreaseAmmo(ammo_nails, autocvar_g_balance_uzi_first_ammo, autocvar_g_balance_uzi_reload_ammo);
80 W_DecreaseAmmo(ammo_nails, autocvar_g_balance_uzi_sustained_ammo, autocvar_g_balance_uzi_reload_ammo);
86 if(self.weapon != self.switchweapon) // abort immediately if switching
93 if (!weapon_action(self.weapon, WR_CHECKAMMO2))
94 if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
96 W_SwitchWeapon_Force(self, w_getbestweapon(self));
100 self.misc_bulletcounter = self.misc_bulletcounter + 1;
101 W_UZI_Attack(WEP_UZI);
102 weapon_thinkf(WFRAME_FIRE1, autocvar_g_balance_uzi_sustained_refire, uzi_fire1_02);
105 weapon_thinkf(WFRAME_FIRE1, autocvar_g_balance_uzi_sustained_refire, w_ready);
109 void uzi_mode1_fire_auto()
113 if (!self.BUTTON_ATCK)
119 if (!weapon_action(self.weapon, WR_CHECKAMMO1))
120 if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
122 W_SwitchWeapon_Force(self, w_getbestweapon(self));
127 W_DecreaseAmmo(ammo_nails, autocvar_g_balance_uzi_sustained_ammo, autocvar_g_balance_uzi_reload_ammo);
129 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);
131 self.punchangle_x = random () - 0.5;
132 self.punchangle_y = random () - 0.5;
134 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);
135 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);
136 endFireBallisticBullet();
138 self.misc_bulletcounter = self.misc_bulletcounter + 1;
140 pointparticles(particleeffectnum("uzi_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
143 W_AttachToShotorg(self.muzzle_flash, '5 0 0');
145 if (autocvar_g_casings >= 2) // casing code
146 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);
148 ATTACK_FINISHED(self) = time + autocvar_g_balance_uzi_first_refire * W_WeaponRateFactor();
149 weapon_thinkf(WFRAME_FIRE1, autocvar_g_balance_uzi_sustained_refire, uzi_mode1_fire_auto);
152 void uzi_mode1_fire_burst()
154 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);
156 self.punchangle_x = random () - 0.5;
157 self.punchangle_y = random () - 0.5;
159 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);
160 endFireBallisticBullet();
163 pointparticles(particleeffectnum("uzi_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
166 W_AttachToShotorg(self.muzzle_flash, '5 0 0');
168 if (autocvar_g_casings >= 2) // casing code
169 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);
171 self.misc_bulletcounter = self.misc_bulletcounter + 1;
172 if (self.misc_bulletcounter == 0)
174 ATTACK_FINISHED(self) = time + autocvar_g_balance_uzi_burst_refire2 * W_WeaponRateFactor();
175 weapon_thinkf(WFRAME_FIRE2, autocvar_g_balance_uzi_burst_animtime, w_ready);
179 weapon_thinkf(WFRAME_FIRE2, autocvar_g_balance_uzi_burst_refire, uzi_mode1_fire_burst);
184 void spawnfunc_weapon_machinegun(); // defined in t_items.qc
186 float w_uzi(float req)
190 if(vlen(self.origin-self.enemy.origin) < 3000 - bound(0, skill, 10) * 200)
191 self.BUTTON_ATCK = bot_aim(1000000, 0, 0.001, FALSE);
194 self.BUTTON_ATCK2 = bot_aim(1000000, 0, 0.001, FALSE);
196 else if (req == WR_THINK)
198 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
199 weapon_action(self.weapon, WR_RELOAD);
200 else if(autocvar_g_balance_uzi_mode == 1)
202 if (self.BUTTON_ATCK)
203 if (weapon_prepareattack(0, 0))
205 self.misc_bulletcounter = 0;
206 uzi_mode1_fire_auto();
209 if(self.BUTTON_ATCK2)
210 if(weapon_prepareattack(1, 0))
212 if (!weapon_action(self.weapon, WR_CHECKAMMO2))
213 if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
215 W_SwitchWeapon_Force(self, w_getbestweapon(self));
220 W_DecreaseAmmo(ammo_nails, autocvar_g_balance_uzi_burst_ammo, autocvar_g_balance_uzi_reload_ammo);
222 self.misc_bulletcounter = autocvar_g_balance_uzi_burst * -1;
223 uzi_mode1_fire_burst();
229 if (self.BUTTON_ATCK)
230 if (weapon_prepareattack(0, 0))
232 self.misc_bulletcounter = 1;
233 W_UZI_Attack(WEP_UZI); // sets attack_finished
234 weapon_thinkf(WFRAME_FIRE1, autocvar_g_balance_uzi_sustained_refire, uzi_fire1_02);
237 if (self.BUTTON_ATCK2 && autocvar_g_balance_uzi_first)
238 if (weapon_prepareattack(1, 0))
240 self.misc_bulletcounter = 1;
241 W_UZI_Attack(WEP_UZI | HITTYPE_SECONDARY); // sets attack_finished
242 weapon_thinkf(WFRAME_FIRE2, autocvar_g_balance_uzi_first_refire, w_ready);
246 else if (req == WR_PRECACHE)
248 precache_model ("models/uziflash.md3");
249 precache_model ("models/weapons/g_uzi.md3");
250 precache_model ("models/weapons/v_uzi.md3");
251 precache_model ("models/weapons/h_uzi.iqm");
252 precache_sound ("weapons/uzi_fire.wav");
253 //precache_sound ("weapons/reload.wav"); // until weapons have individual reload sounds, precache the reload sound somewhere else
255 else if (req == WR_SETUP)
257 weapon_setup(WEP_UZI);
258 self.current_ammo = ammo_nails;
260 else if (req == WR_CHECKAMMO1)
262 if(autocvar_g_balance_uzi_mode == 1)
263 ammo_amount = self.ammo_nails >= autocvar_g_balance_uzi_sustained_ammo;
265 ammo_amount = self.ammo_nails >= autocvar_g_balance_uzi_first_ammo;
267 if(autocvar_g_balance_uzi_reload_ammo)
269 if(autocvar_g_balance_uzi_mode == 1)
270 ammo_amount += self.(weapon_load[WEP_UZI]) >= autocvar_g_balance_uzi_sustained_ammo;
272 ammo_amount += self.(weapon_load[WEP_UZI]) >= autocvar_g_balance_uzi_first_ammo;
276 else if (req == WR_CHECKAMMO2)
278 if(autocvar_g_balance_uzi_mode == 1)
279 ammo_amount = self.ammo_nails >= autocvar_g_balance_uzi_burst_ammo;
281 ammo_amount = self.ammo_nails >= autocvar_g_balance_uzi_first_ammo;
283 if(autocvar_g_balance_uzi_reload_ammo)
285 if(autocvar_g_balance_uzi_mode == 1)
286 ammo_amount += self.(weapon_load[WEP_UZI]) >= autocvar_g_balance_uzi_burst_ammo;
288 ammo_amount += self.(weapon_load[WEP_UZI]) >= autocvar_g_balance_uzi_first_ammo;
292 else if (req == WR_RELOAD)
294 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");
296 else if (req == WR_SUICIDEMESSAGE)
298 return WEAPON_THINKING_WITH_PORTALS;
300 else if (req == WR_KILLMESSAGE)
302 if(w_deathtype & HITTYPE_SECONDARY)
303 return WEAPON_UZI_MURDER_SNIPE;
305 return WEAPON_UZI_MURDER_SPRAY;
311 float w_uzi(float req)
313 if(req == WR_IMPACTEFFECT)
316 org2 = w_org + w_backoff * 2;
317 pointparticles(particleeffectnum("machinegun_impact"), org2, w_backoff * 1000, 1);
320 sound(self, CH_SHOTS, "weapons/ric1.wav", VOL_BASE, ATTN_NORM);
321 else if(w_random < 0.1)
322 sound(self, CH_SHOTS, "weapons/ric2.wav", VOL_BASE, ATTN_NORM);
323 else if(w_random < 0.2)
324 sound(self, CH_SHOTS, "weapons/ric3.wav", VOL_BASE, ATTN_NORM);
326 else if(req == WR_PRECACHE)
328 precache_sound("weapons/ric1.wav");
329 precache_sound("weapons/ric2.wav");
330 precache_sound("weapons/ric3.wav");