add a missing cvar
[divverent/nexuiz.git] / data / qcsrc / server / w_hlac.qc
1 .float HLAC_bulletcounter;
2 void W_HLAC_Touch (void)
3 {
4         PROJECTILE_TOUCH;
5
6         self.event_damage = SUB_Null;
7
8     RadiusDamage (self, self.owner, cvar("g_balance_hlac_primary_damage"), cvar("g_balance_hlac_primary_edgedamage"), cvar("g_balance_hlac_primary_radius"), world, cvar("g_balance_hlac_primary_force"), self.projectiledeathtype, other);
9
10         remove (self);
11 }
12
13 void W_HLAC_Touch2 (void)
14 {
15         PROJECTILE_TOUCH;
16
17         self.event_damage = SUB_Null;
18
19     RadiusDamage (self, self.owner, cvar("g_balance_hlac_secondary_damage"), cvar("g_balance_hlac_secondary_edgedamage"), cvar("g_balance_hlac_secondary_radius"), world, cvar("g_balance_hlac_secondary_force"), self.projectiledeathtype, other);
20
21         remove (self);
22 }
23
24 void W_HLAC_Attack (void)
25 {
26         local entity missile;
27     float spread;
28
29     if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
30     {
31         self.ammo_cells = self.ammo_cells - cvar("g_balance_hlac_primary_ammo");
32     }
33
34     spread = cvar("g_balance_hlac_primary_spread_min") + (cvar("g_balance_hlac_primary_spread_add") * self.HLAC_bulletcounter);
35     spread = min(spread,cvar("g_balance_hlac_primary_spread_max"));
36     if(self.crouch)
37         spread = spread * cvar("g_balance_hlac_primary_spread_crouchmod");
38
39         W_SetupShot (self, FALSE, 3, "weapons/lasergun_fire.wav", cvar("g_balance_hlac_primary_damage"));
40         pointparticles(particleeffectnum("laser_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
41         if (!g_norecoil)
42         {
43                 self.punchangle_x = random () - 0.5;
44                 self.punchangle_y = random () - 0.5;
45         }
46
47         missile = spawn ();
48         missile.owner = self;
49         missile.classname = "hlacbolt";
50         // missile.dmg = issecondary;
51         missile.bot_dodge = TRUE;
52
53     missile.bot_dodgerating = cvar("g_balance_hlac_primary_damage");
54
55         missile.movetype = MOVETYPE_FLY;
56         PROJECTILE_MAKETRIGGER(missile);
57
58         setorigin (missile, w_shotorg);
59         setsize(missile, '0 0 0', '0 0 0');
60
61         W_SetupProjectileVelocity(missile, cvar("g_balance_hlac_primary_speed"), spread);
62         missile.angles = vectoangles (missile.velocity);
63
64         missile.touch = W_HLAC_Touch;
65         missile.think = SUB_Remove;
66
67     missile.nextthink = time + cvar("g_balance_hlac_primary_lifetime");
68
69         missile.flags = FL_PROJECTILE;
70         missile.projectiledeathtype = WEP_HLAC;
71
72         CSQCProjectile(missile, TRUE, PROJECTILE_HLAC, TRUE);
73 }
74
75 void W_HLAC_Attack2f (void)
76 {
77         local entity missile;
78     float spread;
79
80     spread = cvar("g_balance_hlac_secondary_spread");
81
82
83     if(self.crouch)
84         spread = spread * cvar("g_balance_hlac_secondary_spread_crouchmod");
85
86         W_SetupShot (self, FALSE, 3, "weapons/lasergun_fire.wav", cvar("g_balance_hlac_secondary_damage"));
87         pointparticles(particleeffectnum("laser_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
88
89         missile = spawn ();
90         missile.owner = self;
91         missile.classname = "hlacbolt";
92         // missile.dmg = issecondary;
93         missile.bot_dodge = TRUE;
94
95     missile.bot_dodgerating = cvar("g_balance_hlac_secondary_damage");
96
97         missile.movetype = MOVETYPE_FLY;
98         PROJECTILE_MAKETRIGGER(missile);
99
100         setorigin (missile, w_shotorg);
101         setsize(missile, '0 0 0', '0 0 0');
102
103         W_SetupProjectileVelocity(missile, cvar("g_balance_hlac_secondary_speed"), spread);
104         missile.angles = vectoangles (missile.velocity);
105
106         missile.touch = W_HLAC_Touch2;
107         missile.think = SUB_Remove;
108
109     missile.nextthink = time + cvar("g_balance_hlac_secondary_lifetime");
110
111         missile.flags = FL_PROJECTILE;
112         missile.projectiledeathtype = WEP_HLAC | HITTYPE_SECONDARY;
113
114         CSQCProjectile(missile, TRUE, PROJECTILE_HLAC, TRUE);
115 }
116
117 void W_HLAC_Attack2 (void)
118 {
119     float i;
120
121     if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
122     {
123         self.ammo_cells = self.ammo_cells - cvar("g_balance_hlac_secondary_ammo");
124     }
125
126     for(i=cvar("g_balance_hlac_secondary_shots");i>0;--i)
127         W_HLAC_Attack2f();
128
129         if (!g_norecoil)
130         {
131                 self.punchangle_x = random () - 0.5;
132                 self.punchangle_y = random () - 0.5;
133         }
134 }
135
136
137 // weapon frames
138 void HLAC_fire1_02()
139 {
140         if(self.weapon != self.switchweapon) // abort immediately if switching
141         {
142                 w_ready();
143                 return;
144         }
145
146         if (self.BUTTON_ATCK)
147         {
148                 if (!weapon_action(self.weapon, WR_CHECKAMMO1))
149                 {
150                         W_SwitchWeapon_Force(self, w_getbestweapon(self));
151                         w_ready();
152                         return;
153                 }
154
155                 ATTACK_FINISHED(self) = time + cvar("g_balance_hlac_primary_refire") * W_WeaponRateFactor();
156                 W_HLAC_Attack();
157                 self.HLAC_bulletcounter = self.HLAC_bulletcounter + 1;
158         weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_hlac_primary_refire"), HLAC_fire1_02);
159         }
160         else
161         {
162                 weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_hlac_primary_animtime"), w_ready);
163         }
164 };
165
166 void spawnfunc_weapon_hlac (void)
167 {
168         weapon_defaultspawnfunc(WEP_HLAC);
169 }
170
171 float w_hlac(float req)
172 {
173         if (req == WR_AIM)
174         self.BUTTON_ATCK = bot_aim(cvar("g_balance_hlac_primary_speed"), 0, cvar("g_balance_hlac_primary_lifetime"), FALSE);
175         else if (req == WR_THINK)
176         {
177                 if (self.BUTTON_ATCK)
178                 if (weapon_prepareattack(0, cvar("g_balance_hlac_primary_refire")))
179                 {
180                         self.HLAC_bulletcounter = 0;
181                         W_HLAC_Attack();
182                         weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_hlac_primary_refire"), HLAC_fire1_02);
183                 }
184
185                 if (self.BUTTON_ATCK2)
186                 if (weapon_prepareattack(1, cvar("g_balance_hlac_secondary_refire")))
187                 {
188                         W_HLAC_Attack2();
189                         weapon_thinkf(WFRAME_FIRE2, cvar("g_balance_hlac_secondary_animtime"), w_ready);
190                 }
191
192         }
193         else if (req == WR_PRECACHE)
194         {
195         precache_model ("models/weapons/g_hlac.md3");
196                 precache_model ("models/weapons/v_hlac.md3");
197                 precache_model ("models/weapons/h_hlac.dpm");
198                 precache_sound ("weapons/lasergun_fire.wav");
199
200         }
201         else if (req == WR_SETUP)
202                 weapon_setup(WEP_HLAC);
203         else if (req == WR_CHECKAMMO1)
204                 return self.ammo_cells >= cvar("g_balance_hlac_primary_ammo");
205         else if (req == WR_CHECKAMMO2)
206                 return self.ammo_cells >= cvar("g_balance_hlac_secondary_ammo");
207         else if (req == WR_SUICIDEMESSAGE)
208                 w_deathtypestring = "should have used a smaller gun";
209         else if (req == WR_KILLMESSAGE)
210                 w_deathtypestring = "was cut down by";
211         return TRUE;
212 };