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, takedamageexplode) \
35 w_cvar(WEP_ELECTRO, electro, MO_SEC, health) \
36 w_cvar(WEP_ELECTRO, electro, MO_SEC, refire2) \
37 w_cvar(WEP_ELECTRO, electro, MO_SEC, speed_up) \
38 w_cvar(WEP_ELECTRO, electro, MO_SEC, speed_z) \
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, reloading_ammo, reload_ammo) \
48 w_prop(WEP_ELECTRO, electro, reloading_time, reload_time) \
49 w_prop(WEP_ELECTRO, electro, switchdelay_raise, switchdelay_raise) \
50 w_prop(WEP_ELECTRO, electro, switchdelay_drop, switchdelay_drop)
53 ELECTRO_SETTINGS(WEP_ADD_CVAR, WEP_ADD_PROP)
55 .float electro_secondarytime;
56 void W_Plasma_Explode_Combo(void);
60 void spawnfunc_weapon_electro() { weapon_defaultspawnfunc(WEP_ELECTRO); }
62 void W_Plasma_TriggerCombo(vector org, float rad, entity own)
64 entity e = WarpZone_FindRadius(org, rad, !WEP_CVAR(electro, combo_comboradius_thruwall));
67 if(e.classname == "plasma")
69 // do we allow thruwall triggering?
70 if(WEP_CVAR(electro, combo_comboradius_thruwall))
72 // if distance is greater than thruwall distance, check to make sure it's not through a wall
73 if(vlen(e.WarpZone_findradius_dist) > WEP_CVAR(electro, combo_comboradius_thruwall))
75 WarpZone_TraceLine(org, e.origin, MOVE_NOMONSTERS, e);
76 if(trace_fraction != 1)
78 // trigger is through a wall and outside of thruwall range, abort
85 // change owner to whoever caused the combo explosion
87 e.takedamage = DAMAGE_NO;
88 e.classname = "plasma_chain";
90 // now set the next one to trigger as well
91 e.think = W_Plasma_Explode_Combo;
93 // delay combo chains, looks cooler
98 (WEP_CVAR(electro, combo_speed) ?
99 (vlen(e.WarpZone_findradius_dist) / WEP_CVAR(electro, combo_speed))
109 void W_Plasma_Explode(void)
111 if(other.takedamage == DAMAGE_AIM)
113 if(DIFF_TEAM(self.realowner, other))
114 if(other.deadflag == DEAD_NO)
116 Send_Notification(NOTIF_ONE, self.realowner, MSG_ANNCE, ANNCE_ACHIEVEMENT_ELECTROBITCH);
118 self.event_damage = func_null;
119 self.takedamage = DAMAGE_NO;
121 if(self.movetype == MOVETYPE_BOUNCE)
126 WEP_CVAR_SEC(electro, damage),
127 WEP_CVAR_SEC(electro, edgedamage),
128 WEP_CVAR_SEC(electro, radius),
131 WEP_CVAR_SEC(electro, force),
132 self.projectiledeathtype,
138 W_Plasma_TriggerCombo(self.origin, WEP_CVAR_PRI(electro, comboradius), self.realowner);
142 WEP_CVAR_PRI(electro, damage),
143 WEP_CVAR_PRI(electro, edgedamage),
144 WEP_CVAR_PRI(electro, radius),
147 WEP_CVAR_PRI(electro, force),
148 self.projectiledeathtype,
156 void W_Plasma_Explode_Combo(void)
158 W_Plasma_TriggerCombo(self.origin, WEP_CVAR(electro, combo_comboradius), self.realowner);
160 self.event_damage = func_null;
165 WEP_CVAR(electro, combo_damage),
166 WEP_CVAR(electro, combo_edgedamage),
167 WEP_CVAR(electro, combo_radius),
170 WEP_CVAR(electro, combo_force),
171 WEP_ELECTRO | HITTYPE_BOUNCE, // use THIS type for a combo because primary can't bounce
178 void W_Plasma_Touch(void)
181 if(other.takedamage == DAMAGE_AIM)
182 { if(WEP_CVAR_SEC(electro, takedamageexplode)) { W_Plasma_Explode(); } }
185 //UpdateCSQCProjectile(self);
186 spamsound(self, CH_SHOTS, "weapons/electro_bounce.wav", VOL_BASE, ATTEN_NORM);
187 self.projectiledeathtype |= HITTYPE_BOUNCE;
191 void W_Plasma_TouchExplode(void)
197 void W_Plasma_Damage(entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
202 // note: combos are usually triggered by W_Plasma_TriggerCombo, not damage
203 float is_combo = (inflictor.classname == "plasma_chain" || inflictor.classname == "plasma_prim");
205 if(!W_CheckProjectileDamage(inflictor.realowner, self.realowner, deathtype, (is_combo ? 1 : -1)))
206 return; // g_projectiles_damage says to halt
208 self.health = self.health - damage;
211 self.takedamage = DAMAGE_NO;
212 self.nextthink = time;
215 // change owner to whoever caused the combo explosion
216 self.realowner = inflictor.realowner;
217 self.classname = "plasma_chain";
218 self.think = W_Plasma_Explode_Combo;
219 self.nextthink = time +
221 // bound the length, inflictor may be in a galaxy far far away (warpzones)
223 WEP_CVAR(electro, combo_radius),
224 vlen(self.origin - inflictor.origin)
227 // delay combo chains, looks cooler
228 WEP_CVAR(electro, combo_speed)
233 self.use = W_Plasma_Explode;
234 self.think = adaptor_think2use; // not _hittype_splash, as this runs "immediately"
239 void W_Plasma_Think()
241 if(time >= self.ltime)
247 if(WEP_CVAR_PRI(electro, midaircombo_radius))
250 entity e = WarpZone_FindRadius(self.origin, WEP_CVAR_PRI(electro, midaircombo_radius), TRUE);
252 // loop through nearby orbs and trigger them
255 if(e.classname == "plasma")
257 // change owner to whoever caused the combo explosion
258 e.realowner = self.realowner;
259 e.takedamage = DAMAGE_NO;
260 e.classname = "plasma_chain";
262 // now set the next one to trigger as well
263 e.think = W_Plasma_Explode_Combo;
265 // delay combo chains, looks cooler
270 (WEP_CVAR(electro, combo_speed) ?
271 (vlen(e.WarpZone_findradius_dist) / WEP_CVAR(electro, combo_speed))
282 // if we triggered an orb, should we explode? if not, lets try again next time
283 if(found && WEP_CVAR_PRI(electro, midaircombo_explode))
286 { self.nextthink = min(time + WEP_CVAR_PRI(electro, midaircombo_interval), self.ltime); }
288 else { self.nextthink = self.ltime; }
291 void W_Electro_Attack_Bolt(void)
295 W_DecreaseAmmo(ammo_cells, WEP_CVAR_PRI(electro, ammo), autocvar_g_balance_electro_reload_ammo);//weapontodo
297 W_SetupShot_ProjectileSize(self, '0 0 -3', '0 0 -3', FALSE, 2, "weapons/electro_fire.wav", CH_WEAPON_A, WEP_CVAR_PRI(electro, damage));
299 pointparticles(particleeffectnum("electro_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
302 proj.classname = "plasma_prim";
303 proj.owner = proj.realowner = self;
304 proj.bot_dodge = TRUE;
305 proj.bot_dodgerating = WEP_CVAR_PRI(electro, damage);
306 proj.use = W_Plasma_Explode;
307 proj.think = W_Plasma_Think;
308 proj.nextthink = time;
309 proj.ltime = time + WEP_CVAR_PRI(electro, lifetime);
310 PROJECTILE_MAKETRIGGER(proj);
311 proj.projectiledeathtype = WEP_ELECTRO;
312 setorigin(proj, w_shotorg);
314 proj.movetype = MOVETYPE_FLY;
315 WEP_SETUPPROJVELOCITY_PRI(proj, electro);
316 proj.angles = vectoangles(proj.velocity);
317 proj.touch = W_Plasma_TouchExplode;
318 setsize(proj, '0 0 -3', '0 0 -3');
319 proj.flags = FL_PROJECTILE;
320 proj.missile_flags = MIF_SPLASH;
322 CSQCProjectile(proj, TRUE, PROJECTILE_ELECTRO_BEAM, TRUE);
324 other = proj; MUTATOR_CALLHOOK(EditProjectile);
327 void W_Electro_Attack_Orbs(void)
329 W_DecreaseAmmo(ammo_cells, WEP_CVAR_SEC(electro, ammo), autocvar_g_balance_electro_reload_ammo);//weapontodo
331 W_SetupShot_ProjectileSize(self, '0 0 -4', '0 0 -4', FALSE, 2, "weapons/electro_fire2.wav", CH_WEAPON_A, WEP_CVAR_SEC(electro, damage));
333 w_shotdir = v_forward; // no TrueAim for grenades please
335 pointparticles(particleeffectnum("electro_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
337 entity proj = spawn();
338 proj.classname = "plasma";
339 proj.owner = proj.realowner = self;
340 proj.use = W_Plasma_Explode;
341 proj.think = adaptor_think2use_hittype_splash;
342 proj.bot_dodge = TRUE;
343 proj.bot_dodgerating = WEP_CVAR_SEC(electro, damage);
344 proj.nextthink = time + WEP_CVAR_SEC(electro, lifetime);
345 PROJECTILE_MAKETRIGGER(proj);
346 proj.projectiledeathtype = WEP_ELECTRO | HITTYPE_SECONDARY;
347 setorigin(proj, w_shotorg);
349 //proj.glow_size = 50;
350 //proj.glow_color = 45;
351 proj.movetype = MOVETYPE_BOUNCE;
352 WEP_SETUPPROJVELOCITY_UP_SEC(proj, electro);
353 proj.touch = W_Plasma_Touch;
354 setsize(proj, '0 0 -4', '0 0 -4');
355 proj.takedamage = DAMAGE_YES;
356 proj.damageforcescale = WEP_CVAR_SEC(electro, damageforcescale);
357 proj.health = WEP_CVAR_SEC(electro, health);
358 proj.event_damage = W_Plasma_Damage;
359 proj.flags = FL_PROJECTILE;
360 proj.damagedbycontents = (WEP_CVAR_SEC(electro, damagedbycontents));
362 proj.bouncefactor = WEP_CVAR_SEC(electro, bouncefactor);
363 proj.bouncestop = WEP_CVAR_SEC(electro, bouncestop);
364 proj.missile_flags = MIF_SPLASH | MIF_ARC;
369 copyentity(proj, p2);
370 setmodel(p2, "models/ebomb.mdl");
371 setsize(p2, proj.mins, proj.maxs);
374 CSQCProjectile(proj, TRUE, PROJECTILE_ELECTRO, FALSE); // no culling, it has sound
376 other = proj; MUTATOR_CALLHOOK(EditProjectile);
379 void W_Electro_CheckAttack()
381 if(self.electro_count > 1)
382 if(self.BUTTON_ATCK2)
383 if(weapon_prepareattack(1, -1))
385 W_Electro_Attack_Orbs();
386 self.electro_count -= 1;
387 weapon_thinkf(WFRAME_FIRE2, WEP_CVAR_SEC(electro, animtime), W_Electro_CheckAttack);
393 .float bot_secondary_electromooth;
394 float W_Electro(float req)
401 self.BUTTON_ATCK = self.BUTTON_ATCK2 = FALSE;
402 if(vlen(self.origin-self.enemy.origin) > 1000) { self.bot_secondary_electromooth = 0; }
403 if(self.bot_secondary_electromooth == 0)
407 if(WEP_CVAR_PRI(electro, speed))
408 shoot = bot_aim(WEP_CVAR_PRI(electro, speed), 0, WEP_CVAR_PRI(electro, lifetime), FALSE);
410 shoot = bot_aim(1000000, 0, 0.001, FALSE);
414 self.BUTTON_ATCK = TRUE;
415 if(random() < 0.01) self.bot_secondary_electromooth = 1;
420 if(bot_aim(WEP_CVAR_SEC(electro, speed), WEP_CVAR_SEC(electro, speed_up), WEP_CVAR_SEC(electro, lifetime), TRUE))
422 self.BUTTON_ATCK2 = TRUE;
423 if(random() < 0.03) self.bot_secondary_electromooth = 0;
431 if(autocvar_g_balance_electro_reload_ammo) // forced reload // WEAPONTODO
434 if(self.clip_load >= WEP_CVAR_PRI(electro, ammo))
436 if(self.clip_load >= WEP_CVAR_SEC(electro, ammo))
441 WEP_ACTION(self.weapon, WR_RELOAD);
450 if(weapon_prepareattack(0, WEP_CVAR_PRI(electro, refire)))
452 W_Electro_Attack_Bolt();
453 weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_PRI(electro, animtime), w_ready);
456 else if(self.BUTTON_ATCK2)
458 if(time >= self.electro_secondarytime)
459 if(weapon_prepareattack(1, WEP_CVAR_SEC(electro, refire)))
461 W_Electro_Attack_Orbs();
462 self.electro_count = WEP_CVAR_SEC(electro, count);
463 weapon_thinkf(WFRAME_FIRE2, WEP_CVAR_SEC(electro, animtime), W_Electro_CheckAttack);
464 self.electro_secondarytime = time + WEP_CVAR_SEC(electro, refire2) * W_WeaponRateFactor();
472 precache_model("models/weapons/g_electro.md3");
473 precache_model("models/weapons/v_electro.md3");
474 precache_model("models/weapons/h_electro.iqm");
475 precache_sound("weapons/electro_bounce.wav");
476 precache_sound("weapons/electro_fire.wav");
477 precache_sound("weapons/electro_fire2.wav");
478 precache_sound("weapons/electro_impact.wav");
479 precache_sound("weapons/electro_impact_combo.wav");
480 ELECTRO_SETTINGS(WEP_SKIPCVAR, WEP_SET_PROP)
485 self.current_ammo = ammo_cells;
490 ammo_amount = self.ammo_cells >= 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.ammo_cells >= 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.ammo_cells >= 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");