]> icculus.org git repositories - divverent/nexuiz.git/blob - data/qcsrc/server/gamec/w_shotgun.c
add g_navnodeedit
[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 >= 1)
10                 return TRUE;
11         return FALSE;
12 };
13
14 void(float req) w_shotgun =
15 {
16         if (req == WR_IDLE)
17                 shotgun_ready_01();
18         else if (req == WR_FIRE1)
19                 weapon_prepareattack(shotgun_check, shotgun_check, shotgun_fire1_01, cvar("g_balance_shotgun_refire"));
20         else if (req == WR_FIRE2)
21                 weapon_prepareattack(shotgun_check, shotgun_check, shotgun_fire2_01, cvar("g_balance_shotgun_refire2"));
22         else if (req == WR_RAISE)
23                 shotgun_select_01();
24         else if (req == WR_UPDATECOUNTS)
25                 self.currentammo = self.ammo_shells;
26         else if (req == WR_DROP)
27                 shotgun_deselect_01();
28         else if (req == WR_SETUP)
29                 weapon_setup(WEP_SHOTGUN, "w_shotgun.zym", IT_SHELLS);
30         else if (req == WR_CHECKAMMO)
31                 weapon_hasammo = shotgun_check();
32 };
33
34 void W_Shotgun_Attack (void)
35 {
36         local vector org;
37         float   sc;
38         float   bullets;
39         float   d;
40         float   spread;
41         
42         local vector trueaim;
43         trueaim = W_TrueAim();
44
45         sound (self, CHAN_WEAPON, "weapons/shotgun_fire.ogg", 1, ATTN_NORM);
46         if (self.items & IT_STRENGTH) {
47                 sound (self, CHAN_AUTO, "weapons/strength_fire.ogg", 1, ATTN_NORM);
48         }
49         
50         bullets = cvar("g_balance_shotgun_bullets");
51         if (self.button3)
52                 d = cvar("g_balance_shotgun_damage2");
53         else
54                 d = cvar("g_balance_shotgun_damage");
55
56         org = self.origin + self.view_ofs + (v_right * 6) - (v_up * 8) + (v_forward * 5);
57         spread = cvar("g_balance_shotgun_spread");
58         for (sc = 0;sc < bullets;sc = sc + 1)
59                 fireBullet (org, normalize(trueaim - org), spread, d, IT_SHOTGUN, sc < 3);
60         if (cvar("g_use_ammunition"))
61                 self.ammo_shells = self.ammo_shells - 1;
62
63         // casing code
64         if (cvar("g_casings") >= 1)
65         {
66                 org = self.origin + self.view_ofs + (v_right * 6) - (v_up * 8) + (v_forward * 10);
67                 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);
68         }
69
70         org = self.origin + self.view_ofs + (v_right * 6) - (v_up * 8) + (v_forward * 20);
71         W_Smoke(org, v_forward, 12);
72         //te_smallflash(org);
73
74         self.punchangle_x = -5;
75 }
76
77 // weapon frames
78
79 void()  shotgun_ready_01 =      {weapon_thinkf(WFRAME_IDLE, 0.1, shotgun_ready_01); self.weaponentity.state = WS_READY;};
80 void()  shotgun_select_01 =     {weapon_thinkf(-1, cvar("g_balance_weaponswitchdelay"), w_ready); weapon_boblayer1(PLAYER_WEAPONSELECTION_SPEED, '0 0 0');};
81 void()  shotgun_deselect_01 =   {weapon_thinkf(-1, cvar("g_balance_weaponswitchdelay"), w_clear); weapon_boblayer1(PLAYER_WEAPONSELECTION_SPEED, PLAYER_WEAPONSELECTION_RANGE);};
82 void()  shotgun_fire1_01 =
83 {
84         weapon_doattack(shotgun_check, shotgun_check, W_Shotgun_Attack);
85         weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_shotgun_refire3"), shotgun_ready_01);
86 };
87 void()  shotgun_fire2_03 =
88 {
89         weapon_doattack(shotgun_check, shotgun_check, W_Shotgun_Attack);
90         weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_shotgun_refire3"), shotgun_ready_01);
91 }
92 void()  shotgun_fire2_02 =
93 {
94         weapon_doattack(shotgun_check, shotgun_check, W_Shotgun_Attack);
95         weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_shotgun_refire3"), shotgun_fire2_03);
96 }
97 void()  shotgun_fire2_01 =
98 {
99         weapon_doattack(shotgun_check, shotgun_check, W_Shotgun_Attack);
100         weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_shotgun_refire3"), shotgun_fire2_02);
101 }