5 /* ammotype */ IT_NAILS,
7 /* flags */ WEP_FLAG_NORMAL | WEP_FLAG_RELOADABLE | WEP_TYPE_HITSCAN,
8 /* rating */ BOT_PICKUP_RATING_MID,
11 /* fullname */ _("Machine Gun")
14 #define UZI_SETTINGS(w_cvar,w_prop) UZI_SETTINGS_LIST(w_cvar, w_prop, UZI, uzi)
15 #define UZI_SETTINGS_LIST(w_cvar,w_prop,id,sn) \
16 w_cvar(id, sn, MO_NONE, speed) \
17 w_cvar(id, sn, MO_NONE, spread_min) \
18 w_cvar(id, sn, MO_NONE, spread_max) \
19 w_cvar(id, sn, MO_NONE, spread_add) \
20 w_cvar(id, sn, MO_NONE, mode) \
21 w_cvar(id, sn, MO_NONE, bulletconstant) \
22 w_cvar(id, sn, MO_NONE, first) \
23 w_cvar(id, sn, MO_NONE, first_damage) \
24 w_cvar(id, sn, MO_NONE, first_force) \
25 w_cvar(id, sn, MO_NONE, first_refire) \
26 w_cvar(id, sn, MO_NONE, first_spread) \
27 w_cvar(id, sn, MO_NONE, first_ammo) \
28 w_cvar(id, sn, MO_NONE, sustained_damage) \
29 w_cvar(id, sn, MO_NONE, sustained_force) \
30 w_cvar(id, sn, MO_NONE, sustained_refire) \
31 w_cvar(id, sn, MO_NONE, sustained_spread) \
32 w_cvar(id, sn, MO_NONE, sustained_ammo) \
33 w_cvar(id, sn, MO_NONE, burst) \
34 w_cvar(id, sn, MO_NONE, burst_refire) \
35 w_cvar(id, sn, MO_NONE, burst_refire2) \
36 w_cvar(id, sn, MO_NONE, burst_animtime) \
37 w_cvar(id, sn, MO_NONE, burst_speed) \
38 w_cvar(id, sn, MO_NONE, burst_ammo) \
39 w_prop(id, sn, float, reloading_ammo, reload_ammo) \
40 w_prop(id, sn, float, reloading_time, reload_time) \
41 w_prop(id, sn, float, switchdelay_raise, switchdelay_raise) \
42 w_prop(id, sn, float, switchdelay_drop, switchdelay_drop) \
43 w_prop(id, sn, string, weaponreplace, weaponreplace) \
44 w_prop(id, sn, float, weaponstart, weaponstart) \
45 w_prop(id, sn, float, weaponstartoverride, weaponstartoverride)
48 UZI_SETTINGS(WEP_ADD_CVAR, WEP_ADD_PROP)
53 void spawnfunc_weapon_uzi()
55 if(autocvar_sv_q3acompat_machineshotgunswap)
56 if(self.classname != "droppedweapon")
58 weapon_defaultspawnfunc(WEP_SHOCKWAVE);
61 weapon_defaultspawnfunc(WEP_UZI);
64 // leilei's fancy muzzleflash stuff
67 self.frame = self.frame + 2;
68 self.scale = self.scale * 0.5;
69 self.alpha = self.alpha - 0.25;
70 self.nextthink = time + 0.05;
74 self.think = SUB_Remove;
75 self.nextthink = time;
76 self.realowner.muzzle_flash = world;
84 if (self.muzzle_flash == world)
85 self.muzzle_flash = spawn();
87 // muzzle flash for 1st person view
88 setmodel(self.muzzle_flash, "models/uziflash.md3"); // precision set below
90 self.muzzle_flash.scale = 0.75;
91 self.muzzle_flash.think = UZI_Flash_Go;
92 self.muzzle_flash.nextthink = time + 0.02;
93 self.muzzle_flash.frame = 2;
94 self.muzzle_flash.alpha = 0.75;
95 self.muzzle_flash.angles_z = random() * 180;
96 self.muzzle_flash.effects = EF_ADDITIVE | EF_FULLBRIGHT | EF_LOWPRECISION;
97 self.muzzle_flash.owner = self.muzzle_flash.realowner = self;
100 void W_UZI_Attack (float deathtype)
102 W_SetupShot (self, TRUE, 0, "weapons/uzi_fire.wav", CH_WEAPON_A, ((self.misc_bulletcounter == 1) ? WEP_CVAR(uzi, first_damage) : WEP_CVAR(uzi, sustained_damage)));
103 if (!autocvar_g_norecoil)
105 self.punchangle_x = random () - 0.5;
106 self.punchangle_y = random () - 0.5;
109 // this attack_finished just enforces a cooldown at the end of a burst
110 ATTACK_FINISHED(self) = time + WEP_CVAR(uzi, first_refire) * W_WeaponRateFactor();
112 if (self.misc_bulletcounter == 1)
113 fireBallisticBullet(w_shotorg, w_shotdir, WEP_CVAR(uzi, first_spread), WEP_CVAR(uzi, speed), 5, WEP_CVAR(uzi, first_damage), WEP_CVAR(uzi, first_force), deathtype, 0, WEP_CVAR(uzi, bulletconstant));
115 fireBallisticBullet(w_shotorg, w_shotdir, WEP_CVAR(uzi, sustained_spread), WEP_CVAR(uzi, speed), 5, WEP_CVAR(uzi, sustained_damage), WEP_CVAR(uzi, sustained_force), deathtype, 0, WEP_CVAR(uzi, bulletconstant));
116 endFireBallisticBullet();
118 pointparticles(particleeffectnum("uzi_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
121 W_AttachToShotorg(self.muzzle_flash, '5 0 0');
124 if (autocvar_g_casings >= 2)
125 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);
127 if (self.misc_bulletcounter == 1)
128 W_DecreaseAmmo(ammo_nails, WEP_CVAR(uzi, first_ammo), autocvar_g_balance_uzi_reload_ammo);
130 W_DecreaseAmmo(ammo_nails, WEP_CVAR(uzi, sustained_ammo), autocvar_g_balance_uzi_reload_ammo);
136 if(self.weapon != self.switchweapon) // abort immediately if switching
141 if (self.BUTTON_ATCK)
143 if (!WEP_ACTION(self.weapon, WR_CHECKAMMO2))
144 if (!(self.items & IT_UNLIMITED_WEAPON_AMMO))
146 W_SwitchWeapon_Force(self, w_getbestweapon(self));
150 self.misc_bulletcounter = self.misc_bulletcounter + 1;
151 W_UZI_Attack(WEP_UZI);
152 weapon_thinkf(WFRAME_FIRE1, WEP_CVAR(uzi, sustained_refire), uzi_fire1_02);
155 weapon_thinkf(WFRAME_FIRE1, WEP_CVAR(uzi, sustained_refire), w_ready);
159 void uzi_mode1_fire_auto()
163 if (!self.BUTTON_ATCK)
169 if (!WEP_ACTION(self.weapon, WR_CHECKAMMO1))
170 if (!(self.items & IT_UNLIMITED_WEAPON_AMMO))
172 W_SwitchWeapon_Force(self, w_getbestweapon(self));
177 W_DecreaseAmmo(ammo_nails, WEP_CVAR(uzi, sustained_ammo), autocvar_g_balance_uzi_reload_ammo);
179 W_SetupShot (self, TRUE, 0, "weapons/uzi_fire.wav", CH_WEAPON_A, WEP_CVAR(uzi, sustained_damage));
180 if (!autocvar_g_norecoil)
182 self.punchangle_x = random () - 0.5;
183 self.punchangle_y = random () - 0.5;
186 uzi_spread = bound(WEP_CVAR(uzi, spread_min), WEP_CVAR(uzi, spread_min) + (WEP_CVAR(uzi, spread_add) * self.misc_bulletcounter), WEP_CVAR(uzi, spread_max));
187 fireBallisticBullet(w_shotorg, w_shotdir, uzi_spread, WEP_CVAR(uzi, speed), 5, WEP_CVAR(uzi, sustained_damage), WEP_CVAR(uzi, sustained_force), WEP_UZI, 0, WEP_CVAR(uzi, bulletconstant));
188 endFireBallisticBullet();
190 self.misc_bulletcounter = self.misc_bulletcounter + 1;
192 pointparticles(particleeffectnum("uzi_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
195 W_AttachToShotorg(self.muzzle_flash, '5 0 0');
197 if (autocvar_g_casings >= 2) // casing code
198 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);
200 ATTACK_FINISHED(self) = time + WEP_CVAR(uzi, first_refire) * W_WeaponRateFactor();
201 weapon_thinkf(WFRAME_FIRE1, WEP_CVAR(uzi, sustained_refire), uzi_mode1_fire_auto);
204 void uzi_mode1_fire_burst()
206 W_SetupShot (self, TRUE, 0, "weapons/uzi_fire.wav", CH_WEAPON_A, WEP_CVAR(uzi, sustained_damage));
207 if (!autocvar_g_norecoil)
209 self.punchangle_x = random () - 0.5;
210 self.punchangle_y = random () - 0.5;
213 fireBallisticBullet(w_shotorg, w_shotdir, WEP_CVAR(uzi, burst_speed), WEP_CVAR(uzi, speed), 5, WEP_CVAR(uzi, sustained_damage), WEP_CVAR(uzi, sustained_force), WEP_UZI, 0, WEP_CVAR(uzi, bulletconstant));
214 endFireBallisticBullet();
217 pointparticles(particleeffectnum("uzi_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
220 W_AttachToShotorg(self.muzzle_flash, '5 0 0');
222 if (autocvar_g_casings >= 2) // casing code
223 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);
225 self.misc_bulletcounter = self.misc_bulletcounter + 1;
226 if (self.misc_bulletcounter == 0)
228 ATTACK_FINISHED(self) = time + WEP_CVAR(uzi, burst_refire2) * W_WeaponRateFactor();
229 weapon_thinkf(WFRAME_FIRE2, WEP_CVAR(uzi, burst_animtime), w_ready);
233 weapon_thinkf(WFRAME_FIRE2, WEP_CVAR(uzi, burst_refire), uzi_mode1_fire_burst);
238 float w_uzi(float req)
245 if(vlen(self.origin-self.enemy.origin) < 3000 - bound(0, skill, 10) * 200)
246 self.BUTTON_ATCK = bot_aim(1000000, 0, 0.001, FALSE);
248 self.BUTTON_ATCK2 = bot_aim(1000000, 0, 0.001, FALSE);
254 if(autocvar_g_balance_uzi_reload_ammo && self.clip_load < min(max(WEP_CVAR(uzi, sustained_ammo), WEP_CVAR(uzi, first_ammo)), WEP_CVAR(uzi, burst_ammo))) // forced reload
255 WEP_ACTION(self.weapon, WR_RELOAD);
256 else if(WEP_CVAR(uzi, mode) == 1)
258 if (self.BUTTON_ATCK)
259 if (weapon_prepareattack(0, 0))
261 self.misc_bulletcounter = 0;
262 uzi_mode1_fire_auto();
265 if(self.BUTTON_ATCK2)
266 if(weapon_prepareattack(1, 0))
268 if (!WEP_ACTION(self.weapon, WR_CHECKAMMO2))
269 if (!(self.items & IT_UNLIMITED_WEAPON_AMMO))
271 W_SwitchWeapon_Force(self, w_getbestweapon(self));
276 W_DecreaseAmmo(ammo_nails, WEP_CVAR(uzi, burst_ammo), autocvar_g_balance_uzi_reload_ammo);
278 self.misc_bulletcounter = WEP_CVAR(uzi, burst) * -1;
279 uzi_mode1_fire_burst();
285 if (self.BUTTON_ATCK)
286 if (weapon_prepareattack(0, 0))
288 self.misc_bulletcounter = 1;
289 W_UZI_Attack(WEP_UZI); // sets attack_finished
290 weapon_thinkf(WFRAME_FIRE1, WEP_CVAR(uzi, sustained_refire), uzi_fire1_02);
293 if (self.BUTTON_ATCK2 && WEP_CVAR(uzi, first))
294 if (weapon_prepareattack(1, 0))
296 self.misc_bulletcounter = 1;
297 W_UZI_Attack(WEP_UZI | HITTYPE_SECONDARY); // sets attack_finished
298 weapon_thinkf(WFRAME_FIRE2, WEP_CVAR(uzi, first_refire), w_ready);
306 precache_model ("models/uziflash.md3");
307 precache_model ("models/weapons/g_uzi.md3");
308 precache_model ("models/weapons/v_uzi.md3");
309 precache_model ("models/weapons/h_uzi.iqm");
310 precache_sound ("weapons/uzi_fire.wav");
311 UZI_SETTINGS(WEP_SKIPCVAR, WEP_SET_PROP)
316 self.current_ammo = ammo_nails;
321 if(WEP_CVAR(uzi, mode) == 1)
322 ammo_amount = self.ammo_nails >= WEP_CVAR(uzi, sustained_ammo);
324 ammo_amount = self.ammo_nails >= WEP_CVAR(uzi, first_ammo);
326 if(autocvar_g_balance_uzi_reload_ammo)
328 if(WEP_CVAR(uzi, mode) == 1)
329 ammo_amount += self.(weapon_load[WEP_UZI]) >= WEP_CVAR(uzi, sustained_ammo);
331 ammo_amount += self.(weapon_load[WEP_UZI]) >= WEP_CVAR(uzi, first_ammo);
337 if(WEP_CVAR(uzi, mode) == 1)
338 ammo_amount = self.ammo_nails >= WEP_CVAR(uzi, burst_ammo);
340 ammo_amount = self.ammo_nails >= WEP_CVAR(uzi, first_ammo);
342 if(autocvar_g_balance_uzi_reload_ammo)
344 if(WEP_CVAR(uzi, mode) == 1)
345 ammo_amount += self.(weapon_load[WEP_UZI]) >= WEP_CVAR(uzi, burst_ammo);
347 ammo_amount += self.(weapon_load[WEP_UZI]) >= WEP_CVAR(uzi, first_ammo);
353 UZI_SETTINGS(WEP_CONFIG_WRITE_CVARS, WEP_CONFIG_WRITE_PROPS)
358 W_Reload(min(max(WEP_CVAR(uzi, sustained_ammo), WEP_CVAR(uzi, first_ammo)), WEP_CVAR(uzi, burst_ammo)), "weapons/reload.wav");
361 case WR_SUICIDEMESSAGE:
363 return WEAPON_THINKING_WITH_PORTALS;
367 if(w_deathtype & HITTYPE_SECONDARY)
368 return WEAPON_UZI_MURDER_SNIPE;
370 return WEAPON_UZI_MURDER_SPRAY;
377 float w_uzi(float req)
381 case WR_IMPACTEFFECT:
384 org2 = w_org + w_backoff * 2;
385 pointparticles(particleeffectnum("machinegun_impact"), org2, w_backoff * 1000, 1);
388 sound(self, CH_SHOTS, "weapons/ric1.wav", VOL_BASE, ATTN_NORM);
389 else if(w_random < 0.1)
390 sound(self, CH_SHOTS, "weapons/ric2.wav", VOL_BASE, ATTN_NORM);
391 else if(w_random < 0.2)
392 sound(self, CH_SHOTS, "weapons/ric3.wav", VOL_BASE, ATTN_NORM);
398 precache_sound("weapons/ric1.wav");
399 precache_sound("weapons/ric2.wav");
400 precache_sound("weapons/ric3.wav");