change all function declarations (except builtins and data types) to ANSI C-like...
[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   f;
8         float   spread;
9         local entity flash;
10
11         bullets = cvar("g_balance_shotgun_primary_bullets");
12         d = cvar("g_balance_shotgun_primary_damage");
13         f = cvar("g_balance_shotgun_primary_force");
14         spread = cvar("g_balance_shotgun_primary_spread");
15
16         W_SetupShot (self, '25 8 -8', TRUE, 5, "weapons/shotgun_fire.wav");
17         for (sc = 0;sc < bullets;sc = sc + 1)
18                 fireBullet (w_shotorg, w_shotdir, spread, d, f, IT_SHOTGUN, sc < 3);
19         if (cvar("g_use_ammunition"))
20                 self.ammo_shells = self.ammo_shells - cvar("g_balance_shotgun_primary_ammo");
21
22         pointparticles(particleeffectnum("shotgun_muzzleflash"), w_shotorg, w_shotdir * 1000, cvar("g_balance_shotgun_primary_ammo"));
23
24         // casing code
25         if (cvar("g_casings") >= 1)
26                 SpawnCasing (w_shotorg, ((random () * 50 + 50) * v_right) - (v_forward * (random () * 25 + 25)) - ((random () * 5 - 30) * v_up), 2, vectoangles(v_forward),'0 250 0', 100, 1);
27
28         // muzzle flash for 1st person view
29         flash = spawn();
30         setorigin(flash, '53 5 0');
31         setmodel(flash, "models/uziflash.md3"); // precision set below
32         setattachment(flash, self.weaponentity, "bone01");
33         flash.owner = self;
34         flash.viewmodelforclient = self;
35         flash.customizeentityforclient = CL_Weaponentity_CustomizeEntityForClient;
36         flash.scale = 1.2;
37         flash.think = SUB_Remove;
38         flash.nextthink = time + 0.06;
39         flash.angles_z = flash.v_angle_z + random() * 180;
40         flash.alpha = 1;
41         flash.effects = EF_ADDITIVE | EF_FULLBRIGHT | EF_LOWPRECISION;
42
43 }
44
45 void W_Shotgun_Attack2 (void)
46 {
47         float   sc;
48         float   bullets;
49         float   d;
50         float   f;
51         float   spread;
52         local entity flash;
53
54         bullets = cvar("g_balance_shotgun_secondary_bullets");
55         d = cvar("g_balance_shotgun_secondary_damage");
56         f = cvar("g_balance_shotgun_secondary_force");
57         spread = cvar("g_balance_shotgun_secondary_spread");
58
59         W_SetupShot (self, '25 8 -8', TRUE, 5, "weapons/shotgun_fire.wav");
60         for (sc = 0;sc < bullets;sc = sc + 1)
61                 fireBullet (w_shotorg, w_shotdir, spread, d, f, IT_SHOTGUN, sc < 3);
62         if (cvar("g_use_ammunition"))
63                 self.ammo_shells = self.ammo_shells - cvar("g_balance_shotgun_secondary_ammo");
64
65         pointparticles(particleeffectnum("shotgun_muzzleflash"), w_shotorg, w_shotdir * 1000, cvar("g_balance_shotgun_secondary_ammo"));
66
67         // casing code
68         if (cvar("g_casings") >= 1)
69                 SpawnCasing (w_shotorg, ((random () * 50 + 50) * v_right) - (v_forward * (random () * 25 + 25)) - ((random () * 5 - 30) * v_up), 2, vectoangles(v_forward),'0 250 0', 100, 1);
70
71         flash = spawn();
72         setorigin(flash, '53 5 0');
73         setmodel(flash, "models/uziflash.md3"); // precision set below
74         setattachment(flash, self.weaponentity, "bone01");
75         flash.owner = self;
76         flash.viewmodelforclient = self;
77         flash.customizeentityforclient = CL_Weaponentity_CustomizeEntityForClient;
78         flash.scale = 1.2;
79         flash.think = SUB_Remove;
80         flash.nextthink = time + 0.06;
81         flash.angles_z = flash.v_angle_z + random() * 180;
82         flash.alpha = 1;
83         flash.effects = EF_ADDITIVE | EF_FULLBRIGHT | EF_LOWPRECISION;
84 }
85
86 // weapon frames
87 void shotgun_fire2_03()
88 {
89         W_Shotgun_Attack2();
90         weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_shotgun_secondary_animtime"), w_ready);
91 }
92 void shotgun_fire2_02()
93 {
94         W_Shotgun_Attack2();
95         weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_shotgun_secondary_animtime"), shotgun_fire2_03);
96 }
97
98 float w_shotgun(float req)
99 {
100         if (req == WR_AIM)
101                 if(vlen(self.origin-self.enemy.origin)>200)
102                         self.BUTTON_ATCK = bot_aim(1000000, 0, 0.001, FALSE);
103                 else
104                         self.BUTTON_ATCK2 = bot_aim(1000000, 0, 0.001, FALSE);
105         else if (req == WR_THINK)
106         {
107                 if (self.BUTTON_ATCK)
108                 if (weapon_prepareattack(0, cvar("g_balance_shotgun_primary_refire")))
109                 {
110                         W_Shotgun_Attack();
111                         weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_shotgun_primary_animtime"), w_ready);
112                 }
113                 if (self.BUTTON_ATCK2)
114                 if (weapon_prepareattack(1, cvar("g_balance_shotgun_secondary_refire")))
115                 {
116                         W_Shotgun_Attack2();
117                         weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_shotgun_secondary_animtime"), shotgun_fire2_02);
118                 }
119         }
120         else if (req == WR_PRECACHE)
121         {
122                 precache_model ("models/uziflash.md3");
123                 precache_model ("models/tracer.mdl");
124                 precache_model ("models/weapons/g_shotgun.md3");
125                 precache_model ("models/weapons/v_shotgun.md3");
126                 precache_model ("models/weapons/w_shotgun.zym");
127                 precache_sound ("misc/itempickup.wav");
128                 precache_sound ("weapons/ric1.wav");
129                 precache_sound ("weapons/ric2.wav");
130                 precache_sound ("weapons/ric3.wav");
131                 precache_sound ("weapons/shotgun_fire.wav");
132                 precache_sound ("weapons/tink1.wav");
133                 if (cvar("g_casings") >= 1)
134                         precache_model ("models/casing_shell.mdl");
135         }
136         else if (req == WR_SETUP)
137                 weapon_setup(WEP_SHOTGUN, "shotgun", IT_SHELLS);
138         else if (req == WR_CHECKAMMO1)
139                 return self.ammo_shells >= cvar("g_balance_shotgun_primary_ammo");
140         else if (req == WR_CHECKAMMO2)
141                 return self.ammo_shells >= cvar("g_balance_shotgun_secondary_ammo") * 3;
142         else if (req == WR_REGISTER)
143                 weapon_register(WEP_SHOTGUN, min(cvar("g_balance_shotgun_primary_ammo"), cvar("g_balance_shotgun_secondary_ammo")));
144         return TRUE;
145 };