]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Some preparations to enable bot's to use vehicles
authorJakob MG <jakob_mg@hotmail.com>
Tue, 10 Jul 2012 08:19:48 +0000 (10:19 +0200)
committerJakob MG <jakob_mg@hotmail.com>
Tue, 10 Jul 2012 08:19:48 +0000 (10:19 +0200)
qcsrc/server/vehicles/spiderbot.qc
qcsrc/server/vehicles/vehicles.qc

index 42bd7902b654ef7685bd533cd587fb74aba077c5..7795fe324376f0e1aca66cfa12bb93ac2c8fbc4a 100644 (file)
@@ -307,6 +307,11 @@ void spiderbot_rocket_do()
     self.gun2.cnt = time + self.attack_finished_single;
 }
 
+float spiderbot_aiframe()
+{
+    
+}
+
 float spiderbot_frame()
 {
     vector ad, vf;
@@ -325,11 +330,6 @@ float spiderbot_frame()
     player.BUTTON_ZOOM      = 0;
     player.BUTTON_CROUCH    = 0;
     player.switchweapon     = 0;
-
-    if(player.impulse == 12)
-    {
-        dprint("WOOOOOOOOOOOtotototototOOOOOOOOOOOOttt\n");
-    }
     
 
 #if 1 // 0 to enable per-gun impact aux crosshairs
index 2f6a191bf57b222764ff781291c0c99cf9cbada3..534b6d45fa33ba23ff8fe4f886bfbf918439efc7 100644 (file)
@@ -45,6 +45,9 @@ float SendAuxiliaryXhair(entity to, float sf)
 
 void UpdateAuxiliaryXhair(entity own, vector loc, vector clr, float axh_id)
 {
+    if (clienttype(own) != CLIENTTYPE_REAL)
+        return;
+
     entity axh;
 
     axh_id = bound(0, axh_id, MAX_AXH);
@@ -97,6 +100,9 @@ void SendAuxiliaryXhair2(entity own, vector loc, vector clr, float axh_id)
 **/
 void CSQCVehicleSetup(entity own, float vehicle_id)
 {
+    if (clienttype(own) != CLIENTTYPE_REAL)
+        return;
+       
        msg_entity = own;
 
        WriteByte(MSG_ONE, SVC_TEMPENTITY);
@@ -554,18 +560,18 @@ void vehicles_touch()
     if(other.vehicle != world)
         return;
 
-    // Remove this when bots know how to use vehicles.
-    if (clienttype(other) != CLIENTTYPE_REAL)
-        return;
-
     vehicles_enter();
 }
-
+float autocvar_g_vehicles_allow_bots = 0;
 void vehicles_enter()
 {
    // Remove this when bots know how to use vehicles
-    if (clienttype(other) != CLIENTTYPE_REAL)
-        return;
+   
+    if (clienttype(other) == CLIENTTYPE_BOT)    
+        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(self.phase > time)
         return;
@@ -622,23 +628,26 @@ void vehicles_enter()
 
     self.team                 = self.owner.team;
     self.flags               -= FL_NOTARGET;
-
-    msg_entity = other;
-    WriteByte (MSG_ONE, SVC_SETVIEWPORT);
-    WriteEntity(MSG_ONE, self.vehicle_viewport);
-
-    WriteByte (MSG_ONE, SVC_SETVIEWANGLES);
-    if(self.tur_head)
-    {
-        WriteAngle(MSG_ONE, self.tur_head.angles_x + self.angles_x); // tilt
-        WriteAngle(MSG_ONE, self.tur_head.angles_y + self.angles_y); // yaw
-        WriteAngle(MSG_ONE, 0);                                      // roll
-    }
-    else
+    
+    if (clienttype(other) == CLIENTTYPE_REAL)
     {
-        WriteAngle(MSG_ONE,  self.angles_x * -1); // tilt
-        WriteAngle(MSG_ONE,  self.angles_y);      // yaw
-        WriteAngle(MSG_ONE,  0);                  // roll
+        msg_entity = other;
+        WriteByte (MSG_ONE, SVC_SETVIEWPORT);
+        WriteEntity(MSG_ONE, self.vehicle_viewport);
+
+        WriteByte (MSG_ONE, SVC_SETVIEWANGLES);
+        if(self.tur_head)
+        {
+            WriteAngle(MSG_ONE, self.tur_head.angles_x + self.angles_x); // tilt
+            WriteAngle(MSG_ONE, self.tur_head.angles_y + self.angles_y); // yaw
+            WriteAngle(MSG_ONE, 0);                                      // roll
+        }
+        else
+        {
+            WriteAngle(MSG_ONE,  self.angles_x * -1); // tilt
+            WriteAngle(MSG_ONE,  self.angles_y);      // yaw
+            WriteAngle(MSG_ONE,  0);                  // roll
+        }
     }
 
     vehicles_clearrturn();
@@ -731,15 +740,18 @@ void vehicles_exit(float eject)
 
     if (self.owner)
     {
-        msg_entity = self.owner;
-        WriteByte (MSG_ONE, SVC_SETVIEWPORT);
-        WriteEntity( MSG_ONE, self.owner);
-
-        WriteByte (MSG_ONE, SVC_SETVIEWANGLES);
-        WriteAngle(MSG_ONE, 0);                 // pich
-        WriteAngle(MSG_ONE, self.angles_y);     // yaw
-        WriteAngle(MSG_ONE, 0);                 // roll
-
+        if (clienttype(self.owner) == CLIENTTYPE_REAL)
+        {
+            msg_entity = self.owner;
+            WriteByte (MSG_ONE, SVC_SETVIEWPORT);
+            WriteEntity( MSG_ONE, self.owner);
+
+            WriteByte (MSG_ONE, SVC_SETVIEWANGLES);
+            WriteAngle(MSG_ONE, 0);                 // pich
+            WriteAngle(MSG_ONE, self.angles_y);     // yaw
+            WriteAngle(MSG_ONE, 0);                 // roll
+        }
+        
         setsize(self.owner, PL_MIN,PL_MAX);
 
         self.owner.takedamage     = DAMAGE_AIM;
@@ -755,6 +767,13 @@ void vehicles_exit(float eject)
         self.owner.switchweapon   = self.switchweapon;
         //self.owner.BUTTON_USE     = 0;
 
+        if(self.owner.flagcarried)
+        {
+            self.owner.flagcarried.scale = 0.6;
+            setattachment(self.owner.flagcarried, self.owner, "");
+            setorigin(self.owner.flagcarried, FLAG_CARRY_POS);
+        }
+
         CSQCVehicleSetup(self.owner, HUD_NORMAL);
     }
 
@@ -772,12 +791,6 @@ void vehicles_exit(float eject)
     else
         self.team = self.tur_head.team;
 
-    if(self.owner.flagcarried)
-    {
-        self.owner.flagcarried.scale = 0.6;
-        setattachment(self.owner.flagcarried, self.owner, "");
-        setorigin(self.owner.flagcarried, FLAG_CARRY_POS);
-    }
 
     sound (self, CH_TRIGGER_SINGLE, "misc/null.wav", 1, ATTN_NORM);
     self.vehicle_exit(eject);