X-Git-Url: https://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fserver%2Fmutators%2Fmutator%2Fgamemode_race.qc;h=e4109b72a8523e84bd913951409a50339866ed50;hb=05d2779856eda44ed6c8779ab55380fa006cfcb4;hp=c4c8f087e495d388dfc360ca3cc895724894b771;hpb=decae9170e9c82c24a2f9a4fa524c866c8e3d36e;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/server/mutators/mutator/gamemode_race.qc b/qcsrc/server/mutators/mutator/gamemode_race.qc index c4c8f087e..e4109b72a 100644 --- a/qcsrc/server/mutators/mutator/gamemode_race.qc +++ b/qcsrc/server/mutators/mutator/gamemode_race.qc @@ -14,48 +14,54 @@ void havocbot_role_race(entity this) if(IS_DEAD(this)) return; - if (this.bot_strategytime < time) + if (navigation_goalrating_timeout(this)) { - this.bot_strategytime = time + autocvar_bot_ai_strategyinterval; navigation_goalrating_start(this); + bool raw_touch_check = true; + int cp = this.race_checkpoint; + + LABEL(search_racecheckpoints) IL_EACH(g_racecheckpoints, true, { - if(it.cnt == this.race_checkpoint) - { - navigation_routerating(this, it, 1000000, 5000); - } - else if(this.race_checkpoint == -1) + if(it.cnt == cp || cp == -1) { + // redirect bot to next goal if it touched the waypoint of an untouchable checkpoint + // e.g. checkpoint in front of Stormkeep's warpzone + // the same workaround is applied in CTS game mode + if (raw_touch_check && vdist(this.origin - it.nearestwaypoint.origin, <, 30)) + { + cp = race_NextCheckpoint(cp); + raw_touch_check = false; + goto search_racecheckpoints; + } navigation_routerating(this, it, 1000000, 5000); } }); navigation_goalrating_end(this); + + navigation_goalrating_timeout_set(this); } } void race_ScoreRules() { - ScoreRules_basics(race_teams, 0, 0, false); - if(race_teams) - { - ScoreInfo_SetLabel_TeamScore( ST_RACE_LAPS, "laps", SFL_SORT_PRIO_PRIMARY); - ScoreInfo_SetLabel_PlayerScore(SP_RACE_LAPS, "laps", SFL_SORT_PRIO_PRIMARY); - ScoreInfo_SetLabel_PlayerScore(SP_RACE_TIME, "time", SFL_SORT_PRIO_SECONDARY | SFL_LOWER_IS_BETTER | SFL_TIME); - ScoreInfo_SetLabel_PlayerScore(SP_RACE_FASTEST, "fastest", SFL_LOWER_IS_BETTER | SFL_TIME); - } - else if(g_race_qualifying) - { - ScoreInfo_SetLabel_PlayerScore(SP_RACE_FASTEST, "fastest", SFL_SORT_PRIO_PRIMARY | SFL_LOWER_IS_BETTER | SFL_TIME); - } - else - { - ScoreInfo_SetLabel_PlayerScore(SP_RACE_LAPS, "laps", SFL_SORT_PRIO_PRIMARY); - ScoreInfo_SetLabel_PlayerScore(SP_RACE_TIME, "time", SFL_SORT_PRIO_SECONDARY | SFL_LOWER_IS_BETTER | SFL_TIME); - ScoreInfo_SetLabel_PlayerScore(SP_RACE_FASTEST, "fastest", SFL_LOWER_IS_BETTER | SFL_TIME); - } - ScoreRules_basics_end(); + GameRules_score_enabled(false); + GameRules_scoring(race_teams, 0, 0, { + if (race_teams) { + field_team(ST_RACE_LAPS, "laps", SFL_SORT_PRIO_PRIMARY); + field(SP_RACE_LAPS, "laps", SFL_SORT_PRIO_PRIMARY); + field(SP_RACE_TIME, "time", SFL_SORT_PRIO_SECONDARY | SFL_LOWER_IS_BETTER | SFL_TIME); + field(SP_RACE_FASTEST, "fastest", SFL_LOWER_IS_BETTER | SFL_TIME); + } else if (g_race_qualifying) { + field(SP_RACE_FASTEST, "fastest", SFL_SORT_PRIO_PRIMARY | SFL_LOWER_IS_BETTER | SFL_TIME); + } else { + field(SP_RACE_LAPS, "laps", SFL_SORT_PRIO_PRIMARY); + field(SP_RACE_TIME, "time", SFL_SORT_PRIO_SECONDARY | SFL_LOWER_IS_BETTER | SFL_TIME); + field(SP_RACE_FASTEST, "fastest", SFL_LOWER_IS_BETTER | SFL_TIME); + } + }); } void race_EventLog(string mode, entity actor) // use an alias for easy changing and quick editing later @@ -71,11 +77,11 @@ float WinningCondition_Race(float fraglimit) n = 0; c = 0; - FOREACH_CLIENT(IS_PLAYER(it), LAMBDA( + FOREACH_CLIENT(IS_PLAYER(it), { ++n; - if(it.race_completed) + if(CS(it).race_completed) ++c; - )); + }); if(n && (n == c)) return WINNING_YES; wc = WinningCondition_Scores(fraglimit, 0); @@ -150,8 +156,8 @@ MUTATOR_HOOKFUNCTION(rc, PlayerPhysics) // ensure nothing EVIL is being done (i.e. div0_evade) // this hinders joystick users though // but it still gives SOME analog control - wishvel.x = fabs(player.movement.x); - wishvel.y = fabs(player.movement.y); + wishvel.x = fabs(CS(player).movement.x); + wishvel.y = fabs(CS(player).movement.y); if(wishvel.x != 0 && wishvel.y != 0 && wishvel.x != wishvel.y) { wishvel.z = 0; @@ -159,32 +165,32 @@ MUTATOR_HOOKFUNCTION(rc, PlayerPhysics) if(wishvel.x >= 2 * wishvel.y) { // pure X motion - if(player.movement.x > 0) - player.movement_x = wishspeed; + if(CS(player).movement.x > 0) + CS(player).movement_x = wishspeed; else - player.movement_x = -wishspeed; - player.movement_y = 0; + CS(player).movement_x = -wishspeed; + CS(player).movement_y = 0; } else if(wishvel.y >= 2 * wishvel.x) { // pure Y motion - player.movement_x = 0; - if(player.movement.y > 0) - player.movement_y = wishspeed; + CS(player).movement_x = 0; + if(CS(player).movement.y > 0) + CS(player).movement_y = wishspeed; else - player.movement_y = -wishspeed; + CS(player).movement_y = -wishspeed; } else { // diagonal - if(player.movement.x > 0) - player.movement_x = M_SQRT1_2 * wishspeed; + if(CS(player).movement.x > 0) + CS(player).movement_x = M_SQRT1_2 * wishspeed; else - player.movement_x = -M_SQRT1_2 * wishspeed; - if(player.movement.y > 0) - player.movement_y = M_SQRT1_2 * wishspeed; + CS(player).movement_x = -M_SQRT1_2 * wishspeed; + if(CS(player).movement.y > 0) + CS(player).movement_y = M_SQRT1_2 * wishspeed; else - player.movement_y = -M_SQRT1_2 * wishspeed; + CS(player).movement_y = -M_SQRT1_2 * wishspeed; } } } @@ -198,15 +204,15 @@ MUTATOR_HOOKFUNCTION(rc, reset_map_global) race_ClearRecords(); PlayerScore_Sort(race_place, 0, 1, 0); - FOREACH_CLIENT(true, LAMBDA( + FOREACH_CLIENT(true, { if(it.race_place) { - s = PlayerScore_Add(it, SP_RACE_FASTEST, 0); + s = GameRules_scoring_add(it, RACE_FASTEST, 0); if(!s) it.race_place = 0; } race_EventLog(ftos(it.race_place), it); - )); + }); if(g_race_qualifying == 2) { @@ -251,7 +257,7 @@ MUTATOR_HOOKFUNCTION(rc, MakePlayerObserver) entity player = M_ARGV(0, entity); if(g_race_qualifying) - if(PlayerScore_Add(player, SP_RACE_FASTEST, 0)) + if(GameRules_scoring_add(player, RACE_FASTEST, 0)) player.frags = FRAGS_LMS_LOSER; else player.frags = FRAGS_SPECTATOR; @@ -283,7 +289,7 @@ MUTATOR_HOOKFUNCTION(rc, PutClientInServer) if(IS_PLAYER(player)) if(!game_stopped) { - if(player.killcount == FRAGS_SPECTATOR /* initial spawn */ || g_race_qualifying) // spawn + if(CS(player).killcount == FRAGS_SPECTATOR /* initial spawn */ || g_race_qualifying) // spawn race_PreparePlayer(player); else // respawn race_RetractPlayer(player); @@ -312,15 +318,14 @@ MUTATOR_HOOKFUNCTION(rc, GetPressedKeys) { entity player = M_ARGV(0, entity); - if(player.cvar_cl_allow_uidtracking == 1 && player.cvar_cl_allow_uid2name == 1) + if(CS(player).cvar_cl_allow_uidtracking == 1 && CS(player).cvar_cl_allow_uid2name == 1) { if (!player.stored_netname) player.stored_netname = strzone(uid2name(player.crypto_idfp)); if(player.stored_netname != player.netname) { db_put(ServerProgsDB, strcat("/uid2name/", player.crypto_idfp), player.netname); - strunzone(player.stored_netname); - player.stored_netname = strzone(player.netname); + strcpy(player.stored_netname, player.netname); } } @@ -443,17 +448,8 @@ void rc_SetLimits() if(autocvar_g_race_teams) { - ActivateTeamplay(); - race_teams = bound(2, autocvar_g_race_teams, 4); - int teams = 0; - if(race_teams >= 1) teams |= BIT(0); - if(race_teams >= 2) teams |= BIT(1); - if(race_teams >= 3) teams |= BIT(2); - if(race_teams >= 4) teams |= BIT(3); - - race_teams = teams; // now set it? - - have_team_spawns = -1; // request team spawns + GameRules_teams(true); + race_teams = BITS(bound(2, autocvar_g_race_teams, 4)); } else race_teams = 0; @@ -484,5 +480,8 @@ void rc_SetLimits() } else g_race_qualifying = 0; - SetLimits(fraglimit_override, leadlimit_override, timelimit_override, qualifying_override); + GameRules_limit_score(fraglimit_override); + GameRules_limit_lead(leadlimit_override); + GameRules_limit_time(timelimit_override); + GameRules_limit_time_qualifying(qualifying_override); }