]> icculus.org git repositories - divverent/nexuiz.git/blob - TeamNexuiz/game/gamec/w_shotgun.c
bumps for morphed's teleporter model
[divverent/nexuiz.git] / 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         sound (self, CHAN_WEAPON, "weapons/shotgun_fire.wav", 1, ATTN_NORM);\r
43         bullets = cvar("g_balance_shotgun_bullets");\r
44         d = cvar("g_balance_shotgun_damage");\r
45 \r
46         org = self.origin + self.view_ofs + (v_right * 6) - (v_up * 8) + (v_forward * 5);\r
47         spread = cvar("g_balance_shotgun_spread");\r
48         for (sc = 0;sc < bullets;sc = sc + 1)\r
49                 fireBullet2 (org, v_forward, spread, d, WEP_SHOTGUN, sc < 3, cvar("g_balance_shotgun_force"));\r
50         self.currentammo = self.currentammo - 1;\r
51 \r
52         // casing code\r
53         if (cvar("g_casings") >= 1)\r
54         {\r
55                 org = self.origin + self.view_ofs + (v_right * 6) - (v_up * 8) + (v_forward * 10);\r
56                 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
57         }\r
58 \r
59         org = self.origin + self.view_ofs + (v_right * 6) - (v_up * 8) + (v_forward * 20);\r
60         W_Smoke(org, v_forward, 12);\r
61         //te_smallflash(org);\r
62 \r
63         self.punchangle_x = -5;\r
64 }\r
65 \r
66 // weapon frames\r
67 \r
68 void()  shotgun_ready_01 =      {weapon_thinkf(WFRAME_IDLE, 0.1, shotgun_ready_01); self.weaponentity.state = WS_READY;};\r
69 void()  shotgun_select_01 =     {\r
70         self.currentammo = cvar("g_balance_shotgun_clipsize");\r
71         weapon_thinkf(-1, cvar("g_balance_weaponswitchdelay"), w_ready); weapon_boblayer1(PLAYER_WEAPONSELECTION_SPEED, '0 0 0');\r
72 }\r
73 void()  shotgun_deselect_01 =   {weapon_thinkf(-1, cvar("g_balance_weaponswitchdelay"), w_clear); weapon_boblayer1(PLAYER_WEAPONSELECTION_SPEED, PLAYER_WEAPONSELECTION_RANGE);};\r
74 \r
75 void()  shotgun_reload_02 =\r
76 {\r
77         self.currentammo = self.currentammo + 1;\r
78         shotgun_ready_01(); // return to ready state if not already there\r
79 }\r
80 \r
81 void()  shotgun_reload_01 =\r
82 {\r
83         if(self.currentammo >= cvar("g_balance_shotgun_clipsize"))\r
84         { // already full\r
85                 if(self.weaponentity.state != WS_READY)\r
86                         shotgun_ready_01(); // return to ready state if not already there\r
87                 return;\r
88         }\r
89         // if we somehow reached negative, fix that first\r
90         if(self.currentammo < 0)\r
91                 self.currentammo = 0;\r
92 \r
93         sound (self, CHAN_WEAPON, "weapons/shotgun_reload.wav", 1, ATTN_NORM);\r
94 \r
95         // load a shell\r
96         weapon_thinkf(WFRAME_FIRE2, cvar("g_balance_shotgun_loadclip2"), shotgun_reload_02);\r
97 }\r
98 \r
99 // after firing, call this funtion to check if the shotgun is empty\r
100 void()  shotgun_checkempty_01 =\r
101 {\r
102         if(self.currentammo >= 1)\r
103         { // we don't need to force a reload\r
104                 shotgun_ready_01();\r
105                 return;\r
106         }\r
107         // load a shell\r
108         shotgun_reload_01();\r
109 }\r
110 \r
111 void()  shotgun_fire1_01 =\r
112 {\r
113         weapon_doattack(shotgun_check, shotgun_check, W_Shotgun_Attack);\r
114         weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_shotgun_refire"), shotgun_checkempty_01);\r
115 }\r
116 void()  shotgun_fire2_01 =\r
117 {\r
118         shotgun_reload_01();\r
119 }