3 /* WEP_##id */ ELECTRO,
4 /* function */ W_Electro,
5 /* ammotype */ ammo_cells,
7 /* flags */ WEP_FLAG_NORMAL | WEP_FLAG_RELOADABLE | WEP_FLAG_CANCLIMB | 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) \
59 w_prop(id, sn, float, weaponthrowable, weaponthrowable)
62 ELECTRO_SETTINGS(WEP_ADD_CVAR, WEP_ADD_PROP)
64 .float electro_secondarytime;
65 void W_Electro_ExplodeCombo(void);
69 void spawnfunc_weapon_electro(void) { 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(void)
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(
257 "weapons/electro_fire.wav",
259 WEP_CVAR_PRI(electro, damage)
262 pointparticles(particleeffectnum("electro_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
265 proj.classname = "electro_bolt";
266 proj.owner = proj.realowner = self;
267 proj.bot_dodge = TRUE;
268 proj.bot_dodgerating = WEP_CVAR_PRI(electro, damage);
269 proj.use = W_Electro_Explode;
270 proj.think = W_Electro_Bolt_Think;
271 proj.nextthink = time;
272 proj.ltime = time + WEP_CVAR_PRI(electro, lifetime);
273 PROJECTILE_MAKETRIGGER(proj);
274 proj.projectiledeathtype = WEP_ELECTRO;
275 setorigin(proj, w_shotorg);
277 proj.movetype = MOVETYPE_FLY;
278 W_SetupProjVelocity_PRI(proj, electro);
279 proj.angles = vectoangles(proj.velocity);
280 proj.touch = W_Electro_TouchExplode;
281 setsize(proj, '0 0 -3', '0 0 -3');
282 proj.flags = FL_PROJECTILE;
283 proj.missile_flags = MIF_SPLASH;
285 CSQCProjectile(proj, TRUE, PROJECTILE_ELECTRO_BEAM, TRUE);
287 other = proj; MUTATOR_CALLHOOK(EditProjectile);
290 void W_Electro_Orb_Touch(void)
293 if(other.takedamage == DAMAGE_AIM)
294 { if(WEP_CVAR_SEC(electro, touchexplode)) { W_Electro_Explode(); } }
297 //UpdateCSQCProjectile(self);
298 spamsound(self, CH_SHOTS, "weapons/electro_bounce.wav", VOL_BASE, ATTEN_NORM);
299 self.projectiledeathtype |= HITTYPE_BOUNCE;
303 void W_Electro_Orb_Damage(entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
308 // note: combos are usually triggered by W_Electro_TriggerCombo, not damage
309 float is_combo = (inflictor.classname == "electro_orb_chain" || inflictor.classname == "electro_bolt");
311 if(!W_CheckProjectileDamage(inflictor.realowner, self.realowner, deathtype, (is_combo ? 1 : -1)))
312 return; // g_projectiles_damage says to halt
314 self.health = self.health - damage;
317 self.takedamage = DAMAGE_NO;
318 self.nextthink = time;
321 // change owner to whoever caused the combo explosion
322 self.realowner = inflictor.realowner;
323 self.classname = "electro_orb_chain";
324 self.think = W_Electro_ExplodeCombo;
325 self.nextthink = time +
327 // bound the length, inflictor may be in a galaxy far far away (warpzones)
329 WEP_CVAR(electro, combo_radius),
330 vlen(self.origin - inflictor.origin)
333 // delay combo chains, looks cooler
334 WEP_CVAR(electro, combo_speed)
339 self.use = W_Electro_Explode;
340 self.think = adaptor_think2use; // not _hittype_splash, as this runs "immediately"
345 void W_Electro_Attack_Orb(void)
347 W_DecreaseAmmo(WEP_CVAR_SEC(electro, ammo));
349 W_SetupShot_ProjectileSize(
355 "weapons/electro_fire2.wav",
357 WEP_CVAR_SEC(electro, damage)
360 w_shotdir = v_forward; // no TrueAim for grenades please
362 pointparticles(particleeffectnum("electro_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
364 entity proj = spawn();
365 proj.classname = "electro_orb";
366 proj.owner = proj.realowner = self;
367 proj.use = W_Electro_Explode;
368 proj.think = adaptor_think2use_hittype_splash;
369 proj.bot_dodge = TRUE;
370 proj.bot_dodgerating = WEP_CVAR_SEC(electro, damage);
371 proj.nextthink = time + WEP_CVAR_SEC(electro, lifetime);
372 PROJECTILE_MAKETRIGGER(proj);
373 proj.projectiledeathtype = WEP_ELECTRO | HITTYPE_SECONDARY;
374 setorigin(proj, w_shotorg);
376 //proj.glow_size = 50;
377 //proj.glow_color = 45;
378 proj.movetype = MOVETYPE_BOUNCE;
379 W_SetupProjVelocity_UP_SEC(proj, electro);
380 proj.touch = W_Electro_Orb_Touch;
381 setsize(proj, '0 0 -4', '0 0 -4');
382 proj.takedamage = DAMAGE_YES;
383 proj.damageforcescale = WEP_CVAR_SEC(electro, damageforcescale);
384 proj.health = WEP_CVAR_SEC(electro, health);
385 proj.event_damage = W_Electro_Orb_Damage;
386 proj.flags = FL_PROJECTILE;
387 proj.damagedbycontents = (WEP_CVAR_SEC(electro, damagedbycontents));
389 proj.bouncefactor = WEP_CVAR_SEC(electro, bouncefactor);
390 proj.bouncestop = WEP_CVAR_SEC(electro, bouncestop);
391 proj.missile_flags = MIF_SPLASH | MIF_ARC;
396 copyentity(proj, p2);
397 setmodel(p2, "models/ebomb.mdl");
398 setsize(p2, proj.mins, proj.maxs);
401 CSQCProjectile(proj, TRUE, PROJECTILE_ELECTRO, FALSE); // no culling, it has sound
403 other = proj; MUTATOR_CALLHOOK(EditProjectile);
406 void W_Electro_CheckAttack(void)
408 if(self.electro_count > 1)
409 if(self.BUTTON_ATCK2)
410 if(weapon_prepareattack(1, -1))
412 W_Electro_Attack_Orb();
413 self.electro_count -= 1;
414 weapon_thinkf(WFRAME_FIRE2, WEP_CVAR_SEC(electro, animtime), W_Electro_CheckAttack);
417 // WEAPONTODO: when the player releases the button, cut down the length of refire2?
421 .float bot_secondary_electromooth;
422 float W_Electro(float req)
429 self.BUTTON_ATCK = self.BUTTON_ATCK2 = FALSE;
430 if(vlen(self.origin-self.enemy.origin) > 1000) { self.bot_secondary_electromooth = 0; }
431 if(self.bot_secondary_electromooth == 0)
435 if(WEP_CVAR_PRI(electro, speed))
436 shoot = bot_aim(WEP_CVAR_PRI(electro, speed), 0, WEP_CVAR_PRI(electro, lifetime), FALSE);
438 shoot = bot_aim(1000000, 0, 0.001, FALSE);
442 self.BUTTON_ATCK = TRUE;
443 if(random() < 0.01) self.bot_secondary_electromooth = 1;
448 if(bot_aim(WEP_CVAR_SEC(electro, speed), WEP_CVAR_SEC(electro, speed_up), WEP_CVAR_SEC(electro, lifetime), TRUE))
450 self.BUTTON_ATCK2 = TRUE;
451 if(random() < 0.03) self.bot_secondary_electromooth = 0;
459 if(autocvar_g_balance_electro_reload_ammo) // forced reload // WEAPONTODO
462 if(self.clip_load >= WEP_CVAR_PRI(electro, ammo))
464 if(self.clip_load >= WEP_CVAR_SEC(electro, ammo))
469 WEP_ACTION(self.weapon, WR_RELOAD);
478 if(weapon_prepareattack(0, WEP_CVAR_PRI(electro, refire)))
480 W_Electro_Attack_Bolt();
481 weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_PRI(electro, animtime), w_ready);
484 else if(self.BUTTON_ATCK2)
486 if(time >= self.electro_secondarytime)
487 if(weapon_prepareattack(1, WEP_CVAR_SEC(electro, refire)))
489 W_Electro_Attack_Orb();
490 self.electro_count = WEP_CVAR_SEC(electro, count);
491 weapon_thinkf(WFRAME_FIRE2, WEP_CVAR_SEC(electro, animtime), W_Electro_CheckAttack);
492 self.electro_secondarytime = time + WEP_CVAR_SEC(electro, refire2) * W_WeaponRateFactor();
500 precache_model("models/weapons/g_electro.md3");
501 precache_model("models/weapons/v_electro.md3");
502 precache_model("models/weapons/h_electro.iqm");
503 precache_sound("weapons/electro_bounce.wav");
504 precache_sound("weapons/electro_fire.wav");
505 precache_sound("weapons/electro_fire2.wav");
506 precache_sound("weapons/electro_impact.wav");
507 precache_sound("weapons/electro_impact_combo.wav");
508 ELECTRO_SETTINGS(WEP_SKIP_CVAR, WEP_SET_PROP)
513 ammo_amount = self.WEP_AMMO(ELECTRO) >= WEP_CVAR_PRI(electro, ammo);
514 ammo_amount += self.(weapon_load[WEP_ELECTRO]) >= WEP_CVAR_PRI(electro, ammo);
519 if(WEP_CVAR(electro, combo_safeammocheck)) // true if you can fire at least one secondary blob AND one primary shot after it, otherwise false.
521 ammo_amount = self.WEP_AMMO(ELECTRO) >= WEP_CVAR_SEC(electro, ammo) + WEP_CVAR_PRI(electro, ammo);
522 ammo_amount += self.(weapon_load[WEP_ELECTRO]) >= WEP_CVAR_SEC(electro, ammo) + WEP_CVAR_PRI(electro, ammo);
526 ammo_amount = self.WEP_AMMO(ELECTRO) >= WEP_CVAR_SEC(electro, ammo);
527 ammo_amount += self.(weapon_load[WEP_ELECTRO]) >= WEP_CVAR_SEC(electro, ammo);
533 ELECTRO_SETTINGS(WEP_CONFIG_WRITE_CVARS, WEP_CONFIG_WRITE_PROPS)
538 self.electro_secondarytime = time;
543 W_Reload(min(WEP_CVAR_PRI(electro, ammo), WEP_CVAR_SEC(electro, ammo)), "weapons/reload.wav");
546 case WR_SUICIDEMESSAGE:
548 if(w_deathtype & HITTYPE_SECONDARY)
549 return WEAPON_ELECTRO_SUICIDE_ORBS;
551 return WEAPON_ELECTRO_SUICIDE_BOLT;
555 if(w_deathtype & HITTYPE_SECONDARY)
557 return WEAPON_ELECTRO_MURDER_ORBS;
561 if(w_deathtype & HITTYPE_BOUNCE)
562 return WEAPON_ELECTRO_MURDER_COMBO;
564 return WEAPON_ELECTRO_MURDER_BOLT;
572 float W_Electro(float req)
576 case WR_IMPACTEFFECT:
579 org2 = w_org + w_backoff * 6;
580 if(w_deathtype & HITTYPE_SECONDARY)
582 pointparticles(particleeffectnum("electro_ballexplode"), org2, '0 0 0', 1);
584 sound(self, CH_SHOTS, "weapons/electro_impact.wav", VOL_BASE, ATTEN_NORM);
588 if(w_deathtype & HITTYPE_BOUNCE)
590 // this is sent as "primary (w_deathtype & HITTYPE_BOUNCE)" to distinguish it from (w_deathtype & HITTYPE_SECONDARY) bounced balls
591 pointparticles(particleeffectnum("electro_combo"), org2, '0 0 0', 1);
593 sound(self, CH_SHOTS, "weapons/electro_impact_combo.wav", VOL_BASE, ATTEN_NORM);
597 pointparticles(particleeffectnum("electro_impact"), org2, '0 0 0', 1);
599 sound(self, CH_SHOTS, "weapons/electro_impact.wav", VOL_BASE, ATTEN_NORM);
607 precache_sound("weapons/electro_impact.wav");
608 precache_sound("weapons/electro_impact_combo.wav");
613 // no weapon specific image for this weapon