]> icculus.org git repositories - divverent/nexuiz.git/blob - data/qcsrc/server/gamec/w_shotgun.c
Stuff now shoots out of what appears to be the actual muzzles of the weapons. I modif...
[divverent/nexuiz.git] / data / qcsrc / server / gamec / w_shotgun.c
1 void() shotgun_ready_01;
2 void() shotgun_fire1_01;
3 void() shotgun_fire2_01;
4 void() shotgun_deselect_01;
5 void() shotgun_select_01;
6
7 float() shotgun_check =
8 {
9         if (self.ammo_shells >= cvar("g_balance_shotgun_primary_ammo"))
10                 return TRUE;
11         return FALSE;
12 };
13
14 float() shotgun_check2 =
15 {
16         if (self.ammo_shells >= cvar("g_balance_shotgun_secondary_ammo"))
17                 return TRUE;
18         return FALSE;
19 };
20
21 void(float req) w_shotgun =
22 {
23         if (req == WR_IDLE)
24                 shotgun_ready_01();
25         else if (req == WR_FIRE1)
26                 weapon_prepareattack(shotgun_check, shotgun_check, shotgun_fire1_01, cvar("g_balance_shotgun_primary_refire"));
27         else if (req == WR_FIRE2)
28                 weapon_prepareattack(shotgun_check2, shotgun_check2, shotgun_fire2_01, cvar("g_balance_shotgun_secondary_refire"));
29         else if (req == WR_RAISE)
30                 shotgun_select_01();
31         else if (req == WR_UPDATECOUNTS)
32                 self.currentammo = self.ammo_shells;
33         else if (req == WR_DROP)
34                 shotgun_deselect_01();
35         else if (req == WR_SETUP)
36                 weapon_setup(WEP_SHOTGUN, "w_shotgun.zym", IT_SHELLS);
37         else if (req == WR_CHECKAMMO)
38                 weapon_hasammo = shotgun_check() + shotgun_check2();
39 };
40
41 void W_Shotgun_Attack (void)
42 {
43         local vector org;
44         float   sc;
45         float   bullets;
46         float   d;
47         float   spread;
48
49         local vector trueaim;
50         trueaim = W_TrueAim();
51
52         sound (self, CHAN_WEAPON, "weapons/shotgun_fire.ogg", 1, ATTN_NORM);
53         if (self.items & IT_STRENGTH)
54                 sound (self, CHAN_AUTO, "weapons/strength_fire.ogg", 1, ATTN_NORM);
55
56         bullets = cvar("g_balance_shotgun_primary_bullets");
57         d = cvar("g_balance_shotgun_primary_damage");
58         spread = cvar("g_balance_shotgun_primary_spread");
59
60         org = W_MuzzleOrigin (self, '26 9 -10');
61         for (sc = 0;sc < bullets;sc = sc + 1)
62                 fireBullet (org, normalize(trueaim - org), spread, d, IT_SHOTGUN, sc < 3);
63         if (cvar("g_use_ammunition"))
64                 self.ammo_shells = self.ammo_shells - cvar("g_balance_shotgun_primary_ammo");
65
66         W_Smoke(org, v_forward, 12);
67         //te_smallflash(org);
68
69         // casing code
70         if (cvar("g_casings") >= 1)
71         {
72                 org = W_MuzzleOrigin (self, '10 10 -8');
73                 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);
74         }
75
76         self.punchangle_x = -5;
77 }
78
79 void W_Shotgun_Attack2 (void)
80 {
81         local vector org;
82         float   sc;
83         float   bullets;
84         float   d;
85         float   spread;
86
87         local vector trueaim;
88         trueaim = W_TrueAim();
89
90         sound (self, CHAN_WEAPON, "weapons/shotgun_fire.ogg", 1, ATTN_NORM);
91         if (self.items & IT_STRENGTH)
92                 sound (self, CHAN_AUTO, "weapons/strength_fire.ogg", 1, ATTN_NORM);
93
94         bullets = cvar("g_balance_shotgun_secondary_bullets");
95         d = cvar("g_balance_shotgun_secondary_damage");
96         spread = cvar("g_balance_shotgun_secondary_spread");
97
98         org = W_MuzzleOrigin (self, '26 9 -10');
99         for (sc = 0;sc < bullets;sc = sc + 1)
100                 fireBullet (org, normalize(trueaim - org), spread, d, IT_SHOTGUN, sc < 3);
101         if (cvar("g_use_ammunition"))
102                 self.ammo_shells = self.ammo_shells - cvar("g_balance_shotgun_secondary_ammo");
103
104         W_Smoke(org, v_forward, 12);
105         //te_smallflash(org);
106
107         // casing code
108         if (cvar("g_casings") >= 1)
109         {
110                 org = W_MuzzleOrigin (self, '10 10 -8');
111                 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);
112         }
113
114         self.punchangle_x = -5;
115 }
116
117 // weapon frames
118
119 void()  shotgun_ready_01 =      {weapon_thinkf(WFRAME_IDLE, 0.1, shotgun_ready_01); self.weaponentity.state = WS_READY;};
120 void()  shotgun_select_01 =     {weapon_thinkf(-1, cvar("g_balance_weaponswitchdelay"), w_ready); weapon_boblayer1(PLAYER_WEAPONSELECTION_SPEED, '0 0 0');};
121 void()  shotgun_deselect_01 =   {weapon_thinkf(-1, cvar("g_balance_weaponswitchdelay"), w_clear); weapon_boblayer1(PLAYER_WEAPONSELECTION_SPEED, PLAYER_WEAPONSELECTION_RANGE);};
122 void()  shotgun_fire1_01 =
123 {
124         weapon_doattack(shotgun_check, shotgun_check, W_Shotgun_Attack);
125         weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_shotgun_primary_animtime"), shotgun_ready_01);
126 };
127 void()  shotgun_fire2_03 =
128 {
129         weapon_doattack(shotgun_check2, shotgun_check2, W_Shotgun_Attack2);
130         weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_shotgun_secondary_animtime"), shotgun_ready_01);
131 }
132 void()  shotgun_fire2_02 =
133 {
134         weapon_doattack(shotgun_check2, shotgun_check2, W_Shotgun_Attack2);
135         weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_shotgun_secondary_animtime"), shotgun_fire2_03);
136 }
137 void()  shotgun_fire2_01 =
138 {
139         weapon_doattack(shotgun_check2, shotgun_check2, W_Shotgun_Attack2);
140         weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_shotgun_secondary_animtime"), shotgun_fire2_02);
141 }