2 REGISTER_WEAPON(UZI, w_uzi, IT_NAILS, 3, WEP_FLAG_NORMAL | 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.owner.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;
42 void W_Uzi_Attack (float deathtype)
44 if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
46 if (self.misc_bulletcounter == 1)
47 self.ammo_nails = self.ammo_nails - autocvar_g_balance_uzi_first_ammo;
49 self.ammo_nails = self.ammo_nails - autocvar_g_balance_uzi_sustained_ammo;
51 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));
54 self.punchangle_x = random () - 0.5;
55 self.punchangle_y = random () - 0.5;
58 // this attack_finished just enforces a cooldown at the end of a burst
59 ATTACK_FINISHED(self) = time + autocvar_g_balance_uzi_first_refire * W_WeaponRateFactor();
61 if (self.misc_bulletcounter == 1)
62 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);
64 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);
65 endFireBallisticBullet();
67 pointparticles(particleeffectnum("uzi_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
70 W_AttachToShotorg(self.muzzle_flash, '5 0 0');
73 if (autocvar_g_casings >= 2)
74 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(self.weapon != self.switchweapon) // abort immediately if switching
87 if (!weapon_action(self.weapon, WR_CHECKAMMO2))
89 W_SwitchWeapon_Force(self, w_getbestweapon(self));
93 self.misc_bulletcounter = self.misc_bulletcounter + 1;
94 W_Uzi_Attack(WEP_UZI);
95 weapon_thinkf(WFRAME_FIRE1, autocvar_g_balance_uzi_sustained_refire, uzi_fire1_02);
98 weapon_thinkf(WFRAME_FIRE1, autocvar_g_balance_uzi_sustained_refire, w_ready);
102 void uzi_mode1_fire_auto()
106 if (self.BUTTON_ATCK)
107 weapon_thinkf(WFRAME_FIRE1, autocvar_g_balance_uzi_sustained_refire, uzi_mode1_fire_auto);
110 ATTACK_FINISHED(self) = time + autocvar_g_balance_uzi_first_refire * W_WeaponRateFactor();
111 weapon_thinkf(WFRAME_FIRE1, autocvar_g_balance_uzi_sustained_refire, w_ready);
115 if (!weapon_action(self.weapon, WR_CHECKAMMO1))
117 W_SwitchWeapon_Force(self, w_getbestweapon(self));
122 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);
125 self.punchangle_x = random () - 0.5;
126 self.punchangle_y = random () - 0.5;
129 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);
130 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);
131 endFireBallisticBullet();
133 self.misc_bulletcounter = self.misc_bulletcounter + 1;
135 pointparticles(particleeffectnum("uzi_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
138 W_AttachToShotorg(self.muzzle_flash, '5 0 0');
140 if (autocvar_g_casings >= 2) // casing code
141 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);
143 if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
144 self.ammo_nails = self.ammo_nails - autocvar_g_balance_uzi_sustained_ammo;
148 void uzi_mode1_fire_burst()
150 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);
153 self.punchangle_x = random () - 0.5;
154 self.punchangle_y = random () - 0.5;
157 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);
158 endFireBallisticBullet();
161 pointparticles(particleeffectnum("uzi_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
164 W_AttachToShotorg(self.muzzle_flash, '5 0 0');
166 if (autocvar_g_casings >= 2) // casing code
167 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);
169 self.misc_bulletcounter = self.misc_bulletcounter + 1;
170 if (self.misc_bulletcounter == 0)
172 ATTACK_FINISHED(self) = time + autocvar_g_balance_uzi_burst_refire2 * W_WeaponRateFactor();
173 weapon_thinkf(WFRAME_FIRE2, autocvar_g_balance_uzi_burst_animtime, w_ready);
177 weapon_thinkf(WFRAME_FIRE2, autocvar_g_balance_uzi_burst_refire, uzi_mode1_fire_burst);
182 void spawnfunc_weapon_machinegun(); // defined in t_items.qc
184 float w_uzi(float req)
187 if(vlen(self.origin-self.enemy.origin) < 3000 - bound(0, skill, 10) * 200)
188 self.BUTTON_ATCK = bot_aim(1000000, 0, 0.001, FALSE);
191 self.BUTTON_ATCK2 = bot_aim(1000000, 0, 0.001, FALSE);
193 else if (req == WR_THINK)
195 if(autocvar_g_balance_uzi_mode == 1)
197 if (self.BUTTON_ATCK)
198 if (weapon_prepareattack(0, 0))
200 self.misc_bulletcounter = 0;
201 uzi_mode1_fire_auto();
204 if(self.BUTTON_ATCK2)
205 if(weapon_prepareattack(1, 0))
207 if (!weapon_action(self.weapon, WR_CHECKAMMO2))
209 W_SwitchWeapon_Force(self, w_getbestweapon(self));
214 if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
215 self.ammo_nails = self.ammo_nails - autocvar_g_balance_uzi_burst_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");
249 else if (req == WR_SETUP)
250 weapon_setup(WEP_UZI);
251 else if (req == WR_CHECKAMMO1)
252 if(autocvar_g_balance_uzi_mode == 1)
253 return self.ammo_nails >= autocvar_g_balance_uzi_sustained_ammo;
255 return self.ammo_nails >= autocvar_g_balance_uzi_first_ammo;
256 else if (req == WR_CHECKAMMO2)
257 if(autocvar_g_balance_uzi_mode == 1)
258 return self.ammo_nails >= autocvar_g_balance_uzi_burst_ammo;
260 return self.ammo_nails >= autocvar_g_balance_uzi_first_ammo;
265 float w_uzi(float req)
267 if(req == WR_IMPACTEFFECT)
270 org2 = w_org + w_backoff * 2;
271 pointparticles(particleeffectnum("machinegun_impact"), org2, w_backoff * 1000, 1);
274 sound(self, CHAN_PROJECTILE, "weapons/ric1.wav", VOL_BASE, ATTN_NORM);
275 else if(w_random < 0.1)
276 sound(self, CHAN_PROJECTILE, "weapons/ric2.wav", VOL_BASE, ATTN_NORM);
277 else if(w_random < 0.2)
278 sound(self, CHAN_PROJECTILE, "weapons/ric3.wav", VOL_BASE, ATTN_NORM);
280 else if(req == WR_PRECACHE)
282 precache_sound("weapons/ric1.wav");
283 precache_sound("weapons/ric2.wav");
284 precache_sound("weapons/ric3.wav");
286 else if (req == WR_SUICIDEMESSAGE)
287 w_deathtypestring = _("%s did the impossible");
288 else if (req == WR_KILLMESSAGE)
290 if(w_deathtype & HITTYPE_SECONDARY)
291 w_deathtypestring = _("%s was sniped by %s");
293 w_deathtypestring = _("%s was riddled full of holes by %s");