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