Page 1 of 1

[SCRIPT] Intelimode

Posted: Tue Jul 16, 2013 5:00 pm
by thepolm3
Changes gamemodes based on number of players in the server;
REQUIRES MIXED.PY TO WORK
add this line to config with the same number as "game_modes"
Code: Select all
"game_mode_threshold" : [0,1,2,7,20,21,21,etc]
Here da code
Code: Select all
"""
intelimode; Inteligent gamemodes
by thepolm3
"""
from random import randint

def get_mode_index(threshold,nop):
        index = 0
	for i in range(len(threshold)-1):
            if threshold[i] == threshold[i+1]:
                for a in range(i,len(threshold)-1):
                    if threshold[a] != threshold[i]:
                        break
                if threshold[a-1]<= nop < threshold[a]:
                    index=randint(i,a-1)
                    break
                else:
                    i=a
            elif threshold[i] <= nop < threshold[i+1]:
                index=i
                break
        else:
            index=len(threshold)-1
	return index

def apply_script(protocol,connection,config):

        class InteliModeProtocol(protocol):
	
		def on_mode_advance(self,mode,map):
			threshold = config.get("game_mode_threshold",[])
			threshold.append(32)
			if self.map:
                                return config.get("game_modes",[])[get_mode_index(threshold,len(self.players))]
			if "on_mode_advance" in dir(protocol):
                                return protocol.on_mode_advance(self.mode,map)
	return InteliModeProtocol,connection
EDIT: updated for mixed 1.4

Re: [SCRIPT] Intelimode

Posted: Sat Jul 20, 2013 1:55 pm
by thepolm3
Updated for Mixed 1.3

Re: [SCRIPT] Intelimode

Posted: Mon Jul 22, 2013 9:50 pm
by thepolm3
updated for 1.4

Re: [SCRIPT] Intelimode

Posted: Thu Dec 19, 2013 11:35 pm
by Arkger
Looks nice! Can it change maps as well? say, if I had 10 people, I use a smaller map, but if it gets full, I use a full blown map with another gamemode?

Re: [SCRIPT] Intelimode

Posted: Fri Dec 20, 2013 2:06 pm
by thepolm3
for that, you can use "intelimap" instead of "intelimode" and then use "matchmode" to match the mode to the map. Of course you will need mixed.py ;)