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")
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 // now set the next one to trigger as well
163 setthink(e, W_Electro_ExplodeCombo);
165 // delay combo chains, looks cooler
170 (WEP_CVAR(electro, combo_speed) ?
171 (vlen(e.WarpZone_findradius_dist) / WEP_CVAR(electro, combo_speed))
182 // if we triggered an orb, should we explode? if not, lets try again next time
183 if(found && WEP_CVAR_PRI(electro, midaircombo_explode))
184 { this.use(this, NULL, NULL); }
186 { this.nextthink = min(time + WEP_CVAR_PRI(electro, midaircombo_interval), this.ltime); }
188 else { this.nextthink = this.ltime; }
189 // this.nextthink = time;
192 void W_Electro_Attack_Bolt(Weapon thiswep, entity actor, .entity weaponentity)
196 W_DecreaseAmmo(thiswep, actor, WEP_CVAR_PRI(electro, ammo), weaponentity);
198 W_SetupShot_ProjectileSize(
207 WEP_CVAR_PRI(electro, damage)
210 Send_Effect(EFFECT_ELECTRO_MUZZLEFLASH, w_shotorg, w_shotdir * 1000, 1);
212 proj = new(electro_bolt);
213 proj.owner = proj.realowner = actor;
214 proj.bot_dodge = true;
215 proj.bot_dodgerating = WEP_CVAR_PRI(electro, damage);
216 proj.use = W_Electro_Explode_use;
217 setthink(proj, W_Electro_Bolt_Think);
218 proj.nextthink = time;
219 proj.ltime = time + WEP_CVAR_PRI(electro, lifetime);
220 PROJECTILE_MAKETRIGGER(proj);
221 proj.projectiledeathtype = WEP_ELECTRO.m_id;
222 proj.weaponentity_fld = weaponentity;
223 setorigin(proj, w_shotorg);
226 set_movetype(proj, MOVETYPE_FLY);
227 W_SetupProjVelocity_PRI(proj, electro);
228 proj.angles = vectoangles(proj.velocity);
229 settouch(proj, W_Electro_TouchExplode);
230 setsize(proj, '0 0 -3', '0 0 -3');
231 proj.flags = FL_PROJECTILE;
232 IL_PUSH(g_projectiles, proj);
233 IL_PUSH(g_bot_dodge, proj);
234 proj.missile_flags = MIF_SPLASH;
236 CSQCProjectile(proj, true, PROJECTILE_ELECTRO_BEAM, true);
238 MUTATOR_CALLHOOK(EditProjectile, actor, proj);
239 // proj.com_phys_pos = proj.origin;
240 // proj.com_phys_vel = proj.velocity;
243 void W_Electro_Orb_Stick(entity this, entity to)
245 entity newproj = spawn();
246 newproj.classname = this.classname;
248 newproj.bot_dodge = this.bot_dodge;
249 newproj.bot_dodgerating = this.bot_dodgerating;
251 newproj.owner = this.owner;
252 newproj.realowner = this.realowner;
253 setsize(newproj, this.mins, this.maxs);
254 setorigin(newproj, this.origin);
255 setmodel(newproj, MDL_PROJECTILE_ELECTRO);
256 newproj.angles = vectoangles(-trace_plane_normal); // face against the surface
258 newproj.takedamage = this.takedamage;
259 newproj.damageforcescale = this.damageforcescale;
260 newproj.health = this.health;
261 newproj.event_damage = this.event_damage;
262 newproj.spawnshieldtime = this.spawnshieldtime;
263 newproj.damagedbycontents = true;
264 IL_PUSH(g_damagedbycontents, newproj);
266 set_movetype(newproj, MOVETYPE_NONE); // lock the orb in place
267 newproj.projectiledeathtype = this.projectiledeathtype;
268 newproj.weaponentity_fld = this.weaponentity_fld;
270 settouch(newproj, func_null);
271 setthink(newproj, getthink(this));
272 newproj.nextthink = this.nextthink;
273 newproj.use = this.use;
274 newproj.flags = this.flags;
275 IL_PUSH(g_projectiles, newproj);
276 IL_PUSH(g_bot_dodge, newproj);
281 SetMovetypeFollow(this, to);
284 void W_Electro_Orb_Touch(entity this, entity toucher)
286 PROJECTILE_TOUCH(this, toucher);
287 if(toucher.takedamage == DAMAGE_AIM)
288 { if(WEP_CVAR_SEC(electro, touchexplode)) { W_Electro_Explode(this, toucher); } }
289 else if(toucher.owner != this.owner && toucher.classname != this.classname) // don't stick to player's other projectiles!
291 //UpdateCSQCProjectile(this);
292 spamsound(this, CH_SHOTS, SND_ELECTRO_BOUNCE, VOL_BASE, ATTEN_NORM);
293 this.projectiledeathtype |= HITTYPE_BOUNCE;
295 if(WEP_CVAR_SEC(electro, stick))
296 W_Electro_Orb_Stick(this, toucher);
300 void W_Electro_Orb_Damage(entity this, entity inflictor, entity attacker, float damage, int deathtype, .entity weaponentity, vector hitloc, vector force)
305 // note: combos are usually triggered by W_Electro_TriggerCombo, not damage
306 float is_combo = (inflictor.classname == "electro_orb_chain" || inflictor.classname == "electro_bolt");
308 if(!W_CheckProjectileDamage(inflictor.realowner, this.realowner, deathtype, (is_combo ? 1 : -1)))
309 return; // g_projectiles_damage says to halt
311 this.health = this.health - damage;
314 this.takedamage = DAMAGE_NO;
315 this.nextthink = time;
318 // change owner to whoever caused the combo explosion
319 this.realowner = inflictor.realowner;
320 this.classname = "electro_orb_chain";
321 setthink(this, W_Electro_ExplodeCombo);
322 this.nextthink = time +
324 // bound the length, inflictor may be in a galaxy far far away (warpzones)
326 WEP_CVAR(electro, combo_radius),
327 vlen(this.origin - inflictor.origin)
330 // delay combo chains, looks cooler
331 WEP_CVAR(electro, combo_speed)
336 this.use = W_Electro_Explode_use;
337 setthink(this, adaptor_think2use); // not _hittype_splash, as this runs "immediately"
342 void W_Electro_Attack_Orb(Weapon thiswep, entity actor, .entity weaponentity)
344 W_DecreaseAmmo(thiswep, actor, WEP_CVAR_SEC(electro, ammo), weaponentity);
346 W_SetupShot_ProjectileSize(
355 WEP_CVAR_SEC(electro, damage)
358 w_shotdir = v_forward; // no TrueAim for grenades please
360 Send_Effect(EFFECT_ELECTRO_MUZZLEFLASH, w_shotorg, w_shotdir * 1000, 1);
362 entity proj = new(electro_orb);
363 proj.owner = proj.realowner = actor;
364 proj.use = W_Electro_Explode_use;
365 setthink(proj, adaptor_think2use_hittype_splash);
366 proj.bot_dodge = true;
367 proj.bot_dodgerating = WEP_CVAR_SEC(electro, damage);
368 proj.nextthink = time + WEP_CVAR_SEC(electro, lifetime);
369 PROJECTILE_MAKETRIGGER(proj);
370 proj.projectiledeathtype = WEP_ELECTRO.m_id | HITTYPE_SECONDARY;
371 proj.weaponentity_fld = weaponentity;
372 setorigin(proj, w_shotorg);
374 //proj.glow_size = 50;
375 //proj.glow_color = 45;
376 set_movetype(proj, MOVETYPE_BOUNCE);
377 W_SetupProjVelocity_UP_SEC(proj, electro);
378 settouch(proj, W_Electro_Orb_Touch);
379 setsize(proj, '-4 -4 -4', '4 4 4');
380 proj.takedamage = DAMAGE_YES;
381 proj.damageforcescale = WEP_CVAR_SEC(electro, damageforcescale);
382 proj.health = WEP_CVAR_SEC(electro, health);
383 proj.event_damage = W_Electro_Orb_Damage;
384 proj.flags = FL_PROJECTILE;
385 IL_PUSH(g_projectiles, proj);
386 IL_PUSH(g_bot_dodge, proj);
387 proj.damagedbycontents = (WEP_CVAR_SEC(electro, damagedbycontents));
388 if(proj.damagedbycontents)
389 IL_PUSH(g_damagedbycontents, proj);
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, actor, proj);
408 void W_Electro_CheckAttack(Weapon thiswep, entity actor, .entity weaponentity, int fire)
410 if(actor.(weaponentity).electro_count > 1)
411 if(PHYS_INPUT_BUTTON_ATCK2(actor))
412 if(weapon_prepareattack(thiswep, actor, weaponentity, true, -1))
414 W_Electro_Attack_Orb(WEP_ELECTRO, actor, weaponentity);
415 actor.(weaponentity).electro_count -= 1;
416 weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, WEP_CVAR_SEC(electro, animtime), W_Electro_CheckAttack);
419 // WEAPONTODO: when the player releases the button, cut down the length of refire2?
420 w_ready(thiswep, actor, weaponentity, fire);
423 .float bot_secondary_electromooth;
425 METHOD(Electro, wr_aim, void(entity thiswep, entity actor, .entity weaponentity))
427 PHYS_INPUT_BUTTON_ATCK(actor) = PHYS_INPUT_BUTTON_ATCK2(actor) = false;
428 if(vdist(actor.origin - actor.enemy.origin, >, 1000)) { actor.bot_secondary_electromooth = 0; }
429 if(actor.bot_secondary_electromooth == 0)
433 if(WEP_CVAR_PRI(electro, speed))
434 shoot = bot_aim(actor, weaponentity, WEP_CVAR_PRI(electro, speed), 0, WEP_CVAR_PRI(electro, lifetime), false);
436 shoot = bot_aim(actor, weaponentity, 1000000, 0, 0.001, false);
440 PHYS_INPUT_BUTTON_ATCK(actor) = true;
441 if(random() < 0.01) actor.bot_secondary_electromooth = 1;
446 if(bot_aim(actor, weaponentity, WEP_CVAR_SEC(electro, speed), WEP_CVAR_SEC(electro, speed_up), WEP_CVAR_SEC(electro, lifetime), true))
448 PHYS_INPUT_BUTTON_ATCK2(actor) = true;
449 if(random() < 0.03) actor.bot_secondary_electromooth = 0;
453 METHOD(Electro, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire))
455 if(autocvar_g_balance_electro_reload_ammo) // forced reload // WEAPONTODO
457 float ammo_amount = 0;
458 if(actor.(weaponentity).clip_load >= WEP_CVAR_PRI(electro, ammo))
460 if(actor.(weaponentity).clip_load >= WEP_CVAR_SEC(electro, ammo))
465 thiswep.wr_reload(thiswep, actor, weaponentity);
472 if(weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR_PRI(electro, refire)))
474 W_Electro_Attack_Bolt(thiswep, actor, weaponentity);
475 weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(electro, animtime), w_ready);
480 if(time >= actor.(weaponentity).electro_secondarytime)
481 if(weapon_prepareattack(thiswep, actor, weaponentity, true, WEP_CVAR_SEC(electro, refire)))
483 W_Electro_Attack_Orb(thiswep, actor, weaponentity);
484 actor.(weaponentity).electro_count = WEP_CVAR_SEC(electro, count);
485 weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, WEP_CVAR_SEC(electro, animtime), W_Electro_CheckAttack);
486 actor.(weaponentity).electro_secondarytime = time + WEP_CVAR_SEC(electro, refire2) * W_WeaponRateFactor(actor);
490 METHOD(Electro, wr_checkammo1, bool(entity thiswep, entity actor, .entity weaponentity))
492 float ammo_amount = GetResourceAmount(actor, thiswep.ammo_type) >= WEP_CVAR_PRI(electro, ammo);
493 ammo_amount += actor.(weaponentity).(weapon_load[WEP_ELECTRO.m_id]) >= WEP_CVAR_PRI(electro, ammo);
496 METHOD(Electro, wr_checkammo2, bool(entity thiswep, entity actor, .entity weaponentity))
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 = GetResourceAmount(actor, thiswep.ammo_type) >= WEP_CVAR_SEC(electro, ammo) + WEP_CVAR_PRI(electro, ammo);
502 ammo_amount += actor.(weaponentity).(weapon_load[WEP_ELECTRO.m_id]) >= WEP_CVAR_SEC(electro, ammo) + WEP_CVAR_PRI(electro, ammo);
506 ammo_amount = GetResourceAmount(actor, thiswep.ammo_type) >= WEP_CVAR_SEC(electro, ammo);
507 ammo_amount += actor.(weaponentity).(weapon_load[WEP_ELECTRO.m_id]) >= WEP_CVAR_SEC(electro, ammo);
511 METHOD(Electro, wr_resetplayer, void(entity thiswep, entity actor))
513 for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
515 .entity weaponentity = weaponentities[slot];
516 actor.(weaponentity).electro_secondarytime = time;
519 METHOD(Electro, wr_reload, void(entity thiswep, entity actor, .entity weaponentity))
521 W_Reload(actor, weaponentity, min(WEP_CVAR_PRI(electro, ammo), WEP_CVAR_SEC(electro, ammo)), SND_RELOAD);
523 METHOD(Electro, wr_suicidemessage, Notification(entity thiswep))
525 if(w_deathtype & HITTYPE_SECONDARY)
526 return WEAPON_ELECTRO_SUICIDE_ORBS;
528 return WEAPON_ELECTRO_SUICIDE_BOLT;
530 METHOD(Electro, wr_killmessage, Notification(entity thiswep))
532 if(w_deathtype & HITTYPE_SECONDARY)
534 return WEAPON_ELECTRO_MURDER_ORBS;
538 if(w_deathtype & HITTYPE_BOUNCE)
539 return WEAPON_ELECTRO_MURDER_COMBO;
541 return WEAPON_ELECTRO_MURDER_BOLT;
548 METHOD(Electro, wr_impacteffect, void(entity thiswep, entity actor))
551 org2 = w_org + w_backoff * 6;
552 if(w_deathtype & HITTYPE_SECONDARY)
554 pointparticles(EFFECT_ELECTRO_BALLEXPLODE, org2, '0 0 0', 1);
556 sound(actor, CH_SHOTS, SND_ELECTRO_IMPACT, VOL_BASE, ATTEN_NORM);
560 if(w_deathtype & HITTYPE_BOUNCE)
562 // this is sent as "primary (w_deathtype & HITTYPE_BOUNCE)" to distinguish it from (w_deathtype & HITTYPE_SECONDARY) bounced balls
563 pointparticles(EFFECT_ELECTRO_COMBO, org2, '0 0 0', 1);
565 sound(actor, CH_SHOTS, SND_ELECTRO_IMPACT_COMBO, VOL_BASE, ATTEN_NORM);
569 pointparticles(EFFECT_ELECTRO_IMPACT, org2, '0 0 0', 1);
571 sound(actor, CH_SHOTS, SND_ELECTRO_IMPACT, VOL_BASE, ATTEN_NORM);