X-Git-Url: http://de.git.xonotic.org/?p=xonotic%2Fxonotic-data.pk3dir.git;a=blobdiff_plain;f=qcsrc%2Fcommon%2Fgamemodes%2Fgamemode%2Ffreezetag%2Ffreezetag.qc;h=15726ada31d03b5442b12e15e175d34533af9768;hp=f2ce080ebbe9c99e60e3167698ba9f37d1dad582;hb=69eda62d02bc02ff50547bad514af3f7ce487413;hpb=6c27fe90b0454df3dbf7b098bc554fcb5eaa75d0 diff --git a/qcsrc/common/gamemodes/gamemode/freezetag/freezetag.qc b/qcsrc/common/gamemodes/gamemode/freezetag/freezetag.qc index f2ce080ebb..15726ada31 100644 --- a/qcsrc/common/gamemodes/gamemode/freezetag/freezetag.qc +++ b/qcsrc/common/gamemodes/gamemode/freezetag/freezetag.qc @@ -157,14 +157,14 @@ float freezetag_CheckWinner() entity freezetag_LastPlayerForTeam(entity this) { entity last_pl = NULL; - FOREACH_CLIENT(IS_PLAYER(it) && it != this, { - if(GetResourceAmount(it, RESOURCE_HEALTH) >= 1) - if(!STAT(FROZEN, it)) - if(SAME_TEAM(it, this)) - if(!last_pl) - last_pl = it; - else - return NULL; + FOREACH_CLIENT(IS_PLAYER(it) && it != this && SAME_TEAM(it, this), { + if (!STAT(FROZEN, it) && GetResourceAmount(it, RESOURCE_HEALTH) >= 1) + { + if (!last_pl) + last_pl = it; + else + return NULL; + } }); return last_pl; } @@ -198,6 +198,7 @@ void freezetag_Add_Score(entity targ, entity attacker) // else nothing - got frozen by the game type rules themselves } +// to be called when the player is frozen by freezetag (on death, spectator join etc), gives the score void freezetag_Freeze(entity targ, entity attacker) { if(STAT(FROZEN, targ)) @@ -213,14 +214,6 @@ void freezetag_Freeze(entity targ, entity attacker) freezetag_Add_Score(targ, attacker); } -void freezetag_Unfreeze(entity this) -{ - this.freezetag_frozen_time = 0; - this.freezetag_frozen_timeout = 0; - - Unfreeze(this); -} - float freezetag_isEliminated(entity e) { if(IS_PLAYER(e) && (STAT(FROZEN, e) == 1 || IS_DEAD(e))) @@ -329,7 +322,7 @@ void ft_RemovePlayer(entity this) SetResourceAmountExplicit(this, RESOURCE_HEALTH, 0); // neccessary to update correctly alive stats if(!STAT(FROZEN, this)) freezetag_LastPlayerForTeam_Notify(this); - freezetag_Unfreeze(this); + Unfreeze(this); freezetag_count_alive_players(); } @@ -358,7 +351,7 @@ MUTATOR_HOOKFUNCTION(ft, PlayerDies) if(round_handler_CountdownRunning()) { if(STAT(FROZEN, frag_target)) - freezetag_Unfreeze(frag_target); + Unfreeze(frag_target); freezetag_count_alive_players(); return true; // let the player die so that he can respawn whenever he wants } @@ -376,7 +369,7 @@ MUTATOR_HOOKFUNCTION(ft, PlayerDies) freezetag_LastPlayerForTeam_Notify(frag_target); } else - freezetag_Unfreeze(frag_target); // remove ice + Unfreeze(frag_target); // remove ice SetResourceAmountExplicit(frag_target, RESOURCE_HEALTH, 0); // Unfreeze resets health frag_target.freezetag_frozen_timeout = -2; // freeze on respawn return true; @@ -445,6 +438,15 @@ MUTATOR_HOOKFUNCTION(ft, GiveFragsForKill, CBC_ORDER_FIRST) return true; } +MUTATOR_HOOKFUNCTION(ft, Unfreeze) +{ + entity targ = M_ARGV(0, entity); + targ.freezetag_frozen_time = 0; + targ.freezetag_frozen_timeout = 0; + + freezetag_count_alive_players(); +} + MUTATOR_HOOKFUNCTION(ft, PlayerPreThink, CBC_ORDER_FIRST) { if(game_stopped) @@ -490,7 +492,7 @@ MUTATOR_HOOKFUNCTION(ft, PlayerPreThink, CBC_ORDER_FIRST) if(STAT(REVIVE_PROGRESS, player) >= 1) { - freezetag_Unfreeze(player); + Unfreeze(player); freezetag_count_alive_players(); if(n == -1) @@ -583,8 +585,8 @@ MUTATOR_HOOKFUNCTION(ft, FragCenterMessage) return; // target was already frozen, so this is just pushing them off the cliff Send_Notification(NOTIF_ONE, frag_attacker, MSG_CHOICE, CHOICE_FRAG_FREEZE, frag_target.netname, kill_count_to_attacker, (IS_BOT_CLIENT(frag_target) ? -1 : CS(frag_target).ping)); - Send_Notification(NOTIF_ONE, frag_target, MSG_CHOICE, CHOICE_FRAGGED_FREEZE, frag_attacker.netname, kill_count_to_target, - GetResourceAmount(frag_attacker, RESOURCE_HEALTH), GetResourceAmount(frag_attacker, RESOURCE_ARMOR), (IS_BOT_CLIENT(frag_attacker) ? -1 : CS(frag_attacker).ping)); + Send_Notification(NOTIF_ONE, frag_target, MSG_CHOICE, CHOICE_FRAGGED_FREEZE, frag_attacker.netname, kill_count_to_target, + GetResourceAmount(frag_attacker, RESOURCE_HEALTH), GetResourceAmount(frag_attacker, RESOURCE_ARMOR), (IS_BOT_CLIENT(frag_attacker) ? -1 : CS(frag_attacker).ping)); return true; } @@ -597,7 +599,7 @@ void freezetag_Initialize() freezetag_teams = BITS(bound(2, freezetag_teams, 4)); GameRules_scoring(freezetag_teams, SFL_SORT_PRIO_PRIMARY, SFL_SORT_PRIO_PRIMARY, { - field(SP_FREEZETAG_REVIVALS, "revivals", 0); + field(SP_FREEZETAG_REVIVALS, "revivals", 0); }); round_handler_Spawn(freezetag_CheckTeams, freezetag_CheckWinner, func_null);