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"))
6 // leilei's fancy muzzleflash stuff
9 self.frame = self.frame + 2;
10 self.scale = self.scale * 0.5;
11 self.alpha = self.alpha - 0.25;
12 self.nextthink = time + 0.05;
16 self.think = SUB_Remove;
17 self.nextthink = time;
18 self.realowner.muzzle_flash = world;
26 if (self.muzzle_flash == world)
27 self.muzzle_flash = spawn();
29 // muzzle flash for 1st person view
30 setmodel(self.muzzle_flash, "models/uziflash.md3"); // precision set below
32 self.muzzle_flash.scale = 0.75;
33 self.muzzle_flash.think = UZI_Flash_Go;
34 self.muzzle_flash.nextthink = time + 0.02;
35 self.muzzle_flash.frame = 2;
36 self.muzzle_flash.alpha = 0.75;
37 self.muzzle_flash.angles_z = random() * 180;
38 self.muzzle_flash.effects = EF_ADDITIVE | EF_FULLBRIGHT | EF_LOWPRECISION;
39 self.muzzle_flash.owner = self.muzzle_flash.realowner = self;
42 void W_UZI_Attack (float deathtype)
44 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));
47 self.punchangle_x = random () - 0.5;
48 self.punchangle_y = random () - 0.5;
51 // this attack_finished just enforces a cooldown at the end of a burst
52 ATTACK_FINISHED(self) = time + autocvar_g_balance_uzi_first_refire * W_WeaponRateFactor();
54 if (self.misc_bulletcounter == 1)
55 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);
57 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);
58 endFireBallisticBullet();
60 pointparticles(particleeffectnum("uzi_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
63 W_AttachToShotorg(self.muzzle_flash, '5 0 0');
66 if (autocvar_g_casings >= 2)
67 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);
69 if (self.misc_bulletcounter == 1)
70 W_DecreaseAmmo(ammo_nails, autocvar_g_balance_uzi_first_ammo, autocvar_g_balance_uzi_reload_ammo);
72 W_DecreaseAmmo(ammo_nails, autocvar_g_balance_uzi_sustained_ammo, autocvar_g_balance_uzi_reload_ammo);
78 if(self.weapon != self.switchweapon) // abort immediately if switching
85 if (!weapon_action(self.weapon, WR_CHECKAMMO2))
86 if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
88 W_SwitchWeapon_Force(self, w_getbestweapon(self));
92 self.misc_bulletcounter = self.misc_bulletcounter + 1;
93 W_UZI_Attack(WEP_UZI);
94 weapon_thinkf(WFRAME_FIRE1, autocvar_g_balance_uzi_sustained_refire, uzi_fire1_02);
97 weapon_thinkf(WFRAME_FIRE1, autocvar_g_balance_uzi_sustained_refire, w_ready);
101 void uzi_mode1_fire_auto()
105 W_DecreaseAmmo(ammo_nails, autocvar_g_balance_uzi_sustained_ammo, autocvar_g_balance_uzi_reload_ammo);
107 if (self.BUTTON_ATCK)
108 weapon_thinkf(WFRAME_FIRE1, autocvar_g_balance_uzi_sustained_refire, uzi_mode1_fire_auto);
111 ATTACK_FINISHED(self) = time + autocvar_g_balance_uzi_first_refire * W_WeaponRateFactor();
112 weapon_thinkf(WFRAME_FIRE1, autocvar_g_balance_uzi_sustained_refire, w_ready);
116 if (!weapon_action(self.weapon, WR_CHECKAMMO1))
117 if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
119 W_SwitchWeapon_Force(self, w_getbestweapon(self));
124 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);
127 self.punchangle_x = random () - 0.5;
128 self.punchangle_y = random () - 0.5;
131 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);
132 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);
133 endFireBallisticBullet();
135 self.misc_bulletcounter = self.misc_bulletcounter + 1;
137 pointparticles(particleeffectnum("uzi_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
140 W_AttachToShotorg(self.muzzle_flash, '5 0 0');
142 if (autocvar_g_casings >= 2) // casing code
143 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);
146 void uzi_mode1_fire_burst()
148 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);
151 self.punchangle_x = random () - 0.5;
152 self.punchangle_y = random () - 0.5;
155 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);
156 endFireBallisticBullet();
159 pointparticles(particleeffectnum("uzi_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
162 W_AttachToShotorg(self.muzzle_flash, '5 0 0');
164 if (autocvar_g_casings >= 2) // casing code
165 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);
167 self.misc_bulletcounter = self.misc_bulletcounter + 1;
168 if (self.misc_bulletcounter == 0)
170 ATTACK_FINISHED(self) = time + autocvar_g_balance_uzi_burst_refire2 * W_WeaponRateFactor();
171 weapon_thinkf(WFRAME_FIRE2, autocvar_g_balance_uzi_burst_animtime, w_ready);
175 weapon_thinkf(WFRAME_FIRE2, autocvar_g_balance_uzi_burst_refire, uzi_mode1_fire_burst);
180 void spawnfunc_weapon_machinegun(); // defined in t_items.qc
182 float w_uzi(float req)
186 if(vlen(self.origin-self.enemy.origin) < 3000 - bound(0, skill, 10) * 200)
187 self.BUTTON_ATCK = bot_aim(1000000, 0, 0.001, FALSE);
190 self.BUTTON_ATCK2 = bot_aim(1000000, 0, 0.001, FALSE);
192 else if (req == WR_THINK)
194 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
195 weapon_action(self.weapon, WR_RELOAD);
196 else if(autocvar_g_balance_uzi_mode == 1)
198 if (self.BUTTON_ATCK)
199 if (weapon_prepareattack(0, 0))
201 self.misc_bulletcounter = 0;
202 uzi_mode1_fire_auto();
205 if(self.BUTTON_ATCK2)
206 if(weapon_prepareattack(1, 0))
208 if (!weapon_action(self.weapon, WR_CHECKAMMO2))
210 W_SwitchWeapon_Force(self, w_getbestweapon(self));
215 W_DecreaseAmmo(ammo_nails, autocvar_g_balance_uzi_burst_ammo, autocvar_g_balance_uzi_reload_ammo);
217 self.misc_bulletcounter = autocvar_g_balance_uzi_burst * -1;
218 uzi_mode1_fire_burst();
224 if (self.BUTTON_ATCK)
225 if (weapon_prepareattack(0, 0))
227 self.misc_bulletcounter = 1;
228 W_UZI_Attack(WEP_UZI); // sets attack_finished
229 weapon_thinkf(WFRAME_FIRE1, autocvar_g_balance_uzi_sustained_refire, uzi_fire1_02);
232 if (self.BUTTON_ATCK2 && autocvar_g_balance_uzi_first)
233 if (weapon_prepareattack(1, 0))
235 self.misc_bulletcounter = 1;
236 W_UZI_Attack(WEP_UZI | HITTYPE_SECONDARY); // sets attack_finished
237 weapon_thinkf(WFRAME_FIRE2, autocvar_g_balance_uzi_first_refire, w_ready);
241 else if (req == WR_PRECACHE)
243 precache_model ("models/uziflash.md3");
244 precache_model ("models/weapons/g_uzi.md3");
245 precache_model ("models/weapons/v_uzi.md3");
246 precache_model ("models/weapons/h_uzi.iqm");
247 precache_sound ("weapons/uzi_fire.wav");
248 //precache_sound ("weapons/reload.wav"); // until weapons have individual reload sounds, precache the reload sound somewhere else
250 else if (req == WR_SETUP)
252 weapon_setup(WEP_UZI);
253 self.current_ammo = ammo_nails;
255 else if (req == WR_CHECKAMMO1)
257 if(autocvar_g_balance_uzi_mode == 1)
258 ammo_amount = self.ammo_nails >= autocvar_g_balance_uzi_sustained_ammo;
260 ammo_amount = self.ammo_nails >= autocvar_g_balance_uzi_first_ammo;
262 if(autocvar_g_balance_uzi_reload_ammo)
264 if(autocvar_g_balance_uzi_mode == 1)
265 ammo_amount += self.weapon_load[WEP_UZI] >= autocvar_g_balance_uzi_sustained_ammo;
267 ammo_amount += self.weapon_load[WEP_UZI] >= autocvar_g_balance_uzi_first_ammo;
271 else if (req == WR_CHECKAMMO2)
273 if(autocvar_g_balance_uzi_mode == 1)
274 ammo_amount = self.ammo_nails >= autocvar_g_balance_uzi_burst_ammo;
276 ammo_amount = self.ammo_nails >= autocvar_g_balance_uzi_first_ammo;
278 if(autocvar_g_balance_uzi_reload_ammo)
280 if(autocvar_g_balance_uzi_mode == 1)
281 ammo_amount += self.weapon_load[WEP_UZI] >= autocvar_g_balance_uzi_burst_ammo;
283 ammo_amount += self.weapon_load[WEP_UZI] >= autocvar_g_balance_uzi_first_ammo;
287 else if (req == WR_RELOAD)
289 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");
295 float w_uzi(float req)
297 if(req == WR_IMPACTEFFECT)
300 org2 = w_org + w_backoff * 2;
301 pointparticles(particleeffectnum("machinegun_impact"), org2, w_backoff * 1000, 1);
304 sound(self, CH_SHOTS, "weapons/ric1.wav", VOL_BASE, ATTN_NORM);
305 else if(w_random < 0.1)
306 sound(self, CH_SHOTS, "weapons/ric2.wav", VOL_BASE, ATTN_NORM);
307 else if(w_random < 0.2)
308 sound(self, CH_SHOTS, "weapons/ric3.wav", VOL_BASE, ATTN_NORM);
310 else if(req == WR_PRECACHE)
312 precache_sound("weapons/ric1.wav");
313 precache_sound("weapons/ric2.wav");
314 precache_sound("weapons/ric3.wav");
316 else if (req == WR_SUICIDEMESSAGE)
317 w_deathtypestring = _("%s is now thinking with portals");
318 else if (req == WR_KILLMESSAGE)
320 if(w_deathtype & HITTYPE_SECONDARY)
321 w_deathtypestring = _("%s was sniped by %s");
323 w_deathtypestring = _("%s was riddled full of holes by %s");