5 void W_Electro_TriggerCombo(vector org, float rad, entity own)
7 entity e = WarpZone_FindRadius(org, rad, !WEP_CVAR(electro, combo_comboradius_thruwall));
10 if(e.classname == "electro_orb")
12 // do we allow thruwall triggering?
13 if(WEP_CVAR(electro, combo_comboradius_thruwall))
15 // if distance is greater than thruwall distance, check to make sure it's not through a wall
16 if(vdist(e.WarpZone_findradius_dist, >, WEP_CVAR(electro, combo_comboradius_thruwall)))
18 WarpZone_TraceLine(org, e.origin, MOVE_NOMONSTERS, e);
19 if(trace_fraction != 1)
21 // trigger is through a wall and outside of thruwall range, abort
28 // change owner to whoever caused the combo explosion
30 e.takedamage = DAMAGE_NO;
31 e.classname = "electro_orb_chain";
33 // now set the next one to trigger as well
34 setthink(e, W_Electro_ExplodeCombo);
36 // delay combo chains, looks cooler
41 (WEP_CVAR(electro, combo_speed) ?
42 (vlen(e.WarpZone_findradius_dist) / WEP_CVAR(electro, combo_speed))
52 void W_Electro_ExplodeCombo(entity this)
54 W_Electro_TriggerCombo(this.origin, WEP_CVAR(electro, combo_comboradius), this.realowner);
56 this.event_damage = func_null;
61 WEP_CVAR(electro, combo_damage),
62 WEP_CVAR(electro, combo_edgedamage),
63 WEP_CVAR(electro, combo_radius),
66 WEP_CVAR(electro, combo_force),
67 WEP_ELECTRO.m_id | HITTYPE_BOUNCE, // use THIS type for a combo because primary can't bounce
68 this.weaponentity_fld,
75 void W_Electro_Explode(entity this, entity directhitentity)
77 if(directhitentity.takedamage == DAMAGE_AIM)
78 if(IS_PLAYER(directhitentity))
79 if(DIFF_TEAM(this.realowner, directhitentity))
80 if(!IS_DEAD(directhitentity))
81 if(IsFlying(directhitentity))
82 Send_Notification(NOTIF_ONE, this.realowner, MSG_ANNCE, ANNCE_ACHIEVEMENT_ELECTROBITCH);
84 this.event_damage = func_null;
85 this.takedamage = DAMAGE_NO;
87 if(this.move_movetype == MOVETYPE_BOUNCE || this.classname == "electro_orb") // TODO: classname is more reliable anyway?
92 WEP_CVAR_SEC(electro, damage),
93 WEP_CVAR_SEC(electro, edgedamage),
94 WEP_CVAR_SEC(electro, radius),
97 WEP_CVAR_SEC(electro, force),
98 this.projectiledeathtype,
99 this.weaponentity_fld,
105 W_Electro_TriggerCombo(this.origin, WEP_CVAR_PRI(electro, comboradius), this.realowner);
109 WEP_CVAR_PRI(electro, damage),
110 WEP_CVAR_PRI(electro, edgedamage),
111 WEP_CVAR_PRI(electro, radius),
114 WEP_CVAR_PRI(electro, force),
115 this.projectiledeathtype,
116 this.weaponentity_fld,
124 void W_Electro_Explode_use(entity this, entity actor, entity trigger)
126 W_Electro_Explode(this, trigger);
129 void W_Electro_TouchExplode(entity this, entity toucher)
131 PROJECTILE_TOUCH(this, toucher);
132 W_Electro_Explode(this, toucher);
136 void sys_phys_update_single(entity this);
138 void W_Electro_Bolt_Think(entity this)
140 // sys_phys_update_single(this);
141 if(time >= this.ltime)
143 this.use(this, NULL, NULL);
147 if(WEP_CVAR_PRI(electro, midaircombo_radius))
150 entity e = WarpZone_FindRadius(this.origin, WEP_CVAR_PRI(electro, midaircombo_radius), true);
152 // loop through nearby orbs and trigger them
155 if(e.classname == "electro_orb" && (WEP_CVAR_PRI(electro, midaircombo_own) || DIFF_TEAM(this.owner, e.owner)))
157 // change owner to whoever caused the combo explosion
158 e.realowner = this.realowner;
159 e.takedamage = DAMAGE_NO;
160 e.classname = "electro_orb_chain";
162 // explode first orb immediately, other orbs will chain with delay
163 W_Electro_ExplodeCombo(e);
170 // if we triggered an orb, should we explode? if not, lets try again next time
171 if(found && WEP_CVAR_PRI(electro, midaircombo_explode))
172 { this.use(this, NULL, NULL); }
174 { this.nextthink = min(time + WEP_CVAR_PRI(electro, midaircombo_interval), this.ltime); }
176 else { this.nextthink = this.ltime; }
177 // this.nextthink = time;
180 void W_Electro_Attack_Bolt(Weapon thiswep, entity actor, .entity weaponentity)
184 W_DecreaseAmmo(thiswep, actor, WEP_CVAR_PRI(electro, ammo), weaponentity);
186 W_SetupShot_ProjectileSize(
195 WEP_CVAR_PRI(electro, damage),
199 Send_Effect(EFFECT_ELECTRO_MUZZLEFLASH, w_shotorg, w_shotdir * 1000, 1);
201 proj = new(electro_bolt);
202 proj.owner = proj.realowner = actor;
203 proj.bot_dodge = true;
204 proj.bot_dodgerating = WEP_CVAR_PRI(electro, damage);
205 proj.use = W_Electro_Explode_use;
206 setthink(proj, W_Electro_Bolt_Think);
207 proj.nextthink = time;
208 proj.ltime = time + WEP_CVAR_PRI(electro, lifetime);
209 PROJECTILE_MAKETRIGGER(proj);
210 proj.projectiledeathtype = thiswep.m_id;
211 proj.weaponentity_fld = weaponentity;
212 setorigin(proj, w_shotorg);
215 set_movetype(proj, MOVETYPE_FLY);
216 W_SetupProjVelocity_PRI(proj, electro);
217 proj.angles = vectoangles(proj.velocity);
218 settouch(proj, W_Electro_TouchExplode);
219 setsize(proj, '0 0 -3', '0 0 -3');
220 proj.flags = FL_PROJECTILE;
221 IL_PUSH(g_projectiles, proj);
222 IL_PUSH(g_bot_dodge, proj);
223 proj.missile_flags = MIF_SPLASH;
225 CSQCProjectile(proj, true, PROJECTILE_ELECTRO_BEAM, true);
227 MUTATOR_CALLHOOK(EditProjectile, actor, proj);
228 // proj.com_phys_pos = proj.origin;
229 // proj.com_phys_vel = proj.velocity;
232 void W_Electro_Orb_Stick(entity this, entity to)
234 entity newproj = spawn();
235 newproj.classname = this.classname;
237 newproj.bot_dodge = this.bot_dodge;
238 newproj.bot_dodgerating = this.bot_dodgerating;
240 newproj.owner = this.owner;
241 newproj.realowner = this.realowner;
242 setsize(newproj, this.mins, this.maxs);
243 setorigin(newproj, this.origin);
244 setmodel(newproj, MDL_PROJECTILE_ELECTRO);
245 newproj.angles = vectoangles(-trace_plane_normal); // face against the surface
247 newproj.takedamage = this.takedamage;
248 newproj.damageforcescale = this.damageforcescale;
249 SetResourceExplicit(newproj, RES_HEALTH, GetResource(this, RES_HEALTH));
250 newproj.event_damage = this.event_damage;
251 newproj.spawnshieldtime = this.spawnshieldtime;
252 newproj.damagedbycontents = true;
253 IL_PUSH(g_damagedbycontents, newproj);
255 set_movetype(newproj, MOVETYPE_NONE); // lock the orb in place
256 newproj.projectiledeathtype = this.projectiledeathtype;
257 newproj.weaponentity_fld = this.weaponentity_fld;
259 settouch(newproj, func_null);
260 setthink(newproj, getthink(this));
261 newproj.nextthink = this.nextthink;
262 newproj.use = this.use;
263 newproj.flags = this.flags;
264 IL_PUSH(g_projectiles, newproj);
265 IL_PUSH(g_bot_dodge, newproj);
270 SetMovetypeFollow(newproj, to);
273 void W_Electro_Orb_Touch(entity this, entity toucher)
275 PROJECTILE_TOUCH(this, toucher);
276 if(toucher.takedamage == DAMAGE_AIM && WEP_CVAR_SEC(electro, touchexplode))
277 { W_Electro_Explode(this, toucher); }
278 else if(toucher.owner != this.owner && toucher.classname != this.classname) // don't stick to player's other projectiles!
280 //UpdateCSQCProjectile(this);
281 spamsound(this, CH_SHOTS, SND_ELECTRO_BOUNCE, VOL_BASE, ATTEN_NORM);
282 this.projectiledeathtype |= HITTYPE_BOUNCE;
284 if(WEP_CVAR_SEC(electro, stick))
285 W_Electro_Orb_Stick(this, toucher);
289 void W_Electro_Orb_Damage(entity this, entity inflictor, entity attacker, float damage, int deathtype, .entity weaponentity, vector hitloc, vector force)
291 if(GetResource(this, RES_HEALTH) <= 0)
294 // note: combos are usually triggered by W_Electro_TriggerCombo, not damage
295 float is_combo = (inflictor.classname == "electro_orb_chain" || inflictor.classname == "electro_bolt");
297 if(!W_CheckProjectileDamage(inflictor.realowner, this.realowner, deathtype, (is_combo ? 1 : -1)))
298 return; // g_projectiles_damage says to halt
300 TakeResource(this, RES_HEALTH, damage);
301 if(GetResource(this, RES_HEALTH) <= 0)
303 this.takedamage = DAMAGE_NO;
304 this.nextthink = time;
307 // change owner to whoever caused the combo explosion
308 this.realowner = inflictor.realowner;
309 this.classname = "electro_orb_chain";
310 setthink(this, W_Electro_ExplodeCombo);
311 this.nextthink = time +
313 // bound the length, inflictor may be in a galaxy far far away (warpzones)
315 WEP_CVAR(electro, combo_radius),
316 vlen(this.origin - inflictor.origin)
319 // delay combo chains, looks cooler
320 WEP_CVAR(electro, combo_speed)
325 this.use = W_Electro_Explode_use;
326 setthink(this, adaptor_think2use); // not _hittype_splash, as this runs "immediately"
331 void W_Electro_Attack_Orb(Weapon thiswep, entity actor, .entity weaponentity)
333 W_DecreaseAmmo(thiswep, actor, WEP_CVAR_SEC(electro, ammo), weaponentity);
335 W_SetupShot_ProjectileSize(
344 WEP_CVAR_SEC(electro, damage),
345 thiswep.m_id | HITTYPE_SECONDARY
348 w_shotdir = v_forward; // no TrueAim for grenades please
350 Send_Effect(EFFECT_ELECTRO_MUZZLEFLASH, w_shotorg, w_shotdir * 1000, 1);
352 entity proj = new(electro_orb);
353 proj.owner = proj.realowner = actor;
354 proj.use = W_Electro_Explode_use;
355 setthink(proj, adaptor_think2use_hittype_splash);
356 proj.bot_dodge = true;
357 proj.bot_dodgerating = WEP_CVAR_SEC(electro, damage);
358 proj.nextthink = time + WEP_CVAR_SEC(electro, lifetime);
359 PROJECTILE_MAKETRIGGER(proj);
360 proj.projectiledeathtype = thiswep.m_id | HITTYPE_SECONDARY;
361 proj.weaponentity_fld = weaponentity;
362 setorigin(proj, w_shotorg);
364 //proj.glow_size = 50;
365 //proj.glow_color = 45;
366 set_movetype(proj, MOVETYPE_BOUNCE);
367 W_SetupProjVelocity_UP_SEC(proj, electro);
368 settouch(proj, W_Electro_Orb_Touch);
369 setsize(proj, '-4 -4 -4', '4 4 4');
370 proj.takedamage = DAMAGE_YES;
371 proj.damageforcescale = WEP_CVAR_SEC(electro, damageforcescale);
372 SetResourceExplicit(proj, RES_HEALTH, WEP_CVAR_SEC(electro, health));
373 proj.event_damage = W_Electro_Orb_Damage;
374 proj.flags = FL_PROJECTILE;
375 IL_PUSH(g_projectiles, proj);
376 IL_PUSH(g_bot_dodge, proj);
377 proj.damagedbycontents = (WEP_CVAR_SEC(electro, damagedbycontents));
378 if(proj.damagedbycontents)
379 IL_PUSH(g_damagedbycontents, proj);
381 proj.bouncefactor = WEP_CVAR_SEC(electro, bouncefactor);
382 proj.bouncestop = WEP_CVAR_SEC(electro, bouncestop);
383 proj.missile_flags = MIF_SPLASH | MIF_ARC;
385 CSQCProjectile(proj, true, PROJECTILE_ELECTRO, false); // no culling, it has sound
387 MUTATOR_CALLHOOK(EditProjectile, actor, proj);
390 void W_Electro_CheckAttack(Weapon thiswep, entity actor, .entity weaponentity, int fire)
392 if(actor.(weaponentity).electro_count > 1)
393 if(PHYS_INPUT_BUTTON_ATCK2(actor))
394 if(weapon_prepareattack(thiswep, actor, weaponentity, true, -1))
396 W_Electro_Attack_Orb(thiswep, actor, weaponentity);
397 actor.(weaponentity).electro_count -= 1;
398 weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, WEP_CVAR_SEC(electro, animtime), W_Electro_CheckAttack);
401 // WEAPONTODO: when the player releases the button, cut down the length of refire2?
402 w_ready(thiswep, actor, weaponentity, fire);
405 .float bot_secondary_electromooth;
407 METHOD(Electro, wr_aim, void(entity thiswep, entity actor, .entity weaponentity))
409 PHYS_INPUT_BUTTON_ATCK(actor) = PHYS_INPUT_BUTTON_ATCK2(actor) = false;
410 if(vdist(actor.origin - actor.enemy.origin, >, 1000)) { actor.bot_secondary_electromooth = 0; }
411 if(actor.bot_secondary_electromooth == 0)
415 if(WEP_CVAR_PRI(electro, speed))
416 shoot = bot_aim(actor, weaponentity, WEP_CVAR_PRI(electro, speed), 0, WEP_CVAR_PRI(electro, lifetime), false);
418 shoot = bot_aim(actor, weaponentity, 1000000, 0, 0.001, false);
422 PHYS_INPUT_BUTTON_ATCK(actor) = true;
423 if(random() < 0.01) actor.bot_secondary_electromooth = 1;
428 if(bot_aim(actor, weaponentity, WEP_CVAR_SEC(electro, speed), WEP_CVAR_SEC(electro, speed_up), WEP_CVAR_SEC(electro, lifetime), true))
430 PHYS_INPUT_BUTTON_ATCK2(actor) = true;
431 if(random() < 0.03) actor.bot_secondary_electromooth = 0;
435 METHOD(Electro, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire))
437 if(autocvar_g_balance_electro_reload_ammo) // forced reload // WEAPONTODO
439 float ammo_amount = 0;
440 if(actor.(weaponentity).clip_load >= WEP_CVAR_PRI(electro, ammo))
442 if(actor.(weaponentity).clip_load >= WEP_CVAR_SEC(electro, ammo))
447 thiswep.wr_reload(thiswep, actor, weaponentity);
454 if(weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR_PRI(electro, refire)))
456 W_Electro_Attack_Bolt(thiswep, actor, weaponentity);
457 weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(electro, animtime), w_ready);
462 if(time >= actor.(weaponentity).electro_secondarytime)
463 if(weapon_prepareattack(thiswep, actor, weaponentity, true, WEP_CVAR_SEC(electro, refire)))
465 W_Electro_Attack_Orb(thiswep, actor, weaponentity);
466 actor.(weaponentity).electro_count = WEP_CVAR_SEC(electro, count);
467 weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, WEP_CVAR_SEC(electro, animtime), W_Electro_CheckAttack);
468 actor.(weaponentity).electro_secondarytime = time + WEP_CVAR_SEC(electro, refire2) * W_WeaponRateFactor(actor);
472 METHOD(Electro, wr_checkammo1, bool(entity thiswep, entity actor, .entity weaponentity))
474 float ammo_amount = GetResource(actor, thiswep.ammo_type) >= WEP_CVAR_PRI(electro, ammo);
475 ammo_amount += actor.(weaponentity).(weapon_load[thiswep.m_id]) >= WEP_CVAR_PRI(electro, ammo);
478 METHOD(Electro, wr_checkammo2, bool(entity thiswep, entity actor, .entity weaponentity))
481 if(WEP_CVAR(electro, combo_safeammocheck)) // true if you can fire at least one secondary blob AND one primary shot after it, otherwise false.
483 ammo_amount = GetResource(actor, thiswep.ammo_type) >= WEP_CVAR_SEC(electro, ammo) + WEP_CVAR_PRI(electro, ammo);
484 ammo_amount += actor.(weaponentity).(weapon_load[thiswep.m_id]) >= WEP_CVAR_SEC(electro, ammo) + WEP_CVAR_PRI(electro, ammo);
488 ammo_amount = GetResource(actor, thiswep.ammo_type) >= WEP_CVAR_SEC(electro, ammo);
489 ammo_amount += actor.(weaponentity).(weapon_load[thiswep.m_id]) >= WEP_CVAR_SEC(electro, ammo);
493 METHOD(Electro, wr_resetplayer, void(entity thiswep, entity actor))
495 for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
497 .entity weaponentity = weaponentities[slot];
498 actor.(weaponentity).electro_secondarytime = time;
501 METHOD(Electro, wr_reload, void(entity thiswep, entity actor, .entity weaponentity))
503 W_Reload(actor, weaponentity, min(WEP_CVAR_PRI(electro, ammo), WEP_CVAR_SEC(electro, ammo)), SND_RELOAD);
505 METHOD(Electro, wr_suicidemessage, Notification(entity thiswep))
507 if(w_deathtype & HITTYPE_SECONDARY)
508 return WEAPON_ELECTRO_SUICIDE_ORBS;
510 return WEAPON_ELECTRO_SUICIDE_BOLT;
512 METHOD(Electro, wr_killmessage, Notification(entity thiswep))
514 if(w_deathtype & HITTYPE_SECONDARY)
516 return WEAPON_ELECTRO_MURDER_ORBS;
520 if(w_deathtype & HITTYPE_BOUNCE)
521 return WEAPON_ELECTRO_MURDER_COMBO;
523 return WEAPON_ELECTRO_MURDER_BOLT;
530 METHOD(Electro, wr_impacteffect, void(entity thiswep, entity actor))
533 org2 = w_org + w_backoff * 6;
534 if(w_deathtype & HITTYPE_SECONDARY)
536 pointparticles(EFFECT_ELECTRO_BALLEXPLODE, org2, '0 0 0', 1);
538 sound(actor, CH_SHOTS, SND_ELECTRO_IMPACT, VOL_BASE, ATTEN_NORM);
542 if(w_deathtype & HITTYPE_BOUNCE)
544 // this is sent as "primary (w_deathtype & HITTYPE_BOUNCE)" to distinguish it from (w_deathtype & HITTYPE_SECONDARY) bounced balls
545 pointparticles(EFFECT_ELECTRO_COMBO, org2, '0 0 0', 1);
547 sound(actor, CH_SHOTS, SND_ELECTRO_IMPACT_COMBO, VOL_BASE, ATTEN_NORM);
551 pointparticles(EFFECT_ELECTRO_IMPACT, org2, '0 0 0', 1);
553 sound(actor, CH_SHOTS, SND_ELECTRO_IMPACT, VOL_BASE, ATTEN_NORM);