float collision_run()
{
- vector vtmp, vmin, vmax, vrot, vforce;
+ vector vtmp, vmin, vmax, vrot, vforce, vtmp2, vtmp3;
float i, fvel, bcol;
vtmp = vmax; vtmp_z = vmin_z; bb1[7] = vtmp;
makevectors(self.angles + '-2 0 0' * self.angles_x);
- bcol = FALSE;
+ bcol = 0;
+
// Pass1: Transform by rotation, ajust points by impact/s
for(i = 8; i >= 0; --i)
{
te_lightning1(world,self.origin,vtmp);
if(trace_fraction != 1.0)
{
- //bb2[i] = trace_endpos;
vforce += (trace_endpos - vtmp);
- bcol = TRUE;
+ vtmp3 = self.origin + self.velocity * frametime;
+ vtmp2 = vectoangles(normalize(vtmp - vtmp3));
+ vrot += (vectoangles(normalize(trace_endpos - vtmp3)) - vtmp2);
+ bcol += 1;
}
- else
- bb2[i] = bb1[i];
}
if(bcol)
{
- //self.angles += vectoangles(vrot) * frametime;
- //self.angles -= (self.velocity - vectoangles(normalize(vforce))) * frametime;
vtmp = self.origin + self.velocity * frametime;
- vrot = self.origin + vforce * frametime;
- //self.angles += vectoangles(normalize(vtmp - vrot)) * frametime;
+ self.angles += vrot * frametime;
self.velocity += vforce * frametime;
}
-
-// Extract the 8 bbox corners from mins/maxs for self
-/*
- bb1[0] = self.absmax;
- vtmp = self.absmax; vtmp_x = self.absmin_x; bb1[1] = vtmp;
- vtmp = self.absmax; vtmp_y = self.absmin_y; bb1[2] = vtmp;
- vtmp = self.absmin; vtmp_z = self.absmax_z; bb1[3] = vtmp;
- bb1[4] = self.absmin;
- vtmp = self.absmin; vtmp_x = self.absmax_x; bb1[5] = vtmp;
- vtmp = self.absmin; vtmp_y = self.absmax_y; bb1[6] = vtmp;
- vtmp = self.absmax; vtmp_z = self.absmin_z; bb1[7] = vtmp;
-
-
-// Extract the 8 bbox corners from mins/maxs for other
- bb1[0] = other.absmax;
- vtmp = other.absmax; vtmp_x = other.absmin_x; bb2[1] = vtmp;
- vtmp = other.absmax; vtmp_y = other.absmin_y; bb2[2] = vtmp;
- vtmp = other.absmin; vtmp_z = other.absmax_z; bb2[3] = vtmp;
- bb2[4] = other.absmin;
- vtmp = other.absmin; vtmp_x = other.absmax_x; bb2[5] = vtmp;
- vtmp = other.absmin; vtmp_y = other.absmax_y; bb2[6] = vtmp;
- vtmp = other.absmax; vtmp_z = other.absmin_z; bb2[7] = vtmp;
-*/
}
if(autocvar_g_vehicle_racer_rocket_locktarget)
{
- vehicles_locktarget2((1 / autocvar_g_vehicle_racer_rocket_locking_time) * frametime,
+ vehicles_locktarget((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);
void racer_enter()
{
+ self.movetype = MOVETYPE_BOUNCEMISSILE;
self.owner.vehicle_health = (self.vehicle_health / autocvar_g_vehicle_racer_health);
self.owner.vehicle_shield = (self.vehicle_shield / autocvar_g_vehicle_racer_shield);
}
-void racer_spawn();
-
void racer_exit(float eject)
{
- vehicles_setreturn(autocvar_g_vehicle_racer_respawntime, racer_spawn);
-
self.think = racer_think;
self.nextthink = time;
+ self.movetype = MOVETYPE_BOUNCEMISSILE;
if not (self.owner)
return;
self.owner = world;
}
-/*void racer_touch()
-{
- //vehicles_touch();
- if(self.owner)
- {
- return;
- }
-
- if(other.classname != "player")
- return;
-
- if(other.deadflag != DEAD_NO)
- return;
-
- if(other.vehicle != world)
- return;
-
- vehicles_enter();
-}*/
-
void racer_spawn()
{
- self.think = racer_think;
- self.nextthink = time;
-
- self.flags = FL_NOTARGET;
- self.effects = 0;
-
+ self.think = racer_think;
+ self.nextthink = time;
self.vehicle_health = autocvar_g_vehicle_racer_health;
self.vehicle_shield = autocvar_g_vehicle_racer_shield;
-
- self.event_damage = vehicles_damage;
- //self.touch = racer_touch;
- self.touch = vehicles_touch;
-
- self.iscreature = TRUE;
- self.scale = 0.5;
- self.movetype = MOVETYPE_BOUNCEMISSILE;
- self.solid = SOLID_SLIDEBOX;
- self.takedamage = DAMAGE_AIM;
-
- self.alpha = 1;
- self.colormap = 1024;
- self.deadflag = DEAD_NO;
- self.bot_attack = TRUE;
-
- self.vehicle_energy = 1;
- self.vehicle_hudmodel.viewmodelforclient = self;
-
- setorigin(self, self.pos1);
- self.angles = self.pos2;
-
+ self.movetype = MOVETYPE_TOSS;
+ self.solid = SOLID_SLIDEBOX;
+ self.delay = time;
+ self.scale = 0.5;
setsize(self, RACER_MIN * 0.5, RACER_MAX * 0.5);
- pointparticles(particleeffectnum("teleport"), self.origin + '0 0 64', '0 0 0', 1);
- self.delay = time;
-
- vehicles_reset_colors();
}
+
void racer_blowup()
{
self.velocity = '0 0 0';
setorigin(self, self.pos1);
+ self.think = racer_spawn;
+ self.nextthink = time + autocvar_g_vehicle_racer_respawntime;
}
void racer_deadtouch()
pointparticles(particleeffectnum("rocket_explode"), findbetterlocation (self.origin, 16), '0 0 0', 1);
- self.velocity += '0 0 700';
-
if(random() < 0.5)
self.avelocity_z = 16;
else
self.avelocity_z = -16;
self.avelocity_x = -vlen(self.velocity) * 0.2;
-
+ self.velocity += '0 0 700';
self.colormod = '-0.5 -0.5 -0.5';
self.think = racer_blowup;
HUD_WAKIZASHI,
0.5 * RACER_MIN, 0.5 * RACER_MAX,
FALSE,
- racer_spawn, racer_frame,
+ racer_spawn, autocvar_g_vehicle_racer_respawntime,
+ racer_frame,
racer_enter, racer_exit,
racer_die, racer_think))
{
float autocvar_g_vehicle_raptor_shield_regen_pause;
void raptor_spawn();
-//void raptor_return();
float raptor_frame();
-//float raptor_takeoff();
.entity bomb1;
.entity bomb2;
-//.entity camera;
+
//#define RAPTOR_RETARDCAMERA
float raptor_altitude(float amax)
void raptor_enter()
{
- self.movetype = MOVETYPE_BOUNCEMISSILE;
+ self.movetype = MOVETYPE_BOUNCEMISSILE;
+ self.solid = SOLID_BBOX;
self.owner.vehicle_health = (self.vehicle_health / autocvar_g_vehicle_raptor_health);
self.owner.vehicle_shield = (self.vehicle_shield / autocvar_g_vehicle_raptor_shield);
self.velocity_z = 1;
if(hgt < 16)
{
- self.movetype = MOVETYPE_BOUNCE;
+ self.movetype = MOVETYPE_TOSS;
self.think = raptor_think;
}
if(self.deadflag == DEAD_NO)
{
- vehicles_setreturn(autocvar_g_vehicle_raptor_respawntime, raptor_spawn);
self.think = raptor_land;
self.nextthink = time;
}
raptor = self.vehicle;
self = raptor;
- if(player.BUTTON_USE)
+ if(player.BUTTON_USE && raptor.deadflag == DEAD_NO)
{
self = raptor;
vehicles_exit(VHEF_NORMAL);
ftmp = bound(-ftmp, shortangle_f(df_y - raptor.angles_y, raptor.angles_y), ftmp);
// Turn
- raptor.angles_y = anglemods(raptor.angles_y + ftmp);
+ //raptor.angles_y = anglemods(raptor.angles_y + ftmp);
+ raptor.avelocity_y = anglemods(raptor.angles_y + ftmp);
// Pitch Body
ftmp = autocvar_g_vehicle_raptor_pitchspeed * sys_frametime;
ftmp = bound(-ftmp, shortangle_f(df_x - raptor.angles_x, raptor.angles_x), ftmp);
- raptor.angles_x = bound(-autocvar_g_vehicle_raptor_pitchlimit, anglemods(raptor.angles_x + ftmp), autocvar_g_vehicle_raptor_pitchlimit);
+ //raptor.angles_x = bound(-autocvar_g_vehicle_raptor_pitchlimit, anglemods(raptor.angles_x + ftmp), autocvar_g_vehicle_raptor_pitchlimit);
+ raptor.avelocity_x = bound(-autocvar_g_vehicle_raptor_pitchlimit, anglemods(raptor.angles_x + ftmp), autocvar_g_vehicle_raptor_pitchlimit);
#else
- raptor.angles_x *= -1;
- // Rotate Body
- ftmp = autocvar_g_vehicle_raptor_turnspeed * sys_frametime;
- ftmp = bound(-ftmp, shortangle_f(player.v_angle_y - raptor.angles_y, raptor.angles_y), ftmp);
+ vector vang;
+ vang = raptor.angles;
+ df = vectoangles(normalize(trace_endpos - self.origin + '0 0 32'));
+ vang_x *= -1;
+ df_x *= -1;
+ if(df_x > 180) df_x -= 360;
+ if(df_x < -180) df_x += 360;
+ if(df_y > 180) df_y -= 360;
+ if(df_y < -180) df_y += 360;
- // Turn
- raptor.angles_y = anglemods(raptor.angles_y + ftmp);
+ ftmp = shortangle_f(player.v_angle_y - vang_y, vang_y);
+ if(ftmp > 180) ftmp -= 360; if(ftmp < -180) ftmp += 360;
+ raptor.avelocity_y = bound(-autocvar_g_vehicle_raptor_turnspeed, ftmp + raptor.avelocity_y * 0.9, autocvar_g_vehicle_raptor_turnspeed);
- // Pitch Body
- ftmp = autocvar_g_vehicle_raptor_pitchspeed * sys_frametime;
- ftmp2 = shortangle_f(player.v_angle_x - raptor.angles_x, raptor.angles_x);
+ // Pitch
+ ftmp = 0;
+ if(player.movement_x > 0 && vang_x < autocvar_g_vehicle_raptor_pitchlimit) ftmp = 5;
+ else if(player.movement_x < 0 && vang_x > -autocvar_g_vehicle_raptor_pitchlimit) ftmp = -20;
- if(player.movement_x > 0)
- ftmp2 += 20 * ftmp;
- else if(player.movement_x < 0)
- ftmp2 -= 45 * ftmp;
+ df_x = bound(-autocvar_g_vehicle_raptor_pitchlimit, df_x , autocvar_g_vehicle_raptor_pitchlimit);
+ ftmp = vang_x - bound(-autocvar_g_vehicle_raptor_pitchlimit, df_x + ftmp, autocvar_g_vehicle_raptor_pitchlimit);
+ raptor.avelocity_x = bound(-autocvar_g_vehicle_raptor_pitchspeed, ftmp + raptor.avelocity_x * 0.9, autocvar_g_vehicle_raptor_pitchspeed);
+
+ raptor.angles_x = anglemods(raptor.angles_x);
+ raptor.angles_y = anglemods(raptor.angles_y);
+ raptor.angles_z = anglemods(raptor.angles_z);
- ftmp = bound(-ftmp, ftmp2, ftmp);
- raptor.angles_x = bound(-autocvar_g_vehicle_raptor_pitchlimit, anglemods(raptor.angles_x + ftmp), autocvar_g_vehicle_raptor_pitchlimit);
- raptor.angles_x *= -1;
#endif
if(autocvar_g_vehicle_raptor_movestyle == 1)
- fixedmakevectors('0 1 0' * raptor.angles_y);
+ makevectors(raptor.angles + ('-1 0 0' * raptor.angles_x));
else
makevectors(player.v_angle);
else if(player.movement_y > 0)
df += v_right * autocvar_g_vehicle_raptor_speed_strafe;
- raptor.angles_z = bound(-30,raptor.angles_z + (player.movement_y / autocvar_g_vehicle_raptor_speed_strafe),30);
+ //raptor.angles_z = bound(-30,raptor.angles_z + (player.movement_y / autocvar_g_vehicle_raptor_speed_strafe),30);
}
else
{
- raptor.angles_z *= 0.95;
+ /*raptor.angles_z *= 0.95;
if(raptor.angles_z >= -1 && raptor.angles_z <= -1)
- raptor.angles_z = 0;
+ raptor.angles_z = 0;*/
}
if(player.BUTTON_CROUCH)
else if (player.BUTTON_JUMP)
df += v_up * autocvar_g_vehicle_raptor_speed_up;
+
+
raptor.velocity += df * frametime;
player.velocity = player.movement = raptor.velocity;
setorigin(player,raptor.origin + '0 0 32');
if(autocvar_g_vehicle_raptor_cannon_locktarget)
{
- vehicles_locktarget2((1 / autocvar_g_vehicle_raptor_cannon_locking_time) * frametime,
+ vehicles_locktarget((1 / autocvar_g_vehicle_raptor_cannon_locking_time) * frametime,
(1 / autocvar_g_vehicle_raptor_cannon_locking_releasetime) * frametime,
autocvar_g_vehicle_raptor_cannon_locked_time);
return 1;
}
-/*void raptor_touch()
-{
- //vehicles_touch();
- if(self.owner)
- {
- if(vlen(self.velocity) == 0)
- return;
-
- if(other.classname != "player")
- return;
-
- return;
- }
-
- if(other.classname != "player")
- return;
-
- if(other.deadflag != DEAD_NO)
- return;
-
- if(other.vehicle != world)
- return;
-
- vehicles_enter();
-}*/
-
void raptor_blowup()
{
sound (self, CHAN_PROJECTILE, "weapons/rocket_impact.wav", VOL_BASE, ATTN_NORM);
self.vehicle_health = autocvar_g_vehicle_raptor_health;
self.vehicle_shield = autocvar_g_vehicle_raptor_shield;
self.event_damage = vehicles_damage;
- //self.touch = raptor_touch;
self.touch = vehicles_touch;
self.iscreature = TRUE;
self.movetype = MOVETYPE_FLY;
HUD_RAPTOR,
RAPTOR_MIN, RAPTOR_MAX,
FALSE,
- raptor_spawn, raptor_frame,
+ raptor_spawn, autocvar_g_vehicle_raptor_respawntime,
+ raptor_frame,
raptor_enter, raptor_exit,
raptor_die, raptor_think))
{
remove(self);
return;
}
-
+ setorigin(self, self.origin + '0 0 50');
//FIXME: Camera is in a bad place in HUD model.
setorigin(self.vehicle_viewport, '5 0 5');
spinner.avelocity = '0 -90 0';
self.bomb1.gun2 = spinner;
- self.mass = 2200;
+ self.mass = 1 ;
}
void spawnfunc_vehicle_raptor()
void spiderbot_enter()
{
+ self.movetype = MOVETYPE_WALK;
self.owner.vehicle_health = (self.vehicle_health / autocvar_g_vehicle_spiderbot_health);
self.owner.vehicle_shield = (self.vehicle_shield / autocvar_g_vehicle_spiderbot_shield);
}
{
entity e;
- vehicles_setreturn(autocvar_g_vehicle_spiderbot_respawntime, spiderbot_spawn);
-
e = findchain(classname,"spiderbot_rocket");
while(e)
{
self.think = spiderbot_think;
self.nextthink = time;
self.frame = 5;
+ self.movetype = MOVETYPE_WALK;
if not (self.owner)
return;
void spiderbot_spawn()
{
-
self.frame = 5;
self.think = spiderbot_think;
self.nextthink = time;
self.movetype = MOVETYPE_WALK;
self.solid = SOLID_SLIDEBOX;
self.takedamage = DAMAGE_AIM;
- //self.touch = spiderbot_touch;
self.touch = vehicles_touch;
self.alpha = self.tur_head.alpha = self.gun1.alpha = self.gun2.alpha = 1;
self.tur_head.angles = '0 0 0';
self.angles = self.pos2;
vehicles_reset_colors();
-
}
void spiderbot_headfade()
sound (self, CHAN_PROJECTILE, "weapons/rocket_impact.wav", VOL_BASE, ATTN_NORM);
for(i = 0; i < 5; ++i)
- {
- pointparticles(particleeffectnum("rocket_explode"), self.origin + (randomvec() * 200) + '0 0 100', '0 0 0', 1);
- }
+ pointparticles(particleeffectnum("rocket_explode"), self.origin + (randomvec() * 100) + '0 0 100', '0 0 0', 1);
entity h, g1, g2, b;
b = spawn();
HUD_SPIDERBOT,
SPIDERBOT_MIN, SPIDERBOT_MAX,
FALSE,
- spiderbot_spawn, spiderbot_frame,
+ spiderbot_spawn, autocvar_g_vehicle_spiderbot_respawntime,
+ spiderbot_frame,
spiderbot_enter, spiderbot_exit,
spiderbot_die, spiderbot_think))
{
void vehicles_damage(entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force);
void vehicles_return();
+void vehicles_enter();
+void vehicles_touch();
+void vehicles_reset_colors();
void vehicles_clearrturn();
+void vehicles_setreturn(float retime, void() respawn_proc);
+
#define MAX_AXH 4
.entity AuxiliaryXhair[MAX_AXH];
.entity lock_target;
.float lock_strength;
.float lock_time;
-void vehicles_locktarget2(float incr, float decr, float _lock_time)
+void vehicles_locktarget(float incr, float decr, float _lock_time)
{
if(self.lock_target && self.lock_target.deadflag != DEAD_NO)
- self.lock_target = world;
+ {
+ self.lock_target = world;
+ self.lock_strength = 0;
+ self.lock_time = 0;
+ }
if(trace_ent != world)
{
if(self.lock_time > time)
return;
- /*if not (trace_ent.vehicle_flags & VHF_ISVEHICLE || trace_ent.turrcaps_flags & TFL_TURRCAPS_ISTURRET)
- self.lock_strength = min(self.lock_strength - decr, 1);
- else if(trace_ent.deadflag != DEAD_NO)
- self.lock_strength = min(self.lock_strength - decr, 1);*/
-
if(self.lock_target == world && trace_ent != world)
self.lock_target = trace_ent;
return v_forward * force_fromtag_power;
}
+
+
+void vehicles_spawn()
+{
+ dprint("Spawning vehicle: ", self.netname, "\n");
+ self.vehicle_hudmodel.viewmodelforclient = self;
+ self.owner = world;
+ self.event_damage = vehicles_damage;
+ self.iscreature = TRUE;
+ self.movetype = MOVETYPE_WALK;
+ self.solid = SOLID_SLIDEBOX;
+ self.takedamage = DAMAGE_AIM;
+ self.touch = vehicles_touch;
+ self.deadflag = DEAD_NO;
+ self.bot_attack = TRUE;
+ self.flags = FL_NOTARGET;
+ self.angles = self.pos2;
+
+ setorigin(self, self.pos1 + '0 0 128');
+ pointparticles(particleeffectnum("teleport"), self.origin + '0 0 64', '0 0 0', 1);
+
+ vehicles_reset_colors();
+ self.vehicle_spawn();
+}
+
// Better way of determening whats crushable needed! (fl_crushable?)
float vehicles_crushable(entity e)
{
- if(e.classname == "corpse")
- return TRUE;
-
if(e.classname == "player")
return TRUE;
return FALSE;
}
-void vehicles_enter();
void vehicles_touch()
{
// Vehicle currently in use
CSQCVehicleSetup(self.owner, self.hud);
- if(self.vehicle_enter)
- self.vehicle_enter();
+ self.vehicle_enter();
}
void vehicles_exit(float eject)
self.vehicle_hudmodel.viewmodelforclient = self;
self.tur_head.nodrawtoclient = self;
+ vehicles_setreturn(self.vehicle_respawntime, self.vehicle_spawn);
self.phase = time + 1;
if(!teams_matter)
self.team = 0;
- if(self.vehicle_exit)
- self.vehicle_exit(eject);
+ self.vehicle_exit(eject);
self.owner = world;
}
else
self.vehicle_health -= damage;
- self.velocity += force * (vlen(force) / self.mass);
-
- if not(self.owner)
- {
- self.movetype &~= MOVETYPE_TOSS;
- }
+ self.velocity += force; // * (vlen(force) / self.mass);
if(self.vehicle_health <= 0)
{
void vehicles_return()
{
pointparticles(particleeffectnum("teleport"), self.enemy.origin + '0 0 64', '0 0 0', 1);
- self.enemy.think = self.use;
+ self.enemy.think = self.use; // This is the vehicles respwn procedure
self.enemy.nextthink = time;
remove(self);
}
vector max_s,
float nodrop,
void() spawnproc,
+ float _respawntime,
float() physproc,
void() enterproc,
void(float extflag) exitfunc,
self.hud = vhud;
self.customizeentityforclient = vehicles_customizeentityforclient;
- self.vehicle_die = dieproc;
- self.vehicle_exit = exitfunc;
- self.vehicle_enter = enterproc;
- self.PlayerPhysplug = physproc;
- self.event_damage = vehicles_damage;
- self.touch = vehicles_touch;
- self.think = spawnproc;
- self.nextthink = time;
+ self.vehicle_die = dieproc;
+ self.vehicle_exit = exitfunc;
+ self.vehicle_enter = enterproc;
+ self.PlayerPhysplug = physproc;
+ self.event_damage = vehicles_damage;
+ self.touch = vehicles_touch;
+ self.think = vehicles_spawn;
+ self.nextthink = time;
+ self.vehicle_respawntime = _respawntime;
+ self.vehicle_spawn = spawnproc;
if(autocvar_g_nodepthtestplayers)
self.effects = self.effects | EF_NODEPTHTEST;
setmodel(self.vehicle_hudmodel, hudmodel);
setmodel(self.vehicle_viewport, "null");
+
if(topmodel != "")
{
setmodel(self.tur_head, topmodel);
#ifdef VEHICLES_ENABLED
-//#include "collision.qc"
+#include "collision.qc"
#include "vehicles.qc"
#include "racer.qc"
#include "spiderbot.qc"
.float dmg_time;
+.float vehicle_respawntime;
+.void() vehicle_spawn;
+
var .void(float exit_flags) vehicle_exit;
#define VHEF_NORMAL 0
#define VHEF_EJECT 1
#endif
+void(entity e, float physics_enabled) physics_enable = #540; // enable or disable physics on object
+void(entity e, vector force, vector force_pos) physics_addforce = #541; // apply a force from certain origin, length of force vector is power of force
+void(entity e, vector torque) physics_addtorque = #542; // add relative torque