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, BOTH, ammo) \
17 w_cvar(id, sn, BOTH, animtime) \
18 w_cvar(id, sn, BOTH, damage) \
19 w_cvar(id, sn, BOTH, edgedamage) \
20 w_cvar(id, sn, BOTH, force) \
21 w_cvar(id, sn, BOTH, radius) \
22 w_cvar(id, sn, BOTH, refire) \
23 w_cvar(id, sn, BOTH, speed) \
24 w_cvar(id, sn, BOTH, spread) \
25 w_cvar(id, sn, BOTH, lifetime) \
26 w_cvar(id, sn, PRI, comboradius) \
27 w_cvar(id, sn, PRI, midaircombo_explode) \
28 w_cvar(id, sn, PRI, midaircombo_interval) \
29 w_cvar(id, sn, PRI, midaircombo_radius) \
30 w_cvar(id, sn, SEC, bouncefactor) \
31 w_cvar(id, sn, SEC, bouncestop) \
32 w_cvar(id, sn, SEC, count) \
33 w_cvar(id, sn, SEC, damageforcescale) \
34 w_cvar(id, sn, SEC, damagedbycontents) \
35 w_cvar(id, sn, SEC, health) \
36 w_cvar(id, sn, SEC, refire2) \
37 w_cvar(id, sn, SEC, speed_up) \
38 w_cvar(id, sn, SEC, speed_z) \
39 w_cvar(id, sn, SEC, touchexplode) \
40 w_cvar(id, sn, NONE, combo_comboradius) \
41 w_cvar(id, sn, NONE, combo_comboradius_thruwall) \
42 w_cvar(id, sn, NONE, combo_damage) \
43 w_cvar(id, sn, NONE, combo_edgedamage) \
44 w_cvar(id, sn, NONE, combo_force) \
45 w_cvar(id, sn, NONE, combo_radius) \
46 w_cvar(id, sn, NONE, combo_speed) \
47 w_cvar(id, sn, 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_Electro_ExplodeCombo(void);
64 void spawnfunc_weapon_electro() { weapon_defaultspawnfunc(WEP_ELECTRO); }
66 void W_Electro_TriggerCombo(vector org, float rad, entity own)
68 entity e = WarpZone_FindRadius(org, rad, !WEP_CVAR(electro, combo_comboradius_thruwall));
71 if(e.classname == "electro_orb")
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 = "electro_orb_chain";
94 // now set the next one to trigger as well
95 e.think = W_Electro_ExplodeCombo;
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_Electro_ExplodeCombo(void)
115 W_Electro_TriggerCombo(self.origin, WEP_CVAR(electro, combo_comboradius), self.realowner);
117 self.event_damage = func_null;
122 WEP_CVAR(electro, combo_damage),
123 WEP_CVAR(electro, combo_edgedamage),
124 WEP_CVAR(electro, combo_radius),
127 WEP_CVAR(electro, combo_force),
128 WEP_ELECTRO | HITTYPE_BOUNCE, // use THIS type for a combo because primary can't bounce
135 void W_Electro_Explode(void)
137 if(other.takedamage == DAMAGE_AIM)
139 if(DIFF_TEAM(self.realowner, other))
140 if(other.deadflag == DEAD_NO)
142 Send_Notification(NOTIF_ONE, self.realowner, MSG_ANNCE, ANNCE_ACHIEVEMENT_ELECTROBITCH);
144 self.event_damage = func_null;
145 self.takedamage = DAMAGE_NO;
147 if(self.movetype == MOVETYPE_BOUNCE)
152 WEP_CVAR_SEC(electro, damage),
153 WEP_CVAR_SEC(electro, edgedamage),
154 WEP_CVAR_SEC(electro, radius),
157 WEP_CVAR_SEC(electro, force),
158 self.projectiledeathtype,
164 W_Electro_TriggerCombo(self.origin, WEP_CVAR_PRI(electro, comboradius), self.realowner);
168 WEP_CVAR_PRI(electro, damage),
169 WEP_CVAR_PRI(electro, edgedamage),
170 WEP_CVAR_PRI(electro, radius),
173 WEP_CVAR_PRI(electro, force),
174 self.projectiledeathtype,
182 void W_Electro_TouchExplode(void)
188 void W_Electro_Bolt_Think()
190 if(time >= self.ltime)
196 if(WEP_CVAR_PRI(electro, midaircombo_radius))
199 entity e = WarpZone_FindRadius(self.origin, WEP_CVAR_PRI(electro, midaircombo_radius), TRUE);
201 // loop through nearby orbs and trigger them
204 if(e.classname == "electro_orb")
206 // change owner to whoever caused the combo explosion
207 e.realowner = self.realowner;
208 e.takedamage = DAMAGE_NO;
209 e.classname = "electro_orb_chain";
211 // now set the next one to trigger as well
212 e.think = W_Electro_ExplodeCombo;
214 // delay combo chains, looks cooler
219 (WEP_CVAR(electro, combo_speed) ?
220 (vlen(e.WarpZone_findradius_dist) / WEP_CVAR(electro, combo_speed))
231 // if we triggered an orb, should we explode? if not, lets try again next time
232 if(found && WEP_CVAR_PRI(electro, midaircombo_explode))
235 { self.nextthink = min(time + WEP_CVAR_PRI(electro, midaircombo_interval), self.ltime); }
237 else { self.nextthink = self.ltime; }
240 void W_Electro_Attack_Bolt(void)
244 W_DecreaseAmmo(WEP_CVAR_PRI(electro, ammo));
246 W_SetupShot_ProjectileSize(self, '0 0 -3', '0 0 -3', FALSE, 2, "weapons/electro_fire.wav", CH_WEAPON_A, WEP_CVAR_PRI(electro, damage));
248 pointparticles(particleeffectnum("electro_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
251 proj.classname = "electro_bolt";
252 proj.owner = proj.realowner = self;
253 proj.bot_dodge = TRUE;
254 proj.bot_dodgerating = WEP_CVAR_PRI(electro, damage);
255 proj.use = W_Electro_Explode;
256 proj.think = W_Electro_Bolt_Think;
257 proj.nextthink = time;
258 proj.ltime = time + WEP_CVAR_PRI(electro, lifetime);
259 PROJECTILE_MAKETRIGGER(proj);
260 proj.projectiledeathtype = WEP_ELECTRO;
261 setorigin(proj, w_shotorg);
263 proj.movetype = MOVETYPE_FLY;
264 WEP_SETUPPROJVELOCITY_PRI(proj, electro);
265 proj.angles = vectoangles(proj.velocity);
266 proj.touch = W_Electro_TouchExplode;
267 setsize(proj, '0 0 -3', '0 0 -3');
268 proj.flags = FL_PROJECTILE;
269 proj.missile_flags = MIF_SPLASH;
271 CSQCProjectile(proj, TRUE, PROJECTILE_ELECTRO_BEAM, TRUE);
273 other = proj; MUTATOR_CALLHOOK(EditProjectile);
276 void W_Electro_Orb_Touch(void)
279 if(other.takedamage == DAMAGE_AIM)
280 { if(WEP_CVAR_SEC(electro, touchexplode)) { W_Electro_Explode(); } }
283 //UpdateCSQCProjectile(self);
284 spamsound(self, CH_SHOTS, "weapons/electro_bounce.wav", VOL_BASE, ATTEN_NORM);
285 self.projectiledeathtype |= HITTYPE_BOUNCE;
289 void W_Electro_Orb_Damage(entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
294 // note: combos are usually triggered by W_Electro_TriggerCombo, not damage
295 float is_combo = (inflictor.classname == "electro_orb_chain" || inflictor.classname == "electro_bolt");
297 if(!W_CheckProjectileDamage(inflictor.realowner, self.realowner, deathtype, (is_combo ? 1 : -1)))
298 return; // g_projectiles_damage says to halt
300 self.health = self.health - damage;
303 self.takedamage = DAMAGE_NO;
304 self.nextthink = time;
307 // change owner to whoever caused the combo explosion
308 self.realowner = inflictor.realowner;
309 self.classname = "electro_orb_chain";
310 self.think = W_Electro_ExplodeCombo;
311 self.nextthink = time +
313 // bound the length, inflictor may be in a galaxy far far away (warpzones)
315 WEP_CVAR(electro, combo_radius),
316 vlen(self.origin - inflictor.origin)
319 // delay combo chains, looks cooler
320 WEP_CVAR(electro, combo_speed)
325 self.use = W_Electro_Explode;
326 self.think = adaptor_think2use; // not _hittype_splash, as this runs "immediately"
331 void W_Electro_Attack_Orb(void)
333 W_DecreaseAmmo(WEP_CVAR_SEC(electro, ammo));
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 = "electro_orb";
343 proj.owner = proj.realowner = self;
344 proj.use = W_Electro_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_Electro_Orb_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_Electro_Orb_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_Orb();
390 self.electro_count -= 1;
391 weapon_thinkf(WFRAME_FIRE2, WEP_CVAR_SEC(electro, animtime), W_Electro_CheckAttack);
394 // WEAPONTODO: when the player releases the button, cut down the length of refire2?
398 .float bot_secondary_electromooth;
399 float W_Electro(float req)
406 self.BUTTON_ATCK = self.BUTTON_ATCK2 = FALSE;
407 if(vlen(self.origin-self.enemy.origin) > 1000) { self.bot_secondary_electromooth = 0; }
408 if(self.bot_secondary_electromooth == 0)
412 if(WEP_CVAR_PRI(electro, speed))
413 shoot = bot_aim(WEP_CVAR_PRI(electro, speed), 0, WEP_CVAR_PRI(electro, lifetime), FALSE);
415 shoot = bot_aim(1000000, 0, 0.001, FALSE);
419 self.BUTTON_ATCK = TRUE;
420 if(random() < 0.01) self.bot_secondary_electromooth = 1;
425 if(bot_aim(WEP_CVAR_SEC(electro, speed), WEP_CVAR_SEC(electro, speed_up), WEP_CVAR_SEC(electro, lifetime), TRUE))
427 self.BUTTON_ATCK2 = TRUE;
428 if(random() < 0.03) self.bot_secondary_electromooth = 0;
436 if(autocvar_g_balance_electro_reload_ammo) // forced reload // WEAPONTODO
439 if(self.clip_load >= WEP_CVAR_PRI(electro, ammo))
441 if(self.clip_load >= WEP_CVAR_SEC(electro, ammo))
446 WEP_ACTION(self.weapon, WR_RELOAD);
455 if(weapon_prepareattack(0, WEP_CVAR_PRI(electro, refire)))
457 W_Electro_Attack_Bolt();
458 weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_PRI(electro, animtime), w_ready);
461 else if(self.BUTTON_ATCK2)
463 if(time >= self.electro_secondarytime)
464 if(weapon_prepareattack(1, WEP_CVAR_SEC(electro, refire)))
466 W_Electro_Attack_Orb();
467 self.electro_count = WEP_CVAR_SEC(electro, count);
468 weapon_thinkf(WFRAME_FIRE2, WEP_CVAR_SEC(electro, animtime), W_Electro_CheckAttack);
469 self.electro_secondarytime = time + WEP_CVAR_SEC(electro, refire2) * W_WeaponRateFactor();
477 precache_model("models/weapons/g_electro.md3");
478 precache_model("models/weapons/v_electro.md3");
479 precache_model("models/weapons/h_electro.iqm");
480 precache_sound("weapons/electro_bounce.wav");
481 precache_sound("weapons/electro_fire.wav");
482 precache_sound("weapons/electro_fire2.wav");
483 precache_sound("weapons/electro_impact.wav");
484 precache_sound("weapons/electro_impact_combo.wav");
485 ELECTRO_SETTINGS(WEP_SKIPCVAR, WEP_SET_PROP)
490 ammo_amount = self.(self.current_ammo) >= WEP_CVAR_PRI(electro, ammo);
491 ammo_amount += self.(weapon_load[WEP_ELECTRO]) >= WEP_CVAR_PRI(electro, ammo);
496 if(WEP_CVAR(electro, combo_safeammocheck)) // true if you can fire at least one secondary blob AND one primary shot after it, otherwise false.
498 ammo_amount = self.(self.current_ammo) >= WEP_CVAR_SEC(electro, ammo) + WEP_CVAR_PRI(electro, ammo);
499 ammo_amount += self.(weapon_load[WEP_ELECTRO]) >= WEP_CVAR_SEC(electro, ammo) + WEP_CVAR_PRI(electro, ammo);
503 ammo_amount = self.(self.current_ammo) >= WEP_CVAR_SEC(electro, ammo);
504 ammo_amount += self.(weapon_load[WEP_ELECTRO]) >= WEP_CVAR_SEC(electro, ammo);
510 ELECTRO_SETTINGS(WEP_CONFIG_WRITE_CVARS, WEP_CONFIG_WRITE_PROPS)
515 self.electro_secondarytime = time;
520 W_Reload(min(WEP_CVAR_PRI(electro, ammo), WEP_CVAR_SEC(electro, ammo)), "weapons/reload.wav");
523 case WR_SUICIDEMESSAGE:
525 if(w_deathtype & HITTYPE_SECONDARY)
526 return WEAPON_ELECTRO_SUICIDE_ORBS;
528 return WEAPON_ELECTRO_SUICIDE_BOLT;
532 if(w_deathtype & HITTYPE_SECONDARY)
534 return WEAPON_ELECTRO_MURDER_ORBS;
538 if(w_deathtype & HITTYPE_BOUNCE)
539 return WEAPON_ELECTRO_MURDER_COMBO;
541 return WEAPON_ELECTRO_MURDER_BOLT;
549 float W_Electro(float req)
553 case WR_IMPACTEFFECT:
556 org2 = w_org + w_backoff * 6;
557 if(w_deathtype & HITTYPE_SECONDARY)
559 pointparticles(particleeffectnum("electro_ballexplode"), org2, '0 0 0', 1);
561 sound(self, CH_SHOTS, "weapons/electro_impact.wav", VOL_BASE, ATTEN_NORM);
565 if(w_deathtype & HITTYPE_BOUNCE)
567 // this is sent as "primary (w_deathtype & HITTYPE_BOUNCE)" to distinguish it from (w_deathtype & HITTYPE_SECONDARY) bounced balls
568 pointparticles(particleeffectnum("electro_combo"), org2, '0 0 0', 1);
570 sound(self, CH_SHOTS, "weapons/electro_impact_combo.wav", VOL_BASE, ATTEN_NORM);
574 pointparticles(particleeffectnum("electro_impact"), org2, '0 0 0', 1);
576 sound(self, CH_SHOTS, "weapons/electro_impact.wav", VOL_BASE, ATTEN_NORM);
584 precache_sound("weapons/electro_impact.wav");
585 precache_sound("weapons/electro_impact_combo.wav");