]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Begin csqc vehicles framework (not functional or used yet). Add some comments. Spawn...
authorJakob MG <jakob_mg@hotmail.com>
Fri, 8 Apr 2011 03:56:09 +0000 (05:56 +0200)
committerJakob MG <jakob_mg@hotmail.com>
Fri, 8 Apr 2011 03:56:09 +0000 (05:56 +0200)
qcsrc/client/Main.qc
qcsrc/client/damage.qc
qcsrc/client/vehicles/vehicles.qc
qcsrc/common/constants.qh
qcsrc/server/vehicles/vehicles.qc
qcsrc/server/vehicles/vehicles_def.qh

index db1b9b3a9e3e8e84a6aaf3c5374cc94c6a6d972c..3e9f73305fbd5eef3b2d0423060db6af34c6568c 100644 (file)
@@ -970,7 +970,7 @@ void(float bIsNewEntity) CSQC_Ent_Update =
                case ENT_CLIENT_GAUNTLET: Ent_ReadHook(bIsNewEntity, ENT_CLIENT_GAUNTLET); break;
                case ENT_CLIENT_ACCURACY: Ent_ReadAccuracy(); break;
                case ENT_CLIENT_AUXILIARYXHAIR: Net_AuXair2(bIsNewEntity); break;
-               case ENT_CLIENT_VEHICLE_RACER: Net_VehicleRacer(bIsNewEntity); break;
+               case ENT_CLIENT_VEHICLE: Net_Vehicle(bIsNewEntity); break;
                default:
                        error(strcat(_("unknown entity type in CSQC_Ent_Update: %d\n"), self.enttype));
                        break;
index 6aad2e57fc567eb8e1bb4ec3fa3ecfa8dfd8818d..cd338553adaec3830f4fb2489bc3524674339f10 100644 (file)
@@ -120,7 +120,7 @@ void Ent_DamageInfo(float isNew)
             case DEATH_RAPTOR_BOMB_SPLIT:
                 float i;
                 vector ang, vel;
-                for(i = 1; i <= 4; ++i)
+                for(i = 1; i < 4; ++i)
                 {
                     vel = normalize(w_org - (w_org + normalize(force) * 16)) + randomvec() * 128;
                     ang = vectoangles(vel);
index 14949e94051a4522e12a51622f4aa120275362d7..20d3fab75e954ad83710a9c114dd894166fad8aa 100644 (file)
@@ -57,6 +57,10 @@ void AuxiliaryXhair_Draw2D()
         self.draw2d = Draw_Not;
 }
 
+void Net_Vehicle(float IsNew)
+{
+    //entnum
+}
 
 void Net_AuXair2(float bIsNew)
 {
@@ -476,6 +480,7 @@ void RaptorCBShellfragDraw()
 
        self.move_avelocity += randomvec() * 15;
        self.renderflags = 0;
+       if(self.cnt < time)
        self.alpha = bound(0, self.nextthink - time, 1);
 
        if(self.alpha < ALPHA_MIN_VISIBLE)
@@ -504,7 +509,8 @@ void RaptorCBShellfragToss(vector _org, vector _vel, vector _ang)
        sfrag.move_time = time;
        sfrag.damageforcescale = 4;
 
-       sfrag.nextthink = time + 2 * (1 + prandom() * 2);
+       sfrag.nextthink = time + 3;
+       sfrag.cnt = time + 2;
     sfrag.drawmask = MASK_NORMAL;
     
     
index 93ace6f5f8ec836c4c180a09994349b397a98914..c56bda74ce6f3c9d6ebf2c1f7b2d881d82984aed 100644 (file)
@@ -117,7 +117,7 @@ const float ENT_CLIENT_ACCURACY = 30;
 
 const float ENT_CLIENT_TURRET = 40;
 const float ENT_CLIENT_AUXILIARYXHAIR = 50;
-const float ENT_CLIENT_VEHICLE_RACER = 60;
+const float ENT_CLIENT_VEHICLE = 60;
 
 const float SPRITERULE_DEFAULT = 0;
 const float SPRITERULE_TEAMPLAY = 1;
index ad5b006e3a1d23feb5273062297bf8ed03012be8..644411fc6f78fd57a9dea42a3b223aef067b416a 100644 (file)
@@ -10,7 +10,10 @@ void vehicles_clearrturn();
 void vehicles_setreturn();
 
 
-#define MAX_AXH 4
+/** AuxiliaryXhair* 
+    Send addictional points of interest to be drawn, to vehicle owner
+**/
+float MAX_AXH = 4;
 .entity AuxiliaryXhair[MAX_AXH];
 
 float SendAuxiliaryXhair(entity to, float sf)
@@ -75,6 +78,7 @@ void SendAuxiliaryXhair2(entity own, vector loc, vector clr, float axh_id)
 
 }
 */
+// End AuxiliaryXhair
 
 void CSQCVehicleSetup(entity own, float vehicle_id)
 {
@@ -85,6 +89,19 @@ void CSQCVehicleSetup(entity own, float vehicle_id)
        WriteByte(MSG_ONE, vehicle_id);
 }
 
+/** vehicles_locktarget
+    
+    Generic target locking.
+    
+    Figure out if what target is "locked" (if any), for missile tracking as such.
+    
+    after calling, "if(self.lock_target != world && self.lock_strength == 1)" mean
+    you have a locked in target.
+    
+    Exspects a crosshair_trace() or equivalent to be
+    dont before calling.
+    
+**/
 .entity lock_target;
 .float  lock_strength;
 .float  lock_time;
@@ -143,6 +160,7 @@ traceline(orig, orig + vel * dt, MOVE_NORMAL, self); \
 if(trace_fraction != 1) \
     acm += normalize(self.origin - trace_endpos) * (vlen(vel) * mult)
 
+// Hover movement support
 float  force_fromtag_power;
 float  force_fromtag_normpower;
 vector force_fromtag_origin;
@@ -158,6 +176,8 @@ vector vehicles_force_fromtag_hover(string tag_name, float spring_length, float
     return v_forward  * force_fromtag_power;
 }
 
+// Experimental hovermode wich uses attraction/repulstion from surface unsted of gravity/repulsion
+// Can possibly be use to move abt any surface (inclusing walls/celings)
 vector vehicles_force_fromtag_maglev(string tag_name, float spring_length, float max_power)
 {
 
@@ -165,6 +185,7 @@ vector vehicles_force_fromtag_maglev(string tag_name, float spring_length, float
     v_forward  = normalize(v_forward) * -1;
     traceline(force_fromtag_origin, force_fromtag_origin - (v_forward  * spring_length), MOVE_NORMAL, self);
 
+    // TODO - this may NOT be compatible with wall/celing movement, unhardcode 0.25 (engine count multiplier)
     if(trace_fraction == 1.0)
     {
         force_fromtag_normpower = -0.25;
@@ -177,6 +198,7 @@ vector vehicles_force_fromtag_maglev(string tag_name, float spring_length, float
     return v_forward  * force_fromtag_power;
 }
 
+// Generic vehile projectile system
 void vehicles_projectile_damage(entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
 {
     self.health -= damage;
@@ -262,7 +284,12 @@ entity vehicles_projectile(string _mzlfx, string _mzlsound,
 
     return proj;
 }
+// End generic vehile projectile system
 
+/** vehicles_spawn
+    Exetuted for all vehiles on (re)spawn.
+    Sets defaults for newly spawned units.
+**/
 void vehicles_spawn()
 {
     dprint("Spawning vehicle: ", self.netname, "\n");
@@ -663,42 +690,6 @@ void vehicles_reset_colors()
     self.effects        = _effects;
 }
 
-//#define VEHICLES_CSQC
-#ifdef VEHICLES_CSQC
-#define VSF_ORG 2
-#define VSF_VEL 4
-#define VSF_ANG 8
-#define VSF_COLORMAP 16
-#define VSF_STAT1 32
-
-float SendVehicle(entity to, float sf)
-{
-       WriteByte(MSG_ENTITY, ENT_CLIENT_VEHICLE_RACER);
-
-       WriteByte(MSG_ENTITY, self.cnt);
-
-       WriteCoord(MSG_ENTITY, self.origin_x);
-       WriteCoord(MSG_ENTITY, self.origin_y);
-       WriteCoord(MSG_ENTITY, self.origin_z);
-
-       WriteCoord(MSG_ENTITY, self.velocity_x);
-       WriteCoord(MSG_ENTITY, self.velocity_y);
-       WriteCoord(MSG_ENTITY, self.velocity_z);
-
-       WriteAngle(MSG_ENTITY, self.angles_x);
-       WriteAngle(MSG_ENTITY, self.angles_y);
-       WriteAngle(MSG_ENTITY, self.angles_z);
-
-    return TRUE;
-}
-
-void NetLinkVehicle()
-{    
-    self.SendFlags = 0xFFFFFF;
-    Net_LinkEntity(self, FALSE, 0, SendVehicle);    
-}
-#endif
-
 float vehicle_initialize(string  net_name,
                          string  bodymodel,
                          string  topmodel,
@@ -816,3 +807,121 @@ void bugmenot()
     self.vehicle_spawn      = self.vehicle_exit;
     self.AuxiliaryXhair     = self.AuxiliaryXhair;
 }
+
+#ifdef VEHICLES_CSQC
+// SendFlags
+float VSF_SETUP       = 2;          /// Send vehicle type etc
+float VSF_ORIGIN      = 4;          /// Send location
+float VSF_MOVEMENT    = 8;          /// Send movement update (and angle/avelocity)
+float VSF_STATS       = 16;         /// Send ammo, health etc
+float VSF_EXTRA       = 32;         /// Send additional data (turret rotations and such) handeld per vehicle type.
+float VSF_FULL_UPDATE = 16777215    /// Send everything
+
+
+#ifdef SVQC
+float send_vehile(entity to, float sf)
+{
+       WriteByte(MSG_ENTITY, ENT_CLIENT_VEHICLE);
+
+       WriteByte(MSG_ENTITY, sf);
+       
+       if(sf & VSF_SETUP)
+       {
+        WriteByte(MSG_ENTITY,   self.hud);        //vehicle type = hud
+        WriteByte(MSG_ENTITY,   self.team);
+        WriteShort(MSG_ENTITY,  self.colormap);
+       }
+    
+    if(sf & VSF_ORIGIN)
+    {
+        WriteCoord(MSG_ENTITY, self.origin_x);
+        WriteCoord(MSG_ENTITY, self.origin_y);
+        WriteCoord(MSG_ENTITY, self.origin_z);        
+    }
+    
+    if(sf & VSF_MOVEMENT)
+    {    
+        WriteCoord(MSG_ENTITY, self.velocity_x);
+        WriteCoord(MSG_ENTITY, self.velocity_y);
+        WriteCoord(MSG_ENTITY, self.velocity_z);
+
+        WriteAngle(MSG_ENTITY, self.angles_x);
+        WriteAngle(MSG_ENTITY, self.angles_y);
+        WriteAngle(MSG_ENTITY, self.angles_z);
+
+        WriteCoord(MSG_ENTITY, self.avelocity_x);
+        WriteCoord(MSG_ENTITY, self.avelocity_y);
+        WriteCoord(MSG_ENTITY, self.avelocity_z);
+    }
+    
+    if(sf & VSF_STATS)
+    {
+        WriteShort(MSG_ENTITY, self.vehicle_health);
+        WriteShort(MSG_ENTITY, self.vehicle_shield);
+        WriteShort(MSG_ENTITY, self.vehicle_energy);
+        WriteShort(MSG_ENTITY, self.vehicle_ammo1);
+        WriteShort(MSG_ENTITY, self.vehicle_reload1);
+        WriteShort(MSG_ENTITY, self.vehicle_ammo2);
+        WriteShort(MSG_ENTITY, self.vehicle_reload2);
+    }
+    
+    if(sf & VSF_EXTRA)
+    {
+        self.vehile_send_exta(to);
+    }
+    
+    return TRUE;
+}
+
+void net_link_vehile()
+{    
+    self.SendFlags = 0xFFFFFF;
+    Net_LinkEntity(self, FALSE, 0, send_vehile);    
+}
+#endif // SVQC
+
+#ifdef CSQC
+void Net_ReadVehicle(float bIsNew)
+{
+    float sf;
+    
+    sf = ReadByte();
+    
+    if(sf & VSF_SETUP)
+    {
+        float vhtype;
+        vhtype = ReadByte();
+        
+    }
+    
+    if(bIsNew)
+    {
+        setmodel(self, "models/vehicles/wakizashi.dpm");
+        self.move_movetype = MOVETYPE_BOUNCE;        
+        self.entremove = VehicleRacerRemove;
+        setsize(self,  '-60 -60 -20', '60 60 20');        
+        self.draw = VehicleRacerDraw;
+        self.scale = 0.5;
+    }
+    
+    self.cnt = ReadByte();
+    
+    self.origin_x = ReadCoord();
+    self.origin_y = ReadCoord();
+    self.origin_z = ReadCoord();
+    
+    self.velocity_x = ReadCoord();
+    self.velocity_y = ReadCoord();
+    self.velocity_z = ReadCoord();
+
+    self.angles_x = ReadAngle();
+    self.angles_y = ReadAngle();
+    self.angles_z = ReadAngle();
+
+    self.move_origin    = self.origin;
+    self.move_velocity  = self.velocity;
+    self.move_angles    = self.angles;
+}
+#endif // CSQC
+
+#endif // VEHICLES_CSQC
index 570e8a82855835db1aba173beafeaa41d2812b1e..8c68fa04a143c2d22806ba404cb7e80b7411e9dd 100644 (file)
@@ -1,62 +1,68 @@
+// #define VEHICLES_CSQC
+// #define VEHICLES_USE_ODE
 #define VEHICLES_ENABLED
 #ifdef VEHICLES_ENABLED
 
 //#define VEHICLES_VIEWROTATE_CROSSHAIR
-
 #message "with tZork vehicles (experimental)"
 
-float SVC_SETVIEWPORT   = 5;   // Net.Protocol 0x05
-float SVC_SETVIEWANGLES = 10;  // Net.Protocol 0x0A
-float SVC_UPDATEENTITY  = 128; // Net.Protocol 0x80
-
 .float vehicle_flags;
-#define VHF_ISVEHICLE   2
-#define VHF_HASSHIELD   4
-#define VHF_SHIELDREGEN 8
-#define VHF_HEALTHREGEN 16
-#define VHF_ENERGYREGEN  32
-#define VHF_DEATHEJECT  64
-#define VHF_MOVE_GROUND 128
-#define VHF_MOVE_HOVER  256
-#define VHF_MOVE_FLY    512
+float VHF_ISVEHICLE     = 2;    /// Indicates vehicle
+float VHF_HASSHIELD     = 4;    /// Vehicle has shileding
+float VHF_SHIELDREGEN   = 8;    /// Vehicles shield regenerates
+float VHF_HEALTHREGEN   = 16;   /// Vehicles health regenerates
+float VHF_ENERGYREGEN   = 32;   /// Vehicles energy regenerates
+float VHF_DEATHEJECT    = 64;   /// Vehicle ejects pilot upon fatal damage
+float VHF_MOVE_GROUND   = 128;  /// Vehicle moves on gound
+float VHF_MOVE_HOVER    = 256;  /// Vehicle hover close to gound 
+float VHF_MOVE_FLY      = 512;  /// Vehicle is airborn
 
 .float hud;
 
 .entity gun1;
 .entity gun2;
 
-.entity vehicle_shieldent;
-
-.float vehicle_health;
-.float vehicle_shield;
-.float vehicle_energy;
+.float vehicle_health;      /// If self is player this is 0..1 indicating precentage of health left on vehicle. If self is vehile, this is the real health value.
+.float vehicle_energy;      /// If self is player this is 0..1 indicating precentage of energy left on vehicle. If self is vehile, this is the real energy value.
+.float vehicle_shield;      /// If self is player this is 0..1 indicating precentage of shield left on vehicle. If self is vehile, this is the real shield value.
+.entity vehicle_shieldent;  /// Entity to disply the shild effect on damage
 
-.float vehicle_ammo1;
-.float vehicle_reload1;
-
-.float vehicle_ammo2;
-.float vehicle_reload2;
+.float vehicle_ammo1;   /// If self is player this field's use depends on the individual vehile. If self is vehile, this is the real ammo1 value.
+.float vehicle_reload1; /// If self is player this field's use depends on the individual vehile. If self is vehile, this is the real reload1 value.
+.float vehicle_ammo2;   /// If self is player this field's use depends on the individual vehile. If self is vehile, this is the real ammo2 value.
+.float vehicle_reload2; /// If self is player this field's use depends on the individual vehile. If self is vehile, this is the real reload2 value.
 
 .entity vehicle;
 .entity vehicle_viewport;
 .entity vehicle_hudmodel;
 
+#ifdef SVQC
 .float dmg_time;
-
 .float  vehicle_respawntime;
 .void() vehicle_spawn;
 
 var .void(float exit_flags) vehicle_exit;
-#define VHEF_NORMAL 0
-#define VHEF_EJECT  1
-#define VHEF_RELESE 2
+float VHEF_NORMAL = 0;  /// User pressed exit key
+float VHEF_EJECT  = 1;  /// User pressed exit key 3 times fast (not implemented) or vehile is dying
+float VHEF_RELESE = 2;  /// Release ownership, client possibly allready dissconnected / went spec / changed team / used "kill" (not implemented)
+
+float SVC_SETVIEWPORT   = 5;   // Net.Protocol 0x05
+float SVC_SETVIEWANGLES = 10;  // Net.Protocol 0x0A
+float SVC_UPDATEENTITY  = 128; // Net.Protocol 0x80
 
-var .void() vehicle_enter;
-var .void() vehicle_die;
-var .void() vehicle_spawn;
+var .void() vehicle_enter;  /// Vehicles custom funciton to be executed when owner exit it
+var .void() vehicle_die;    /// Vehicles custom function to be executed when vehile die
+var .void() vehicle_spawn;  /// Vehicles custom fucntion to be efecuted when vehicle (re)spawns
 
-#endif
+#ifdef VEHICLES_CSQC
+var .void(entity to) vehile_send_exta;  /// Vehicles custom send code (for extra bits, stats and whatnot)
+void net_link_vehile();                 /// Initiates csqc networking for vehicle
+#endif //VEHICLES_CSQC
+#endif //SVQC
 
+#ifdef VEHICLES_USE_ODE
 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
+#endif  // VEHICLES_USE_ODE
+#endif  // VEHICLES_ENABLED
\ No newline at end of file