2 REGISTER_WEAPON(UZI, w_uzi, IT_NAILS, 3, WEP_FLAG_NORMAL | WEP_FLAG_RELOADABLE | WEP_TYPE_HITSCAN, BOT_PICKUP_RATING_MID, "uzi", "uzi", _("Machine Gun"))
8 self.reload_ammo_player = ammo_nails;
9 self.reload_ammo_min = min(max(autocvar_g_balance_uzi_sustained_ammo, autocvar_g_balance_uzi_first_ammo), autocvar_g_balance_uzi_burst_ammo);
10 self.reload_ammo_amount = autocvar_g_balance_uzi_reload_ammo;
11 self.reload_time = autocvar_g_balance_uzi_reload_time;
12 self.reload_sound = "weapons/reload.wav";
17 // leilei's fancy muzzleflash stuff
20 self.frame = self.frame + 2;
21 self.scale = self.scale * 0.5;
22 self.alpha = self.alpha - 0.25;
23 self.nextthink = time + 0.05;
27 self.think = SUB_Remove;
28 self.nextthink = time;
29 self.owner.muzzle_flash = world;
37 if (self.muzzle_flash == world)
38 self.muzzle_flash = spawn();
40 // muzzle flash for 1st person view
41 setmodel(self.muzzle_flash, "models/uziflash.md3"); // precision set below
43 self.muzzle_flash.scale = 0.75;
44 self.muzzle_flash.think = UZI_Flash_Go;
45 self.muzzle_flash.nextthink = time + 0.02;
46 self.muzzle_flash.frame = 2;
47 self.muzzle_flash.alpha = 0.75;
48 self.muzzle_flash.angles_z = random() * 180;
49 self.muzzle_flash.effects = EF_ADDITIVE | EF_FULLBRIGHT | EF_LOWPRECISION;
50 self.muzzle_flash.owner = self;
53 void W_UZI_Attack (float deathtype)
55 W_SetupShot (self, autocvar_g_antilag_bullets && autocvar_g_balance_uzi_speed >= autocvar_g_antilag_bullets, 0, "weapons/uzi_fire.wav", CHAN_WEAPON, ((self.misc_bulletcounter == 1) ? autocvar_g_balance_uzi_first_damage : autocvar_g_balance_uzi_sustained_damage));
58 self.punchangle_x = random () - 0.5;
59 self.punchangle_y = random () - 0.5;
62 // this attack_finished just enforces a cooldown at the end of a burst
63 ATTACK_FINISHED(self) = time + autocvar_g_balance_uzi_first_refire * W_WeaponRateFactor();
65 if (self.misc_bulletcounter == 1)
66 fireBallisticBullet(w_shotorg, w_shotdir, autocvar_g_balance_uzi_first_spread, autocvar_g_balance_uzi_speed, 5, autocvar_g_balance_uzi_first_damage, 0, autocvar_g_balance_uzi_first_force, deathtype, 0, 1, autocvar_g_balance_uzi_bulletconstant);
68 fireBallisticBullet(w_shotorg, w_shotdir, autocvar_g_balance_uzi_sustained_spread, autocvar_g_balance_uzi_speed, 5, autocvar_g_balance_uzi_sustained_damage, 0, autocvar_g_balance_uzi_sustained_force, deathtype, 0, 1, autocvar_g_balance_uzi_bulletconstant);
69 endFireBallisticBullet();
71 pointparticles(particleeffectnum("uzi_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
74 W_AttachToShotorg(self.muzzle_flash, '5 0 0');
77 if (autocvar_g_casings >= 2)
78 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);
80 // if this weapon is reloadable, decrease its load. Else decrease the player's ammo
81 if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
83 if(autocvar_g_balance_uzi_reload_ammo)
85 if (self.misc_bulletcounter == 1)
86 self.clip_load -= autocvar_g_balance_uzi_first_ammo;
88 self.clip_load -= autocvar_g_balance_uzi_sustained_ammo;
89 self.weapon_load[WEP_UZI] = self.clip_load;
93 if (self.misc_bulletcounter == 1)
94 self.ammo_nails -= autocvar_g_balance_uzi_first_ammo;
96 self.ammo_nails -= autocvar_g_balance_uzi_sustained_ammo;
104 if(self.weapon != self.switchweapon) // abort immediately if switching
109 if (self.BUTTON_ATCK)
111 if (!weapon_action(self.weapon, WR_CHECKAMMO2))
113 W_SwitchWeapon_Force(self, w_getbestweapon(self));
117 self.misc_bulletcounter = self.misc_bulletcounter + 1;
118 W_UZI_Attack(WEP_UZI);
119 weapon_thinkf(WFRAME_FIRE1, autocvar_g_balance_uzi_sustained_refire, uzi_fire1_02);
122 weapon_thinkf(WFRAME_FIRE1, autocvar_g_balance_uzi_sustained_refire, w_ready);
126 void uzi_mode1_fire_auto()
130 // if this weapon is reloadable, decrease its load. Else decrease the player's ammo
131 if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
133 if(autocvar_g_balance_uzi_reload_ammo)
135 self.clip_load -= autocvar_g_balance_uzi_sustained_ammo;
136 self.weapon_load[WEP_UZI] = self.clip_load;
139 self.ammo_nails -= autocvar_g_balance_uzi_sustained_ammo;
142 if (self.BUTTON_ATCK)
143 weapon_thinkf(WFRAME_FIRE1, autocvar_g_balance_uzi_sustained_refire, uzi_mode1_fire_auto);
146 ATTACK_FINISHED(self) = time + autocvar_g_balance_uzi_first_refire * W_WeaponRateFactor();
147 weapon_thinkf(WFRAME_FIRE1, autocvar_g_balance_uzi_sustained_refire, w_ready);
151 if (!weapon_action(self.weapon, WR_CHECKAMMO1))
153 W_SwitchWeapon_Force(self, w_getbestweapon(self));
158 W_SetupShot (self, autocvar_g_antilag_bullets && autocvar_g_balance_uzi_speed >= autocvar_g_antilag_bullets, 0, "weapons/uzi_fire.wav", CHAN_WEAPON, autocvar_g_balance_uzi_sustained_damage);
161 self.punchangle_x = random () - 0.5;
162 self.punchangle_y = random () - 0.5;
165 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);
166 fireBallisticBullet(w_shotorg, w_shotdir, uzi_spread, autocvar_g_balance_uzi_speed, 5, autocvar_g_balance_uzi_sustained_damage, 0, autocvar_g_balance_uzi_sustained_force, WEP_UZI, 0, 1, autocvar_g_balance_uzi_bulletconstant);
167 endFireBallisticBullet();
169 self.misc_bulletcounter = self.misc_bulletcounter + 1;
171 pointparticles(particleeffectnum("uzi_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
174 W_AttachToShotorg(self.muzzle_flash, '5 0 0');
176 if (autocvar_g_casings >= 2) // casing code
177 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);
180 void uzi_mode1_fire_burst()
182 W_SetupShot (self, autocvar_g_antilag_bullets && autocvar_g_balance_uzi_speed >= autocvar_g_antilag_bullets, 0, "weapons/uzi_fire.wav", CHAN_WEAPON, autocvar_g_balance_uzi_sustained_damage);
185 self.punchangle_x = random () - 0.5;
186 self.punchangle_y = random () - 0.5;
189 fireBallisticBullet(w_shotorg, w_shotdir, autocvar_g_balance_uzi_burst_spread, autocvar_g_balance_uzi_speed, 5, autocvar_g_balance_uzi_sustained_damage, 0, autocvar_g_balance_uzi_sustained_force, WEP_UZI, 0, 1, autocvar_g_balance_uzi_bulletconstant);
190 endFireBallisticBullet();
193 pointparticles(particleeffectnum("uzi_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
196 W_AttachToShotorg(self.muzzle_flash, '5 0 0');
198 if (autocvar_g_casings >= 2) // casing code
199 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);
201 self.misc_bulletcounter = self.misc_bulletcounter + 1;
202 if (self.misc_bulletcounter == 0)
204 ATTACK_FINISHED(self) = time + autocvar_g_balance_uzi_burst_refire2 * W_WeaponRateFactor();
205 weapon_thinkf(WFRAME_FIRE2, autocvar_g_balance_uzi_burst_animtime, w_ready);
209 weapon_thinkf(WFRAME_FIRE2, autocvar_g_balance_uzi_burst_refire, uzi_mode1_fire_burst);
214 void spawnfunc_weapon_machinegun(); // defined in t_items.qc
216 float w_uzi(float req)
220 if(vlen(self.origin-self.enemy.origin) < 3000 - bound(0, skill, 10) * 200)
221 self.BUTTON_ATCK = bot_aim(1000000, 0, 0.001, FALSE);
224 self.BUTTON_ATCK2 = bot_aim(1000000, 0, 0.001, FALSE);
226 else if (req == WR_THINK)
228 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
230 else if(autocvar_g_balance_uzi_mode == 1)
232 if (self.BUTTON_ATCK)
233 if (weapon_prepareattack(0, 0))
235 self.misc_bulletcounter = 0;
236 uzi_mode1_fire_auto();
239 if(self.BUTTON_ATCK2)
240 if(weapon_prepareattack(1, 0))
242 if (!weapon_action(self.weapon, WR_CHECKAMMO2))
244 W_SwitchWeapon_Force(self, w_getbestweapon(self));
249 // if this weapon is reloadable, decrease its load. Else decrease the player's ammo
250 if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
252 if(autocvar_g_balance_uzi_reload_ammo)
254 self.clip_load -= autocvar_g_balance_uzi_burst_ammo;
255 self.weapon_load[WEP_UZI] = self.clip_load;
258 self.ammo_nails -= autocvar_g_balance_uzi_burst_ammo;
261 self.misc_bulletcounter = autocvar_g_balance_uzi_burst * -1;
262 uzi_mode1_fire_burst();
268 if (self.BUTTON_ATCK)
269 if (weapon_prepareattack(0, 0))
271 self.misc_bulletcounter = 1;
272 W_UZI_Attack(WEP_UZI); // sets attack_finished
273 weapon_thinkf(WFRAME_FIRE1, autocvar_g_balance_uzi_sustained_refire, uzi_fire1_02);
276 if (self.BUTTON_ATCK2 && autocvar_g_balance_uzi_first)
277 if (weapon_prepareattack(1, 0))
279 self.misc_bulletcounter = 1;
280 W_UZI_Attack(WEP_UZI | HITTYPE_SECONDARY); // sets attack_finished
281 weapon_thinkf(WFRAME_FIRE2, autocvar_g_balance_uzi_first_refire, w_ready);
285 else if (req == WR_PRECACHE)
287 precache_model ("models/uziflash.md3");
288 precache_model ("models/weapons/g_uzi.md3");
289 precache_model ("models/weapons/v_uzi.md3");
290 precache_model ("models/weapons/h_uzi.iqm");
291 precache_sound ("weapons/uzi_fire.wav");
292 precache_sound ("weapons/reload.wav");
294 else if (req == WR_SETUP)
296 weapon_setup(WEP_UZI);
298 else if (req == WR_CHECKAMMO1)
300 if(autocvar_g_balance_uzi_mode == 1)
301 ammo_amount = self.ammo_nails >= autocvar_g_balance_uzi_sustained_ammo;
303 ammo_amount = self.ammo_nails >= autocvar_g_balance_uzi_first_ammo;
305 if(autocvar_g_balance_uzi_reload_ammo)
307 if(autocvar_g_balance_uzi_mode == 1)
308 ammo_amount += self.weapon_load[WEP_UZI] >= autocvar_g_balance_uzi_sustained_ammo;
310 ammo_amount += self.weapon_load[WEP_UZI] >= autocvar_g_balance_uzi_first_ammo;
314 else if (req == WR_CHECKAMMO2)
316 if(autocvar_g_balance_uzi_mode == 1)
317 ammo_amount = self.ammo_nails >= autocvar_g_balance_uzi_burst_ammo;
319 ammo_amount = self.ammo_nails >= autocvar_g_balance_uzi_first_ammo;
321 if(autocvar_g_balance_uzi_reload_ammo)
323 if(autocvar_g_balance_uzi_mode == 1)
324 ammo_amount += self.weapon_load[WEP_UZI] >= autocvar_g_balance_uzi_burst_ammo;
326 ammo_amount += self.weapon_load[WEP_UZI] >= autocvar_g_balance_uzi_first_ammo;
330 else if (req == WR_RELOAD)
338 float w_uzi(float req)
340 if(req == WR_IMPACTEFFECT)
343 org2 = w_org + w_backoff * 2;
344 pointparticles(particleeffectnum("machinegun_impact"), org2, w_backoff * 1000, 1);
347 sound(self, CHAN_PROJECTILE, "weapons/ric1.wav", VOL_BASE, ATTN_NORM);
348 else if(w_random < 0.1)
349 sound(self, CHAN_PROJECTILE, "weapons/ric2.wav", VOL_BASE, ATTN_NORM);
350 else if(w_random < 0.2)
351 sound(self, CHAN_PROJECTILE, "weapons/ric3.wav", VOL_BASE, ATTN_NORM);
353 else if(req == WR_PRECACHE)
355 precache_sound("weapons/ric1.wav");
356 precache_sound("weapons/ric2.wav");
357 precache_sound("weapons/ric3.wav");
359 else if (req == WR_SUICIDEMESSAGE)
360 w_deathtypestring = _("%s did the impossible");
361 else if (req == WR_KILLMESSAGE)
363 if(w_deathtype & HITTYPE_SECONDARY)
364 w_deathtypestring = _("%s was sniped by %s");
366 w_deathtypestring = _("%s was riddled full of holes by %s");