diff --git a/mapvote/README.md b/mapvote/README.md index 9816125..2e94130 100644 --- a/mapvote/README.md +++ b/mapvote/README.md @@ -77,6 +77,10 @@ Here are the dvars you can configure: | mapvote_blur_fade_in_time | The time (in seconds) it takes for the blur to reach `mapvote_blur_level`. For example if you set it to 10 and `mapvote_blur_level` is 5 then it will progressively blur the screen from 0 to 5 in 10 seconds | 2 | Any number | | mapvote_horizontal_spacing | The horizontal spacing between the map/mode names on the left and the vote counts on the right. I recommend setting this value according to the longest map or mode name length so that it doesn't overlap with the vote counts | 75 | Any plain number | | mapvote_display_wait_time | Once the killcam ends, the time to wait before displaying the vote menu (in seconds) | 1 | Any number superior or equal to 0.05 | +| mapvote_default_rotation_maps | A list of the maps that are available for default rotation | "Hijacked:Raid:Nuketown" | Any map name. Each map is separated with a colon (:) | +| mapvote_default_rotation_modes | A list of the modes that are available for default rotation. It needs to be the name of a CFG file | "tdm" | Any cfg file name. Each cfg file name is separated with a colon (:) | +| mapvote_default_rotation_min_players | The minimum amount of human players required to rotate the default rotation instead of showing the mapvote. If the human players count is smaller than this then it will display the mapvote | 0 | Any plain number from 0 to 18 | +| mapvote_default_rotation_max_players | The maximum amount of human players required to rotate the default rotation instead of showing the mapvote. If the human players count is higher than this then it will display the mapvote | 0 | Any plain number from 0 to 18 | @@ -101,6 +105,9 @@ Here are the dvars you can configure: | mapvote_blur_fade_in_time | The time (in seconds) it takes for the blur to reach `mapvote_blur_level`. For example if you set it to 10 and `mapvote_blur_level` is 5 then it will progressively blur the screen from 0 to 5 in 10 seconds | 2 | Any number | | mapvote_horizontal_spacing | The horizontal spacing between the map names on the left and the vote counts on the right. I recommend setting this value according to the longest map name length so that it doesn't overlap with the vote counts | 75 | Any plain number | | mapvote_display_wait_time | Once the game over screen ends, the time to wait before displaying the vote menu (in seconds) | 1 | Any number above 0.05 | +| mapvote_default_rotation_maps | A list of the maps that are available for default rotation | "Town,zm_standard_town:Farm,zm_standard_farm" | The map name followed by a comma (,) and then the CFG file name. Each block is separated with a colon (:) | +| mapvote_default_rotation_min_players | The minimum amount of human players required to rotate the default rotation instead of showing the mapvote. If the human players count is smaller than this then it will display the mapvote | 0 | Any plain number from 0 to 18 | +| mapvote_default_rotation_max_players | The maximum amount of human players required to rotate the default rotation instead of showing the mapvote. If the human players count is higher than this then it will display the mapvote | 0 | Any plain number from 0 to 18 | diff --git a/mapvote/mapvote.gsc b/mapvote/mapvote.gsc index bd8de46..342ec22 100644 Binary files a/mapvote/mapvote.gsc and b/mapvote/mapvote.gsc differ diff --git a/mapvote/mapvote_mp_extend.gsc b/mapvote/mapvote_mp_extend.gsc index b51609f..174043e 100644 Binary files a/mapvote/mapvote_mp_extend.gsc and b/mapvote/mapvote_mp_extend.gsc differ diff --git a/mapvote/mapvote_zm_extend.gsc b/mapvote/mapvote_zm_extend.gsc index 23e9a01..c6ca773 100644 Binary files a/mapvote/mapvote_zm_extend.gsc and b/mapvote/mapvote_zm_extend.gsc differ diff --git a/mapvote/source/mapvote-source.gsc b/mapvote/source/mapvote-source.gsc index 99cc173..d2d7fc8 100644 --- a/mapvote/source/mapvote-source.gsc +++ b/mapvote/source/mapvote-source.gsc @@ -20,8 +20,7 @@ Init() { if (GetDvarInt("mapvote_enable")) { - level.mapvote_start_function = ::StartVote; - level.mapvote_end_function = ::ListenForEndVote; + level.mapvote_rotate_function = ::DoRotation; InitMapvote(); } @@ -61,10 +60,13 @@ InitDvars() SetDvarIfNotInitialized("mapvote_limits_modes", 0); SetDvarIfNotInitialized("mapvote_sounds_menu_enabled", 1); SetDvarIfNotInitialized("mapvote_sounds_timer_enabled", 1); + SetDvarIfNotInitialized("mapvote_default_rotation_maps", "Hijacked:Raid:Nuketown"); + SetDvarIfNotInitialized("mapvote_default_rotation_modes", "tdm"); } else { SetDvarIfNotInitialized("mapvote_maps", "Bus Depot,Bus Depot,zm_standard_transit:Town,Town,zm_standard_town:Farm,Farm,zm_standard_farm:Mob of The Dead,Mob of The Dead,zm_classic_prison:Nuketown,Nuketown,zm_standard_nuked:Origins,Origins,zm_classic_tomb:Buried,Buried,zm_classic_processing:Die Rise,Die Rise,zm_classic_rooftop"); + SetDvarIfNotInitialized("mapvote_default_rotation_maps", "Town,zm_standard_town:Farm,zm_standard_farm"); } SetDvarIfNotInitialized("mapvote_limits_max", 12); @@ -80,6 +82,8 @@ InitDvars() SetDvarIfNotInitialized("mapvote_blur_fade_in_time", 2); SetDvarIfNotInitialized("mapvote_horizontal_spacing", 75); SetDvarIfNotInitialized("mapvote_display_wait_time", 1); + SetDvarIfNotInitialized("mapvote_default_rotation_min_players", 0); + SetDvarIfNotInitialized("mapvote_default_rotation_max_players", 0); } InitVariables() @@ -662,6 +666,54 @@ GetVoteLimits(mapsAmount, modesAmount) return limits; } +ShouldRotateDefault() +{ + humanPlayersCount = GetHumanPlayers().size; + + if (GetDvarInt("mapvote_default_rotation_max_players") > 0 && humanPlayersCount >= GetDvarInt("mapvote_default_rotation_min_players") && humanPlayersCount <= GetDvarInt("mapvote_default_rotation_max_players")) + { + return true; + } + + return false; +} + +RotateDefault() +{ + mapName = ""; + modeCfg = ""; + + if (IsMultiplayerMode()) + { + modeCfg = GetRandomElementInArray(StrTok(GetDvar("mapvote_default_rotation_modes"), ":")); + mapName = GetMapCodeName(GetRandomElementInArray(StrTok(GetDvar("mapvote_default_rotation_maps"), ":"))); + } + else + { + data = GetRandomElementInArray(StrTok(GetDvar("mapvote_default_rotation_maps"), ":")); + dataSplitted = StrTok(data, ","); + + modeCfg = dataSplitted[1]; + mapName = GetMapCodeName(dataSplitted[0]); + } + + SetDvar("sv_maprotationcurrent", "exec " + modeCfg + ".cfg map " + mapName); + SetDvar("sv_maprotation", "exec " + modeCfg + ".cfg map " + mapName); +} + +DoRotation() +{ + if (ShouldRotateDefault()) + { + RotateDefault(); + } + else + { + StartVote(); + ListenForEndVote(); + } +} + /* HUD section */ diff --git a/mapvote/source/mapvote_mp_extend-source.gsc b/mapvote/source/mapvote_mp_extend-source.gsc index 2186f73..0578e19 100644 --- a/mapvote/source/mapvote_mp_extend-source.gsc +++ b/mapvote/source/mapvote_mp_extend-source.gsc @@ -14,19 +14,19 @@ OnKillcamEnd() { if (isRoundBased() && !wasLastRound()) return false; - wait GetDvarInt("mapvote_display_wait_time"); - [[level.mapvote_start_function]](); - [[level.mapvote_end_function]](); + wait GetDvarInt("mapvote_display_wait_time"); + [[level.mapvote_rotate_function]](); + return false; } level waittill("final_killcam_done"); if (isRoundBased() && !wasLastRound()) return true; - wait GetDvarInt("mapvote_display_wait_time"); - [[level.mapvote_start_function]](); - [[level.mapvote_end_function]](); + wait GetDvarInt("mapvote_display_wait_time"); + [[level.mapvote_rotate_function]](); + return true; } \ No newline at end of file diff --git a/mapvote/source/mapvote_zm_extend-source.gsc b/mapvote/source/mapvote_zm_extend-source.gsc index 05ca19c..b564734 100644 --- a/mapvote/source/mapvote_zm_extend-source.gsc +++ b/mapvote/source/mapvote_zm_extend-source.gsc @@ -35,8 +35,7 @@ OnIntermissionStart() wait GetDvarInt("mapvote_display_wait_time"); - [[level.mapvote_start_function]](); - [[level.mapvote_end_function]](); + [[level.mapvote_rotate_function]](); for (i = 0; i < level.players.size; i++) {