]> icculus.org git repositories - divverent/nexuiz.git/blob - data/qcsrc/gamec/w_uzi.c
add g_navnodeedit
[divverent/nexuiz.git] / data / 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 || req == WR_FIRE2)
18                 weapon_prepareattack(uzi_check, uzi_check, uzi_fire1_01, cvar("g_balance_uzi_refire"));
19         else if (req == WR_RAISE)
20                 uzi_select_01();
21         else if (req == WR_UPDATECOUNTS)
22                 self.currentammo = self.ammo_nails;
23         else if (req == WR_DROP)
24                 uzi_deselect_01();
25         else if (req == WR_SETUP)
26                 weapon_setup(WEP_UZI, "w_uzi.zym", IT_NAILS);
27         else if (req == WR_CHECKAMMO)
28                 weapon_hasammo = uzi_check();
29 };
30
31 .float uzi_bulletcounter;
32 void W_Uzi_Attack (void)
33 {
34         local vector org;
35
36         local vector trueaim;
37         trueaim = W_TrueAim();
38         
39         entity flash;
40         sound (self, CHAN_WEAPON, "weapons/uzi_fire.ogg", 1, ATTN_NORM);
41         if (self.items & IT_STRENGTH) {
42                 sound (self, CHAN_AUTO, "weapons/strength_fire.ogg", 1, ATTN_NORM);
43         }
44         
45         if (cvar("g_use_ammunition"))
46                 self.ammo_nails = self.ammo_nails - 1;
47         self.punchangle_x = random () - 0.5;
48         self.punchangle_y = random () - 0.5;
49         org = self.origin + self.view_ofs + (v_right * 6) - (v_up * 8) + (v_forward * 15);
50
51         // this attack_finished just enforces a cooldown at the end of a burst
52         self.attack_finished = time + cvar("g_balance_uzi_refire2");
53
54         if (self.uzi_bulletcounter == 1)
55                 fireBullet (org, normalize(trueaim - org), cvar("g_balance_uzi_spread2"), cvar("g_balance_uzi_damage2"), IT_UZI, (self.uzi_bulletcounter & 3) == 0);
56         else
57                 fireBullet (org, normalize(trueaim - org), cvar("g_balance_uzi_spread"), cvar("g_balance_uzi_damage"), IT_UZI, (self.uzi_bulletcounter & 3) == 0);
58
59         // casing code
60         if (cvar("g_casings") >= 2)
61         {
62                 org = self.origin + self.view_ofs + (v_right * 6) - (v_up * 8) + (v_forward * 10);
63                 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);
64         }
65
66         flash = spawn ();
67         org = self.origin + self.view_ofs + (v_right * 6) - (v_up * 10) + (v_forward * 40);
68         setorigin (flash, org);
69         setmodel (flash, "models/uziflash.md3");
70         flash.velocity = v_forward * 20;
71         flash.angles = vectoangles (flash.velocity);
72         flash.angles_z=flash.v_angle_z + random () * 180;
73         flash.scale = 0.75;
74         flash.alpha = 0.5;
75         SUB_SetFade (flash, time, 0.2);
76         flash.effects = flash.effects | EF_ADDITIVE | EF_FULLBRIGHT | EF_LOWPRECISION;
77
78 }
79 // weapon frames
80
81 void()  uzi_ready_01 =  {weapon_thinkf(WFRAME_IDLE, 0.1, uzi_ready_01); self.weaponentity.state = WS_READY;};
82 void()  uzi_select_01 = {weapon_thinkf(-1, cvar("g_balance_weaponswitchdelay"), w_ready); weapon_boblayer1(PLAYER_WEAPONSELECTION_SPEED, '0 0 0');};
83 void()  uzi_deselect_01 =       {weapon_thinkf(-1, cvar("g_balance_weaponswitchdelay"), w_clear); weapon_boblayer1(PLAYER_WEAPONSELECTION_SPEED, PLAYER_WEAPONSELECTION_RANGE);};
84 void()  uzi_fire1_02 =
85 {
86         if (self.button0)
87         {
88                 self.uzi_bulletcounter = self.uzi_bulletcounter + 1;
89                 weapon_doattack(uzi_check, uzi_check, W_Uzi_Attack);
90                 weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_uzi_refire"), uzi_fire1_02);
91         }
92         else
93                 weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_uzi_refire"), uzi_ready_01);
94 };
95 void()  uzi_fire1_01 =
96 {
97         self.uzi_bulletcounter = 1;
98         weapon_doattack(uzi_check, uzi_check, W_Uzi_Attack);
99         weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_uzi_refire"), uzi_fire1_02);
100 };
101