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 /* refname */ "electro",
14 /* wepname */ _("Electro")
17 #define ELECTRO_SETTINGS(w_cvar,w_prop) ELECTRO_SETTINGS_LIST(w_cvar, w_prop, ELECTRO, electro)
18 #define ELECTRO_SETTINGS_LIST(w_cvar,w_prop,id,sn) \
19 w_cvar(id, sn, BOTH, ammo) \
20 w_cvar(id, sn, BOTH, animtime) \
21 w_cvar(id, sn, BOTH, damage) \
22 w_cvar(id, sn, BOTH, edgedamage) \
23 w_cvar(id, sn, BOTH, force) \
24 w_cvar(id, sn, BOTH, radius) \
25 w_cvar(id, sn, BOTH, refire) \
26 w_cvar(id, sn, BOTH, speed) \
27 w_cvar(id, sn, BOTH, spread) \
28 w_cvar(id, sn, BOTH, lifetime) \
29 w_cvar(id, sn, PRI, comboradius) \
30 w_cvar(id, sn, PRI, midaircombo_explode) \
31 w_cvar(id, sn, PRI, midaircombo_interval) \
32 w_cvar(id, sn, PRI, midaircombo_radius) \
33 w_cvar(id, sn, SEC, bouncefactor) \
34 w_cvar(id, sn, SEC, bouncestop) \
35 w_cvar(id, sn, SEC, count) \
36 w_cvar(id, sn, SEC, damageforcescale) \
37 w_cvar(id, sn, SEC, damagedbycontents) \
38 w_cvar(id, sn, SEC, health) \
39 w_cvar(id, sn, SEC, refire2) \
40 w_cvar(id, sn, SEC, speed_up) \
41 w_cvar(id, sn, SEC, speed_z) \
42 w_cvar(id, sn, SEC, touchexplode) \
43 w_cvar(id, sn, NONE, combo_comboradius) \
44 w_cvar(id, sn, NONE, combo_comboradius_thruwall) \
45 w_cvar(id, sn, NONE, combo_damage) \
46 w_cvar(id, sn, NONE, combo_edgedamage) \
47 w_cvar(id, sn, NONE, combo_force) \
48 w_cvar(id, sn, NONE, combo_radius) \
49 w_cvar(id, sn, NONE, combo_speed) \
50 w_cvar(id, sn, NONE, combo_safeammocheck) \
51 w_prop(id, sn, float, reloading_ammo, reload_ammo) \
52 w_prop(id, sn, float, reloading_time, reload_time) \
53 w_prop(id, sn, float, switchdelay_raise, switchdelay_raise) \
54 w_prop(id, sn, float, switchdelay_drop, switchdelay_drop) \
55 w_prop(id, sn, string, weaponreplace, weaponreplace) \
56 w_prop(id, sn, float, weaponstart, weaponstart) \
57 w_prop(id, sn, float, weaponstartoverride, weaponstartoverride)
60 ELECTRO_SETTINGS(WEP_ADD_CVAR, WEP_ADD_PROP)
62 .float electro_secondarytime;
63 void W_Electro_ExplodeCombo(void);
67 void spawnfunc_weapon_electro() { weapon_defaultspawnfunc(WEP_ELECTRO); }
69 void W_Electro_TriggerCombo(vector org, float rad, entity own)
71 entity e = WarpZone_FindRadius(org, rad, !WEP_CVAR(electro, combo_comboradius_thruwall));
74 if(e.classname == "electro_orb")
76 // do we allow thruwall triggering?
77 if(WEP_CVAR(electro, combo_comboradius_thruwall))
79 // if distance is greater than thruwall distance, check to make sure it's not through a wall
80 if(vlen(e.WarpZone_findradius_dist) > WEP_CVAR(electro, combo_comboradius_thruwall))
82 WarpZone_TraceLine(org, e.origin, MOVE_NOMONSTERS, e);
83 if(trace_fraction != 1)
85 // trigger is through a wall and outside of thruwall range, abort
92 // change owner to whoever caused the combo explosion
94 e.takedamage = DAMAGE_NO;
95 e.classname = "electro_orb_chain";
97 // now set the next one to trigger as well
98 e.think = W_Electro_ExplodeCombo;
100 // delay combo chains, looks cooler
105 (WEP_CVAR(electro, combo_speed) ?
106 (vlen(e.WarpZone_findradius_dist) / WEP_CVAR(electro, combo_speed))
116 void W_Electro_ExplodeCombo(void)
118 W_Electro_TriggerCombo(self.origin, WEP_CVAR(electro, combo_comboradius), self.realowner);
120 self.event_damage = func_null;
125 WEP_CVAR(electro, combo_damage),
126 WEP_CVAR(electro, combo_edgedamage),
127 WEP_CVAR(electro, combo_radius),
130 WEP_CVAR(electro, combo_force),
131 WEP_ELECTRO | HITTYPE_BOUNCE, // use THIS type for a combo because primary can't bounce
138 void W_Electro_Explode(void)
140 if(other.takedamage == DAMAGE_AIM)
142 if(DIFF_TEAM(self.realowner, other))
143 if(other.deadflag == DEAD_NO)
145 Send_Notification(NOTIF_ONE, self.realowner, MSG_ANNCE, ANNCE_ACHIEVEMENT_ELECTROBITCH);
147 self.event_damage = func_null;
148 self.takedamage = DAMAGE_NO;
150 if(self.movetype == MOVETYPE_BOUNCE)
155 WEP_CVAR_SEC(electro, damage),
156 WEP_CVAR_SEC(electro, edgedamage),
157 WEP_CVAR_SEC(electro, radius),
160 WEP_CVAR_SEC(electro, force),
161 self.projectiledeathtype,
167 W_Electro_TriggerCombo(self.origin, WEP_CVAR_PRI(electro, comboradius), self.realowner);
171 WEP_CVAR_PRI(electro, damage),
172 WEP_CVAR_PRI(electro, edgedamage),
173 WEP_CVAR_PRI(electro, radius),
176 WEP_CVAR_PRI(electro, force),
177 self.projectiledeathtype,
185 void W_Electro_TouchExplode(void)
191 void W_Electro_Bolt_Think()
193 if(time >= self.ltime)
199 if(WEP_CVAR_PRI(electro, midaircombo_radius))
202 entity e = WarpZone_FindRadius(self.origin, WEP_CVAR_PRI(electro, midaircombo_radius), TRUE);
204 // loop through nearby orbs and trigger them
207 if(e.classname == "electro_orb")
209 // change owner to whoever caused the combo explosion
210 e.realowner = self.realowner;
211 e.takedamage = DAMAGE_NO;
212 e.classname = "electro_orb_chain";
214 // now set the next one to trigger as well
215 e.think = W_Electro_ExplodeCombo;
217 // delay combo chains, looks cooler
222 (WEP_CVAR(electro, combo_speed) ?
223 (vlen(e.WarpZone_findradius_dist) / WEP_CVAR(electro, combo_speed))
234 // if we triggered an orb, should we explode? if not, lets try again next time
235 if(found && WEP_CVAR_PRI(electro, midaircombo_explode))
238 { self.nextthink = min(time + WEP_CVAR_PRI(electro, midaircombo_interval), self.ltime); }
240 else { self.nextthink = self.ltime; }
243 void W_Electro_Attack_Bolt(void)
247 W_DecreaseAmmo(WEP_CVAR_PRI(electro, ammo));
249 W_SetupShot_ProjectileSize(self, '0 0 -3', '0 0 -3', FALSE, 2, "weapons/electro_fire.wav", CH_WEAPON_A, WEP_CVAR_PRI(electro, damage));
251 pointparticles(particleeffectnum("electro_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
254 proj.classname = "electro_bolt";
255 proj.owner = proj.realowner = self;
256 proj.bot_dodge = TRUE;
257 proj.bot_dodgerating = WEP_CVAR_PRI(electro, damage);
258 proj.use = W_Electro_Explode;
259 proj.think = W_Electro_Bolt_Think;
260 proj.nextthink = time;
261 proj.ltime = time + WEP_CVAR_PRI(electro, lifetime);
262 PROJECTILE_MAKETRIGGER(proj);
263 proj.projectiledeathtype = WEP_ELECTRO;
264 setorigin(proj, w_shotorg);
266 proj.movetype = MOVETYPE_FLY;
267 W_SetupProjVelocity_PRI(proj, electro);
268 proj.angles = vectoangles(proj.velocity);
269 proj.touch = W_Electro_TouchExplode;
270 setsize(proj, '0 0 -3', '0 0 -3');
271 proj.flags = FL_PROJECTILE;
272 proj.missile_flags = MIF_SPLASH;
274 CSQCProjectile(proj, TRUE, PROJECTILE_ELECTRO_BEAM, TRUE);
276 other = proj; MUTATOR_CALLHOOK(EditProjectile);
279 void W_Electro_Orb_Touch(void)
282 if(other.takedamage == DAMAGE_AIM)
283 { if(WEP_CVAR_SEC(electro, touchexplode)) { W_Electro_Explode(); } }
286 //UpdateCSQCProjectile(self);
287 spamsound(self, CH_SHOTS, "weapons/electro_bounce.wav", VOL_BASE, ATTEN_NORM);
288 self.projectiledeathtype |= HITTYPE_BOUNCE;
292 void W_Electro_Orb_Damage(entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
297 // note: combos are usually triggered by W_Electro_TriggerCombo, not damage
298 float is_combo = (inflictor.classname == "electro_orb_chain" || inflictor.classname == "electro_bolt");
300 if(!W_CheckProjectileDamage(inflictor.realowner, self.realowner, deathtype, (is_combo ? 1 : -1)))
301 return; // g_projectiles_damage says to halt
303 self.health = self.health - damage;
306 self.takedamage = DAMAGE_NO;
307 self.nextthink = time;
310 // change owner to whoever caused the combo explosion
311 self.realowner = inflictor.realowner;
312 self.classname = "electro_orb_chain";
313 self.think = W_Electro_ExplodeCombo;
314 self.nextthink = time +
316 // bound the length, inflictor may be in a galaxy far far away (warpzones)
318 WEP_CVAR(electro, combo_radius),
319 vlen(self.origin - inflictor.origin)
322 // delay combo chains, looks cooler
323 WEP_CVAR(electro, combo_speed)
328 self.use = W_Electro_Explode;
329 self.think = adaptor_think2use; // not _hittype_splash, as this runs "immediately"
334 void W_Electro_Attack_Orb(void)
336 W_DecreaseAmmo(WEP_CVAR_SEC(electro, ammo));
338 W_SetupShot_ProjectileSize(self, '0 0 -4', '0 0 -4', FALSE, 2, "weapons/electro_fire2.wav", CH_WEAPON_A, WEP_CVAR_SEC(electro, damage));
340 w_shotdir = v_forward; // no TrueAim for grenades please
342 pointparticles(particleeffectnum("electro_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
344 entity proj = spawn();
345 proj.classname = "electro_orb";
346 proj.owner = proj.realowner = self;
347 proj.use = W_Electro_Explode;
348 proj.think = adaptor_think2use_hittype_splash;
349 proj.bot_dodge = TRUE;
350 proj.bot_dodgerating = WEP_CVAR_SEC(electro, damage);
351 proj.nextthink = time + WEP_CVAR_SEC(electro, lifetime);
352 PROJECTILE_MAKETRIGGER(proj);
353 proj.projectiledeathtype = WEP_ELECTRO | HITTYPE_SECONDARY;
354 setorigin(proj, w_shotorg);
356 //proj.glow_size = 50;
357 //proj.glow_color = 45;
358 proj.movetype = MOVETYPE_BOUNCE;
359 W_SetupProjVelocity_UP_SEC(proj, electro);
360 proj.touch = W_Electro_Orb_Touch;
361 setsize(proj, '0 0 -4', '0 0 -4');
362 proj.takedamage = DAMAGE_YES;
363 proj.damageforcescale = WEP_CVAR_SEC(electro, damageforcescale);
364 proj.health = WEP_CVAR_SEC(electro, health);
365 proj.event_damage = W_Electro_Orb_Damage;
366 proj.flags = FL_PROJECTILE;
367 proj.damagedbycontents = (WEP_CVAR_SEC(electro, damagedbycontents));
369 proj.bouncefactor = WEP_CVAR_SEC(electro, bouncefactor);
370 proj.bouncestop = WEP_CVAR_SEC(electro, bouncestop);
371 proj.missile_flags = MIF_SPLASH | MIF_ARC;
376 copyentity(proj, p2);
377 setmodel(p2, "models/ebomb.mdl");
378 setsize(p2, proj.mins, proj.maxs);
381 CSQCProjectile(proj, TRUE, PROJECTILE_ELECTRO, FALSE); // no culling, it has sound
383 other = proj; MUTATOR_CALLHOOK(EditProjectile);
386 void W_Electro_CheckAttack()
388 if(self.electro_count > 1)
389 if(self.BUTTON_ATCK2)
390 if(weapon_prepareattack(1, -1))
392 W_Electro_Attack_Orb();
393 self.electro_count -= 1;
394 weapon_thinkf(WFRAME_FIRE2, WEP_CVAR_SEC(electro, animtime), W_Electro_CheckAttack);
397 // WEAPONTODO: when the player releases the button, cut down the length of refire2?
401 .float bot_secondary_electromooth;
402 float W_Electro(float req)
409 self.BUTTON_ATCK = self.BUTTON_ATCK2 = FALSE;
410 if(vlen(self.origin-self.enemy.origin) > 1000) { self.bot_secondary_electromooth = 0; }
411 if(self.bot_secondary_electromooth == 0)
415 if(WEP_CVAR_PRI(electro, speed))
416 shoot = bot_aim(WEP_CVAR_PRI(electro, speed), 0, WEP_CVAR_PRI(electro, lifetime), FALSE);
418 shoot = bot_aim(1000000, 0, 0.001, FALSE);
422 self.BUTTON_ATCK = TRUE;
423 if(random() < 0.01) self.bot_secondary_electromooth = 1;
428 if(bot_aim(WEP_CVAR_SEC(electro, speed), WEP_CVAR_SEC(electro, speed_up), WEP_CVAR_SEC(electro, lifetime), TRUE))
430 self.BUTTON_ATCK2 = TRUE;
431 if(random() < 0.03) self.bot_secondary_electromooth = 0;
439 if(autocvar_g_balance_electro_reload_ammo) // forced reload // WEAPONTODO
442 if(self.clip_load >= WEP_CVAR_PRI(electro, ammo))
444 if(self.clip_load >= WEP_CVAR_SEC(electro, ammo))
449 WEP_ACTION(self.weapon, WR_RELOAD);
458 if(weapon_prepareattack(0, WEP_CVAR_PRI(electro, refire)))
460 W_Electro_Attack_Bolt();
461 weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_PRI(electro, animtime), w_ready);
464 else if(self.BUTTON_ATCK2)
466 if(time >= self.electro_secondarytime)
467 if(weapon_prepareattack(1, WEP_CVAR_SEC(electro, refire)))
469 W_Electro_Attack_Orb();
470 self.electro_count = WEP_CVAR_SEC(electro, count);
471 weapon_thinkf(WFRAME_FIRE2, WEP_CVAR_SEC(electro, animtime), W_Electro_CheckAttack);
472 self.electro_secondarytime = time + WEP_CVAR_SEC(electro, refire2) * W_WeaponRateFactor();
480 precache_model("models/weapons/g_electro.md3");
481 precache_model("models/weapons/v_electro.md3");
482 precache_model("models/weapons/h_electro.iqm");
483 precache_sound("weapons/electro_bounce.wav");
484 precache_sound("weapons/electro_fire.wav");
485 precache_sound("weapons/electro_fire2.wav");
486 precache_sound("weapons/electro_impact.wav");
487 precache_sound("weapons/electro_impact_combo.wav");
488 ELECTRO_SETTINGS(WEP_SKIP_CVAR, WEP_SET_PROP)
493 ammo_amount = self.WEP_AMMO(ELECTRO) >= 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.WEP_AMMO(ELECTRO) >= 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.WEP_AMMO(ELECTRO) >= 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");
593 // no weapon specific image for this weapon