3 /* WEP_##id */ ELECTRO,
4 /* function */ W_Electro,
5 /* ammotype */ ammo_cells,
7 /* flags */ WEP_FLAG_NORMAL | WEP_FLAG_RELOADABLE | WEP_TYPE_SPLASH,
8 /* rating */ BOT_PICKUP_RATING_MID,
10 /* netname */ "electro",
11 /* fullname */ _("Electro")
14 #define ELECTRO_SETTINGS(w_cvar,w_prop) ELECTRO_SETTINGS_LIST(w_cvar, w_prop, ELECTRO, electro)
15 #define ELECTRO_SETTINGS_LIST(w_cvar,w_prop,id,sn) \
16 w_cvar(id, sn, MO_BOTH, ammo) \
17 w_cvar(id, sn, MO_BOTH, animtime) \
18 w_cvar(id, sn, MO_BOTH, damage) \
19 w_cvar(id, sn, MO_BOTH, edgedamage) \
20 w_cvar(id, sn, MO_BOTH, force) \
21 w_cvar(id, sn, MO_BOTH, radius) \
22 w_cvar(id, sn, MO_BOTH, refire) \
23 w_cvar(id, sn, MO_BOTH, speed) \
24 w_cvar(id, sn, MO_BOTH, spread) \
25 w_cvar(id, sn, MO_BOTH, lifetime) \
26 w_cvar(id, sn, MO_PRI, comboradius) \
27 w_cvar(id, sn, MO_PRI, midaircombo_explode) \
28 w_cvar(id, sn, MO_PRI, midaircombo_interval) \
29 w_cvar(id, sn, MO_PRI, midaircombo_radius) \
30 w_cvar(id, sn, MO_SEC, bouncefactor) \
31 w_cvar(id, sn, MO_SEC, bouncestop) \
32 w_cvar(id, sn, MO_SEC, count) \
33 w_cvar(id, sn, MO_SEC, damageforcescale) \
34 w_cvar(id, sn, MO_SEC, damagedbycontents) \
35 w_cvar(id, sn, MO_SEC, health) \
36 w_cvar(id, sn, MO_SEC, refire2) \
37 w_cvar(id, sn, MO_SEC, speed_up) \
38 w_cvar(id, sn, MO_SEC, speed_z) \
39 w_cvar(id, sn, MO_SEC, touchexplode) \
40 w_cvar(id, sn, MO_NONE, combo_comboradius) \
41 w_cvar(id, sn, MO_NONE, combo_comboradius_thruwall) \
42 w_cvar(id, sn, MO_NONE, combo_damage) \
43 w_cvar(id, sn, MO_NONE, combo_edgedamage) \
44 w_cvar(id, sn, MO_NONE, combo_force) \
45 w_cvar(id, sn, MO_NONE, combo_radius) \
46 w_cvar(id, sn, MO_NONE, combo_speed) \
47 w_cvar(id, sn, MO_NONE, combo_safeammocheck) \
48 w_prop(id, sn, float, reloading_ammo, reload_ammo) \
49 w_prop(id, sn, float, reloading_time, reload_time) \
50 w_prop(id, sn, float, switchdelay_raise, switchdelay_raise) \
51 w_prop(id, sn, float, switchdelay_drop, switchdelay_drop) \
52 w_prop(id, sn, string, weaponreplace, weaponreplace) \
53 w_prop(id, sn, float, weaponstart, weaponstart) \
54 w_prop(id, sn, float, weaponstartoverride, weaponstartoverride)
57 ELECTRO_SETTINGS(WEP_ADD_CVAR, WEP_ADD_PROP)
59 .float electro_secondarytime;
60 void W_Plasma_Explode_Combo(void);
64 void spawnfunc_weapon_electro() { weapon_defaultspawnfunc(WEP_ELECTRO); }
66 void W_Plasma_TriggerCombo(vector org, float rad, entity own)
68 entity e = WarpZone_FindRadius(org, rad, !WEP_CVAR(electro, combo_comboradius_thruwall));
71 if(e.classname == "plasma")
73 // do we allow thruwall triggering?
74 if(WEP_CVAR(electro, combo_comboradius_thruwall))
76 // if distance is greater than thruwall distance, check to make sure it's not through a wall
77 if(vlen(e.WarpZone_findradius_dist) > WEP_CVAR(electro, combo_comboradius_thruwall))
79 WarpZone_TraceLine(org, e.origin, MOVE_NOMONSTERS, e);
80 if(trace_fraction != 1)
82 // trigger is through a wall and outside of thruwall range, abort
89 // change owner to whoever caused the combo explosion
91 e.takedamage = DAMAGE_NO;
92 e.classname = "plasma_chain";
94 // now set the next one to trigger as well
95 e.think = W_Plasma_Explode_Combo;
97 // delay combo chains, looks cooler
102 (WEP_CVAR(electro, combo_speed) ?
103 (vlen(e.WarpZone_findradius_dist) / WEP_CVAR(electro, combo_speed))
113 void W_Plasma_Explode(void)
115 if(other.takedamage == DAMAGE_AIM)
117 if(DIFF_TEAM(self.realowner, other))
118 if(other.deadflag == DEAD_NO)
120 Send_Notification(NOTIF_ONE, self.realowner, MSG_ANNCE, ANNCE_ACHIEVEMENT_ELECTROBITCH);
122 self.event_damage = func_null;
123 self.takedamage = DAMAGE_NO;
125 if(self.movetype == MOVETYPE_BOUNCE)
130 WEP_CVAR_SEC(electro, damage),
131 WEP_CVAR_SEC(electro, edgedamage),
132 WEP_CVAR_SEC(electro, radius),
135 WEP_CVAR_SEC(electro, force),
136 self.projectiledeathtype,
142 W_Plasma_TriggerCombo(self.origin, WEP_CVAR_PRI(electro, comboradius), self.realowner);
146 WEP_CVAR_PRI(electro, damage),
147 WEP_CVAR_PRI(electro, edgedamage),
148 WEP_CVAR_PRI(electro, radius),
151 WEP_CVAR_PRI(electro, force),
152 self.projectiledeathtype,
160 void W_Plasma_Explode_Combo(void)
162 W_Plasma_TriggerCombo(self.origin, WEP_CVAR(electro, combo_comboradius), self.realowner);
164 self.event_damage = func_null;
169 WEP_CVAR(electro, combo_damage),
170 WEP_CVAR(electro, combo_edgedamage),
171 WEP_CVAR(electro, combo_radius),
174 WEP_CVAR(electro, combo_force),
175 WEP_ELECTRO | HITTYPE_BOUNCE, // use THIS type for a combo because primary can't bounce
182 void W_Plasma_Touch(void)
185 if(other.takedamage == DAMAGE_AIM)
186 { if(WEP_CVAR_SEC(electro, touchexplode)) { W_Plasma_Explode(); } }
189 //UpdateCSQCProjectile(self);
190 spamsound(self, CH_SHOTS, "weapons/electro_bounce.wav", VOL_BASE, ATTEN_NORM);
191 self.projectiledeathtype |= HITTYPE_BOUNCE;
195 void W_Plasma_TouchExplode(void)
201 void W_Plasma_Damage(entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
206 // note: combos are usually triggered by W_Plasma_TriggerCombo, not damage
207 float is_combo = (inflictor.classname == "plasma_chain" || inflictor.classname == "plasma_prim");
209 if(!W_CheckProjectileDamage(inflictor.realowner, self.realowner, deathtype, (is_combo ? 1 : -1)))
210 return; // g_projectiles_damage says to halt
212 self.health = self.health - damage;
215 self.takedamage = DAMAGE_NO;
216 self.nextthink = time;
219 // change owner to whoever caused the combo explosion
220 self.realowner = inflictor.realowner;
221 self.classname = "plasma_chain";
222 self.think = W_Plasma_Explode_Combo;
223 self.nextthink = time +
225 // bound the length, inflictor may be in a galaxy far far away (warpzones)
227 WEP_CVAR(electro, combo_radius),
228 vlen(self.origin - inflictor.origin)
231 // delay combo chains, looks cooler
232 WEP_CVAR(electro, combo_speed)
237 self.use = W_Plasma_Explode;
238 self.think = adaptor_think2use; // not _hittype_splash, as this runs "immediately"
243 void W_Plasma_Think()
245 if(time >= self.ltime)
251 if(WEP_CVAR_PRI(electro, midaircombo_radius))
254 entity e = WarpZone_FindRadius(self.origin, WEP_CVAR_PRI(electro, midaircombo_radius), TRUE);
256 // loop through nearby orbs and trigger them
259 if(e.classname == "plasma")
261 // change owner to whoever caused the combo explosion
262 e.realowner = self.realowner;
263 e.takedamage = DAMAGE_NO;
264 e.classname = "plasma_chain";
266 // now set the next one to trigger as well
267 e.think = W_Plasma_Explode_Combo;
269 // delay combo chains, looks cooler
274 (WEP_CVAR(electro, combo_speed) ?
275 (vlen(e.WarpZone_findradius_dist) / WEP_CVAR(electro, combo_speed))
286 // if we triggered an orb, should we explode? if not, lets try again next time
287 if(found && WEP_CVAR_PRI(electro, midaircombo_explode))
290 { self.nextthink = min(time + WEP_CVAR_PRI(electro, midaircombo_interval), self.ltime); }
292 else { self.nextthink = self.ltime; }
295 void W_Electro_Attack_Bolt(void)
299 W_DecreaseAmmo(ammo_cells, WEP_CVAR_PRI(electro, ammo), autocvar_g_balance_electro_reload_ammo);//weapontodo
301 W_SetupShot_ProjectileSize(self, '0 0 -3', '0 0 -3', FALSE, 2, "weapons/electro_fire.wav", CH_WEAPON_A, WEP_CVAR_PRI(electro, damage));
303 pointparticles(particleeffectnum("electro_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
306 proj.classname = "plasma_prim";
307 proj.owner = proj.realowner = self;
308 proj.bot_dodge = TRUE;
309 proj.bot_dodgerating = WEP_CVAR_PRI(electro, damage);
310 proj.use = W_Plasma_Explode;
311 proj.think = W_Plasma_Think;
312 proj.nextthink = time;
313 proj.ltime = time + WEP_CVAR_PRI(electro, lifetime);
314 PROJECTILE_MAKETRIGGER(proj);
315 proj.projectiledeathtype = WEP_ELECTRO;
316 setorigin(proj, w_shotorg);
318 proj.movetype = MOVETYPE_FLY;
319 WEP_SETUPPROJVELOCITY_PRI(proj, electro);
320 proj.angles = vectoangles(proj.velocity);
321 proj.touch = W_Plasma_TouchExplode;
322 setsize(proj, '0 0 -3', '0 0 -3');
323 proj.flags = FL_PROJECTILE;
324 proj.missile_flags = MIF_SPLASH;
326 CSQCProjectile(proj, TRUE, PROJECTILE_ELECTRO_BEAM, TRUE);
328 other = proj; MUTATOR_CALLHOOK(EditProjectile);
331 void W_Electro_Attack_Orbs(void)
333 W_DecreaseAmmo(ammo_cells, WEP_CVAR_SEC(electro, ammo), autocvar_g_balance_electro_reload_ammo);//weapontodo
335 W_SetupShot_ProjectileSize(self, '0 0 -4', '0 0 -4', FALSE, 2, "weapons/electro_fire2.wav", CH_WEAPON_A, WEP_CVAR_SEC(electro, damage));
337 w_shotdir = v_forward; // no TrueAim for grenades please
339 pointparticles(particleeffectnum("electro_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
341 entity proj = spawn();
342 proj.classname = "plasma";
343 proj.owner = proj.realowner = self;
344 proj.use = W_Plasma_Explode;
345 proj.think = adaptor_think2use_hittype_splash;
346 proj.bot_dodge = TRUE;
347 proj.bot_dodgerating = WEP_CVAR_SEC(electro, damage);
348 proj.nextthink = time + WEP_CVAR_SEC(electro, lifetime);
349 PROJECTILE_MAKETRIGGER(proj);
350 proj.projectiledeathtype = WEP_ELECTRO | HITTYPE_SECONDARY;
351 setorigin(proj, w_shotorg);
353 //proj.glow_size = 50;
354 //proj.glow_color = 45;
355 proj.movetype = MOVETYPE_BOUNCE;
356 WEP_SETUPPROJVELOCITY_UP_SEC(proj, electro);
357 proj.touch = W_Plasma_Touch;
358 setsize(proj, '0 0 -4', '0 0 -4');
359 proj.takedamage = DAMAGE_YES;
360 proj.damageforcescale = WEP_CVAR_SEC(electro, damageforcescale);
361 proj.health = WEP_CVAR_SEC(electro, health);
362 proj.event_damage = W_Plasma_Damage;
363 proj.flags = FL_PROJECTILE;
364 proj.damagedbycontents = (WEP_CVAR_SEC(electro, damagedbycontents));
366 proj.bouncefactor = WEP_CVAR_SEC(electro, bouncefactor);
367 proj.bouncestop = WEP_CVAR_SEC(electro, bouncestop);
368 proj.missile_flags = MIF_SPLASH | MIF_ARC;
373 copyentity(proj, p2);
374 setmodel(p2, "models/ebomb.mdl");
375 setsize(p2, proj.mins, proj.maxs);
378 CSQCProjectile(proj, TRUE, PROJECTILE_ELECTRO, FALSE); // no culling, it has sound
380 other = proj; MUTATOR_CALLHOOK(EditProjectile);
383 void W_Electro_CheckAttack()
385 if(self.electro_count > 1)
386 if(self.BUTTON_ATCK2)
387 if(weapon_prepareattack(1, -1))
389 W_Electro_Attack_Orbs();
390 self.electro_count -= 1;
391 weapon_thinkf(WFRAME_FIRE2, WEP_CVAR_SEC(electro, animtime), W_Electro_CheckAttack);
397 .float bot_secondary_electromooth;
398 float W_Electro(float req)
405 self.BUTTON_ATCK = self.BUTTON_ATCK2 = FALSE;
406 if(vlen(self.origin-self.enemy.origin) > 1000) { self.bot_secondary_electromooth = 0; }
407 if(self.bot_secondary_electromooth == 0)
411 if(WEP_CVAR_PRI(electro, speed))
412 shoot = bot_aim(WEP_CVAR_PRI(electro, speed), 0, WEP_CVAR_PRI(electro, lifetime), FALSE);
414 shoot = bot_aim(1000000, 0, 0.001, FALSE);
418 self.BUTTON_ATCK = TRUE;
419 if(random() < 0.01) self.bot_secondary_electromooth = 1;
424 if(bot_aim(WEP_CVAR_SEC(electro, speed), WEP_CVAR_SEC(electro, speed_up), WEP_CVAR_SEC(electro, lifetime), TRUE))
426 self.BUTTON_ATCK2 = TRUE;
427 if(random() < 0.03) self.bot_secondary_electromooth = 0;
435 if(autocvar_g_balance_electro_reload_ammo) // forced reload // WEAPONTODO
438 if(self.clip_load >= WEP_CVAR_PRI(electro, ammo))
440 if(self.clip_load >= WEP_CVAR_SEC(electro, ammo))
445 WEP_ACTION(self.weapon, WR_RELOAD);
454 if(weapon_prepareattack(0, WEP_CVAR_PRI(electro, refire)))
456 W_Electro_Attack_Bolt();
457 weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_PRI(electro, animtime), w_ready);
460 else if(self.BUTTON_ATCK2)
462 if(time >= self.electro_secondarytime)
463 if(weapon_prepareattack(1, WEP_CVAR_SEC(electro, refire)))
465 W_Electro_Attack_Orbs();
466 self.electro_count = WEP_CVAR_SEC(electro, count);
467 weapon_thinkf(WFRAME_FIRE2, WEP_CVAR_SEC(electro, animtime), W_Electro_CheckAttack);
468 self.electro_secondarytime = time + WEP_CVAR_SEC(electro, refire2) * W_WeaponRateFactor();
476 precache_model("models/weapons/g_electro.md3");
477 precache_model("models/weapons/v_electro.md3");
478 precache_model("models/weapons/h_electro.iqm");
479 precache_sound("weapons/electro_bounce.wav");
480 precache_sound("weapons/electro_fire.wav");
481 precache_sound("weapons/electro_fire2.wav");
482 precache_sound("weapons/electro_impact.wav");
483 precache_sound("weapons/electro_impact_combo.wav");
484 ELECTRO_SETTINGS(WEP_SKIPCVAR, WEP_SET_PROP)
489 self.current_ammo = ammo_cells;
494 ammo_amount = self.ammo_cells >= WEP_CVAR_PRI(electro, ammo);
495 ammo_amount += self.(weapon_load[WEP_ELECTRO]) >= WEP_CVAR_PRI(electro, ammo);
500 if(WEP_CVAR(electro, combo_safeammocheck)) // true if you can fire at least one secondary blob AND one primary shot after it, otherwise false.
502 ammo_amount = self.ammo_cells >= WEP_CVAR_SEC(electro, ammo) + WEP_CVAR_PRI(electro, ammo);
503 ammo_amount += self.(weapon_load[WEP_ELECTRO]) >= WEP_CVAR_SEC(electro, ammo) + WEP_CVAR_PRI(electro, ammo);
507 ammo_amount = self.ammo_cells >= WEP_CVAR_SEC(electro, ammo);
508 ammo_amount += self.(weapon_load[WEP_ELECTRO]) >= WEP_CVAR_SEC(electro, ammo);
514 ELECTRO_SETTINGS(WEP_CONFIG_WRITE_CVARS, WEP_CONFIG_WRITE_PROPS)
519 self.electro_secondarytime = time;
524 W_Reload(min(WEP_CVAR_PRI(electro, ammo), WEP_CVAR_SEC(electro, ammo)), "weapons/reload.wav");
527 case WR_SUICIDEMESSAGE:
529 if(w_deathtype & HITTYPE_SECONDARY)
530 return WEAPON_ELECTRO_SUICIDE_ORBS;
532 return WEAPON_ELECTRO_SUICIDE_BOLT;
536 if(w_deathtype & HITTYPE_SECONDARY)
538 return WEAPON_ELECTRO_MURDER_ORBS;
542 if(w_deathtype & HITTYPE_BOUNCE)
543 return WEAPON_ELECTRO_MURDER_COMBO;
545 return WEAPON_ELECTRO_MURDER_BOLT;
553 float W_Electro(float req)
557 case WR_IMPACTEFFECT:
560 org2 = w_org + w_backoff * 6;
561 if(w_deathtype & HITTYPE_SECONDARY)
563 pointparticles(particleeffectnum("electro_ballexplode"), org2, '0 0 0', 1);
565 sound(self, CH_SHOTS, "weapons/electro_impact.wav", VOL_BASE, ATTEN_NORM);
569 if(w_deathtype & HITTYPE_BOUNCE)
571 // this is sent as "primary (w_deathtype & HITTYPE_BOUNCE)" to distinguish it from (w_deathtype & HITTYPE_SECONDARY) bounced balls
572 pointparticles(particleeffectnum("electro_combo"), org2, '0 0 0', 1);
574 sound(self, CH_SHOTS, "weapons/electro_impact_combo.wav", VOL_BASE, ATTEN_NORM);
578 pointparticles(particleeffectnum("electro_impact"), org2, '0 0 0', 1);
580 sound(self, CH_SHOTS, "weapons/electro_impact.wav", VOL_BASE, ATTEN_NORM);
588 precache_sound("weapons/electro_impact.wav");
589 precache_sound("weapons/electro_impact_combo.wav");