From: FruitieX Date: Thu, 25 Nov 2010 13:05:11 +0000 (+0200) Subject: fix handling of the revival progress X-Git-Tag: xonotic-v0.1.0preview~86^2~2^2~9 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=5e151cf45d6bc2d77b4ead780ccc1c145302bb5a;p=xonotic%2Fxonotic-data.pk3dir.git fix handling of the revival progress --- diff --git a/qcsrc/server/mutators/gamemode_freezetag.qc b/qcsrc/server/mutators/gamemode_freezetag.qc index d9e60a8e2..0d218c58d 100644 --- a/qcsrc/server/mutators/gamemode_freezetag.qc +++ b/qcsrc/server/mutators/gamemode_freezetag.qc @@ -184,54 +184,66 @@ MUTATOR_HOOKFUNCTION(freezetag_GiveFragsForKill) MUTATOR_HOOKFUNCTION(freezetag_PlayerPreThink) { - vector revive_extra_size; - revive_extra_size = '1 1 1' * cvar("g_freezetag_revive_extra_size"); - - float teammate_nearby; - FOR_EACH_PLAYER(other) if(self != other) - { - if(other.freezetag_frozen == 0) - { - if(other.team == self.team) - { - teammate_nearby = boxesoverlap(self.absmin - revive_extra_size, self.absmax + revive_extra_size, other.absmin, other.absmax); - if(teammate_nearby) - break; - } - } - } - - if(teammate_nearby && self.freezetag_frozen == 1) - { - if(self.freezetag_beginrevive_time == -9999) - { - self.freezetag_beginrevive_time = time; - self.freezetag_revive_progress = 0; - other.freezetag_revive_progress = 0; - } - else - { - self.freezetag_revive_progress = (time - self.freezetag_beginrevive_time) / cvar("g_freezetag_revive_time"); - other.freezetag_revive_progress = (time - self.freezetag_beginrevive_time) / cvar("g_freezetag_revive_time"); - if(time - self.freezetag_beginrevive_time >= cvar("g_freezetag_revive_time")) - { - freezetag_Unfreeze(); - - centerprint(self, strcat("^5You were revived by ^7", other.netname, ".\n")); - centerprint(other, strcat("^5You revived ^7", self.netname, ".\n")); - bprint("^7", other.netname, "^5 revived ^7", self.netname, ".\n"); - - self.freezetag_beginrevive_time = -9999; - self.freezetag_revive_progress = 0; - other.freezetag_revive_progress = 0; - } - } - } - else if(!teammate_nearby) // only if no teammate is nearby will we reset - { - self.freezetag_beginrevive_time = -9999; - self.freezetag_revive_progress = 0; - } + vector revive_extra_size; + revive_extra_size = '1 1 1' * cvar("g_freezetag_revive_extra_size"); + + float revive_progress; + + float teammate_nearby; + FOR_EACH_PLAYER(other) if(self != other) + { + if(other.freezetag_frozen == 0) + { + if(other.team == self.team) + { + teammate_nearby = boxesoverlap(self.absmin - revive_extra_size, self.absmax + revive_extra_size, other.absmin, other.absmax); + if(teammate_nearby) + break; + } + } + } + + if(teammate_nearby && self.freezetag_frozen == 1) // OK, there is at least one teammate reviving us + { + if(self.freezetag_beginrevive_time == -9999) // initialize values if this is the first frame of revival + { + self.freezetag_beginrevive_time = time; + self.freezetag_revive_progress = 0; + } + else + { + self.freezetag_revive_progress = (time - self.freezetag_beginrevive_time) / cvar("g_freezetag_revive_time"); + if(time - self.freezetag_beginrevive_time >= cvar("g_freezetag_revive_time")) + { + freezetag_Unfreeze(); + + centerprint(self, strcat("^5You were revived by ^7", other.netname, ".\n")); + centerprint(other, strcat("^5You revived ^7", self.netname, ".\n")); + bprint("^7", other.netname, "^5 revived ^7", self.netname, ".\n"); + + self.freezetag_beginrevive_time = -9999; + self.freezetag_revive_progress = 0; + } + } + // now find EVERY teammate within reviving radius, set their revive_progress values correct + FOR_EACH_PLAYER(other) if(self != other) + { + if(other.freezetag_frozen == 0) + { + if(other.team == self.team) + { + teammate_nearby = boxesoverlap(self.absmin - revive_extra_size, self.absmax + revive_extra_size, other.absmin, other.absmax); + if(teammate_nearby) + other.freezetag_revive_progress = self.freezetag_revive_progress; + } + } + } + } + else if(!teammate_nearby) // only if no teammate is nearby will we reset + { + self.freezetag_beginrevive_time = -9999; + self.freezetag_revive_progress = 0; + } return 1; }