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 /* firstpmdl */ "models/weapons/h_electro.iqm",
11 /* thirdpmdl */ "models/weapons/v_electro.md3",
12 /* pickupmdl */ "models/weapons/g_electro.md3",
13 /* simplemdl */ "foobar",
14 /* crosshair */ "gfx/crosshairelectro 0.5",
15 /* refname */ "electro",
16 /* wepname */ _("Electro")
19 #define ELECTRO_SETTINGS(w_cvar,w_prop) ELECTRO_SETTINGS_LIST(w_cvar, w_prop, ELECTRO, electro)
20 #define ELECTRO_SETTINGS_LIST(w_cvar,w_prop,id,sn) \
21 w_cvar(id, sn, BOTH, ammo) \
22 w_cvar(id, sn, BOTH, animtime) \
23 w_cvar(id, sn, BOTH, damage) \
24 w_cvar(id, sn, BOTH, edgedamage) \
25 w_cvar(id, sn, BOTH, force) \
26 w_cvar(id, sn, BOTH, radius) \
27 w_cvar(id, sn, BOTH, refire) \
28 w_cvar(id, sn, BOTH, speed) \
29 w_cvar(id, sn, BOTH, spread) \
30 w_cvar(id, sn, BOTH, lifetime) \
31 w_cvar(id, sn, PRI, comboradius) \
32 w_cvar(id, sn, PRI, midaircombo_explode) \
33 w_cvar(id, sn, PRI, midaircombo_interval) \
34 w_cvar(id, sn, PRI, midaircombo_radius) \
35 w_cvar(id, sn, SEC, bouncefactor) \
36 w_cvar(id, sn, SEC, bouncestop) \
37 w_cvar(id, sn, SEC, count) \
38 w_cvar(id, sn, SEC, damageforcescale) \
39 w_cvar(id, sn, SEC, damagedbycontents) \
40 w_cvar(id, sn, SEC, health) \
41 w_cvar(id, sn, SEC, refire2) \
42 w_cvar(id, sn, SEC, speed_up) \
43 w_cvar(id, sn, SEC, speed_z) \
44 w_cvar(id, sn, SEC, touchexplode) \
45 w_cvar(id, sn, NONE, combo_comboradius) \
46 w_cvar(id, sn, NONE, combo_comboradius_thruwall) \
47 w_cvar(id, sn, NONE, combo_damage) \
48 w_cvar(id, sn, NONE, combo_edgedamage) \
49 w_cvar(id, sn, NONE, combo_force) \
50 w_cvar(id, sn, NONE, combo_radius) \
51 w_cvar(id, sn, NONE, combo_speed) \
52 w_cvar(id, sn, NONE, combo_safeammocheck) \
53 w_prop(id, sn, float, reloading_ammo, reload_ammo) \
54 w_prop(id, sn, float, reloading_time, reload_time) \
55 w_prop(id, sn, float, switchdelay_raise, switchdelay_raise) \
56 w_prop(id, sn, float, switchdelay_drop, switchdelay_drop) \
57 w_prop(id, sn, string, weaponreplace, weaponreplace) \
58 w_prop(id, sn, float, weaponstart, weaponstart) \
59 w_prop(id, sn, float, weaponstartoverride, weaponstartoverride)
62 ELECTRO_SETTINGS(WEP_ADD_CVAR, WEP_ADD_PROP)
64 .float electro_secondarytime;
65 void W_Electro_ExplodeCombo(void);
69 void spawnfunc_weapon_electro() { weapon_defaultspawnfunc(WEP_ELECTRO); }
71 void W_Electro_TriggerCombo(vector org, float rad, entity own)
73 entity e = WarpZone_FindRadius(org, rad, !WEP_CVAR(electro, combo_comboradius_thruwall));
76 if(e.classname == "electro_orb")
78 // do we allow thruwall triggering?
79 if(WEP_CVAR(electro, combo_comboradius_thruwall))
81 // if distance is greater than thruwall distance, check to make sure it's not through a wall
82 if(vlen(e.WarpZone_findradius_dist) > WEP_CVAR(electro, combo_comboradius_thruwall))
84 WarpZone_TraceLine(org, e.origin, MOVE_NOMONSTERS, e);
85 if(trace_fraction != 1)
87 // trigger is through a wall and outside of thruwall range, abort
94 // change owner to whoever caused the combo explosion
96 e.takedamage = DAMAGE_NO;
97 e.classname = "electro_orb_chain";
99 // now set the next one to trigger as well
100 e.think = W_Electro_ExplodeCombo;
102 // delay combo chains, looks cooler
107 (WEP_CVAR(electro, combo_speed) ?
108 (vlen(e.WarpZone_findradius_dist) / WEP_CVAR(electro, combo_speed))
118 void W_Electro_ExplodeCombo(void)
120 W_Electro_TriggerCombo(self.origin, WEP_CVAR(electro, combo_comboradius), self.realowner);
122 self.event_damage = func_null;
127 WEP_CVAR(electro, combo_damage),
128 WEP_CVAR(electro, combo_edgedamage),
129 WEP_CVAR(electro, combo_radius),
132 WEP_CVAR(electro, combo_force),
133 WEP_ELECTRO | HITTYPE_BOUNCE, // use THIS type for a combo because primary can't bounce
140 void W_Electro_Explode(void)
142 if(other.takedamage == DAMAGE_AIM)
144 if(DIFF_TEAM(self.realowner, other))
145 if(other.deadflag == DEAD_NO)
147 Send_Notification(NOTIF_ONE, self.realowner, MSG_ANNCE, ANNCE_ACHIEVEMENT_ELECTROBITCH);
149 self.event_damage = func_null;
150 self.takedamage = DAMAGE_NO;
152 if(self.movetype == MOVETYPE_BOUNCE)
157 WEP_CVAR_SEC(electro, damage),
158 WEP_CVAR_SEC(electro, edgedamage),
159 WEP_CVAR_SEC(electro, radius),
162 WEP_CVAR_SEC(electro, force),
163 self.projectiledeathtype,
169 W_Electro_TriggerCombo(self.origin, WEP_CVAR_PRI(electro, comboradius), self.realowner);
173 WEP_CVAR_PRI(electro, damage),
174 WEP_CVAR_PRI(electro, edgedamage),
175 WEP_CVAR_PRI(electro, radius),
178 WEP_CVAR_PRI(electro, force),
179 self.projectiledeathtype,
187 void W_Electro_TouchExplode(void)
193 void W_Electro_Bolt_Think()
195 if(time >= self.ltime)
201 if(WEP_CVAR_PRI(electro, midaircombo_radius))
204 entity e = WarpZone_FindRadius(self.origin, WEP_CVAR_PRI(electro, midaircombo_radius), TRUE);
206 // loop through nearby orbs and trigger them
209 if(e.classname == "electro_orb")
211 // change owner to whoever caused the combo explosion
212 e.realowner = self.realowner;
213 e.takedamage = DAMAGE_NO;
214 e.classname = "electro_orb_chain";
216 // now set the next one to trigger as well
217 e.think = W_Electro_ExplodeCombo;
219 // delay combo chains, looks cooler
224 (WEP_CVAR(electro, combo_speed) ?
225 (vlen(e.WarpZone_findradius_dist) / WEP_CVAR(electro, combo_speed))
236 // if we triggered an orb, should we explode? if not, lets try again next time
237 if(found && WEP_CVAR_PRI(electro, midaircombo_explode))
240 { self.nextthink = min(time + WEP_CVAR_PRI(electro, midaircombo_interval), self.ltime); }
242 else { self.nextthink = self.ltime; }
245 void W_Electro_Attack_Bolt(void)
249 W_DecreaseAmmo(WEP_CVAR_PRI(electro, ammo));
251 W_SetupShot_ProjectileSize(self, '0 0 -3', '0 0 -3', FALSE, 2, "weapons/electro_fire.wav", CH_WEAPON_A, WEP_CVAR_PRI(electro, damage));
253 pointparticles(particleeffectnum("electro_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
256 proj.classname = "electro_bolt";
257 proj.owner = proj.realowner = self;
258 proj.bot_dodge = TRUE;
259 proj.bot_dodgerating = WEP_CVAR_PRI(electro, damage);
260 proj.use = W_Electro_Explode;
261 proj.think = W_Electro_Bolt_Think;
262 proj.nextthink = time;
263 proj.ltime = time + WEP_CVAR_PRI(electro, lifetime);
264 PROJECTILE_MAKETRIGGER(proj);
265 proj.projectiledeathtype = WEP_ELECTRO;
266 setorigin(proj, w_shotorg);
268 proj.movetype = MOVETYPE_FLY;
269 W_SetupProjVelocity_PRI(proj, electro);
270 proj.angles = vectoangles(proj.velocity);
271 proj.touch = W_Electro_TouchExplode;
272 setsize(proj, '0 0 -3', '0 0 -3');
273 proj.flags = FL_PROJECTILE;
274 proj.missile_flags = MIF_SPLASH;
276 CSQCProjectile(proj, TRUE, PROJECTILE_ELECTRO_BEAM, TRUE);
278 other = proj; MUTATOR_CALLHOOK(EditProjectile);
281 void W_Electro_Orb_Touch(void)
284 if(other.takedamage == DAMAGE_AIM)
285 { if(WEP_CVAR_SEC(electro, touchexplode)) { W_Electro_Explode(); } }
288 //UpdateCSQCProjectile(self);
289 spamsound(self, CH_SHOTS, "weapons/electro_bounce.wav", VOL_BASE, ATTEN_NORM);
290 self.projectiledeathtype |= HITTYPE_BOUNCE;
294 void W_Electro_Orb_Damage(entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
299 // note: combos are usually triggered by W_Electro_TriggerCombo, not damage
300 float is_combo = (inflictor.classname == "electro_orb_chain" || inflictor.classname == "electro_bolt");
302 if(!W_CheckProjectileDamage(inflictor.realowner, self.realowner, deathtype, (is_combo ? 1 : -1)))
303 return; // g_projectiles_damage says to halt
305 self.health = self.health - damage;
308 self.takedamage = DAMAGE_NO;
309 self.nextthink = time;
312 // change owner to whoever caused the combo explosion
313 self.realowner = inflictor.realowner;
314 self.classname = "electro_orb_chain";
315 self.think = W_Electro_ExplodeCombo;
316 self.nextthink = time +
318 // bound the length, inflictor may be in a galaxy far far away (warpzones)
320 WEP_CVAR(electro, combo_radius),
321 vlen(self.origin - inflictor.origin)
324 // delay combo chains, looks cooler
325 WEP_CVAR(electro, combo_speed)
330 self.use = W_Electro_Explode;
331 self.think = adaptor_think2use; // not _hittype_splash, as this runs "immediately"
336 void W_Electro_Attack_Orb(void)
338 W_DecreaseAmmo(WEP_CVAR_SEC(electro, ammo));
340 W_SetupShot_ProjectileSize(self, '0 0 -4', '0 0 -4', FALSE, 2, "weapons/electro_fire2.wav", CH_WEAPON_A, WEP_CVAR_SEC(electro, damage));
342 w_shotdir = v_forward; // no TrueAim for grenades please
344 pointparticles(particleeffectnum("electro_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
346 entity proj = spawn();
347 proj.classname = "electro_orb";
348 proj.owner = proj.realowner = self;
349 proj.use = W_Electro_Explode;
350 proj.think = adaptor_think2use_hittype_splash;
351 proj.bot_dodge = TRUE;
352 proj.bot_dodgerating = WEP_CVAR_SEC(electro, damage);
353 proj.nextthink = time + WEP_CVAR_SEC(electro, lifetime);
354 PROJECTILE_MAKETRIGGER(proj);
355 proj.projectiledeathtype = WEP_ELECTRO | HITTYPE_SECONDARY;
356 setorigin(proj, w_shotorg);
358 //proj.glow_size = 50;
359 //proj.glow_color = 45;
360 proj.movetype = MOVETYPE_BOUNCE;
361 W_SetupProjVelocity_UP_SEC(proj, electro);
362 proj.touch = W_Electro_Orb_Touch;
363 setsize(proj, '0 0 -4', '0 0 -4');
364 proj.takedamage = DAMAGE_YES;
365 proj.damageforcescale = WEP_CVAR_SEC(electro, damageforcescale);
366 proj.health = WEP_CVAR_SEC(electro, health);
367 proj.event_damage = W_Electro_Orb_Damage;
368 proj.flags = FL_PROJECTILE;
369 proj.damagedbycontents = (WEP_CVAR_SEC(electro, damagedbycontents));
371 proj.bouncefactor = WEP_CVAR_SEC(electro, bouncefactor);
372 proj.bouncestop = WEP_CVAR_SEC(electro, bouncestop);
373 proj.missile_flags = MIF_SPLASH | MIF_ARC;
378 copyentity(proj, p2);
379 setmodel(p2, "models/ebomb.mdl");
380 setsize(p2, proj.mins, proj.maxs);
383 CSQCProjectile(proj, TRUE, PROJECTILE_ELECTRO, FALSE); // no culling, it has sound
385 other = proj; MUTATOR_CALLHOOK(EditProjectile);
388 void W_Electro_CheckAttack()
390 if(self.electro_count > 1)
391 if(self.BUTTON_ATCK2)
392 if(weapon_prepareattack(1, -1))
394 W_Electro_Attack_Orb();
395 self.electro_count -= 1;
396 weapon_thinkf(WFRAME_FIRE2, WEP_CVAR_SEC(electro, animtime), W_Electro_CheckAttack);
399 // WEAPONTODO: when the player releases the button, cut down the length of refire2?
403 .float bot_secondary_electromooth;
404 float W_Electro(float req)
411 self.BUTTON_ATCK = self.BUTTON_ATCK2 = FALSE;
412 if(vlen(self.origin-self.enemy.origin) > 1000) { self.bot_secondary_electromooth = 0; }
413 if(self.bot_secondary_electromooth == 0)
417 if(WEP_CVAR_PRI(electro, speed))
418 shoot = bot_aim(WEP_CVAR_PRI(electro, speed), 0, WEP_CVAR_PRI(electro, lifetime), FALSE);
420 shoot = bot_aim(1000000, 0, 0.001, FALSE);
424 self.BUTTON_ATCK = TRUE;
425 if(random() < 0.01) self.bot_secondary_electromooth = 1;
430 if(bot_aim(WEP_CVAR_SEC(electro, speed), WEP_CVAR_SEC(electro, speed_up), WEP_CVAR_SEC(electro, lifetime), TRUE))
432 self.BUTTON_ATCK2 = TRUE;
433 if(random() < 0.03) self.bot_secondary_electromooth = 0;
441 if(autocvar_g_balance_electro_reload_ammo) // forced reload // WEAPONTODO
444 if(self.clip_load >= WEP_CVAR_PRI(electro, ammo))
446 if(self.clip_load >= WEP_CVAR_SEC(electro, ammo))
451 WEP_ACTION(self.weapon, WR_RELOAD);
460 if(weapon_prepareattack(0, WEP_CVAR_PRI(electro, refire)))
462 W_Electro_Attack_Bolt();
463 weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_PRI(electro, animtime), w_ready);
466 else if(self.BUTTON_ATCK2)
468 if(time >= self.electro_secondarytime)
469 if(weapon_prepareattack(1, WEP_CVAR_SEC(electro, refire)))
471 W_Electro_Attack_Orb();
472 self.electro_count = WEP_CVAR_SEC(electro, count);
473 weapon_thinkf(WFRAME_FIRE2, WEP_CVAR_SEC(electro, animtime), W_Electro_CheckAttack);
474 self.electro_secondarytime = time + WEP_CVAR_SEC(electro, refire2) * W_WeaponRateFactor();
482 precache_model("models/weapons/g_electro.md3");
483 precache_model("models/weapons/v_electro.md3");
484 precache_model("models/weapons/h_electro.iqm");
485 precache_sound("weapons/electro_bounce.wav");
486 precache_sound("weapons/electro_fire.wav");
487 precache_sound("weapons/electro_fire2.wav");
488 precache_sound("weapons/electro_impact.wav");
489 precache_sound("weapons/electro_impact_combo.wav");
490 ELECTRO_SETTINGS(WEP_SKIP_CVAR, WEP_SET_PROP)
495 ammo_amount = self.WEP_AMMO(ELECTRO) >= WEP_CVAR_PRI(electro, ammo);
496 ammo_amount += self.(weapon_load[WEP_ELECTRO]) >= WEP_CVAR_PRI(electro, ammo);
501 if(WEP_CVAR(electro, combo_safeammocheck)) // true if you can fire at least one secondary blob AND one primary shot after it, otherwise false.
503 ammo_amount = self.WEP_AMMO(ELECTRO) >= WEP_CVAR_SEC(electro, ammo) + WEP_CVAR_PRI(electro, ammo);
504 ammo_amount += self.(weapon_load[WEP_ELECTRO]) >= WEP_CVAR_SEC(electro, ammo) + WEP_CVAR_PRI(electro, ammo);
508 ammo_amount = self.WEP_AMMO(ELECTRO) >= WEP_CVAR_SEC(electro, ammo);
509 ammo_amount += self.(weapon_load[WEP_ELECTRO]) >= WEP_CVAR_SEC(electro, ammo);
515 ELECTRO_SETTINGS(WEP_CONFIG_WRITE_CVARS, WEP_CONFIG_WRITE_PROPS)
520 self.electro_secondarytime = time;
525 W_Reload(min(WEP_CVAR_PRI(electro, ammo), WEP_CVAR_SEC(electro, ammo)), "weapons/reload.wav");
528 case WR_SUICIDEMESSAGE:
530 if(w_deathtype & HITTYPE_SECONDARY)
531 return WEAPON_ELECTRO_SUICIDE_ORBS;
533 return WEAPON_ELECTRO_SUICIDE_BOLT;
537 if(w_deathtype & HITTYPE_SECONDARY)
539 return WEAPON_ELECTRO_MURDER_ORBS;
543 if(w_deathtype & HITTYPE_BOUNCE)
544 return WEAPON_ELECTRO_MURDER_COMBO;
546 return WEAPON_ELECTRO_MURDER_BOLT;
554 float W_Electro(float req)
558 case WR_IMPACTEFFECT:
561 org2 = w_org + w_backoff * 6;
562 if(w_deathtype & HITTYPE_SECONDARY)
564 pointparticles(particleeffectnum("electro_ballexplode"), org2, '0 0 0', 1);
566 sound(self, CH_SHOTS, "weapons/electro_impact.wav", VOL_BASE, ATTEN_NORM);
570 if(w_deathtype & HITTYPE_BOUNCE)
572 // this is sent as "primary (w_deathtype & HITTYPE_BOUNCE)" to distinguish it from (w_deathtype & HITTYPE_SECONDARY) bounced balls
573 pointparticles(particleeffectnum("electro_combo"), org2, '0 0 0', 1);
575 sound(self, CH_SHOTS, "weapons/electro_impact_combo.wav", VOL_BASE, ATTEN_NORM);
579 pointparticles(particleeffectnum("electro_impact"), org2, '0 0 0', 1);
581 sound(self, CH_SHOTS, "weapons/electro_impact.wav", VOL_BASE, ATTEN_NORM);
589 precache_sound("weapons/electro_impact.wav");
590 precache_sound("weapons/electro_impact_combo.wav");
595 // no weapon specific image for this weapon