]> icculus.org git repositories - divverent/nexuiz.git/blob - qcsrc/gamec/w_uzi.c
major tweaks to ammo pickups, item respawn times, and all weapons are now parameteriz...
[divverent/nexuiz.git] / qcsrc / gamec / w_uzi.c
1 void() uzi_ready_01;
2 void() uzi_fire1_01;
3 void() uzi_fire2_01;
4 void() uzi_deselect_01;
5 void() uzi_select_01;
6
7 float() uzi_check =
8 {
9         if (self.ammo_nails >= 1)
10                 return TRUE;
11         return FALSE;
12 };
13
14 void(float req) w_uzi =
15 {
16         if (req == WR_IDLE)
17                 uzi_ready_01();
18         else if (req == WR_FIRE1)
19                 weapon_prepareattack(uzi_check, uzi_check, uzi_fire1_01, 0.075);
20         else if (req == WR_FIRE2)
21                 weapon_prepareattack(uzi_check, uzi_check, uzi_fire2_01, 0.4);
22         else if (req == WR_RAISE)
23                 uzi_select_01();
24         else if (req == WR_UPDATECOUNTS)
25                 self.currentammo = self.ammo_nails;
26         else if (req == WR_DROP)
27                 uzi_deselect_01();
28         else if (req == WR_SETUP)
29                 weapon_setup(WEP_UZI, "w_uzi.zym", IT_NAILS);
30         else if (req == WR_CHECKAMMO)
31                 weapon_hasammo = uzi_check();
32 };
33
34 void W_Uzi_Attack (void)
35 {
36         makevectors(self.v_angle);
37         sound (self, CHAN_WEAPON, "weapons/uzi_fire.wav", 1, ATTN_NORM);
38
39         fireBullet (self.origin + self.view_ofs, v_forward, 0.05, cvar("g_balance_uzi_damage"), IT_UZI);
40
41         self.punchangle_x = random () - 0.5;
42         self.punchangle_y = random () - 0.5;
43         self.punchangle_z = random () - 0.5;
44
45         self.attack_finished = time + 0.05;
46         self.ammo_nails = self.ammo_nails - 1;
47
48         vector  org; // casing code
49         org = self.origin + self.view_ofs + (v_right * 6) - (v_up * 1) + (v_forward * 15);
50         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);
51 }
52
53 void W_Uzi_Attack2 (void)
54 {
55         makevectors(self.v_angle);
56         sound (self, CHAN_WEAPON, "weapons/uzi_fire.wav", 1, ATTN_NORM);
57
58         fireBullet (self.origin + self.view_ofs, v_forward, 0.01, 21, IT_UZI);
59
60         self.attack_finished = time + 0.3;
61         self.ammo_nails = self.ammo_nails - 1;
62
63         vector  org; // casing code
64         org = self.origin + self.view_ofs + (v_right * 6) - (v_up * 1) + (v_forward * 20);
65         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);
66 }
67 // weapon frames
68
69 void()  uzi_ready_01 =  {weapon_thinkf(WFRAME_IDLE, 0.1, uzi_ready_01); self.weaponentity.state = WS_READY;};
70 void()  uzi_select_01 = {weapon_thinkf(-1, PLAYER_WEAPONSELECTION_DELAY, w_ready); weapon_boblayer1(PLAYER_WEAPONSELECTION_SPEED, '0 0 0');};
71 void()  uzi_deselect_01 =       {weapon_thinkf(-1, PLAYER_WEAPONSELECTION_DELAY, w_clear); weapon_boblayer1(PLAYER_WEAPONSELECTION_SPEED, PLAYER_WEAPONSELECTION_RANGE);};
72 void()  uzi_fire1_01 =
73 {
74         weapon_doattack(uzi_check, uzi_check, W_Uzi_Attack);
75         if (self.button0)
76                 weapon_thinkf(WFRAME_FIRE1, 0.05, uzi_fire1_01);
77         else
78                 weapon_thinkf(WFRAME_FIRE1, 0.05, uzi_ready_01);
79 };
80 void()  uzi_fire2_01 =
81 {
82         weapon_doattack(uzi_check, uzi_check, W_Uzi_Attack2);
83         weapon_thinkf(WFRAME_FIRE2, 0.05, uzi_ready_01);
84 };