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