]> icculus.org git repositories - divverent/nexuiz.git/blob - data/qcsrc/server/w_uzi.qc
centerprints now are managed independently per line
[divverent/nexuiz.git] / data / qcsrc / server / w_uzi.qc
1
2 .float uzi_bulletcounter;
3 void W_Uzi_Attack (void)
4 {
5         local entity flash;
6
7         if (cvar("g_use_ammunition"))
8         {
9                 if (self.uzi_bulletcounter == 1)
10                         self.ammo_nails = self.ammo_nails - cvar("g_balance_uzi_first_ammo");
11                 else
12                         self.ammo_nails = self.ammo_nails - cvar("g_balance_uzi_sustained_ammo");
13         }
14         W_SetupShot (self, '15 8 -8', TRUE, 0, "weapons/uzi_fire.ogg");
15         if (!cvar("g_norecoil"))
16         {
17                 self.punchangle_x = random () - 0.5;
18                 self.punchangle_y = random () - 0.5;
19         }
20
21         // this attack_finished just enforces a cooldown at the end of a burst
22         self.attack_finished = time + cvar("g_balance_uzi_first_refire");
23
24         if (self.uzi_bulletcounter == 1)
25                 fireBullet (w_shotorg, w_shotdir, cvar("g_balance_uzi_first_spread"), cvar("g_balance_uzi_first_damage"), IT_UZI, (self.uzi_bulletcounter & 3) == 0);
26         else
27                 fireBullet (w_shotorg, w_shotdir, cvar("g_balance_uzi_sustained_spread"), cvar("g_balance_uzi_sustained_damage"), IT_UZI, (self.uzi_bulletcounter & 3) == 0);
28
29         flash = spawn ();
30         setorigin (flash, w_shotorg + v_forward * 17);
31         setmodel (flash, "models/uziflash.md3");
32         flash.angles = vectoangles (w_shotdir);
33         flash.angles_z=flash.v_angle_z + random () * 180;
34         flash.scale = 0.75;
35         flash.alpha = 0.5;
36         SUB_SetFade (flash, time, 0.2);
37         flash.effects = flash.effects | EF_ADDITIVE | EF_FULLBRIGHT | EF_LOWPRECISION;
38
39         // casing code
40         if (cvar("g_casings") >= 2)
41                 SpawnCasing (w_shotorg + v_forward * 10, ((random () * 50 + 50) * v_right) - ((random () * 25 + 25) * v_forward) - ((random () * 5 - 70) * v_up), 2, vectoangles(v_forward),'0 250 0', 100, 3);
42 }
43
44 // weapon frames
45 void()  uzi_fire1_02 =
46 {
47         if (self.button0 && self.weapon == self.switchweapon)
48         {
49                 if (!weapon_action(self.weapon, WR_CHECKAMMO2))
50                 {
51                         self.switchweapon = w_getbestweapon(self);
52                         if (self.switchweapon != self.weapon)
53                                 self.cnt = self.weapon;
54                         w_ready();
55                         return;
56                 }
57                 self.attack_finished = time + cvar("g_balance_uzi_refire");
58                 self.uzi_bulletcounter = self.uzi_bulletcounter + 1;
59                 W_Uzi_Attack();
60                 weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_uzi_sustained_refire"), uzi_fire1_02);
61         }
62         else
63                 weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_uzi_sustained_refire"), w_ready);
64 };
65
66 float(float req) w_uzi =
67 {
68         if (req == WR_AIM)
69                 self.button0 = bot_aim(1000000, 0, 0.001, FALSE);
70         else if (req == WR_THINK)
71         {
72                 if (self.button0)
73                 if (weapon_prepareattack(0, cvar("g_balance_uzi_refire")))
74                 {
75                         self.uzi_bulletcounter = 1;
76                         W_Uzi_Attack();
77                         weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_uzi_sustained_refire"), uzi_fire1_02);
78                 }
79                 if (self.button3)
80                 if (weapon_prepareattack(1, cvar("g_balance_uzi_refire")))
81                 {
82                         self.uzi_bulletcounter = 1;
83                         W_Uzi_Attack();
84                         weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_uzi_sustained_refire"), w_ready);
85                 }
86         }
87         else if (req == WR_SETUP)
88                 weapon_setup(WEP_UZI, "uzi", IT_NAILS);
89         else if (req == WR_CHECKAMMO1)
90                 return self.ammo_nails >= cvar("g_balance_uzi_first_ammo");
91         else if (req == WR_CHECKAMMO2)
92                 return self.ammo_nails >= cvar("g_balance_uzi_sustained_ammo");
93         return TRUE;
94 };