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 /* model */ "electro",
11 /* netname */ "electro",
12 /* fullname */ _("Electro")
15 #define ELECTRO_SETTINGS(w_cvar,w_prop) ELECTRO_SETTINGS_LIST(w_cvar, w_prop, ELECTRO, electro)
16 #define ELECTRO_SETTINGS_LIST(w_cvar,w_prop,id,sn) \
17 w_cvar(id, sn, BOTH, ammo) \
18 w_cvar(id, sn, BOTH, animtime) \
19 w_cvar(id, sn, BOTH, damage) \
20 w_cvar(id, sn, BOTH, edgedamage) \
21 w_cvar(id, sn, BOTH, force) \
22 w_cvar(id, sn, BOTH, radius) \
23 w_cvar(id, sn, BOTH, refire) \
24 w_cvar(id, sn, BOTH, speed) \
25 w_cvar(id, sn, BOTH, spread) \
26 w_cvar(id, sn, BOTH, lifetime) \
27 w_cvar(id, sn, PRI, comboradius) \
28 w_cvar(id, sn, PRI, midaircombo_explode) \
29 w_cvar(id, sn, PRI, midaircombo_interval) \
30 w_cvar(id, sn, PRI, midaircombo_radius) \
31 w_cvar(id, sn, SEC, bouncefactor) \
32 w_cvar(id, sn, SEC, bouncestop) \
33 w_cvar(id, sn, SEC, count) \
34 w_cvar(id, sn, SEC, damageforcescale) \
35 w_cvar(id, sn, SEC, damagedbycontents) \
36 w_cvar(id, sn, SEC, health) \
37 w_cvar(id, sn, SEC, refire2) \
38 w_cvar(id, sn, SEC, speed_up) \
39 w_cvar(id, sn, SEC, speed_z) \
40 w_cvar(id, sn, SEC, touchexplode) \
41 w_cvar(id, sn, NONE, combo_comboradius) \
42 w_cvar(id, sn, NONE, combo_comboradius_thruwall) \
43 w_cvar(id, sn, NONE, combo_damage) \
44 w_cvar(id, sn, NONE, combo_edgedamage) \
45 w_cvar(id, sn, NONE, combo_force) \
46 w_cvar(id, sn, NONE, combo_radius) \
47 w_cvar(id, sn, NONE, combo_speed) \
48 w_cvar(id, sn, NONE, combo_safeammocheck) \
49 w_prop(id, sn, float, reloading_ammo, reload_ammo) \
50 w_prop(id, sn, float, reloading_time, reload_time) \
51 w_prop(id, sn, float, switchdelay_raise, switchdelay_raise) \
52 w_prop(id, sn, float, switchdelay_drop, switchdelay_drop) \
53 w_prop(id, sn, string, weaponreplace, weaponreplace) \
54 w_prop(id, sn, float, weaponstart, weaponstart) \
55 w_prop(id, sn, float, weaponstartoverride, weaponstartoverride)
58 ELECTRO_SETTINGS(WEP_ADD_CVAR, WEP_ADD_PROP)
60 .float electro_secondarytime;
61 void W_Electro_ExplodeCombo(void);
65 void spawnfunc_weapon_electro() { weapon_defaultspawnfunc(WEP_ELECTRO); }
67 void W_Electro_TriggerCombo(vector org, float rad, entity own)
69 entity e = WarpZone_FindRadius(org, rad, !WEP_CVAR(electro, combo_comboradius_thruwall));
72 if(e.classname == "electro_orb")
74 // do we allow thruwall triggering?
75 if(WEP_CVAR(electro, combo_comboradius_thruwall))
77 // if distance is greater than thruwall distance, check to make sure it's not through a wall
78 if(vlen(e.WarpZone_findradius_dist) > WEP_CVAR(electro, combo_comboradius_thruwall))
80 WarpZone_TraceLine(org, e.origin, MOVE_NOMONSTERS, e);
81 if(trace_fraction != 1)
83 // trigger is through a wall and outside of thruwall range, abort
90 // change owner to whoever caused the combo explosion
92 e.takedamage = DAMAGE_NO;
93 e.classname = "electro_orb_chain";
95 // now set the next one to trigger as well
96 e.think = W_Electro_ExplodeCombo;
98 // delay combo chains, looks cooler
103 (WEP_CVAR(electro, combo_speed) ?
104 (vlen(e.WarpZone_findradius_dist) / WEP_CVAR(electro, combo_speed))
114 void W_Electro_ExplodeCombo(void)
116 W_Electro_TriggerCombo(self.origin, WEP_CVAR(electro, combo_comboradius), self.realowner);
118 self.event_damage = func_null;
123 WEP_CVAR(electro, combo_damage),
124 WEP_CVAR(electro, combo_edgedamage),
125 WEP_CVAR(electro, combo_radius),
128 WEP_CVAR(electro, combo_force),
129 WEP_ELECTRO | HITTYPE_BOUNCE, // use THIS type for a combo because primary can't bounce
136 void W_Electro_Explode(void)
138 if(other.takedamage == DAMAGE_AIM)
140 if(DIFF_TEAM(self.realowner, other))
141 if(other.deadflag == DEAD_NO)
143 Send_Notification(NOTIF_ONE, self.realowner, MSG_ANNCE, ANNCE_ACHIEVEMENT_ELECTROBITCH);
145 self.event_damage = func_null;
146 self.takedamage = DAMAGE_NO;
148 if(self.movetype == MOVETYPE_BOUNCE)
153 WEP_CVAR_SEC(electro, damage),
154 WEP_CVAR_SEC(electro, edgedamage),
155 WEP_CVAR_SEC(electro, radius),
158 WEP_CVAR_SEC(electro, force),
159 self.projectiledeathtype,
165 W_Electro_TriggerCombo(self.origin, WEP_CVAR_PRI(electro, comboradius), self.realowner);
169 WEP_CVAR_PRI(electro, damage),
170 WEP_CVAR_PRI(electro, edgedamage),
171 WEP_CVAR_PRI(electro, radius),
174 WEP_CVAR_PRI(electro, force),
175 self.projectiledeathtype,
183 void W_Electro_TouchExplode(void)
189 void W_Electro_Bolt_Think()
191 if(time >= self.ltime)
197 if(WEP_CVAR_PRI(electro, midaircombo_radius))
200 entity e = WarpZone_FindRadius(self.origin, WEP_CVAR_PRI(electro, midaircombo_radius), TRUE);
202 // loop through nearby orbs and trigger them
205 if(e.classname == "electro_orb")
207 // change owner to whoever caused the combo explosion
208 e.realowner = self.realowner;
209 e.takedamage = DAMAGE_NO;
210 e.classname = "electro_orb_chain";
212 // now set the next one to trigger as well
213 e.think = W_Electro_ExplodeCombo;
215 // delay combo chains, looks cooler
220 (WEP_CVAR(electro, combo_speed) ?
221 (vlen(e.WarpZone_findradius_dist) / WEP_CVAR(electro, combo_speed))
232 // if we triggered an orb, should we explode? if not, lets try again next time
233 if(found && WEP_CVAR_PRI(electro, midaircombo_explode))
236 { self.nextthink = min(time + WEP_CVAR_PRI(electro, midaircombo_interval), self.ltime); }
238 else { self.nextthink = self.ltime; }
241 void W_Electro_Attack_Bolt(void)
245 W_DecreaseAmmo(WEP_CVAR_PRI(electro, ammo));
247 W_SetupShot_ProjectileSize(self, '0 0 -3', '0 0 -3', FALSE, 2, "weapons/electro_fire.wav", CH_WEAPON_A, WEP_CVAR_PRI(electro, damage));
249 pointparticles(particleeffectnum("electro_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
252 proj.classname = "electro_bolt";
253 proj.owner = proj.realowner = self;
254 proj.bot_dodge = TRUE;
255 proj.bot_dodgerating = WEP_CVAR_PRI(electro, damage);
256 proj.use = W_Electro_Explode;
257 proj.think = W_Electro_Bolt_Think;
258 proj.nextthink = time;
259 proj.ltime = time + WEP_CVAR_PRI(electro, lifetime);
260 PROJECTILE_MAKETRIGGER(proj);
261 proj.projectiledeathtype = WEP_ELECTRO;
262 setorigin(proj, w_shotorg);
264 proj.movetype = MOVETYPE_FLY;
265 WEP_SETUPPROJVELOCITY_PRI(proj, electro);
266 proj.angles = vectoangles(proj.velocity);
267 proj.touch = W_Electro_TouchExplode;
268 setsize(proj, '0 0 -3', '0 0 -3');
269 proj.flags = FL_PROJECTILE;
270 proj.missile_flags = MIF_SPLASH;
272 CSQCProjectile(proj, TRUE, PROJECTILE_ELECTRO_BEAM, TRUE);
274 other = proj; MUTATOR_CALLHOOK(EditProjectile);
277 void W_Electro_Orb_Touch(void)
280 if(other.takedamage == DAMAGE_AIM)
281 { if(WEP_CVAR_SEC(electro, touchexplode)) { W_Electro_Explode(); } }
284 //UpdateCSQCProjectile(self);
285 spamsound(self, CH_SHOTS, "weapons/electro_bounce.wav", VOL_BASE, ATTEN_NORM);
286 self.projectiledeathtype |= HITTYPE_BOUNCE;
290 void W_Electro_Orb_Damage(entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
295 // note: combos are usually triggered by W_Electro_TriggerCombo, not damage
296 float is_combo = (inflictor.classname == "electro_orb_chain" || inflictor.classname == "electro_bolt");
298 if(!W_CheckProjectileDamage(inflictor.realowner, self.realowner, deathtype, (is_combo ? 1 : -1)))
299 return; // g_projectiles_damage says to halt
301 self.health = self.health - damage;
304 self.takedamage = DAMAGE_NO;
305 self.nextthink = time;
308 // change owner to whoever caused the combo explosion
309 self.realowner = inflictor.realowner;
310 self.classname = "electro_orb_chain";
311 self.think = W_Electro_ExplodeCombo;
312 self.nextthink = time +
314 // bound the length, inflictor may be in a galaxy far far away (warpzones)
316 WEP_CVAR(electro, combo_radius),
317 vlen(self.origin - inflictor.origin)
320 // delay combo chains, looks cooler
321 WEP_CVAR(electro, combo_speed)
326 self.use = W_Electro_Explode;
327 self.think = adaptor_think2use; // not _hittype_splash, as this runs "immediately"
332 void W_Electro_Attack_Orb(void)
334 W_DecreaseAmmo(WEP_CVAR_SEC(electro, ammo));
336 W_SetupShot_ProjectileSize(self, '0 0 -4', '0 0 -4', FALSE, 2, "weapons/electro_fire2.wav", CH_WEAPON_A, WEP_CVAR_SEC(electro, damage));
338 w_shotdir = v_forward; // no TrueAim for grenades please
340 pointparticles(particleeffectnum("electro_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
342 entity proj = spawn();
343 proj.classname = "electro_orb";
344 proj.owner = proj.realowner = self;
345 proj.use = W_Electro_Explode;
346 proj.think = adaptor_think2use_hittype_splash;
347 proj.bot_dodge = TRUE;
348 proj.bot_dodgerating = WEP_CVAR_SEC(electro, damage);
349 proj.nextthink = time + WEP_CVAR_SEC(electro, lifetime);
350 PROJECTILE_MAKETRIGGER(proj);
351 proj.projectiledeathtype = WEP_ELECTRO | HITTYPE_SECONDARY;
352 setorigin(proj, w_shotorg);
354 //proj.glow_size = 50;
355 //proj.glow_color = 45;
356 proj.movetype = MOVETYPE_BOUNCE;
357 WEP_SETUPPROJVELOCITY_UP_SEC(proj, electro);
358 proj.touch = W_Electro_Orb_Touch;
359 setsize(proj, '0 0 -4', '0 0 -4');
360 proj.takedamage = DAMAGE_YES;
361 proj.damageforcescale = WEP_CVAR_SEC(electro, damageforcescale);
362 proj.health = WEP_CVAR_SEC(electro, health);
363 proj.event_damage = W_Electro_Orb_Damage;
364 proj.flags = FL_PROJECTILE;
365 proj.damagedbycontents = (WEP_CVAR_SEC(electro, damagedbycontents));
367 proj.bouncefactor = WEP_CVAR_SEC(electro, bouncefactor);
368 proj.bouncestop = WEP_CVAR_SEC(electro, bouncestop);
369 proj.missile_flags = MIF_SPLASH | MIF_ARC;
374 copyentity(proj, p2);
375 setmodel(p2, "models/ebomb.mdl");
376 setsize(p2, proj.mins, proj.maxs);
379 CSQCProjectile(proj, TRUE, PROJECTILE_ELECTRO, FALSE); // no culling, it has sound
381 other = proj; MUTATOR_CALLHOOK(EditProjectile);
384 void W_Electro_CheckAttack()
386 if(self.electro_count > 1)
387 if(self.BUTTON_ATCK2)
388 if(weapon_prepareattack(1, -1))
390 W_Electro_Attack_Orb();
391 self.electro_count -= 1;
392 weapon_thinkf(WFRAME_FIRE2, WEP_CVAR_SEC(electro, animtime), W_Electro_CheckAttack);
395 // WEAPONTODO: when the player releases the button, cut down the length of refire2?
399 .float bot_secondary_electromooth;
400 float W_Electro(float req)
407 self.BUTTON_ATCK = self.BUTTON_ATCK2 = FALSE;
408 if(vlen(self.origin-self.enemy.origin) > 1000) { self.bot_secondary_electromooth = 0; }
409 if(self.bot_secondary_electromooth == 0)
413 if(WEP_CVAR_PRI(electro, speed))
414 shoot = bot_aim(WEP_CVAR_PRI(electro, speed), 0, WEP_CVAR_PRI(electro, lifetime), FALSE);
416 shoot = bot_aim(1000000, 0, 0.001, FALSE);
420 self.BUTTON_ATCK = TRUE;
421 if(random() < 0.01) self.bot_secondary_electromooth = 1;
426 if(bot_aim(WEP_CVAR_SEC(electro, speed), WEP_CVAR_SEC(electro, speed_up), WEP_CVAR_SEC(electro, lifetime), TRUE))
428 self.BUTTON_ATCK2 = TRUE;
429 if(random() < 0.03) self.bot_secondary_electromooth = 0;
437 if(autocvar_g_balance_electro_reload_ammo) // forced reload // WEAPONTODO
440 if(self.clip_load >= WEP_CVAR_PRI(electro, ammo))
442 if(self.clip_load >= WEP_CVAR_SEC(electro, ammo))
447 WEP_ACTION(self.weapon, WR_RELOAD);
456 if(weapon_prepareattack(0, WEP_CVAR_PRI(electro, refire)))
458 W_Electro_Attack_Bolt();
459 weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_PRI(electro, animtime), w_ready);
462 else if(self.BUTTON_ATCK2)
464 if(time >= self.electro_secondarytime)
465 if(weapon_prepareattack(1, WEP_CVAR_SEC(electro, refire)))
467 W_Electro_Attack_Orb();
468 self.electro_count = WEP_CVAR_SEC(electro, count);
469 weapon_thinkf(WFRAME_FIRE2, WEP_CVAR_SEC(electro, animtime), W_Electro_CheckAttack);
470 self.electro_secondarytime = time + WEP_CVAR_SEC(electro, refire2) * W_WeaponRateFactor();
478 precache_model("models/weapons/g_electro.md3");
479 precache_model("models/weapons/v_electro.md3");
480 precache_model("models/weapons/h_electro.iqm");
481 precache_sound("weapons/electro_bounce.wav");
482 precache_sound("weapons/electro_fire.wav");
483 precache_sound("weapons/electro_fire2.wav");
484 precache_sound("weapons/electro_impact.wav");
485 precache_sound("weapons/electro_impact_combo.wav");
486 ELECTRO_SETTINGS(WEP_SKIPCVAR, WEP_SET_PROP)
491 ammo_amount = self.AMMO_VAL(WEP_ELECTRO) >= WEP_CVAR_PRI(electro, ammo);
492 ammo_amount += self.(weapon_load[WEP_ELECTRO]) >= WEP_CVAR_PRI(electro, ammo);
497 if(WEP_CVAR(electro, combo_safeammocheck)) // true if you can fire at least one secondary blob AND one primary shot after it, otherwise false.
499 ammo_amount = self.AMMO_VAL(WEP_ELECTRO) >= WEP_CVAR_SEC(electro, ammo) + WEP_CVAR_PRI(electro, ammo);
500 ammo_amount += self.(weapon_load[WEP_ELECTRO]) >= WEP_CVAR_SEC(electro, ammo) + WEP_CVAR_PRI(electro, ammo);
504 ammo_amount = self.AMMO_VAL(WEP_ELECTRO) >= WEP_CVAR_SEC(electro, ammo);
505 ammo_amount += self.(weapon_load[WEP_ELECTRO]) >= WEP_CVAR_SEC(electro, ammo);
511 ELECTRO_SETTINGS(WEP_CONFIG_WRITE_CVARS, WEP_CONFIG_WRITE_PROPS)
516 self.electro_secondarytime = time;
521 W_Reload(min(WEP_CVAR_PRI(electro, ammo), WEP_CVAR_SEC(electro, ammo)), "weapons/reload.wav");
524 case WR_SUICIDEMESSAGE:
526 if(w_deathtype & HITTYPE_SECONDARY)
527 return WEAPON_ELECTRO_SUICIDE_ORBS;
529 return WEAPON_ELECTRO_SUICIDE_BOLT;
533 if(w_deathtype & HITTYPE_SECONDARY)
535 return WEAPON_ELECTRO_MURDER_ORBS;
539 if(w_deathtype & HITTYPE_BOUNCE)
540 return WEAPON_ELECTRO_MURDER_COMBO;
542 return WEAPON_ELECTRO_MURDER_BOLT;
550 float W_Electro(float req)
554 case WR_IMPACTEFFECT:
557 org2 = w_org + w_backoff * 6;
558 if(w_deathtype & HITTYPE_SECONDARY)
560 pointparticles(particleeffectnum("electro_ballexplode"), org2, '0 0 0', 1);
562 sound(self, CH_SHOTS, "weapons/electro_impact.wav", VOL_BASE, ATTEN_NORM);
566 if(w_deathtype & HITTYPE_BOUNCE)
568 // this is sent as "primary (w_deathtype & HITTYPE_BOUNCE)" to distinguish it from (w_deathtype & HITTYPE_SECONDARY) bounced balls
569 pointparticles(particleeffectnum("electro_combo"), org2, '0 0 0', 1);
571 sound(self, CH_SHOTS, "weapons/electro_impact_combo.wav", VOL_BASE, ATTEN_NORM);
575 pointparticles(particleeffectnum("electro_impact"), org2, '0 0 0', 1);
577 sound(self, CH_SHOTS, "weapons/electro_impact.wav", VOL_BASE, ATTEN_NORM);
585 precache_sound("weapons/electro_impact.wav");
586 precache_sound("weapons/electro_impact_combo.wav");