X-Git-Url: http://de.git.xonotic.org/?p=xonotic%2Fxonotic-data.pk3dir.git;a=blobdiff_plain;f=qcsrc%2Fserver%2Fmutators%2Fmutator%2Fgamemode_freezetag.qc;h=88afaa755d7b9f995419411e912d431b7d4ec166;hp=cec7d950e9076cdecfc573fdaeafe9be16f409e2;hb=81062a39c99785039ceee2dcd187fed9352a08c5;hpb=26693a3ac060825ce6c7f170d4e65f7ac2a1fb25 diff --git a/qcsrc/server/mutators/mutator/gamemode_freezetag.qc b/qcsrc/server/mutators/mutator/gamemode_freezetag.qc index cec7d950e..88afaa755 100644 --- a/qcsrc/server/mutators/mutator/gamemode_freezetag.qc +++ b/qcsrc/server/mutators/mutator/gamemode_freezetag.qc @@ -7,17 +7,10 @@ float autocvar_g_freezetag_round_timelimit; int autocvar_g_freezetag_teams_override; float autocvar_g_freezetag_warmup; -void freezetag_ScoreRules(int teams) -{ - ScoreRules_basics(teams, SFL_SORT_PRIO_PRIMARY, SFL_SORT_PRIO_PRIMARY, true); // SFL_SORT_PRIO_PRIMARY - ScoreInfo_SetLabel_PlayerScore(SP_FREEZETAG_REVIVALS, "revivals", 0); - ScoreRules_basics_end(); -} - void freezetag_count_alive_players() { total_players = redalive = bluealive = yellowalive = pinkalive = 0; - FOREACH_CLIENT(IS_PLAYER(it), LAMBDA( + FOREACH_CLIENT(IS_PLAYER(it), { switch(it.team) { case NUM_TEAM_1: ++total_players; if(it.health >= 1 && STAT(FROZEN, it) != 1) ++redalive; break; @@ -25,13 +18,13 @@ void freezetag_count_alive_players() case NUM_TEAM_3: ++total_players; if(it.health >= 1 && STAT(FROZEN, it) != 1) ++yellowalive; break; case NUM_TEAM_4: ++total_players; if(it.health >= 1 && STAT(FROZEN, it) != 1) ++pinkalive; break; } - )); - FOREACH_CLIENT(IS_REAL_CLIENT(it), LAMBDA( + }); + FOREACH_CLIENT(IS_REAL_CLIENT(it), { it.redalive_stat = redalive; it.bluealive_stat = bluealive; it.yellowalive_stat = yellowalive; it.pinkalive_stat = pinkalive; - )); + }); eliminatedPlayers.SendFlags |= 1; } @@ -106,10 +99,11 @@ float freezetag_CheckWinner() { Send_Notification(NOTIF_ALL, NULL, MSG_CENTER, CENTER_ROUND_OVER); Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_ROUND_OVER); - FOREACH_CLIENT(IS_PLAYER(it), LAMBDA( + FOREACH_CLIENT(IS_PLAYER(it), { it.freezetag_frozen_timeout = 0; nades_Clear(it); - )); + }); + game_stopped = true; round_handler_Init(5, autocvar_g_freezetag_warmup, autocvar_g_freezetag_round_timelimit); return 1; } @@ -130,10 +124,12 @@ float freezetag_CheckWinner() Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_ROUND_TIED); } - FOREACH_CLIENT(IS_PLAYER(it), LAMBDA( + FOREACH_CLIENT(IS_PLAYER(it), { it.freezetag_frozen_timeout = 0; nades_Clear(it); - )); + }); + + game_stopped = true; round_handler_Init(5, autocvar_g_freezetag_warmup, autocvar_g_freezetag_round_timelimit); return 1; } @@ -141,7 +137,7 @@ float freezetag_CheckWinner() entity freezetag_LastPlayerForTeam(entity this) { entity last_pl = NULL; - FOREACH_CLIENT(IS_PLAYER(it) && it != this, LAMBDA( + FOREACH_CLIENT(IS_PLAYER(it) && it != this, { if(it.health >= 1) if(!STAT(FROZEN, it)) if(SAME_TEAM(it, this)) @@ -149,7 +145,7 @@ entity freezetag_LastPlayerForTeam(entity this) last_pl = it; else return NULL; - )); + }); return last_pl; } @@ -170,14 +166,14 @@ void freezetag_Add_Score(entity targ, entity attacker) { // you froze your own dumb targ // counted as "suicide" already - PlayerScore_Add(targ, SP_SCORE, -1); + GameRules_scoring_add(targ, SCORE, -1); } else if(IS_PLAYER(attacker)) { // got frozen by an enemy // counted as "kill" and "death" already - PlayerScore_Add(targ, SP_SCORE, -1); - PlayerScore_Add(attacker, SP_SCORE, +1); + GameRules_scoring_add(targ, SCORE, -1); + GameRules_scoring_add(attacker, SCORE, +1); } // else nothing - got frozen by the game type rules themselves } @@ -222,20 +218,22 @@ void(entity this) havocbot_role_ft_offense; void havocbot_goalrating_freeplayers(entity this, float ratingscale, vector org, float sradius) { - FOREACH_CLIENT(IS_PLAYER(it) && it != this && SAME_TEAM(it, this), LAMBDA( + float t; + FOREACH_CLIENT(IS_PLAYER(it) && it != this && SAME_TEAM(it, this), { if (STAT(FROZEN, it) == 1) { if(vdist(it.origin - org, >, sradius)) continue; navigation_routerating(this, it, ratingscale, 2000); } - else + else if(vdist(it.origin - org, >, 400)) // avoid gathering all teammates in one place { // If teamate is not frozen still seek them out as fight better // in a group. - navigation_routerating(this, it, ratingscale/3, 2000); + t = 0.2 * 150 / (this.health + this.armorvalue); + navigation_routerating(this, it, t * ratingscale, 2000); } - )); + }); } void havocbot_role_ft_offense(entity this) @@ -248,7 +246,7 @@ void havocbot_role_ft_offense(entity this) // Count how many players on team are unfrozen. int unfrozen = 0; - FOREACH_CLIENT(IS_PLAYER(it) && SAME_TEAM(it, this) && !(STAT(FROZEN, it) != 1), LAMBDA(unfrozen++)); + FOREACH_CLIENT(IS_PLAYER(it) && SAME_TEAM(it, this) && !(STAT(FROZEN, it) != 1), { unfrozen++; }); // If only one left on team or if role has timed out then start trying to free players. if (((unfrozen == 0) && (!STAT(FROZEN, this))) || (time > this.havocbot_role_timeout)) @@ -267,7 +265,7 @@ void havocbot_role_ft_offense(entity this) havocbot_goalrating_items(this, 10000, this.origin, 10000); havocbot_goalrating_enemyplayers(this, 20000, this.origin, 10000); havocbot_goalrating_freeplayers(this, 9000, this.origin, 10000); - //havocbot_goalrating_waypoints(1, this.origin, 1000); + havocbot_goalrating_waypoints(this, 1, this.origin, 3000); navigation_goalrating_end(this); } } @@ -296,7 +294,7 @@ void havocbot_role_ft_freeing(entity this) havocbot_goalrating_items(this, 8000, this.origin, 10000); havocbot_goalrating_enemyplayers(this, 10000, this.origin, 10000); havocbot_goalrating_freeplayers(this, 20000, this.origin, 10000); - //havocbot_goalrating_waypoints(1, this.origin, 1000); + havocbot_goalrating_waypoints(this, 1, this.origin, 3000); navigation_goalrating_end(this); } } @@ -411,12 +409,12 @@ MUTATOR_HOOKFUNCTION(ft, PlayerSpawn) MUTATOR_HOOKFUNCTION(ft, reset_map_players) { - FOREACH_CLIENT(IS_PLAYER(it), LAMBDA( - it.killcount = 0; + FOREACH_CLIENT(IS_PLAYER(it), { + CS(it).killcount = 0; it.freezetag_frozen_timeout = -1; PutClientInServer(it); it.freezetag_frozen_timeout = 0; - )); + }); freezetag_count_alive_players(); return true; } @@ -429,7 +427,7 @@ MUTATOR_HOOKFUNCTION(ft, GiveFragsForKill, CBC_ORDER_FIRST) MUTATOR_HOOKFUNCTION(ft, PlayerPreThink, CBC_ORDER_FIRST) { - if(gameover) + if(game_stopped) return true; if(round_handler_IsActive()) @@ -449,7 +447,7 @@ MUTATOR_HOOKFUNCTION(ft, PlayerPreThink, CBC_ORDER_FIRST) { vector revive_extra_size = '1 1 1' * autocvar_g_freezetag_revive_extra_size; n = 0; - FOREACH_CLIENT(IS_PLAYER(it) && it != player, LAMBDA( + FOREACH_CLIENT(IS_PLAYER(it) && it != player, { if(STAT(FROZEN, it) == 0) if(!IS_DEAD(it)) if(SAME_TEAM(it, player)) @@ -461,7 +459,7 @@ MUTATOR_HOOKFUNCTION(ft, PlayerPreThink, CBC_ORDER_FIRST) it.reviving = true; ++n; } - )); + }); } @@ -483,21 +481,21 @@ MUTATOR_HOOKFUNCTION(ft, PlayerPreThink, CBC_ORDER_FIRST) } // EVERY team mate nearby gets a point (even if multiple!) - FOREACH_CLIENT(IS_PLAYER(it) && it.reviving, LAMBDA( - PlayerScore_Add(it, SP_FREEZETAG_REVIVALS, +1); - PlayerScore_Add(it, SP_SCORE, +1); + FOREACH_CLIENT(IS_PLAYER(it) && it.reviving, { + GameRules_scoring_add(it, FREEZETAG_REVIVALS, +1); + GameRules_scoring_add(it, SCORE, +1); nades_GiveBonus(it,autocvar_g_nades_bonus_score_low); - )); + }); Send_Notification(NOTIF_ONE, player, MSG_CENTER, CENTER_FREEZETAG_REVIVED, o.netname); Send_Notification(NOTIF_ONE, o, MSG_CENTER, CENTER_FREEZETAG_REVIVE, player.netname); Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_FREEZETAG_REVIVED, player.netname, o.netname); } - FOREACH_CLIENT(IS_PLAYER(it) && it.reviving, LAMBDA( + FOREACH_CLIENT(IS_PLAYER(it) && it.reviving, { it.revive_progress = player.revive_progress; it.reviving = false; - )); + }); } else if(!n && STAT(FROZEN, player) == 1) // only if no teammate is nearby will we reset { @@ -563,8 +561,8 @@ MUTATOR_HOOKFUNCTION(ft, FragCenterMessage) if(STAT(FROZEN, frag_target)) 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 : frag_target.ping)); - Send_Notification(NOTIF_ONE, frag_target, MSG_CHOICE, CHOICE_FRAGGED_FREEZE, frag_attacker.netname, kill_count_to_target, frag_attacker.health, frag_attacker.armorvalue, (IS_BOT_CLIENT(frag_attacker) ? -1 : frag_attacker.ping)); + 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, frag_attacker.health, frag_attacker.armorvalue, (IS_BOT_CLIENT(frag_attacker) ? -1 : CS(frag_attacker).ping)); return true; } @@ -574,16 +572,11 @@ void freezetag_Initialize() freezetag_teams = autocvar_g_freezetag_teams_override; if(freezetag_teams < 2) freezetag_teams = cvar("g_freezetag_teams"); // read the cvar directly as it gets written earlier in the same frame - freezetag_teams = bound(2, freezetag_teams, 4); - - int teams = 0; - if(freezetag_teams >= 1) teams |= BIT(0); - if(freezetag_teams >= 2) teams |= BIT(1); - if(freezetag_teams >= 3) teams |= BIT(2); - if(freezetag_teams >= 4) teams |= BIT(3); - freezetag_teams = teams; // now set it? - freezetag_ScoreRules(freezetag_teams); + 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); + }); round_handler_Spawn(freezetag_CheckTeams, freezetag_CheckWinner, func_null); round_handler_Init(5, autocvar_g_freezetag_warmup, autocvar_g_freezetag_round_timelimit);