Merge remote-tracking branch 'origin/master' into Mario/classname_checks
[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(IS_PLAYER(other))
33                         if(IsDifferentTeam(self.realowner, other))
34                                 if(other.deadflag == DEAD_NO)
35                                         if(IsFlying(other))
36                                                 Send_Notification(NOTIF_ONE, self.realowner, MSG_ANNCE, ANNCE_ACHIEVEMENT_ELECTROBITCH);
37
38         self.event_damage = func_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 = func_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         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                         ammo_amount = 0;
420                         if(autocvar_g_balance_electro_lightning)
421                         {
422                                 if(self.clip_load > 0)
423                                         ammo_amount = 1;
424                         }
425                         else if(self.clip_load >= autocvar_g_balance_electro_primary_ammo)
426                                 ammo_amount = 1;
427                         if(self.clip_load >= autocvar_g_balance_electro_secondary_ammo)
428                                 ammo_amount += 1;
429
430                         if(!ammo_amount)
431                         {
432                                 weapon_action(self.weapon, WR_RELOAD);
433                                 return FALSE;
434                         }
435                 }
436                 if (self.BUTTON_ATCK)
437                 {
438                         if(autocvar_g_balance_electro_lightning)
439                                 if(self.BUTTON_ATCK_prev)
440                                         weapon_thinkf(WFRAME_FIRE1, autocvar_g_balance_electro_primary_animtime, w_ready);
441
442                         if (weapon_prepareattack(0, (autocvar_g_balance_electro_lightning ? 0 : autocvar_g_balance_electro_primary_refire)))
443                         {
444                                 if(autocvar_g_balance_electro_lightning)
445                                 {
446                                         if ((!self.lgbeam) || wasfreed(self.lgbeam))
447                                         {
448                                                 W_Electro_Attack3();
449                                         }
450                                         if(!self.BUTTON_ATCK_prev)
451                                         {
452                                                 weapon_thinkf(WFRAME_FIRE1, autocvar_g_balance_electro_primary_animtime, w_ready);
453                                                 self.BUTTON_ATCK_prev = 1;
454                                         }
455                                 }
456                                 else
457                                 {
458                                         W_Electro_Attack();
459                                         weapon_thinkf(WFRAME_FIRE1, autocvar_g_balance_electro_primary_animtime, w_ready);
460                                 }
461                         }
462                 } else {
463                         if(autocvar_g_balance_electro_lightning)
464                         {
465                                 if (self.BUTTON_ATCK_prev != 0)
466                                 {
467                                         weapon_thinkf(WFRAME_FIRE1, autocvar_g_balance_electro_primary_animtime, w_ready);
468                                         ATTACK_FINISHED(self) = time + autocvar_g_balance_electro_primary_refire * W_WeaponRateFactor();
469                                 }
470                                 self.BUTTON_ATCK_prev = 0;
471                         }
472
473                         if (self.BUTTON_ATCK2)
474                         {
475                                 if (time >= self.electro_secondarytime)
476                                 if (weapon_prepareattack(1, autocvar_g_balance_electro_secondary_refire))
477                                 {
478                                         W_Electro_Attack2();
479                                         self.electro_count = autocvar_g_balance_electro_secondary_count;
480                                         weapon_thinkf(WFRAME_FIRE2, autocvar_g_balance_electro_secondary_animtime, w_electro_checkattack);
481                                         self.electro_secondarytime = time + autocvar_g_balance_electro_secondary_refire2 * W_WeaponRateFactor();
482                                 }
483                         }
484                 }
485         }
486         else if (req == WR_PRECACHE)
487         {
488                 precache_model ("models/weapons/g_electro.md3");
489                 precache_model ("models/weapons/v_electro.md3");
490                 precache_model ("models/weapons/h_electro.iqm");
491                 precache_sound ("weapons/electro_bounce.wav");
492                 precache_sound ("weapons/electro_fire.wav");
493                 precache_sound ("weapons/electro_fire2.wav");
494                 precache_sound ("weapons/electro_impact.wav");
495                 precache_sound ("weapons/electro_impact_combo.wav");
496                 //precache_sound ("weapons/reload.wav"); // until weapons have individual reload sounds, precache the reload sound somewhere else
497                 if(autocvar_g_balance_electro_lightning)
498                 {
499                         precache_sound ("weapons/lgbeam_fire.wav");
500                 }
501         }
502         else if (req == WR_SETUP)
503         {
504                 weapon_setup(WEP_ELECTRO);
505                 self.current_ammo = ammo_cells;
506         }
507         else if (req == WR_CHECKAMMO1)
508         {
509                 if(autocvar_g_balance_electro_lightning)
510                 {
511                         if(!autocvar_g_balance_electro_primary_ammo)
512                                 ammo_amount = 1;
513                         else
514                                 ammo_amount = self.ammo_cells > 0;
515                         ammo_amount += self.(weapon_load[WEP_ELECTRO]) > 0;
516                 }
517                 else
518                 {
519                         ammo_amount = self.ammo_cells >= autocvar_g_balance_electro_primary_ammo;
520                         ammo_amount += self.(weapon_load[WEP_ELECTRO]) >= autocvar_g_balance_electro_primary_ammo;
521                 }
522                 return ammo_amount;
523         }
524         else if (req == WR_CHECKAMMO2)
525         {
526                 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.
527                 {
528                         ammo_amount = self.ammo_cells >= autocvar_g_balance_electro_secondary_ammo + autocvar_g_balance_electro_primary_ammo;
529                         ammo_amount += self.(weapon_load[WEP_ELECTRO]) >= autocvar_g_balance_electro_secondary_ammo + autocvar_g_balance_electro_primary_ammo;
530                 }
531                 else
532                 {
533                         ammo_amount = self.ammo_cells >= autocvar_g_balance_electro_secondary_ammo;
534                         ammo_amount += self.(weapon_load[WEP_ELECTRO]) >= autocvar_g_balance_electro_secondary_ammo;
535                 }
536                 return ammo_amount;
537         }
538         else if (req == WR_RESETPLAYER)
539         {
540                 self.electro_secondarytime = time;
541         }
542         else if (req == WR_RELOAD)
543         {
544                 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");
545         }
546         else if (req == WR_SUICIDEMESSAGE)
547         {
548                 if(w_deathtype & HITTYPE_SECONDARY)
549                         return WEAPON_ELECTRO_SUICIDE_ORBS;
550                 else
551                         return WEAPON_ELECTRO_SUICIDE_BOLT;
552         }
553         else if (req == WR_KILLMESSAGE)
554         {
555                 if(w_deathtype & HITTYPE_SECONDARY)
556                 {
557                         return WEAPON_ELECTRO_MURDER_ORBS;
558                 }
559                 else
560                 {
561                         if(w_deathtype & HITTYPE_BOUNCE)
562                                 return WEAPON_ELECTRO_MURDER_COMBO;
563                         else
564                                 return WEAPON_ELECTRO_MURDER_BOLT;
565                 }
566         }
567         return TRUE;
568 }
569 #endif
570 #ifdef CSQC
571 float w_electro(float req)
572 {
573         if(req == WR_IMPACTEFFECT)
574         {
575                 vector org2;
576                 org2 = w_org + w_backoff * 6;
577                 if(w_deathtype & HITTYPE_SECONDARY)
578                 {
579                         pointparticles(particleeffectnum("electro_ballexplode"), org2, '0 0 0', 1);
580                         if(!w_issilent)
581                                 sound(self, CH_SHOTS, "weapons/electro_impact.wav", VOL_BASE, ATTN_NORM);
582                 }
583                 else
584                 {
585                         if(w_deathtype & HITTYPE_BOUNCE)
586                         {
587                                 // this is sent as "primary (w_deathtype & HITTYPE_BOUNCE)" to distinguish it from (w_deathtype & HITTYPE_SECONDARY) bounced balls
588                                 pointparticles(particleeffectnum("electro_combo"), org2, '0 0 0', 1);
589                                 if(!w_issilent)
590                                         sound(self, CH_SHOTS, "weapons/electro_impact_combo.wav", VOL_BASE, ATTN_NORM);
591                         }
592                         else
593                         {
594                                 pointparticles(particleeffectnum("electro_impact"), org2, '0 0 0', 1);
595                                 if(!w_issilent)
596                                         sound(self, CH_SHOTS, "weapons/electro_impact.wav", VOL_BASE, ATTN_NORM);
597                         }
598                 }
599         }
600         else if(req == WR_PRECACHE)
601         {
602                 precache_sound("weapons/electro_impact.wav");
603                 precache_sound("weapons/electro_impact_combo.wav");
604         }
605         return TRUE;
606 }
607 #endif
608 #endif