]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/vehicles/sv_vehicles.qc
Merge branch 'master' into terencehill/slider_anim_improvements
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / vehicles / sv_vehicles.qc
index 58d2dd47cdbdbf9275e549e689f3fcb710c7888c..523156006d9c9067315533bb68a34c7fa67430a8 100644 (file)
@@ -1,7 +1,44 @@
-#include "vehicles.qh"
 #include "sv_vehicles.qh"
+#include "../effects.qh"
 
-float SendAuxiliaryXhair(entity to, float sf)
+#if 0
+bool vehicle_send(entity to, int sf)
+{
+       WriteByte(MSG_ENTITY, ENT_CLIENT_VEHICLE);
+       WriteByte(MSG_ENTITY, sf);
+
+       if(sf & VSF_SPAWN)
+       {
+               WriteByte(MSG_ENTITY, self.vehicleid);
+       }
+
+       if(sf & VSF_SETUP)
+       {
+               // send stuff?
+       }
+
+       if(sf & VSF_ENTER)
+       {
+               // player handles the .vehicle stuff, we need only set ourselves up for driving
+
+               // send stuff?
+       }
+
+       if(sf & VSF_EXIT)
+       {
+               // senf stuff?
+       }
+
+       if(sf & VSF_PRECACHE)
+       {
+               // send stuff?!
+       }
+
+       return true;
+}
+#endif
+
+bool SendAuxiliaryXhair(entity to, int sf)
 {
 
        WriteByte(MSG_ENTITY, ENT_CLIENT_AUXILIARYXHAIR);
@@ -99,7 +136,7 @@ void vehicles_locktarget(float incr, float decr, float _lock_time)
                if(trace_ent.deadflag != DEAD_NO)
                        trace_ent = world;
 
-               if(!((trace_ent.vehicle_flags & VHF_ISVEHICLE) || (trace_ent.turrcaps_flags & TFL_TURRCAPS_ISTURRET)))
+               if(!(IS_VEHICLE(trace_ent) || IS_TURRET(trace_ent)))
                        trace_ent = world;
 
                if(trace_ent.alpha <= 0.5 && trace_ent.alpha != 0)
@@ -255,8 +292,7 @@ entity vehicles_projectile(string _mzlfx, string _mzlsound,
                sound (self, CH_WEAPON_A, _mzlsound, VOL_BASE, ATTEN_NORM);
 
        if(_mzlfx)
-               pointparticles(particleeffectnum(_mzlfx), proj.origin, proj.velocity, 1);
-
+               Send_Effect_(_mzlfx, proj.origin, proj.velocity, 1);
 
        setsize (proj, '-1 -1 -1' * _size, '1 1 1' * _size);
 
@@ -267,9 +303,9 @@ entity vehicles_projectile(string _mzlfx, string _mzlsound,
 
 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);
+       sound (self, CH_SHOTS, W_Sound("rocket_impact"), VOL_BASE, ATTEN_NORM);
+       Send_Effect(EFFECT_EXPLOSION_SMALL, randomvec() * 80 + (self.origin + '0 0 100'), '0 0 0', 1);
+       Send_Effect(EFFECT_EXPLOSION_SMALL, self.wp00.origin + '0 0 64', '0 0 0', 1);
        remove(self);
 }
 
@@ -443,7 +479,7 @@ void vehicles_clearreturn(entity veh)
 void vehicles_spawn();
 void vehicles_return()
 {
-       pointparticles(particleeffectnum("teleport"), self.wp00.origin + '0 0 64', '0 0 0', 1);
+       Send_Effect(EFFECT_TELEPORT, self.wp00.origin + '0 0 64', '0 0 0', 1);
 
        self.wp00.think  = vehicles_spawn;
        self.wp00.nextthink = time;
@@ -493,7 +529,8 @@ 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);
+       entity wp = WaypointSprite_Spawn(WP_Vehicle, 0, 0, self, '0 0 64', world, 0, self, waypointsprite_attached, true, RADARICON_POWERUP);
+       wp.colormod = rgb;
        if(self.waypointsprite_attached)
        {
                WaypointSprite_UpdateRule(self.waypointsprite_attached, self.wp00.team, SPRITERULE_DEFAULT);
@@ -535,7 +572,7 @@ void vehicles_setreturn(entity veh)
 
 void vehicle_use()
 {
-       dprint("vehicle ",self.netname, " used by ", activator.classname, "\n");
+       LOG_TRACE("vehicle ",self.netname, " used by ", activator.classname, "\n");
 
        self.tur_head.team = activator.team;
 
@@ -546,7 +583,7 @@ void vehicle_use()
 
        if(self.active == ACTIVE_ACTIVE && self.deadflag == DEAD_NO && !gameover)
        {
-               dprint("Respawning vehicle: ", self.netname, "\n");
+               LOG_TRACE("Respawning vehicle: ", self.netname, "\n");
                if(self.effects & EF_NODRAW)
                {
                        self.think = vehicles_spawn;
@@ -598,7 +635,7 @@ void vehicles_painframe()
                float _ftmp;
                _ftmp = self.owner.vehicle_health / 50;
                self.pain_frame = time + 0.1 + (random() * 0.5 * _ftmp);
-               pointparticles(particleeffectnum("smoke_small"), (self.origin + (randomvec() * 80)), '0 0 0', 1);
+               pointparticles(particleeffectnum(EFFECT_SMOKE_SMALL), (self.origin + (randomvec() * 80)), '0 0 0', 1);
 
                if(self.vehicle_flags & VHF_DMGSHAKE)
                        self.velocity += randomvec() * 30;
@@ -617,19 +654,19 @@ void vehicles_damage(entity inflictor, entity attacker, float damage, int deatht
        self.dmg_time = time;
 
        // WEAPONTODO
-       if(DEATH_ISWEAPON(deathtype, WEP_VORTEX))
+       if(DEATH_ISWEAPON(deathtype, WEP_VORTEX.m_id))
                damage *= autocvar_g_vehicles_vortex_damagerate;
 
-       if(DEATH_ISWEAPON(deathtype, WEP_MACHINEGUN))
+       if(DEATH_ISWEAPON(deathtype, WEP_MACHINEGUN.m_id))
                damage *= autocvar_g_vehicles_machinegun_damagerate;
 
-       if(DEATH_ISWEAPON(deathtype, WEP_RIFLE))
+       if(DEATH_ISWEAPON(deathtype, WEP_RIFLE.m_id))
                damage *= autocvar_g_vehicles_rifle_damagerate;
 
-       if(DEATH_ISWEAPON(deathtype, WEP_VAPORIZER))
+       if(DEATH_ISWEAPON(deathtype, WEP_VAPORIZER.m_id))
                damage *= autocvar_g_vehicles_vaporizer_damagerate;
 
-       if(DEATH_ISWEAPON(deathtype, WEP_SEEKER))
+       if(DEATH_ISWEAPON(deathtype, WEP_SEEKER.m_id))
                damage *= autocvar_g_vehicles_tag_damagerate;
 
        if(DEATH_WEAPONOFWEAPONDEATH(deathtype))
@@ -710,7 +747,7 @@ float vehicles_crushable(entity e)
        if(IS_PLAYER(e) && time >= e.vehicle_enter_delay)
                return true;
 
-       if(e.flags & FL_MONSTER)
+       if(IS_MONSTER(e))
                return true;
 
        return false;
@@ -795,7 +832,7 @@ void vehicles_exit(bool eject)
 
        if(vehicles_exit_running)
        {
-               dprint("^1vehicles_exit allready running! this is not good..\n");
+               LOG_TRACE("^1vehicles_exit allready running! this is not good..\n");
                return;
        }
 
@@ -867,11 +904,7 @@ void vehicles_exit(bool eject)
 
        WaypointSprite_Kill(_vehicle.wps_intruder);
 
-       vh_player = _player;
-       vh_vehicle = _vehicle;
-       MUTATOR_CALLHOOK(VehicleExit);
-       _player = vh_player;
-       _vehicle = vh_vehicle;
+       MUTATOR_CALLHOOK(VehicleExit, _player, _vehicle);
 
        _vehicle.team = _vehicle.tur_head.team;
 
@@ -894,7 +927,7 @@ void vehicles_exit(bool eject)
 
 void vehicles_touch()
 {
-       if(MUTATOR_CALLHOOK(VehicleTouch))
+       if(MUTATOR_CALLHOOK(VehicleTouch, self, other))
                return;
 
        // Vehicle currently in use
@@ -923,6 +956,20 @@ void vehicles_touch()
        vehicles_enter(other, self);
 }
 
+bool vehicle_impulse(int imp)
+{
+       switch(imp)
+       {
+               case 17:
+               {
+                       stuffcmd(self, "\ntoggle cl_eventchase_vehicle\nset _vehicles_shownchasemessage 1\n");
+                       return true;
+               }
+       }
+
+       return false;
+}
+
 void vehicles_enter(entity pl, entity veh)
 {
    // Remove this when bots know how to use vehicles
@@ -977,8 +1024,10 @@ 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));
+               if (autocvar_g_vehicles_steal_show_waypoint) {
+                       entity wp = WaypointSprite_Spawn(WP_VehicleIntruder, 0, 0, pl, '0 0 68', world, veh.team, veh, wps_intruder, true, RADARICON_DANGER);
+                       wp.colormod = Team_ColorRGB(pl.team);
+               }
        }
        else return;
 
@@ -1024,6 +1073,7 @@ void vehicles_enter(entity pl, entity veh)
        pl.vehicle_ammo2 = veh.vehicle_ammo2;
        pl.vehicle_reload1 = veh.vehicle_reload1;
        pl.vehicle_reload2 = veh.vehicle_reload2;
+       pl.vehicle_energy = veh.vehicle_energy;
 
        // Cant do this, hides attached objects too.
        //veh.exteriormodeltoclient = veh.owner;
@@ -1062,9 +1112,7 @@ void vehicles_enter(entity pl, entity veh)
 
        CSQCVehicleSetup(pl, veh.vehicleid);
 
-       vh_player = pl;
-       vh_vehicle = veh;
-       MUTATOR_CALLHOOK(VehicleEnter);
+       MUTATOR_CALLHOOK(VehicleEnter, pl, veh);
 
        entity oldself = self;
        self = veh;
@@ -1078,10 +1126,10 @@ void vehicles_enter(entity pl, entity veh)
 void vehicles_think()
 {
        self.nextthink = time;
-       
+
        if(self.owner)
                self.owner.vehicle_weapon2mode = self.vehicle_weapon2mode;
-       
+
        VEH_ACTION(self.vehicleid, VR_THINK);
 
        CSQCMODEL_AUTOUPDATE();
@@ -1090,7 +1138,7 @@ void vehicles_think()
 // initialization
 void vehicles_spawn()
 {
-       dprint("Spawning vehicle: ", self.classname, "\n");
+       LOG_TRACE("Spawning vehicle: ", self.classname, "\n");
 
        // disown & reset
        self.vehicle_hudmodel.viewmodelforclient = self;
@@ -1121,7 +1169,7 @@ void vehicles_spawn()
        self.angles = self.pos2;
        setorigin(self, self.pos1);
        // Show it
-       pointparticles(particleeffectnum("teleport"), self.origin + '0 0 64', '0 0 0', 1);
+       Send_Effect(EFFECT_TELEPORT, self.origin + '0 0 64', '0 0 0', 1);
 
        if(self.vehicle_controller)
                self.team = self.vehicle_controller.team;
@@ -1138,17 +1186,15 @@ void vehicles_spawn()
        CSQCMODEL_AUTOINIT();
 }
 
-bool vehicle_initialize(int vehicle_id, bool nodrop)
+bool vehicle_initialize(entity veh, bool nodrop)
 {
        if(!autocvar_g_vehicles)
                return false;
 
-       entity veh = get_vehicleinfo(vehicle_id);
-
        if(!veh.vehicleid)
                return false;
-       
-       if(!veh.tur_head) { VEH_ACTION(vehicle_id, VR_PRECACHE); }
+
+       if(!veh.tur_head) { VEH_ACTION(veh.vehicleid, VR_PRECACHE); }
 
        if(self.targetname && self.targetname != "")
        {
@@ -1177,9 +1223,12 @@ bool vehicle_initialize(int vehicle_id, bool nodrop)
        if(self.team && (!teamplay || !autocvar_g_vehicles_teams))
                self.team = 0;
 
-       self.vehicle_flags |= VHF_ISVEHICLE;
+       if(self.mdl == "" || !self.mdl)
+               setmodel(self, veh.model);
+       else
+               setmodel(self, self.mdl);
 
-       setmodel(self, veh.model);
+       self.vehicle_flags |= VHF_ISVEHICLE;
 
        self.vehicle_viewport           = spawn();
        self.vehicle_hudmodel           = spawn();
@@ -1190,7 +1239,7 @@ bool vehicle_initialize(int vehicle_id, bool nodrop)
        self.iscreature                         = true;
        self.teleportable                       = false; // no teleporting for vehicles, too buggy
        self.damagedbycontents          = true;
-       self.vehicleid                          = vehicle_id;
+       self.vehicleid                          = veh.vehicleid;
        self.PlayerPhysplug                     = veh.PlayerPhysplug;
        self.event_damage                       = func_null;
        self.touch                                      = vehicles_touch;
@@ -1238,7 +1287,7 @@ bool vehicle_initialize(int vehicle_id, bool nodrop)
        self.pos2 = self.angles;
        self.tur_head.team = self.team;
 
-       VEH_ACTION(vehicle_id, VR_SETUP);
+       VEH_ACTION(veh.vehicleid, VR_SETUP);
 
        if(self.active == ACTIVE_NOT)
                self.nextthink = 0; // wait until activated