]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Much more stable implementation of floating flags
authorSamual Lenks <samual@xonotic.org>
Fri, 31 Aug 2012 18:04:34 +0000 (14:04 -0400)
committerSamual Lenks <samual@xonotic.org>
Fri, 31 Aug 2012 18:04:34 +0000 (14:04 -0400)
qcsrc/server/mutators/gamemode_ctf.qc
qcsrc/server/mutators/gamemode_ctf.qh

index b0529a1a93011dd267f88d2d2baaed14dbb477c5..3e3032eb7f94e2dc7929d3b1f7f14e0a01e425a1 100644 (file)
@@ -607,7 +607,7 @@ void ctf_FlagThink()
        // declarations
        entity tmp_entity;
 
-       self.nextthink = time;// + FLAG_THINKRATE; // only 5 fps, more is unnecessary.
+       self.nextthink = time + FLAG_THINKRATE; // only 5 fps, more is unnecessary.
 
        // captureshield
        if(self == ctf_worldflaglist) // only for the first flag
@@ -652,37 +652,18 @@ void ctf_FlagThink()
                {
                        if(autocvar_g_ctf_flag_dropped_floatinwater)// && (self.flags & FL_INWATER))
                        {
-                               //self.velocity = self.velocity * 0.5;
-                               //self.velocity_z = autocvar_g_ctf_flag_dropped_floatinwater;
-                       //}
-                               if(self.water_foundsurface)
+                               vector midpoint = ((self.absmin + self.absmax) * 0.5);
+                               if(pointcontents(midpoint) == CONTENT_WATER)
                                {
-                                       if(self.flags & FL_INWATER) { self.origin_z = self.water_height; }
-                                       else { CTF_CLEARWATERVARS(self); }
-                               }
-                               else
-                               {
-                                       if(self.flags & FL_INWATER)
-                                       {
-                                               if(self.was_in_water && self.was_in_air)
-                                               {
-                                                       self.water_foundsurface = TRUE;
-                                                       self.water_height = self.origin_z;
-                                               }
-                                               else
-                                               {
-                                                       self.was_in_water = TRUE;
-                                                       self.velocity_z = autocvar_g_ctf_flag_dropped_floatinwater;
-                                               }
-                                       }
+                                       self.velocity = self.velocity * 0.5;
+                                       
+                                       if(pointcontents(midpoint + FLAG_FLOAT_OFFSET) == CONTENT_WATER)
+                                               { self.velocity_z = autocvar_g_ctf_flag_dropped_floatinwater; }
                                        else
-                                       {
-                                               if(self.was_in_water) { self.was_in_air = TRUE; }
-                                               else { CTF_CLEARWATERVARS(self); }
-                                       }       
+                                               { self.movetype = MOVETYPE_FLY; }
                                }
+                               else if(self.movetype == MOVETYPE_FLY) { self.movetype = MOVETYPE_TOSS; }
                        }
-                       
                        if(autocvar_g_ctf_flag_return_dropped)
                        {
                                if((vlen(self.origin - self.ctf_spawnorigin) <= autocvar_g_ctf_flag_return_dropped) || (autocvar_g_ctf_flag_return_dropped == -1))
index 6c00fab8c2ddb35472c9e0f62b51f2c0b05ee662..7ba0e50646006297cf551fb675b7ce2ba8b871d8 100644 (file)
@@ -26,6 +26,7 @@ void spawnfunc_ctf_team();
 #define FLAG_CARRY_OFFSET ('-16 0 8')
 #define FLAG_SPAWN_OFFSET ('0 0 1' * (PL_MAX_z - 13))
 #define FLAG_WAYPOINT_OFFSET ('0 0 64')
+#define FLAG_FLOAT_OFFSET ('0 0 32')
 
 #define VEHICLE_FLAG_OFFSET ('0 0 96')
 #define VEHICLE_FLAG_SCALE 1.0
@@ -98,13 +99,6 @@ float ctf_captimerecord; // record time for capturing the flag
 .entity pass_target;
 .float throw_antispam;
 
-// water floating properties
-#define CTF_CLEARWATERVARS(ent) (ent.water_foundsurface = ent.water_height = ent.was_in_water = ent.was_in_air = FALSE)
-.float water_foundsurface;
-.float water_height;
-.float was_in_water;
-.float was_in_air;
-
 // CaptureShield: If the player is too bad to be allowed to capture, shield them from taking the flag.
 .float ctf_captureshielded; // set to 1 if the player is too bad to be allowed to capture
 float ctf_captureshield_min_negscore; // punish at -20 points