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