From bd9e6eb9e9d706a0efff03b793dcaae445adae1d Mon Sep 17 00:00:00 2001 From: Samual Lenks Date: Fri, 31 Aug 2012 02:15:30 -0400 Subject: [PATCH] Experimenting with new float-in-water handling techniques --- qcsrc/server/mutators/gamemode_ctf.qc | 38 ++++++++++++++++++++++++--- qcsrc/server/mutators/gamemode_ctf.qh | 7 +++++ 2 files changed, 41 insertions(+), 4 deletions(-) diff --git a/qcsrc/server/mutators/gamemode_ctf.qc b/qcsrc/server/mutators/gamemode_ctf.qc index 31b19f46d..b0529a1a9 100644 --- a/qcsrc/server/mutators/gamemode_ctf.qc +++ b/qcsrc/server/mutators/gamemode_ctf.qc @@ -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 @@ -650,9 +650,39 @@ void ctf_FlagThink() case FLAG_DROPPED: { - if(autocvar_g_ctf_flag_dropped_floatinwater && (self.flags & FL_INWATER)) - self.velocity_z = autocvar_g_ctf_flag_dropped_floatinwater; - + 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) + { + 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; + } + } + else + { + if(self.was_in_water) { self.was_in_air = TRUE; } + else { CTF_CLEARWATERVARS(self); } + } + } + } + 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)) diff --git a/qcsrc/server/mutators/gamemode_ctf.qh b/qcsrc/server/mutators/gamemode_ctf.qh index 376be568c..6c00fab8c 100644 --- a/qcsrc/server/mutators/gamemode_ctf.qh +++ b/qcsrc/server/mutators/gamemode_ctf.qh @@ -98,6 +98,13 @@ 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 -- 2.39.2