]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/server/w_electro.qc
Fix issues with electro beam
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / w_electro.qc
1 #ifdef REGISTER_WEAPON
2 REGISTER_WEAPON(ELECTRO, w_electro, IT_CELLS, 5, WEP_FLAG_NORMAL | WEP_TYPE_SPLASH, BOT_PICKUP_RATING_MID, "electro", "electro", _("Electro"));
3 #else
4 #ifdef SVQC
5 .float electro_count;
6 .float electro_secondarytime;
7
8 .float electro_load;
9
10 void W_Electro_SetAmmoCounter()
11 {
12         // set clip_load to the weapon we have switched to, if the gun uses reloading
13         if(!autocvar_g_balance_electro_reload_ammo)
14                 self.clip_load = 0; // also keeps crosshair ammo from displaying
15         else
16         {
17                 self.clip_load = self.electro_load;
18                 self.clip_size = autocvar_g_balance_electro_reload_ammo; // for the crosshair ammo display
19         }
20 }
21
22 void W_Electro_ReloadedAndReady()
23 {
24         float t;
25
26         // now do the ammo transfer
27         self.clip_load = self.old_clip_load; // restore the ammo counter, in case we still had ammo in the weapon before reloading
28         while(self.clip_load < autocvar_g_balance_electro_reload_ammo && self.ammo_cells) // make sure we don't add more ammo than we have
29         {
30                 self.clip_load += 1;
31                 self.ammo_cells -= 1;
32         }
33         self.electro_load = self.clip_load;
34
35         t = ATTACK_FINISHED(self) - autocvar_g_balance_electro_reload_time - 1;
36         ATTACK_FINISHED(self) = t;
37         w_ready();
38 }
39
40 void W_Electro_Reload()
41 {
42         // return if reloading is disabled for this weapon
43         if(!autocvar_g_balance_electro_reload_ammo)
44                 return;
45
46         if(!W_ReloadCheck(self.ammo_cells))
47                 return;
48
49         float t;
50
51         sound (self, CHAN_WEAPON2, "weapons/reload.wav", VOL_BASE, ATTN_NORM);
52
53         t = max(time, ATTACK_FINISHED(self)) + autocvar_g_balance_electro_reload_time + 1;
54         ATTACK_FINISHED(self) = t;
55
56         weapon_thinkf(WFRAME_RELOAD, autocvar_g_balance_electro_reload_time, W_Electro_ReloadedAndReady);
57
58         self.old_clip_load = self.clip_load;
59         self.clip_load = -1;
60 }
61
62 void W_Plasma_Explode_Combo (void);
63
64 void W_Plasma_TriggerCombo(vector org, float rad, entity own)
65 {
66         local entity e;
67         e = WarpZone_FindRadius(org, rad, TRUE);
68         while (e)
69         {
70                 if (e.classname == "plasma")
71                 {
72                         // change owner to whoever caused the combo explosion
73                         e.owner = own;
74                         e.takedamage = DAMAGE_NO;
75                         e.classname = "plasma_chain";
76                         e.think = W_Plasma_Explode_Combo;
77                         e.nextthink = time + vlen(e.WarpZone_findradius_dist) / autocvar_g_balance_electro_combo_speed; // delay combo chains, looks cooler
78                 }
79                 e = e.chain;
80         }
81 }
82
83 void W_Plasma_Explode (void)
84 {
85         if(other.takedamage == DAMAGE_AIM)
86                 if(other.classname == "player")
87                         if(IsDifferentTeam(self.owner, other))
88                                 if(other.deadflag == DEAD_NO)
89                                         if(IsFlying(other))
90                                                 AnnounceTo(self.owner, "electrobitch");
91
92         self.event_damage = SUB_Null;
93         self.takedamage = DAMAGE_NO;
94         if (self.movetype == MOVETYPE_BOUNCE)
95         {
96                 RadiusDamage (self, self.owner, autocvar_g_balance_electro_secondary_damage, autocvar_g_balance_electro_secondary_edgedamage, autocvar_g_balance_electro_secondary_radius, world, autocvar_g_balance_electro_secondary_force, self.projectiledeathtype, other);
97         }
98         else
99         {
100                 W_Plasma_TriggerCombo(self.origin, autocvar_g_balance_electro_primary_comboradius, self.owner);
101                 RadiusDamage (self, self.owner, autocvar_g_balance_electro_primary_damage, autocvar_g_balance_electro_primary_edgedamage, autocvar_g_balance_electro_primary_radius, world, autocvar_g_balance_electro_primary_force, self.projectiledeathtype, other);
102         }
103
104         remove (self);
105 }
106
107 void W_Plasma_Explode_Combo (void)
108 {
109         W_Plasma_TriggerCombo(self.origin, autocvar_g_balance_electro_combo_comboradius, self.owner);
110
111         self.event_damage = SUB_Null;
112         RadiusDamage (self, self.owner, autocvar_g_balance_electro_combo_damage, autocvar_g_balance_electro_combo_edgedamage, autocvar_g_balance_electro_combo_radius, world, autocvar_g_balance_electro_combo_force, WEP_ELECTRO | HITTYPE_BOUNCE, world); // use THIS type for a combo because primary can't bounce
113         remove (self);
114 }
115
116 void W_Plasma_Touch (void)
117 {
118         //self.velocity = self.velocity  * 0.1;
119
120         PROJECTILE_TOUCH;
121         if (other.takedamage == DAMAGE_AIM) {
122                 W_Plasma_Explode ();
123         } else {
124                 //UpdateCSQCProjectile(self);
125                 spamsound (self, CHAN_PROJECTILE, "weapons/electro_bounce.wav", VOL_BASE, ATTN_NORM);
126                 self.projectiledeathtype |= HITTYPE_BOUNCE;
127         }
128 }
129
130 void W_Plasma_TouchExplode (void)
131 {
132         PROJECTILE_TOUCH;
133         W_Plasma_Explode ();
134 }
135
136 void W_Plasma_Damage (entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
137 {
138         if(self.health <= 0)
139                 return;
140         // note: combos are usually triggered by W_Plasma_TriggerCombo, not damage
141         self.health = self.health - damage;
142         if (self.health <= 0)
143         {
144                 self.takedamage = DAMAGE_NO;
145                 self.nextthink = time;
146                 if (inflictor.classname == "plasma_chain" || inflictor.classname == "plasma_prim")
147                 {
148                         // change owner to whoever caused the combo explosion
149                         self.owner = inflictor.owner;
150                         self.classname = "plasma_chain";
151                         self.think = W_Plasma_Explode_Combo;
152                         self.nextthink = time + min(autocvar_g_balance_electro_combo_radius, vlen(self.origin - inflictor.origin)) / autocvar_g_balance_electro_combo_speed; // delay combo chains, looks cooler
153                                 //                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ bounding the length, because inflictor may be in a galaxy far far away (warpzones)
154                 }
155                 else
156                 {
157                         self.use = W_Plasma_Explode;
158                         self.think = adaptor_think2use; // not _hittype_splash, as this runs "immediately"
159                 }
160         }
161 }
162
163 void W_Electro_Attack()
164 {
165         local entity proj;
166
167         W_SetupShot_ProjectileSize (self, '0 0 -3', '0 0 -3', FALSE, 2, "weapons/electro_fire.wav", CHAN_WEAPON, autocvar_g_balance_electro_primary_damage);
168
169         pointparticles(particleeffectnum("electro_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
170
171         proj = spawn ();
172         proj.classname = "plasma_prim";
173         proj.owner = self;
174         proj.bot_dodge = TRUE;
175         proj.bot_dodgerating = autocvar_g_balance_electro_primary_damage;
176         proj.use = W_Plasma_Explode;
177         proj.think = adaptor_think2use_hittype_splash;
178         proj.nextthink = time + autocvar_g_balance_electro_primary_lifetime;
179         PROJECTILE_MAKETRIGGER(proj);
180         proj.projectiledeathtype = WEP_ELECTRO;
181         setorigin(proj, w_shotorg);
182
183         proj.movetype = MOVETYPE_FLY;
184         W_SETUPPROJECTILEVELOCITY(proj, g_balance_electro_primary);
185         proj.angles = vectoangles(proj.velocity);
186         proj.touch = W_Plasma_TouchExplode;
187         setsize(proj, '0 0 -3', '0 0 -3');
188         proj.flags = FL_PROJECTILE;
189
190         //sound (proj, CHAN_PAIN, "weapons/electro_fly.wav", VOL_BASE, ATTN_NORM);
191         //sounds bad
192
193         CSQCProjectile(proj, TRUE, PROJECTILE_ELECTRO_BEAM, TRUE);
194
195         other = proj; MUTATOR_CALLHOOK(EditProjectile);
196
197         // if this weapon is reloadable, decrease its load. Else decrease the player's ammo
198         if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
199         {
200                 if(autocvar_g_balance_electro_reload_ammo)
201                 {
202                         self.clip_load -= autocvar_g_balance_electro_primary_ammo;
203                         self.electro_load = self.clip_load;
204                 }
205                 else
206                         self.ammo_cells -= autocvar_g_balance_electro_primary_ammo;
207         }
208 }
209
210 void W_Electro_Attack2()
211 {
212         local entity proj;
213
214         W_SetupShot_ProjectileSize (self, '0 0 -4', '0 0 -4', FALSE, 2, "weapons/electro_fire2.wav", CHAN_WEAPON, autocvar_g_balance_electro_secondary_damage);
215
216         w_shotdir = v_forward; // no TrueAim for grenades please
217
218         pointparticles(particleeffectnum("electro_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
219
220         proj = spawn ();
221         proj.classname = "plasma";
222         proj.owner = self;
223         proj.use = W_Plasma_Explode;
224         proj.think = adaptor_think2use_hittype_splash;
225         proj.bot_dodge = TRUE;
226         proj.bot_dodgerating = autocvar_g_balance_electro_secondary_damage;
227         proj.nextthink = time + autocvar_g_balance_electro_secondary_lifetime;
228         PROJECTILE_MAKETRIGGER(proj);
229         proj.projectiledeathtype = WEP_ELECTRO | HITTYPE_SECONDARY;
230         setorigin(proj, w_shotorg);
231
232         //proj.glow_size = 50;
233         //proj.glow_color = 45;
234         proj.movetype = MOVETYPE_BOUNCE;
235         W_SETUPPROJECTILEVELOCITY_UP(proj, g_balance_electro_secondary);
236         proj.touch = W_Plasma_Touch;
237         setsize(proj, '0 0 -4', '0 0 -4');
238         proj.takedamage = DAMAGE_YES;
239         proj.damageforcescale = autocvar_g_balance_electro_secondary_damageforcescale;
240         proj.health = autocvar_g_balance_electro_secondary_health;
241         proj.event_damage = W_Plasma_Damage;
242         proj.flags = FL_PROJECTILE;
243
244         proj.bouncefactor = autocvar_g_balance_electro_secondary_bouncefactor;
245         proj.bouncestop = autocvar_g_balance_electro_secondary_bouncestop;
246
247 #if 0
248         entity p2;
249         p2 = spawn();
250         copyentity(proj, p2);
251         setmodel(p2, "models/ebomb.mdl");
252         setsize(p2, proj.mins, proj.maxs);
253 #endif
254
255         CSQCProjectile(proj, TRUE, PROJECTILE_ELECTRO, FALSE); // no culling, it has sound
256
257         other = proj; MUTATOR_CALLHOOK(EditProjectile);
258
259         // if this weapon is reloadable, decrease its load. Else decrease the player's ammo
260         if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
261         {
262                 if(autocvar_g_balance_electro_reload_ammo)
263                 {
264                         self.clip_load -= autocvar_g_balance_electro_secondary_ammo;
265                         self.electro_load = self.clip_load;
266                 }
267                 else
268                         self.ammo_cells -= autocvar_g_balance_electro_secondary_ammo;
269         }
270 }
271
272 .vector hook_start, hook_end;
273 float lgbeam_send(entity to, float sf)
274 {
275         WriteByte(MSG_ENTITY, ENT_CLIENT_LGBEAM);
276         sf = sf & 0x7F;
277         if(sound_allowed(MSG_BROADCAST, self.owner))
278                 sf |= 0x80;
279         WriteByte(MSG_ENTITY, sf);
280         if(sf & 1)
281         {
282                 WriteByte(MSG_ENTITY, num_for_edict(self.owner));
283                 WriteCoord(MSG_ENTITY, autocvar_g_balance_electro_primary_range);
284         }
285         if(sf & 2)
286         {
287                 WriteCoord(MSG_ENTITY, self.hook_start_x);
288                 WriteCoord(MSG_ENTITY, self.hook_start_y);
289                 WriteCoord(MSG_ENTITY, self.hook_start_z);
290         }
291         if(sf & 4)
292         {
293                 WriteCoord(MSG_ENTITY, self.hook_end_x);
294                 WriteCoord(MSG_ENTITY, self.hook_end_y);
295                 WriteCoord(MSG_ENTITY, self.hook_end_z);
296         }
297         return TRUE;
298 }
299 .entity lgbeam;
300 .float prevlgfire;
301 float lgbeam_checkammo()
302 {
303         if(self.owner.items & IT_UNLIMITED_WEAPON_AMMO)
304                 return TRUE;
305         else if(autocvar_g_balance_electro_reload_ammo)
306                 return self.owner.clip_load > 0;
307         else
308                 return self.owner.ammo_cells > 0;
309 }
310
311 void lgbeam_think()
312 {
313         self.owner.prevlgfire = time;
314         if (self != self.owner.lgbeam)
315         {
316                 remove(self);
317                 return;
318         }
319         if(autocvar_g_balance_electro_reload_ammo)
320
321         if (self.owner.weaponentity.state != WS_INUSE || !lgbeam_checkammo() || self.owner.deadflag != DEAD_NO || !self.owner.BUTTON_ATCK || self.owner.freezetag_frozen)
322         {
323                 if(self == self.owner.lgbeam)
324                         self.owner.lgbeam = world;
325                 remove(self);
326                 return;
327         }
328
329         self.nextthink = time;
330
331         makevectors(self.owner.v_angle);
332
333         float dt, f;
334         dt = frametime;
335         if not(self.owner.items & IT_UNLIMITED_WEAPON_AMMO)
336         {
337                 // if this weapon is reloadable, decrease its load. Else decrease the player's ammo
338                 if(autocvar_g_balance_electro_primary_ammo)
339                 {
340                         if(autocvar_g_balance_electro_reload_ammo)
341                         {
342                                 dt = min(dt, self.owner.clip_load / autocvar_g_balance_electro_primary_ammo);
343                                 self.owner.clip_load = max(0, self.owner.clip_load - autocvar_g_balance_electro_primary_ammo * frametime);
344                                 self.owner.electro_load = self.owner.clip_load;
345                         }
346                         else
347                         {
348                                 dt = min(dt, self.owner.ammo_cells / autocvar_g_balance_electro_primary_ammo);
349                                 self.owner.ammo_cells = max(0, self.owner.ammo_cells - autocvar_g_balance_electro_primary_ammo * frametime);
350                         }
351                 }
352         }
353
354         W_SetupShot_Range(self.owner, TRUE, 0, "", 0, autocvar_g_balance_electro_primary_damage * dt, autocvar_g_balance_electro_primary_range);
355         WarpZone_traceline_antilag(self.owner, w_shotorg, w_shotend, MOVE_NORMAL, self.owner, ANTILAG_LATENCY(self.owner));
356
357         // apply the damage
358         if(trace_ent)
359         {
360                 vector force;
361                 force = w_shotdir * autocvar_g_balance_electro_primary_force + '0 0 1' * autocvar_g_balance_electro_primary_force_up;
362
363                 f = ExponentialFalloff(autocvar_g_balance_electro_primary_falloff_mindist, autocvar_g_balance_electro_primary_falloff_maxdist, autocvar_g_balance_electro_primary_falloff_halflifedist, vlen(WarpZone_UnTransformOrigin(WarpZone_trace_transform, trace_endpos) - w_shotorg));
364
365                 if(accuracy_isgooddamage(self.owner, trace_ent))
366                         accuracy_add(self.owner, WEP_ELECTRO, 0, autocvar_g_balance_electro_primary_damage * dt * f);
367                 Damage (trace_ent, self.owner, self.owner, autocvar_g_balance_electro_primary_damage * dt * f, WEP_ELECTRO, trace_endpos, force * dt);
368         }
369         W_Plasma_TriggerCombo(trace_endpos, autocvar_g_balance_electro_primary_comboradius, self.owner);
370
371         // draw effect
372         if(w_shotorg != self.hook_start)
373         {
374                 self.SendFlags |= 2;
375                 self.hook_start = w_shotorg;
376         }
377         if(w_shotend != self.hook_end)
378         {
379                 self.SendFlags |= 4;
380                 self.hook_end = w_shotend;
381         }
382 }
383
384 // experimental lightning gun
385 void W_Electro_Attack3 (void)
386 {
387         // only play fire sound if 0.5 sec has passed since player let go the fire button
388         if(time - self.prevlgfire > 0.5)
389                 sound (self, CHAN_WEAPON, "weapons/lgbeam_fire.wav", VOL_BASE, ATTN_NORM);
390
391         entity beam, oldself;
392
393         self.lgbeam = beam = spawn();
394         beam.classname = "lgbeam";
395         beam.solid = SOLID_NOT;
396         beam.think = lgbeam_think;
397         beam.owner = self;
398         beam.movetype = MOVETYPE_NONE;
399         beam.shot_spread = 0;
400         beam.bot_dodge = TRUE;
401         beam.bot_dodgerating = autocvar_g_balance_electro_primary_damage;
402         Net_LinkEntity(beam, FALSE, 0, lgbeam_send);
403
404         oldself = self;
405         self = beam;
406         self.think();
407         self = oldself;
408 }
409
410 void ElectroInit()
411 {
412         weapon_action(WEP_ELECTRO, WR_PRECACHE);
413         electro_shotorigin[0] = shotorg_adjust_values(CL_Weapon_GetShotOrg(WEP_ELECTRO), FALSE, FALSE, 1);
414         electro_shotorigin[1] = shotorg_adjust_values(CL_Weapon_GetShotOrg(WEP_ELECTRO), FALSE, FALSE, 2);
415         electro_shotorigin[2] = shotorg_adjust_values(CL_Weapon_GetShotOrg(WEP_ELECTRO), FALSE, FALSE, 3);
416         electro_shotorigin[3] = shotorg_adjust_values(CL_Weapon_GetShotOrg(WEP_ELECTRO), FALSE, FALSE, 4);
417 }
418
419 void spawnfunc_weapon_electro (void)
420 {
421         weapon_defaultspawnfunc(WEP_ELECTRO);
422 }
423
424 void w_electro_checkattack()
425 {
426         if(self.electro_count > 1)
427         if(self.BUTTON_ATCK2)
428         if(weapon_prepareattack(1, -1))
429         {
430                 W_Electro_Attack2();
431                 self.electro_count -= 1;
432                 weapon_thinkf(WFRAME_FIRE2, autocvar_g_balance_electro_secondary_animtime, w_electro_checkattack);
433                 return;
434         }
435
436         w_ready();
437 }
438
439 .float bot_secondary_electromooth;
440 .float BUTTON_ATCK_prev;
441 float w_electro(float req)
442 {
443         if (req == WR_AIM)
444         {
445                 self.BUTTON_ATCK=FALSE;
446                 self.BUTTON_ATCK2=FALSE;
447                 if(vlen(self.origin-self.enemy.origin) > 1000)
448                         self.bot_secondary_electromooth = 0;
449                 if(self.bot_secondary_electromooth == 0)
450                 {
451                         float shoot;
452
453                         if(autocvar_g_balance_electro_primary_speed)
454                                 shoot = bot_aim(autocvar_g_balance_electro_primary_speed, 0, autocvar_g_balance_electro_primary_lifetime, FALSE);
455                         else
456                                 shoot = bot_aim(1000000, 0, 0.001, FALSE);
457
458                         if(shoot)
459                         {
460                                 self.BUTTON_ATCK = TRUE;
461                                 if(random() < 0.01) self.bot_secondary_electromooth = 1;
462                         }
463                 }
464                 else
465                 {
466                         if(bot_aim(autocvar_g_balance_electro_secondary_speed, autocvar_g_balance_grenadelauncher_secondary_speed_up, autocvar_g_balance_electro_secondary_lifetime, TRUE))
467                         {
468                                 self.BUTTON_ATCK2 = TRUE;
469                                 if(random() < 0.03) self.bot_secondary_electromooth = 0;
470                         }
471                 }
472         }
473         else if (req == WR_THINK)
474         {
475                 if(autocvar_g_balance_electro_reload_ammo && self.clip_load < min(autocvar_g_balance_electro_primary_ammo, autocvar_g_balance_electro_secondary_ammo)) // forced reload
476                         W_Electro_Reload();
477                 else if (self.BUTTON_ATCK)
478                 {
479                         if(autocvar_g_balance_electro_lightning)
480                                 if(self.BUTTON_ATCK_prev)
481                                 {
482                                         // prolong the animtime while the gun is being fired
483                                         if(self.animstate_startframe == self.anim_shoot_x && self.animstate_numframes == self.anim_shoot_y)
484                                                 weapon_thinkf(WFRAME_DONTCHANGE, autocvar_g_balance_electro_primary_animtime, w_ready);
485                                         else
486                                                 weapon_thinkf(WFRAME_FIRE1, autocvar_g_balance_electro_primary_animtime, w_ready);
487                                 }
488                         if (weapon_prepareattack(0, (autocvar_g_balance_electro_lightning ? 0 : autocvar_g_balance_electro_primary_refire)))
489                         {
490                                 if(autocvar_g_balance_electro_lightning)
491                                 {
492                                         if ((!self.lgbeam) || wasfreed(self.lgbeam))
493                                         {
494                                                 W_Electro_Attack3();
495                                         }
496                                         if(!self.BUTTON_ATCK_prev)
497                                         {
498                                                 weapon_thinkf(WFRAME_FIRE1, autocvar_g_balance_electro_primary_animtime, w_ready);
499                                                 self.BUTTON_ATCK_prev = 1;
500                                         }
501                                 }
502                                 else
503                                 {
504                                         W_Electro_Attack();
505                                         weapon_thinkf(WFRAME_FIRE1, autocvar_g_balance_electro_primary_animtime, w_ready);
506                                 }
507                         }
508                 } else {
509                         if(autocvar_g_balance_electro_lightning)
510                         {
511                                 if (self.BUTTON_ATCK_prev != 0)
512                                 {
513                                         weapon_thinkf(WFRAME_FIRE1, autocvar_g_balance_electro_primary_animtime, w_ready);
514                                         ATTACK_FINISHED(self) = time + autocvar_g_balance_electro_primary_refire * W_WeaponRateFactor();
515                                 }
516                                 self.BUTTON_ATCK_prev = 0;
517                         }
518
519                         if (self.BUTTON_ATCK2)
520                         {
521                                 if (time >= self.electro_secondarytime)
522                                 if (weapon_prepareattack(1, autocvar_g_balance_electro_secondary_refire))
523                                 {
524                                         W_Electro_Attack2();
525                                         self.electro_count = autocvar_g_balance_electro_secondary_count;
526                                         weapon_thinkf(WFRAME_FIRE2, autocvar_g_balance_electro_secondary_animtime, w_electro_checkattack);
527                                         self.electro_secondarytime = time + autocvar_g_balance_electro_secondary_refire2 * W_WeaponRateFactor();
528                                 }
529                         }
530                 }
531
532         if(self.wish_reload)
533         {
534             if(self.switchweapon == self.weapon)
535             {
536                 if(self.weaponentity.state == WS_READY)
537                 {
538                     self.wish_reload = 0;
539                     W_Electro_Reload();
540                 }
541             }
542         }
543         }
544         else if (req == WR_PRECACHE)
545         {
546                 precache_model ("models/weapons/g_electro.md3");
547                 precache_model ("models/weapons/v_electro.md3");
548                 precache_model ("models/weapons/h_electro.iqm");
549                 precache_sound ("weapons/electro_bounce.wav");
550                 precache_sound ("weapons/electro_fire.wav");
551                 precache_sound ("weapons/electro_fire2.wav");
552                 precache_sound ("weapons/electro_impact.wav");
553                 precache_sound ("weapons/electro_impact_combo.wav");
554                 if(autocvar_g_balance_electro_lightning)
555                 {
556                         precache_sound ("weapons/lgbeam_fire.wav");
557                 }
558         }
559         else if (req == WR_SETUP)
560         {
561                 weapon_setup(WEP_ELECTRO);
562                 W_Electro_SetAmmoCounter();
563         }
564         else if (req == WR_CHECKAMMO1)
565         {
566                 if(autocvar_g_balance_electro_reload_ammo)
567                 {
568                         if(autocvar_g_balance_electro_lightning)
569                                 return !autocvar_g_balance_electro_primary_ammo || (self.electro_load > 0);
570                         else
571                                 return self.electro_load >= autocvar_g_balance_electro_primary_ammo;
572                 }
573                 else
574                 {
575                         if(autocvar_g_balance_electro_lightning)
576                                 return !autocvar_g_balance_electro_primary_ammo || (self.ammo_cells > 0);
577                         else
578                                 return self.ammo_cells >= autocvar_g_balance_electro_primary_ammo;
579                 }
580         }
581         else if (req == WR_CHECKAMMO2)
582         {
583                 if(autocvar_g_balance_electro_reload_ammo)
584                         return self.electro_load >= autocvar_g_balance_electro_secondary_ammo;
585                 else
586                         return self.ammo_cells >= autocvar_g_balance_electro_secondary_ammo;
587         }
588         else if (req == WR_RESETPLAYER)
589         {
590                 self.electro_secondarytime = time;
591         }
592         else if (req == WR_RELOAD)
593         {
594                 W_Shotgun_Reload();
595         }
596         return TRUE;
597 };
598 #endif
599 #ifdef CSQC
600 float w_electro(float req)
601 {
602         if(req == WR_IMPACTEFFECT)
603         {
604                 vector org2;
605                 org2 = w_org + w_backoff * 6;
606                 if(w_deathtype & HITTYPE_SECONDARY)
607                 {
608                         pointparticles(particleeffectnum("electro_ballexplode"), org2, '0 0 0', 1);
609                         if(!w_issilent)
610                                 sound(self, CHAN_PROJECTILE, "weapons/electro_impact.wav", VOL_BASE, ATTN_NORM);
611                 }
612                 else
613                 {
614                         if(w_deathtype & HITTYPE_BOUNCE)
615                         {
616                                 // this is sent as "primary (w_deathtype & HITTYPE_BOUNCE)" to distinguish it from (w_deathtype & HITTYPE_SECONDARY) bounced balls
617                                 pointparticles(particleeffectnum("electro_combo"), org2, '0 0 0', 1);
618                                 if(!w_issilent)
619                                         sound(self, CHAN_PROJECTILE, "weapons/electro_impact_combo.wav", VOL_BASE, ATTN_NORM);
620                         }
621                         else
622                         {
623                                 pointparticles(particleeffectnum("electro_impact"), org2, '0 0 0', 1);
624                                 if(!w_issilent)
625                                         sound(self, CHAN_PROJECTILE, "weapons/electro_impact.wav", VOL_BASE, ATTN_NORM);
626                         }
627                 }
628         }
629         else if(req == WR_PRECACHE)
630         {
631                 precache_sound("weapons/electro_impact.wav");
632                 precache_sound("weapons/electro_impact_combo.wav");
633         }
634         else if (req == WR_SUICIDEMESSAGE)
635         {
636                 if(w_deathtype & HITTYPE_SECONDARY)
637                         w_deathtypestring = "%s could not remember where they put plasma";
638                 else
639                         w_deathtypestring = "%s played with plasma";
640         }
641         else if (req == WR_KILLMESSAGE)
642         {
643                 if(w_deathtype & HITTYPE_SECONDARY)
644                 {
645                         if(w_deathtype & HITTYPE_SPLASH) // unchecked: BOUNCE
646                                 w_deathtypestring = "%s just noticed %s's blue ball";
647                         else // unchecked: BOUNCE
648                                 w_deathtypestring = "%s got in touch with %s's blue ball";
649                 }
650                 else
651                 {
652                         if(w_deathtype & HITTYPE_BOUNCE) // combo
653                                 w_deathtypestring = "%s felt the electrifying air of %s's combo";
654                         else if(w_deathtype & HITTYPE_SPLASH)
655                                 w_deathtypestring = "%s got too close to %s's blue beam";
656                         else
657                                 w_deathtypestring = "%s was blasted by %s's blue beam";
658                 }
659         }
660         return TRUE;
661 }
662 #endif
663 #endif