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.6",
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);
70 spawnfunc(weapon_electro) { weapon_defaultspawnfunc(WEP_ELECTRO.m_id); }
72 void W_Electro_TriggerCombo(vector org, float rad, entity own)
74 entity e = WarpZone_FindRadius(org, rad, !WEP_CVAR(electro, combo_comboradius_thruwall));
77 if(e.classname == "electro_orb")
79 // do we allow thruwall triggering?
80 if(WEP_CVAR(electro, combo_comboradius_thruwall))
82 // if distance is greater than thruwall distance, check to make sure it's not through a wall
83 if(vlen(e.WarpZone_findradius_dist) > WEP_CVAR(electro, combo_comboradius_thruwall))
85 WarpZone_TraceLine(org, e.origin, MOVE_NOMONSTERS, e);
86 if(trace_fraction != 1)
88 // trigger is through a wall and outside of thruwall range, abort
95 // change owner to whoever caused the combo explosion
97 e.takedamage = DAMAGE_NO;
98 e.classname = "electro_orb_chain";
100 // now set the next one to trigger as well
101 e.think = W_Electro_ExplodeCombo;
103 // delay combo chains, looks cooler
108 (WEP_CVAR(electro, combo_speed) ?
109 (vlen(e.WarpZone_findradius_dist) / WEP_CVAR(electro, combo_speed))
119 void W_Electro_ExplodeCombo(void)
121 W_Electro_TriggerCombo(self.origin, WEP_CVAR(electro, combo_comboradius), self.realowner);
123 self.event_damage = func_null;
128 WEP_CVAR(electro, combo_damage),
129 WEP_CVAR(electro, combo_edgedamage),
130 WEP_CVAR(electro, combo_radius),
133 WEP_CVAR(electro, combo_force),
134 WEP_ELECTRO.m_id | HITTYPE_BOUNCE, // use THIS type for a combo because primary can't bounce
141 void W_Electro_Explode(void)
143 if(other.takedamage == DAMAGE_AIM)
145 if(DIFF_TEAM(self.realowner, other))
146 if(other.deadflag == DEAD_NO)
148 Send_Notification(NOTIF_ONE, self.realowner, MSG_ANNCE, ANNCE_ACHIEVEMENT_ELECTROBITCH);
150 self.event_damage = func_null;
151 self.takedamage = DAMAGE_NO;
153 if(self.movetype == MOVETYPE_BOUNCE)
158 WEP_CVAR_SEC(electro, damage),
159 WEP_CVAR_SEC(electro, edgedamage),
160 WEP_CVAR_SEC(electro, radius),
163 WEP_CVAR_SEC(electro, force),
164 self.projectiledeathtype,
170 W_Electro_TriggerCombo(self.origin, WEP_CVAR_PRI(electro, comboradius), self.realowner);
174 WEP_CVAR_PRI(electro, damage),
175 WEP_CVAR_PRI(electro, edgedamage),
176 WEP_CVAR_PRI(electro, radius),
179 WEP_CVAR_PRI(electro, force),
180 self.projectiledeathtype,
188 void W_Electro_TouchExplode(void)
194 void W_Electro_Bolt_Think(void)
196 if(time >= self.ltime)
202 if(WEP_CVAR_PRI(electro, midaircombo_radius))
205 entity e = WarpZone_FindRadius(self.origin, WEP_CVAR_PRI(electro, midaircombo_radius), true);
207 // loop through nearby orbs and trigger them
210 if(e.classname == "electro_orb")
212 // change owner to whoever caused the combo explosion
213 e.realowner = self.realowner;
214 e.takedamage = DAMAGE_NO;
215 e.classname = "electro_orb_chain";
217 // now set the next one to trigger as well
218 e.think = W_Electro_ExplodeCombo;
220 // delay combo chains, looks cooler
225 (WEP_CVAR(electro, combo_speed) ?
226 (vlen(e.WarpZone_findradius_dist) / WEP_CVAR(electro, combo_speed))
237 // if we triggered an orb, should we explode? if not, lets try again next time
238 if(found && WEP_CVAR_PRI(electro, midaircombo_explode))
241 { self.nextthink = min(time + WEP_CVAR_PRI(electro, midaircombo_interval), self.ltime); }
243 else { self.nextthink = self.ltime; }
246 void W_Electro_Attack_Bolt(void)
250 W_DecreaseAmmo(WEP_CVAR_PRI(electro, ammo));
252 W_SetupShot_ProjectileSize(
260 WEP_CVAR_PRI(electro, damage)
263 Send_Effect(EFFECT_ELECTRO_MUZZLEFLASH, w_shotorg, w_shotdir * 1000, 1);
266 proj.classname = "electro_bolt";
267 proj.owner = proj.realowner = self;
268 proj.bot_dodge = true;
269 proj.bot_dodgerating = WEP_CVAR_PRI(electro, damage);
270 proj.use = W_Electro_Explode;
271 proj.think = W_Electro_Bolt_Think;
272 proj.nextthink = time;
273 proj.ltime = time + WEP_CVAR_PRI(electro, lifetime);
274 PROJECTILE_MAKETRIGGER(proj);
275 proj.projectiledeathtype = WEP_ELECTRO.m_id;
276 setorigin(proj, w_shotorg);
278 proj.movetype = MOVETYPE_FLY;
279 W_SetupProjVelocity_PRI(proj, electro);
280 proj.angles = vectoangles(proj.velocity);
281 proj.touch = W_Electro_TouchExplode;
282 setsize(proj, '0 0 -3', '0 0 -3');
283 proj.flags = FL_PROJECTILE;
284 proj.missile_flags = MIF_SPLASH;
286 CSQCProjectile(proj, true, PROJECTILE_ELECTRO_BEAM, true);
288 MUTATOR_CALLHOOK(EditProjectile, self, proj);
291 void W_Electro_Orb_Touch(void)
294 if(other.takedamage == DAMAGE_AIM)
295 { if(WEP_CVAR_SEC(electro, touchexplode)) { W_Electro_Explode(); } }
298 //UpdateCSQCProjectile(self);
299 spamsound(self, CH_SHOTS, SND(ELECTRO_BOUNCE), VOL_BASE, ATTEN_NORM);
300 self.projectiledeathtype |= HITTYPE_BOUNCE;
304 void W_Electro_Orb_Damage(entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force)
309 // note: combos are usually triggered by W_Electro_TriggerCombo, not damage
310 float is_combo = (inflictor.classname == "electro_orb_chain" || inflictor.classname == "electro_bolt");
312 if(!W_CheckProjectileDamage(inflictor.realowner, self.realowner, deathtype, (is_combo ? 1 : -1)))
313 return; // g_projectiles_damage says to halt
315 self.health = self.health - damage;
318 self.takedamage = DAMAGE_NO;
319 self.nextthink = time;
322 // change owner to whoever caused the combo explosion
323 self.realowner = inflictor.realowner;
324 self.classname = "electro_orb_chain";
325 self.think = W_Electro_ExplodeCombo;
326 self.nextthink = time +
328 // bound the length, inflictor may be in a galaxy far far away (warpzones)
330 WEP_CVAR(electro, combo_radius),
331 vlen(self.origin - inflictor.origin)
334 // delay combo chains, looks cooler
335 WEP_CVAR(electro, combo_speed)
340 self.use = W_Electro_Explode;
341 self.think = adaptor_think2use; // not _hittype_splash, as this runs "immediately"
346 void W_Electro_Attack_Orb(void)
348 W_DecreaseAmmo(WEP_CVAR_SEC(electro, ammo));
350 W_SetupShot_ProjectileSize(
358 WEP_CVAR_SEC(electro, damage)
361 w_shotdir = v_forward; // no TrueAim for grenades please
363 Send_Effect(EFFECT_ELECTRO_MUZZLEFLASH, w_shotorg, w_shotdir * 1000, 1);
365 entity proj = spawn();
366 proj.classname = "electro_orb";
367 proj.owner = proj.realowner = self;
368 proj.use = W_Electro_Explode;
369 proj.think = adaptor_think2use_hittype_splash;
370 proj.bot_dodge = true;
371 proj.bot_dodgerating = WEP_CVAR_SEC(electro, damage);
372 proj.nextthink = time + WEP_CVAR_SEC(electro, lifetime);
373 PROJECTILE_MAKETRIGGER(proj);
374 proj.projectiledeathtype = WEP_ELECTRO.m_id | HITTYPE_SECONDARY;
375 setorigin(proj, w_shotorg);
377 //proj.glow_size = 50;
378 //proj.glow_color = 45;
379 proj.movetype = MOVETYPE_BOUNCE;
380 W_SetupProjVelocity_UP_SEC(proj, electro);
381 proj.touch = W_Electro_Orb_Touch;
382 setsize(proj, '0 0 -4', '0 0 -4');
383 proj.takedamage = DAMAGE_YES;
384 proj.damageforcescale = WEP_CVAR_SEC(electro, damageforcescale);
385 proj.health = WEP_CVAR_SEC(electro, health);
386 proj.event_damage = W_Electro_Orb_Damage;
387 proj.flags = FL_PROJECTILE;
388 proj.damagedbycontents = (WEP_CVAR_SEC(electro, damagedbycontents));
390 proj.bouncefactor = WEP_CVAR_SEC(electro, bouncefactor);
391 proj.bouncestop = WEP_CVAR_SEC(electro, bouncestop);
392 proj.missile_flags = MIF_SPLASH | MIF_ARC;
397 copyentity(proj, p2);
398 setmodel(p2, MDL_PROJECTILE_ELECTRO);
399 setsize(p2, proj.mins, proj.maxs);
402 CSQCProjectile(proj, true, PROJECTILE_ELECTRO, false); // no culling, it has sound
404 MUTATOR_CALLHOOK(EditProjectile, self, proj);
407 void W_Electro_CheckAttack(void)
409 if(self.electro_count > 1)
410 if(self.BUTTON_ATCK2)
411 if(weapon_prepareattack(1, -1))
413 W_Electro_Attack_Orb();
414 self.electro_count -= 1;
415 weapon_thinkf(WFRAME_FIRE2, WEP_CVAR_SEC(electro, animtime), W_Electro_CheckAttack);
418 // WEAPONTODO: when the player releases the button, cut down the length of refire2?
422 .float bot_secondary_electromooth;
423 bool W_Electro(int req)
430 self.BUTTON_ATCK = self.BUTTON_ATCK2 = false;
431 if(vlen(self.origin-self.enemy.origin) > 1000) { self.bot_secondary_electromooth = 0; }
432 if(self.bot_secondary_electromooth == 0)
436 if(WEP_CVAR_PRI(electro, speed))
437 shoot = bot_aim(WEP_CVAR_PRI(electro, speed), 0, WEP_CVAR_PRI(electro, lifetime), false);
439 shoot = bot_aim(1000000, 0, 0.001, false);
443 self.BUTTON_ATCK = true;
444 if(random() < 0.01) self.bot_secondary_electromooth = 1;
449 if(bot_aim(WEP_CVAR_SEC(electro, speed), WEP_CVAR_SEC(electro, speed_up), WEP_CVAR_SEC(electro, lifetime), true))
451 self.BUTTON_ATCK2 = true;
452 if(random() < 0.03) self.bot_secondary_electromooth = 0;
460 if(autocvar_g_balance_electro_reload_ammo) // forced reload // WEAPONTODO
463 if(self.clip_load >= WEP_CVAR_PRI(electro, ammo))
465 if(self.clip_load >= WEP_CVAR_SEC(electro, ammo))
470 WEP_ACTION(self.weapon, WR_RELOAD);
479 if(weapon_prepareattack(0, WEP_CVAR_PRI(electro, refire)))
481 W_Electro_Attack_Bolt();
482 weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_PRI(electro, animtime), w_ready);
485 else if(self.BUTTON_ATCK2)
487 if(time >= self.electro_secondarytime)
488 if(weapon_prepareattack(1, WEP_CVAR_SEC(electro, refire)))
490 W_Electro_Attack_Orb();
491 self.electro_count = WEP_CVAR_SEC(electro, count);
492 weapon_thinkf(WFRAME_FIRE2, WEP_CVAR_SEC(electro, animtime), W_Electro_CheckAttack);
493 self.electro_secondarytime = time + WEP_CVAR_SEC(electro, refire2) * W_WeaponRateFactor();
501 ELECTRO_SETTINGS(WEP_SKIP_CVAR, WEP_SET_PROP);
506 ammo_amount = self.WEP_AMMO(ELECTRO) >= WEP_CVAR_PRI(electro, ammo);
507 ammo_amount += self.(weapon_load[WEP_ELECTRO.m_id]) >= WEP_CVAR_PRI(electro, ammo);
512 if(WEP_CVAR(electro, combo_safeammocheck)) // true if you can fire at least one secondary blob AND one primary shot after it, otherwise false.
514 ammo_amount = self.WEP_AMMO(ELECTRO) >= WEP_CVAR_SEC(electro, ammo) + WEP_CVAR_PRI(electro, ammo);
515 ammo_amount += self.(weapon_load[WEP_ELECTRO.m_id]) >= WEP_CVAR_SEC(electro, ammo) + WEP_CVAR_PRI(electro, ammo);
519 ammo_amount = self.WEP_AMMO(ELECTRO) >= WEP_CVAR_SEC(electro, ammo);
520 ammo_amount += self.(weapon_load[WEP_ELECTRO.m_id]) >= WEP_CVAR_SEC(electro, ammo);
526 ELECTRO_SETTINGS(WEP_CONFIG_WRITE_CVARS, WEP_CONFIG_WRITE_PROPS);
531 self.electro_secondarytime = time;
536 W_Reload(min(WEP_CVAR_PRI(electro, ammo), WEP_CVAR_SEC(electro, ammo)), SND(RELOAD));
539 case WR_SUICIDEMESSAGE:
541 if(w_deathtype & HITTYPE_SECONDARY)
542 return WEAPON_ELECTRO_SUICIDE_ORBS;
544 return WEAPON_ELECTRO_SUICIDE_BOLT;
548 if(w_deathtype & HITTYPE_SECONDARY)
550 return WEAPON_ELECTRO_MURDER_ORBS;
554 if(w_deathtype & HITTYPE_BOUNCE)
555 return WEAPON_ELECTRO_MURDER_COMBO;
557 return WEAPON_ELECTRO_MURDER_BOLT;
565 bool W_Electro(int req)
569 case WR_IMPACTEFFECT:
572 org2 = w_org + w_backoff * 6;
573 if(w_deathtype & HITTYPE_SECONDARY)
575 pointparticles(particleeffectnum(EFFECT_ELECTRO_BALLEXPLODE), org2, '0 0 0', 1);
577 sound(self, CH_SHOTS, SND_ELECTRO_IMPACT, VOL_BASE, ATTEN_NORM);
581 if(w_deathtype & HITTYPE_BOUNCE)
583 // this is sent as "primary (w_deathtype & HITTYPE_BOUNCE)" to distinguish it from (w_deathtype & HITTYPE_SECONDARY) bounced balls
584 pointparticles(particleeffectnum(EFFECT_ELECTRO_COMBO), org2, '0 0 0', 1);
586 sound(self, CH_SHOTS, SND_ELECTRO_IMPACT_COMBO, VOL_BASE, ATTEN_NORM);
590 pointparticles(particleeffectnum(EFFECT_ELECTRO_IMPACT), org2, '0 0 0', 1);
592 sound(self, CH_SHOTS, SND_ELECTRO_IMPACT, VOL_BASE, ATTEN_NORM);
604 // no weapon specific image for this weapon