#include "electro.qh"
#ifdef SVQC
+#include <common/effects/qc/_mod.qh>
void W_Electro_TriggerCombo(vector org, float rad, entity own)
{
{
if(e.classname == "electro_orb")
{
+ // check if the ball we are exploding is not owned by an
+ // independent player which is not the player who shot the ball
+ if(IS_INDEPENDENT_PLAYER(e.realowner) && own != e.realowner)
+ {
+ e = e.chain;
+ continue;
+ }
// do we allow thruwall triggering?
if(WEP_CVAR(electro, combo_comboradius_thruwall))
{
setthink(e, W_Electro_ExplodeCombo);
// delay combo chains, looks cooler
- e.nextthink =
- (
- time
- +
- (WEP_CVAR(electro, combo_speed) ?
- (vlen(e.WarpZone_findradius_dist) / WEP_CVAR(electro, combo_speed))
- :
- 0
- )
- );
+ float delay = 0;
+ if (WEP_CVAR(electro, combo_speed))
+ delay = vlen(e.WarpZone_findradius_dist) / WEP_CVAR(electro, combo_speed);
+ e.nextthink = time + delay;
}
e = e.chain;
}
}
+void W_Electro_ExplodeComboThink(entity this)
+{
+ float dt = time - this.teleport_time + this.dmg_interval;
+ float dmg_remaining_next = (bound(0, 1 - dt / this.dmg_duration, 1) ** this.dmg_power);
+
+ float f = this.dmg_last - dmg_remaining_next;
+ this.dmg_last = dmg_remaining_next;
+
+ float dmg_scale = ((this.dmg_linear) ? this.dmg_interval : f);
+
+ RadiusDamage(this, this.realowner, this.dmg * dmg_scale, this.dmg_edge * dmg_scale, this.dmg_radius, NULL, NULL, this.dmg_force * f, this.projectiledeathtype, this.weaponentity_fld, NULL);
+ this.projectiledeathtype |= HITTYPE_BOUNCE; // ensure it doesn't spam its effect
+
+ if(dt < this.dmg_duration)
+ this.nextthink = time + this.dmg_interval; // soon
+ else
+ delete(this);
+}
+
void W_Electro_ExplodeCombo(entity this)
{
W_Electro_TriggerCombo(this.origin, WEP_CVAR(electro, combo_comboradius), this.realowner);
this.event_damage = func_null;
+ this.velocity = this.movedir; // particle fx and decals need .velocity
+
+ if(WEP_CVAR(electro, combo_duration))
+ {
+ this.projectiledeathtype = WEP_ELECTRO.m_id | HITTYPE_SPLASH;
+ this.event_damage = func_null;
+ settouch(this, func_null);
+ this.effects |= EF_NODRAW;
+
+ setthink(this, W_Electro_ExplodeComboThink);
+ this.nextthink = time;
+ this.dmg = WEP_CVAR(electro, combo_damage);
+ this.dmg_edge = WEP_CVAR(electro, combo_edgedamage);
+ this.dmg_radius = WEP_CVAR(electro, combo_radius);
+ this.dmg_force = WEP_CVAR(electro, combo_force);
+ this.dmg_power = WEP_CVAR(electro, combo_power);
+ this.dmg_duration = WEP_CVAR(electro, combo_duration);
+ this.dmg_interval = WEP_CVAR(electro, combo_damage_interval);
+ this.dmg_linear = WEP_CVAR(electro, combo_damage_linear);
+ this.teleport_time = time;
+ this.dmg_last = 1;
+ set_movetype(this, MOVETYPE_NONE);
+ return;
+ }
RadiusDamage(
this,
this.event_damage = func_null;
this.takedamage = DAMAGE_NO;
+ this.velocity = this.movedir; // particle fx and decals need .velocity
if(this.move_movetype == MOVETYPE_BOUNCE || this.classname == "electro_orb") // TODO: classname is more reliable anyway?
{
}
-void sys_phys_update_single(entity this);
+//void sys_phys_update_single(entity this);
void W_Electro_Bolt_Think(entity this)
{
{
if(e.classname == "electro_orb")
{
+ // check if the ball we are exploding is not owned by an
+ // independent player which is not the player who shot the ball
+ if(IS_INDEPENDENT_PLAYER(e.realowner) && this.realowner != e.realowner)
+ {
+ e = e.chain;
+ continue;
+ }
bool explode;
if (this.owner == e.owner)
{
// (the bolt and orb should explode together because they interacted together)
// while keeping the chaining delay.
setthink(e, W_Electro_ExplodeCombo);
- e.nextthink =
- (
- time
- +
- (WEP_CVAR_PRI(electro, midaircombo_speed) ?
- (vlen(e.WarpZone_findradius_dist) / WEP_CVAR_PRI(electro, midaircombo_speed))
- :
- 0
- )
- );
-
+ float delay = 0;
+ if (WEP_CVAR_PRI(electro, midaircombo_speed))
+ delay = vlen(e.WarpZone_findradius_dist) / WEP_CVAR_PRI(electro, midaircombo_speed);
+ e.nextthink = time + delay;
++found;
}
thiswep.m_id
);
- Send_Effect(EFFECT_ELECTRO_MUZZLEFLASH, w_shotorg, w_shotdir * 1000, 1);
+ W_MuzzleFlash(thiswep, actor, weaponentity, w_shotorg, w_shotdir);
proj = new(electro_bolt);
proj.owner = proj.realowner = actor;
// proj.com_phys_vel = proj.velocity;
}
+void W_Electro_Orb_Follow_Think(entity this)
+{
+ if (time > this.death_time)
+ {
+ adaptor_think2use_hittype_splash(this);
+ return;
+ }
+ if (this.move_movetype == MOVETYPE_FOLLOW)
+ {
+ int lost = LostMovetypeFollow(this);
+ if (lost == 2)
+ {
+ // FIXME if player disconnected, it isn't possible to drop the orb at player's origin
+ // see comment in LostMovetypeFollow implementation
+ delete(this);
+ return;
+ }
+ if (lost)
+ {
+ // drop the orb at the corpse's location
+ PROJECTILE_MAKETRIGGER(this);
+ set_movetype(this, MOVETYPE_TOSS);
+
+ setthink(this, adaptor_think2use_hittype_splash);
+ this.nextthink = this.death_time;
+ return;
+ }
+ }
+ this.nextthink = time;
+}
+
void W_Electro_Orb_Stick(entity this, entity to)
{
entity newproj = spawn();
newproj.owner = this.owner;
newproj.realowner = this.realowner;
- setsize(newproj, this.mins, this.maxs);
setorigin(newproj, this.origin);
setmodel(newproj, MDL_PROJECTILE_ELECTRO);
+ setsize(newproj, this.mins, this.maxs);
newproj.angles = vectoangles(-trace_plane_normal); // face against the surface
+ newproj.traileffectnum = _particleeffectnum(EFFECT_TR_NEXUIZPLASMA.eent_eff_name);
+
+ newproj.movedir = -trace_plane_normal;
newproj.takedamage = this.takedamage;
newproj.damageforcescale = this.damageforcescale;
newproj.weaponentity_fld = this.weaponentity_fld;
settouch(newproj, func_null);
- setthink(newproj, getthink(this));
- newproj.nextthink = this.nextthink;
+ if(WEP_CVAR_SEC(electro, stick_lifetime) > 0){
+ newproj.death_time = time + WEP_CVAR_SEC(electro, stick_lifetime);
+ }else{
+ newproj.death_time = this.death_time;
+ }
newproj.use = this.use;
newproj.flags = this.flags;
IL_PUSH(g_projectiles, newproj);
IL_PUSH(g_bot_dodge, newproj);
+ // check if limits are enabled (we can tell by checking if the original orb is listed) and push it to the list if so
+ if(LimitedElectroBallRubbleList && IL_CONTAINS(LimitedElectroBallRubbleList, this))
+ {
+ ReplaceOldListedChildRubble(LimitedElectroBallRubbleList, newproj, this);
+ }
+
delete(this);
if(to)
+ {
SetMovetypeFollow(newproj, to);
+
+ setthink(newproj, W_Electro_Orb_Follow_Think);
+ newproj.nextthink = time;
+ }
+ else
+ {
+ setthink(newproj, adaptor_think2use_hittype_splash);
+ newproj.nextthink = newproj.death_time;
+ }
}
void W_Electro_Orb_Touch(entity this, entity toucher)
spamsound(this, CH_SHOTS, SND_ELECTRO_BOUNCE, VOL_BASE, ATTEN_NORM);
this.projectiledeathtype |= HITTYPE_BOUNCE;
- if(WEP_CVAR_SEC(electro, stick))
- W_Electro_Orb_Stick(this, toucher);
+ if(WEP_CVAR_SEC(electro, stick)){
+ if(WEP_CVAR_SEC(electro, stick_lifetime) == 0){
+ W_Electro_Explode(this, toucher);
+ } else {
+ W_Electro_Orb_Stick(this, toucher);
+ }
+ }
}
}
this.realowner = inflictor.realowner;
this.classname = "electro_orb_chain";
setthink(this, W_Electro_ExplodeCombo);
- this.nextthink = time +
- (
- // bound the length, inflictor may be in a galaxy far far away (warpzones)
- min(
- WEP_CVAR(electro, combo_radius),
- vlen(this.origin - inflictor.origin)
- )
- /
- // delay combo chains, looks cooler
- WEP_CVAR(electro, combo_speed)
- );
+ // delay combo chains, looks cooler
+ // bound the length, inflictor may be in a galaxy far far away (warpzones)
+ float len = min(WEP_CVAR(electro, combo_radius), vlen(this.origin - inflictor.origin));
+ float delay = len / WEP_CVAR(electro, combo_speed);
+ this.nextthink = time + delay;
}
else
{
w_shotdir = v_forward; // no TrueAim for grenades please
- Send_Effect(EFFECT_ELECTRO_MUZZLEFLASH, w_shotorg, w_shotdir * 1000, 1);
+ W_MuzzleFlash(thiswep, actor, weaponentity, w_shotorg, w_shotdir);
entity proj = new(electro_orb);
proj.owner = proj.realowner = actor;
proj.bot_dodge = true;
proj.bot_dodgerating = WEP_CVAR_SEC(electro, damage);
proj.nextthink = time + WEP_CVAR_SEC(electro, lifetime);
+ proj.death_time = time + WEP_CVAR_SEC(electro, lifetime);
PROJECTILE_MAKETRIGGER(proj);
proj.projectiledeathtype = thiswep.m_id | HITTYPE_SECONDARY;
proj.weaponentity_fld = weaponentity;
proj.bouncestop = WEP_CVAR_SEC(electro, bouncestop);
proj.missile_flags = MIF_SPLASH | MIF_ARC;
+ if(WEP_CVAR_SEC(electro, limit) > 0)
+ {
+ if (!LimitedElectroBallRubbleList)
+ LimitedElectroBallRubbleList = IL_NEW();
+ ListNewChildRubble(LimitedElectroBallRubbleList, proj);
+ LimitedChildrenRubble(LimitedElectroBallRubbleList, "electro_orb", WEP_CVAR_SEC(electro, limit), adaptor_think2use_hittype_splash, actor);
+ }
+
CSQCProjectile(proj, true, PROJECTILE_ELECTRO, false); // no culling, it has sound
MUTATOR_CALLHOOK(EditProjectile, actor, proj);
{
W_Electro_Attack_Orb(thiswep, actor, weaponentity);
actor.(weaponentity).electro_count -= 1;
+ actor.(weaponentity).electro_secondarytime = time;
weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, WEP_CVAR_SEC(electro, animtime), W_Electro_CheckAttack);
return;
}
- // WEAPONTODO: when the player releases the button, cut down the length of refire2?
w_ready(thiswep, actor, weaponentity, fire);
}
if(fire & 1)
{
+ if(time >= actor.(weaponentity).electro_secondarytime + WEP_CVAR_SEC(electro, refire2) * W_WeaponRateFactor(actor))
if(weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR_PRI(electro, refire)))
{
- W_Electro_Attack_Bolt(thiswep, actor, weaponentity);
- weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(electro, animtime), w_ready);
+ W_Electro_Attack_Bolt(thiswep, actor, weaponentity);
+ weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(electro, animtime), w_ready);
}
}
else if(fire & 2)
{
- if(time >= actor.(weaponentity).electro_secondarytime)
- if(weapon_prepareattack(thiswep, actor, weaponentity, true, WEP_CVAR_SEC(electro, refire)))
+ if(time >= actor.(weaponentity).electro_secondarytime + WEP_CVAR_SEC(electro, refire) * W_WeaponRateFactor(actor))
+ if(weapon_prepareattack(thiswep, actor, weaponentity, true, -1))
{
W_Electro_Attack_Orb(thiswep, actor, weaponentity);
actor.(weaponentity).electro_count = WEP_CVAR_SEC(electro, count);
+ actor.(weaponentity).electro_secondarytime = time;
weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, WEP_CVAR_SEC(electro, animtime), W_Electro_CheckAttack);
- actor.(weaponentity).electro_secondarytime = time + WEP_CVAR_SEC(electro, refire2) * W_WeaponRateFactor(actor);
}
}
}
}
return ammo_amount;
}
-METHOD(Electro, wr_resetplayer, void(entity thiswep, entity actor))
-{
- for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
- {
- .entity weaponentity = weaponentities[slot];
- actor.(weaponentity).electro_secondarytime = time;
- }
-}
METHOD(Electro, wr_reload, void(entity thiswep, entity actor, .entity weaponentity))
{
W_Reload(actor, weaponentity, min(WEP_CVAR_PRI(electro, ammo), WEP_CVAR_SEC(electro, ammo)), SND_RELOAD);
}
else
{
- if(w_deathtype & HITTYPE_BOUNCE)
+ if(w_deathtype & HITTYPE_SPLASH)
+ {
+ org2 = w_org + w_backoff * 2;
+ if(particleeffectnum(EFFECT_ELECTRO_COMBO_LONG) >= 0)
+ pointparticles(EFFECT_ELECTRO_COMBO_LONG, org2, '0 0 0', 1);
+ else
+ pointparticles(EFFECT_HOOK_EXPLODE, org2, '0 0 0', 1);
+ if(!w_issilent)
+ sound(actor, CH_SHOTS, SND_ELECTRO_IMPACT_COMBO, VOL_BASE, ATTEN_NORM);
+ }
+ else if(w_deathtype & HITTYPE_BOUNCE)
{
// this is sent as "primary (w_deathtype & HITTYPE_BOUNCE)" to distinguish it from (w_deathtype & HITTYPE_SECONDARY) bounced balls
pointparticles(EFFECT_ELECTRO_COMBO, org2, '0 0 0', 1);