]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/vehicles/sv_vehicles.qc
Merge new vehicle stuff from combined updates
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / vehicles / sv_vehicles.qc
index d5bba034fc8260362900c80b00715d624b363ac6..be0a1deaeeb8f5bffd752a6e7c8618d485122f61 100644 (file)
@@ -1,7 +1,5 @@
-// =========================
-//  SVQC Vehicle Properties
-// =========================
-
+#include "vehicles.qh"
+#include "sv_vehicles.qh"
 
 float SendAuxiliaryXhair(entity to, float sf)
 {
@@ -18,7 +16,7 @@ float SendAuxiliaryXhair(entity to, float sf)
        WriteByte(MSG_ENTITY, rint(self.colormod_y * 255));
        WriteByte(MSG_ENTITY, rint(self.colormod_z * 255));
 
-       return TRUE;
+       return true;
 }
 
 void UpdateAuxiliaryXhair(entity own, vector loc, vector clr, float axh_id)
@@ -37,7 +35,7 @@ void UpdateAuxiliaryXhair(entity own, vector loc, vector clr, float axh_id)
                axh.cnt                          = axh_id;
                axh.drawonlytoclient    = own;
                axh.owner                          = own;
-               Net_LinkEntity(axh, FALSE, 0, SendAuxiliaryXhair);
+               Net_LinkEntity(axh, false, 0, SendAuxiliaryXhair);
        }
 
        setorigin(axh, loc);
@@ -234,7 +232,7 @@ entity vehicles_projectile(string _mzlfx, string _mzlsound,
        proj.solid                      = SOLID_BBOX;
        proj.movetype            = MOVETYPE_FLYMISSILE;
        proj.flags                      = FL_PROJECTILE;
-       proj.bot_dodge          = TRUE;
+       proj.bot_dodge          = true;
        proj.bot_dodgerating  = _dmg;
        proj.velocity            = _vel;
        proj.touch                      = vehicles_projectile_explode;
@@ -271,6 +269,7 @@ void vehicles_gib_explode()
 {
        sound (self, CH_SHOTS, "weapons/rocket_impact.wav", VOL_BASE, ATTEN_NORM);
        pointparticles(particleeffectnum("explosion_small"), randomvec() * 80 + (self.origin + '0 0 100'), '0 0 0', 1);
+       pointparticles(particleeffectnum("explosion_small"), self.wp00.origin + '0 0 64', '0 0 0', 1);
        remove(self);
 }
 
@@ -340,7 +339,7 @@ float vehicle_addplayerslot(        entity _owner,
        setattachment(_slot.vehicle_hudmodel, _slot, "");
        setattachment(_slot.vehicle_viewport, _slot.vehicle_hudmodel, "");
 
-       return TRUE;
+       return true;
 }
 
 vector vehicle_aimturret(entity _vehic, vector _target, entity _turrret, string _tagname,
@@ -352,7 +351,7 @@ vector vehicle_aimturret(entity _vehic, vector _target, entity _turrret, string
        vtag = gettaginfo(_turrret, gettagindex(_turrret, _tagname));
        vtmp = vectoangles(normalize(_target - vtag));
        vtmp = AnglesTransform_ToAngles(AnglesTransform_LeftDivide(AnglesTransform_FromAngles(_vehic.angles), AnglesTransform_FromAngles(vtmp))) - _turrret.angles;
-       vtmp = AnglesTransform_Normalize(vtmp, TRUE);
+       vtmp = AnglesTransform_Normalize(vtmp, true);
        ftmp = _aimspeed * frametime;
        vtmp_y = bound(-ftmp, vtmp_y, ftmp);
        vtmp_x = bound(-ftmp, vtmp_x, ftmp);
@@ -494,7 +493,7 @@ void vehicles_showwp()
                rgb = Team_ColorRGB(self.team);
        else
                rgb = '1 1 1';
-       WaypointSprite_Spawn("vehicle", 0, 0, self, '0 0 64', world, 0, self, waypointsprite_attached, TRUE, RADARICON_POWERUP, rgb);
+       WaypointSprite_Spawn("vehicle", 0, 0, self, '0 0 64', world, 0, self, waypointsprite_attached, true, RADARICON_POWERUP, rgb);
        if(self.waypointsprite_attached)
        {
                WaypointSprite_UpdateRule(self.waypointsprite_attached, self.wp00.team, SPRITERULE_DEFAULT);
@@ -633,6 +632,9 @@ void vehicles_damage(entity inflictor, entity attacker, float damage, float deat
        if(DEATH_ISWEAPON(deathtype, WEP_SEEKER))
                damage *= autocvar_g_vehicles_tag_damagerate;
 
+       if(DEATH_WEAPONOFWEAPONDEATH(deathtype))
+               damage *= autocvar_g_vehicles_weapon_damagerate;
+
        self.enemy = attacker;
 
        self.pain_finished = time;
@@ -705,13 +707,13 @@ void vehicles_damage(entity inflictor, entity attacker, float damage, float deat
 
 float vehicles_crushable(entity e)
 {
-       if(IS_PLAYER(e))
-               return TRUE;
+       if(IS_PLAYER(e) && time >= e.vehicle_enter_delay)
+               return true;
 
        if(e.flags & FL_MONSTER)
-               return TRUE;
+               return true;
 
-       return FALSE;
+       return false;
 }
 
 void vehicles_impact(float _minspeed, float _speedfac, float _maxpain)
@@ -797,7 +799,7 @@ void vehicles_exit(float eject)
                return;
        }
 
-       vehicles_exit_running = TRUE;
+       vehicles_exit_running = true;
        if(IS_CLIENT(self))
        {
                _vehicle = self.vehicle;
@@ -806,7 +808,7 @@ void vehicles_exit(float eject)
                {
                        _vehicle.vehicle_exit(eject);
                        self = _oldself;
-                       vehicles_exit_running = FALSE;
+                       vehicles_exit_running = false;
                        return;
                }
        }
@@ -846,6 +848,7 @@ void vehicles_exit(float eject)
                _player.hud                             = HUD_NORMAL;
                _player.switchweapon    = _vehicle.switchweapon;
                _player.last_vehiclecheck = time + 3;
+               _player.vehicle_enter_delay = time + 2;
 
                CSQCVehicleSetup(_player, HUD_NORMAL);
        }
@@ -886,7 +889,7 @@ void vehicles_exit(float eject)
 
        self = _oldself;
 
-       vehicles_exit_running = FALSE;
+       vehicles_exit_running = false;
 }
 
 void vehicles_touch()
@@ -902,7 +905,7 @@ void vehicles_touch()
                if((self.origin_z + self.maxs_z) > (other.origin_z))
                if(vehicles_crushable(other))
                {
-                       if(vlen(self.velocity) != 0)
+                       if(vlen(self.velocity) >= 30)
                                Damage(other, self, self.owner, autocvar_g_vehicles_crush_dmg, DEATH_VH_CRUSH, '0 0 0', normalize(other.origin - self.origin) * autocvar_g_vehicles_crush_force);
 
                        return; // Dont do selfdamage when hitting "soft targets".
@@ -923,28 +926,18 @@ void vehicles_touch()
 void vehicles_enter(entity pl, entity veh)
 {
    // Remove this when bots know how to use vehicles
-       if (IS_BOT_CLIENT(pl))
-       if (autocvar_g_vehicles_allow_bots)
-               dprint("Bot enters vehicle\n"); // This is where we need to disconnect (some, all?) normal bot AI and hand over to vehicle's _aiframe()
-       else
-               return;
-
-       if(!IS_PLAYER(pl))
-               return;
-
-       if(veh.phase > time)
-               return;
-
-       if(pl.frozen)
+       if((IS_BOT_CLIENT(pl) && !autocvar_g_vehicles_allow_bots))
                return;
 
-       if(pl.deadflag != DEAD_NO)
-               return;
-
-       if(pl.vehicle)
-               return;
+       if((!IS_PLAYER(pl))
+       || (veh.phase >= time)
+       || (pl.vehicle_enter_delay >= time)
+       || (pl.frozen)
+       || (pl.deadflag != DEAD_NO)
+       || (pl.vehicle)
+       ) { return; }
 
-       if(autocvar_g_vehicles_enter) // skip if we're using regular touch code
+       if(autocvar_g_vehicles_enter) // vehicle's touch function should handle this if entering via use key is disabled (TODO)
        if(veh.vehicle_flags & VHF_MULTISLOT)
        if(veh.owner)
        {
@@ -953,7 +946,7 @@ void vehicles_enter(entity pl, entity veh)
                other = pl; // TODO: fix
 
                if(!veh.gunner1)
-               if(veh.gun1.phase <= time)
+               if(time >= veh.gun1.phase)
                if(veh.gun1.vehicle_enter)
                if(veh.gun1.vehicle_enter())
                {
@@ -962,7 +955,7 @@ void vehicles_enter(entity pl, entity veh)
                }
 
                if(!veh.gunner2)
-               if(veh.gun2.phase <= time)
+               if(time >= veh.gun2.phase)
                if(veh.gun2.vehicle_enter)
                if(veh.gun2.vehicle_enter())
                {
@@ -985,9 +978,9 @@ void vehicles_enter(entity pl, entity veh)
                Send_Notification(NOTIF_ONE, pl, MSG_CENTER, CENTER_VEHICLE_STEAL_SELF);
 
                if(autocvar_g_vehicles_steal_show_waypoint)
-                       WaypointSprite_Spawn("intruder", 0, 0, pl, '0 0 68', world, veh.team, veh, wps_intruder, TRUE, RADARICON_DANGER, Team_ColorRGB(pl.team));
+                       WaypointSprite_Spawn("intruder", 0, 0, pl, '0 0 68', world, veh.team, veh, wps_intruder, true, RADARICON_DANGER, Team_ColorRGB(pl.team));
        }
-       else return;
+       else { return; }
 
        RemoveGrapplingHook(pl);
 
@@ -1005,8 +998,8 @@ void vehicles_enter(entity pl, entity veh)
 
        veh.vehicle_hudmodel.viewmodelforclient = pl;
 
-       tracebox(pl.origin, PL_MIN, PL_MAX, pl.origin, FALSE, pl);
-       pl.crouch = FALSE;
+       tracebox(pl.origin, PL_MIN, PL_MAX, pl.origin, false, pl);
+       pl.crouch = false;
        pl.view_ofs = PL_VIEW_OFS;
        setsize (pl, PL_MIN, PL_MAX);
 
@@ -1016,7 +1009,7 @@ void vehicles_enter(entity pl, entity veh)
        pl.takedamage           = DAMAGE_NO;
        pl.solid                        = SOLID_NOT;
        pl.movetype                     = MOVETYPE_NOCLIP;
-       pl.teleportable         = FALSE;
+       pl.teleportable         = false;
        pl.alpha                        = -1;
        pl.event_damage         = func_null;
        pl.view_ofs                     = '0 0 0';
@@ -1105,14 +1098,14 @@ void vehicles_spawn()
        self.owner                              = world;
        self.touch                              = vehicles_touch;
        self.event_damage               = vehicles_damage;
-       self.iscreature                 = TRUE;
-       self.teleportable               = FALSE; // no teleporting for vehicles, too buggy
-       self.damagedbycontents  = TRUE;
+       self.iscreature                 = true;
+       self.teleportable               = false; // no teleporting for vehicles, too buggy
+       self.damagedbycontents  = true;
        self.movetype                   = MOVETYPE_WALK;
        self.solid                              = SOLID_SLIDEBOX;
        self.takedamage                 = DAMAGE_AIM;
        self.deadflag                   = DEAD_NO;
-       self.bot_attack                 = TRUE;
+       self.bot_attack                 = true;
        self.flags                              = FL_NOTARGET;
        self.avelocity                  = '0 0 0';
        self.velocity                   = '0 0 0';
@@ -1148,12 +1141,12 @@ void vehicles_spawn()
 float vehicle_initialize(float vehicle_id, float nodrop)
 {
        if(!autocvar_g_vehicles)
-               return FALSE;
+               return false;
 
        entity veh = get_vehicleinfo(vehicle_id);
 
        if(!veh.vehicleid)
-               return FALSE;
+               return false;
        
        if(!veh.tur_head) { VEH_ACTION(vehicle_id, VR_PRECACHE); }
 
@@ -1193,10 +1186,10 @@ float vehicle_initialize(float vehicle_id, float nodrop)
        self.tur_head                           = spawn();
        self.tur_head.owner                     = self;
        self.takedamage                         = DAMAGE_NO;
-       self.bot_attack                         = TRUE;
-       self.iscreature                         = TRUE;
-       self.teleportable                       = FALSE; // no teleporting for vehicles, too buggy
-       self.damagedbycontents          = TRUE;
+       self.bot_attack                         = true;
+       self.iscreature                         = true;
+       self.teleportable                       = false; // no teleporting for vehicles, too buggy
+       self.damagedbycontents          = true;
        self.vehicleid                          = vehicle_id;
        self.PlayerPhysplug                     = veh.PlayerPhysplug;
        self.event_damage                       = func_null;
@@ -1255,7 +1248,7 @@ float vehicle_initialize(float vehicle_id, float nodrop)
                self.nextthink = time + game_starttime;
 
        if(MUTATOR_CALLHOOK(VehicleSpawn))
-               return FALSE;
+               return false;
 
-       return TRUE;
+       return true;
 }