]> icculus.org git repositories - divverent/nexuiz.git/blob - data/qcsrc/server/w_uzi.qc
if you have strength, the second Damage() call will take care of it anyway
[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 5.5 -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.weapon != self.switchweapon) // abort immediately if switching
48         {
49                 w_ready();
50                 return;
51         }
52         if (self.button0)
53         {
54                 if (!weapon_action(self.weapon, WR_CHECKAMMO2))
55                 {
56                         self.switchweapon = w_getbestweapon(self);
57                         if (self.switchweapon != self.weapon)
58                                 self.cnt = self.weapon;
59                         w_ready();
60                         return;
61                 }
62                 self.attack_finished = time + cvar("g_balance_uzi_refire");
63                 self.uzi_bulletcounter = self.uzi_bulletcounter + 1;
64                 W_Uzi_Attack();
65                 weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_uzi_sustained_refire"), uzi_fire1_02);
66         }
67         else
68                 weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_uzi_sustained_refire"), w_ready);
69 };
70
71 float(float req) w_uzi =
72 {
73         if (req == WR_AIM)
74                 if(vlen(self.origin-self.enemy.origin)<750)
75                         self.button0 = bot_aim(1000000, 0, 0.001, FALSE);
76                 else
77                 {
78                         self.button3 = bot_aim(1000000, 0, 0.001, FALSE);
79                 }
80         else if (req == WR_THINK)
81         {
82                 if (self.button0)
83                 if (weapon_prepareattack(0, cvar("g_balance_uzi_refire")))
84                 {
85                         self.uzi_bulletcounter = 1;
86                         W_Uzi_Attack();
87                         weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_uzi_sustained_refire"), uzi_fire1_02);
88                 }
89                 if (self.button3)
90                 if (weapon_prepareattack(1, cvar("g_balance_uzi_refire")))
91                 {
92                         self.uzi_bulletcounter = 1;
93                         W_Uzi_Attack();
94                         weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_uzi_sustained_refire"), w_ready);
95                 }
96         }
97         else if (req == WR_SETUP)
98                 weapon_setup(WEP_UZI, "uzi", IT_NAILS);
99         else if (req == WR_CHECKAMMO1)
100                 return self.ammo_nails >= cvar("g_balance_uzi_first_ammo");
101         else if (req == WR_CHECKAMMO2)
102                 return self.ammo_nails >= cvar("g_balance_uzi_sustained_ammo");
103         return TRUE;
104 };