vector w_shotorg;
vector w_shotdir;
+vector w_shotend;
// this function calculates w_shotorg and w_shotdir based on the weapon model
// offset, trueaim and antilag, and won't put w_shotorg inside a wall.
// make sure you call makevectors first (FIXME?)
-void W_SetupShot_Dir_ProjectileSize(entity ent, vector s_forward, vector mi, vector ma, float antilag, float recoil, string snd, float maxdamage)
+void W_SetupShot_Dir_ProjectileSize_Range(entity ent, vector s_forward, vector mi, vector ma, float antilag, float recoil, string snd, float maxdamage, float range)
{
float nudge = 1; // added to traceline target and subtracted from result
- local vector trueaimpoint;
local float oldsolid;
vector vecs, dv;
oldsolid = ent.dphitcontentsmask;
else
ent.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_BODY | DPCONTENTS_CORPSE;
if(antilag)
- WarpZone_traceline_antilag(world, ent.origin + ent.view_ofs, ent.origin + ent.view_ofs + s_forward * MAX_SHOT_DISTANCE, MOVE_NORMAL, ent, ANTILAG_LATENCY(ent));
+ WarpZone_traceline_antilag(world, ent.origin + ent.view_ofs, ent.origin + ent.view_ofs + s_forward * range, MOVE_NORMAL, ent, ANTILAG_LATENCY(ent));
// passing world, because we do NOT want it to touch dphitcontentsmask
else
- WarpZone_TraceLine(ent.origin + ent.view_ofs, ent.origin + ent.view_ofs + s_forward * MAX_SHOT_DISTANCE, MOVE_NOMONSTERS, ent);
+ WarpZone_TraceLine(ent.origin + ent.view_ofs, ent.origin + ent.view_ofs + s_forward * range, MOVE_NOMONSTERS, ent);
ent.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_BODY | DPCONTENTS_CORPSE;
vector vf, vr, vu;
vf = v_forward;
vr = v_right;
vu = v_up;
- trueaimpoint = WarpZone_UnTransformOrigin(WarpZone_trace_transform, trace_endpos); // warpzone support
+ w_shotend = WarpZone_UnTransformOrigin(WarpZone_trace_transform, trace_endpos); // warpzone support
v_forward = vf;
v_right = vr;
v_up = vu;
tracebox(w_shotorg, mi, ma, w_shotorg + v_forward * (vecs_x + nudge), MOVE_NORMAL, ent);
w_shotorg = trace_endpos - v_forward * nudge;
// calculate the shotdir from the chosen shotorg
- w_shotdir = normalize(trueaimpoint - w_shotorg);
+ w_shotdir = normalize(w_shotend - w_shotorg);
if (antilag)
if (!ent.cvar_cl_noantilag)
{
if (cvar("g_antilag") == 1) // switch to "ghost" if not hitting original
{
- traceline(w_shotorg, w_shotorg + w_shotdir * MAX_SHOT_DISTANCE, MOVE_NORMAL, ent);
+ traceline(w_shotorg, w_shotorg + w_shotdir * range, MOVE_NORMAL, ent);
if (!trace_ent.takedamage)
{
- traceline_antilag_force (ent, w_shotorg, w_shotorg + w_shotdir * MAX_SHOT_DISTANCE, MOVE_NORMAL, ent, ANTILAG_LATENCY(ent));
+ traceline_antilag_force (ent, w_shotorg, w_shotorg + w_shotdir * range, MOVE_NORMAL, ent, ANTILAG_LATENCY(ent));
if (trace_ent.takedamage && trace_ent.classname == "player")
{
entity e;
{
// verify that the shot would miss without antilag
// (avoids an issue where guns would always shoot at their origin)
- traceline(w_shotorg, w_shotorg + w_shotdir * MAX_SHOT_DISTANCE, MOVE_NORMAL, ent);
+ traceline(w_shotorg, w_shotorg + w_shotdir * range, MOVE_NORMAL, ent);
if (!trace_ent.takedamage)
{
// verify that the shot would hit if altered
if (ent.items & IT_STRENGTH)
if (!g_minstagib)
sound (ent, CHAN_AUTO, "weapons/strength_fire.wav", VOL_BASE, ATTN_NORM);
+
+ // nudge w_shotend so a trace to w_shotend hits
+ w_shotend = w_shotend + normalize(w_shotend - w_shotorg) * nudge;
};
+#define W_SetupShot_Dir_ProjectileSize(ent,s_forward,mi,ma,antilag,recoil,snd,maxdamage) W_SetupShot_Dir_ProjectileSize_Range(ent, s_forward, mi, ma, antilag, recoil, snd, maxdamage, MAX_SHOT_DISTANCE)
#define W_SetupShot_ProjectileSize(ent,mi,ma,antilag,recoil,snd,maxdamage) W_SetupShot_Dir_ProjectileSize(ent, v_forward, mi, ma, antilag, recoil, snd, maxdamage)
#define W_SetupShot_Dir(ent,s_forward,antilag,recoil,snd,maxdamage) W_SetupShot_Dir_ProjectileSize(ent, s_forward, '0 0 0', '0 0 0', antilag, recoil, snd, maxdamage)
#define W_SetupShot(ent,antilag,recoil,snd,maxdamage) W_SetupShot_ProjectileSize(ent, '0 0 0', '0 0 0', antilag, recoil, snd, maxdamage)
+#define W_SetupShot_Range(ent,antilag,recoil,snd,maxdamage,range) W_SetupShot_Dir_ProjectileSize_Range(ent, v_forward, '0 0 0', '0 0 0', antilag, recoil, snd, maxdamage, range)
void LaserTarget_Think()
{
.float prevlgfire;
void lgbeam_think()
{
- vector endpos;
- float oldsolid;
-
self.owner.prevlgfire = time;
if (self.owner.weaponentity.state != WS_INUSE || (self.owner.ammo_cells <= 0 && !(self.owner.items & IT_UNLIMITED_WEAPON_AMMO)) || self != self.owner.lgbeam || self.owner.deadflag != DEAD_NO || !self.owner.BUTTON_ATCK)
{
self.nextthink = time;
makevectors(self.owner.v_angle);
- vector angle;
- angle = v_forward;
- // get effect origin
- vector vecs, org;
- if(self.owner.weaponentity.movedir_x > 0)
- vecs = self.owner.weaponentity.movedir;
- else
- vecs = '0 0 0';
- if(debug_shotorg != '0 0 0')
- vecs = debug_shotorg;
- org = self.owner.origin + self.owner.view_ofs + v_forward * vecs_x + v_right * -vecs_y + v_up * vecs_z;
-
- oldsolid = self.owner.dphitcontentsmask;
- self.owner.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_BODY | DPCONTENTS_CORPSE;
-
- WarpZone_traceline_antilag(self.owner, self.owner.origin + self.owner.view_ofs, self.owner.origin + self.owner.view_ofs + angle * cvar("g_balance_electro_primary_range"), MOVE_NORMAL, self.owner, ANTILAG_LATENCY(self.owner));
- endpos = WarpZone_UnTransformOrigin(WarpZone_trace_transform, trace_endpos);
- WarpZone_traceline_antilag(self.owner, org, endpos + 4 * normalize(endpos - org), MOVE_NORMAL, self.owner, ANTILAG_LATENCY(self.owner));
-
- self.owner.dphitcontentsmask = oldsolid;
+ float dt;
+ dt = frametime;
if not(self.owner.items & IT_UNLIMITED_WEAPON_AMMO)
+ {
+ if(cvar("g_balance_electro_primary_ammo"))
+ dt = min(frametime, self.owner.ammo_cells / cvar("g_balance_electro_primary_ammo"));
self.owner.ammo_cells = max(0, self.owner.ammo_cells - cvar("g_balance_electro_primary_ammo") * frametime);
+ }
+
+ W_SetupShot_Range(self.owner, TRUE, 0, "", cvar("g_balance_electro_primary_damage") * dt, cvar("g_balance_electro_primary_range"));
+ WarpZone_traceline_antilag(self.owner, w_shotorg, w_shotend, MOVE_NORMAL, self.owner, ANTILAG_LATENCY(self.owner));
// apply the damage
if(trace_ent)
{
vector force;
- force = angle * cvar("g_balance_electro_primary_force") + '0 0 1' * cvar("g_balance_electro_primary_force_up");
- Damage (trace_ent, self.owner, self.owner, cvar("g_balance_electro_primary_damage") * frametime, WEP_ELECTRO, trace_endpos, force * frametime);
+ force = w_shotdir * cvar("g_balance_electro_primary_force") + '0 0 1' * cvar("g_balance_electro_primary_force_up");
+ Damage (trace_ent, self.owner, self.owner, cvar("g_balance_electro_primary_damage") * dt, WEP_ELECTRO, trace_endpos, force * dt);
W_Plasma_TriggerCombo(trace_endpos, cvar("g_balance_electro_primary_comboradius"), self.owner);
}
// draw effect
- if(org != self.hook_start)
+ if(w_shotorg != self.hook_start)
{
self.SendFlags |= 2;
- self.hook_start = org;
+ self.hook_start = w_shotorg;
}
- if(endpos != self.hook_end)
+ if(w_shotend != self.hook_end)
{
self.SendFlags |= 4;
- self.hook_end = endpos;
+ self.hook_end = w_shotend;
}
}
.float prevgauntletfire;
void gauntletbeam_think()
{
- vector endpos;
- float oldsolid;
-
float damage, myforce, myradius;
if(self.cnt)
{
self.nextthink = time;
makevectors(self.owner.v_angle);
- vector angle;
- angle = v_forward;
- // get effect origin
- vector vecs, org;
- if(self.owner.weaponentity.movedir_x > 0)
- vecs = self.owner.weaponentity.movedir;
- else
- vecs = '0 0 0';
- if(debug_shotorg != '0 0 0')
- vecs = debug_shotorg;
- org = self.owner.origin + self.owner.view_ofs + v_forward * vecs_x + v_right * -vecs_y + v_up * vecs_z;
-
- oldsolid = self.owner.dphitcontentsmask;
- self.owner.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_BODY | DPCONTENTS_CORPSE;
- WarpZone_traceline_antilag(self.owner, self.owner.origin + self.owner.view_ofs, self.owner.origin + self.owner.view_ofs + angle * myradius, MOVE_NORMAL, self.owner, ANTILAG_LATENCY(self.owner));
- endpos = WarpZone_UnTransformOrigin(WarpZone_trace_transform, trace_endpos);
- WarpZone_traceline_antilag(self.owner, org, endpos + 4 * normalize(endpos - org), MOVE_NORMAL, self.owner, ANTILAG_LATENCY(self.owner));
+ float dt;
+ dt = frametime;
- self.owner.dphitcontentsmask = oldsolid;
+ W_SetupShot_Range(self.owner, TRUE, 0, "", damage * dt, myradius);
+ WarpZone_traceline_antilag(self.owner, w_shotorg, w_shotend, MOVE_NORMAL, self.owner, ANTILAG_LATENCY(self.owner));
// apply the damage
if(trace_ent)
{
vector force;
- force = angle * myforce;
- Damage (trace_ent, self.owner, self.owner, damage * frametime, WEP_ELECTRO, trace_endpos, force * frametime);
+ force = w_shotdir * myforce;
+ Damage (trace_ent, self.owner, self.owner, damage * dt, WEP_ELECTRO, trace_endpos, force * dt);
}
// draw effect
- if(org != self.hook_start)
+ if(w_shotorg != self.hook_start)
{
self.SendFlags |= 2;
- self.hook_start = org;
+ self.hook_start = w_shotorg;
}
- if(endpos != self.hook_end)
+ if(w_shotend != self.hook_end)
{
self.SendFlags |= 4;
- self.hook_end = endpos;
+ self.hook_end = w_shotend;
}
}