]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/weapons/weapon/electro.qc
Fix FL_WEAPON flag overlapping FL_JUMPRELEASED. This unintentional change was introdu...
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / weapons / weapon / electro.qc
1 #include "electro.qh"
2
3 #ifdef SVQC
4 #include <common/effects/qc/_mod.qh>
5
6 void W_Electro_TriggerCombo(vector org, float rad, entity own)
7 {
8         entity e = WarpZone_FindRadius(org, rad, !WEP_CVAR(electro, combo_comboradius_thruwall));
9         while(e)
10         {
11                 if(e.classname == "electro_orb")
12                 {
13                         // check if the ball we are exploding is not owned by an
14                         // independent player which is not the player who shot the ball
15                         if(IS_INDEPENDENT_PLAYER(e.realowner) && own != e.realowner)
16                         {
17                                 e = e.chain;
18                                 continue;
19                         }
20                         // do we allow thruwall triggering?
21                         if(WEP_CVAR(electro, combo_comboradius_thruwall))
22                         {
23                                 // if distance is greater than thruwall distance, check to make sure it's not through a wall
24                                 if(vdist(e.WarpZone_findradius_dist, >, WEP_CVAR(electro, combo_comboradius_thruwall)))
25                                 {
26                                         WarpZone_TraceLine(org, e.origin, MOVE_NOMONSTERS, e);
27                                         if(trace_fraction != 1)
28                                         {
29                                                 // trigger is through a wall and outside of thruwall range, abort
30                                                 e = e.chain;
31                                                 continue;
32                                         }
33                                 }
34                         }
35
36                         // change owner to whoever caused the combo explosion
37                         e.realowner = own;
38                         e.takedamage = DAMAGE_NO;
39                         e.classname = "electro_orb_chain";
40
41                         // now set the next one to trigger as well
42                         setthink(e, W_Electro_ExplodeCombo);
43
44                         // delay combo chains, looks cooler
45                         float delay = 0;
46                         if (WEP_CVAR(electro, combo_speed))
47                                 delay = vlen(e.WarpZone_findradius_dist) / WEP_CVAR(electro, combo_speed);
48                         e.nextthink = time + delay;
49                 }
50                 e = e.chain;
51         }
52 }
53
54 void W_Electro_ExplodeCombo(entity this)
55 {
56         W_Electro_TriggerCombo(this.origin, WEP_CVAR(electro, combo_comboradius), this.realowner);
57
58         this.event_damage = func_null;
59         this.velocity = this.movedir; // .velocity must be != '0 0 0' for particle fx and decal to work
60
61         RadiusDamage(
62                 this,
63                 this.realowner,
64                 WEP_CVAR(electro, combo_damage),
65                 WEP_CVAR(electro, combo_edgedamage),
66                 WEP_CVAR(electro, combo_radius),
67                 NULL,
68                 NULL,
69                 WEP_CVAR(electro, combo_force),
70                 WEP_ELECTRO.m_id | HITTYPE_BOUNCE, // use THIS type for a combo because primary can't bounce
71                 this.weaponentity_fld,
72                 NULL
73         );
74
75         delete(this);
76 }
77
78 void W_Electro_Explode(entity this, entity directhitentity)
79 {
80         if(directhitentity.takedamage == DAMAGE_AIM)
81                 if(IS_PLAYER(directhitentity))
82                         if(DIFF_TEAM(this.realowner, directhitentity))
83                                 if(!IS_DEAD(directhitentity))
84                                         if(IsFlying(directhitentity))
85                                                 Send_Notification(NOTIF_ONE, this.realowner, MSG_ANNCE, ANNCE_ACHIEVEMENT_ELECTROBITCH);
86
87         this.event_damage = func_null;
88         this.takedamage = DAMAGE_NO;
89         this.velocity = this.movedir; // .velocity must be != '0 0 0' for particle fx and decal to work
90
91         if(this.move_movetype == MOVETYPE_BOUNCE || this.classname == "electro_orb") // TODO: classname is more reliable anyway?
92         {
93                 RadiusDamage(
94                         this,
95                         this.realowner,
96                         WEP_CVAR_SEC(electro, damage),
97                         WEP_CVAR_SEC(electro, edgedamage),
98                         WEP_CVAR_SEC(electro, radius),
99                         NULL,
100                         NULL,
101                         WEP_CVAR_SEC(electro, force),
102                         this.projectiledeathtype,
103                         this.weaponentity_fld,
104                         directhitentity
105                 );
106         }
107         else
108         {
109                 W_Electro_TriggerCombo(this.origin, WEP_CVAR_PRI(electro, comboradius), this.realowner);
110                 RadiusDamage(
111                         this,
112                         this.realowner,
113                         WEP_CVAR_PRI(electro, damage),
114                         WEP_CVAR_PRI(electro, edgedamage),
115                         WEP_CVAR_PRI(electro, radius),
116                         NULL,
117                         NULL,
118                         WEP_CVAR_PRI(electro, force),
119                         this.projectiledeathtype,
120                         this.weaponentity_fld,
121                         directhitentity
122                 );
123         }
124
125         delete(this);
126 }
127
128 void W_Electro_Explode_use(entity this, entity actor, entity trigger)
129 {
130         W_Electro_Explode(this, trigger);
131 }
132
133 void W_Electro_TouchExplode(entity this, entity toucher)
134 {
135         PROJECTILE_TOUCH(this, toucher);
136         W_Electro_Explode(this, toucher);
137 }
138
139
140 //void sys_phys_update_single(entity this);
141
142 void W_Electro_Bolt_Think(entity this)
143 {
144         // sys_phys_update_single(this);
145         if(time >= this.ltime)
146         {
147                 this.use(this, NULL, NULL);
148                 return;
149         }
150
151         if(WEP_CVAR_PRI(electro, midaircombo_radius))
152         {
153                 float found = 0;
154                 entity e = WarpZone_FindRadius(this.origin, WEP_CVAR_PRI(electro, midaircombo_radius), true);
155
156                 // loop through nearby orbs and trigger them
157                 while(e)
158                 {
159                         if(e.classname == "electro_orb")
160                         {
161                                 // check if the ball we are exploding is not owned by an
162                                 // independent player which is not the player who shot the ball
163                                 if(IS_INDEPENDENT_PLAYER(e.realowner) && this.realowner != e.realowner)
164                                 {
165                                         e = e.chain;
166                                         continue;
167                                 }
168                                 bool explode;
169                                 if (this.owner == e.owner)
170                                 {
171                                         explode = WEP_CVAR_PRI(electro, midaircombo_own);
172                                 }
173                                 else if (SAME_TEAM(this.owner, e.owner))
174                                 {
175                                         explode = WEP_CVAR_PRI(electro, midaircombo_teammate);
176                                 }
177                                 else
178                                 {
179                                         explode = WEP_CVAR_PRI(electro, midaircombo_enemy);
180                                 }
181
182                                 if (explode)
183                                 {
184                                         // change owner to whoever caused the combo explosion
185                                         e.realowner = this.realowner;
186                                         e.takedamage = DAMAGE_NO;
187                                         e.classname = "electro_orb_chain";
188
189                                         // Only first orb explosion uses midaircombo_speed, others use the normal combo_speed.
190                                         // This allows to avoid the delay on the first explosion which looks better
191                                         // (the bolt and orb should explode together because they interacted together)
192                                         // while keeping the chaining delay.
193                                         setthink(e, W_Electro_ExplodeCombo);
194                                         float delay = 0;
195                                         if (WEP_CVAR_PRI(electro, midaircombo_speed))
196                                                 delay = vlen(e.WarpZone_findradius_dist) / WEP_CVAR_PRI(electro, midaircombo_speed);
197                                         e.nextthink = time + delay;
198
199                                         ++found;
200                                 }
201                         }
202                         e = e.chain;
203                 }
204
205                 // if we triggered an orb, should we explode? if not, lets try again next time
206                 if(found && WEP_CVAR_PRI(electro, midaircombo_explode))
207                         { this.use(this, NULL, NULL); }
208                 else
209                         { this.nextthink = min(time + WEP_CVAR_PRI(electro, midaircombo_interval), this.ltime); }
210         }
211         else { this.nextthink = this.ltime; }
212         // this.nextthink = time;
213 }
214
215 void W_Electro_Attack_Bolt(Weapon thiswep, entity actor, .entity weaponentity)
216 {
217         entity proj;
218
219         W_DecreaseAmmo(thiswep, actor, WEP_CVAR_PRI(electro, ammo), weaponentity);
220
221         W_SetupShot_ProjectileSize(
222                 actor,
223                 weaponentity,
224                 '0 0 -3',
225                 '0 0 -3',
226                 false,
227                 2,
228                 SND_ELECTRO_FIRE,
229                 CH_WEAPON_A,
230                 WEP_CVAR_PRI(electro, damage),
231                 thiswep.m_id
232         );
233
234         W_MuzzleFlash(thiswep, actor, weaponentity, w_shotorg, w_shotdir);
235
236         proj = new(electro_bolt);
237         proj.owner = proj.realowner = actor;
238         proj.bot_dodge = true;
239         proj.bot_dodgerating = WEP_CVAR_PRI(electro, damage);
240         proj.use = W_Electro_Explode_use;
241         setthink(proj, W_Electro_Bolt_Think);
242         proj.nextthink = time;
243         proj.ltime = time + WEP_CVAR_PRI(electro, lifetime);
244         PROJECTILE_MAKETRIGGER(proj);
245         proj.projectiledeathtype = thiswep.m_id;
246         proj.weaponentity_fld = weaponentity;
247         setorigin(proj, w_shotorg);
248
249         // if (IS_CSQC)
250         set_movetype(proj, MOVETYPE_FLY);
251         W_SetupProjVelocity_PRI(proj, electro);
252         proj.angles = vectoangles(proj.velocity);
253         settouch(proj, W_Electro_TouchExplode);
254         setsize(proj, '0 0 -3', '0 0 -3');
255         proj.flags = FL_PROJECTILE;
256         IL_PUSH(g_projectiles, proj);
257         IL_PUSH(g_bot_dodge, proj);
258         proj.missile_flags = MIF_SPLASH;
259
260         CSQCProjectile(proj, true, PROJECTILE_ELECTRO_BEAM, true);
261
262         MUTATOR_CALLHOOK(EditProjectile, actor, proj);
263         // proj.com_phys_pos = proj.origin;
264         // proj.com_phys_vel = proj.velocity;
265 }
266
267 void W_Electro_Orb_Follow_Think(entity this)
268 {
269         if (time > this.death_time)
270         {
271                 adaptor_think2use_hittype_splash(this);
272                 return;
273         }
274         if (this.move_movetype == MOVETYPE_FOLLOW)
275         {
276                 int lost = LostMovetypeFollow(this);
277                 if (lost == 2)
278                 {
279                         // FIXME if player disconnected, it isn't possible to drop the orb at player's origin
280                         // see comment in LostMovetypeFollow implementation
281                         delete(this);
282                         return;
283                 }
284                 if (lost)
285                 {
286                         // drop the orb at the corpse's location
287                         PROJECTILE_MAKETRIGGER(this);
288                         set_movetype(this, MOVETYPE_TOSS);
289
290                         setthink(this, adaptor_think2use_hittype_splash);
291                         this.nextthink = this.death_time;
292                         return;
293                 }
294         }
295         this.nextthink = time;
296 }
297
298 void W_Electro_Orb_Stick(entity this, entity to)
299 {
300         entity newproj = spawn();
301         newproj.classname = this.classname;
302
303         newproj.bot_dodge = this.bot_dodge;
304         newproj.bot_dodgerating = this.bot_dodgerating;
305
306         newproj.owner = this.owner;
307         newproj.realowner = this.realowner;
308         PROJECTILE_MAKETRIGGER(newproj);
309         setorigin(newproj, this.origin);
310         setmodel(newproj, MDL_PROJECTILE_ELECTRO);
311         setsize(newproj, this.mins, this.maxs);
312         newproj.angles = vectoangles(-trace_plane_normal); // face against the surface
313         newproj.traileffectnum = _particleeffectnum(EFFECT_TR_NEXUIZPLASMA.eent_eff_name);
314
315         newproj.movedir = -trace_plane_normal;
316
317         newproj.takedamage = this.takedamage;
318         newproj.damageforcescale = this.damageforcescale;
319         SetResourceExplicit(newproj, RES_HEALTH, GetResource(this, RES_HEALTH));
320         newproj.event_damage = this.event_damage;
321         newproj.spawnshieldtime = this.spawnshieldtime;
322         newproj.damagedbycontents = true;
323         IL_PUSH(g_damagedbycontents, newproj);
324
325         set_movetype(newproj, MOVETYPE_NONE); // lock the orb in place
326         newproj.projectiledeathtype = this.projectiledeathtype;
327         newproj.weaponentity_fld = this.weaponentity_fld;
328
329         settouch(newproj, func_null);
330         if(WEP_CVAR_SEC(electro, stick_lifetime) > 0){
331                 newproj.death_time = time + WEP_CVAR_SEC(electro, stick_lifetime);
332         }else{
333                 newproj.death_time = this.death_time;
334         }
335         newproj.use = this.use;
336         newproj.flags = this.flags;
337         IL_PUSH(g_projectiles, newproj);
338         IL_PUSH(g_bot_dodge, newproj);
339
340         // check if limits are enabled (we can tell by checking if the original orb is listed) and push it to the list if so
341         if(LimitedElectroBallRubbleList && IL_CONTAINS(LimitedElectroBallRubbleList, this))
342         {
343                 ReplaceOldListedChildRubble(LimitedElectroBallRubbleList, newproj, this);
344         }
345
346         delete(this);
347
348         if(to)
349         {
350                 SetMovetypeFollow(newproj, to);
351
352                 setthink(newproj, W_Electro_Orb_Follow_Think);
353                 newproj.nextthink = time;
354         }
355         else
356         {
357                 setthink(newproj, adaptor_think2use_hittype_splash);
358                 newproj.nextthink = newproj.death_time;
359         }
360 }
361
362 void W_Electro_Orb_Touch(entity this, entity toucher)
363 {
364         PROJECTILE_TOUCH(this, toucher);
365         if(toucher.takedamage == DAMAGE_AIM && WEP_CVAR_SEC(electro, touchexplode))
366                 { W_Electro_Explode(this, toucher); }
367         else if(toucher.owner != this.owner && toucher.classname != this.classname) // don't stick to player's other projectiles!
368         {
369                 //UpdateCSQCProjectile(this);
370                 spamsound(this, CH_SHOTS, SND_ELECTRO_BOUNCE, VOL_BASE, ATTEN_NORM);
371                 this.projectiledeathtype |= HITTYPE_BOUNCE;
372
373                 if(WEP_CVAR_SEC(electro, stick)){
374                         if(WEP_CVAR_SEC(electro, stick_lifetime) == 0){
375                                 W_Electro_Explode(this, toucher);
376                         } else {
377                                 W_Electro_Orb_Stick(this, toucher);
378                         }
379                 }
380         }
381 }
382
383 void W_Electro_Orb_Damage(entity this, entity inflictor, entity attacker, float damage, int deathtype, .entity weaponentity, vector hitloc, vector force)
384 {
385         if(GetResource(this, RES_HEALTH) <= 0)
386                 return;
387
388         // note: combos are usually triggered by W_Electro_TriggerCombo, not damage
389         float is_combo = (inflictor.classname == "electro_orb_chain" || inflictor.classname == "electro_bolt");
390
391         if(!W_CheckProjectileDamage(inflictor.realowner, this.realowner, deathtype, (is_combo ? 1 : -1)))
392                 return; // g_projectiles_damage says to halt
393
394         TakeResource(this, RES_HEALTH, damage);
395         if(GetResource(this, RES_HEALTH) <= 0)
396         {
397                 this.takedamage = DAMAGE_NO;
398                 this.nextthink = time;
399                 if(is_combo)
400                 {
401                         // change owner to whoever caused the combo explosion
402                         this.realowner = inflictor.realowner;
403                         this.classname = "electro_orb_chain";
404                         setthink(this, W_Electro_ExplodeCombo);
405                         // delay combo chains, looks cooler
406                         // bound the length, inflictor may be in a galaxy far far away (warpzones)
407                         float len = min(WEP_CVAR(electro, combo_radius), vlen(this.origin - inflictor.origin));
408                         float delay = len / WEP_CVAR(electro, combo_speed);
409                         this.nextthink = time + delay;
410                 }
411                 else
412                 {
413                         this.use = W_Electro_Explode_use;
414                         setthink(this, adaptor_think2use); // not _hittype_splash, as this runs "immediately"
415                 }
416         }
417 }
418
419 void W_Electro_Attack_Orb(Weapon thiswep, entity actor, .entity weaponentity)
420 {
421         W_DecreaseAmmo(thiswep, actor, WEP_CVAR_SEC(electro, ammo), weaponentity);
422
423         W_SetupShot_ProjectileSize(
424                 actor,
425                 weaponentity,
426                 '-4 -4 -4',
427                 '4 4 4',
428                 false,
429                 2,
430                 SND_ELECTRO_FIRE2,
431                 CH_WEAPON_A,
432                 WEP_CVAR_SEC(electro, damage),
433                 thiswep.m_id | HITTYPE_SECONDARY
434         );
435
436         w_shotdir = v_forward; // no TrueAim for grenades please
437
438         W_MuzzleFlash(thiswep, actor, weaponentity, w_shotorg, w_shotdir);
439
440         entity proj = new(electro_orb);
441         proj.owner = proj.realowner = actor;
442         proj.use = W_Electro_Explode_use;
443         setthink(proj, adaptor_think2use_hittype_splash);
444         proj.bot_dodge = true;
445         proj.bot_dodgerating = WEP_CVAR_SEC(electro, damage);
446         proj.nextthink = time + WEP_CVAR_SEC(electro, lifetime);
447         proj.death_time = time + WEP_CVAR_SEC(electro, lifetime);
448         PROJECTILE_MAKETRIGGER(proj);
449         proj.projectiledeathtype = thiswep.m_id | HITTYPE_SECONDARY;
450         proj.weaponentity_fld = weaponentity;
451         setorigin(proj, w_shotorg);
452
453         //proj.glow_size = 50;
454         //proj.glow_color = 45;
455         set_movetype(proj, MOVETYPE_BOUNCE);
456         W_SetupProjVelocity_UP_SEC(proj, electro);
457         settouch(proj, W_Electro_Orb_Touch);
458         setsize(proj, '-4 -4 -4', '4 4 4');
459         proj.takedamage = DAMAGE_YES;
460         proj.damageforcescale = WEP_CVAR_SEC(electro, damageforcescale);
461         SetResourceExplicit(proj, RES_HEALTH, WEP_CVAR_SEC(electro, health));
462         proj.event_damage = W_Electro_Orb_Damage;
463         proj.flags = FL_PROJECTILE;
464         IL_PUSH(g_projectiles, proj);
465         IL_PUSH(g_bot_dodge, proj);
466         proj.damagedbycontents = (WEP_CVAR_SEC(electro, damagedbycontents));
467         if(proj.damagedbycontents)
468                 IL_PUSH(g_damagedbycontents, proj);
469
470         proj.bouncefactor = WEP_CVAR_SEC(electro, bouncefactor);
471         proj.bouncestop = WEP_CVAR_SEC(electro, bouncestop);
472         proj.missile_flags = MIF_SPLASH | MIF_ARC;
473
474         if(WEP_CVAR_SEC(electro, limit) > 0)
475         {
476                 if (!LimitedElectroBallRubbleList)
477                         LimitedElectroBallRubbleList = IL_NEW();
478                 ListNewChildRubble(LimitedElectroBallRubbleList, proj);
479                 LimitedChildrenRubble(LimitedElectroBallRubbleList, "electro_orb", WEP_CVAR_SEC(electro, limit), adaptor_think2use_hittype_splash, actor);
480         }
481
482         CSQCProjectile(proj, true, PROJECTILE_ELECTRO, false); // no culling, it has sound
483
484         MUTATOR_CALLHOOK(EditProjectile, actor, proj);
485 }
486
487 void W_Electro_CheckAttack(Weapon thiswep, entity actor, .entity weaponentity, int fire)
488 {
489         if(actor.(weaponentity).electro_count > 1)
490         if(PHYS_INPUT_BUTTON_ATCK2(actor))
491         if(weapon_prepareattack(thiswep, actor, weaponentity, true, -1))
492         {
493                 W_Electro_Attack_Orb(thiswep, actor, weaponentity);
494                 actor.(weaponentity).electro_count -= 1;
495                 actor.(weaponentity).electro_secondarytime = time;
496                 weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, WEP_CVAR_SEC(electro, animtime), W_Electro_CheckAttack);
497                 return;
498         }
499         w_ready(thiswep, actor, weaponentity, fire);
500 }
501
502 .float bot_secondary_electromooth;
503
504 METHOD(Electro, wr_aim, void(entity thiswep, entity actor, .entity weaponentity))
505 {
506     PHYS_INPUT_BUTTON_ATCK(actor) = PHYS_INPUT_BUTTON_ATCK2(actor) = false;
507     if(vdist(actor.origin - actor.enemy.origin, >, 1000)) { actor.bot_secondary_electromooth = 0; }
508     if(actor.bot_secondary_electromooth == 0)
509     {
510         float shoot;
511
512         if(WEP_CVAR_PRI(electro, speed))
513             shoot = bot_aim(actor, weaponentity, WEP_CVAR_PRI(electro, speed), 0, WEP_CVAR_PRI(electro, lifetime), false, true);
514         else
515             shoot = bot_aim(actor, weaponentity, 1000000, 0, 0.001, false, true);
516
517         if(shoot)
518         {
519             PHYS_INPUT_BUTTON_ATCK(actor) = true;
520             if(random() < 0.01) actor.bot_secondary_electromooth = 1;
521         }
522     }
523     else
524     {
525         if(bot_aim(actor, weaponentity, WEP_CVAR_SEC(electro, speed), WEP_CVAR_SEC(electro, speed_up), WEP_CVAR_SEC(electro, lifetime), true, true))
526         {
527             PHYS_INPUT_BUTTON_ATCK2(actor) = true;
528             if(random() < 0.03) actor.bot_secondary_electromooth = 0;
529         }
530     }
531 }
532 METHOD(Electro, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire))
533 {
534     if(autocvar_g_balance_electro_reload_ammo) // forced reload // WEAPONTODO
535     {
536         float ammo_amount = 0;
537         if(actor.(weaponentity).clip_load >= WEP_CVAR_PRI(electro, ammo))
538             ammo_amount = 1;
539         if(actor.(weaponentity).clip_load >= WEP_CVAR_SEC(electro, ammo))
540             ammo_amount += 1;
541
542         if(!ammo_amount)
543         {
544             thiswep.wr_reload(thiswep, actor, weaponentity);
545             return;
546         }
547     }
548
549     if(fire & 1)
550     {
551         if(time >= actor.(weaponentity).electro_secondarytime + WEP_CVAR_SEC(electro, refire2) * W_WeaponRateFactor(actor))
552         if(weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR_PRI(electro, refire)))
553         {
554             W_Electro_Attack_Bolt(thiswep, actor, weaponentity);
555             weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(electro, animtime), w_ready);
556         }
557     }
558     else if(fire & 2)
559     {
560         if(time >= actor.(weaponentity).electro_secondarytime + WEP_CVAR_SEC(electro, refire) * W_WeaponRateFactor(actor))
561         if(weapon_prepareattack(thiswep, actor, weaponentity, true, -1))
562         {
563             W_Electro_Attack_Orb(thiswep, actor, weaponentity);
564             actor.(weaponentity).electro_count = WEP_CVAR_SEC(electro, count);
565             actor.(weaponentity).electro_secondarytime = time;
566             weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, WEP_CVAR_SEC(electro, animtime), W_Electro_CheckAttack);
567         }
568     }
569 }
570 METHOD(Electro, wr_checkammo1, bool(entity thiswep, entity actor, .entity weaponentity))
571 {
572     float ammo_amount = GetResource(actor, thiswep.ammo_type) >= WEP_CVAR_PRI(electro, ammo);
573     ammo_amount += actor.(weaponentity).(weapon_load[thiswep.m_id]) >= WEP_CVAR_PRI(electro, ammo);
574     return ammo_amount;
575 }
576 METHOD(Electro, wr_checkammo2, bool(entity thiswep, entity actor, .entity weaponentity))
577 {
578     float ammo_amount;
579     if(WEP_CVAR(electro, combo_safeammocheck)) // true if you can fire at least one secondary blob AND one primary shot after it, otherwise false.
580     {
581         ammo_amount = GetResource(actor, thiswep.ammo_type) >= WEP_CVAR_SEC(electro, ammo) + WEP_CVAR_PRI(electro, ammo);
582         ammo_amount += actor.(weaponentity).(weapon_load[thiswep.m_id]) >= WEP_CVAR_SEC(electro, ammo) + WEP_CVAR_PRI(electro, ammo);
583     }
584     else
585     {
586         ammo_amount = GetResource(actor, thiswep.ammo_type) >= WEP_CVAR_SEC(electro, ammo);
587         ammo_amount += actor.(weaponentity).(weapon_load[thiswep.m_id]) >= WEP_CVAR_SEC(electro, ammo);
588     }
589     return ammo_amount;
590 }
591 METHOD(Electro, wr_reload, void(entity thiswep, entity actor, .entity weaponentity))
592 {
593     W_Reload(actor, weaponentity, min(WEP_CVAR_PRI(electro, ammo), WEP_CVAR_SEC(electro, ammo)), SND_RELOAD);
594 }
595 METHOD(Electro, wr_suicidemessage, Notification(entity thiswep))
596 {
597     if(w_deathtype & HITTYPE_SECONDARY)
598         return WEAPON_ELECTRO_SUICIDE_ORBS;
599     else
600         return WEAPON_ELECTRO_SUICIDE_BOLT;
601 }
602 METHOD(Electro, wr_killmessage, Notification(entity thiswep))
603 {
604     if(w_deathtype & HITTYPE_SECONDARY)
605     {
606         return WEAPON_ELECTRO_MURDER_ORBS;
607     }
608     else
609     {
610         if(w_deathtype & HITTYPE_BOUNCE)
611             return WEAPON_ELECTRO_MURDER_COMBO;
612         else
613             return WEAPON_ELECTRO_MURDER_BOLT;
614     }
615 }
616
617 #endif
618 #ifdef CSQC
619
620 METHOD(Electro, wr_impacteffect, void(entity thiswep, entity actor))
621 {
622     vector org2 = w_org + w_backoff * 2;
623     if(w_deathtype & HITTYPE_SECONDARY)
624     {
625         pointparticles(EFFECT_ELECTRO_BALLEXPLODE, org2, '0 0 0', 1);
626         if(!w_issilent)
627             sound(actor, CH_SHOTS, SND_ELECTRO_IMPACT, VOL_BASE, ATTEN_NORM);
628     }
629     else
630     {
631         if(w_deathtype & HITTYPE_BOUNCE)
632         {
633             // this is sent as "primary (w_deathtype & HITTYPE_BOUNCE)" to distinguish it from (w_deathtype & HITTYPE_SECONDARY) bounced balls
634             pointparticles(EFFECT_ELECTRO_COMBO, org2, '0 0 0', 1);
635             if(!w_issilent)
636                 sound(actor, CH_SHOTS, SND_ELECTRO_IMPACT_COMBO, VOL_BASE, ATTEN_NORM);
637         }
638         else
639         {
640             pointparticles(EFFECT_ELECTRO_IMPACT, org2, '0 0 0', 1);
641             if(!w_issilent)
642                 sound(actor, CH_SHOTS, SND_ELECTRO_IMPACT, VOL_BASE, ATTEN_NORM);
643         }
644     }
645 }
646
647 #endif