]> icculus.org git repositories - divverent/nexuiz.git/blob - qcsrc/gamec/w_uzi.c
added many g_balance cvars and renamed cl_weapon_ cvars to use the g_viewweapon_...
[divverent/nexuiz.git] / qcsrc / gamec / w_uzi.c
1 void() uzi_ready_01;
2 void() uzi_fire1_01;
3 void() uzi_deselect_01;
4 void() uzi_select_01;
5
6 float() uzi_check =
7 {
8         if (self.ammo_nails >= 1)
9                 return TRUE;
10         return FALSE;
11 };
12
13 void(float req) w_uzi =
14 {
15         if (req == WR_IDLE)
16                 uzi_ready_01();
17         else if (req == WR_FIRE1)
18                 weapon_prepareattack(uzi_check, uzi_check, uzi_fire1_01, cvar("g_balance_uzi_refire"));
19         else if (req == WR_FIRE2)
20                 weapon_prepareattack(uzi_check, uzi_check, uzi_fire1_01, cvar("g_balance_uzi_refire"));
21         else if (req == WR_RAISE)
22                 uzi_select_01();
23         else if (req == WR_UPDATECOUNTS)
24                 self.currentammo = self.ammo_nails;
25         else if (req == WR_DROP)
26                 uzi_deselect_01();
27         else if (req == WR_SETUP)
28                 weapon_setup(WEP_UZI, "w_uzi.zym", IT_NAILS);
29         else if (req == WR_CHECKAMMO)
30                 weapon_hasammo = uzi_check();
31 };
32
33 .float uzi_bulletcounter;
34 void W_Uzi_Attack (void)
35 {
36         local vector org;
37         makevectors(self.v_angle);
38         sound (self, CHAN_WEAPON, "weapons/uzi_fire.wav", 1, ATTN_NORM);
39
40         org = self.origin + self.view_ofs + (v_right * 6) - (v_up * 8) + (v_forward * 15);
41         if (self.uzi_bulletcounter == 1)
42                 fireBullet (org, v_forward, cvar("g_balance_uzi_spread2"), cvar("g_balance_uzi_damage2"), IT_UZI, (self.uzi_bulletcounter & 3) == 0);
43         else
44                 fireBullet (org, v_forward, cvar("g_balance_uzi_spread"), cvar("g_balance_uzi_damage"), IT_UZI, (self.uzi_bulletcounter & 3) == 0);
45
46         self.punchangle_x = random () - 0.5;
47         self.punchangle_y = random () - 0.5;
48
49         self.ammo_nails = self.ammo_nails - 1;
50         // this attack_finished just enforces a cooldown at the end of a burst
51         self.attack_finished = time + cvar("g_balance_uzi_refire2");
52
53         // casing code
54         if (cvar("g_casings") == 1)
55         {
56                 org = self.origin + self.view_ofs + (v_right * 6) - (v_up * 8) + (v_forward * 10);
57                 SpawnCasing (org, ((random () * 50 + 50) * v_right) - ((random () * 25 + 25) * v_forward) - ((random () * 5 + 10) * v_up), 2, v_forward,'0 250 0', 100, 2);
58         }
59 }
60 // weapon frames
61
62 void()  uzi_ready_01 =  {weapon_thinkf(WFRAME_IDLE, 0.1, uzi_ready_01); self.weaponentity.state = WS_READY;};
63 void()  uzi_select_01 = {weapon_thinkf(-1, cvar("g_balance_weaponswitchdelay"), w_ready); weapon_boblayer1(PLAYER_WEAPONSELECTION_SPEED, '0 0 0');};
64 void()  uzi_deselect_01 =       {weapon_thinkf(-1, cvar("g_balance_weaponswitchdelay"), w_clear); weapon_boblayer1(PLAYER_WEAPONSELECTION_SPEED, PLAYER_WEAPONSELECTION_RANGE);};
65 void()  uzi_fire1_02 =
66 {
67         if (self.button0)
68         {
69                 self.uzi_bulletcounter = self.uzi_bulletcounter + 1;
70                 weapon_doattack(uzi_check, uzi_check, W_Uzi_Attack);
71                 weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_uzi_refire"), uzi_fire1_02);
72         }
73         else
74                 weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_uzi_refire"), uzi_ready_01);
75 };
76 void()  uzi_fire1_01 =
77 {
78         self.uzi_bulletcounter = 1;
79         weapon_doattack(uzi_check, uzi_check, W_Uzi_Attack);
80         weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_uzi_refire"), uzi_fire1_02);
81 };
82