centerprints now are managed independently per line
[divverent/nexuiz.git] / data / qcsrc / server / w_shotgun.qc
1
2 void W_Shotgun_Attack (void)
3 {
4         float   sc;
5         float   bullets;
6         float   d;
7         float   spread;
8
9         bullets = cvar("g_balance_shotgun_primary_bullets");
10         d = cvar("g_balance_shotgun_primary_damage");
11         spread = cvar("g_balance_shotgun_primary_spread");
12
13         W_SetupShot (self, '15 8 -8', TRUE, 5, "weapons/shotgun_fire.ogg");
14         for (sc = 0;sc < bullets;sc = sc + 1)
15                 fireBullet (w_shotorg, w_shotdir, spread, d, IT_SHOTGUN, sc < 3);
16         if (cvar("g_use_ammunition"))
17                 self.ammo_shells = self.ammo_shells - cvar("g_balance_shotgun_primary_ammo");
18
19         W_Smoke(w_shotorg, v_forward, 12);
20         //te_smallflash(w_shotorg);
21
22         // casing code
23         if (cvar("g_casings") >= 1)
24                 SpawnCasing (w_shotorg, ((random () * 50 + 50) * v_right) - ((random () * 25 + 25) * v_forward) - ((random () * 5 - 30) * v_up), 2, vectoangles(v_forward),'0 250 0', 100, 1);
25 }
26
27 void W_Shotgun_Attack2 (void)
28 {
29         float   sc;
30         float   bullets;
31         float   d;
32         float   spread;
33
34         bullets = cvar("g_balance_shotgun_secondary_bullets");
35         d = cvar("g_balance_shotgun_secondary_damage");
36         spread = cvar("g_balance_shotgun_secondary_spread");
37
38         W_SetupShot (self, '15 8 -8', TRUE, 5, "weapons/shotgun_fire.ogg");
39         for (sc = 0;sc < bullets;sc = sc + 1)
40                 fireBullet (w_shotorg, w_shotdir, spread, d, IT_SHOTGUN, sc < 3);
41         if (cvar("g_use_ammunition"))
42                 self.ammo_shells = self.ammo_shells - cvar("g_balance_shotgun_secondary_ammo");
43
44         W_Smoke(w_shotorg + v_forward * 8, v_forward, 12);
45         //te_smallflash(w_shotorg);
46
47         // casing code
48         if (cvar("g_casings") >= 1)
49                 SpawnCasing (w_shotorg, ((random () * 50 + 50) * v_right) - ((random () * 25 + 25) * v_forward) - ((random () * 5 - 30) * v_up), 2, vectoangles(v_forward),'0 250 0', 100, 1);
50 }
51
52 // weapon frames
53 void()  shotgun_fire2_03 =
54 {
55         W_Shotgun_Attack2();
56         weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_shotgun_secondary_animtime"), w_ready);
57 }
58 void()  shotgun_fire2_02 =
59 {
60         W_Shotgun_Attack2();
61         weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_shotgun_secondary_animtime"), shotgun_fire2_03);
62 }
63
64 float(float req) w_shotgun =
65 {
66         if (req == WR_AIM)
67                 self.button0 = bot_aim(1000000, 0, 0.001, FALSE);
68         else if (req == WR_THINK)
69         {
70                 if (self.button0)
71                 if (weapon_prepareattack(0, cvar("g_balance_shotgun_primary_refire")))
72                 {
73                         W_Shotgun_Attack();
74                         weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_shotgun_primary_animtime"), w_ready);
75                 }
76                 if (self.button3)
77                 if (weapon_prepareattack(1, cvar("g_balance_shotgun_secondary_refire")))
78                 {
79                         W_Shotgun_Attack2();
80                         weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_shotgun_secondary_animtime"), shotgun_fire2_02);
81                 }
82         }
83         else if (req == WR_SETUP)
84                 weapon_setup(WEP_SHOTGUN, "shotgun", IT_SHELLS);
85         else if (req == WR_CHECKAMMO1)
86                 return self.ammo_shells >= cvar("g_balance_shotgun_primary_ammo");
87         else if (req == WR_CHECKAMMO2)
88                 return self.ammo_shells >= cvar("g_balance_shotgun_secondary_ammo") * 3;
89         return TRUE;
90 };