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