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