]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/server/w_electro.qc
Remove a useless cvar check. If reloading is disabled, the weapon load is always...
[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 // weapon load persistence, for weapons that support reloading
9 .float electro_load;
10
11 void W_Electro_SetAmmoCounter()
12 {
13         // set clip_load to the weapon we have switched to, if the gun uses reloading
14         if(!autocvar_g_balance_electro_reload_ammo)
15                 self.clip_load = 0; // also keeps crosshair ammo from displaying
16         else
17         {
18                 self.clip_load = self.electro_load;
19                 self.clip_size = autocvar_g_balance_electro_reload_ammo; // for the crosshair ammo display
20         }
21 }
22
23 void W_Electro_ReloadedAndReady()
24 {
25         float t;
26
27         // now do the ammo transfer
28         self.clip_load = self.old_clip_load; // restore the ammo counter, in case we still had ammo in the weapon before reloading
29         while(self.clip_load < autocvar_g_balance_electro_reload_ammo && self.ammo_cells) // make sure we don't add more ammo than we have
30         {
31                 self.clip_load += 1;
32                 self.ammo_cells -= 1;
33         }
34         self.electro_load = self.clip_load;
35
36         t = ATTACK_FINISHED(self) - autocvar_g_balance_electro_reload_time - 1;
37         ATTACK_FINISHED(self) = t;
38         w_ready();
39 }
40
41 void W_Electro_Reload()
42 {
43         // return if reloading is disabled for this weapon
44         if(!autocvar_g_balance_electro_reload_ammo)
45                 return;
46
47         if(!W_ReloadCheck(self.ammo_cells, min(autocvar_g_balance_electro_primary_ammo, autocvar_g_balance_electro_secondary_ammo)))
48                 return;
49
50         float t;
51
52         sound (self, CHAN_WEAPON2, "weapons/reload.wav", VOL_BASE, ATTN_NORM);
53
54         t = max(time, ATTACK_FINISHED(self)) + autocvar_g_balance_electro_reload_time + 1;
55         ATTACK_FINISHED(self) = t;
56
57         weapon_thinkf(WFRAME_RELOAD, autocvar_g_balance_electro_reload_time, W_Electro_ReloadedAndReady);
58
59         self.old_clip_load = self.clip_load;
60         self.clip_load = -1;
61 }
62
63 void W_Plasma_Explode_Combo (void);
64
65 void W_Plasma_TriggerCombo(vector org, float rad, entity own)
66 {
67         local entity e;
68         e = WarpZone_FindRadius(org, rad, TRUE);
69         while (e)
70         {
71                 if (e.classname == "plasma")
72                 {
73                         // change owner to whoever caused the combo explosion
74                         e.owner = own;
75                         e.takedamage = DAMAGE_NO;
76                         e.classname = "plasma_chain";
77                         e.think = W_Plasma_Explode_Combo;
78                         e.nextthink = time + vlen(e.WarpZone_findradius_dist) / autocvar_g_balance_electro_combo_speed; // delay combo chains, looks cooler
79                 }
80                 e = e.chain;
81         }
82 }
83
84 void W_Plasma_Explode (void)
85 {
86         if(other.takedamage == DAMAGE_AIM)
87                 if(other.classname == "player")
88                         if(IsDifferentTeam(self.owner, other))
89                                 if(other.deadflag == DEAD_NO)
90                                         if(IsFlying(other))
91                                                 AnnounceTo(self.owner, "electrobitch");
92
93         self.event_damage = SUB_Null;
94         self.takedamage = DAMAGE_NO;
95         if (self.movetype == MOVETYPE_BOUNCE)
96         {
97                 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);
98         }
99         else
100         {
101                 W_Plasma_TriggerCombo(self.origin, autocvar_g_balance_electro_primary_comboradius, self.owner);
102                 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);
103         }
104
105         remove (self);
106 }
107
108 void W_Plasma_Explode_Combo (void)
109 {
110         W_Plasma_TriggerCombo(self.origin, autocvar_g_balance_electro_combo_comboradius, self.owner);
111
112         self.event_damage = SUB_Null;
113         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
114         remove (self);
115 }
116
117 void W_Plasma_Touch (void)
118 {
119         //self.velocity = self.velocity  * 0.1;
120
121         PROJECTILE_TOUCH;
122         if (other.takedamage == DAMAGE_AIM) {
123                 W_Plasma_Explode ();
124         } else {
125                 //UpdateCSQCProjectile(self);
126                 spamsound (self, CHAN_PROJECTILE, "weapons/electro_bounce.wav", VOL_BASE, ATTN_NORM);
127                 self.projectiledeathtype |= HITTYPE_BOUNCE;
128         }
129 }
130
131 void W_Plasma_TouchExplode (void)
132 {
133         PROJECTILE_TOUCH;
134         W_Plasma_Explode ();
135 }
136
137 void W_Plasma_Damage (entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
138 {
139         if(self.health <= 0)
140                 return;
141         // note: combos are usually triggered by W_Plasma_TriggerCombo, not damage
142         self.health = self.health - damage;
143         if (self.health <= 0)
144         {
145                 self.takedamage = DAMAGE_NO;
146                 self.nextthink = time;
147                 if (inflictor.classname == "plasma_chain" || inflictor.classname == "plasma_prim")
148                 {
149                         // change owner to whoever caused the combo explosion
150                         self.owner = inflictor.owner;
151                         self.classname = "plasma_chain";
152                         self.think = W_Plasma_Explode_Combo;
153                         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
154                                 //                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ bounding the length, because inflictor may be in a galaxy far far away (warpzones)
155                 }
156                 else
157                 {
158                         self.use = W_Plasma_Explode;
159                         self.think = adaptor_think2use; // not _hittype_splash, as this runs "immediately"
160                 }
161         }
162 }
163
164 void W_Electro_Attack()
165 {
166         local entity proj;
167
168         // if this weapon is reloadable, decrease its load. Else decrease the player's ammo
169         if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
170         {
171                 if(autocvar_g_balance_electro_reload_ammo)
172                 {
173                         self.clip_load -= autocvar_g_balance_electro_primary_ammo;
174                         self.electro_load = self.clip_load;
175                 }
176                 else
177                         self.ammo_cells -= autocvar_g_balance_electro_primary_ammo;
178         }
179
180         W_SetupShot_ProjectileSize (self, '0 0 -3', '0 0 -3', FALSE, 2, "weapons/electro_fire.wav", CHAN_WEAPON, autocvar_g_balance_electro_primary_damage);
181
182         pointparticles(particleeffectnum("electro_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
183
184         proj = spawn ();
185         proj.classname = "plasma_prim";
186         proj.owner = self;
187         proj.bot_dodge = TRUE;
188         proj.bot_dodgerating = autocvar_g_balance_electro_primary_damage;
189         proj.use = W_Plasma_Explode;
190         proj.think = adaptor_think2use_hittype_splash;
191         proj.nextthink = time + autocvar_g_balance_electro_primary_lifetime;
192         PROJECTILE_MAKETRIGGER(proj);
193         proj.projectiledeathtype = WEP_ELECTRO;
194         setorigin(proj, w_shotorg);
195
196         proj.movetype = MOVETYPE_FLY;
197         W_SETUPPROJECTILEVELOCITY(proj, g_balance_electro_primary);
198         proj.angles = vectoangles(proj.velocity);
199         proj.touch = W_Plasma_TouchExplode;
200         setsize(proj, '0 0 -3', '0 0 -3');
201         proj.flags = FL_PROJECTILE;
202
203         //sound (proj, CHAN_PAIN, "weapons/electro_fly.wav", VOL_BASE, ATTN_NORM);
204         //sounds bad
205
206         CSQCProjectile(proj, TRUE, PROJECTILE_ELECTRO_BEAM, TRUE);
207
208         other = proj; MUTATOR_CALLHOOK(EditProjectile);
209 }
210
211 void W_Electro_Attack2()
212 {
213         local entity proj;
214
215         // if this weapon is reloadable, decrease its load. Else decrease the player's ammo
216         if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
217         {
218                 if(autocvar_g_balance_electro_reload_ammo)
219                 {
220                         self.clip_load -= autocvar_g_balance_electro_secondary_ammo;
221                         self.electro_load = self.clip_load;
222                 }
223                 else
224                         self.ammo_cells -= autocvar_g_balance_electro_secondary_ammo;
225         }
226
227         W_SetupShot_ProjectileSize (self, '0 0 -4', '0 0 -4', FALSE, 2, "weapons/electro_fire2.wav", CHAN_WEAPON, autocvar_g_balance_electro_secondary_damage);
228
229         w_shotdir = v_forward; // no TrueAim for grenades please
230
231         pointparticles(particleeffectnum("electro_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
232
233         proj = spawn ();
234         proj.classname = "plasma";
235         proj.owner = self;
236         proj.use = W_Plasma_Explode;
237         proj.think = adaptor_think2use_hittype_splash;
238         proj.bot_dodge = TRUE;
239         proj.bot_dodgerating = autocvar_g_balance_electro_secondary_damage;
240         proj.nextthink = time + autocvar_g_balance_electro_secondary_lifetime;
241         PROJECTILE_MAKETRIGGER(proj);
242         proj.projectiledeathtype = WEP_ELECTRO | HITTYPE_SECONDARY;
243         setorigin(proj, w_shotorg);
244
245         //proj.glow_size = 50;
246         //proj.glow_color = 45;
247         proj.movetype = MOVETYPE_BOUNCE;
248         W_SETUPPROJECTILEVELOCITY_UP(proj, g_balance_electro_secondary);
249         proj.touch = W_Plasma_Touch;
250         setsize(proj, '0 0 -4', '0 0 -4');
251         proj.takedamage = DAMAGE_YES;
252         proj.damageforcescale = autocvar_g_balance_electro_secondary_damageforcescale;
253         proj.health = autocvar_g_balance_electro_secondary_health;
254         proj.event_damage = W_Plasma_Damage;
255         proj.flags = FL_PROJECTILE;
256
257         proj.bouncefactor = autocvar_g_balance_electro_secondary_bouncefactor;
258         proj.bouncestop = autocvar_g_balance_electro_secondary_bouncestop;
259
260 #if 0
261         entity p2;
262         p2 = spawn();
263         copyentity(proj, p2);
264         setmodel(p2, "models/ebomb.mdl");
265         setsize(p2, proj.mins, proj.maxs);
266 #endif
267
268         CSQCProjectile(proj, TRUE, PROJECTILE_ELECTRO, FALSE); // no culling, it has sound
269
270         other = proj; MUTATOR_CALLHOOK(EditProjectile);
271 }
272
273 .vector hook_start, hook_end;
274 float lgbeam_send(entity to, float sf)
275 {
276         WriteByte(MSG_ENTITY, ENT_CLIENT_LGBEAM);
277         sf = sf & 0x7F;
278         if(sound_allowed(MSG_BROADCAST, self.owner))
279                 sf |= 0x80;
280         WriteByte(MSG_ENTITY, sf);
281         if(sf & 1)
282         {
283                 WriteByte(MSG_ENTITY, num_for_edict(self.owner));
284                 WriteCoord(MSG_ENTITY, autocvar_g_balance_electro_primary_range);
285         }
286         if(sf & 2)
287         {
288                 WriteCoord(MSG_ENTITY, self.hook_start_x);
289                 WriteCoord(MSG_ENTITY, self.hook_start_y);
290                 WriteCoord(MSG_ENTITY, self.hook_start_z);
291         }
292         if(sf & 4)
293         {
294                 WriteCoord(MSG_ENTITY, self.hook_end_x);
295                 WriteCoord(MSG_ENTITY, self.hook_end_y);
296                 WriteCoord(MSG_ENTITY, self.hook_end_z);
297         }
298         return TRUE;
299 }
300 .entity lgbeam;
301 .float prevlgfire;
302 float lgbeam_checkammo()
303 {
304         if(self.owner.items & IT_UNLIMITED_WEAPON_AMMO)
305                 return TRUE;
306         else if(autocvar_g_balance_electro_reload_ammo)
307                 return self.owner.clip_load > 0;
308         else
309                 return self.owner.ammo_cells > 0;
310 }
311
312 void lgbeam_think()
313 {
314         self.owner.prevlgfire = time;
315         if (self != self.owner.lgbeam)
316         {
317                 remove(self);
318                 return;
319         }
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 this weapon is reloadable, decrease its load. Else decrease the player's ammo
336         if not(self.owner.items & IT_UNLIMITED_WEAPON_AMMO)
337         {
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         float ammo_amount;
444         if (req == WR_AIM)
445         {
446                 self.BUTTON_ATCK=FALSE;
447                 self.BUTTON_ATCK2=FALSE;
448                 if(vlen(self.origin-self.enemy.origin) > 1000)
449                         self.bot_secondary_electromooth = 0;
450                 if(self.bot_secondary_electromooth == 0)
451                 {
452                         float shoot;
453
454                         if(autocvar_g_balance_electro_primary_speed)
455                                 shoot = bot_aim(autocvar_g_balance_electro_primary_speed, 0, autocvar_g_balance_electro_primary_lifetime, FALSE);
456                         else
457                                 shoot = bot_aim(1000000, 0, 0.001, FALSE);
458
459                         if(shoot)
460                         {
461                                 self.BUTTON_ATCK = TRUE;
462                                 if(random() < 0.01) self.bot_secondary_electromooth = 1;
463                         }
464                 }
465                 else
466                 {
467                         if(bot_aim(autocvar_g_balance_electro_secondary_speed, autocvar_g_balance_grenadelauncher_secondary_speed_up, autocvar_g_balance_electro_secondary_lifetime, TRUE))
468                         {
469                                 self.BUTTON_ATCK2 = TRUE;
470                                 if(random() < 0.03) self.bot_secondary_electromooth = 0;
471                         }
472                 }
473         }
474         else if (req == WR_THINK)
475         {
476                 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
477                         W_Electro_Reload();
478                 else if (self.BUTTON_ATCK)
479                 {
480                         if(autocvar_g_balance_electro_lightning)
481                                 if(self.BUTTON_ATCK_prev)
482                                 {
483                                         // prolong the animtime while the gun is being fired
484                                         if(self.animstate_startframe == self.anim_shoot_x && self.animstate_numframes == self.anim_shoot_y)
485                                                 weapon_thinkf(WFRAME_DONTCHANGE, autocvar_g_balance_electro_primary_animtime, w_ready);
486                                         else
487                                                 weapon_thinkf(WFRAME_FIRE1, autocvar_g_balance_electro_primary_animtime, w_ready);
488                                 }
489                         if (weapon_prepareattack(0, (autocvar_g_balance_electro_lightning ? 0 : autocvar_g_balance_electro_primary_refire)))
490                         {
491                                 if(autocvar_g_balance_electro_lightning)
492                                 {
493                                         if ((!self.lgbeam) || wasfreed(self.lgbeam))
494                                         {
495                                                 W_Electro_Attack3();
496                                         }
497                                         if(!self.BUTTON_ATCK_prev)
498                                         {
499                                                 weapon_thinkf(WFRAME_FIRE1, autocvar_g_balance_electro_primary_animtime, w_ready);
500                                                 self.BUTTON_ATCK_prev = 1;
501                                         }
502                                 }
503                                 else
504                                 {
505                                         W_Electro_Attack();
506                                         weapon_thinkf(WFRAME_FIRE1, autocvar_g_balance_electro_primary_animtime, w_ready);
507                                 }
508                         }
509                 } else {
510                         if(autocvar_g_balance_electro_lightning)
511                         {
512                                 if (self.BUTTON_ATCK_prev != 0)
513                                 {
514                                         weapon_thinkf(WFRAME_FIRE1, autocvar_g_balance_electro_primary_animtime, w_ready);
515                                         ATTACK_FINISHED(self) = time + autocvar_g_balance_electro_primary_refire * W_WeaponRateFactor();
516                                 }
517                                 self.BUTTON_ATCK_prev = 0;
518                         }
519
520                         if (self.BUTTON_ATCK2)
521                         {
522                                 if (time >= self.electro_secondarytime)
523                                 if (weapon_prepareattack(1, autocvar_g_balance_electro_secondary_refire))
524                                 {
525                                         W_Electro_Attack2();
526                                         self.electro_count = autocvar_g_balance_electro_secondary_count;
527                                         weapon_thinkf(WFRAME_FIRE2, autocvar_g_balance_electro_secondary_animtime, w_electro_checkattack);
528                                         self.electro_secondarytime = time + autocvar_g_balance_electro_secondary_refire2 * W_WeaponRateFactor();
529                                 }
530                         }
531                 }
532         }
533         else if (req == WR_PRECACHE)
534         {
535                 precache_model ("models/weapons/g_electro.md3");
536                 precache_model ("models/weapons/v_electro.md3");
537                 precache_model ("models/weapons/h_electro.iqm");
538                 precache_sound ("weapons/electro_bounce.wav");
539                 precache_sound ("weapons/electro_fire.wav");
540                 precache_sound ("weapons/electro_fire2.wav");
541                 precache_sound ("weapons/electro_impact.wav");
542                 precache_sound ("weapons/electro_impact_combo.wav");
543                 precache_sound ("weapons/reload.wav");
544                 if(autocvar_g_balance_electro_lightning)
545                 {
546                         precache_sound ("weapons/lgbeam_fire.wav");
547                 }
548         }
549         else if (req == WR_SETUP)
550         {
551                 weapon_setup(WEP_ELECTRO);
552                 W_Electro_SetAmmoCounter();
553         }
554         else if (req == WR_CHECKAMMO1)
555         {
556                 if(autocvar_g_balance_electro_lightning)
557                         ammo_amount = !autocvar_g_balance_electro_primary_ammo || (self.ammo_cells > 0);
558                 else
559                         ammo_amount = self.ammo_cells >= autocvar_g_balance_electro_primary_ammo;
560                 if(autocvar_g_balance_electro_reload_ammo)
561                 {
562                         if(autocvar_g_balance_electro_lightning)
563                                 ammo_amount += !autocvar_g_balance_electro_primary_ammo || (self.electro_load > 0);
564                         else
565                                 ammo_amount += self.electro_load >= autocvar_g_balance_electro_primary_ammo;
566                 }
567                 return ammo_amount;
568         }
569         else if (req == WR_CHECKAMMO2)
570         {
571                 ammo_amount = self.ammo_cells >= autocvar_g_balance_electro_secondary_ammo;
572                 ammo_amount += self.electro_load >= autocvar_g_balance_electro_secondary_ammo;
573                 return ammo_amount;
574         }
575         else if (req == WR_RESETPLAYER)
576         {
577                 self.electro_secondarytime = time;
578
579                 // all weapons must be fully loaded when we spawn
580                 self.electro_load = autocvar_g_balance_electro_reload_ammo;
581         }
582         else if (req == WR_RELOAD)
583         {
584                 W_Shotgun_Reload();
585         }
586         return TRUE;
587 };
588 #endif
589 #ifdef CSQC
590 float w_electro(float req)
591 {
592         if(req == WR_IMPACTEFFECT)
593         {
594                 vector org2;
595                 org2 = w_org + w_backoff * 6;
596                 if(w_deathtype & HITTYPE_SECONDARY)
597                 {
598                         pointparticles(particleeffectnum("electro_ballexplode"), org2, '0 0 0', 1);
599                         if(!w_issilent)
600                                 sound(self, CHAN_PROJECTILE, "weapons/electro_impact.wav", VOL_BASE, ATTN_NORM);
601                 }
602                 else
603                 {
604                         if(w_deathtype & HITTYPE_BOUNCE)
605                         {
606                                 // this is sent as "primary (w_deathtype & HITTYPE_BOUNCE)" to distinguish it from (w_deathtype & HITTYPE_SECONDARY) bounced balls
607                                 pointparticles(particleeffectnum("electro_combo"), org2, '0 0 0', 1);
608                                 if(!w_issilent)
609                                         sound(self, CHAN_PROJECTILE, "weapons/electro_impact_combo.wav", VOL_BASE, ATTN_NORM);
610                         }
611                         else
612                         {
613                                 pointparticles(particleeffectnum("electro_impact"), org2, '0 0 0', 1);
614                                 if(!w_issilent)
615                                         sound(self, CHAN_PROJECTILE, "weapons/electro_impact.wav", VOL_BASE, ATTN_NORM);
616                         }
617                 }
618         }
619         else if(req == WR_PRECACHE)
620         {
621                 precache_sound("weapons/electro_impact.wav");
622                 precache_sound("weapons/electro_impact_combo.wav");
623         }
624         else if (req == WR_SUICIDEMESSAGE)
625         {
626                 if(w_deathtype & HITTYPE_SECONDARY)
627                         w_deathtypestring = _("%s could not remember where they put plasma");
628                 else
629                         w_deathtypestring = _("%s played with plasma");
630         }
631         else if (req == WR_KILLMESSAGE)
632         {
633                 if(w_deathtype & HITTYPE_SECONDARY)
634                 {
635                         if(w_deathtype & HITTYPE_SPLASH) // unchecked: BOUNCE
636                                 w_deathtypestring = _("%s just noticed %s's blue ball");
637                         else // unchecked: BOUNCE
638                                 w_deathtypestring = _("%s got in touch with %s's blue ball");
639                 }
640                 else
641                 {
642                         if(w_deathtype & HITTYPE_BOUNCE) // combo
643                                 w_deathtypestring = _("%s felt the electrifying air of %s's combo");
644                         else if(w_deathtype & HITTYPE_SPLASH)
645                                 w_deathtypestring = _("%s got too close to %s's blue beam");
646                         else
647                                 w_deathtypestring = _("%s was blasted by %s's blue beam");
648                 }
649         }
650         return TRUE;
651 }
652 #endif
653 #endif