SOOO an arena map with arena:True in its map extensions will set the gamemode automatically to arena.
If it detects multiple game modes (e.g arena:True, koth:True, onectf:True) It will randomly choose between the modes
You can set a definite mode by putting "game_mode":"arena" in order to ovveride or for new scripts
Now enough dilly dallying; Here is the code
Code: Select all
"""
switches to arena for an arena map, for example
thepolm3
"""
from random import randint
def get_map_extensions(map):
extensions = {}
try:
f = open("maps/"+str(map)+".txt")
exec(f.read())
f.close()
except Exception, e:
print(e)
return extensions
def apply_script(protocol,connection,config):
class MatchModeProtocol(protocol):
oldmode = None
def on_mode_advance(self,mode,map):
extensions = get_map_extensions(map)
if extensions:
game_modes = config.get("game_modes",[])
modes = []
for extension in extensions:
if extension.lower() == "game_mode":
if type(extensions[extension])==list:
modes = extensions[extension]
else:
return extensions["game_mode"]
elif extension.lower() in game_modes:
if extensions[extension.lower()]:
modes.append(extension)
if modes:
return modes[randint(0,len(modes)-1)]
if "on_mode_advance" in dir(protocol):
returned = protocol.on_mode_advance(self,mode,map)
if returned:
return returned
if self.oldmode:
returned = self.oldmode
self.oldmode = None
return returned
return MatchModeProtocol,connection