]> icculus.org git repositories - divverent/nexuiz.git/blob - data/qcsrc/server/w_shotgun.qc
Qantourisc's improved havocbots AI - have fun!
[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                 if(vlen(self.origin-self.enemy.origin)>200)
68                         self.button0 = bot_aim(1000000, 0, 0.001, FALSE);
69                 else
70                         self.button3 = bot_aim(1000000, 0, 0.001, FALSE);
71         else if (req == WR_THINK)
72         {
73                 if (self.button0)
74                 if (weapon_prepareattack(0, cvar("g_balance_shotgun_primary_refire")))
75                 {
76                         W_Shotgun_Attack();
77                         weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_shotgun_primary_animtime"), w_ready);
78                 }
79                 if (self.button3)
80                 if (weapon_prepareattack(1, cvar("g_balance_shotgun_secondary_refire")))
81                 {
82                         W_Shotgun_Attack2();
83                         weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_shotgun_secondary_animtime"), shotgun_fire2_02);
84                 }
85         }
86         else if (req == WR_SETUP)
87                 weapon_setup(WEP_SHOTGUN, "shotgun", IT_SHELLS);
88         else if (req == WR_CHECKAMMO1)
89                 return self.ammo_shells >= cvar("g_balance_shotgun_primary_ammo");
90         else if (req == WR_CHECKAMMO2)
91                 return self.ammo_shells >= cvar("g_balance_shotgun_secondary_ammo") * 3;
92         return TRUE;
93 };