]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Some preparation for client side vehicles
authorMario <zacjardine@y7mail.com>
Thu, 23 Apr 2015 00:58:03 +0000 (10:58 +1000)
committerMario <zacjardine@y7mail.com>
Thu, 23 Apr 2015 00:58:03 +0000 (10:58 +1000)
qcsrc/common/vehicles/cl_vehicles.qc
qcsrc/common/vehicles/sv_vehicles.qc
qcsrc/common/vehicles/unit/racer.qc

index 8c4bd6044bfa7209befd6861e0d60cdaa60d2753..964a9dbe510923d8522a6436bdb0de40e0e3b4d0 100644 (file)
@@ -1,33 +1,33 @@
-#define hud_bg "gfx/vehicles/frame.tga"
-#define hud_sh "gfx/vehicles/vh-shield.tga"
+const string hud_bg = "gfx/vehicles/frame.tga";
+const string hud_sh = "gfx/vehicles/vh-shield.tga";
 
-#define hud_hp_bar "gfx/vehicles/bar_up_left.tga"
-#define hud_hp_ico "gfx/vehicles/health.tga"
-#define hud_sh_bar "gfx/vehicles/bar_dwn_left.tga"
-#define hud_sh_ico "gfx/vehicles/shield.tga"
+const string hud_hp_bar = "gfx/vehicles/bar_up_left.tga";
+const string hud_hp_ico = "gfx/vehicles/health.tga";
+const string hud_sh_bar = "gfx/vehicles/bar_dwn_left.tga";
+const string hud_sh_ico = "gfx/vehicles/shield.tga";
 
-#define hud_ammo1_bar "gfx/vehicles/bar_up_right.tga"
-#define hud_ammo1_ico "gfx/vehicles/bullets.tga"
-#define hud_ammo2_bar "gfx/vehicles/bar_dwn_right.tga"
-#define hud_ammo2_ico "gfx/vehicles/rocket.tga"
-#define hud_energy "gfx/vehicles/energy.tga"
+const string hud_ammo1_bar = "gfx/vehicles/bar_up_right.tga";
+const string hud_ammo1_ico = "gfx/vehicles/bullets.tga";
+const string hud_ammo2_bar = "gfx/vehicles/bar_dwn_right.tga";
+const string hud_ammo2_ico = "gfx/vehicles/rocket.tga";
+const string hud_energy = "gfx/vehicles/energy.tga";
 
 entity dropmark;
 float autocvar_cl_vehicles_hudscale = 0.5;
 float autocvar_cl_vehicles_hudalpha = 0.75;
 
-const float MAX_AXH = 4;
+const int MAX_AXH = 4;
 entity AuxiliaryXhair[MAX_AXH];
 
 .string axh_image;
 .float  axh_fadetime;
-.float  axh_drawflag;
+.int    axh_drawflag;
 .float  axh_scale;
 
 float alarm1time;
 float alarm2time;
 
-void vehicle_alarm(entity e, float ch, string s0und)
+void vehicle_alarm(entity e, int ch, string s0und)
 {
        if(!autocvar_cl_vehicles_alarm)
                return;
@@ -82,9 +82,8 @@ void Net_AuXair2(bool bIsNew)
 
 void Net_VehicleSetup()
 {
-       float i;
-
-       float hud_id = ReadByte();
+       int i;
+       int hud_id = ReadByte();
 
        // hud_id == 0 means we exited a vehicle, so stop alarm sound/s
        if(hud_id == 0)
@@ -124,3 +123,43 @@ void Net_VehicleSetup()
        }
        else { VEH_ACTION(hud_id, VR_SETUP); }
 }
+
+#if 0
+.bool veh_precached;
+void ent_vehicle()
+{
+       int sf = ReadByte();
+
+       if(sf & VSF_SPAWN)
+       {
+               self.vehicleid = ReadByte();
+               VEH_ACTION(self.vehicleid, VR_SPAWN);
+       }
+
+       if(sf & VSF_SETUP)
+       {
+               VEH_ACTION(self.vehicleid, VR_SETUP);
+       }
+
+       if(sf & VSF_ENTER)
+       {
+               // player handles the .vehicle stuff, we need only set ourselves up for driving
+
+               VEH_ACTION(self.vehicleid, VR_ENTER);
+       }
+
+       if(sf & VSF_EXIT)
+       {
+               VEH_ACTION(self.vehicleid, VR_EXIT);
+       }
+
+       if(sf & VSF_PRECACHE)
+       {
+               if(!get_vehicleinfo(self.vehicleid).veh_precached)
+               {
+                       (get_vehicleinfo(self.vehicleid)).veh_precached = true;
+                       VEH_ACTION(self.vehicleid, VR_PRECACHE);
+               }
+       }
+}
+#endif
index 792b2127d2cc382eb020d637a72309b642bbccfc..d4be5bce490ea9a660c3dd346f10934b9c6fa673 100644 (file)
@@ -3,7 +3,44 @@
 #include "sv_vehicles.qh"
 #include "../../server/jeff.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);
@@ -21,7 +58,7 @@ float SendAuxiliaryXhair(entity to, float sf)
        return true;
 }
 
-void UpdateAuxiliaryXhair(entity own, vector loc, vector clr, float axh_id)
+void UpdateAuxiliaryXhair(entity own, vector loc, vector clr, int axh_id)
 {
        if(!IS_REAL_CLIENT(own))
                return;
@@ -46,7 +83,7 @@ void UpdateAuxiliaryXhair(entity own, vector loc, vector clr, float axh_id)
        own.(AuxiliaryXhair[axh_id]) = axh;
 }
 
-void CSQCVehicleSetup(entity own, float vehicle_id)
+void CSQCVehicleSetup(entity own, int vehicle_id)
 {
        if(!IS_REAL_CLIENT(own))
                return;
@@ -61,7 +98,7 @@ void CSQCVehicleSetup(entity own, float vehicle_id)
 vector targetdrone_getnewspot()
 {
        vector spot;
-       float i;
+       int i;
        for(i = 0; i < 100; ++i)
        {
                spot = self.origin + randomvec() * 1024;
@@ -178,7 +215,7 @@ vector vehicles_force_fromtag_maglev(string tag_name, float spring_length, float
 }
 
 // projectile handling
-void vehicles_projectile_damage(entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
+void vehicles_projectile_damage(entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force)
 {
        // Ignore damage from oterh projectiles from my owner (dont mess up volly's)
        if(inflictor.owner == self.owner)
@@ -217,8 +254,8 @@ void vehicles_projectile_explode()
 entity vehicles_projectile(int _mzlfx, string _mzlsound,
                                                   vector _org, vector _vel,
                                                   float _dmg, float _radi, float _force,  float _size,
-                                                  float _deahtype, float _projtype, float _health,
-                                                  float _cull, float _clianim, entity _owner)
+                                                  int _deahtype, float _projtype, float _health,
+                                                  bool _cull, bool _clianim, entity _owner)
 {
        entity proj;
 
@@ -283,7 +320,7 @@ void vehicles_gib_think()
                self.nextthink = time + 0.1;
 }
 
-entity vehicle_tossgib(entity _template, vector _vel, string _tag, float _burn, float _explode, float _maxtime, vector _rot)
+entity vehicle_tossgib(entity _template, vector _vel, string _tag, bool _burn, bool _explode, float _maxtime, vector _rot)
 {
        entity _gib = spawn();
        setmodel(_gib, _template.model);
@@ -314,12 +351,12 @@ entity vehicle_tossgib(entity _template, vector _vel, string _tag, float _burn,
        return _gib;
 }
 
-float vehicle_addplayerslot(   entity _owner,
+bool vehicle_addplayerslot(    entity _owner,
                                                                entity _slot,
-                                                               float _hud,
+                                                               int _hud,
                                                                string _hud_model,
-                                                               float() _framefunc,
-                                                               void(float) _exitfunc, float() _enterfunc)
+                                                               bool() _framefunc,
+                                                               void(bool) _exitfunc, float() _enterfunc)
 {
        if(!(_owner.vehicle_flags & VHF_MULTISLOT))
                _owner.vehicle_flags |= VHF_MULTISLOT;
@@ -613,7 +650,7 @@ void vehicles_painframe()
        }
 }
 
-void vehicles_damage(entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
+void vehicles_damage(entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force)
 {
        self.dmg_time = time;
 
@@ -788,7 +825,7 @@ vector vehicles_findgoodexit(vector prefer_spot)
        return self.origin;
 }
 
-void vehicles_exit(float eject)
+void vehicles_exit(bool eject)
 {
        entity _vehicle;
        entity _player;
@@ -1141,7 +1178,7 @@ void vehicles_spawn()
        CSQCMODEL_AUTOINIT();
 }
 
-float vehicle_initialize(float vehicle_id, float nodrop)
+bool vehicle_initialize(int vehicle_id, bool nodrop)
 {
        if(!autocvar_g_vehicles)
                return false;
index 837000329fbcae461dc9b6324e6611ceab765981..0d948fdc6e430032976d1de7a92deea7c89336b8 100644 (file)
@@ -646,62 +646,82 @@ void spawnfunc_vehicle_racer()
        if(!vehicle_initialize(VEH_RACER, false)) { remove(self); return; }
 }
 
-float v_racer(float req)
+#endif // SVQC
+
+#ifdef CSQC
+const string waki_ico = "gfx/vehicles/waki.tga";
+const string waki_eng = "gfx/vehicles/waki_e.tga";
+const string waki_gun = "gfx/vehicles/waki_guns.tga";
+const string waki_rkt = "gfx/vehicles/waki_rockets.tga";
+const string waki_xhair = "gfx/vehicles/axh-special1.tga";
+
+#if 0
+void racer_draw()
+{
+       float pushdeltatime = time - self.lastpushtime;
+       if (pushdeltatime > 0.15) pushdeltatime = 0;
+       self.lastpushtime = time;
+       if(!pushdeltatime) return;
+
+       tracebox(self.move_origin, self.mins, self.maxs, self.move_origin - ('0 0 1' * getstatf(STAT_VEH_RACER_SPRINGLENGTH)), MOVE_NOMONSTERS, self);
+
+       vector df = self.move_velocity * -getstatf(STAT_VEH_RACER_FRICTION);
+       df_z += (1 - trace_fraction) * getstatf(STAT_VEH_RACER_HOVERPOWER) + sin(time * 2) * (getstatf(STAT_VEH_RACER_SPRINGLENGTH) * 2);
+
+       float forced = getstatf(STAT_VEH_RACER_UPFORCEDAMPER);
+
+       int cont = pointcontents(self.move_origin - '0 0 64');
+       if(cont == CONTENT_WATER || cont == CONTENT_LAVA || cont == CONTENT_SLIME)
+       {
+               forced = getstatf(STAT_VEH_RACER_WATER_UPFORCEDAMPER);
+               self.move_velocity_z += 200;
+       }
+
+       self.move_velocity += df * pushdeltatime;
+       if(self.move_velocity_z > 0)
+               self.move_velocity_z *= 1 - forced * pushdeltatime;
+
+       self.move_angles_x *= 1 - (getstatf(STAT_VEH_RACER_ANGLESTABILIZER) * pushdeltatime);
+       self.move_angles_z *= 1 - (getstatf(STAT_VEH_RACER_ANGLESTABILIZER) * pushdeltatime);
+       
+       Movetype_Physics_MatchServer(false);
+}
+#endif
+#endif
+
+bool v_racer(int req)
 {
        switch(req)
        {
                case VR_IMPACT:
                {
+               #ifdef SVQC
                        if(autocvar_g_vehicle_racer_bouncepain)
                                vehicles_impact(autocvar_g_vehicle_racer_bouncepain_x, autocvar_g_vehicle_racer_bouncepain_y, autocvar_g_vehicle_racer_bouncepain_z);
+               #endif
                        return true;
                }
+
                case VR_ENTER:
                {
+               #ifdef SVQC
                        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;
 
                        if(self.owner.flagcarried)
                           setorigin(self.owner.flagcarried, '-190 0 96');
+               #elif defined(CSQC)
+
+                       self.move_movetype = MOVETYPE_BOUNCE;
+               #endif
                           
                        return true;
                }
-               case VR_THINK:
-               {
-                       return true;
-               }
-               case VR_DEATH:
-               {
-                       self.health                     = 0;
-                       self.event_damage       = func_null;
-                       self.solid                      = SOLID_CORPSE;
-                       self.takedamage         = DAMAGE_NO;
-                       self.deadflag           = DEAD_DYING;
-                       self.movetype           = MOVETYPE_BOUNCE;
-                       self.wait                       = time;
-                       self.delay                      = 2 + time + random() * 3;
-                       self.cnt                        = 1 + random() * 2;
-                       self.touch                      = racer_deadtouch;
 
-                       Send_Effect(EFFECT_EXPLOSION_MEDIUM, self.origin, '0 0 0', 1);
-
-                       if(random() < 0.5)
-                               self.avelocity_z = 32;
-                       else
-                               self.avelocity_z = -32;
-
-                       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_think;
-                       self.nextthink = time;
-       
-                       return true;
-               }
                case VR_SPAWN:
                {
+               #ifdef SVQC
                        if(self.scale != 0.5)
                        {
                                if(autocvar_g_vehicle_racer_hovertype != 0)
@@ -734,64 +754,43 @@ float v_racer(float req)
                        self.damageforcescale = 0.5;
                        self.vehicle_health = autocvar_g_vehicle_racer_health;
                        self.vehicle_shield = autocvar_g_vehicle_racer_shield;
-                       
+               #endif
                        return true;
                }
-               case VR_SETUP:
-               {
-                       if(autocvar_g_vehicle_racer_energy)
-                       if(autocvar_g_vehicle_racer_energy_regen)
-                               self.vehicle_flags |= VHF_ENERGYREGEN;
 
-                       if(autocvar_g_vehicle_racer_shield)
-                               self.vehicle_flags |= VHF_HASSHIELD;
+               case VR_DEATH:
+               {
+               #ifdef SVQC
+                       self.SendEntity         = func_null; // stop networking this racer (for now)
+                       self.health                     = 0;
+                       self.event_damage       = func_null;
+                       self.solid                      = SOLID_CORPSE;
+                       self.takedamage         = DAMAGE_NO;
+                       self.deadflag           = DEAD_DYING;
+                       self.movetype           = MOVETYPE_BOUNCE;
+                       self.wait                       = time;
+                       self.delay                      = 2 + time + random() * 3;
+                       self.cnt                        = 1 + random() * 2;
+                       self.touch                      = racer_deadtouch;
 
-                       if(autocvar_g_vehicle_racer_shield_regen)
-                               self.vehicle_flags |= VHF_SHIELDREGEN;
+                       Send_Effect(EFFECT_EXPLOSION_MEDIUM, self.origin, '0 0 0', 1);
 
-                       if(autocvar_g_vehicle_racer_health_regen)
-                               self.vehicle_flags |= VHF_HEALTHREGEN;
-                               
-                       self.vehicle_exit = racer_exit;
-                       self.respawntime = autocvar_g_vehicle_racer_respawntime;
-                       self.vehicle_health = autocvar_g_vehicle_racer_health;
-                       self.vehicle_shield = autocvar_g_vehicle_racer_shield;
-                       self.max_health = self.vehicle_health;
-                               
-                       return true;
-               }
-               case VR_PRECACHE:
-               {
-                       precache_sound (W_Sound("lasergun_fire"));
-                       precache_sound (W_Sound("rocket_fire"));
+                       if(random() < 0.5)
+                               self.avelocity_z = 32;
+                       else
+                               self.avelocity_z = -32;
 
-                       precache_sound ("vehicles/racer_idle.wav");
-                       precache_sound ("vehicles/racer_move.wav");
-                       precache_sound ("vehicles/racer_boost.wav");
+                       self.avelocity_x = -vlen(self.velocity) * 0.2;
+                       self.velocity += '0 0 700';
+                       self.colormod = '-0.5 -0.5 -0.5';
 
-                       precache_model ("models/vhshield.md3");
-                       precache_model ("models/vehicles/wakizashi.dpm");
-                       precache_model ("models/vehicles/wakizashi_cockpit.dpm");
+                       self.think = racer_blowup_think;
+                       self.nextthink = time;
+               #endif
                        return true;
                }
-       }
 
-       return true;
-}
-
-#endif // SVQC
 #ifdef CSQC
-
-#define waki_ico "gfx/vehicles/waki.tga"
-#define waki_eng "gfx/vehicles/waki_e.tga"
-#define waki_gun "gfx/vehicles/waki_guns.tga"
-#define waki_rkt "gfx/vehicles/waki_rockets.tga"
-#define waki_xhair "gfx/vehicles/axh-special1.tga"
-
-float v_racer(float req)
-{
-       switch(req)
-       {
                case VR_HUD:
                {
                        if(autocvar_r_letterbox)
@@ -923,14 +922,56 @@ float v_racer(float req)
                        }
                        return true;
                }
+#endif
                case VR_SETUP:
                {
+               #ifdef SVQC
+                       self.vehicle_exit = racer_exit;
+               #endif
+
+               #ifdef SVQC
+                       // we have no need to network energy
+                       if(autocvar_g_vehicle_racer_energy)
+                       if(autocvar_g_vehicle_racer_energy_regen)
+                               self.vehicle_flags |= VHF_ENERGYREGEN;
+
+                       if(autocvar_g_vehicle_racer_shield)
+                               self.vehicle_flags |= VHF_HASSHIELD;
+
+                       if(autocvar_g_vehicle_racer_shield_regen)
+                               self.vehicle_flags |= VHF_SHIELDREGEN;
+
+                       if(autocvar_g_vehicle_racer_health_regen)
+                               self.vehicle_flags |= VHF_HEALTHREGEN;
+
+                       self.respawntime = autocvar_g_vehicle_racer_respawntime;
+                       self.vehicle_health = autocvar_g_vehicle_racer_health;
+                       self.vehicle_shield = autocvar_g_vehicle_racer_shield;
+                       self.max_health = self.vehicle_health;
+               #endif
+
+               #ifdef CSQC
                        AuxiliaryXhair[0].axh_image = "gfx/vehicles/axh-bracket.tga";
                        AuxiliaryXhair[0].axh_scale = 0.25;
+               #endif
                        return true;
                }
+
                case VR_PRECACHE:
                {
+               #ifdef SVQC
+                       precache_sound (W_Sound("lasergun_fire"));
+                       precache_sound (W_Sound("rocket_fire"));
+
+                       precache_sound ("vehicles/racer_idle.wav");
+                       precache_sound ("vehicles/racer_move.wav");
+                       precache_sound ("vehicles/racer_boost.wav");
+
+                       precache_model ("models/vhshield.md3");
+               #endif
+
+                       precache_model ("models/vehicles/wakizashi.dpm");
+                       precache_model ("models/vehicles/wakizashi_cockpit.dpm");
                        return true;
                }
        }
@@ -938,5 +979,4 @@ float v_racer(float req)
        return true;
 }
 
-#endif // CSQC
 #endif // REGISTER_VEHICLE