From: Mario Date: Wed, 8 May 2013 04:20:26 +0000 (+1000) Subject: Fix some issues with LMS & CA X-Git-Tag: xonotic-v0.7.0~55^2~8^2 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=ff949c70b545db358159063980b2a787c43ae238;p=xonotic%2Fxonotic-data.pk3dir.git Fix some issues with LMS & CA --- diff --git a/qcsrc/server/cl_client.qc b/qcsrc/server/cl_client.qc index 3d8930184..641482155 100644 --- a/qcsrc/server/cl_client.qc +++ b/qcsrc/server/cl_client.qc @@ -385,15 +385,7 @@ void PutObserverInServer (void) WriteEntity(MSG_ONE, self); } - if(g_lms) - { - // Only if the player cannot play at all - if(PlayerScore_Add(self, SP_LMS_RANK, 0) == 666) - self.frags = FRAGS_SPECTATOR; - else - self.frags = FRAGS_LMS_LOSER; - } - else if((g_race && g_race_qualifying) || g_cts) + if((g_race && g_race_qualifying) || g_cts) { if(PlayerScore_Add(self, SP_RACE_FASTEST, 0)) self.frags = FRAGS_LMS_LOSER; @@ -610,14 +602,6 @@ void PutClientInServer (void) // reset player keys self.itemkeys = 0; - // player is dead and becomes observer - // FIXME fix LMS scoring for new system - if(g_lms) - { - if(PlayerScore_Add(self, SP_LMS_RANK, 0) > 0) - self.classname = "observer"; - } - MUTATOR_CALLHOOK(PutClientInServer); if(gameover) @@ -800,8 +784,6 @@ void PutClientInServer (void) self.colormod = '1 1 1' * autocvar_g_player_brightness; self.exteriorweaponentity.alpha = default_weapon_alpha; - self.lms_nextcheck = time + autocvar_g_lms_campcheck_interval*2; - self.lms_traveled_distance = 0; self.speedrunning = FALSE; race_PostSpawn(spot); diff --git a/qcsrc/server/cl_player.qc b/qcsrc/server/cl_player.qc index 95aeced31..60df5dd31 100644 --- a/qcsrc/server/cl_player.qc +++ b/qcsrc/server/cl_player.qc @@ -664,7 +664,7 @@ void PlayerDamage (entity inflictor, entity attacker, float damage, float deatht else self.respawn_countdown = -1; // do not count down - if(g_lms || g_cts || autocvar_g_forced_respawn) + if(g_cts || autocvar_g_forced_respawn) self.respawn_flags = self.respawn_flags | RESPAWN_FORCE; self.death_time = time; diff --git a/qcsrc/server/command/vote.qc b/qcsrc/server/command/vote.qc index 3e564e39a..e34464f16 100644 --- a/qcsrc/server/command/vote.qc +++ b/qcsrc/server/command/vote.qc @@ -332,9 +332,6 @@ void reset_map(float dorespawn) race_ReadyRestart(); else MUTATOR_CALLHOOK(reset_map_global); - lms_lowest_lives = 999; - lms_next_place = player_count; - for(self = world; (self = nextent(self)); ) if(clienttype(self) == CLIENTTYPE_NOTACLIENT) { @@ -379,8 +376,6 @@ void reset_map(float dorespawn) //NEW: changed behaviour so that it prevents that previous spectators/observers suddenly spawn as players if (IS_PLAYER(self)) { //PlayerScore_Clear(self); - if(g_lms) - PlayerScore_Add(self, SP_LMS_LIVES, LMS_NewPlayerLives()); self.killcount = 0; //stop the player from moving so that he stands still once he gets respawned self.velocity = '0 0 0'; diff --git a/qcsrc/server/defs.qh b/qcsrc/server/defs.qh index fb93b7c78..95dbe48ff 100644 --- a/qcsrc/server/defs.qh +++ b/qcsrc/server/defs.qh @@ -243,9 +243,6 @@ float nJoinAllowed(entity ignore); .float spawnshieldtime; -.float lms_nextcheck; -.float lms_traveled_distance; - .entity flagcarried; .float playerid; diff --git a/qcsrc/server/miscfunctions.qc b/qcsrc/server/miscfunctions.qc index 13eb647db..191bfaede 100644 --- a/qcsrc/server/miscfunctions.qc +++ b/qcsrc/server/miscfunctions.qc @@ -828,8 +828,7 @@ void readplayerstartcvars() g_pinata = 0; // incompatible g_weapon_stay = 0; // incompatible WEPSET_COPY_AA(start_weapons, g_weaponarena_weapons); - if(!g_ca) - start_items |= IT_UNLIMITED_AMMO; + start_items |= IT_UNLIMITED_AMMO; } else if (g_minstagib) { @@ -881,28 +880,11 @@ void readplayerstartcvars() } else { - if(g_ca) - { - start_ammo_shells = cvar("g_lms_start_ammo_shells"); - start_ammo_nails = cvar("g_lms_start_ammo_nails"); - start_ammo_rockets = cvar("g_lms_start_ammo_rockets"); - start_ammo_cells = cvar("g_lms_start_ammo_cells"); - start_ammo_fuel = cvar("g_lms_start_ammo_fuel"); - } - else - { - start_ammo_shells = cvar("g_start_ammo_shells"); - start_ammo_nails = cvar("g_start_ammo_nails"); - start_ammo_rockets = cvar("g_start_ammo_rockets"); - start_ammo_cells = cvar("g_start_ammo_cells"); - start_ammo_fuel = cvar("g_start_ammo_fuel"); - } - } - - if (g_ca) - { - start_health = cvar("g_lms_start_health"); - start_armorvalue = cvar("g_lms_start_armor"); + start_ammo_shells = cvar("g_start_ammo_shells"); + start_ammo_nails = cvar("g_start_ammo_nails"); + start_ammo_rockets = cvar("g_start_ammo_rockets"); + start_ammo_cells = cvar("g_start_ammo_cells"); + start_ammo_fuel = cvar("g_start_ammo_fuel"); } if (inWarmupStage) diff --git a/qcsrc/server/mutators/gamemode_ca.qc b/qcsrc/server/mutators/gamemode_ca.qc index 11330fbd7..22bfc981c 100644 --- a/qcsrc/server/mutators/gamemode_ca.qc +++ b/qcsrc/server/mutators/gamemode_ca.qc @@ -222,6 +222,22 @@ MUTATOR_HOOKFUNCTION(ca_GiveFragsForKill) return 1; } +MUTATOR_HOOKFUNCTION(ca_SetStartItems) +{ + start_health = cvar("g_lms_start_health"); + start_armorvalue = cvar("g_lms_start_armor"); + + start_ammo_shells = cvar("g_lms_start_ammo_shells"); + start_ammo_nails = cvar("g_lms_start_ammo_nails"); + start_ammo_rockets = cvar("g_lms_start_ammo_rockets"); + start_ammo_cells = cvar("g_lms_start_ammo_cells"); + start_ammo_fuel = cvar("g_lms_start_ammo_fuel"); + + start_items &~= IT_UNLIMITED_AMMO; + + return 0; +} + void ca_Initialize() { allowed_to_spawn = TRUE; @@ -248,6 +264,7 @@ MUTATOR_DEFINITION(gamemode_ca) 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); + MUTATOR_HOOK(SetStartItems, ca_SetStartItems, CBC_ORDER_ANY); MUTATOR_ONADD { diff --git a/qcsrc/server/mutators/gamemode_lms.qc b/qcsrc/server/mutators/gamemode_lms.qc index 681a1d433..82258ac77 100644 --- a/qcsrc/server/mutators/gamemode_lms.qc +++ b/qcsrc/server/mutators/gamemode_lms.qc @@ -18,15 +18,49 @@ float LMS_NewPlayerLives() } // mutator hooks -MUTATOR_HOOKFUNCTION(lms_PlayerSpawn) +MUTATOR_HOOKFUNCTION(lms_ResetMap) +{ + lms_lowest_lives = 999; + lms_next_place = player_count; + + return FALSE; +} + +MUTATOR_HOOKFUNCTION(lms_ResetPlayers) { - if(IS_PLAYER(self)) if(restart_mapalreadyrestarted || (time < game_starttime)) + FOR_EACH_CLIENT(self) + if(IS_PLAYER(self)) PlayerScore_Add(self, SP_LMS_LIVES, LMS_NewPlayerLives()); + + return FALSE; +} + +MUTATOR_HOOKFUNCTION(lms_PlayerPreSpawn) +{ + // player is dead and becomes observer + // FIXME fix LMS scoring for new system + if(PlayerScore_Add(self, SP_LMS_RANK, 0) > 0) + self.classname = "observer"; + + return FALSE; +} + +MUTATOR_HOOKFUNCTION(lms_PlayerSpawn) +{ + self.lms_nextcheck = time + autocvar_g_lms_campcheck_interval*2; + self.lms_traveled_distance = 0; return FALSE; } +MUTATOR_HOOKFUNCTION(lms_PlayerDies) +{ + self.respawn_flags |= RESPAWN_FORCE; + + return FALSE; +} + MUTATOR_HOOKFUNCTION(lms_RemovePlayer) { // Only if the player cannot play at all @@ -181,18 +215,6 @@ MUTATOR_HOOKFUNCTION(lms_ItemTouch) return FALSE; } -MUTATOR_HOOKFUNCTION(lms_BotSpawn) -{ - // temporary hack to give bots lives - if(PlayerScore_Add(self, SP_LMS_LIVES, LMS_NewPlayerLives()) <= 0) - { - PlayerScore_Add(self, SP_LMS_RANK, 666); - self.frags = FRAGS_SPECTATOR; - } - - return FALSE; -} - // scoreboard stuff void lms_ScoreRules() { @@ -212,7 +234,11 @@ void lms_Initialize() MUTATOR_DEFINITION(gamemode_lms) { + MUTATOR_HOOK(reset_map_global, lms_ResetMap, CBC_ORDER_ANY); + MUTATOR_HOOK(reset_map_players, lms_ResetPlayers, CBC_ORDER_ANY); + MUTATOR_HOOK(PutClientInServer, lms_PlayerPreSpawn, CBC_ORDER_ANY); MUTATOR_HOOK(PlayerSpawn, lms_PlayerSpawn, CBC_ORDER_ANY); + MUTATOR_HOOK(PlayerDies, lms_PlayerDies, CBC_ORDER_ANY); MUTATOR_HOOK(MakePlayerObserver, lms_RemovePlayer, CBC_ORDER_ANY); MUTATOR_HOOK(ClientConnect, lms_ClientConnect, CBC_ORDER_ANY); MUTATOR_HOOK(PlayerPreThink, lms_PlayerThink, CBC_ORDER_ANY); @@ -223,7 +249,6 @@ MUTATOR_DEFINITION(gamemode_lms) MUTATOR_HOOK(ForbidPlayerScore_Clear, lms_KeepScore, CBC_ORDER_ANY); MUTATOR_HOOK(FilterItem, lms_FilterItem, CBC_ORDER_ANY); MUTATOR_HOOK(ItemTouch, lms_ItemTouch, CBC_ORDER_ANY); - MUTATOR_HOOK(HavocBot_ChooseRule, lms_BotSpawn, CBC_ORDER_ANY); MUTATOR_ONADD { diff --git a/qcsrc/server/mutators/gamemode_lms.qh b/qcsrc/server/mutators/gamemode_lms.qh index 16fda6155..508bf8c6c 100644 --- a/qcsrc/server/mutators/gamemode_lms.qh +++ b/qcsrc/server/mutators/gamemode_lms.qh @@ -5,4 +5,8 @@ // lives related defs float lms_lowest_lives; float lms_next_place; -float LMS_NewPlayerLives(); \ No newline at end of file +float LMS_NewPlayerLives(); + +// camp check +.float lms_nextcheck; +.float lms_traveled_distance; \ No newline at end of file