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 /* modelname */ "electro",
11 /* simplemdl */ "foobar",
12 /* crosshair */ "gfx/crosshairelectro 0.5",
13 /* wepimg */ "weaponelectro",
14 /* refname */ "electro",
15 /* wepname */ _("Electro")
18 #define ELECTRO_SETTINGS(w_cvar,w_prop) ELECTRO_SETTINGS_LIST(w_cvar, w_prop, ELECTRO, electro)
19 #define ELECTRO_SETTINGS_LIST(w_cvar,w_prop,id,sn) \
20 w_cvar(id, sn, BOTH, ammo) \
21 w_cvar(id, sn, BOTH, animtime) \
22 w_cvar(id, sn, BOTH, damage) \
23 w_cvar(id, sn, BOTH, edgedamage) \
24 w_cvar(id, sn, BOTH, force) \
25 w_cvar(id, sn, BOTH, radius) \
26 w_cvar(id, sn, BOTH, refire) \
27 w_cvar(id, sn, BOTH, speed) \
28 w_cvar(id, sn, BOTH, spread) \
29 w_cvar(id, sn, BOTH, lifetime) \
30 w_cvar(id, sn, PRI, comboradius) \
31 w_cvar(id, sn, PRI, midaircombo_explode) \
32 w_cvar(id, sn, PRI, midaircombo_interval) \
33 w_cvar(id, sn, PRI, midaircombo_radius) \
34 w_cvar(id, sn, SEC, bouncefactor) \
35 w_cvar(id, sn, SEC, bouncestop) \
36 w_cvar(id, sn, SEC, count) \
37 w_cvar(id, sn, SEC, damageforcescale) \
38 w_cvar(id, sn, SEC, damagedbycontents) \
39 w_cvar(id, sn, SEC, health) \
40 w_cvar(id, sn, SEC, refire2) \
41 w_cvar(id, sn, SEC, speed_up) \
42 w_cvar(id, sn, SEC, speed_z) \
43 w_cvar(id, sn, SEC, touchexplode) \
44 w_cvar(id, sn, NONE, combo_comboradius) \
45 w_cvar(id, sn, NONE, combo_comboradius_thruwall) \
46 w_cvar(id, sn, NONE, combo_damage) \
47 w_cvar(id, sn, NONE, combo_edgedamage) \
48 w_cvar(id, sn, NONE, combo_force) \
49 w_cvar(id, sn, NONE, combo_radius) \
50 w_cvar(id, sn, NONE, combo_speed) \
51 w_cvar(id, sn, NONE, combo_safeammocheck) \
52 w_prop(id, sn, float, reloading_ammo, reload_ammo) \
53 w_prop(id, sn, float, reloading_time, reload_time) \
54 w_prop(id, sn, float, switchdelay_raise, switchdelay_raise) \
55 w_prop(id, sn, float, switchdelay_drop, switchdelay_drop) \
56 w_prop(id, sn, string, weaponreplace, weaponreplace) \
57 w_prop(id, sn, float, weaponstart, weaponstart) \
58 w_prop(id, sn, float, weaponstartoverride, weaponstartoverride)
61 ELECTRO_SETTINGS(WEP_ADD_CVAR, WEP_ADD_PROP)
63 .float electro_secondarytime;
64 void W_Electro_ExplodeCombo(void);
68 void spawnfunc_weapon_electro() { weapon_defaultspawnfunc(WEP_ELECTRO); }
70 void W_Electro_TriggerCombo(vector org, float rad, entity own)
72 entity e = WarpZone_FindRadius(org, rad, !WEP_CVAR(electro, combo_comboradius_thruwall));
75 if(e.classname == "electro_orb")
77 // do we allow thruwall triggering?
78 if(WEP_CVAR(electro, combo_comboradius_thruwall))
80 // if distance is greater than thruwall distance, check to make sure it's not through a wall
81 if(vlen(e.WarpZone_findradius_dist) > WEP_CVAR(electro, combo_comboradius_thruwall))
83 WarpZone_TraceLine(org, e.origin, MOVE_NOMONSTERS, e);
84 if(trace_fraction != 1)
86 // trigger is through a wall and outside of thruwall range, abort
93 // change owner to whoever caused the combo explosion
95 e.takedamage = DAMAGE_NO;
96 e.classname = "electro_orb_chain";
98 // now set the next one to trigger as well
99 e.think = W_Electro_ExplodeCombo;
101 // delay combo chains, looks cooler
106 (WEP_CVAR(electro, combo_speed) ?
107 (vlen(e.WarpZone_findradius_dist) / WEP_CVAR(electro, combo_speed))
117 void W_Electro_ExplodeCombo(void)
119 W_Electro_TriggerCombo(self.origin, WEP_CVAR(electro, combo_comboradius), self.realowner);
121 self.event_damage = func_null;
126 WEP_CVAR(electro, combo_damage),
127 WEP_CVAR(electro, combo_edgedamage),
128 WEP_CVAR(electro, combo_radius),
131 WEP_CVAR(electro, combo_force),
132 WEP_ELECTRO | HITTYPE_BOUNCE, // use THIS type for a combo because primary can't bounce
139 void W_Electro_Explode(void)
141 if(other.takedamage == DAMAGE_AIM)
143 if(DIFF_TEAM(self.realowner, other))
144 if(other.deadflag == DEAD_NO)
146 Send_Notification(NOTIF_ONE, self.realowner, MSG_ANNCE, ANNCE_ACHIEVEMENT_ELECTROBITCH);
148 self.event_damage = func_null;
149 self.takedamage = DAMAGE_NO;
151 if(self.movetype == MOVETYPE_BOUNCE)
156 WEP_CVAR_SEC(electro, damage),
157 WEP_CVAR_SEC(electro, edgedamage),
158 WEP_CVAR_SEC(electro, radius),
161 WEP_CVAR_SEC(electro, force),
162 self.projectiledeathtype,
168 W_Electro_TriggerCombo(self.origin, WEP_CVAR_PRI(electro, comboradius), self.realowner);
172 WEP_CVAR_PRI(electro, damage),
173 WEP_CVAR_PRI(electro, edgedamage),
174 WEP_CVAR_PRI(electro, radius),
177 WEP_CVAR_PRI(electro, force),
178 self.projectiledeathtype,
186 void W_Electro_TouchExplode(void)
192 void W_Electro_Bolt_Think()
194 if(time >= self.ltime)
200 if(WEP_CVAR_PRI(electro, midaircombo_radius))
203 entity e = WarpZone_FindRadius(self.origin, WEP_CVAR_PRI(electro, midaircombo_radius), TRUE);
205 // loop through nearby orbs and trigger them
208 if(e.classname == "electro_orb")
210 // change owner to whoever caused the combo explosion
211 e.realowner = self.realowner;
212 e.takedamage = DAMAGE_NO;
213 e.classname = "electro_orb_chain";
215 // now set the next one to trigger as well
216 e.think = W_Electro_ExplodeCombo;
218 // delay combo chains, looks cooler
223 (WEP_CVAR(electro, combo_speed) ?
224 (vlen(e.WarpZone_findradius_dist) / WEP_CVAR(electro, combo_speed))
235 // if we triggered an orb, should we explode? if not, lets try again next time
236 if(found && WEP_CVAR_PRI(electro, midaircombo_explode))
239 { self.nextthink = min(time + WEP_CVAR_PRI(electro, midaircombo_interval), self.ltime); }
241 else { self.nextthink = self.ltime; }
244 void W_Electro_Attack_Bolt(void)
248 W_DecreaseAmmo(WEP_CVAR_PRI(electro, ammo));
250 W_SetupShot_ProjectileSize(self, '0 0 -3', '0 0 -3', FALSE, 2, "weapons/electro_fire.wav", CH_WEAPON_A, WEP_CVAR_PRI(electro, damage));
252 pointparticles(particleeffectnum("electro_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
255 proj.classname = "electro_bolt";
256 proj.owner = proj.realowner = self;
257 proj.bot_dodge = TRUE;
258 proj.bot_dodgerating = WEP_CVAR_PRI(electro, damage);
259 proj.use = W_Electro_Explode;
260 proj.think = W_Electro_Bolt_Think;
261 proj.nextthink = time;
262 proj.ltime = time + WEP_CVAR_PRI(electro, lifetime);
263 PROJECTILE_MAKETRIGGER(proj);
264 proj.projectiledeathtype = WEP_ELECTRO;
265 setorigin(proj, w_shotorg);
267 proj.movetype = MOVETYPE_FLY;
268 W_SetupProjVelocity_PRI(proj, electro);
269 proj.angles = vectoangles(proj.velocity);
270 proj.touch = W_Electro_TouchExplode;
271 setsize(proj, '0 0 -3', '0 0 -3');
272 proj.flags = FL_PROJECTILE;
273 proj.missile_flags = MIF_SPLASH;
275 CSQCProjectile(proj, TRUE, PROJECTILE_ELECTRO_BEAM, TRUE);
277 other = proj; MUTATOR_CALLHOOK(EditProjectile);
280 void W_Electro_Orb_Touch(void)
283 if(other.takedamage == DAMAGE_AIM)
284 { if(WEP_CVAR_SEC(electro, touchexplode)) { W_Electro_Explode(); } }
287 //UpdateCSQCProjectile(self);
288 spamsound(self, CH_SHOTS, "weapons/electro_bounce.wav", VOL_BASE, ATTEN_NORM);
289 self.projectiledeathtype |= HITTYPE_BOUNCE;
293 void W_Electro_Orb_Damage(entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
298 // note: combos are usually triggered by W_Electro_TriggerCombo, not damage
299 float is_combo = (inflictor.classname == "electro_orb_chain" || inflictor.classname == "electro_bolt");
301 if(!W_CheckProjectileDamage(inflictor.realowner, self.realowner, deathtype, (is_combo ? 1 : -1)))
302 return; // g_projectiles_damage says to halt
304 self.health = self.health - damage;
307 self.takedamage = DAMAGE_NO;
308 self.nextthink = time;
311 // change owner to whoever caused the combo explosion
312 self.realowner = inflictor.realowner;
313 self.classname = "electro_orb_chain";
314 self.think = W_Electro_ExplodeCombo;
315 self.nextthink = time +
317 // bound the length, inflictor may be in a galaxy far far away (warpzones)
319 WEP_CVAR(electro, combo_radius),
320 vlen(self.origin - inflictor.origin)
323 // delay combo chains, looks cooler
324 WEP_CVAR(electro, combo_speed)
329 self.use = W_Electro_Explode;
330 self.think = adaptor_think2use; // not _hittype_splash, as this runs "immediately"
335 void W_Electro_Attack_Orb(void)
337 W_DecreaseAmmo(WEP_CVAR_SEC(electro, ammo));
339 W_SetupShot_ProjectileSize(self, '0 0 -4', '0 0 -4', FALSE, 2, "weapons/electro_fire2.wav", CH_WEAPON_A, WEP_CVAR_SEC(electro, damage));
341 w_shotdir = v_forward; // no TrueAim for grenades please
343 pointparticles(particleeffectnum("electro_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
345 entity proj = spawn();
346 proj.classname = "electro_orb";
347 proj.owner = proj.realowner = self;
348 proj.use = W_Electro_Explode;
349 proj.think = adaptor_think2use_hittype_splash;
350 proj.bot_dodge = TRUE;
351 proj.bot_dodgerating = WEP_CVAR_SEC(electro, damage);
352 proj.nextthink = time + WEP_CVAR_SEC(electro, lifetime);
353 PROJECTILE_MAKETRIGGER(proj);
354 proj.projectiledeathtype = WEP_ELECTRO | HITTYPE_SECONDARY;
355 setorigin(proj, w_shotorg);
357 //proj.glow_size = 50;
358 //proj.glow_color = 45;
359 proj.movetype = MOVETYPE_BOUNCE;
360 W_SetupProjVelocity_UP_SEC(proj, electro);
361 proj.touch = W_Electro_Orb_Touch;
362 setsize(proj, '0 0 -4', '0 0 -4');
363 proj.takedamage = DAMAGE_YES;
364 proj.damageforcescale = WEP_CVAR_SEC(electro, damageforcescale);
365 proj.health = WEP_CVAR_SEC(electro, health);
366 proj.event_damage = W_Electro_Orb_Damage;
367 proj.flags = FL_PROJECTILE;
368 proj.damagedbycontents = (WEP_CVAR_SEC(electro, damagedbycontents));
370 proj.bouncefactor = WEP_CVAR_SEC(electro, bouncefactor);
371 proj.bouncestop = WEP_CVAR_SEC(electro, bouncestop);
372 proj.missile_flags = MIF_SPLASH | MIF_ARC;
377 copyentity(proj, p2);
378 setmodel(p2, "models/ebomb.mdl");
379 setsize(p2, proj.mins, proj.maxs);
382 CSQCProjectile(proj, TRUE, PROJECTILE_ELECTRO, FALSE); // no culling, it has sound
384 other = proj; MUTATOR_CALLHOOK(EditProjectile);
387 void W_Electro_CheckAttack()
389 if(self.electro_count > 1)
390 if(self.BUTTON_ATCK2)
391 if(weapon_prepareattack(1, -1))
393 W_Electro_Attack_Orb();
394 self.electro_count -= 1;
395 weapon_thinkf(WFRAME_FIRE2, WEP_CVAR_SEC(electro, animtime), W_Electro_CheckAttack);
398 // WEAPONTODO: when the player releases the button, cut down the length of refire2?
402 .float bot_secondary_electromooth;
403 float W_Electro(float req)
410 self.BUTTON_ATCK = self.BUTTON_ATCK2 = FALSE;
411 if(vlen(self.origin-self.enemy.origin) > 1000) { self.bot_secondary_electromooth = 0; }
412 if(self.bot_secondary_electromooth == 0)
416 if(WEP_CVAR_PRI(electro, speed))
417 shoot = bot_aim(WEP_CVAR_PRI(electro, speed), 0, WEP_CVAR_PRI(electro, lifetime), FALSE);
419 shoot = bot_aim(1000000, 0, 0.001, FALSE);
423 self.BUTTON_ATCK = TRUE;
424 if(random() < 0.01) self.bot_secondary_electromooth = 1;
429 if(bot_aim(WEP_CVAR_SEC(electro, speed), WEP_CVAR_SEC(electro, speed_up), WEP_CVAR_SEC(electro, lifetime), TRUE))
431 self.BUTTON_ATCK2 = TRUE;
432 if(random() < 0.03) self.bot_secondary_electromooth = 0;
440 if(autocvar_g_balance_electro_reload_ammo) // forced reload // WEAPONTODO
443 if(self.clip_load >= WEP_CVAR_PRI(electro, ammo))
445 if(self.clip_load >= WEP_CVAR_SEC(electro, ammo))
450 WEP_ACTION(self.weapon, WR_RELOAD);
459 if(weapon_prepareattack(0, WEP_CVAR_PRI(electro, refire)))
461 W_Electro_Attack_Bolt();
462 weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_PRI(electro, animtime), w_ready);
465 else if(self.BUTTON_ATCK2)
467 if(time >= self.electro_secondarytime)
468 if(weapon_prepareattack(1, WEP_CVAR_SEC(electro, refire)))
470 W_Electro_Attack_Orb();
471 self.electro_count = WEP_CVAR_SEC(electro, count);
472 weapon_thinkf(WFRAME_FIRE2, WEP_CVAR_SEC(electro, animtime), W_Electro_CheckAttack);
473 self.electro_secondarytime = time + WEP_CVAR_SEC(electro, refire2) * W_WeaponRateFactor();
481 precache_model("models/weapons/g_electro.md3");
482 precache_model("models/weapons/v_electro.md3");
483 precache_model("models/weapons/h_electro.iqm");
484 precache_sound("weapons/electro_bounce.wav");
485 precache_sound("weapons/electro_fire.wav");
486 precache_sound("weapons/electro_fire2.wav");
487 precache_sound("weapons/electro_impact.wav");
488 precache_sound("weapons/electro_impact_combo.wav");
489 ELECTRO_SETTINGS(WEP_SKIP_CVAR, WEP_SET_PROP)
494 ammo_amount = self.WEP_AMMO(ELECTRO) >= WEP_CVAR_PRI(electro, ammo);
495 ammo_amount += self.(weapon_load[WEP_ELECTRO]) >= WEP_CVAR_PRI(electro, ammo);
500 if(WEP_CVAR(electro, combo_safeammocheck)) // true if you can fire at least one secondary blob AND one primary shot after it, otherwise false.
502 ammo_amount = self.WEP_AMMO(ELECTRO) >= WEP_CVAR_SEC(electro, ammo) + WEP_CVAR_PRI(electro, ammo);
503 ammo_amount += self.(weapon_load[WEP_ELECTRO]) >= WEP_CVAR_SEC(electro, ammo) + WEP_CVAR_PRI(electro, ammo);
507 ammo_amount = self.WEP_AMMO(ELECTRO) >= WEP_CVAR_SEC(electro, ammo);
508 ammo_amount += self.(weapon_load[WEP_ELECTRO]) >= WEP_CVAR_SEC(electro, ammo);
514 ELECTRO_SETTINGS(WEP_CONFIG_WRITE_CVARS, WEP_CONFIG_WRITE_PROPS)
519 self.electro_secondarytime = time;
524 W_Reload(min(WEP_CVAR_PRI(electro, ammo), WEP_CVAR_SEC(electro, ammo)), "weapons/reload.wav");
527 case WR_SUICIDEMESSAGE:
529 if(w_deathtype & HITTYPE_SECONDARY)
530 return WEAPON_ELECTRO_SUICIDE_ORBS;
532 return WEAPON_ELECTRO_SUICIDE_BOLT;
536 if(w_deathtype & HITTYPE_SECONDARY)
538 return WEAPON_ELECTRO_MURDER_ORBS;
542 if(w_deathtype & HITTYPE_BOUNCE)
543 return WEAPON_ELECTRO_MURDER_COMBO;
545 return WEAPON_ELECTRO_MURDER_BOLT;
553 float W_Electro(float req)
557 case WR_IMPACTEFFECT:
560 org2 = w_org + w_backoff * 6;
561 if(w_deathtype & HITTYPE_SECONDARY)
563 pointparticles(particleeffectnum("electro_ballexplode"), org2, '0 0 0', 1);
565 sound(self, CH_SHOTS, "weapons/electro_impact.wav", VOL_BASE, ATTEN_NORM);
569 if(w_deathtype & HITTYPE_BOUNCE)
571 // this is sent as "primary (w_deathtype & HITTYPE_BOUNCE)" to distinguish it from (w_deathtype & HITTYPE_SECONDARY) bounced balls
572 pointparticles(particleeffectnum("electro_combo"), org2, '0 0 0', 1);
574 sound(self, CH_SHOTS, "weapons/electro_impact_combo.wav", VOL_BASE, ATTEN_NORM);
578 pointparticles(particleeffectnum("electro_impact"), org2, '0 0 0', 1);
580 sound(self, CH_SHOTS, "weapons/electro_impact.wav", VOL_BASE, ATTEN_NORM);
588 precache_sound("weapons/electro_impact.wav");
589 precache_sound("weapons/electro_impact_combo.wav");
594 // no weapon specific image for this weapon