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