3 /* WEP_##id */ ELECTRO,
4 /* function */ W_Electro,
5 /* ammotype */ IT_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) \
15 w_cvar(WEP_ELECTRO, electro, MO_BOTH, ammo) \
16 w_cvar(WEP_ELECTRO, electro, MO_BOTH, animtime) \
17 w_cvar(WEP_ELECTRO, electro, MO_BOTH, damage) \
18 w_cvar(WEP_ELECTRO, electro, MO_BOTH, edgedamage) \
19 w_cvar(WEP_ELECTRO, electro, MO_BOTH, force) \
20 w_cvar(WEP_ELECTRO, electro, MO_BOTH, radius) \
21 w_cvar(WEP_ELECTRO, electro, MO_BOTH, refire) \
22 w_cvar(WEP_ELECTRO, electro, MO_BOTH, speed) \
23 w_cvar(WEP_ELECTRO, electro, MO_BOTH, spread) \
24 w_cvar(WEP_ELECTRO, electro, MO_BOTH, lifetime) \
25 w_cvar(WEP_ELECTRO, electro, MO_PRI, comboradius) \
26 w_cvar(WEP_ELECTRO, electro, MO_PRI, midaircombo_explode) \
27 w_cvar(WEP_ELECTRO, electro, MO_PRI, midaircombo_interval) \
28 w_cvar(WEP_ELECTRO, electro, MO_PRI, midaircombo_radius) \
29 w_cvar(WEP_ELECTRO, electro, MO_SEC, bouncefactor) \
30 w_cvar(WEP_ELECTRO, electro, MO_SEC, bouncestop) \
31 w_cvar(WEP_ELECTRO, electro, MO_SEC, count) \
32 w_cvar(WEP_ELECTRO, electro, MO_SEC, damageforcescale) \
33 w_cvar(WEP_ELECTRO, electro, MO_SEC, damagedbycontents) \
34 w_cvar(WEP_ELECTRO, electro, MO_SEC, health) \
35 w_cvar(WEP_ELECTRO, electro, MO_SEC, refire2) \
36 w_cvar(WEP_ELECTRO, electro, MO_SEC, speed_up) \
37 w_cvar(WEP_ELECTRO, electro, MO_SEC, speed_z) \
38 w_cvar(WEP_ELECTRO, electro, MO_SEC, touchexplode) \
39 w_cvar(WEP_ELECTRO, electro, MO_NONE, combo_comboradius) \
40 w_cvar(WEP_ELECTRO, electro, MO_NONE, combo_comboradius_thruwall) \
41 w_cvar(WEP_ELECTRO, electro, MO_NONE, combo_damage) \
42 w_cvar(WEP_ELECTRO, electro, MO_NONE, combo_edgedamage) \
43 w_cvar(WEP_ELECTRO, electro, MO_NONE, combo_force) \
44 w_cvar(WEP_ELECTRO, electro, MO_NONE, combo_radius) \
45 w_cvar(WEP_ELECTRO, electro, MO_NONE, combo_speed) \
46 w_cvar(WEP_ELECTRO, electro, MO_NONE, combo_safeammocheck) \
47 w_prop(WEP_ELECTRO, electro, float, reloading_ammo, reload_ammo) \
48 w_prop(WEP_ELECTRO, electro, float, reloading_time, reload_time) \
49 w_prop(WEP_ELECTRO, electro, float, switchdelay_raise, switchdelay_raise) \
50 w_prop(WEP_ELECTRO, electro, float, switchdelay_drop, switchdelay_drop) \
51 w_prop(WEP_ELECTRO, electro, string, weaponreplace, weaponreplace) \
52 w_prop(WEP_ELECTRO, electro, float, weaponstart, weaponstart) \
53 w_prop(WEP_ELECTRO, electro, float, weaponstartoverride, weaponstartoverride)
56 ELECTRO_SETTINGS(WEP_ADD_CVAR, WEP_ADD_PROP)
58 .float electro_secondarytime;
59 void W_Plasma_Explode_Combo(void);
63 void spawnfunc_weapon_electro() { weapon_defaultspawnfunc(WEP_ELECTRO); }
65 void W_Plasma_TriggerCombo(vector org, float rad, entity own)
67 entity e = WarpZone_FindRadius(org, rad, !WEP_CVAR(electro, combo_comboradius_thruwall));
70 if(e.classname == "plasma")
72 // do we allow thruwall triggering?
73 if(WEP_CVAR(electro, combo_comboradius_thruwall))
75 // if distance is greater than thruwall distance, check to make sure it's not through a wall
76 if(vlen(e.WarpZone_findradius_dist) > WEP_CVAR(electro, combo_comboradius_thruwall))
78 WarpZone_TraceLine(org, e.origin, MOVE_NOMONSTERS, e);
79 if(trace_fraction != 1)
81 // trigger is through a wall and outside of thruwall range, abort
88 // change owner to whoever caused the combo explosion
90 e.takedamage = DAMAGE_NO;
91 e.classname = "plasma_chain";
93 // now set the next one to trigger as well
94 e.think = W_Plasma_Explode_Combo;
96 // delay combo chains, looks cooler
101 (WEP_CVAR(electro, combo_speed) ?
102 (vlen(e.WarpZone_findradius_dist) / WEP_CVAR(electro, combo_speed))
112 void W_Plasma_Explode(void)
114 if(other.takedamage == DAMAGE_AIM)
116 if(DIFF_TEAM(self.realowner, other))
117 if(other.deadflag == DEAD_NO)
119 Send_Notification(NOTIF_ONE, self.realowner, MSG_ANNCE, ANNCE_ACHIEVEMENT_ELECTROBITCH);
121 self.event_damage = func_null;
122 self.takedamage = DAMAGE_NO;
124 if(self.movetype == MOVETYPE_BOUNCE)
129 WEP_CVAR_SEC(electro, damage),
130 WEP_CVAR_SEC(electro, edgedamage),
131 WEP_CVAR_SEC(electro, radius),
134 WEP_CVAR_SEC(electro, force),
135 self.projectiledeathtype,
141 W_Plasma_TriggerCombo(self.origin, WEP_CVAR_PRI(electro, comboradius), self.realowner);
145 WEP_CVAR_PRI(electro, damage),
146 WEP_CVAR_PRI(electro, edgedamage),
147 WEP_CVAR_PRI(electro, radius),
150 WEP_CVAR_PRI(electro, force),
151 self.projectiledeathtype,
159 void W_Plasma_Explode_Combo(void)
161 W_Plasma_TriggerCombo(self.origin, WEP_CVAR(electro, combo_comboradius), self.realowner);
163 self.event_damage = func_null;
168 WEP_CVAR(electro, combo_damage),
169 WEP_CVAR(electro, combo_edgedamage),
170 WEP_CVAR(electro, combo_radius),
173 WEP_CVAR(electro, combo_force),
174 WEP_ELECTRO | HITTYPE_BOUNCE, // use THIS type for a combo because primary can't bounce
181 void W_Plasma_Touch(void)
184 if(other.takedamage == DAMAGE_AIM)
185 { if(WEP_CVAR_SEC(electro, touchexplode)) { W_Plasma_Explode(); } }
188 //UpdateCSQCProjectile(self);
189 spamsound(self, CH_SHOTS, "weapons/electro_bounce.wav", VOL_BASE, ATTEN_NORM);
190 self.projectiledeathtype |= HITTYPE_BOUNCE;
194 void W_Plasma_TouchExplode(void)
200 void W_Plasma_Damage(entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
205 // note: combos are usually triggered by W_Plasma_TriggerCombo, not damage
206 float is_combo = (inflictor.classname == "plasma_chain" || inflictor.classname == "plasma_prim");
208 if(!W_CheckProjectileDamage(inflictor.realowner, self.realowner, deathtype, (is_combo ? 1 : -1)))
209 return; // g_projectiles_damage says to halt
211 self.health = self.health - damage;
214 self.takedamage = DAMAGE_NO;
215 self.nextthink = time;
218 // change owner to whoever caused the combo explosion
219 self.realowner = inflictor.realowner;
220 self.classname = "plasma_chain";
221 self.think = W_Plasma_Explode_Combo;
222 self.nextthink = time +
224 // bound the length, inflictor may be in a galaxy far far away (warpzones)
226 WEP_CVAR(electro, combo_radius),
227 vlen(self.origin - inflictor.origin)
230 // delay combo chains, looks cooler
231 WEP_CVAR(electro, combo_speed)
236 self.use = W_Plasma_Explode;
237 self.think = adaptor_think2use; // not _hittype_splash, as this runs "immediately"
242 void W_Plasma_Think()
244 if(time >= self.ltime)
250 if(WEP_CVAR_PRI(electro, midaircombo_radius))
253 entity e = WarpZone_FindRadius(self.origin, WEP_CVAR_PRI(electro, midaircombo_radius), TRUE);
255 // loop through nearby orbs and trigger them
258 if(e.classname == "plasma")
260 // change owner to whoever caused the combo explosion
261 e.realowner = self.realowner;
262 e.takedamage = DAMAGE_NO;
263 e.classname = "plasma_chain";
265 // now set the next one to trigger as well
266 e.think = W_Plasma_Explode_Combo;
268 // delay combo chains, looks cooler
273 (WEP_CVAR(electro, combo_speed) ?
274 (vlen(e.WarpZone_findradius_dist) / WEP_CVAR(electro, combo_speed))
285 // if we triggered an orb, should we explode? if not, lets try again next time
286 if(found && WEP_CVAR_PRI(electro, midaircombo_explode))
289 { self.nextthink = min(time + WEP_CVAR_PRI(electro, midaircombo_interval), self.ltime); }
291 else { self.nextthink = self.ltime; }
294 void W_Electro_Attack_Bolt(void)
298 W_DecreaseAmmo(ammo_cells, WEP_CVAR_PRI(electro, ammo), autocvar_g_balance_electro_reload_ammo);//weapontodo
300 W_SetupShot_ProjectileSize(self, '0 0 -3', '0 0 -3', FALSE, 2, "weapons/electro_fire.wav", CH_WEAPON_A, WEP_CVAR_PRI(electro, damage));
302 pointparticles(particleeffectnum("electro_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
305 proj.classname = "plasma_prim";
306 proj.owner = proj.realowner = self;
307 proj.bot_dodge = TRUE;
308 proj.bot_dodgerating = WEP_CVAR_PRI(electro, damage);
309 proj.use = W_Plasma_Explode;
310 proj.think = W_Plasma_Think;
311 proj.nextthink = time;
312 proj.ltime = time + WEP_CVAR_PRI(electro, lifetime);
313 PROJECTILE_MAKETRIGGER(proj);
314 proj.projectiledeathtype = WEP_ELECTRO;
315 setorigin(proj, w_shotorg);
317 proj.movetype = MOVETYPE_FLY;
318 WEP_SETUPPROJVELOCITY_PRI(proj, electro);
319 proj.angles = vectoangles(proj.velocity);
320 proj.touch = W_Plasma_TouchExplode;
321 setsize(proj, '0 0 -3', '0 0 -3');
322 proj.flags = FL_PROJECTILE;
323 proj.missile_flags = MIF_SPLASH;
325 CSQCProjectile(proj, TRUE, PROJECTILE_ELECTRO_BEAM, TRUE);
327 other = proj; MUTATOR_CALLHOOK(EditProjectile);
330 void W_Electro_Attack_Orbs(void)
332 W_DecreaseAmmo(ammo_cells, WEP_CVAR_SEC(electro, ammo), autocvar_g_balance_electro_reload_ammo);//weapontodo
334 W_SetupShot_ProjectileSize(self, '0 0 -4', '0 0 -4', FALSE, 2, "weapons/electro_fire2.wav", CH_WEAPON_A, WEP_CVAR_SEC(electro, damage));
336 w_shotdir = v_forward; // no TrueAim for grenades please
338 pointparticles(particleeffectnum("electro_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
340 entity proj = spawn();
341 proj.classname = "plasma";
342 proj.owner = proj.realowner = self;
343 proj.use = W_Plasma_Explode;
344 proj.think = adaptor_think2use_hittype_splash;
345 proj.bot_dodge = TRUE;
346 proj.bot_dodgerating = WEP_CVAR_SEC(electro, damage);
347 proj.nextthink = time + WEP_CVAR_SEC(electro, lifetime);
348 PROJECTILE_MAKETRIGGER(proj);
349 proj.projectiledeathtype = WEP_ELECTRO | HITTYPE_SECONDARY;
350 setorigin(proj, w_shotorg);
352 //proj.glow_size = 50;
353 //proj.glow_color = 45;
354 proj.movetype = MOVETYPE_BOUNCE;
355 WEP_SETUPPROJVELOCITY_UP_SEC(proj, electro);
356 proj.touch = W_Plasma_Touch;
357 setsize(proj, '0 0 -4', '0 0 -4');
358 proj.takedamage = DAMAGE_YES;
359 proj.damageforcescale = WEP_CVAR_SEC(electro, damageforcescale);
360 proj.health = WEP_CVAR_SEC(electro, health);
361 proj.event_damage = W_Plasma_Damage;
362 proj.flags = FL_PROJECTILE;
363 proj.damagedbycontents = (WEP_CVAR_SEC(electro, damagedbycontents));
365 proj.bouncefactor = WEP_CVAR_SEC(electro, bouncefactor);
366 proj.bouncestop = WEP_CVAR_SEC(electro, bouncestop);
367 proj.missile_flags = MIF_SPLASH | MIF_ARC;
372 copyentity(proj, p2);
373 setmodel(p2, "models/ebomb.mdl");
374 setsize(p2, proj.mins, proj.maxs);
377 CSQCProjectile(proj, TRUE, PROJECTILE_ELECTRO, FALSE); // no culling, it has sound
379 other = proj; MUTATOR_CALLHOOK(EditProjectile);
382 void W_Electro_CheckAttack()
384 if(self.electro_count > 1)
385 if(self.BUTTON_ATCK2)
386 if(weapon_prepareattack(1, -1))
388 W_Electro_Attack_Orbs();
389 self.electro_count -= 1;
390 weapon_thinkf(WFRAME_FIRE2, WEP_CVAR_SEC(electro, animtime), W_Electro_CheckAttack);
396 .float bot_secondary_electromooth;
397 float W_Electro(float req)
404 self.BUTTON_ATCK = self.BUTTON_ATCK2 = FALSE;
405 if(vlen(self.origin-self.enemy.origin) > 1000) { self.bot_secondary_electromooth = 0; }
406 if(self.bot_secondary_electromooth == 0)
410 if(WEP_CVAR_PRI(electro, speed))
411 shoot = bot_aim(WEP_CVAR_PRI(electro, speed), 0, WEP_CVAR_PRI(electro, lifetime), FALSE);
413 shoot = bot_aim(1000000, 0, 0.001, FALSE);
417 self.BUTTON_ATCK = TRUE;
418 if(random() < 0.01) self.bot_secondary_electromooth = 1;
423 if(bot_aim(WEP_CVAR_SEC(electro, speed), WEP_CVAR_SEC(electro, speed_up), WEP_CVAR_SEC(electro, lifetime), TRUE))
425 self.BUTTON_ATCK2 = TRUE;
426 if(random() < 0.03) self.bot_secondary_electromooth = 0;
434 if(autocvar_g_balance_electro_reload_ammo) // forced reload // WEAPONTODO
437 if(self.clip_load >= WEP_CVAR_PRI(electro, ammo))
439 if(self.clip_load >= WEP_CVAR_SEC(electro, ammo))
444 WEP_ACTION(self.weapon, WR_RELOAD);
453 if(weapon_prepareattack(0, WEP_CVAR_PRI(electro, refire)))
455 W_Electro_Attack_Bolt();
456 weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_PRI(electro, animtime), w_ready);
459 else if(self.BUTTON_ATCK2)
461 if(time >= self.electro_secondarytime)
462 if(weapon_prepareattack(1, WEP_CVAR_SEC(electro, refire)))
464 W_Electro_Attack_Orbs();
465 self.electro_count = WEP_CVAR_SEC(electro, count);
466 weapon_thinkf(WFRAME_FIRE2, WEP_CVAR_SEC(electro, animtime), W_Electro_CheckAttack);
467 self.electro_secondarytime = time + WEP_CVAR_SEC(electro, refire2) * W_WeaponRateFactor();
475 precache_model("models/weapons/g_electro.md3");
476 precache_model("models/weapons/v_electro.md3");
477 precache_model("models/weapons/h_electro.iqm");
478 precache_sound("weapons/electro_bounce.wav");
479 precache_sound("weapons/electro_fire.wav");
480 precache_sound("weapons/electro_fire2.wav");
481 precache_sound("weapons/electro_impact.wav");
482 precache_sound("weapons/electro_impact_combo.wav");
483 ELECTRO_SETTINGS(WEP_SKIPCVAR, WEP_SET_PROP)
488 self.current_ammo = ammo_cells;
493 ammo_amount = self.ammo_cells >= WEP_CVAR_PRI(electro, ammo);
494 ammo_amount += self.(weapon_load[WEP_ELECTRO]) >= WEP_CVAR_PRI(electro, ammo);
499 if(WEP_CVAR(electro, combo_safeammocheck)) // true if you can fire at least one secondary blob AND one primary shot after it, otherwise false.
501 ammo_amount = self.ammo_cells >= WEP_CVAR_SEC(electro, ammo) + WEP_CVAR_PRI(electro, ammo);
502 ammo_amount += self.(weapon_load[WEP_ELECTRO]) >= WEP_CVAR_SEC(electro, ammo) + WEP_CVAR_PRI(electro, ammo);
506 ammo_amount = self.ammo_cells >= WEP_CVAR_SEC(electro, ammo);
507 ammo_amount += self.(weapon_load[WEP_ELECTRO]) >= WEP_CVAR_SEC(electro, ammo);
513 ELECTRO_SETTINGS(WEP_CONFIG_WRITE_CVARS, WEP_CONFIG_WRITE_PROPS)
518 self.electro_secondarytime = time;
523 W_Reload(min(WEP_CVAR_PRI(electro, ammo), WEP_CVAR_SEC(electro, ammo)), "weapons/reload.wav");
526 case WR_SUICIDEMESSAGE:
528 if(w_deathtype & HITTYPE_SECONDARY)
529 return WEAPON_ELECTRO_SUICIDE_ORBS;
531 return WEAPON_ELECTRO_SUICIDE_BOLT;
535 if(w_deathtype & HITTYPE_SECONDARY)
537 return WEAPON_ELECTRO_MURDER_ORBS;
541 if(w_deathtype & HITTYPE_BOUNCE)
542 return WEAPON_ELECTRO_MURDER_COMBO;
544 return WEAPON_ELECTRO_MURDER_BOLT;
552 float W_Electro(float req)
556 case WR_IMPACTEFFECT:
559 org2 = w_org + w_backoff * 6;
560 if(w_deathtype & HITTYPE_SECONDARY)
562 pointparticles(particleeffectnum("electro_ballexplode"), org2, '0 0 0', 1);
564 sound(self, CH_SHOTS, "weapons/electro_impact.wav", VOL_BASE, ATTEN_NORM);
568 if(w_deathtype & HITTYPE_BOUNCE)
570 // this is sent as "primary (w_deathtype & HITTYPE_BOUNCE)" to distinguish it from (w_deathtype & HITTYPE_SECONDARY) bounced balls
571 pointparticles(particleeffectnum("electro_combo"), org2, '0 0 0', 1);
573 sound(self, CH_SHOTS, "weapons/electro_impact_combo.wav", VOL_BASE, ATTEN_NORM);
577 pointparticles(particleeffectnum("electro_impact"), org2, '0 0 0', 1);
579 sound(self, CH_SHOTS, "weapons/electro_impact.wav", VOL_BASE, ATTEN_NORM);
587 precache_sound("weapons/electro_impact.wav");
588 precache_sound("weapons/electro_impact_combo.wav");