From: terencehill Date: Wed, 26 Feb 2014 10:41:05 +0000 (+0100) Subject: CA and Freezetag: centerprint "^F4You are now alone!" to the last alive player of... X-Git-Tag: xonotic-v0.8.0~126^2~11 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=8f52b69fc643b74eb46e1db9b908137004f89c7d;p=xonotic%2Fxonotic-data.pk3dir.git CA and Freezetag: centerprint "^F4You are now alone!" to the last alive player of the team --- diff --git a/qcsrc/common/notifications.qh b/qcsrc/common/notifications.qh index 303ad61b8..062d2080d 100644 --- a/qcsrc/common/notifications.qh +++ b/qcsrc/common/notifications.qh @@ -545,6 +545,7 @@ void Send_Notification_WOCOVA( MULTITEAM_CENTER##teams(default,prefix,strnum,flnum,args,cpid,durcnt,normal,gentle) #define MSG_CENTER_NOTIFICATIONS \ + MSG_CENTER_NOTIF(1, CENTER_ALONE, 0, 0, "", NO_CPID, "0 0", _("^F4You are now alone!"), "") \ MSG_CENTER_NOTIF(1, CENTER_ASSAULT_ATTACKING, 0, 0, "", CPID_ASSAULT_ROLE, "0 0", _("^BGYou are attacking!"), "") \ MSG_CENTER_NOTIF(1, CENTER_ASSAULT_DEFENDING, 0, 0, "", CPID_ASSAULT_ROLE, "0 0", _("^BGYou are defending!"), "") \ MSG_CENTER_NOTIF(1, CENTER_COUNTDOWN_BEGIN, 0, 0, "", CPID_ROUND, "2 0", _("^F4Begin!"), "") \ diff --git a/qcsrc/server/mutators/gamemode_ca.qc b/qcsrc/server/mutators/gamemode_ca.qc index cf5dde111..5236889ad 100644 --- a/qcsrc/server/mutators/gamemode_ca.qc +++ b/qcsrc/server/mutators/gamemode_ca.qc @@ -197,13 +197,48 @@ MUTATOR_HOOKFUNCTION(ca_GetTeamCount) return 0; } +entity ca_LastPlayerForTeam() +{ + entity pl, last_pl = world; + FOR_EACH_PLAYER(pl) + { + if(pl.health >= 1) + if(pl != self) + if(pl.team == self.team) + if(!last_pl) + last_pl = pl; + else + return world; + } + return last_pl; +} + +void ca_LastPlayerForTeam_Notify() +{ + if(round_handler_IsActive()) + if(round_handler_IsRoundStarted()) + { + entity pl = ca_LastPlayerForTeam(); + if(pl) + Send_Notification(NOTIF_ONE, pl, MSG_CENTER, CENTER_ALONE); + } +} + MUTATOR_HOOKFUNCTION(ca_PlayerDies) { + ca_LastPlayerForTeam_Notify(); if(!allowed_to_spawn) self.respawn_flags = RESPAWN_SILENT; return 1; } +MUTATOR_HOOKFUNCTION(ca_ClientDisconnect) +{ + if(self.caplayer == 1) + ca_LastPlayerForTeam_Notify(); + return 1; +} + MUTATOR_HOOKFUNCTION(ca_ForbidPlayerScore_Clear) { return 1; @@ -211,6 +246,8 @@ MUTATOR_HOOKFUNCTION(ca_ForbidPlayerScore_Clear) MUTATOR_HOOKFUNCTION(ca_MakePlayerObserver) { + if(self.caplayer == 1) + ca_LastPlayerForTeam_Notify(); if(self.killindicator_teamchange == -2) self.caplayer = 0; if(self.caplayer) @@ -313,6 +350,7 @@ MUTATOR_DEFINITION(gamemode_ca) MUTATOR_HOOK(reset_map_players, ca_reset_map_players, CBC_ORDER_ANY); MUTATOR_HOOK(GetTeamCount, ca_GetTeamCount, CBC_ORDER_EXCLUSIVE); MUTATOR_HOOK(PlayerDies, ca_PlayerDies, CBC_ORDER_ANY); + MUTATOR_HOOK(ClientDisconnect, ca_ClientDisconnect, CBC_ORDER_ANY); MUTATOR_HOOK(ForbidPlayerScore_Clear, ca_ForbidPlayerScore_Clear, CBC_ORDER_ANY); MUTATOR_HOOK(ForbidThrowCurrentWeapon, ca_ForbidThrowCurrentWeapon, CBC_ORDER_ANY); MUTATOR_HOOK(GiveFragsForKill, ca_GiveFragsForKill, CBC_ORDER_FIRST); diff --git a/qcsrc/server/mutators/gamemode_freezetag.qc b/qcsrc/server/mutators/gamemode_freezetag.qc index d6b537288..214a88419 100644 --- a/qcsrc/server/mutators/gamemode_freezetag.qc +++ b/qcsrc/server/mutators/gamemode_freezetag.qc @@ -137,6 +137,34 @@ float freezetag_CheckWinner() return 1; } +entity freezetag_LastPlayerForTeam() +{ + entity pl, last_pl = world; + FOR_EACH_PLAYER(pl) + { + if(pl.health >= 1) + if(!pl.freezetag_frozen) + if(pl != self) + if(pl.team == self.team) + if(!last_pl) + last_pl = pl; + else + return world; + } + return last_pl; +} + +void freezetag_LastPlayerForTeam_Notify() +{ + if(round_handler_IsActive()) + if(round_handler_IsRoundStarted()) + { + entity pl = freezetag_LastPlayerForTeam(); + if(pl) + Send_Notification(NOTIF_ONE, pl, MSG_CENTER, CENTER_ALONE); + } +} + // this is needed to allow the player to turn his view around (fixangle can't // be used to freeze his view, as that also changes the angles), while not // turning that ice object with the player @@ -325,6 +353,8 @@ void havocbot_role_ft_freeing() MUTATOR_HOOKFUNCTION(freezetag_RemovePlayer) { self.health = 0; // neccessary to update correctly alive stats + if(!self.freezetag_frozen) + freezetag_LastPlayerForTeam_Notify(); freezetag_Unfreeze(world); freezetag_count_alive_players(); return 1; @@ -351,6 +381,7 @@ MUTATOR_HOOKFUNCTION(freezetag_PlayerDies) { freezetag_Add_Score(frag_attacker); freezetag_count_alive_players(); + freezetag_LastPlayerForTeam_Notify(); } else freezetag_Unfreeze(world); // remove ice @@ -362,6 +393,7 @@ MUTATOR_HOOKFUNCTION(freezetag_PlayerDies) return 1; freezetag_Freeze(frag_attacker); + freezetag_LastPlayerForTeam_Notify(); if(frag_attacker == frag_target || frag_attacker == world) {