diff --git a/code/controllers/configuration.dm b/code/controllers/configuration.dm
index 003cc3b5f84..f16547a21bf 100644
--- a/code/controllers/configuration.dm
+++ b/code/controllers/configuration.dm
@@ -171,6 +171,7 @@
var/list/datum/votablemap/maplist = list()
var/datum/votablemap/defaultmap = null
var/maprotation = 1
+ var/maprotatechancedelta = 0.75
/datum/configuration/New()
var/list/L = typesof(/datum/game_mode) - /datum/game_mode
@@ -360,6 +361,8 @@
config.announce_admin_login = 1
if("maprotation")
config.maprotation = 1
+ if("maprotationchancedelta")
+ config.maprotatechancedelta = text2num(value)
else
diary << "Unknown setting in configuration: '[name]'"
diff --git a/code/controllers/subsystem/ticker.dm b/code/controllers/subsystem/ticker.dm
index cc81d451ba3..06bafa8ebe3 100644
--- a/code/controllers/subsystem/ticker.dm
+++ b/code/controllers/subsystem/ticker.dm
@@ -473,67 +473,7 @@ var/datum/subsystem/ticker/ticker
maprotatechecked = 1
- //map rotate chance is length of the round (in minutes) divided by 2
- if (!prob((world.time/600)/2))
+ //map rotate chance defaults to 75% of the length of the round (in minutes)
+ if (!prob((world.time/600)*config.maprotatechancedelta))
return
-
- var/players = clients.len
- var/list/mapvotes = list()
- //count votes
- for (var/client/c in clients)
- var/vote = c.prefs.preferred_map
- mapvotes[vote] += 1
- //filter votes
- for (var/map in mapvotes)
- if (!map)
- if (!config.defaultmap)
- mapvotes.Remove(map)
- continue
- mapvotes[config.defaultmap.name] += mapvotes[map]
- if (!(map in config.maplist))
- mapvotes.Remove(map)
- continue
- var/datum/votablemap/VM = config.maplist[map]
- if (!VM)
- mapvotes.Remove(map)
- continue
- if (VM.voteweight <= 0)
- mapvotes.Remove(map)
- continue
- if (VM.minusers > 0 && players < VM.minusers)
- mapvotes.Remove(map)
- continue
- if (VM.maxusers > 0 && players < VM.maxusers)
- mapvotes.Remove(map)
- continue
-
- mapvotes[map] = mapvotes[map]*VM.voteweight
-
- var/pickedmap = pickweight(mapvotes)
- if (!pickedmap)
- return
-
- var/file = file("setnewmap.bat")
- file << "\nset MAPROTATE=[pickedmap]\n"
- var/exitcode = shell("..\\bin\\maprotate.bat")
- switch (exitcode)
- if (null)
- message_admins("Failed to rotate map: Could not run map rotator")
- log_game("Failed to rotate map: Could not run map rotator")
- if (0)
- var/datum/votablemap/VM = config.maplist[pickedmap]
- world << "Map rotation has choosen [VM.friendlyname] for next round!"
- if (11)
- message_admins("Failed to rotate map: Map rotator script couldn't find file listing new map")
- log_game("Failed to rotate map: Map rotator script couldn't find file listing new map")
- if (12)
- message_admins("Failed to rotate map: Map rotator script couldn't find tgstation-tools framework")
- log_game("Failed to rotate map: Map rotator script couldn't find tgstation-tools framework")
- if (13)
- message_admins("Failed to rotate map: Could not compile new map:[pickedmap]")
- log_game("Failed to rotate map: Could not compile new map:[pickedmap]")
- else
- message_admins("Failed to rotate map: Unknown error")
- log_game("Failed to rotate map: Unknown error")
-
-
+ maprotate()
\ No newline at end of file
diff --git a/code/modules/admin/admin_verbs.dm b/code/modules/admin/admin_verbs.dm
index f900be95527..be67721314a 100644
--- a/code/modules/admin/admin_verbs.dm
+++ b/code/modules/admin/admin_verbs.dm
@@ -108,7 +108,12 @@ var/list/admin_verbs_server = list(
/client/proc/cmd_admin_delete, /*delete an instance/object/mob/etc*/
/client/proc/cmd_debug_del_all,
/client/proc/toggle_random_events,
+#if SERVERTOOLS
+ /client/proc/forcerandomrotate,
+ /client/proc/adminchangemap,
+#endif
/client/proc/panicbunker
+
)
var/list/admin_verbs_debug = list(
/client/proc/restart_controller,
diff --git a/code/modules/admin/verbs/maprotation.dm b/code/modules/admin/verbs/maprotation.dm
new file mode 100644
index 00000000000..d2313b4c532
--- /dev/null
+++ b/code/modules/admin/verbs/maprotation.dm
@@ -0,0 +1,34 @@
+/client/proc/forcerandomrotate()
+ set category = "Server"
+ set name = "Trigger Random Map Rotation"
+ ticker.maprotatechecked = 1
+ maprotate()
+
+/client/proc/adminchangemap()
+ set category = "Server"
+ set name = "Change Map"
+ var/list/maprotatechoices = list()
+ for (var/map in config.maplist)
+ var/datum/votablemap/VM = config.maplist[map]
+ var/mapname = VM.friendlyname
+ if (VM == config.defaultmap)
+ mapname += " (Default)"
+
+ if (VM.minusers > 0 || VM.maxusers > 0)
+ mapname += " \["
+ if (VM.minusers > 0)
+ mapname += "[VM.minusers]"
+ else
+ mapname += "0"
+ mapname += "-"
+ if (VM.maxusers > 0)
+ mapname += "[VM.maxusers]"
+ else
+ mapname += "inf"
+ mapname += "\]"
+
+ maprotatechoices[mapname] = VM
+ var/choosenmap = input("Choose a map to rotate to", "Change Map") as null|anything in maprotatechoices
+ if (!choosenmap)
+ return
+ changemap(maprotatechoices[choosenmap])
\ No newline at end of file
diff --git a/code/world.dm b/code/world.dm
index e03868be844..79563970489 100644
--- a/code/world.dm
+++ b/code/world.dm
@@ -297,3 +297,77 @@ var/failed_db_connections = 0
return 1
#undef FAILED_DB_CONNECTION_CUTOFF
+
+
+/proc/maprotate()
+ if (!SERVERTOOLS)
+ return
+ var/players = clients.len
+ var/list/mapvotes = list()
+ //count votes
+ for (var/client/c in clients)
+ var/vote = c.prefs.preferred_map
+ if (!vote)
+ if (config.defaultmap)
+ mapvotes[config.defaultmap.name] += 1
+ continue
+ mapvotes[vote] += 1
+
+ //filter votes
+ for (var/map in mapvotes)
+ if (!map)
+ mapvotes.Remove(map)
+ if (!(map in config.maplist))
+ mapvotes.Remove(map)
+ continue
+ var/datum/votablemap/VM = config.maplist[map]
+ if (!VM)
+ mapvotes.Remove(map)
+ continue
+ if (VM.voteweight <= 0)
+ mapvotes.Remove(map)
+ continue
+ if (VM.minusers > 0 && players < VM.minusers)
+ mapvotes.Remove(map)
+ continue
+ if (VM.maxusers > 0 && players < VM.maxusers)
+ mapvotes.Remove(map)
+ continue
+
+ mapvotes[map] = mapvotes[map]*VM.voteweight
+
+ var/pickedmap = pickweight(mapvotes)
+ if (!pickedmap)
+ return
+ var/datum/votablemap/VM = config.maplist[pickedmap]
+ message_admins("Randomly rotating map to [VM.name]([VM.friendlyname])")
+ . = changemap(VM)
+ if (. == 0)
+ world << "Map rotation has choosen [VM.friendlyname] for next round!"
+
+/proc/changemap(var/datum/votablemap/VM)
+ if (!SERVERTOOLS)
+ return
+ if (!istype(VM))
+ return
+ var/file = file("setnewmap.bat")
+ file << "\nset MAPROTATE=[VM.name]\n"
+ . = shell("..\\bin\\maprotate.bat")
+ switch (.)
+ if (null)
+ message_admins("Failed to change map: Could not run map rotator")
+ log_game("Failed to change map: Could not run map rotator")
+ if (0)
+ log_game("Changed to map [VM.friendlyname]")
+ if (11)
+ message_admins("Failed to change map: Map rotator script couldn't find file listing new map")
+ log_game("Failed to change map: Map rotator script couldn't find file listing new map")
+ if (12)
+ message_admins("Failed to change map: Map rotator script couldn't find tgstation-server framework")
+ log_game("Failed to change map: Map rotator script couldn't find tgstation-server framework")
+ if (13)
+ message_admins("Failed to change map: Could not compile new map:[VM.name]")
+ log_game("Failed to change map: Could not compile new map:[VM.name]")
+ else
+ message_admins("Failed to change map: Unknown error")
+ log_game("Failed to change map: Unknown error")
diff --git a/config/config.txt b/config/config.txt
index c7d25266922..e909d642955 100644
--- a/config/config.txt
+++ b/config/config.txt
@@ -207,4 +207,10 @@ ANNOUNCE_ADMIN_LOGOUT
##Map rotation
##This feature requires you are running a Windows OS (or can other wise run .bat files) and that you are using the tgstation-server toolset in tools/
##You should edit maps.txt to match your configuration when you enable this.
-#MAPROTATION
\ No newline at end of file
+#MAPROTATION
+
+##Map rotate chance delta
+##This is the chance of map rotation factored to the round length.
+##A value of 1 would mean the map rotation chance is the round length in minutes (hour long round == 60% rotation chance)
+##A value of 0.5 would mean the map rotation chance is half of the round length in minutes (hour long round == 30% rotation chance)
+#MAPROTATIONCHANCEDELTA 0.75
\ No newline at end of file
diff --git a/tgstation.dme b/tgstation.dme
index 038c2783782..94e07baf4bc 100644
--- a/tgstation.dme
+++ b/tgstation.dme
@@ -859,6 +859,7 @@
#include "code\modules\admin\verbs\machine_upgrade.dm"
#include "code\modules\admin\verbs\manipulate_organs.dm"
#include "code\modules\admin\verbs\mapping.dm"
+#include "code\modules\admin\verbs\maprotation.dm"
#include "code\modules\admin\verbs\massmodvar.dm"
#include "code\modules\admin\verbs\modifyvariables.dm"
#include "code\modules\admin\verbs\one_click_antag.dm"