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