X-Git-Url: http://git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fserver%2Fmutators%2Fmutator%2Fgamemode_cts.qc;h=daaf8a969592e810af3531a1cdcded327b46a8fc;hb=9366bc8fa80268a5cc80044db3f38f98ecfea3e6;hp=21098a5e996f04ddf213b20bd2042d844226fd52;hpb=ad1fc0314153e3f183fc36892aa86126fa269c5e;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/server/mutators/mutator/gamemode_cts.qc b/qcsrc/server/mutators/mutator/gamemode_cts.qc index 21098a5e9..daaf8a969 100644 --- a/qcsrc/server/mutators/mutator/gamemode_cts.qc +++ b/qcsrc/server/mutators/mutator/gamemode_cts.qc @@ -1,7 +1,7 @@ #include "gamemode_cts.qh" -#include #include +#include float autocvar_g_cts_finish_kill_delay; bool autocvar_g_cts_selfdamage; @@ -13,37 +13,49 @@ void havocbot_role_cts(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 Race 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 cts_ScoreRules() { - ScoreRules_basics(0, 0, 0, false); - 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(0, 0, 0, { + 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 cts_EventLog(string mode, entity actor) // use an alias for easy changing and quick editing later @@ -98,8 +110,8 @@ MUTATOR_HOOKFUNCTION(cts, 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; @@ -107,32 +119,32 @@ MUTATOR_HOOKFUNCTION(cts, 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; } } } @@ -146,15 +158,15 @@ MUTATOR_HOOKFUNCTION(cts, 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; } cts_EventLog(ftos(it.race_place), it); - )); + }); if(g_race_qualifying == 2) { @@ -194,11 +206,19 @@ MUTATOR_HOOKFUNCTION(cts, ClientConnect) } } +MUTATOR_HOOKFUNCTION(cts, AbortSpeedrun) +{ + entity player = M_ARGV(0, entity); + + if(autocvar_g_allow_checkpoints) + race_PreparePlayer(player); // nice try +} + MUTATOR_HOOKFUNCTION(cts, MakePlayerObserver) { entity player = M_ARGV(0, entity); - 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; @@ -228,9 +248,9 @@ MUTATOR_HOOKFUNCTION(cts, PutClientInServer) entity player = M_ARGV(0, entity); if(IS_PLAYER(player)) - if(!gameover) + 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); @@ -259,7 +279,7 @@ MUTATOR_HOOKFUNCTION(cts, 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)); @@ -308,8 +328,10 @@ MUTATOR_HOOKFUNCTION(cts, FilterItem) { entity item = M_ARGV(0, entity); - if(item.classname == "droppedweapon") + if (Item_IsLoot(item)) + { return true; + } } MUTATOR_HOOKFUNCTION(cts, Damage_Calculate) @@ -379,6 +401,11 @@ MUTATOR_HOOKFUNCTION(cts, Race_FinalCheckpoint) CTS_ClientKill(player); } +MUTATOR_HOOKFUNCTION(cts, HideTeamNagger) +{ + return true; // doesn't work so well (but isn't cts a teamless mode?) +} + MUTATOR_HOOKFUNCTION(cts, FixClientCvars) { entity player = M_ARGV(0, entity); @@ -393,6 +420,11 @@ MUTATOR_HOOKFUNCTION(cts, WantWeapon) return true; } +MUTATOR_HOOKFUNCTION(cts, ForbidDropCurrentWeapon) +{ + return true; +} + void cts_Initialize() { cts_ScoreRules();