mousepos = mousepos*0.5 + getmousepos();
*/
- FOREACH_ENTITY(it.draw, LAMBDA(WITH(entity, self, it, it.draw(it))));
+ FOREACH_ENTITY(it.draw, it.draw(it));
addentities(MASK_NORMAL | MASK_ENGINE | MASK_ENGINEVIEWMODELS);
renderscene();
{
this.trail_oldorigin = this.origin;
if (!(this.count & 0x80))
- WITH(entity, self, this, InterpolateOrigin_Reset());
+ InterpolateOrigin_Reset(this);
}
if (f & 0x20)
class(Casing) .int state;
class(Casing) .float cnt;
-void Casing_Delete()
-{SELFPARAM();
+void Casing_Delete(entity this)
+{
remove(self);
}
void Casing_Draw(entity this)
{
- if (self.move_flags & FL_ONGROUND)
+ if (this.move_flags & FL_ONGROUND)
{
- self.move_angles_x = 0;
- self.move_angles_z = 0;
- UNSET_ONGROUND(self);
+ this.move_angles_x = 0;
+ this.move_angles_z = 0;
+ UNSET_ONGROUND(this);
}
- Movetype_Physics_MatchTicrate(self, autocvar_cl_casings_ticrate, autocvar_cl_casings_sloppy);
- if (wasfreed(self))
+ Movetype_Physics_MatchTicrate(this, autocvar_cl_casings_ticrate, autocvar_cl_casings_sloppy);
+ if (wasfreed(this))
return; // deleted by touch function
- self.renderflags = 0;
- self.alpha = bound(0, self.cnt - time, 1);
+ this.renderflags = 0;
+ this.alpha = bound(0, this.cnt - time, 1);
- if (self.alpha < ALPHA_MIN_VISIBLE)
+ if (this.alpha < ALPHA_MIN_VISIBLE)
{
- Casing_Delete();
- self.drawmask = 0;
+ Casing_Delete(this);
+ this.drawmask = 0;
}
}
{SELFPARAM();
if (trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOIMPACT)
{
- Casing_Delete();
+ Casing_Delete(self);
return;
}
.float cnt;
.float gravity;
-void Gib_Delete()
-{SELFPARAM();
- remove(self);
+void Gib_Delete(entity this)
+{
+ remove(this);
}
string species_prefix(int specnum);
void SUB_RemoveOnNoImpact()
{
if(trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOIMPACT)
- Gib_Delete();
+ Gib_Delete(self);
}
void Gib_Touch()
if(trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOIMPACT)
{
- Gib_Delete();
+ Gib_Delete(self);
return;
}
sound(self, CH_PAIN, SND_GIB_SPLAT_RANDOM(), VOL_BASE, ATTEN_NORM);
__pointparticles(_particleeffectnum(strcat(species_prefix(self.cnt), "blood")), self.origin + '0 0 1', '0 0 30', 10);
- Gib_Delete();
+ Gib_Delete(self);
}
void Gib_Draw(entity this)
{
vector oldorg;
- oldorg = self.origin;
+ oldorg = this.origin;
- Movetype_Physics_MatchTicrate(self, autocvar_cl_gibs_ticrate, autocvar_cl_gibs_sloppy);
- if(wasfreed(self))
+ Movetype_Physics_MatchTicrate(this, autocvar_cl_gibs_ticrate, autocvar_cl_gibs_sloppy);
+ if(wasfreed(this))
return;
- if(self.touch == Gib_Touch) // don't do this for the "chunk" thingie...
- // TODO somehow make it spray in a direction dependent on self.angles
- __trailparticles(self, _particleeffectnum(strcat(species_prefix(self.cnt), EFFECT_TR_SLIGHTBLOOD.eent_eff_name)), oldorg, self.origin);
+ if(this.touch == Gib_Touch) // don't do this for the "chunk" thingie...
+ // TODO somehow make it spray in a direction dependent on this.angles
+ __trailparticles(this, _particleeffectnum(strcat(species_prefix(this.cnt), EFFECT_TR_SLIGHTBLOOD.eent_eff_name)), oldorg, this.origin);
else
- __trailparticles(self, _particleeffectnum(strcat(species_prefix(self.cnt), EFFECT_TR_BLOOD.eent_eff_name)), oldorg, self.origin);
+ __trailparticles(this, _particleeffectnum(strcat(species_prefix(this.cnt), EFFECT_TR_BLOOD.eent_eff_name)), oldorg, this.origin);
- self.renderflags = 0;
+ this.renderflags = 0;
// make gibs die faster at low view quality
// if view_quality is 0.5, we want to have them die twice as fast
- self.nextthink -= frametime * (1 / bound(0.01, view_quality, 1.00) - 1);
+ this.nextthink -= frametime * (1 / bound(0.01, view_quality, 1.00) - 1);
- self.alpha = bound(0, self.nextthink - time, 1);
+ this.alpha = bound(0, this.nextthink - time, 1);
- if(self.alpha < ALPHA_MIN_VISIBLE)
+ if(this.alpha < ALPHA_MIN_VISIBLE)
{
- self.drawmask = 0;
- Gib_Delete();
+ this.drawmask = 0;
+ Gib_Delete(this);
}
}
void ModelEffect_Draw(entity this)
{
- self.angles = self.angles + frametime * self.avelocity;
- setorigin(self, self.origin + frametime * self.velocity);
- self.scale = self.scale1 + (self.scale2 - self.scale1) * (time - self.teleport_time) / (self.lifetime + self.fadetime - self.teleport_time);
- self.alpha = self.cnt * bound(0, 1 - (time - self.lifetime) / self.fadetime, 1);
- if(self.alpha < ALPHA_MIN_VISIBLE)
+ this.angles = this.angles + frametime * this.avelocity;
+ setorigin(this, this.origin + frametime * this.velocity);
+ this.scale = this.scale1 + (this.scale2 - this.scale1) * (time - this.teleport_time) / (this.lifetime + this.fadetime - this.teleport_time);
+ this.alpha = this.cnt * bound(0, 1 - (time - this.lifetime) / this.fadetime, 1);
+ if(this.alpha < ALPHA_MIN_VISIBLE)
{
- remove(self);
+ remove(this);
return;
}
- self.drawmask = MASK_NORMAL;
- if(self.scale <= 0)
+ this.drawmask = MASK_NORMAL;
+ if(this.scale <= 0)
{
- self.drawmask = 0;
+ this.drawmask = 0;
return;
}
}
entityclass(Rubble);
class(Rubble).float creationtime;
-void RubbleLimit(string cname, float limit, void() deleteproc)
+void RubbleLimit(string cname, float limit, void(entity) deleteproc)
{
SELFPARAM();
entity e;
if (c <= limit) break;
// delete this oldest one and search again
- WITH(entity, self, oldest, deleteproc());
+ deleteproc(oldest);
}
}
void generator_draw(entity this)
{
- if(time < self.move_time)
+ if(time < this.move_time)
return;
- if(self.health > 0)
+ if(this.health > 0)
{
// damaged fx (less probable the more damaged is the generator)
- if(random() < 0.9 - self.health / self.max_health)
+ if(random() < 0.9 - this.health / this.max_health)
if(random() < 0.01)
{
- pointparticles(EFFECT_ELECTRO_BALLEXPLODE, self.origin + randompos('-50 -50 -20', '50 50 50'), '0 0 0', 1);
- sound(self, CH_TRIGGER, SND_ONS_ELECTRICITY_EXPLODE, VOL_BASE, ATTEN_NORM);
+ pointparticles(EFFECT_ELECTRO_BALLEXPLODE, this.origin + randompos('-50 -50 -20', '50 50 50'), '0 0 0', 1);
+ sound(this, CH_TRIGGER, SND_ONS_ELECTRICITY_EXPLODE, VOL_BASE, ATTEN_NORM);
}
else
- pointparticles(EFFECT_ONS_GENERATOR_DAMAGED, self.origin + randompos('-60 -60 -20', '60 60 60'), '0 0 0', 1);
+ pointparticles(EFFECT_ONS_GENERATOR_DAMAGED, this.origin + randompos('-60 -60 -20', '60 60 60'), '0 0 0', 1);
- self.move_time = time + 0.1;
+ this.move_time = time + 0.1;
return;
}
- if(self.count <= 0)
+ if(this.count <= 0)
return;
vector org;
int i;
// White shockwave
- if(self.count==40||self.count==20)
+ if(this.count==40||this.count==20)
{
- sound(self, CH_TRIGGER, SND_ONS_SHOCKWAVE, VOL_BASE, ATTEN_NORM);
- pointparticles(EFFECT_ELECTRO_COMBO, self.origin, '0 0 0', 6);
+ sound(this, CH_TRIGGER, SND_ONS_SHOCKWAVE, VOL_BASE, ATTEN_NORM);
+ pointparticles(EFFECT_ELECTRO_COMBO, this.origin, '0 0 0', 6);
}
// rays
if(random() > 0.25)
{
- ons_generator_ray_spawn(self.origin);
+ ons_generator_ray_spawn(this.origin);
}
// Spawn fire balls
for(i=0;i < 10;++i)
{
- org = self.origin + randompos('-30 -30 -30' * i + '0 0 -20', '30 30 30' * i + '0 0 20');
+ org = this.origin + randompos('-30 -30 -30' * i + '0 0 -20', '30 30 30' * i + '0 0 20');
pointparticles(EFFECT_ONS_GENERATOR_GIB, org, '0 0 0', 1);
}
// Short explosion sound + small explosion
if(random() < 0.25)
{
- te_explosion(self.origin);
- sound(self, CH_TRIGGER, SND_GRENADE_IMPACT, VOL_BASE, ATTEN_NORM);
+ te_explosion(this.origin);
+ sound(this, CH_TRIGGER, SND_GRENADE_IMPACT, VOL_BASE, ATTEN_NORM);
}
// Particles
- org = self.origin + randompos(self.mins + '8 8 8', self.maxs + '-8 -8 -8');
+ org = this.origin + randompos(this.mins + '8 8 8', this.maxs + '-8 -8 -8');
pointparticles(EFFECT_ONS_GENERATOR_EXPLODE, org, '0 0 0', 1);
// Final explosion
- if(self.count==1)
+ if(this.count==1)
{
- org = self.origin;
+ org = this.origin;
te_explosion(org);
pointparticles(EFFECT_ONS_GENERATOR_EXPLODE2, org, '0 0 0', 1);
- sound(self, CH_TRIGGER, SND_ROCKET_IMPACT, VOL_BASE, ATTEN_NORM);
+ sound(this, CH_TRIGGER, SND_ROCKET_IMPACT, VOL_BASE, ATTEN_NORM);
}
- self.move_time = time + 0.05;
+ this.move_time = time + 0.05;
- self.count -= 1;
+ this.count -= 1;
}
void generator_damage(float hp)
.float ltime;
void healer_draw(entity this)
{
- float dt = time - self.move_time;
- self.move_time = time;
+ float dt = time - this.move_time;
+ this.move_time = time;
if(dt <= 0)
return;
- self.alpha = (self.ltime - time) / self.healer_lifetime;
- self.scale = min((1 - self.alpha)*self.healer_lifetime*4,1)*self.healer_radius;
+ this.alpha = (this.ltime - time) / this.healer_lifetime;
+ this.scale = min((1 - this.alpha)*this.healer_lifetime*4,1)*this.healer_radius;
}
void healer_setup(entity e)
#elif defined(CSQC)
void Draw_Rain(entity this)
{
- te_particlerain(self.origin + self.mins, self.origin + self.maxs, self.velocity, floor(self.count * drawframetime + random()), self.glow_color);
+ te_particlerain(this.origin + this.mins, this.origin + this.maxs, this.velocity, floor(this.count * drawframetime + random()), this.glow_color);
}
void Draw_Snow(entity this)
{
- te_particlesnow(self.origin + self.mins, self.origin + self.maxs, self.velocity, floor(self.count * drawframetime + random()), self.glow_color);
+ te_particlesnow(this.origin + this.mins, this.origin + this.maxs, this.velocity, floor(this.count * drawframetime + random()), this.glow_color);
}
NET_HANDLE(ENT_CLIENT_RAINSNOW, bool isnew)
void Draw_Laser(entity this)
{
- if(!self.state)
+ if(!this.state)
return;
- InterpolateOrigin_Do(self);
- if(self.count & 0x80)
+ InterpolateOrigin_Do(this);
+ if(this.count & 0x80)
{
- if(self.count & 0x10)
+ if(this.count & 0x10)
{
- trace_endpos = self.velocity;
+ trace_endpos = this.velocity;
trace_dphitq3surfaceflags = 0;
}
else
- traceline(self.origin, self.velocity, 0, self);
+ traceline(this.origin, this.velocity, 0, this);
}
else
{
- if(self.count & 0x10)
+ if(this.count & 0x10)
{
- makevectors(self.angles);
- trace_endpos = self.origin + v_forward * 1048576;
+ makevectors(this.angles);
+ trace_endpos = this.origin + v_forward * 1048576;
trace_dphitq3surfaceflags = Q3SURFACEFLAG_SKY;
}
else
{
- makevectors(self.angles);
- traceline(self.origin, self.origin + v_forward * 32768, 0, self);
+ makevectors(this.angles);
+ traceline(this.origin, this.origin + v_forward * 32768, 0, this);
if(trace_dphitq3surfaceflags & Q3SURFACEFLAG_SKY)
- trace_endpos = self.origin + v_forward * 1048576;
+ trace_endpos = this.origin + v_forward * 1048576;
}
}
- if(self.scale != 0)
+ if(this.scale != 0)
{
- if(self.alpha)
+ if(this.alpha)
{
- Draw_CylindricLine(self.origin, trace_endpos, self.scale, "particles/laserbeam", 0, time * 3, self.colormod, self.alpha, DRAWFLAG_NORMAL, view_origin);
+ Draw_CylindricLine(this.origin, trace_endpos, this.scale, "particles/laserbeam", 0, time * 3, this.colormod, this.alpha, DRAWFLAG_NORMAL, view_origin);
}
else
{
- Draw_CylindricLine(self.origin, trace_endpos, self.scale, "particles/laserbeam", 0, time * 3, self.colormod, 0.5, DRAWFLAG_ADDITIVE, view_origin);
+ Draw_CylindricLine(this.origin, trace_endpos, this.scale, "particles/laserbeam", 0, time * 3, this.colormod, 0.5, DRAWFLAG_ADDITIVE, view_origin);
}
}
if (!(trace_dphitq3surfaceflags & (Q3SURFACEFLAG_SKY | Q3SURFACEFLAG_NOIMPACT)))
{
- if(self.cnt >= 0)
- __pointparticles(self.cnt, trace_endpos, trace_plane_normal, drawframetime * 1000);
- if(self.colormod != '0 0 0' && self.modelscale != 0)
- adddynamiclight(trace_endpos + trace_plane_normal * 1, self.modelscale, self.colormod * 5);
+ if(this.cnt >= 0)
+ __pointparticles(this.cnt, trace_endpos, trace_plane_normal, drawframetime * 1000);
+ if(this.colormod != '0 0 0' && this.modelscale != 0)
+ adddynamiclight(trace_endpos + trace_plane_normal * 1, this.modelscale, this.colormod * 5);
}
}
}
#ifdef CSQC
-void trigger_touch_generic(void() touchfunc)
-{SELFPARAM();
+void trigger_touch_generic(entity this, void() touchfunc)
+{
entity e;
- for(e = findradius((self.absmin + self.absmax) * 0.5, vlen(self.absmax - self.absmin) * 0.5 + 1); e; e = e.chain)
+ for(e = findradius((this.absmin + this.absmax) * 0.5, vlen(this.absmax - this.absmin) * 0.5 + 1); e; e = e.chain)
if(e.isplayermodel || e.classname == "csqcprojectile")
{
vector emin = e.absmin, emax = e.absmax;
- if(self.solid == SOLID_BSP)
+ if(this.solid == SOLID_BSP)
{
emin -= '1 1 1';
emax += '1 1 1';
}
- if(boxesoverlap(emin, emax, self.absmin, self.absmax)) // quick
- if(WarpZoneLib_BoxTouchesBrush(emin, emax, self, e)) // accurate
+ if(boxesoverlap(emin, emax, this.absmin, this.absmax)) // quick
+ if(WarpZoneLib_BoxTouchesBrush(emin, emax, this, e)) // accurate
{
other = e;
- touchfunc();
+ WITH(entity, self, this, touchfunc());
}
}
}
void trigger_draw_generic(entity this)
{
- float dt = time - self.move_time;
- self.move_time = time;
+ float dt = time - this.move_time;
+ this.move_time = time;
if(dt <= 0) { return; }
- if(self.trigger_touch) { trigger_touch_generic(self.trigger_touch); }
+ if(this.trigger_touch) { trigger_touch_generic(this, this.trigger_touch); }
}
#endif
{
float dt;
- dt = time - self.move_time;
- self.move_time = time;
+ dt = time - this.move_time;
+ this.move_time = time;
if(dt <= 0)
return;
- self.tur_head.angles += dt * self.tur_head.move_avelocity;
+ this.tur_head.angles += dt * this.tur_head.move_avelocity;
- if (self.health < 127)
+ if (this.health < 127)
{
dt = random();
if(dt < 0.03)
- te_spark(self.origin + '0 0 40', randomvec() * 256 + '0 0 256', 16);
+ te_spark(this.origin + '0 0 40', randomvec() * 256 + '0 0 256', 16);
}
- if(self.health < 85)
+ if(this.health < 85)
if(dt < 0.01)
- pointparticles(EFFECT_SMOKE_LARGE, (self.origin + (randomvec() * 80)), '0 0 0', 1);
+ pointparticles(EFFECT_SMOKE_LARGE, (this.origin + (randomvec() * 80)), '0 0 0', 1);
- if(self.health < 32)
+ if(this.health < 32)
if(dt < 0.015)
- pointparticles(EFFECT_SMOKE_SMALL, (self.origin + (randomvec() * 80)), '0 0 0', 1);
+ pointparticles(EFFECT_SMOKE_SMALL, (this.origin + (randomvec() * 80)), '0 0 0', 1);
}
}
entity turret_gibtoss(string _model, vector _from, vector _to, vector _cmod, float _explode);
-void turret_gibboom();
+void turret_gibboom(entity this);
void turret_gib_draw(entity this)
{
- Movetype_Physics_MatchTicrate(self, autocvar_cl_gibs_ticrate, autocvar_cl_gibs_sloppy);
+ Movetype_Physics_MatchTicrate(this, autocvar_cl_gibs_ticrate, autocvar_cl_gibs_sloppy);
- self.drawmask = MASK_NORMAL;
+ this.drawmask = MASK_NORMAL;
- if(self.cnt)
+ if(this.cnt)
{
- if(time >= self.nextthink)
+ if(time >= this.nextthink)
{
- turret_gibboom();
- remove(self);
+ turret_gibboom(this);
+ remove(this);
}
}
else
{
- self.alpha = bound(0, self.nextthink - time, 1);
- if(self.alpha < ALPHA_MIN_VISIBLE)
- remove(self);
+ this.alpha = bound(0, this.nextthink - time, 1);
+ if(this.alpha < ALPHA_MIN_VISIBLE)
+ remove(this);
}
}
-void turret_gibboom()
-{SELFPARAM();
- float i;
-
- sound (self, CH_SHOTS, SND_ROCKET_IMPACT, VOL_BASE, ATTEN_NORM);
- pointparticles(EFFECT_ROCKET_EXPLODE, self.origin, '0 0 0', 1);
+void turret_gibboom(entity this)
+{
+ sound (this, CH_SHOTS, SND_ROCKET_IMPACT, VOL_BASE, ATTEN_NORM);
+ pointparticles(EFFECT_ROCKET_EXPLODE, this.origin, '0 0 0', 1);
- for (i = 1; i < 5; i = i + 1)
- turret_gibtoss(strcat("models/turrets/head-gib", ftos(i), ".md3"), self.origin + '0 0 2', self.velocity + randomvec() * 700, '0 0 0', false);
+ for (int j = 1; j < 5; j = j + 1)
+ turret_gibtoss(strcat("models/turrets/head-gib", ftos(j), ".md3"), this.origin + '0 0 2', this.velocity + randomvec() * 700, '0 0 0', false);
}
entity turret_gibtoss(string _model, vector _from, vector _to, vector _cmod, float _explode)
{
float dt;
- dt = time - self.move_time;
- self.move_time = time;
+ dt = time - this.move_time;
+ this.move_time = time;
if(dt <= 0)
return;
- fixedmakevectors(self.angles);
- setorigin(self, self.origin + self.velocity * dt);
- self.tur_head.angles += dt * self.tur_head.move_avelocity;
- self.angles_y = self.move_angles_y;
+ fixedmakevectors(this.angles);
+ setorigin(this, this.origin + this.velocity * dt);
+ this.tur_head.angles += dt * this.tur_head.move_avelocity;
+ this.angles_y = this.move_angles_y;
- if (self.health < 127)
+ if (this.health < 127)
if(random() < 0.05)
- te_spark(self.origin + '0 0 40', randomvec() * 256 + '0 0 256', 16);
+ te_spark(this.origin + '0 0 40', randomvec() * 256 + '0 0 256', 16);
}
METHOD(EWheel, tr_setup, void(EWheel this, entity it))
{
float dt;
- dt = time - self.move_time;
- self.move_time = time;
+ dt = time - this.move_time;
+ this.move_time = time;
if(dt <= 0)
return;
- fixedmakevectors(self.angles);
+ fixedmakevectors(this.angles);
movelib_groundalign4point(300, 100, 0.25, 45);
- setorigin(self, self.origin + self.velocity * dt);
- self.tur_head.angles += dt * self.tur_head.move_avelocity;
- self.angles_y = self.move_angles_y;
+ setorigin(this, this.origin + this.velocity * dt);
+ this.tur_head.angles += dt * this.tur_head.move_avelocity;
+ this.angles_y = this.move_angles_y;
- if (self.health < 127)
+ if (this.health < 127)
if(random() < 0.15)
- te_spark(self.origin + '0 0 40', randomvec() * 256 + '0 0 256', 16);
+ te_spark(this.origin + '0 0 40', randomvec() * 256 + '0 0 256', 16);
}
METHOD(WalkerTurret, tr_setup, void(WalkerTurret this, entity it))
vector _dir;
vector _vtmp1, _vtmp2;
- _len = vlen(self.origin - self.move_origin);
- _dir = normalize(self.move_origin - self.origin);
+ _len = vlen(this.origin - this.move_origin);
+ _dir = normalize(this.move_origin - this.origin);
- if(self.bumble_raygun_nextdraw < time)
+ if(this.bumble_raygun_nextdraw < time)
{
- boxparticles(particleeffectnum(Effects_from(self.traileffect)), self, self.origin, self.origin + _dir * -64, _dir * -_len , _dir * -_len, 1, PARTICLES_USEALPHA);
- boxparticles(self.lip, self, self.move_origin, self.move_origin + _dir * -64, _dir * -200 , _dir * -200, 1, PARTICLES_USEALPHA);
- self.bumble_raygun_nextdraw = time + 0.1;
+ boxparticles(particleeffectnum(Effects_from(this.traileffect)), this, this.origin, this.origin + _dir * -64, _dir * -_len , _dir * -_len, 1, PARTICLES_USEALPHA);
+ boxparticles(this.lip, this, this.move_origin, this.move_origin + _dir * -64, _dir * -200 , _dir * -200, 1, PARTICLES_USEALPHA);
+ this.bumble_raygun_nextdraw = time + 0.1;
}
float i, df, sz, al;
df = DRAWFLAG_NORMAL; //((random() < 0.5) ? DRAWFLAG_ADDITIVE : DRAWFLAG_SCREEN);
sz = 5 + random() * 5;
al = 0.25 + random() * 0.5;
- _vtmp1 = self.origin + _dir * _len * (0.25 + i);
- _vtmp1 += (randomvec() * (_len * 0.2) * (frametime * 2)); //self.raygun_l1;
- Draw_CylindricLine(self.origin, _vtmp1, sz, "gfx/colors/white.tga", 1, 1, self.colormod, al, df, view_origin);
+ _vtmp1 = this.origin + _dir * _len * (0.25 + i);
+ _vtmp1 += (randomvec() * (_len * 0.2) * (frametime * 2)); //this.raygun_l1;
+ Draw_CylindricLine(this.origin, _vtmp1, sz, "gfx/colors/white.tga", 1, 1, this.colormod, al, df, view_origin);
- _vtmp2 = self.origin + _dir * _len * (0.5 + i);
- _vtmp2 += (randomvec() * (_len * 0.2) * (frametime * 5)); //self.raygun_l2;
- Draw_CylindricLine(_vtmp1, _vtmp2, sz, "gfx/colors/white.tga", 1, 1, self.colormod, al, df, view_origin);
+ _vtmp2 = this.origin + _dir * _len * (0.5 + i);
+ _vtmp2 += (randomvec() * (_len * 0.2) * (frametime * 5)); //this.raygun_l2;
+ Draw_CylindricLine(_vtmp1, _vtmp2, sz, "gfx/colors/white.tga", 1, 1, this.colormod, al, df, view_origin);
- _vtmp1 = self.origin + _dir * _len * (0.75 + i);
- _vtmp1 += randomvec() * (_len * 0.2) * (frametime * 10); //self.raygun_l3;
- Draw_CylindricLine(_vtmp2, _vtmp1, sz, "gfx/colors/white.tga", 1, 1, self.colormod, al, df, view_origin);
+ _vtmp1 = this.origin + _dir * _len * (0.75 + i);
+ _vtmp1 += randomvec() * (_len * 0.2) * (frametime * 10); //this.raygun_l3;
+ Draw_CylindricLine(_vtmp2, _vtmp1, sz, "gfx/colors/white.tga", 1, 1, this.colormod, al, df, view_origin);
- Draw_CylindricLine(_vtmp1, self.move_origin + randomvec() * 32, sz, "gfx/colors/white.tga", 1, 1, self.colormod, al, df, view_origin);
+ Draw_CylindricLine(_vtmp1, this.move_origin + randomvec() * 32, sz, "gfx/colors/white.tga", 1, 1, this.colormod, al, df, view_origin);
}
}
void RaptorCBShellfragDraw(entity this)
{
- if(wasfreed(self))
+ if(wasfreed(this))
return;
- Movetype_Physics_MatchTicrate(self, autocvar_cl_gibs_ticrate, autocvar_cl_gibs_sloppy);
- self.move_avelocity += randomvec() * 15;
- self.renderflags = 0;
+ Movetype_Physics_MatchTicrate(this, autocvar_cl_gibs_ticrate, autocvar_cl_gibs_sloppy);
+ this.move_avelocity += randomvec() * 15;
+ this.renderflags = 0;
- if(self.cnt < time)
- self.alpha = bound(0, self.nextthink - time, 1);
+ if(this.cnt < time)
+ this.alpha = bound(0, this.nextthink - time, 1);
- if(self.alpha < ALPHA_MIN_VISIBLE)
- remove(self);
+ if(this.alpha < ALPHA_MIN_VISIBLE)
+ remove(this);
}
void RaptorCBShellfragToss(vector _org, vector _vel, vector _ang)
void Draw_ArcBeam(entity this)
{
- float dt = time - self.move_time;
- self.move_time = time;
+ float dt = time - this.move_time;
+ this.move_time = time;
if(dt <= 0) { return; }
- if(!self.beam_usevieworigin)
+ if(!this.beam_usevieworigin)
{
- InterpolateOrigin_Do(self);
+ InterpolateOrigin_Do(this);
}
// origin = beam starting origin
vector start_pos;
vector wantdir; //= view_forward;
- vector beamdir; //= self.beam_dir;
+ vector beamdir; //= this.beam_dir;
float segments;
- if(self.beam_usevieworigin)
+ if(this.beam_usevieworigin)
{
// WEAPONTODO:
// Currently we have to replicate nearly the same method of figuring
vector up = v_up;
// decide upon start position
- if(self.beam_usevieworigin == 2)
+ if(this.beam_usevieworigin == 2)
{ start_pos = warpzone_save_view_origin; }
else
- { start_pos = self.origin; }
+ { start_pos = this.origin; }
// trace forward with an estimation
WarpZone_TraceLine(
start_pos,
- start_pos + forward * self.beam_range,
+ start_pos + forward * this.beam_range,
MOVE_NOMONSTERS,
- self
+ this
);
// untransform in case our trace went through a warpzone
// move shot origin to the actual gun muzzle origin
vector origin_offset =
- right * -self.beam_shotorigin.y
- + up * self.beam_shotorigin.z;
+ right * -this.beam_shotorigin.y
+ + up * this.beam_shotorigin.z;
start_pos = start_pos + origin_offset;
// Move it also forward, but only as far as possible without hitting anything. Don't poke into walls!
- traceline(start_pos, start_pos + forward * self.beam_shotorigin.x, MOVE_NORMAL, self);
+ traceline(start_pos, start_pos + forward * this.beam_shotorigin.x, MOVE_NORMAL, this);
start_pos = trace_endpos;
// calculate the aim direction now
wantdir = normalize(end_pos - start_pos);
- if(!self.beam_initialized)
+ if(!this.beam_initialized)
{
- self.beam_dir = wantdir;
- self.beam_initialized = true;
+ this.beam_dir = wantdir;
+ this.beam_initialized = true;
}
- if(self.beam_dir != wantdir)
+ if(this.beam_dir != wantdir)
{
// calculate how much we're going to move the end of the beam to the want position
// WEAPONTODO (server and client):
// blendfactor never actually becomes 0 in this situation, which is a problem
- // regarding precision... this means that self.beam_dir and w_shotdir approach
+ // regarding precision... this means that this.beam_dir and w_shotdir approach
// eachother, however they never actually become the same value with this method.
// Perhaps we should do some form of rounding/snapping?
- float angle = vlen(wantdir - self.beam_dir) * RAD2DEG;
- if(angle && (angle > self.beam_maxangle))
+ float angle = vlen(wantdir - this.beam_dir) * RAD2DEG;
+ if(angle && (angle > this.beam_maxangle))
{
// if the angle is greater than maxangle, force the blendfactor to make this the maximum factor
float blendfactor = bound(
0,
- (1 - (self.beam_returnspeed * frametime)),
- min(self.beam_maxangle / angle, 1)
+ (1 - (this.beam_returnspeed * frametime)),
+ min(this.beam_maxangle / angle, 1)
);
- self.beam_dir = normalize((wantdir * (1 - blendfactor)) + (self.beam_dir * blendfactor));
+ this.beam_dir = normalize((wantdir * (1 - blendfactor)) + (this.beam_dir * blendfactor));
}
else
{
// the radius is not too far yet, no worries :D
float blendfactor = bound(
0,
- (1 - (self.beam_returnspeed * frametime)),
+ (1 - (this.beam_returnspeed * frametime)),
1
);
- self.beam_dir = normalize((wantdir * (1 - blendfactor)) + (self.beam_dir * blendfactor));
+ this.beam_dir = normalize((wantdir * (1 - blendfactor)) + (this.beam_dir * blendfactor));
}
// calculate how many segments are needed
float max_allowed_segments;
- if(self.beam_distancepersegment)
+ if(this.beam_distancepersegment)
{
max_allowed_segments = min(
ARC_MAX_SEGMENTS,
- 1 + (vlen(wantdir / self.beam_distancepersegment))
+ 1 + (vlen(wantdir / this.beam_distancepersegment))
);
}
else { max_allowed_segments = ARC_MAX_SEGMENTS; }
- if(self.beam_degreespersegment)
+ if(this.beam_degreespersegment)
{
segments = bound(
1,
(
min(
angle,
- self.beam_maxangle
+ this.beam_maxangle
)
/
- self.beam_degreespersegment
+ this.beam_degreespersegment
),
max_allowed_segments
);
else { segments = 1; }
// set the beam direction which the rest of the code will refer to
- beamdir = self.beam_dir;
+ beamdir = this.beam_dir;
- // finally, set self.angles to the proper direction so that muzzle attachment points in proper direction
- self.angles = fixedvectoangles2(forward, up); // TODO(Samual): is this == warpzone_save_view_angles?
+ // finally, set this.angles to the proper direction so that muzzle attachment points in proper direction
+ this.angles = fixedvectoangles2(forward, up); // TODO(Samual): is this == warpzone_save_view_angles?
}
else
{
// set the values from the provided info from the networked entity
- start_pos = self.origin;
- wantdir = self.v_angle;
- beamdir = self.angles;
+ start_pos = this.origin;
+ wantdir = this.v_angle;
+ beamdir = this.angles;
if(beamdir != wantdir)
{
// calculate how many segments are needed
float max_allowed_segments;
- if(self.beam_distancepersegment)
+ if(this.beam_distancepersegment)
{
max_allowed_segments = min(
ARC_MAX_SEGMENTS,
- 1 + (vlen(wantdir / self.beam_distancepersegment))
+ 1 + (vlen(wantdir / this.beam_distancepersegment))
);
}
else { max_allowed_segments = ARC_MAX_SEGMENTS; }
- if(self.beam_degreespersegment)
+ if(this.beam_degreespersegment)
{
segments = bound(
1,
(
min(
angle,
- self.beam_maxangle
+ this.beam_maxangle
)
/
- self.beam_degreespersegment
+ this.beam_degreespersegment
),
max_allowed_segments
);
else { segments = 1; }
}
- setorigin(self, start_pos);
- self.beam_muzzleentity.angles_z = random() * 360; // WEAPONTODO: use avelocity instead?
+ setorigin(this, start_pos);
+ this.beam_muzzleentity.angles_z = random() * 360; // WEAPONTODO: use avelocity instead?
- vector beam_endpos = (start_pos + (beamdir * self.beam_range));
- vector beam_controlpoint = start_pos + wantdir * (self.beam_range * (1 - self.beam_tightness));
+ vector beam_endpos = (start_pos + (beamdir * this.beam_range));
+ vector beam_controlpoint = start_pos + wantdir * (this.beam_range * (1 - this.beam_tightness));
- Draw_ArcBeam_callback_entity = self;
+ Draw_ArcBeam_callback_entity = this;
Draw_ArcBeam_callback_last_thickness = 0;
Draw_ArcBeam_callback_last_top = start_pos;
Draw_ArcBeam_callback_last_bottom = start_pos;
}
// visual effects for startpoint and endpoint
- if(self.beam_hiteffect)
+ if(this.beam_hiteffect)
{
// FIXME we really should do this on the server so it actually
// matches gameplay. What this client side stuff is doing is no
// more than guesswork.
if((trace_ent || trace_fraction < 1) && !(trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOIMPACT))
pointparticles(
- self.beam_hiteffect,
+ this.beam_hiteffect,
last_origin,
beamdir * -1,
frametime * 2
);
}
- if(self.beam_hitlight[0])
+ if(this.beam_hitlight[0])
{
adddynamiclight(
last_origin,
- self.beam_hitlight[0],
+ this.beam_hitlight[0],
vec3(
- self.beam_hitlight[1],
- self.beam_hitlight[2],
- self.beam_hitlight[3]
+ this.beam_hitlight[1],
+ this.beam_hitlight[2],
+ this.beam_hitlight[3]
)
);
}
- if(self.beam_muzzleeffect)
+ if(this.beam_muzzleeffect)
{
pointparticles(
- self.beam_muzzleeffect,
+ this.beam_muzzleeffect,
original_start_pos + wantdir * 20,
wantdir * 1000,
frametime * 0.1
);
}
- if(self.beam_muzzlelight[0])
+ if(this.beam_muzzlelight[0])
{
adddynamiclight(
original_start_pos + wantdir * 20,
- self.beam_muzzlelight[0],
+ this.beam_muzzlelight[0],
vec3(
- self.beam_muzzlelight[1],
- self.beam_muzzlelight[2],
- self.beam_muzzlelight[3]
+ this.beam_muzzlelight[1],
+ this.beam_muzzlelight[2],
+ this.beam_muzzlelight[3]
)
);
}
vector vs;
float intensity, offset;
- if(self.teleport_time)
- if(time > self.teleport_time)
+ if(this.teleport_time)
+ if(time > this.teleport_time)
{
- sound (self, CH_SHOTS_SINGLE, SND_Null, VOL_BASE, ATTEN_NORM); // safeguard
- self.teleport_time = 0;
+ sound (this, CH_SHOTS_SINGLE, SND_Null, VOL_BASE, ATTEN_NORM); // safeguard
+ this.teleport_time = 0;
}
InterpolateOrigin_Do(this);
int s = W_GetGunAlignment(world);
- switch(self.HookType)
+ switch(this.HookType)
{
default:
case NET_ENT_CLIENT_HOOK:
break;
}
- if((self.owner.sv_entnum == player_localentnum - 1) && autocvar_chase_active <= 0)
+ if((this.owner.sv_entnum == player_localentnum - 1) && autocvar_chase_active <= 0)
{
- switch(self.HookType)
+ switch(this.HookType)
{
default:
case NET_ENT_CLIENT_HOOK:
a = view_origin + view_forward * vs.x + view_right * -vs.y + view_up * vs.z;
- b = self.origin;
+ b = this.origin;
break;
case NET_ENT_CLIENT_ARC_BEAM:
- if(self.HookRange)
- b = view_origin + view_forward * self.HookRange;
+ if(this.HookRange)
+ b = view_origin + view_forward * this.HookRange;
else
- b = view_origin + view_forward * vlen(self.velocity - self.origin); // honor original length of beam!
+ b = view_origin + view_forward * vlen(this.velocity - this.origin); // honor original length of beam!
WarpZone_TraceLine(view_origin, b, MOVE_NORMAL, world);
b = WarpZone_UnTransformOrigin(WarpZone_trace_transform, trace_endpos);
a = view_origin + view_forward * vs.x + view_right * -vs.y + view_up * vs.z;
}
else
{
- switch(self.HookType)
+ switch(this.HookType)
{
default:
case NET_ENT_CLIENT_HOOK:
- a = self.velocity;
- b = self.origin;
+ a = this.velocity;
+ b = this.origin;
break;
case NET_ENT_CLIENT_ARC_BEAM:
- a = self.origin;
- b = self.velocity;
+ a = this.origin;
+ b = this.velocity;
break;
}
}
- t = entcs_GetTeamColor(self.owner.sv_entnum);
+ t = entcs_GetTeamColor(this.owner.sv_entnum);
- switch(self.HookType)
+ switch(this.HookType)
{
default:
case NET_ENT_CLIENT_HOOK:
case NUM_TEAM_2: tex = "particles/hook_blue"; rgb = '0.3 0.3 1'; break;
case NUM_TEAM_3: tex = "particles/hook_yellow"; rgb = '1 1 0.3'; break;
case NUM_TEAM_4: tex = "particles/hook_pink"; rgb = '1 0.3 1'; break;
- default: tex = "particles/hook_white"; rgb = entcs_GetColor(self.sv_entnum - 1); break;
+ default: tex = "particles/hook_white"; rgb = entcs_GetColor(this.sv_entnum - 1); break;
}
break;
case NET_ENT_CLIENT_ARC_BEAM: // todo
- intensity = bound(0.2, 1 + Noise_Pink(self, frametime) * 1 + Noise_Burst(self, frametime, 0.03) * 0.3, 2);
- offset = Noise_Brown(self, frametime) * 10;
+ intensity = bound(0.2, 1 + Noise_Pink(this, frametime) * 1 + Noise_Burst(this, frametime, 0.03) * 0.3, 2);
+ offset = Noise_Brown(this, frametime) * 10;
tex = "particles/lgbeam";
rgb = '1 1 1';
break;
Draw_GrapplingHook_trace_callback_rnd = offset;
Draw_GrapplingHook_trace_callback_rgb = rgb;
Draw_GrapplingHook_trace_callback_a = intensity;
- WarpZone_TraceBox_ThroughZone(a, '0 0 0', '0 0 0', b, ((self.HookType == NET_ENT_CLIENT_HOOK) ? MOVE_NOTHING : MOVE_NORMAL), world, world, Draw_GrapplingHook_trace_callback);
+ WarpZone_TraceBox_ThroughZone(a, '0 0 0', '0 0 0', b, ((this.HookType == NET_ENT_CLIENT_HOOK) ? MOVE_NOTHING : MOVE_NORMAL), world, world, Draw_GrapplingHook_trace_callback);
Draw_GrapplingHook_trace_callback_tex = string_null;
atrans = WarpZone_TransformOrigin(WarpZone_trace_transform, a);
- switch(self.HookType)
+ switch(this.HookType)
{
default:
case NET_ENT_CLIENT_HOOK:
if(vlen(trace_endpos - atrans) > 0.5)
{
- setorigin(self, trace_endpos); // hook endpoint!
- self.angles = vectoangles(trace_endpos - atrans);
- self.drawmask = MASK_NORMAL;
+ setorigin(this, trace_endpos); // hook endpoint!
+ this.angles = vectoangles(trace_endpos - atrans);
+ this.drawmask = MASK_NORMAL;
}
else
{
- self.drawmask = 0;
+ this.drawmask = 0;
}
break;
case NET_ENT_CLIENT_ARC_BEAM:
- setorigin(self, a); // beam origin!
+ setorigin(this, a); // beam origin!
break;
}
- switch(self.HookType)
+ switch(this.HookType)
{
default:
case NET_ENT_CLIENT_HOOK:
void Draw_Shockwave(entity this)
{
// fading/removal control
- float a = bound(0, (SW_MAXALPHA - ((time - self.sw_time) / SW_FADETIME)), SW_MAXALPHA);
- if(a < ALPHA_MIN_VISIBLE) { remove(self); }
+ float a = bound(0, (SW_MAXALPHA - ((time - this.sw_time) / SW_FADETIME)), SW_MAXALPHA);
+ if(a < ALPHA_MIN_VISIBLE) { remove(this); }
// WEAPONTODO: save this only once when creating the entity
- vector sw_color = entcs_GetColor(self.sv_entnum - 1); // GetTeamRGB(entcs_GetTeam(self.sv_entnum));
+ vector sw_color = entcs_GetColor(this.sv_entnum - 1); // GetTeamRGB(entcs_GetTeam(this.sv_entnum));
// WEAPONTODO: trace to find what we actually hit
- vector endpos = (self.sw_shotorg + (self.sw_shotdir * self.sw_distance));
+ vector endpos = (this.sw_shotorg + (this.sw_shotdir * this.sw_distance));
- vectorvectors(self.sw_shotdir);
+ vectorvectors(this.sw_shotdir);
vector right = v_right; // save this for when we do makevectors later
vector up = v_up; // save this for when we do makevectors later
// WEAPONTODO: combine and simplify these calculations
- vector min_end = ((self.sw_shotorg + (self.sw_shotdir * SW_DISTTOMIN)) + (up * self.sw_spread_min));
- vector max_end = (endpos + (up * self.sw_spread_max));
- float spread_to_min = vlen(normalize(min_end - self.sw_shotorg) - self.sw_shotdir);
- float spread_to_max = vlen(normalize(max_end - min_end) - self.sw_shotdir);
+ vector min_end = ((this.sw_shotorg + (this.sw_shotdir * SW_DISTTOMIN)) + (up * this.sw_spread_min));
+ vector max_end = (endpos + (up * this.sw_spread_max));
+ float spread_to_min = vlen(normalize(min_end - this.sw_shotorg) - this.sw_shotdir);
+ float spread_to_max = vlen(normalize(max_end - min_end) - this.sw_shotdir);
vector first_min_end = '0 0 0', prev_min_end = '0 0 0', new_min_end = '0 0 0';
vector first_max_end = '0 0 0', prev_max_end = '0 0 0', new_max_end = '0 0 0';
// first do the spread_to_min effect
deviation = angle * spread_to_min;
- deviation = ((self.sw_shotdir + (right * deviation.y) + (up * deviation.z)));
+ deviation = ((this.sw_shotdir + (right * deviation.y) + (up * deviation.z)));
new_min_dist = SW_DISTTOMIN;
- new_min_end = (self.sw_shotorg + (deviation * new_min_dist));
- //te_lightning2(world, new_min_end, self.sw_shotorg);
+ new_min_end = (this.sw_shotorg + (deviation * new_min_dist));
+ //te_lightning2(world, new_min_end, this.sw_shotorg);
// then calculate spread_to_max effect
deviation = angle * spread_to_max;
- deviation = ((self.sw_shotdir + (right * deviation.y) + (up * deviation.z)));
+ deviation = ((this.sw_shotdir + (right * deviation.y) + (up * deviation.z)));
new_max_dist = vlen(new_min_end - endpos);
new_max_end = (new_min_end + (deviation * new_max_dist));
//te_lightning2(world, new_end, prev_min_end);
R_BeginPolygon("", DRAWFLAG_NORMAL);
R_PolygonVertex(prev_min_end, '0 0 0', sw_color, a);
R_PolygonVertex(new_min_end, '0 0 0', sw_color, a);
- R_PolygonVertex(self.sw_shotorg, '0 0 0', sw_color, a);
+ R_PolygonVertex(this.sw_shotorg, '0 0 0', sw_color, a);
R_EndPolygon();
// draw from min spread radius to max spread radius
R_BeginPolygon("", DRAWFLAG_NORMAL);
R_PolygonVertex(prev_min_end, '0 0 0', sw_color, a);
R_PolygonVertex(first_min_end, '0 0 0', sw_color, a);
- R_PolygonVertex(self.sw_shotorg, '0 0 0', sw_color, a);
+ R_PolygonVertex(this.sw_shotorg, '0 0 0', sw_color, a);
R_EndPolygon();
// draw from min spread radius to max spread radius
// rgb = e.glowmod;
rgb *= (1 + autocvar_cl_vaporizerbeam_colorboost);
- float fail = (self.nextthink - time);
+ float fail = (this.nextthink - time);
Draw_VaporizerBeam_trace_callback_tex = tex;
Draw_VaporizerBeam_trace_callback_rnd = 0;
.vector ivforward1, ivforward2;
.vector ivup1, ivup2;
.float itime1, itime2;
-void InterpolateOrigin_Reset()
+void InterpolateOrigin_Reset(entity this)
{
- SELFPARAM();
- self.iflags &= ~IFLAG_INTERNALMASK;
- self.itime1 = self.itime2 = 0;
+ this.iflags &= ~IFLAG_INTERNALMASK;
+ this.itime1 = this.itime2 = 0;
}
void InterpolateOrigin_Note(entity this)
{
void InterpolateOrigin_Note(entity this);
// call this when the entity got teleported, before InterpolateOrigin_Note
-void InterpolateOrigin_Reset();
+void InterpolateOrigin_Reset(entity this);
// call this BEFORE drawing
void InterpolateOrigin_Do(entity this);