bool autocvar_g_vehicle_racer = true;
+float autocvar_g_vehicle_racer_thinkrate = 0.05; // TODO: any higher causes it to sink in liquids
+
float autocvar_g_vehicle_racer_speed_afterburn = 3000;
// energy consumed per second
float autocvar_g_vehicle_racer_afterburn_cost = 100;
vehicles_frame(vehic, this);
- if(pointcontents(vehic.origin) != CONTENT_WATER)
+ traceline(vehic.origin, vehic.origin + '0 0 1', MOVE_NOMONSTERS, this);
+ int cont = trace_dpstartcontents;
+ if(cont & DPCONTENTS_WATER)
vehic.air_finished = time + autocvar_g_vehicle_racer_water_time;
if(IS_DEAD(vehic))
PHYS_INPUT_BUTTON_ZOOM(this) = PHYS_INPUT_BUTTON_CROUCH(this) = false;
- crosshair_trace(this);
+ if(time >= vehic.vehicle_last_trace)
+ {
+ crosshair_trace(this);
+ vehic.vehicle_last_trace = time + autocvar_g_vehicle_racer_thinkrate;
+ }
vehic.angles_x *= -1;
vector df = vehic.velocity * -autocvar_g_vehicle_racer_friction;
//vehic.velocity_z = ftmp;
- int cont = pointcontents(vehic.origin);
if(this.movement)
{
- if(cont == CONTENT_WATER || cont == CONTENT_LAVA || cont == CONTENT_SLIME)
+ if(cont & DPCONTENTS_LIQUIDSMASK)
{
if(this.movement_x) { df += v_forward * ((this.movement_x > 0) ? autocvar_g_vehicle_racer_water_speed_forward : -autocvar_g_vehicle_racer_water_speed_forward); }
if(this.movement_y) { df += v_right * ((this.movement_y > 0) ? autocvar_g_vehicle_racer_water_speed_strafe : -autocvar_g_vehicle_racer_water_speed_strafe); }
vehic.wait = time;
- if(cont == CONTENT_WATER || cont == CONTENT_LAVA || cont == CONTENT_SLIME)
+ if(cont & DPCONTENTS_LIQUIDSMASK)
{
vehic.vehicle_energy -= autocvar_g_vehicle_racer_waterburn_cost * PHYS_INPUT_TIMELENGTH;
df += (v_forward * autocvar_g_vehicle_racer_waterburn_speed);
sound (vehic.tur_head, CH_TRIGGER_SINGLE, SND_Null, VOL_VEHICLEENGINE, ATTEN_NORM);
}
- if(cont == CONTENT_WATER || cont == CONTENT_LAVA || cont == CONTENT_SLIME)
+ if(cont & DPCONTENTS_LIQUIDSMASK)
vehic.racer_watertime = time;
float dforce = autocvar_g_vehicle_racer_downforce;
this.movement = vehic.velocity += df * PHYS_INPUT_TIMELENGTH;
#ifdef SVQC
- setself(vehic);
Weapon wep1 = WEP_RACER;
if (!forbidWeaponUse(this))
if (PHYS_INPUT_BUTTON_ATCK(this))
- if (wep1.wr_checkammo1(wep1))
+ if (wep1.wr_checkammo1(wep1, vehic))
{
string tagname = (vehic.cnt)
? (vehic.cnt = 0, "tag_fire1")
crosshair_trace(this);
w_shotdir.z = normalize(trace_endpos - org).z * 0.5;
.entity weaponentity = weaponentities[0];
- wep1.wr_think(wep1, vehic, weaponentity, 1);
+ WITHSELF(vehic, wep1.wr_think(wep1, vehic, weaponentity, 1));
}
- setself(this);
-
if(autocvar_g_vehicle_racer_rocket_locktarget)
{
+ if(vehic.vehicle_last_trace == time + autocvar_g_vehicle_racer_thinkrate)
vehicles_locktarget(vehic, (1 / autocvar_g_vehicle_racer_rocket_locking_time) * frametime,
(1 / autocvar_g_vehicle_racer_rocket_locking_releasetime) * frametime,
autocvar_g_vehicle_racer_rocket_locked_time);
this.velocity = vehic.velocity;
}
-void racer_think()
-{SELFPARAM();
- self.nextthink = time;
-
- float pushdeltatime = time - self.lastpushtime;
- if (pushdeltatime > 0.15) pushdeltatime = 0;
- self.lastpushtime = time;
- if(!pushdeltatime) return;
+void racer_think(entity this)
+{
+ this.nextthink = time + autocvar_g_vehicle_racer_thinkrate;
- tracebox(self.origin, self.mins, self.maxs, self.origin - ('0 0 1' * autocvar_g_vehicle_racer_springlength), MOVE_NOMONSTERS, self);
+ tracebox(this.origin, this.mins, this.maxs, this.origin - ('0 0 1' * autocvar_g_vehicle_racer_springlength), MOVE_NOMONSTERS, this);
- vector df = self.velocity * -autocvar_g_vehicle_racer_friction;
+ vector df = this.velocity * -autocvar_g_vehicle_racer_friction;
df_z += (1 - trace_fraction) * autocvar_g_vehicle_racer_hoverpower + sin(time * 2) * (autocvar_g_vehicle_racer_springlength * 2);
float forced = autocvar_g_vehicle_racer_upforcedamper;
- int cont = pointcontents(self.origin - '0 0 64');
- if(cont == CONTENT_WATER || cont == CONTENT_LAVA || cont == CONTENT_SLIME)
+ //int cont = pointcontents(this.origin - '0 0 64');
+ traceline(this.origin - '0 0 64', this.origin - '0 0 64', MOVE_NOMONSTERS, this);
+ //if(cont == CONTENT_WATER || cont == CONTENT_LAVA || cont == CONTENT_SLIME)
+ if(trace_dpstartcontents & DPCONTENTS_LIQUIDSMASK)
{
forced = autocvar_g_vehicle_racer_water_upforcedamper;
- self.velocity_z += 200;
+ this.velocity_z += 200;
}
- self.velocity += df * pushdeltatime;
- if(self.velocity_z > 0)
- self.velocity_z *= 1 - forced * pushdeltatime;
+ this.velocity += df * autocvar_g_vehicle_racer_thinkrate;
+ if(this.velocity_z > 0)
+ this.velocity_z *= 1 - forced * autocvar_g_vehicle_racer_thinkrate;
- self.angles_x *= 1 - (autocvar_g_vehicle_racer_anglestabilizer * pushdeltatime);
- self.angles_z *= 1 - (autocvar_g_vehicle_racer_anglestabilizer * pushdeltatime);
+ this.angles_x *= 1 - (autocvar_g_vehicle_racer_anglestabilizer * autocvar_g_vehicle_racer_thinkrate);
+ this.angles_z *= 1 - (autocvar_g_vehicle_racer_anglestabilizer * autocvar_g_vehicle_racer_thinkrate);
- CSQCMODEL_AUTOUPDATE(self);
+ CSQCMODEL_AUTOUPDATE(this);
}
-void racer_exit(float eject)
-{SELFPARAM();
+void racer_exit(entity this, int eject)
+{
vector spot;
- self.think = racer_think;
- self.nextthink = time;
- self.movetype = MOVETYPE_BOUNCE;
- sound (self.tur_head, CH_TRIGGER_SINGLE, SND_Null, VOL_VEHICLEENGINE, ATTEN_NORM);
+ setthink(this, racer_think);
+ this.nextthink = time;
+ this.movetype = MOVETYPE_BOUNCE;
+ sound (this.tur_head, CH_TRIGGER_SINGLE, SND_Null, VOL_VEHICLEENGINE, ATTEN_NORM);
- if(!self.owner)
+ if(!this.owner)
return;
- makevectors(self.angles);
+ makevectors(this.angles);
if(eject)
{
- spot = self.origin + v_forward * 100 + '0 0 64';
- spot = vehicles_findgoodexit(spot);
- setorigin(self.owner , spot);
- self.owner.velocity = (v_up + v_forward * 0.25) * 750;
- self.owner.oldvelocity = self.owner.velocity;
+ spot = this.origin + v_forward * 100 + '0 0 64';
+ spot = vehicles_findgoodexit(this, spot);
+ setorigin(this.owner, spot);
+ this.owner.velocity = (v_up + v_forward * 0.25) * 750;
+ this.owner.oldvelocity = this.owner.velocity;
}
else
{
- if(vdist(self.velocity, >, 2 * autocvar_sv_maxairspeed))
+ if(vdist(this.velocity, >, 2 * autocvar_sv_maxairspeed))
{
- self.owner.velocity = normalize(self.velocity) * autocvar_sv_maxairspeed * 2;
- self.owner.velocity_z += 200;
- spot = self.origin + v_forward * 32 + '0 0 32';
- spot = vehicles_findgoodexit(spot);
+ this.owner.velocity = normalize(this.velocity) * autocvar_sv_maxairspeed * 2;
+ this.owner.velocity_z += 200;
+ spot = this.origin + v_forward * 32 + '0 0 32';
+ spot = vehicles_findgoodexit(this, spot);
}
else
{
- self.owner.velocity = self.velocity * 0.5;
- self.owner.velocity_z += 10;
- spot = self.origin - v_forward * 200 + '0 0 32';
- spot = vehicles_findgoodexit(spot);
+ this.owner.velocity = this.velocity * 0.5;
+ this.owner.velocity_z += 10;
+ spot = this.origin - v_forward * 200 + '0 0 32';
+ spot = vehicles_findgoodexit(this, spot);
}
- self.owner.oldvelocity = self.owner.velocity;
- setorigin(self.owner , spot);
+ this.owner.oldvelocity = this.owner.velocity;
+ setorigin(this.owner , spot);
}
- antilag_clear(self.owner, CS(self.owner));
- self.owner = world;
+ antilag_clear(this.owner, CS(this.owner));
+ this.owner = world;
}
-void racer_blowup()
-{SELFPARAM();
- self.deadflag = DEAD_DEAD;
- self.vehicle_exit(VHEF_NORMAL);
+void racer_blowup(entity this)
+{
+ this.deadflag = DEAD_DEAD;
+ this.vehicle_exit(this, VHEF_NORMAL);
- RadiusDamage (self, self.enemy, autocvar_g_vehicle_racer_blowup_coredamage,
+ RadiusDamage (this, this.enemy, autocvar_g_vehicle_racer_blowup_coredamage,
autocvar_g_vehicle_racer_blowup_edgedamage,
autocvar_g_vehicle_racer_blowup_radius, world, world,
autocvar_g_vehicle_racer_blowup_forceintensity,
DEATH_VH_WAKI_DEATH.m_id, world);
- self.nextthink = time + autocvar_g_vehicle_racer_respawntime;
- self.think = vehicles_spawn;
- self.movetype = MOVETYPE_NONE;
- self.effects = EF_NODRAW;
- self.solid = SOLID_NOT;
+ this.nextthink = time + autocvar_g_vehicle_racer_respawntime;
+ setthink(this, vehicles_spawn);
+ this.movetype = MOVETYPE_NONE;
+ this.effects = EF_NODRAW;
+ this.solid = SOLID_NOT;
- self.colormod = '0 0 0';
- self.avelocity = '0 0 0';
- self.velocity = '0 0 0';
+ this.colormod = '0 0 0';
+ this.avelocity = '0 0 0';
+ this.velocity = '0 0 0';
- setorigin(self, self.pos1);
+ setorigin(this, this.pos1);
}
-void racer_blowup_think()
-{SELFPARAM();
- self.nextthink = time;
+void racer_blowup_think(entity this)
+{
+ this.nextthink = time;
- if(time >= self.delay)
- racer_blowup();
+ if(time >= this.delay)
+ racer_blowup(this);
- CSQCMODEL_AUTOUPDATE(self);
+ CSQCMODEL_AUTOUPDATE(this);
}
-void racer_deadtouch()
-{SELFPARAM();
- self.avelocity_x *= 0.7;
- self.cnt -= 1;
- if(self.cnt <= 0)
- racer_blowup();
+void racer_deadtouch(entity this)
+{
+ this.avelocity_x *= 0.7;
+ this.cnt -= 1;
+ if(this.cnt <= 0)
+ racer_blowup(this);
}
spawnfunc(vehicle_racer)
#ifdef CSQC
#if 0
-void racer_draw()
-{SELFPARAM();
- float pushdeltatime = time - self.lastpushtime;
+void racer_draw(entity this)
+{
+ float pushdeltatime = time - this.lastpushtime;
if (pushdeltatime > 0.15) pushdeltatime = 0;
- self.lastpushtime = time;
+ this.lastpushtime = time;
if(!pushdeltatime) return;
- tracebox(self.move_origin, self.mins, self.maxs, self.move_origin - ('0 0 1' * STAT(VEH_RACER_SPRINGLENGTH)), MOVE_NOMONSTERS, self);
+ tracebox(this.move_origin, this.mins, this.maxs, this.move_origin - ('0 0 1' * STAT(VEH_RACER_SPRINGLENGTH)), MOVE_NOMONSTERS, this);
- vector df = self.move_velocity * -STAT(VEH_RACER_FRICTION);
+ vector df = this.move_velocity * -STAT(VEH_RACER_FRICTION);
df_z += (1 - trace_fraction) * STAT(VEH_RACER_HOVERPOWER) + sin(time * 2) * (STAT(VEH_RACER_SPRINGLENGTH) * 2);
float forced = STAT(VEH_RACER_UPFORCEDAMPER);
- int cont = pointcontents(self.move_origin - '0 0 64');
+ int cont = pointcontents(this.move_origin - '0 0 64');
if(cont == CONTENT_WATER || cont == CONTENT_LAVA || cont == CONTENT_SLIME)
{
forced = STAT(VEH_RACER_WATER_UPFORCEDAMPER);
- self.move_velocity_z += 200;
+ this.move_velocity_z += 200;
}
- self.move_velocity += df * pushdeltatime;
- if(self.move_velocity_z > 0)
- self.move_velocity_z *= 1 - forced * pushdeltatime;
+ this.move_velocity += df * pushdeltatime;
+ if(this.move_velocity_z > 0)
+ this.move_velocity_z *= 1 - forced * pushdeltatime;
- self.move_angles_x *= 1 - (STAT(VEH_RACER_ANGLESTABILIZER) * pushdeltatime);
- self.move_angles_z *= 1 - (STAT(VEH_RACER_ANGLESTABILIZER) * pushdeltatime);
+ this.move_angles_x *= 1 - (STAT(VEH_RACER_ANGLESTABILIZER) * pushdeltatime);
+ this.move_angles_z *= 1 - (STAT(VEH_RACER_ANGLESTABILIZER) * pushdeltatime);
- Movetype_Physics_MatchServer(false);
+ Movetype_Physics_MatchServer(this, false);
}
#endif
#endif
METHOD(Racer, vr_enter, void(Racer thisveh, entity instance))
{
#ifdef SVQC
- SELFPARAM();
- self.movetype = MOVETYPE_BOUNCE;
- self.owner.vehicle_health = (self.vehicle_health / autocvar_g_vehicle_racer_health) * 100;
- self.owner.vehicle_shield = (self.vehicle_shield / autocvar_g_vehicle_racer_shield) * 100;
+ instance.movetype = MOVETYPE_BOUNCE;
+ instance.owner.vehicle_health = (instance.vehicle_health / autocvar_g_vehicle_racer_health) * 100;
+ instance.owner.vehicle_shield = (instance.vehicle_shield / autocvar_g_vehicle_racer_shield) * 100;
- if(self.owner.flagcarried)
- setorigin(self.owner.flagcarried, '-190 0 96');
+ if(instance.owner.flagcarried)
+ setorigin(instance.owner.flagcarried, '-190 0 96');
#elif defined(CSQC)
- SELFPARAM();
- self.move_movetype = MOVETYPE_BOUNCE;
+ instance.move_movetype = MOVETYPE_BOUNCE;
#endif
}
METHOD(Racer, vr_spawn, void(Racer thisveh, entity instance))
{
#ifdef SVQC
- SELFPARAM();
- if(self.scale != 0.5)
+ if(instance.scale != 0.5)
{
if(autocvar_g_vehicle_racer_hovertype != 0)
racer_force_from_tag = vehicles_force_fromtag_maglev;
racer_force_from_tag = vehicles_force_fromtag_hover;
// FIXME: this be hakkz, fix the models insted (scale body, add tag_viewport to the hudmodel).
- self.scale = 0.5;
- setattachment(self.vehicle_hudmodel, self, "");
- setattachment(self.vehicle_viewport, self, "tag_viewport");
+ instance.scale = 0.5;
+ setattachment(instance.vehicle_hudmodel, instance, "");
+ setattachment(instance.vehicle_viewport, instance, "tag_viewport");
- self.mass = 900;
+ instance.mass = 900;
}
- self.think = racer_think;
- self.nextthink = time;
- self.vehicle_health = autocvar_g_vehicle_racer_health;
- self.vehicle_shield = autocvar_g_vehicle_racer_shield;
+ setthink(instance, racer_think);
+ instance.nextthink = time;
+ instance.vehicle_health = autocvar_g_vehicle_racer_health;
+ instance.vehicle_shield = autocvar_g_vehicle_racer_shield;
- self.movetype = MOVETYPE_TOSS;
- self.solid = SOLID_SLIDEBOX;
- self.delay = time;
- self.scale = 0.5;
+ instance.movetype = MOVETYPE_TOSS;
+ instance.solid = SOLID_SLIDEBOX;
+ instance.delay = time;
+ instance.scale = 0.5;
- self.PlayerPhysplug = racer_frame;
+ instance.PlayerPhysplug = racer_frame;
- self.bouncefactor = autocvar_g_vehicle_racer_bouncefactor;
- self.bouncestop = autocvar_g_vehicle_racer_bouncestop;
- self.damageforcescale = 0.5;
- self.vehicle_health = autocvar_g_vehicle_racer_health;
- self.vehicle_shield = autocvar_g_vehicle_racer_shield;
+ instance.bouncefactor = autocvar_g_vehicle_racer_bouncefactor;
+ instance.bouncestop = autocvar_g_vehicle_racer_bouncestop;
+ instance.damageforcescale = 0.5;
+ instance.vehicle_health = autocvar_g_vehicle_racer_health;
+ instance.vehicle_shield = autocvar_g_vehicle_racer_shield;
#endif
}
instance.wait = time;
instance.delay = 2 + time + random() * 3;
instance.cnt = 1 + random() * 2;
- instance.touch = racer_deadtouch;
+ settouch(instance, racer_deadtouch);
Send_Effect(EFFECT_EXPLOSION_MEDIUM, instance.origin, '0 0 0', 1);
instance.velocity += '0 0 700';
instance.colormod = '-0.5 -0.5 -0.5';
- instance.think = racer_blowup_think;
+ setthink(instance, racer_blowup_think);
instance.nextthink = time;
#endif
}
"vehicle_icon_ammo1", autocvar_hud_progressbar_vehicles_ammo1_color,
"vehicle_icon_ammo2", autocvar_hud_progressbar_vehicles_ammo2_color);
}
-METHOD(Racer, vr_crosshair, void(Racer thisveh))
+METHOD(Racer, vr_crosshair, void(Racer thisveh, entity player))
{
Vehicles_drawCrosshair(vCROSS_GUIDE);
}