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 /* crosshair */ "gfx/crosshairelectro 0.5",
12 /* refname */ "electro",
13 /* wepname */ _("Electro")
16 #define ELECTRO_SETTINGS(w_cvar,w_prop) ELECTRO_SETTINGS_LIST(w_cvar, w_prop, ELECTRO, electro)
17 #define ELECTRO_SETTINGS_LIST(w_cvar,w_prop,id,sn) \
18 w_cvar(id, sn, BOTH, ammo) \
19 w_cvar(id, sn, BOTH, animtime) \
20 w_cvar(id, sn, BOTH, damage) \
21 w_cvar(id, sn, BOTH, edgedamage) \
22 w_cvar(id, sn, BOTH, force) \
23 w_cvar(id, sn, BOTH, radius) \
24 w_cvar(id, sn, BOTH, refire) \
25 w_cvar(id, sn, BOTH, speed) \
26 w_cvar(id, sn, BOTH, spread) \
27 w_cvar(id, sn, BOTH, lifetime) \
28 w_cvar(id, sn, PRI, comboradius) \
29 w_cvar(id, sn, PRI, midaircombo_explode) \
30 w_cvar(id, sn, PRI, midaircombo_interval) \
31 w_cvar(id, sn, PRI, midaircombo_radius) \
32 w_cvar(id, sn, SEC, bouncefactor) \
33 w_cvar(id, sn, SEC, bouncestop) \
34 w_cvar(id, sn, SEC, count) \
35 w_cvar(id, sn, SEC, damageforcescale) \
36 w_cvar(id, sn, SEC, damagedbycontents) \
37 w_cvar(id, sn, SEC, health) \
38 w_cvar(id, sn, SEC, refire2) \
39 w_cvar(id, sn, SEC, speed_up) \
40 w_cvar(id, sn, SEC, speed_z) \
41 w_cvar(id, sn, SEC, touchexplode) \
42 w_cvar(id, sn, NONE, combo_comboradius) \
43 w_cvar(id, sn, NONE, combo_comboradius_thruwall) \
44 w_cvar(id, sn, NONE, combo_damage) \
45 w_cvar(id, sn, NONE, combo_edgedamage) \
46 w_cvar(id, sn, NONE, combo_force) \
47 w_cvar(id, sn, NONE, combo_radius) \
48 w_cvar(id, sn, NONE, combo_speed) \
49 w_cvar(id, sn, NONE, combo_safeammocheck) \
50 w_prop(id, sn, float, reloading_ammo, reload_ammo) \
51 w_prop(id, sn, float, reloading_time, reload_time) \
52 w_prop(id, sn, float, switchdelay_raise, switchdelay_raise) \
53 w_prop(id, sn, float, switchdelay_drop, switchdelay_drop) \
54 w_prop(id, sn, string, weaponreplace, weaponreplace) \
55 w_prop(id, sn, float, weaponstart, weaponstart) \
56 w_prop(id, sn, float, weaponstartoverride, weaponstartoverride)
59 ELECTRO_SETTINGS(WEP_ADD_CVAR, WEP_ADD_PROP)
61 .float electro_secondarytime;
62 void W_Electro_ExplodeCombo(void);
66 void spawnfunc_weapon_electro() { weapon_defaultspawnfunc(WEP_ELECTRO); }
68 void W_Electro_TriggerCombo(vector org, float rad, entity own)
70 entity e = WarpZone_FindRadius(org, rad, !WEP_CVAR(electro, combo_comboradius_thruwall));
73 if(e.classname == "electro_orb")
75 // do we allow thruwall triggering?
76 if(WEP_CVAR(electro, combo_comboradius_thruwall))
78 // if distance is greater than thruwall distance, check to make sure it's not through a wall
79 if(vlen(e.WarpZone_findradius_dist) > WEP_CVAR(electro, combo_comboradius_thruwall))
81 WarpZone_TraceLine(org, e.origin, MOVE_NOMONSTERS, e);
82 if(trace_fraction != 1)
84 // trigger is through a wall and outside of thruwall range, abort
91 // change owner to whoever caused the combo explosion
93 e.takedamage = DAMAGE_NO;
94 e.classname = "electro_orb_chain";
96 // now set the next one to trigger as well
97 e.think = W_Electro_ExplodeCombo;
99 // delay combo chains, looks cooler
104 (WEP_CVAR(electro, combo_speed) ?
105 (vlen(e.WarpZone_findradius_dist) / WEP_CVAR(electro, combo_speed))
115 void W_Electro_ExplodeCombo(void)
117 W_Electro_TriggerCombo(self.origin, WEP_CVAR(electro, combo_comboradius), self.realowner);
119 self.event_damage = func_null;
124 WEP_CVAR(electro, combo_damage),
125 WEP_CVAR(electro, combo_edgedamage),
126 WEP_CVAR(electro, combo_radius),
129 WEP_CVAR(electro, combo_force),
130 WEP_ELECTRO | HITTYPE_BOUNCE, // use THIS type for a combo because primary can't bounce
137 void W_Electro_Explode(void)
139 if(other.takedamage == DAMAGE_AIM)
141 if(DIFF_TEAM(self.realowner, other))
142 if(other.deadflag == DEAD_NO)
144 Send_Notification(NOTIF_ONE, self.realowner, MSG_ANNCE, ANNCE_ACHIEVEMENT_ELECTROBITCH);
146 self.event_damage = func_null;
147 self.takedamage = DAMAGE_NO;
149 if(self.movetype == MOVETYPE_BOUNCE)
154 WEP_CVAR_SEC(electro, damage),
155 WEP_CVAR_SEC(electro, edgedamage),
156 WEP_CVAR_SEC(electro, radius),
159 WEP_CVAR_SEC(electro, force),
160 self.projectiledeathtype,
166 W_Electro_TriggerCombo(self.origin, WEP_CVAR_PRI(electro, comboradius), self.realowner);
170 WEP_CVAR_PRI(electro, damage),
171 WEP_CVAR_PRI(electro, edgedamage),
172 WEP_CVAR_PRI(electro, radius),
175 WEP_CVAR_PRI(electro, force),
176 self.projectiledeathtype,
184 void W_Electro_TouchExplode(void)
190 void W_Electro_Bolt_Think()
192 if(time >= self.ltime)
198 if(WEP_CVAR_PRI(electro, midaircombo_radius))
201 entity e = WarpZone_FindRadius(self.origin, WEP_CVAR_PRI(electro, midaircombo_radius), TRUE);
203 // loop through nearby orbs and trigger them
206 if(e.classname == "electro_orb")
208 // change owner to whoever caused the combo explosion
209 e.realowner = self.realowner;
210 e.takedamage = DAMAGE_NO;
211 e.classname = "electro_orb_chain";
213 // now set the next one to trigger as well
214 e.think = W_Electro_ExplodeCombo;
216 // delay combo chains, looks cooler
221 (WEP_CVAR(electro, combo_speed) ?
222 (vlen(e.WarpZone_findradius_dist) / WEP_CVAR(electro, combo_speed))
233 // if we triggered an orb, should we explode? if not, lets try again next time
234 if(found && WEP_CVAR_PRI(electro, midaircombo_explode))
237 { self.nextthink = min(time + WEP_CVAR_PRI(electro, midaircombo_interval), self.ltime); }
239 else { self.nextthink = self.ltime; }
242 void W_Electro_Attack_Bolt(void)
246 W_DecreaseAmmo(WEP_CVAR_PRI(electro, ammo));
248 W_SetupShot_ProjectileSize(self, '0 0 -3', '0 0 -3', FALSE, 2, "weapons/electro_fire.wav", CH_WEAPON_A, WEP_CVAR_PRI(electro, damage));
250 pointparticles(particleeffectnum("electro_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
253 proj.classname = "electro_bolt";
254 proj.owner = proj.realowner = self;
255 proj.bot_dodge = TRUE;
256 proj.bot_dodgerating = WEP_CVAR_PRI(electro, damage);
257 proj.use = W_Electro_Explode;
258 proj.think = W_Electro_Bolt_Think;
259 proj.nextthink = time;
260 proj.ltime = time + WEP_CVAR_PRI(electro, lifetime);
261 PROJECTILE_MAKETRIGGER(proj);
262 proj.projectiledeathtype = WEP_ELECTRO;
263 setorigin(proj, w_shotorg);
265 proj.movetype = MOVETYPE_FLY;
266 W_SetupProjVelocity_PRI(proj, electro);
267 proj.angles = vectoangles(proj.velocity);
268 proj.touch = W_Electro_TouchExplode;
269 setsize(proj, '0 0 -3', '0 0 -3');
270 proj.flags = FL_PROJECTILE;
271 proj.missile_flags = MIF_SPLASH;
273 CSQCProjectile(proj, TRUE, PROJECTILE_ELECTRO_BEAM, TRUE);
275 other = proj; MUTATOR_CALLHOOK(EditProjectile);
278 void W_Electro_Orb_Touch(void)
281 if(other.takedamage == DAMAGE_AIM)
282 { if(WEP_CVAR_SEC(electro, touchexplode)) { W_Electro_Explode(); } }
285 //UpdateCSQCProjectile(self);
286 spamsound(self, CH_SHOTS, "weapons/electro_bounce.wav", VOL_BASE, ATTEN_NORM);
287 self.projectiledeathtype |= HITTYPE_BOUNCE;
291 void W_Electro_Orb_Damage(entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
296 // note: combos are usually triggered by W_Electro_TriggerCombo, not damage
297 float is_combo = (inflictor.classname == "electro_orb_chain" || inflictor.classname == "electro_bolt");
299 if(!W_CheckProjectileDamage(inflictor.realowner, self.realowner, deathtype, (is_combo ? 1 : -1)))
300 return; // g_projectiles_damage says to halt
302 self.health = self.health - damage;
305 self.takedamage = DAMAGE_NO;
306 self.nextthink = time;
309 // change owner to whoever caused the combo explosion
310 self.realowner = inflictor.realowner;
311 self.classname = "electro_orb_chain";
312 self.think = W_Electro_ExplodeCombo;
313 self.nextthink = time +
315 // bound the length, inflictor may be in a galaxy far far away (warpzones)
317 WEP_CVAR(electro, combo_radius),
318 vlen(self.origin - inflictor.origin)
321 // delay combo chains, looks cooler
322 WEP_CVAR(electro, combo_speed)
327 self.use = W_Electro_Explode;
328 self.think = adaptor_think2use; // not _hittype_splash, as this runs "immediately"
333 void W_Electro_Attack_Orb(void)
335 W_DecreaseAmmo(WEP_CVAR_SEC(electro, ammo));
337 W_SetupShot_ProjectileSize(self, '0 0 -4', '0 0 -4', FALSE, 2, "weapons/electro_fire2.wav", CH_WEAPON_A, WEP_CVAR_SEC(electro, damage));
339 w_shotdir = v_forward; // no TrueAim for grenades please
341 pointparticles(particleeffectnum("electro_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
343 entity proj = spawn();
344 proj.classname = "electro_orb";
345 proj.owner = proj.realowner = self;
346 proj.use = W_Electro_Explode;
347 proj.think = adaptor_think2use_hittype_splash;
348 proj.bot_dodge = TRUE;
349 proj.bot_dodgerating = WEP_CVAR_SEC(electro, damage);
350 proj.nextthink = time + WEP_CVAR_SEC(electro, lifetime);
351 PROJECTILE_MAKETRIGGER(proj);
352 proj.projectiledeathtype = WEP_ELECTRO | HITTYPE_SECONDARY;
353 setorigin(proj, w_shotorg);
355 //proj.glow_size = 50;
356 //proj.glow_color = 45;
357 proj.movetype = MOVETYPE_BOUNCE;
358 W_SetupProjVelocity_UP_SEC(proj, electro);
359 proj.touch = W_Electro_Orb_Touch;
360 setsize(proj, '0 0 -4', '0 0 -4');
361 proj.takedamage = DAMAGE_YES;
362 proj.damageforcescale = WEP_CVAR_SEC(electro, damageforcescale);
363 proj.health = WEP_CVAR_SEC(electro, health);
364 proj.event_damage = W_Electro_Orb_Damage;
365 proj.flags = FL_PROJECTILE;
366 proj.damagedbycontents = (WEP_CVAR_SEC(electro, damagedbycontents));
368 proj.bouncefactor = WEP_CVAR_SEC(electro, bouncefactor);
369 proj.bouncestop = WEP_CVAR_SEC(electro, bouncestop);
370 proj.missile_flags = MIF_SPLASH | MIF_ARC;
375 copyentity(proj, p2);
376 setmodel(p2, "models/ebomb.mdl");
377 setsize(p2, proj.mins, proj.maxs);
380 CSQCProjectile(proj, TRUE, PROJECTILE_ELECTRO, FALSE); // no culling, it has sound
382 other = proj; MUTATOR_CALLHOOK(EditProjectile);
385 void W_Electro_CheckAttack()
387 if(self.electro_count > 1)
388 if(self.BUTTON_ATCK2)
389 if(weapon_prepareattack(1, -1))
391 W_Electro_Attack_Orb();
392 self.electro_count -= 1;
393 weapon_thinkf(WFRAME_FIRE2, WEP_CVAR_SEC(electro, animtime), W_Electro_CheckAttack);
396 // WEAPONTODO: when the player releases the button, cut down the length of refire2?
400 .float bot_secondary_electromooth;
401 float W_Electro(float req)
408 self.BUTTON_ATCK = self.BUTTON_ATCK2 = FALSE;
409 if(vlen(self.origin-self.enemy.origin) > 1000) { self.bot_secondary_electromooth = 0; }
410 if(self.bot_secondary_electromooth == 0)
414 if(WEP_CVAR_PRI(electro, speed))
415 shoot = bot_aim(WEP_CVAR_PRI(electro, speed), 0, WEP_CVAR_PRI(electro, lifetime), FALSE);
417 shoot = bot_aim(1000000, 0, 0.001, FALSE);
421 self.BUTTON_ATCK = TRUE;
422 if(random() < 0.01) self.bot_secondary_electromooth = 1;
427 if(bot_aim(WEP_CVAR_SEC(electro, speed), WEP_CVAR_SEC(electro, speed_up), WEP_CVAR_SEC(electro, lifetime), TRUE))
429 self.BUTTON_ATCK2 = TRUE;
430 if(random() < 0.03) self.bot_secondary_electromooth = 0;
438 if(autocvar_g_balance_electro_reload_ammo) // forced reload // WEAPONTODO
441 if(self.clip_load >= WEP_CVAR_PRI(electro, ammo))
443 if(self.clip_load >= WEP_CVAR_SEC(electro, ammo))
448 WEP_ACTION(self.weapon, WR_RELOAD);
457 if(weapon_prepareattack(0, WEP_CVAR_PRI(electro, refire)))
459 W_Electro_Attack_Bolt();
460 weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_PRI(electro, animtime), w_ready);
463 else if(self.BUTTON_ATCK2)
465 if(time >= self.electro_secondarytime)
466 if(weapon_prepareattack(1, WEP_CVAR_SEC(electro, refire)))
468 W_Electro_Attack_Orb();
469 self.electro_count = WEP_CVAR_SEC(electro, count);
470 weapon_thinkf(WFRAME_FIRE2, WEP_CVAR_SEC(electro, animtime), W_Electro_CheckAttack);
471 self.electro_secondarytime = time + WEP_CVAR_SEC(electro, refire2) * W_WeaponRateFactor();
479 precache_model("models/weapons/g_electro.md3");
480 precache_model("models/weapons/v_electro.md3");
481 precache_model("models/weapons/h_electro.iqm");
482 precache_sound("weapons/electro_bounce.wav");
483 precache_sound("weapons/electro_fire.wav");
484 precache_sound("weapons/electro_fire2.wav");
485 precache_sound("weapons/electro_impact.wav");
486 precache_sound("weapons/electro_impact_combo.wav");
487 ELECTRO_SETTINGS(WEP_SKIP_CVAR, WEP_SET_PROP)
492 ammo_amount = self.WEP_AMMO(ELECTRO) >= WEP_CVAR_PRI(electro, ammo);
493 ammo_amount += self.(weapon_load[WEP_ELECTRO]) >= WEP_CVAR_PRI(electro, ammo);
498 if(WEP_CVAR(electro, combo_safeammocheck)) // true if you can fire at least one secondary blob AND one primary shot after it, otherwise false.
500 ammo_amount = self.WEP_AMMO(ELECTRO) >= WEP_CVAR_SEC(electro, ammo) + WEP_CVAR_PRI(electro, ammo);
501 ammo_amount += self.(weapon_load[WEP_ELECTRO]) >= WEP_CVAR_SEC(electro, ammo) + WEP_CVAR_PRI(electro, ammo);
505 ammo_amount = self.WEP_AMMO(ELECTRO) >= WEP_CVAR_SEC(electro, ammo);
506 ammo_amount += self.(weapon_load[WEP_ELECTRO]) >= WEP_CVAR_SEC(electro, ammo);
512 ELECTRO_SETTINGS(WEP_CONFIG_WRITE_CVARS, WEP_CONFIG_WRITE_PROPS)
517 self.electro_secondarytime = time;
522 W_Reload(min(WEP_CVAR_PRI(electro, ammo), WEP_CVAR_SEC(electro, ammo)), "weapons/reload.wav");
525 case WR_SUICIDEMESSAGE:
527 if(w_deathtype & HITTYPE_SECONDARY)
528 return WEAPON_ELECTRO_SUICIDE_ORBS;
530 return WEAPON_ELECTRO_SUICIDE_BOLT;
534 if(w_deathtype & HITTYPE_SECONDARY)
536 return WEAPON_ELECTRO_MURDER_ORBS;
540 if(w_deathtype & HITTYPE_BOUNCE)
541 return WEAPON_ELECTRO_MURDER_COMBO;
543 return WEAPON_ELECTRO_MURDER_BOLT;
551 float W_Electro(float req)
555 case WR_IMPACTEFFECT:
558 org2 = w_org + w_backoff * 6;
559 if(w_deathtype & HITTYPE_SECONDARY)
561 pointparticles(particleeffectnum("electro_ballexplode"), org2, '0 0 0', 1);
563 sound(self, CH_SHOTS, "weapons/electro_impact.wav", VOL_BASE, ATTEN_NORM);
567 if(w_deathtype & HITTYPE_BOUNCE)
569 // this is sent as "primary (w_deathtype & HITTYPE_BOUNCE)" to distinguish it from (w_deathtype & HITTYPE_SECONDARY) bounced balls
570 pointparticles(particleeffectnum("electro_combo"), org2, '0 0 0', 1);
572 sound(self, CH_SHOTS, "weapons/electro_impact_combo.wav", VOL_BASE, ATTEN_NORM);
576 pointparticles(particleeffectnum("electro_impact"), org2, '0 0 0', 1);
578 sound(self, CH_SHOTS, "weapons/electro_impact.wav", VOL_BASE, ATTEN_NORM);
586 precache_sound("weapons/electro_impact.wav");
587 precache_sound("weapons/electro_impact_combo.wav");
592 // no weapon specific image for this weapon