[SCRIPT] Intelimode

Intended for use on live public servers.
5 posts Page 1 of 1 First unread post
thepolm3
Scripter
Scripter
Posts: 424
Joined: Sat Feb 16, 2013 10:49 pm


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
Attachments
intelimode.py
(1.19 KiB) Downloaded 321 times
Last edited by thepolm3 on Mon Jul 22, 2013 9:50 pm, edited 1 time in total.
thepolm3
Scripter
Scripter
Posts: 424
Joined: Sat Feb 16, 2013 10:49 pm


Updated for Mixed 1.3
thepolm3
Scripter
Scripter
Posts: 424
Joined: Sat Feb 16, 2013 10:49 pm


updated for 1.4
Arkger
League Participant
League Participant
Posts: 371
Joined: Sat Nov 02, 2013 6:31 pm


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?
thepolm3
Scripter
Scripter
Posts: 424
Joined: Sat Feb 16, 2013 10:49 pm


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 ;)
5 posts Page 1 of 1 First unread post
Return to “Completed Releases”

Who is online

Users browsing this forum: No registered users and 1 guest