]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/server/w_electro.qc
Merge remote-tracking branch 'origin/master' into samual/spawn_weapons
[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, 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, 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, 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         proj.missile_flags = MIF_SPLASH;
144
145         CSQCProjectile(proj, TRUE, PROJECTILE_ELECTRO_BEAM, TRUE);
146
147         other = proj; MUTATOR_CALLHOOK(EditProjectile);
148 }
149
150 void W_Electro_Attack2()
151 {
152         entity proj;
153
154         W_DecreaseAmmo(ammo_cells, autocvar_g_balance_electro_secondary_ammo, autocvar_g_balance_electro_reload_ammo);
155
156         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);
157
158         w_shotdir = v_forward; // no TrueAim for grenades please
159
160         pointparticles(particleeffectnum("electro_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
161
162         proj = spawn ();
163         proj.classname = "plasma";
164         proj.owner = proj.realowner = self;
165         proj.use = W_Plasma_Explode;
166         proj.think = adaptor_think2use_hittype_splash;
167         proj.bot_dodge = TRUE;
168         proj.bot_dodgerating = autocvar_g_balance_electro_secondary_damage;
169         proj.nextthink = time + autocvar_g_balance_electro_secondary_lifetime;
170         PROJECTILE_MAKETRIGGER(proj);
171         proj.projectiledeathtype = WEP_ELECTRO | HITTYPE_SECONDARY;
172         setorigin(proj, w_shotorg);
173
174         //proj.glow_size = 50;
175         //proj.glow_color = 45;
176         proj.movetype = MOVETYPE_BOUNCE;
177         W_SETUPPROJECTILEVELOCITY_UP(proj, g_balance_electro_secondary);
178         proj.touch = W_Plasma_Touch;
179         setsize(proj, '0 0 -4', '0 0 -4');
180         proj.takedamage = DAMAGE_YES;
181         proj.damageforcescale = autocvar_g_balance_electro_secondary_damageforcescale;
182         proj.health = autocvar_g_balance_electro_secondary_health;
183         proj.event_damage = W_Plasma_Damage;
184         proj.flags = FL_PROJECTILE;
185         proj.damagedbycontents = (autocvar_g_balance_electro_secondary_damagedbycontents);
186
187         proj.bouncefactor = autocvar_g_balance_electro_secondary_bouncefactor;
188         proj.bouncestop = autocvar_g_balance_electro_secondary_bouncestop;
189         proj.missile_flags = MIF_SPLASH | MIF_ARC;
190
191 #if 0
192         entity p2;
193         p2 = spawn();
194         copyentity(proj, p2);
195         setmodel(p2, "models/ebomb.mdl");
196         setsize(p2, proj.mins, proj.maxs);
197 #endif
198
199         CSQCProjectile(proj, TRUE, PROJECTILE_ELECTRO, FALSE); // no culling, it has sound
200
201         other = proj; MUTATOR_CALLHOOK(EditProjectile);
202 }
203
204 .vector hook_start, hook_end;
205 float lgbeam_send(entity to, float sf)
206 {
207         WriteByte(MSG_ENTITY, ENT_CLIENT_LGBEAM);
208         sf = sf & 0x7F;
209         if(sound_allowed(MSG_BROADCAST, self.realowner))
210                 sf |= 0x80;
211         WriteByte(MSG_ENTITY, sf);
212         if(sf & 1)
213         {
214                 WriteByte(MSG_ENTITY, num_for_edict(self.realowner));
215                 WriteCoord(MSG_ENTITY, autocvar_g_balance_electro_primary_range);
216         }
217         if(sf & 2)
218         {
219                 WriteCoord(MSG_ENTITY, self.hook_start_x);
220                 WriteCoord(MSG_ENTITY, self.hook_start_y);
221                 WriteCoord(MSG_ENTITY, self.hook_start_z);
222         }
223         if(sf & 4)
224         {
225                 WriteCoord(MSG_ENTITY, self.hook_end_x);
226                 WriteCoord(MSG_ENTITY, self.hook_end_y);
227                 WriteCoord(MSG_ENTITY, self.hook_end_z);
228         }
229         return TRUE;
230 }
231 .entity lgbeam;
232 .float prevlgfire;
233 float lgbeam_checkammo()
234 {
235         if(self.realowner.items & IT_UNLIMITED_WEAPON_AMMO)
236                 return TRUE;
237         else if(autocvar_g_balance_electro_reload_ammo)
238                 return self.realowner.clip_load > 0;
239         else
240                 return self.realowner.ammo_cells > 0;
241 }
242
243 entity lgbeam_owner_ent;
244 void lgbeam_think()
245 {
246         entity owner_player;
247         owner_player = self.realowner;
248
249         owner_player.prevlgfire = time;
250         if (self != owner_player.lgbeam)
251         {
252                 remove(self);
253                 return;
254         }
255
256         if (owner_player.weaponentity.state != WS_INUSE || !lgbeam_checkammo() || owner_player.deadflag != DEAD_NO || !owner_player.BUTTON_ATCK || owner_player.freezetag_frozen)
257         {
258                 if(self == owner_player.lgbeam)
259                         owner_player.lgbeam = world;
260                 remove(self);
261                 return;
262         }
263
264         self.nextthink = time;
265
266         makevectors(owner_player.v_angle);
267
268         float dt, f;
269         dt = frametime;
270
271         // if this weapon is reloadable, decrease its load. Else decrease the player's ammo
272         if not(owner_player.items & IT_UNLIMITED_WEAPON_AMMO)
273         {
274                 if(autocvar_g_balance_electro_primary_ammo)
275                 {
276                         if(autocvar_g_balance_electro_reload_ammo)
277                         {
278                                 dt = min(dt, owner_player.clip_load / autocvar_g_balance_electro_primary_ammo);
279                                 owner_player.clip_load = max(0, owner_player.clip_load - autocvar_g_balance_electro_primary_ammo * frametime);
280                                 owner_player.(weapon_load[WEP_ELECTRO]) = owner_player.clip_load;
281                         }
282                         else
283                         {
284                                 dt = min(dt, owner_player.ammo_cells / autocvar_g_balance_electro_primary_ammo);
285                                 owner_player.ammo_cells = max(0, owner_player.ammo_cells - autocvar_g_balance_electro_primary_ammo * frametime);
286                         }
287                 }
288         }
289
290         W_SetupShot_Range(owner_player, TRUE, 0, "", 0, autocvar_g_balance_electro_primary_damage * dt, autocvar_g_balance_electro_primary_range);
291         if(!lgbeam_owner_ent)
292         {
293                 lgbeam_owner_ent = spawn();
294                 lgbeam_owner_ent.classname = "lgbeam_owner_ent";
295         }
296         WarpZone_traceline_antilag(lgbeam_owner_ent, w_shotorg, w_shotend, MOVE_NORMAL, lgbeam_owner_ent, ANTILAG_LATENCY(owner_player));
297
298         // apply the damage
299         if(trace_ent)
300         {
301                 vector force;
302                 force = w_shotdir * autocvar_g_balance_electro_primary_force + '0 0 1' * autocvar_g_balance_electro_primary_force_up;
303
304                 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));
305
306                 if(accuracy_isgooddamage(owner_player, trace_ent))
307                         accuracy_add(owner_player, WEP_ELECTRO, 0, autocvar_g_balance_electro_primary_damage * dt * f);
308                 Damage (trace_ent, owner_player, owner_player, autocvar_g_balance_electro_primary_damage * dt * f, WEP_ELECTRO, trace_endpos, force * dt);
309         }
310         W_Plasma_TriggerCombo(trace_endpos, autocvar_g_balance_electro_primary_comboradius, owner_player);
311
312         // draw effect
313         if(w_shotorg != self.hook_start)
314         {
315                 self.SendFlags |= 2;
316                 self.hook_start = w_shotorg;
317         }
318         if(w_shotend != self.hook_end)
319         {
320                 self.SendFlags |= 4;
321                 self.hook_end = w_shotend;
322         }
323 }
324
325 // experimental lightning gun
326 void W_Electro_Attack3 (void)
327 {
328         // only play fire sound if 0.5 sec has passed since player let go the fire button
329         if(time - self.prevlgfire > 0.5)
330                 sound (self, CH_WEAPON_A, "weapons/lgbeam_fire.wav", VOL_BASE, ATTN_NORM);
331
332         entity beam, oldself;
333
334         self.lgbeam = beam = spawn();
335         beam.classname = "lgbeam";
336         beam.solid = SOLID_NOT;
337         beam.think = lgbeam_think;
338         beam.owner = beam.realowner = self;
339         beam.movetype = MOVETYPE_NONE;
340         beam.shot_spread = 0;
341         beam.bot_dodge = TRUE;
342         beam.bot_dodgerating = autocvar_g_balance_electro_primary_damage;
343         Net_LinkEntity(beam, FALSE, 0, lgbeam_send);
344
345         oldself = self;
346         self = beam;
347         self.think();
348         self = oldself;
349 }
350
351 void ElectroInit()
352 {
353         weapon_action(WEP_ELECTRO, WR_PRECACHE);
354         electro_shotorigin[0] = shotorg_adjust_values(CL_Weapon_GetShotOrg(WEP_ELECTRO), FALSE, FALSE, 1);
355         electro_shotorigin[1] = shotorg_adjust_values(CL_Weapon_GetShotOrg(WEP_ELECTRO), FALSE, FALSE, 2);
356         electro_shotorigin[2] = shotorg_adjust_values(CL_Weapon_GetShotOrg(WEP_ELECTRO), FALSE, FALSE, 3);
357         electro_shotorigin[3] = shotorg_adjust_values(CL_Weapon_GetShotOrg(WEP_ELECTRO), FALSE, FALSE, 4);
358 }
359
360 void spawnfunc_weapon_electro (void)
361 {
362         weapon_defaultspawnfunc(WEP_ELECTRO);
363 }
364
365 void w_electro_checkattack()
366 {
367         if(self.electro_count > 1)
368         if(self.BUTTON_ATCK2)
369         if(weapon_prepareattack(1, -1))
370         {
371                 W_Electro_Attack2();
372                 self.electro_count -= 1;
373                 weapon_thinkf(WFRAME_FIRE2, autocvar_g_balance_electro_secondary_animtime, w_electro_checkattack);
374                 return;
375         }
376
377         w_ready();
378 }
379
380 .float bot_secondary_electromooth;
381 .float BUTTON_ATCK_prev;
382 float w_electro(float req)
383 {
384         float ammo_amount;
385         if (req == WR_AIM)
386         {
387                 self.BUTTON_ATCK=FALSE;
388                 self.BUTTON_ATCK2=FALSE;
389                 if(vlen(self.origin-self.enemy.origin) > 1000)
390                         self.bot_secondary_electromooth = 0;
391                 if(self.bot_secondary_electromooth == 0)
392                 {
393                         float shoot;
394
395                         if(autocvar_g_balance_electro_primary_speed)
396                                 shoot = bot_aim(autocvar_g_balance_electro_primary_speed, 0, autocvar_g_balance_electro_primary_lifetime, FALSE);
397                         else
398                                 shoot = bot_aim(1000000, 0, 0.001, FALSE);
399
400                         if(shoot)
401                         {
402                                 self.BUTTON_ATCK = TRUE;
403                                 if(random() < 0.01) self.bot_secondary_electromooth = 1;
404                         }
405                 }
406                 else
407                 {
408                         if(bot_aim(autocvar_g_balance_electro_secondary_speed, autocvar_g_balance_grenadelauncher_secondary_speed_up, autocvar_g_balance_electro_secondary_lifetime, TRUE))
409                         {
410                                 self.BUTTON_ATCK2 = TRUE;
411                                 if(random() < 0.03) self.bot_secondary_electromooth = 0;
412                         }
413                 }
414         }
415         else if (req == WR_THINK)
416         {
417                 if(autocvar_g_balance_electro_reload_ammo) // forced reload
418                 {
419                         if(autocvar_g_balance_electro_lightning)
420                         {
421                                 if(self.clip_load > 0)
422                                         ammo_amount = 1;
423                         }
424                         else if(self.clip_load >= autocvar_g_balance_electro_primary_ammo)
425                                 ammo_amount = 1;
426                         if(self.clip_load >= autocvar_g_balance_electro_secondary_ammo)
427                                 ammo_amount += 1;
428
429                         if(!ammo_amount)
430                         {
431                                 weapon_action(self.weapon, WR_RELOAD);
432                                 return FALSE;
433                         }
434                 }
435                 if (self.BUTTON_ATCK)
436                 {
437                         if(autocvar_g_balance_electro_lightning)
438                                 if(self.BUTTON_ATCK_prev)
439                                 {
440                                         // prolong the animtime while the gun is being fired
441                                         if(self.animstate_startframe == self.anim_shoot_x && self.animstate_numframes == self.anim_shoot_y)
442                                                 weapon_thinkf(WFRAME_DONTCHANGE, autocvar_g_balance_electro_primary_animtime, w_ready);
443                                         else
444                                                 weapon_thinkf(WFRAME_FIRE1, autocvar_g_balance_electro_primary_animtime, w_ready);
445                                 }
446                         if (weapon_prepareattack(0, (autocvar_g_balance_electro_lightning ? 0 : autocvar_g_balance_electro_primary_refire)))
447                         {
448                                 if(autocvar_g_balance_electro_lightning)
449                                 {
450                                         if ((!self.lgbeam) || wasfreed(self.lgbeam))
451                                         {
452                                                 W_Electro_Attack3();
453                                         }
454                                         if(!self.BUTTON_ATCK_prev)
455                                         {
456                                                 weapon_thinkf(WFRAME_FIRE1, autocvar_g_balance_electro_primary_animtime, w_ready);
457                                                 self.BUTTON_ATCK_prev = 1;
458                                         }
459                                 }
460                                 else
461                                 {
462                                         W_Electro_Attack();
463                                         weapon_thinkf(WFRAME_FIRE1, autocvar_g_balance_electro_primary_animtime, w_ready);
464                                 }
465                         }
466                 } else {
467                         if(autocvar_g_balance_electro_lightning)
468                         {
469                                 if (self.BUTTON_ATCK_prev != 0)
470                                 {
471                                         weapon_thinkf(WFRAME_FIRE1, autocvar_g_balance_electro_primary_animtime, w_ready);
472                                         ATTACK_FINISHED(self) = time + autocvar_g_balance_electro_primary_refire * W_WeaponRateFactor();
473                                 }
474                                 self.BUTTON_ATCK_prev = 0;
475                         }
476
477                         if (self.BUTTON_ATCK2)
478                         {
479                                 if (time >= self.electro_secondarytime)
480                                 if (weapon_prepareattack(1, autocvar_g_balance_electro_secondary_refire))
481                                 {
482                                         W_Electro_Attack2();
483                                         self.electro_count = autocvar_g_balance_electro_secondary_count;
484                                         weapon_thinkf(WFRAME_FIRE2, autocvar_g_balance_electro_secondary_animtime, w_electro_checkattack);
485                                         self.electro_secondarytime = time + autocvar_g_balance_electro_secondary_refire2 * W_WeaponRateFactor();
486                                 }
487                         }
488                 }
489         }
490         else if (req == WR_PRECACHE)
491         {
492                 precache_model ("models/weapons/g_electro.md3");
493                 precache_model ("models/weapons/v_electro.md3");
494                 precache_model ("models/weapons/h_electro.iqm");
495                 precache_sound ("weapons/electro_bounce.wav");
496                 precache_sound ("weapons/electro_fire.wav");
497                 precache_sound ("weapons/electro_fire2.wav");
498                 precache_sound ("weapons/electro_impact.wav");
499                 precache_sound ("weapons/electro_impact_combo.wav");
500                 //precache_sound ("weapons/reload.wav"); // until weapons have individual reload sounds, precache the reload sound somewhere else
501                 if(autocvar_g_balance_electro_lightning)
502                 {
503                         precache_sound ("weapons/lgbeam_fire.wav");
504                 }
505         }
506         else if (req == WR_SETUP)
507         {
508                 weapon_setup(WEP_ELECTRO);
509                 self.current_ammo = ammo_cells;
510         }
511         else if (req == WR_CHECKAMMO1)
512         {
513                 if(autocvar_g_balance_electro_lightning)
514                 {
515                         if(!autocvar_g_balance_electro_primary_ammo)
516                                 ammo_amount = 1;
517                         else
518                                 ammo_amount = self.ammo_cells > 0;
519                         ammo_amount += self.(weapon_load[WEP_ELECTRO]) > 0;
520                 }
521                 else
522                 {
523                         ammo_amount = self.ammo_cells >= autocvar_g_balance_electro_primary_ammo;
524                         ammo_amount += self.(weapon_load[WEP_ELECTRO]) >= autocvar_g_balance_electro_primary_ammo;
525                 }
526                 return ammo_amount;
527         }
528         else if (req == WR_CHECKAMMO2)
529         {
530                 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.
531                 {
532                         ammo_amount = self.ammo_cells >= autocvar_g_balance_electro_secondary_ammo + autocvar_g_balance_electro_primary_ammo;
533                         ammo_amount += self.(weapon_load[WEP_ELECTRO]) >= autocvar_g_balance_electro_secondary_ammo + autocvar_g_balance_electro_primary_ammo;
534                 }
535                 else
536                 {
537                         ammo_amount = self.ammo_cells >= autocvar_g_balance_electro_secondary_ammo;
538                         ammo_amount += self.(weapon_load[WEP_ELECTRO]) >= autocvar_g_balance_electro_secondary_ammo;
539                 }
540                 return ammo_amount;
541         }
542         else if (req == WR_RESETPLAYER)
543         {
544                 self.electro_secondarytime = time;
545         }
546         else if (req == WR_RELOAD)
547         {
548                 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");
549         }
550         return TRUE;
551 }
552 #endif
553 #ifdef CSQC
554 float w_electro(float req)
555 {
556         if(req == WR_IMPACTEFFECT)
557         {
558                 vector org2;
559                 org2 = w_org + w_backoff * 6;
560                 if(w_deathtype & HITTYPE_SECONDARY)
561                 {
562                         pointparticles(particleeffectnum("electro_ballexplode"), org2, '0 0 0', 1);
563                         if(!w_issilent)
564                                 sound(self, CH_SHOTS, "weapons/electro_impact.wav", VOL_BASE, ATTN_NORM);
565                 }
566                 else
567                 {
568                         if(w_deathtype & HITTYPE_BOUNCE)
569                         {
570                                 // this is sent as "primary (w_deathtype & HITTYPE_BOUNCE)" to distinguish it from (w_deathtype & HITTYPE_SECONDARY) bounced balls
571                                 pointparticles(particleeffectnum("electro_combo"), org2, '0 0 0', 1);
572                                 if(!w_issilent)
573                                         sound(self, CH_SHOTS, "weapons/electro_impact_combo.wav", VOL_BASE, ATTN_NORM);
574                         }
575                         else
576                         {
577                                 pointparticles(particleeffectnum("electro_impact"), org2, '0 0 0', 1);
578                                 if(!w_issilent)
579                                         sound(self, CH_SHOTS, "weapons/electro_impact.wav", VOL_BASE, ATTN_NORM);
580                         }
581                 }
582         }
583         else if(req == WR_PRECACHE)
584         {
585                 precache_sound("weapons/electro_impact.wav");
586                 precache_sound("weapons/electro_impact_combo.wav");
587         }
588         else if (req == WR_SUICIDEMESSAGE)
589         {
590                 if(w_deathtype & HITTYPE_SECONDARY)
591                         w_deathtypestring = _("%s could not remember where they put their electro plasma");
592                 else
593                         w_deathtypestring = _("%s played with electro plasma");
594         }
595         else if (req == WR_KILLMESSAGE)
596         {
597                 if(w_deathtype & HITTYPE_SECONDARY)
598                 {
599                         if(w_deathtype & HITTYPE_SPLASH) // unchecked: BOUNCE
600                                 w_deathtypestring = _("%s just noticed %s's electro plasma");
601                         else // unchecked: BOUNCE
602                                 w_deathtypestring = _("%s got in touch with %s's electro plasma");
603                 }
604                 else
605                 {
606                         if(w_deathtype & HITTYPE_BOUNCE) // combo
607                                 w_deathtypestring = _("%s felt the electrifying air of %s's electro combo");
608                         else if(w_deathtype & HITTYPE_SPLASH)
609                                 w_deathtypestring = _("%s got too close to %s's blue electro bolt");
610                         else
611                                 w_deathtypestring = _("%s was blasted by %s's blue electro bolt");
612                 }
613         }
614         return TRUE;
615 }
616 #endif
617 #endif