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