diff --git a/GriefFix/better-countdown-hud.gsc b/GriefFix/better-countdown-hud.gsc deleted file mode 100644 index d3d52f2..0000000 --- a/GriefFix/better-countdown-hud.gsc +++ /dev/null @@ -1,24 +0,0 @@ - Remaining = create_simple_hud(); - Remaining.horzAlign = "center"; - Remaining.vertAlign = "middle"; - Remaining.alignX = "center"; - Remaining.alignY = "middle"; - Remaining.y = 20; - Remaining.x = 0; - Remaining.foreground = 1; - Remaining.fontscale = 2.0; - Remaining.alpha = 1; - Remaining.color = ( 0.98, 0.549, 0 ); - - Countdown = create_simple_hud(); - Countdown.horzAlign = "center"; - Countdown.vertAlign = "middle"; - Countdown.alignX = "center"; - Countdown.alignY = "middle"; - Countdown.y = -20; - Countdown.x = 0; - Countdown.foreground = 1; - Countdown.fontscale = 2.0; - Countdown.alpha = 1; - Countdown.color = ( 1.000, 1.000, 1.000 ); - Countdown SetText( "Match begins in" ); diff --git a/GriefFix/grief_fix_basic.gsc b/GriefFix/grief_fix_basic.gsc new file mode 100644 index 0000000..b47bfd4 --- /dev/null +++ b/GriefFix/grief_fix_basic.gsc @@ -0,0 +1,320 @@ +#include maps\mp\_utility; +#include common_scripts\utility; +#include maps\mp\zombies\_zm_utility; +#include maps\mp\gametypes_zm\_hud_util; +#include maps\mp\gametypes_zm\_hud_message; +#include maps\mp\zombies\_zm; +#include maps\mp\zombies\_zm_perks; + + +init() +{ + thread griefFunctionsAndVars(); + gameDelayFunctionsAndVars() + thread setPlayersToSpectator(); + thread gscRestart(); + thread emptyLobbyRestart(); + thread gscMapChange(); +} + +gameDelayFunctionsAndVars() +{ + //game delay functions options + level.wait_time = getDvarIntDefault( "waitTime", 30 ); //change this to adjust the start time once the player quota is met + level.player_quota_active = getDvarIntDefault( "playerQuotaActive", 1 ); //set this to 0 to disable player quotas recommended to be 1 for grief + level.player_quota = getDvarIntDefault( "playerQuota", 2 ); //number of players required before the game starts + level.waiting = 0; //don't change this + level.countdown_start = 0; //don't change this + + level.round_prestart_func =::round_prestart_func; //delays the rounds from starting + SetDvar( "scr_zm_enable_bots", 1 ); //this is required for the mod to work + thread flag_clearer(); + thread add_bots(); //this overrides the typical start time logic +} + +griefFunctionsAndVars() +{ + if ( level.scr_zm_ui_gametype_group != "zencounter" ) + { + return; + } + level.default_solo_laststandpistol = "m1911_zm"; //prevents players from having the solo pistol when downed in grief + for(;;) + { + level waittill("connected", player); + player teamBalancing(); + player [[ level.givecustomcharacters ]](); + } +} + +round_prestart_func() +{ + players = get_players(); + while ( players.size < level.player_quota && level.player_quota_active == 1 || players.size < 1) + { + wait 0.5; + players = get_players(); + } + wait level.wait_time; +} + +teamBalancing() +{ + teamplayersallies = countplayers( "allies"); + teamplayersaxis = countplayers( "axis"); + if (teamplayersallies > teamplayersaxis && !level.isresetting_grief) + { + self.team = "axis"; + self.sessionteam = "axis"; + self [[level.axis]](); + self.pers["team"] = "axis"; + self._encounters_team = "A"; + } + else if (teamplayersallies < teamplayersaxis && !level.isresetting_grief) + { + self.team = "allies"; + self.sessionteam = "allies"; + self [[level.allies]](); + self.pers["team"] = "allies"; + self._encounters_team = "B"; + } + else if (teamplayersallies == teamplayersaxis && !level.isresetting_grief) + { + self.team = "allies"; + self.sessionteam = "allies"; + self [[level.allies]](); + self.pers["team"] = "allies"; + self._encounters_team = "B"; + } +} + +flag_clearer() +{ + //hopefully keep the game from starting prematurely on map_restart + while ( 1 ) + { + flag_clear( "solo_game" ); + flag_clear( "start_zombie_round_logic" ); + wait 0.1; + if ( !level.waiting ) + { + break; + } + } +} + +add_bots() +{ + players = get_players(); + level.waiting = 1; + thread waitMessage(); + while ( players.size < level.player_quota && level.player_quota_active || players.size < 1) + { + wait 0.5; + players = get_players(); + } + level.waiting = 0; + level.countdown_start = 1; + thread countdownTimer(); + wait level.wait_time; + flag_set( "start_zombie_round_logic" ); +} + +waitMessage() +{ + level endon("game_ended"); + self endon("disconnect"); + if( level.waiting == 0 ) + { + return; + } + + Waiting = create_simple_hud(); + Waiting.horzAlign = "center"; //valid inputs: center, top, bottom, left, right, top_right, top_left, topcenter, bottom_right, bottom_left + Waiting.vertAlign = "middle"; + Waiting.alignX = "center"; + Waiting.alignY = "middle"; + Waiting.y = 0; //- is top 0 is middle + is bottom + Waiting.x = -1; + Waiting.foreground = 1; + Waiting.fontscale = 3.0; + Waiting.alpha = 1; //transparency + Waiting.color = ( 1.000, 1.000, 1.000 ); //RGB + Waiting SetText( "Waiting for 1 more player" ); + + while ( 1 ) + { + if ( level.waiting == 0 ) + { + Waiting destroy(); + break; + } + wait 1; + } +} + +countdownTimer() +{ + level endon("game_ended"); + self endon("disconnect"); + if ( level.countdown_start == 0 ) + { + return; + } + + Remaining = create_simple_hud(); + Remaining.horzAlign = "center"; + Remaining.vertAlign = "middle"; + Remaining.alignX = "center"; + Remaining.alignY = "middle"; + Remaining.y = 20; + Remaining.x = 0; + Remaining.foreground = 1; + Remaining.fontscale = 2.0; + Remaining.alpha = 1; + Remaining.color = ( 0.98, 0.549, 0 ); + + Countdown = create_simple_hud(); + Countdown.horzAlign = "center"; + Countdown.vertAlign = "middle"; + Countdown.alignX = "center"; + Countdown.alignY = "middle"; + Countdown.y = -20; + Countdown.x = 0; + Countdown.foreground = 1; + Countdown.fontscale = 2.0; + Countdown.alpha = 1; + Countdown.color = ( 1.000, 1.000, 1.000 ); + Countdown SetText( "Match begins in" ); + + timer = level.wait_time; + while ( level.countdown_start == 1 ) + { + Remaining SetValue( timer ); + wait 1; + timer--; + if ( timer <= 0 ) + { + Countdown destroy(); + Remaining destroy(); + break; + } + } +} + +gscRestart() +{ + if ( level.map_rotate && level.script == "zm_transit" ) + { + return; + } + level waittill( "end_game" ); + wait 12; + map_restart( false ); +} + +//grief games don't end if no players remain in the server so this will force a restart to reset the map +emptyLobbyRestart() +{ + while ( 1 ) + { + players = get_players(); + if (players.size > 0 ) + { + while ( 1 ) + { + players = get_players(); + if ( players.size < 1 ) + { + map_restart( false ); + } + wait 1; + } + } + wait 1; + } +} + +gscMapChange() +{ + if ( !level.map_rotate || level.script != "zm_transit" ) + { + return; + } + level waittill( "end_game" ); + wait 20; + mapChange( location() ); + map_restart( false ); +} + +location() +{ + //move the order of the if statements to change the order of the rotation + if ( getDvarIntDefault( "farm", 1 ) ) + { + setDvar( "farm", 0 ); + return "farm"; + } + if ( getDvarIntDefault( "town", 1 ) ) + { + setDvar( "town", 0 ); + return "town"; + } + if ( getDvarIntDefault( "transit", 1 ) ) + { + setDvar( "transit", 0 ); + return "transit"; + } + setDvar( "farm", 1 ); + setDvar( "transit", 1 ); + setDvar( "town", 1 ); +} + +mapChange( startlocation ) +{ + setDvar( "ui_zm_mapstartlocation", startlocation ); + makedvarserverinfo( "ui_zm_mapstartlocation", startlocation ); +} + +setPlayersToSpectator() +{ + level.no_end_game_check = 1; + wait 3; + players = get_players(); + i = 0; + while ( i < players.size ) + { + if ( i == 0 ) + { + i++; + } + players[ i ] kill(); + i++; + } + wait 10; + spawnAllPlayers(); +} + +kill() +{ + self.maxhealth = 100; + self.health = self.maxhealth; + self disableInvulnerability(); + self dodamage( self.health * 2, self.origin ); + self.bleedout_time = 0; +} + +spawnAllPlayers() +{ + players = get_players(); + i = 0; + while ( i < players.size ) + { + if ( players[ i ].sessionstate == "spectator" && isDefined( players[ i ].spectator_respawn ) ) + { + players[ i ] [[ level.spawnplayer ]](); + thread refresh_player_navcard_hud(); + } + i++; + } +} diff --git a/GriefFix/main.gsc b/GriefFix/grief_fix_enhanced.gsc similarity index 89% rename from GriefFix/main.gsc rename to GriefFix/grief_fix_enhanced.gsc index c131f36..df0ebab 100644 --- a/GriefFix/main.gsc +++ b/GriefFix/grief_fix_enhanced.gsc @@ -79,8 +79,6 @@ griefFunctionsAndVars() for(;;) { level waittill("connected", player); - level.playerTeamNameTag = player getTeamNameTag(); - player teamPicking(); player teamBalancing(); player [[ level.givecustomcharacters ]](); } @@ -97,47 +95,8 @@ round_prestart_func() wait level.wait_time; } -getTeamNameTag() -{ - name = self.name; - return name[0] + name[1] + name[2]; -} - -teamPicking() -{ - teamplayersallies = countplayers( "allies"); - teamplayersaxis = countplayers( "axis"); - if ( level.playerTeamNameTag == "cdc" && teamplayersallies < 4 && !level.isresetting_grief ) - { - self.team = "allies"; - self.sessionteam = "allies"; - self [[level.allies]](); - self.pers["team"] = "allies"; - self._encounters_team = "B"; - return true; - } - else if ( level.playerTeamNameTag == "cia" && teamplayersaxis < 4 && !level.isresetting_grief ) - { - self.team = "axis"; - self.sessionteam = "axis"; - self [[level.axis]](); - self.pers["team"] = "axis"; - self._encounters_team = "A"; - return true; - } - else - { - return false; - } -} - teamBalancing() { - teamChosen = teamPicking(); - if ( teamChosen ) - { - return; - } teamplayersallies = countplayers( "allies"); teamplayersaxis = countplayers( "axis"); if (teamplayersallies > teamplayersaxis && !level.isresetting_grief) @@ -243,27 +202,27 @@ countdownTimer() Remaining = create_simple_hud(); Remaining.horzAlign = "center"; Remaining.vertAlign = "middle"; - Remaining.alignX = "Left"; + Remaining.alignX = "center"; Remaining.alignY = "middle"; - Remaining.y = 0; - Remaining.x = 135; + Remaining.y = 20; + Remaining.x = 0; Remaining.foreground = 1; - Remaining.fontscale = 3.0; + Remaining.fontscale = 2.0; Remaining.alpha = 1; - Remaining.color = ( 1.000, 1.000, 1.000 ); + Remaining.color = ( 0.98, 0.549, 0 ); Countdown = create_simple_hud(); Countdown.horzAlign = "center"; Countdown.vertAlign = "middle"; Countdown.alignX = "center"; Countdown.alignY = "middle"; - Countdown.y = 0; - Countdown.x = -1; + Countdown.y = -20; + Countdown.x = 0; Countdown.foreground = 1; - Countdown.fontscale = 3.0; + Countdown.fontscale = 2.0; Countdown.alpha = 1; Countdown.color = ( 1.000, 1.000, 1.000 ); - Countdown SetText( "Time until game starts:" ); + Countdown SetText( "Match begins in" ); timer = level.wait_time; while ( level.countdown_start == 1 ) @@ -283,28 +242,18 @@ countdownTimer() deleteBuyableDoors() { doors_trigs = getentarray( "zombie_door", "targetname" ); - _a41 = doors_trigs; - _k41 = getFirstArrayKey( _a41 ); - while ( isDefined( _k41 ) ) - { - door = _a41[ _k41 ]; - //deletes the depot main door trigger + foreach ( door in doors_trigs ) door self_delete(); - _k41 = getNextArrayKey( _a41, _k41 ); } } deleteBuyableDebris() { debris_trigs = getentarray( "zombie_debris", "targetname" ); - _a41 = debris_trigs; - _k41 = getFirstArrayKey( _a41 ); - while ( isDefined( _k41 ) ) - { - debris = _a41[ _k41 ]; + foreach ( debris in debris_trigs ) + { //deletes the depot main door trigger debris self_delete(); - _k41 = getNextArrayKey( _a41, _k41 ); } } @@ -315,7 +264,7 @@ gscRestart() return; } level waittill( "end_game" ); - wait 20; + wait 12; map_restart( false ); } diff --git a/GriefFix/instructions.md b/GriefFix/instructions.md new file mode 100644 index 0000000..ba6082b --- /dev/null +++ b/GriefFix/instructions.md @@ -0,0 +1,28 @@ +# Instructions + +## Installing the correct version + +If you want to host a public grief server you need to include this fix otherwise teams don't balance. +I've decided to offer up two versions of the grieffix mod so if you don't want to use the version with bonus settings you can use the basic version. + +### Installing the basic fix + +Compile grief_fix_basic.gsc as _clientids.gsc and place it in maps/mp/gametypes_zm + +### Installing the enhanced version + +Compile grief_fix_enhanced.gsc as _clientids.gsc and place it maps/mp/gametypes_zm + +### Loading up Grief + +Make sure you have the dedicated_zm.cfg and the grief.cfg in gamesettings added from here: +https://github.com/xerxes-at/T6ServerConfigs +Next make an sv_maprotation in the dedicated_zm.cfg with only 1 map loading up the grief map of your choice. +It should look like this +``` +sv_maprotation "exec zgrief.cfg gametype zgrief loc town map zm_transit" +map_rotate +``` +Double check if you have another sv_maprotation set already since that can cause errors. + +Feel free to modify the zgrief.cfg to change a few settings like start round or magic \ No newline at end of file diff --git a/GriefFix/readme.md b/GriefFix/readme.md index 1feca32..2f47444 100644 --- a/GriefFix/readme.md +++ b/GriefFix/readme.md @@ -75,9 +75,6 @@ Town, Farm and Bus Depot //requires one of these maps to be loaded initially and ## Requirements Grief requires gts teamCount "2" to work properly in the server config turn it off when loading non-grief maps -## Better countdown hud -An addon for grief regarding countdown ui, to enable this copy the lines from better-countdown-hud.gsc and replace lines 243 - 246 on main.gsc - ### Changelog //Players are set to spectator state directly instead of being killed Reverted to killing players on Grief only @@ -94,3 +91,5 @@ Fixed a check involving mapMapChange() 4/4/20 Fixed getDvarIntDefault() not properly defining the default dvars +9/16/20 +GrieffFix separated into 2 versions and instructions.md added \ No newline at end of file diff --git a/GriefFix/server_config_dvars.md b/GriefFix/server_config_dvars.md index da576e3..75f62a4 100644 --- a/GriefFix/server_config_dvars.md +++ b/GriefFix/server_config_dvars.md @@ -1,7 +1,13 @@ ``` -//add this to the gts settings -gts teamCount "2" +//These settings apply to both versions +//game delay settings +set waitTime "30" +set playerQuotaActive "1" +set playerQuota "2" +//this controls the simple map rotation between town, farm and bus depot +set mapRotate "1" +//grieff fix enhanced only //put these in your server config //disable or enable settings set randomGameSettings "1" @@ -17,9 +23,6 @@ set electricDoorsDisabledChanceActive "1" set firstRoomOnlyChanceActive "1" set disableBoxMoveChanceActive "1" -//this controls the simple map rotation between town, farm and bus depot -set mapRotate "1" - //change settings chances of happening each time the server restarts set hyperSpeedSpawnsChance "50" set extraDropsChance "15" @@ -32,9 +35,4 @@ set disableJuggChance "30" set electricDoorsDisabledChance "20" set firstRoomOnlyChance "40" set disableBoxMoveChance "10" - -//game delay settings -set waitTime "30" -set playerQuotaActive "1" -set playerQuota "2" ```