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 /* model */ MDL_ELECTRO_ITEM,
12 /* simplemdl */ "foobar",
13 /* crosshair */ "gfx/crosshairelectro 0.6",
14 /* wepimg */ "weaponelectro",
15 /* refname */ "electro",
16 /* wepname */ _("Electro")
19 #define ELECTRO_SETTINGS(w_cvar,w_prop) ELECTRO_SETTINGS_LIST(w_cvar, w_prop, ELECTRO, electro)
20 #define ELECTRO_SETTINGS_LIST(w_cvar,w_prop,id,sn) \
21 w_cvar(id, sn, BOTH, ammo) \
22 w_cvar(id, sn, BOTH, animtime) \
23 w_cvar(id, sn, BOTH, damage) \
24 w_cvar(id, sn, BOTH, edgedamage) \
25 w_cvar(id, sn, BOTH, force) \
26 w_cvar(id, sn, BOTH, radius) \
27 w_cvar(id, sn, BOTH, refire) \
28 w_cvar(id, sn, BOTH, speed) \
29 w_cvar(id, sn, BOTH, spread) \
30 w_cvar(id, sn, BOTH, lifetime) \
31 w_cvar(id, sn, PRI, comboradius) \
32 w_cvar(id, sn, PRI, midaircombo_explode) \
33 w_cvar(id, sn, PRI, midaircombo_interval) \
34 w_cvar(id, sn, PRI, midaircombo_radius) \
35 w_cvar(id, sn, SEC, bouncefactor) \
36 w_cvar(id, sn, SEC, bouncestop) \
37 w_cvar(id, sn, SEC, count) \
38 w_cvar(id, sn, SEC, damageforcescale) \
39 w_cvar(id, sn, SEC, damagedbycontents) \
40 w_cvar(id, sn, SEC, health) \
41 w_cvar(id, sn, SEC, refire2) \
42 w_cvar(id, sn, SEC, speed_up) \
43 w_cvar(id, sn, SEC, speed_z) \
44 w_cvar(id, sn, SEC, touchexplode) \
45 w_cvar(id, sn, NONE, combo_comboradius) \
46 w_cvar(id, sn, NONE, combo_comboradius_thruwall) \
47 w_cvar(id, sn, NONE, combo_damage) \
48 w_cvar(id, sn, NONE, combo_edgedamage) \
49 w_cvar(id, sn, NONE, combo_force) \
50 w_cvar(id, sn, NONE, combo_radius) \
51 w_cvar(id, sn, NONE, combo_speed) \
52 w_cvar(id, sn, NONE, combo_safeammocheck) \
53 w_prop(id, sn, float, reloading_ammo, reload_ammo) \
54 w_prop(id, sn, float, reloading_time, reload_time) \
55 w_prop(id, sn, float, switchdelay_raise, switchdelay_raise) \
56 w_prop(id, sn, float, switchdelay_drop, switchdelay_drop) \
57 w_prop(id, sn, string, weaponreplace, weaponreplace) \
58 w_prop(id, sn, float, weaponstart, weaponstart) \
59 w_prop(id, sn, float, weaponstartoverride, weaponstartoverride) \
60 w_prop(id, sn, float, weaponthrowable, weaponthrowable)
63 ELECTRO_SETTINGS(WEP_ADD_CVAR, WEP_ADD_PROP)
65 .float electro_secondarytime;
66 void W_Electro_ExplodeCombo(void);
71 void spawnfunc_weapon_electro(void) { weapon_defaultspawnfunc(WEP_ELECTRO.m_id); }
73 void W_Electro_TriggerCombo(vector org, float rad, entity own)
75 entity e = WarpZone_FindRadius(org, rad, !WEP_CVAR(electro, combo_comboradius_thruwall));
78 if(e.classname == "electro_orb")
80 // do we allow thruwall triggering?
81 if(WEP_CVAR(electro, combo_comboradius_thruwall))
83 // if distance is greater than thruwall distance, check to make sure it's not through a wall
84 if(vlen(e.WarpZone_findradius_dist) > WEP_CVAR(electro, combo_comboradius_thruwall))
86 WarpZone_TraceLine(org, e.origin, MOVE_NOMONSTERS, e);
87 if(trace_fraction != 1)
89 // trigger is through a wall and outside of thruwall range, abort
96 // change owner to whoever caused the combo explosion
98 e.takedamage = DAMAGE_NO;
99 e.classname = "electro_orb_chain";
101 // now set the next one to trigger as well
102 e.think = W_Electro_ExplodeCombo;
104 // delay combo chains, looks cooler
109 (WEP_CVAR(electro, combo_speed) ?
110 (vlen(e.WarpZone_findradius_dist) / WEP_CVAR(electro, combo_speed))
120 void W_Electro_ExplodeCombo(void)
122 W_Electro_TriggerCombo(self.origin, WEP_CVAR(electro, combo_comboradius), self.realowner);
124 self.event_damage = func_null;
129 WEP_CVAR(electro, combo_damage),
130 WEP_CVAR(electro, combo_edgedamage),
131 WEP_CVAR(electro, combo_radius),
134 WEP_CVAR(electro, combo_force),
135 WEP_ELECTRO.m_id | HITTYPE_BOUNCE, // use THIS type for a combo because primary can't bounce
142 void W_Electro_Explode(void)
144 if(other.takedamage == DAMAGE_AIM)
146 if(DIFF_TEAM(self.realowner, other))
147 if(other.deadflag == DEAD_NO)
149 Send_Notification(NOTIF_ONE, self.realowner, MSG_ANNCE, ANNCE_ACHIEVEMENT_ELECTROBITCH);
151 self.event_damage = func_null;
152 self.takedamage = DAMAGE_NO;
154 if(self.movetype == MOVETYPE_BOUNCE)
159 WEP_CVAR_SEC(electro, damage),
160 WEP_CVAR_SEC(electro, edgedamage),
161 WEP_CVAR_SEC(electro, radius),
164 WEP_CVAR_SEC(electro, force),
165 self.projectiledeathtype,
171 W_Electro_TriggerCombo(self.origin, WEP_CVAR_PRI(electro, comboradius), self.realowner);
175 WEP_CVAR_PRI(electro, damage),
176 WEP_CVAR_PRI(electro, edgedamage),
177 WEP_CVAR_PRI(electro, radius),
180 WEP_CVAR_PRI(electro, force),
181 self.projectiledeathtype,
189 void W_Electro_TouchExplode(void)
195 void W_Electro_Bolt_Think(void)
197 if(time >= self.ltime)
203 if(WEP_CVAR_PRI(electro, midaircombo_radius))
206 entity e = WarpZone_FindRadius(self.origin, WEP_CVAR_PRI(electro, midaircombo_radius), true);
208 // loop through nearby orbs and trigger them
211 if(e.classname == "electro_orb")
213 // change owner to whoever caused the combo explosion
214 e.realowner = self.realowner;
215 e.takedamage = DAMAGE_NO;
216 e.classname = "electro_orb_chain";
218 // now set the next one to trigger as well
219 e.think = W_Electro_ExplodeCombo;
221 // delay combo chains, looks cooler
226 (WEP_CVAR(electro, combo_speed) ?
227 (vlen(e.WarpZone_findradius_dist) / WEP_CVAR(electro, combo_speed))
238 // if we triggered an orb, should we explode? if not, lets try again next time
239 if(found && WEP_CVAR_PRI(electro, midaircombo_explode))
242 { self.nextthink = min(time + WEP_CVAR_PRI(electro, midaircombo_interval), self.ltime); }
244 else { self.nextthink = self.ltime; }
247 void W_Electro_Attack_Bolt(void)
251 W_DecreaseAmmo(WEP_CVAR_PRI(electro, ammo));
253 W_SetupShot_ProjectileSize(
261 WEP_CVAR_PRI(electro, damage)
264 Send_Effect(EFFECT_ELECTRO_MUZZLEFLASH, w_shotorg, w_shotdir * 1000, 1);
267 proj.classname = "electro_bolt";
268 proj.owner = proj.realowner = self;
269 proj.bot_dodge = true;
270 proj.bot_dodgerating = WEP_CVAR_PRI(electro, damage);
271 proj.use = W_Electro_Explode;
272 proj.think = W_Electro_Bolt_Think;
273 proj.nextthink = time;
274 proj.ltime = time + WEP_CVAR_PRI(electro, lifetime);
275 PROJECTILE_MAKETRIGGER(proj);
276 proj.projectiledeathtype = WEP_ELECTRO.m_id;
277 setorigin(proj, w_shotorg);
279 proj.movetype = MOVETYPE_FLY;
280 W_SetupProjVelocity_PRI(proj, electro);
281 proj.angles = vectoangles(proj.velocity);
282 proj.touch = W_Electro_TouchExplode;
283 setsize(proj, '0 0 -3', '0 0 -3');
284 proj.flags = FL_PROJECTILE;
285 proj.missile_flags = MIF_SPLASH;
287 CSQCProjectile(proj, true, PROJECTILE_ELECTRO_BEAM, true);
289 MUTATOR_CALLHOOK(EditProjectile, self, proj);
292 void W_Electro_Orb_Touch(void)
295 if(other.takedamage == DAMAGE_AIM)
296 { if(WEP_CVAR_SEC(electro, touchexplode)) { W_Electro_Explode(); } }
299 //UpdateCSQCProjectile(self);
300 spamsound(self, CH_SHOTS, SND(ELECTRO_BOUNCE), VOL_BASE, ATTEN_NORM);
301 self.projectiledeathtype |= HITTYPE_BOUNCE;
305 void W_Electro_Orb_Damage(entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force)
310 // note: combos are usually triggered by W_Electro_TriggerCombo, not damage
311 float is_combo = (inflictor.classname == "electro_orb_chain" || inflictor.classname == "electro_bolt");
313 if(!W_CheckProjectileDamage(inflictor.realowner, self.realowner, deathtype, (is_combo ? 1 : -1)))
314 return; // g_projectiles_damage says to halt
316 self.health = self.health - damage;
319 self.takedamage = DAMAGE_NO;
320 self.nextthink = time;
323 // change owner to whoever caused the combo explosion
324 self.realowner = inflictor.realowner;
325 self.classname = "electro_orb_chain";
326 self.think = W_Electro_ExplodeCombo;
327 self.nextthink = time +
329 // bound the length, inflictor may be in a galaxy far far away (warpzones)
331 WEP_CVAR(electro, combo_radius),
332 vlen(self.origin - inflictor.origin)
335 // delay combo chains, looks cooler
336 WEP_CVAR(electro, combo_speed)
341 self.use = W_Electro_Explode;
342 self.think = adaptor_think2use; // not _hittype_splash, as this runs "immediately"
347 void W_Electro_Attack_Orb(void)
349 W_DecreaseAmmo(WEP_CVAR_SEC(electro, ammo));
351 W_SetupShot_ProjectileSize(
359 WEP_CVAR_SEC(electro, damage)
362 w_shotdir = v_forward; // no TrueAim for grenades please
364 Send_Effect(EFFECT_ELECTRO_MUZZLEFLASH, w_shotorg, w_shotdir * 1000, 1);
366 entity proj = spawn();
367 proj.classname = "electro_orb";
368 proj.owner = proj.realowner = self;
369 proj.use = W_Electro_Explode;
370 proj.think = adaptor_think2use_hittype_splash;
371 proj.bot_dodge = true;
372 proj.bot_dodgerating = WEP_CVAR_SEC(electro, damage);
373 proj.nextthink = time + WEP_CVAR_SEC(electro, lifetime);
374 PROJECTILE_MAKETRIGGER(proj);
375 proj.projectiledeathtype = WEP_ELECTRO.m_id | HITTYPE_SECONDARY;
376 setorigin(proj, w_shotorg);
378 //proj.glow_size = 50;
379 //proj.glow_color = 45;
380 proj.movetype = MOVETYPE_BOUNCE;
381 W_SetupProjVelocity_UP_SEC(proj, electro);
382 proj.touch = W_Electro_Orb_Touch;
383 setsize(proj, '0 0 -4', '0 0 -4');
384 proj.takedamage = DAMAGE_YES;
385 proj.damageforcescale = WEP_CVAR_SEC(electro, damageforcescale);
386 proj.health = WEP_CVAR_SEC(electro, health);
387 proj.event_damage = W_Electro_Orb_Damage;
388 proj.flags = FL_PROJECTILE;
389 proj.damagedbycontents = (WEP_CVAR_SEC(electro, damagedbycontents));
391 proj.bouncefactor = WEP_CVAR_SEC(electro, bouncefactor);
392 proj.bouncestop = WEP_CVAR_SEC(electro, bouncestop);
393 proj.missile_flags = MIF_SPLASH | MIF_ARC;
398 copyentity(proj, p2);
399 setmodel(p2, MDL_PROJECTILE_ELECTRO);
400 setsize(p2, proj.mins, proj.maxs);
403 CSQCProjectile(proj, true, PROJECTILE_ELECTRO, false); // no culling, it has sound
405 MUTATOR_CALLHOOK(EditProjectile, self, proj);
408 void W_Electro_CheckAttack(void)
410 if(self.electro_count > 1)
411 if(self.BUTTON_ATCK2)
412 if(weapon_prepareattack(1, -1))
414 W_Electro_Attack_Orb();
415 self.electro_count -= 1;
416 weapon_thinkf(WFRAME_FIRE2, WEP_CVAR_SEC(electro, animtime), W_Electro_CheckAttack);
419 // WEAPONTODO: when the player releases the button, cut down the length of refire2?
423 .float bot_secondary_electromooth;
424 bool W_Electro(entity thiswep, int req)
431 self.BUTTON_ATCK = self.BUTTON_ATCK2 = false;
432 if(vlen(self.origin-self.enemy.origin) > 1000) { self.bot_secondary_electromooth = 0; }
433 if(self.bot_secondary_electromooth == 0)
437 if(WEP_CVAR_PRI(electro, speed))
438 shoot = bot_aim(WEP_CVAR_PRI(electro, speed), 0, WEP_CVAR_PRI(electro, lifetime), false);
440 shoot = bot_aim(1000000, 0, 0.001, false);
444 self.BUTTON_ATCK = true;
445 if(random() < 0.01) self.bot_secondary_electromooth = 1;
450 if(bot_aim(WEP_CVAR_SEC(electro, speed), WEP_CVAR_SEC(electro, speed_up), WEP_CVAR_SEC(electro, lifetime), true))
452 self.BUTTON_ATCK2 = true;
453 if(random() < 0.03) self.bot_secondary_electromooth = 0;
461 if(autocvar_g_balance_electro_reload_ammo) // forced reload // WEAPONTODO
464 if(self.clip_load >= WEP_CVAR_PRI(electro, ammo))
466 if(self.clip_load >= WEP_CVAR_SEC(electro, ammo))
471 _WEP_ACTION(self.weapon, WR_RELOAD);
480 if(weapon_prepareattack(0, WEP_CVAR_PRI(electro, refire)))
482 W_Electro_Attack_Bolt();
483 weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_PRI(electro, animtime), w_ready);
486 else if(self.BUTTON_ATCK2)
488 if(time >= self.electro_secondarytime)
489 if(weapon_prepareattack(1, WEP_CVAR_SEC(electro, refire)))
491 W_Electro_Attack_Orb();
492 self.electro_count = WEP_CVAR_SEC(electro, count);
493 weapon_thinkf(WFRAME_FIRE2, WEP_CVAR_SEC(electro, animtime), W_Electro_CheckAttack);
494 self.electro_secondarytime = time + WEP_CVAR_SEC(electro, refire2) * W_WeaponRateFactor();
502 ELECTRO_SETTINGS(WEP_SKIP_CVAR, WEP_SET_PROP);
507 ammo_amount = self.WEP_AMMO(ELECTRO) >= WEP_CVAR_PRI(electro, ammo);
508 ammo_amount += self.(weapon_load[WEP_ELECTRO.m_id]) >= WEP_CVAR_PRI(electro, ammo);
513 if(WEP_CVAR(electro, combo_safeammocheck)) // true if you can fire at least one secondary blob AND one primary shot after it, otherwise false.
515 ammo_amount = self.WEP_AMMO(ELECTRO) >= WEP_CVAR_SEC(electro, ammo) + WEP_CVAR_PRI(electro, ammo);
516 ammo_amount += self.(weapon_load[WEP_ELECTRO.m_id]) >= WEP_CVAR_SEC(electro, ammo) + WEP_CVAR_PRI(electro, ammo);
520 ammo_amount = self.WEP_AMMO(ELECTRO) >= WEP_CVAR_SEC(electro, ammo);
521 ammo_amount += self.(weapon_load[WEP_ELECTRO.m_id]) >= WEP_CVAR_SEC(electro, ammo);
527 ELECTRO_SETTINGS(WEP_CONFIG_WRITE_CVARS, WEP_CONFIG_WRITE_PROPS);
532 self.electro_secondarytime = time;
537 W_Reload(min(WEP_CVAR_PRI(electro, ammo), WEP_CVAR_SEC(electro, ammo)), SND(RELOAD));
540 case WR_SUICIDEMESSAGE:
542 if(w_deathtype & HITTYPE_SECONDARY)
543 return WEAPON_ELECTRO_SUICIDE_ORBS;
545 return WEAPON_ELECTRO_SUICIDE_BOLT;
549 if(w_deathtype & HITTYPE_SECONDARY)
551 return WEAPON_ELECTRO_MURDER_ORBS;
555 if(w_deathtype & HITTYPE_BOUNCE)
556 return WEAPON_ELECTRO_MURDER_COMBO;
558 return WEAPON_ELECTRO_MURDER_BOLT;
566 bool W_Electro(entity thiswep, int req)
570 case WR_IMPACTEFFECT:
573 org2 = w_org + w_backoff * 6;
574 if(w_deathtype & HITTYPE_SECONDARY)
576 pointparticles(particleeffectnum(EFFECT_ELECTRO_BALLEXPLODE), org2, '0 0 0', 1);
578 sound(self, CH_SHOTS, SND_ELECTRO_IMPACT, VOL_BASE, ATTEN_NORM);
582 if(w_deathtype & HITTYPE_BOUNCE)
584 // this is sent as "primary (w_deathtype & HITTYPE_BOUNCE)" to distinguish it from (w_deathtype & HITTYPE_SECONDARY) bounced balls
585 pointparticles(particleeffectnum(EFFECT_ELECTRO_COMBO), org2, '0 0 0', 1);
587 sound(self, CH_SHOTS, SND_ELECTRO_IMPACT_COMBO, VOL_BASE, ATTEN_NORM);
591 pointparticles(particleeffectnum(EFFECT_ELECTRO_IMPACT), org2, '0 0 0', 1);
593 sound(self, CH_SHOTS, SND_ELECTRO_IMPACT, VOL_BASE, ATTEN_NORM);
605 // no weapon specific image for this weapon