X-Git-Url: http://git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fserver%2Fmutators%2Fmutator%2Fgamemode_cts.qc;h=f05b53ce8cbc6998407f91ac71998a0d13c9a5bf;hb=0042a63cfa8ef7889d1f9ed24e3644615ffbef2a;hp=a220801eefb6ed3ee46a5ccdbfbfe5b491572700;hpb=0fca74f0a20647a83f1e710308a818f19792765c;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 a220801ee..f05b53ce8 100644 --- a/qcsrc/server/mutators/mutator/gamemode_cts.qc +++ b/qcsrc/server/mutators/mutator/gamemode_cts.qc @@ -1,4 +1,5 @@ -#include "../../race.qh" +#include "gamemode_cts.qh" +#include #ifndef GAMEMODE_CTS_H #define GAMEMODE_CTS_H @@ -11,11 +12,12 @@ REGISTER_MUTATOR(cts, false) { if (time > 1) // game loads at time 1 error("This is a game type and it cannot be added at runtime."); - cts_Initialize(); g_race_qualifying = true; independent_players = 1; - SetLimits(0, 0, 0, -1); + SetLimits(0, 0, autocvar_timelimit_override, -1); + + cts_Initialize(); } MUTATOR_ONROLLBACK_OR_REMOVE @@ -43,37 +45,32 @@ const float SP_CTS_FASTEST = 6; #ifdef IMPLEMENTATION -#include "../../race.qh" +#include float autocvar_g_cts_finish_kill_delay; bool autocvar_g_cts_selfdamage; // legacy bot roles .float race_checkpoint; -void havocbot_role_cts() -{SELFPARAM(); - if(self.deadflag != DEAD_NO) +void havocbot_role_cts(entity this) +{ + if(IS_DEAD(this)) return; - entity e; - if (self.bot_strategytime < time) + if (this.bot_strategytime < time) { - self.bot_strategytime = time + autocvar_bot_ai_strategyinterval; - navigation_goalrating_start(); + this.bot_strategytime = time + autocvar_bot_ai_strategyinterval; + navigation_goalrating_start(this); - for(e = world; (e = find(e, classname, "trigger_race_checkpoint")) != world; ) + FOREACH_ENTITY_CLASS("trigger_race_checkpoint", true, { - if(e.cnt == self.race_checkpoint) - { - navigation_routerating(e, 1000000, 5000); - } - else if(self.race_checkpoint == -1) - { - navigation_routerating(e, 1000000, 5000); - } - } + if(it.cnt == this.race_checkpoint) + navigation_routerating(this, it, 1000000, 5000); + else if(this.race_checkpoint == -1) + navigation_routerating(this, it, 1000000, 5000); + }); - navigation_goalrating_end(); + navigation_goalrating_end(this); } } @@ -99,6 +96,7 @@ void cts_EventLog(string mode, entity actor) // use an alias for easy changing a GameLogEcho(strcat(":cts:", mode, ":", ((actor != world) ? (strcat(":", ftos(actor.playerid))) : ""))); } +void KillIndicator_Think(); void CTS_ClientKill(entity e) // silent version of ClientKill, used when player finishes a CTS run. Useful to prevent cheating by running back to the start line and starting out with more speed { e.killindicator = spawn(); @@ -191,17 +189,15 @@ MUTATOR_HOOKFUNCTION(cts, reset_map_global) race_ClearRecords(); PlayerScore_Sort(race_place, 0, 1, 0); - entity e; - FOR_EACH_CLIENT(e) - { - if(e.race_place) + FOREACH_CLIENT(true, LAMBDA( + if(it.race_place) { - s = PlayerScore_Add(e, SP_RACE_FASTEST, 0); + s = PlayerScore_Add(it, SP_RACE_FASTEST, 0); if(!s) - e.race_place = 0; + it.race_place = 0; } - cts_EventLog(ftos(e.race_place), e); - } + cts_EventLog(ftos(it.race_place), it); + )); if(g_race_qualifying == 2) { @@ -216,16 +212,6 @@ MUTATOR_HOOKFUNCTION(cts, reset_map_global) return false; } -MUTATOR_HOOKFUNCTION(cts, PlayerPreThink) -{SELFPARAM(); - if(IS_SPEC(self) || IS_OBSERVER(self)) - if(g_race_qualifying) - if(msg_entity.enemy.race_laptime) - race_SendNextCheckpoint(msg_entity.enemy, 1); - - return false; -} - MUTATOR_HOOKFUNCTION(cts, ClientConnect) {SELFPARAM(); race_PreparePlayer(); @@ -297,9 +283,9 @@ MUTATOR_HOOKFUNCTION(cts, PutClientInServer) } MUTATOR_HOOKFUNCTION(cts, PlayerDies) -{SELFPARAM(); - self.respawn_flags |= RESPAWN_FORCE; - race_AbandonRaceCheck(self); +{ + frag_target.respawn_flags |= RESPAWN_FORCE; + race_AbandonRaceCheck(frag_target); return false; } @@ -380,13 +366,6 @@ MUTATOR_HOOKFUNCTION(cts, ForbidPlayerScore_Clear) return true; // in CTS, you don't lose score by observing } -MUTATOR_HOOKFUNCTION(cts, SetModname) -{ - g_cloaked = 1; // always enable cloak in CTS - - return false; -} - MUTATOR_HOOKFUNCTION(cts, GetRecords) { for(int i = record_page * 200; i < MapInfo_count && i < record_page * 200 + 200; ++i) @@ -406,8 +385,10 @@ MUTATOR_HOOKFUNCTION(cts, GetRecords) return false; } +void ClientKill_Now(); MUTATOR_HOOKFUNCTION(cts, ClientKill) { + SELFPARAM(); ret_float = 0; if(self.killindicator && self.killindicator.health == 1) // self.killindicator.health == 1 means that the kill indicator was spawned by CTS_ClientKill @@ -424,7 +405,7 @@ MUTATOR_HOOKFUNCTION(cts, ClientKill) MUTATOR_HOOKFUNCTION(cts, Race_FinalCheckpoint) { if(autocvar_g_cts_finish_kill_delay) - CTS_ClientKill(self); + CTS_ClientKill(race_player); return false; } @@ -437,7 +418,7 @@ MUTATOR_HOOKFUNCTION(cts, FixClientCvars) MUTATOR_HOOKFUNCTION(cts, WantWeapon) { - ret_float = (want_weaponinfo.weapon == WEP_SHOTGUN.m_id); + ret_float = (want_weaponinfo == WEP_SHOTGUN); want_mutatorblocked = true; return true; }