]> icculus.org git repositories - divverent/nexuiz.git/blob - attic/TeamNexuiz/game/gamec/w_shotgun.c
moved navnodeedit & TeamNexuiz to attic
[divverent/nexuiz.git] / attic / TeamNexuiz / game / gamec / w_shotgun.c
1 void() shotgun_ready_01;\r
2 void() shotgun_fire1_01;\r
3 void() shotgun_fire2_01;\r
4 void() shotgun_deselect_01;\r
5 void() shotgun_select_01;\r
6 \r
7 float() shotgun_check =\r
8 {\r
9 //      if (self.ammo_shells >= 1)\r
10                 return TRUE;\r
11 //      return FALSE;\r
12 };\r
13 \r
14 void(float req) w_shotgun =\r
15 {\r
16         if (req == WR_IDLE)\r
17                 shotgun_ready_01();\r
18         else if (req == WR_FIRE1)\r
19                 weapon_prepareattack(shotgun_check, shotgun_check, shotgun_fire1_01, cvar("g_balance_shotgun_refire"));\r
20         else if (req == WR_FIRE2)\r
21                 weapon_prepareattack(shotgun_check, shotgun_check, shotgun_fire2_01, cvar("g_balance_shotgun_loadclip"));\r
22         else if (req == WR_RAISE)\r
23                 shotgun_select_01();\r
24         else if (req == WR_UPDATECOUNTS)\r
25                 return;//self.currentammo = self.ammo_shells;\r
26         else if (req == WR_DROP)\r
27                 shotgun_deselect_01();\r
28         else if (req == WR_SETUP)\r
29                 weapon_setup(WEP_SHOTGUN, "w_shotgun.zym", IT_SHELLS);\r
30         else if (req == WR_CHECKAMMO)\r
31                 weapon_hasammo = shotgun_check();\r
32 };\r
33 \r
34 void W_Shotgun_Attack (void)\r
35 {\r
36         local vector org;\r
37         float   sc;\r
38         float   bullets;\r
39         float   d;\r
40         float   spread;\r
41 \r
42         local vector end;\r
43         local vector trueaim;\r
44         org = self.origin + self.view_ofs;\r
45         end = self.origin + self.view_ofs + v_forward * 4096;\r
46         traceline(org,end,TRUE,self);\r
47         \r
48         trueaim = trace_endpos;\r
49 \r
50         sound (self, CHAN_WEAPON, "weapons/shotgun_fire.ogg", 1, ATTN_NORM);\r
51         bullets = cvar("g_balance_shotgun_bullets");\r
52         d = cvar("g_balance_shotgun_damage");\r
53 \r
54         org = self.origin + self.view_ofs + (v_right * 6) - (v_up * 8) + (v_forward * 5);\r
55         spread = cvar("g_balance_shotgun_spread");\r
56         for (sc = 0;sc < bullets;sc = sc + 1)\r
57                 fireBullet2 (org, normalize(trueaim - org), spread, d, WEP_SHOTGUN, sc < 3, cvar("g_balance_shotgun_force"));\r
58         self.currentammo = self.currentammo - 1;\r
59 \r
60         // casing code\r
61         if (cvar("g_casings") >= 1)\r
62         {\r
63                 org = self.origin + self.view_ofs + (v_right * 6) - (v_up * 8) + (v_forward * 10);\r
64                 SpawnCasing (org, ((random () * 50 + 50) * v_right) - ((random () * 25 + 25) * v_forward) - ((random () * 5 + 10) * v_up), 2, v_forward,'0 250 0', 100, 1);\r
65         }\r
66 \r
67         org = self.origin + self.view_ofs + (v_right * 6) - (v_up * 8) + (v_forward * 20);\r
68         W_Smoke(org, v_forward, 12);\r
69         //te_smallflash(org);\r
70 \r
71         self.punchangle_x = -5;\r
72 }\r
73 \r
74 // weapon frames\r
75 \r
76 void()  shotgun_ready_01 =      {weapon_thinkf(WFRAME_IDLE, 0.1, shotgun_ready_01); self.weaponentity.state = WS_READY;};\r
77 void()  shotgun_select_01 =     {\r
78         self.currentammo = cvar("g_balance_shotgun_clipsize");\r
79         weapon_thinkf(-1, cvar("g_balance_weaponswitchdelay"), w_ready); weapon_boblayer1(PLAYER_WEAPONSELECTION_SPEED, '0 0 0');\r
80 }\r
81 void()  shotgun_deselect_01 =   {weapon_thinkf(-1, cvar("g_balance_weaponswitchdelay"), w_clear); weapon_boblayer1(PLAYER_WEAPONSELECTION_SPEED, PLAYER_WEAPONSELECTION_RANGE);};\r
82 \r
83 void()  shotgun_reload_02 =\r
84 {\r
85         self.currentammo = self.currentammo + 1;\r
86         shotgun_ready_01(); // return to ready state if not already there\r
87 }\r
88 \r
89 void()  shotgun_reload_01 =\r
90 {\r
91         if(self.currentammo >= cvar("g_balance_shotgun_clipsize"))\r
92         { // already full\r
93                 if(self.weaponentity.state != WS_READY)\r
94                         shotgun_ready_01(); // return to ready state if not already there\r
95                 return;\r
96         }\r
97         // if we somehow reached negative, fix that first\r
98         if(self.currentammo < 0)\r
99                 self.currentammo = 0;\r
100 \r
101         sound (self, CHAN_WEAPON, "weapons/shotgun_reload.wav", 1, ATTN_NORM);\r
102 \r
103         // load a shell\r
104         weapon_thinkf(WFRAME_FIRE2, cvar("g_balance_shotgun_loadclip2"), shotgun_reload_02);\r
105 }\r
106 \r
107 // after firing, call this funtion to check if the shotgun is empty\r
108 void()  shotgun_checkempty_01 =\r
109 {\r
110         if(self.currentammo >= 1)\r
111         { // we don't need to force a reload\r
112                 shotgun_ready_01();\r
113                 return;\r
114         }\r
115         // load a shell\r
116         shotgun_reload_01();\r
117 }\r
118 \r
119 void()  shotgun_fire1_01 =\r
120 {\r
121         weapon_doattack(shotgun_check, shotgun_check, W_Shotgun_Attack);\r
122         weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_shotgun_refire"), shotgun_checkempty_01);\r
123 }\r
124 void()  shotgun_fire2_01 =\r
125 {\r
126         shotgun_reload_01();\r
127 }