]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/weapons/weapon/electro.qc
weapon independency fixes
[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; // particle fx and decals need .velocity
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; // particle fx and decals need .velocity
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         setorigin(newproj, this.origin);
309         setmodel(newproj, MDL_PROJECTILE_ELECTRO);
310         setsize(newproj, this.mins, this.maxs);
311         newproj.angles = vectoangles(-trace_plane_normal); // face against the surface
312         newproj.traileffectnum = _particleeffectnum(EFFECT_TR_NEXUIZPLASMA.eent_eff_name);
313
314         newproj.movedir = -trace_plane_normal;
315
316         newproj.takedamage = this.takedamage;
317         newproj.damageforcescale = this.damageforcescale;
318         SetResourceExplicit(newproj, RES_HEALTH, GetResource(this, RES_HEALTH));
319         newproj.event_damage = this.event_damage;
320         newproj.spawnshieldtime = this.spawnshieldtime;
321         newproj.damagedbycontents = true;
322         IL_PUSH(g_damagedbycontents, newproj);
323
324         set_movetype(newproj, MOVETYPE_NONE); // lock the orb in place
325         newproj.projectiledeathtype = this.projectiledeathtype;
326         newproj.weaponentity_fld = this.weaponentity_fld;
327
328         settouch(newproj, func_null);
329         if(WEP_CVAR_SEC(electro, stick_lifetime) > 0){
330                 newproj.death_time = time + WEP_CVAR_SEC(electro, stick_lifetime);
331         }else{
332                 newproj.death_time = this.death_time;
333         }
334         newproj.use = this.use;
335         newproj.flags = this.flags;
336         IL_PUSH(g_projectiles, newproj);
337         IL_PUSH(g_bot_dodge, newproj);
338
339         // check if limits are enabled (we can tell by checking if the original orb is listed) and push it to the list if so
340         if(LimitedElectroBallRubbleList && IL_CONTAINS(LimitedElectroBallRubbleList, this))
341         {
342                 ReplaceOldListedChildRubble(LimitedElectroBallRubbleList, newproj, this);
343         }
344
345         delete(this);
346
347         if(to)
348         {
349                 SetMovetypeFollow(newproj, to);
350
351                 setthink(newproj, W_Electro_Orb_Follow_Think);
352                 newproj.nextthink = time;
353         }
354         else
355         {
356                 setthink(newproj, adaptor_think2use_hittype_splash);
357                 newproj.nextthink = newproj.death_time;
358         }
359 }
360
361 void W_Electro_Orb_Touch(entity this, entity toucher)
362 {
363         PROJECTILE_TOUCH(this, toucher);
364         if(toucher.takedamage == DAMAGE_AIM && WEP_CVAR_SEC(electro, touchexplode))
365                 { W_Electro_Explode(this, toucher); }
366         else if(toucher.owner != this.owner && toucher.classname != this.classname) // don't stick to player's other projectiles!
367         {
368                 //UpdateCSQCProjectile(this);
369                 spamsound(this, CH_SHOTS, SND_ELECTRO_BOUNCE, VOL_BASE, ATTEN_NORM);
370                 this.projectiledeathtype |= HITTYPE_BOUNCE;
371
372                 if(WEP_CVAR_SEC(electro, stick)){
373                         if(WEP_CVAR_SEC(electro, stick_lifetime) == 0){
374                                 W_Electro_Explode(this, toucher);
375                         } else {
376                                 W_Electro_Orb_Stick(this, toucher);
377                         }
378                 }
379         }
380 }
381
382 void W_Electro_Orb_Damage(entity this, entity inflictor, entity attacker, float damage, int deathtype, .entity weaponentity, vector hitloc, vector force)
383 {
384         if(GetResource(this, RES_HEALTH) <= 0)
385                 return;
386
387         // note: combos are usually triggered by W_Electro_TriggerCombo, not damage
388         float is_combo = (inflictor.classname == "electro_orb_chain" || inflictor.classname == "electro_bolt");
389
390         if(!W_CheckProjectileDamage(inflictor.realowner, this.realowner, deathtype, (is_combo ? 1 : -1)))
391                 return; // g_projectiles_damage says to halt
392
393         TakeResource(this, RES_HEALTH, damage);
394         if(GetResource(this, RES_HEALTH) <= 0)
395         {
396                 this.takedamage = DAMAGE_NO;
397                 this.nextthink = time;
398                 if(is_combo)
399                 {
400                         // change owner to whoever caused the combo explosion
401                         this.realowner = inflictor.realowner;
402                         this.classname = "electro_orb_chain";
403                         setthink(this, W_Electro_ExplodeCombo);
404                         // delay combo chains, looks cooler
405                         // bound the length, inflictor may be in a galaxy far far away (warpzones)
406                         float len = min(WEP_CVAR(electro, combo_radius), vlen(this.origin - inflictor.origin));
407                         float delay = len / WEP_CVAR(electro, combo_speed);
408                         this.nextthink = time + delay;
409                 }
410                 else
411                 {
412                         this.use = W_Electro_Explode_use;
413                         setthink(this, adaptor_think2use); // not _hittype_splash, as this runs "immediately"
414                 }
415         }
416 }
417
418 void W_Electro_Attack_Orb(Weapon thiswep, entity actor, .entity weaponentity)
419 {
420         W_DecreaseAmmo(thiswep, actor, WEP_CVAR_SEC(electro, ammo), weaponentity);
421
422         W_SetupShot_ProjectileSize(
423                 actor,
424                 weaponentity,
425                 '-4 -4 -4',
426                 '4 4 4',
427                 false,
428                 2,
429                 SND_ELECTRO_FIRE2,
430                 CH_WEAPON_A,
431                 WEP_CVAR_SEC(electro, damage),
432                 thiswep.m_id | HITTYPE_SECONDARY
433         );
434
435         w_shotdir = v_forward; // no TrueAim for grenades please
436
437         W_MuzzleFlash(thiswep, actor, weaponentity, w_shotorg, w_shotdir);
438
439         entity proj = new(electro_orb);
440         proj.owner = proj.realowner = actor;
441         proj.use = W_Electro_Explode_use;
442         setthink(proj, adaptor_think2use_hittype_splash);
443         proj.bot_dodge = true;
444         proj.bot_dodgerating = WEP_CVAR_SEC(electro, damage);
445         proj.nextthink = time + WEP_CVAR_SEC(electro, lifetime);
446         proj.death_time = time + WEP_CVAR_SEC(electro, lifetime);
447         PROJECTILE_MAKETRIGGER(proj);
448         proj.projectiledeathtype = thiswep.m_id | HITTYPE_SECONDARY;
449         proj.weaponentity_fld = weaponentity;
450         setorigin(proj, w_shotorg);
451
452         //proj.glow_size = 50;
453         //proj.glow_color = 45;
454         set_movetype(proj, MOVETYPE_BOUNCE);
455         W_SetupProjVelocity_UP_SEC(proj, electro);
456         settouch(proj, W_Electro_Orb_Touch);
457         setsize(proj, '-4 -4 -4', '4 4 4');
458         proj.takedamage = DAMAGE_YES;
459         proj.damageforcescale = WEP_CVAR_SEC(electro, damageforcescale);
460         SetResourceExplicit(proj, RES_HEALTH, WEP_CVAR_SEC(electro, health));
461         proj.event_damage = W_Electro_Orb_Damage;
462         proj.flags = FL_PROJECTILE;
463         IL_PUSH(g_projectiles, proj);
464         IL_PUSH(g_bot_dodge, proj);
465         proj.damagedbycontents = (WEP_CVAR_SEC(electro, damagedbycontents));
466         if(proj.damagedbycontents)
467                 IL_PUSH(g_damagedbycontents, proj);
468
469         proj.bouncefactor = WEP_CVAR_SEC(electro, bouncefactor);
470         proj.bouncestop = WEP_CVAR_SEC(electro, bouncestop);
471         proj.missile_flags = MIF_SPLASH | MIF_ARC;
472
473         if(WEP_CVAR_SEC(electro, limit) > 0)
474         {
475                 if (!LimitedElectroBallRubbleList)
476                         LimitedElectroBallRubbleList = IL_NEW();
477                 ListNewChildRubble(LimitedElectroBallRubbleList, proj);
478                 LimitedChildrenRubble(LimitedElectroBallRubbleList, "electro_orb", WEP_CVAR_SEC(electro, limit), adaptor_think2use_hittype_splash, actor);
479         }
480
481         CSQCProjectile(proj, true, PROJECTILE_ELECTRO, false); // no culling, it has sound
482
483         MUTATOR_CALLHOOK(EditProjectile, actor, proj);
484 }
485
486 void W_Electro_CheckAttack(Weapon thiswep, entity actor, .entity weaponentity, int fire)
487 {
488         if(actor.(weaponentity).electro_count > 1)
489         if(PHYS_INPUT_BUTTON_ATCK2(actor))
490         if(weapon_prepareattack(thiswep, actor, weaponentity, true, -1))
491         {
492                 W_Electro_Attack_Orb(thiswep, actor, weaponentity);
493                 actor.(weaponentity).electro_count -= 1;
494                 actor.(weaponentity).electro_secondarytime = time;
495                 weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, WEP_CVAR_SEC(electro, animtime), W_Electro_CheckAttack);
496                 return;
497         }
498         w_ready(thiswep, actor, weaponentity, fire);
499 }
500
501 .float bot_secondary_electromooth;
502
503 METHOD(Electro, wr_aim, void(entity thiswep, entity actor, .entity weaponentity))
504 {
505     PHYS_INPUT_BUTTON_ATCK(actor) = PHYS_INPUT_BUTTON_ATCK2(actor) = false;
506     if(vdist(actor.origin - actor.enemy.origin, >, 1000)) { actor.bot_secondary_electromooth = 0; }
507     if(actor.bot_secondary_electromooth == 0)
508     {
509         float shoot;
510
511         if(WEP_CVAR_PRI(electro, speed))
512             shoot = bot_aim(actor, weaponentity, WEP_CVAR_PRI(electro, speed), 0, WEP_CVAR_PRI(electro, lifetime), false);
513         else
514             shoot = bot_aim(actor, weaponentity, 1000000, 0, 0.001, false);
515
516         if(shoot)
517         {
518             PHYS_INPUT_BUTTON_ATCK(actor) = true;
519             if(random() < 0.01) actor.bot_secondary_electromooth = 1;
520         }
521     }
522     else
523     {
524         if(bot_aim(actor, weaponentity, WEP_CVAR_SEC(electro, speed), WEP_CVAR_SEC(electro, speed_up), WEP_CVAR_SEC(electro, lifetime), true))
525         {
526             PHYS_INPUT_BUTTON_ATCK2(actor) = true;
527             if(random() < 0.03) actor.bot_secondary_electromooth = 0;
528         }
529     }
530 }
531 METHOD(Electro, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire))
532 {
533     if(autocvar_g_balance_electro_reload_ammo) // forced reload // WEAPONTODO
534     {
535         float ammo_amount = 0;
536         if(actor.(weaponentity).clip_load >= WEP_CVAR_PRI(electro, ammo))
537             ammo_amount = 1;
538         if(actor.(weaponentity).clip_load >= WEP_CVAR_SEC(electro, ammo))
539             ammo_amount += 1;
540
541         if(!ammo_amount)
542         {
543             thiswep.wr_reload(thiswep, actor, weaponentity);
544             return;
545         }
546     }
547
548     if(fire & 1)
549     {
550         if(time >= actor.(weaponentity).electro_secondarytime + WEP_CVAR_SEC(electro, refire2) * W_WeaponRateFactor(actor))
551         if(weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR_PRI(electro, refire)))
552         {
553             W_Electro_Attack_Bolt(thiswep, actor, weaponentity);
554             weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(electro, animtime), w_ready);
555         }
556     }
557     else if(fire & 2)
558     {
559         if(time >= actor.(weaponentity).electro_secondarytime + WEP_CVAR_SEC(electro, refire) * W_WeaponRateFactor(actor))
560         if(weapon_prepareattack(thiswep, actor, weaponentity, true, -1))
561         {
562             W_Electro_Attack_Orb(thiswep, actor, weaponentity);
563             actor.(weaponentity).electro_count = WEP_CVAR_SEC(electro, count);
564             actor.(weaponentity).electro_secondarytime = time;
565             weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, WEP_CVAR_SEC(electro, animtime), W_Electro_CheckAttack);
566         }
567     }
568 }
569 METHOD(Electro, wr_checkammo1, bool(entity thiswep, entity actor, .entity weaponentity))
570 {
571     float ammo_amount = GetResource(actor, thiswep.ammo_type) >= WEP_CVAR_PRI(electro, ammo);
572     ammo_amount += actor.(weaponentity).(weapon_load[thiswep.m_id]) >= WEP_CVAR_PRI(electro, ammo);
573     return ammo_amount;
574 }
575 METHOD(Electro, wr_checkammo2, bool(entity thiswep, entity actor, .entity weaponentity))
576 {
577     float ammo_amount;
578     if(WEP_CVAR(electro, combo_safeammocheck)) // true if you can fire at least one secondary blob AND one primary shot after it, otherwise false.
579     {
580         ammo_amount = GetResource(actor, thiswep.ammo_type) >= WEP_CVAR_SEC(electro, ammo) + WEP_CVAR_PRI(electro, ammo);
581         ammo_amount += actor.(weaponentity).(weapon_load[thiswep.m_id]) >= WEP_CVAR_SEC(electro, ammo) + WEP_CVAR_PRI(electro, ammo);
582     }
583     else
584     {
585         ammo_amount = GetResource(actor, thiswep.ammo_type) >= WEP_CVAR_SEC(electro, ammo);
586         ammo_amount += actor.(weaponentity).(weapon_load[thiswep.m_id]) >= WEP_CVAR_SEC(electro, ammo);
587     }
588     return ammo_amount;
589 }
590 METHOD(Electro, wr_reload, void(entity thiswep, entity actor, .entity weaponentity))
591 {
592     W_Reload(actor, weaponentity, min(WEP_CVAR_PRI(electro, ammo), WEP_CVAR_SEC(electro, ammo)), SND_RELOAD);
593 }
594 METHOD(Electro, wr_suicidemessage, Notification(entity thiswep))
595 {
596     if(w_deathtype & HITTYPE_SECONDARY)
597         return WEAPON_ELECTRO_SUICIDE_ORBS;
598     else
599         return WEAPON_ELECTRO_SUICIDE_BOLT;
600 }
601 METHOD(Electro, wr_killmessage, Notification(entity thiswep))
602 {
603     if(w_deathtype & HITTYPE_SECONDARY)
604     {
605         return WEAPON_ELECTRO_MURDER_ORBS;
606     }
607     else
608     {
609         if(w_deathtype & HITTYPE_BOUNCE)
610             return WEAPON_ELECTRO_MURDER_COMBO;
611         else
612             return WEAPON_ELECTRO_MURDER_BOLT;
613     }
614 }
615
616 #endif
617 #ifdef CSQC
618
619 METHOD(Electro, wr_impacteffect, void(entity thiswep, entity actor))
620 {
621     vector org2;
622     org2 = w_org + w_backoff * 6;
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