[SCRIPT] Intelimap 1.2

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


Welcome to intelimap!
This is
TB_ wrote:
a script that changes the map based on how many players who are online
Idea by TB_: More info HERE
script:
Code: Select all
"""
thepolm3
idea @ TB_
"""

from twisted.internet.task import LoopingCall
from map import check_rotation
from commands import add
from random import randint

def intelimap(connection):
    connection.protocol.overruled=not connection.protocol.ovveruled
    return ("intelimap is" + ["ON","OFF"][connection.protocol.ovveruled] + "This round")

add(intelimap)
threshold=[]
def apply_script(protocol, connection, config):
    class MapProtocol(protocol):
        overruled=False
        
        def check_next_map(self):
            if not self.overruled:
                nop=len(self.players)
                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]:
                            mapindex=randint(i,a-1)
                            break
                        else:
                            i=a
                    elif threshold[i] <= nop < threshold[i+1]:
                        mapindex=i
                        break
                else:
                    mapindex=len(threshold)-1
                self.planned_map=check_rotation([self.get_map_rotation()[mapindex]])[0]

        def on_command(self,command,sender):
            if command=="map" and sender.admin:
                self.overruled=True
            protocol.on_command(self,command,sender)

        def on_map_change(self,map):
            global threshold
            self.overruled=False
            threshold=config.get("map_threshold",[])
            if threshold==[]:
                nop=self.max_players
                rot=self.get_map_rotation()
                step=nop/len(rot)
                for i in range(len(rot)):
                    threshold.append(i*step)
            checking=LoopingCall(self.check_next_map)
            checking.start(1)
            protocol.on_map_change(self,map)

    return MapProtocol, connection

To set up a custom rotation put the line "map_threshold" in config.txt
Code: Select all
    "maps" : ["hallway","platform","skullisland","pinpoint","classicgen","random","hallway"],
    "map_threshold" : [0,0,0,4,8,12,16],
so if these were in your config, when the map advances with 14 players it is random, with 3 it is a random [hallway, platform, skullisland], with 17 it is hallway and with 9 it is classicgen

Edit: Made the random feature a reality!
Edit: Fixed the reality!
Attachments
intelimap.py
(2.1 KiB) Downloaded 227 times
Last edited by thepolm3 on Thu Jun 06, 2013 4:37 pm, edited 6 times in total.
danhezee
Former Admin / Co-founder
Former Admin / Co-founder
Posts: 1710
Joined: Wed Oct 03, 2012 12:09 am


Looking forward to testing this.
TB_
Post Demon
Post Demon
Posts: 998
Joined: Tue Nov 20, 2012 6:59 pm


Oh my god, I just came back from school. I thought this would take a few days. o.o
Is it possible to have several maps per "step"? Like when it reaches the level where its 12 players, it'll randomly choose between several maps like the stash, rocket island, standoff etc.. ?

And btw, what happens when a mod forces map change to a certain map? This script is best for when the mods aren't constantly watching over the server. So maybe a simple command to enable and disable it would be a good idea? So they can enable it when they aren't watching over the server, and disable it whe nthey are. Blue_Happy1
thepolm3
Scripter
Scripter
Posts: 424
Joined: Sat Feb 16, 2013 10:49 pm


the thing about the random thing is that it uses the existing map rotation in config for simplicity. If you want a pseudo-random one put your intervals close together. E.g [hallway,pinpoint,eggmap],[0,1,2]
enable/disable added ;)
Ninja_pig_pro
Build and Shoot's 1st Birthday
Build and Shoot's 1st Birthday
Posts: 418
Joined: Thu Dec 20, 2012 1:24 pm


Okay what we need is a server that uses thepolm3's scripts.
thepolm3
Scripter
Scripter
Posts: 424
Joined: Sat Feb 16, 2013 10:49 pm


Icecraft ftw
IceCream
Hoster
Hoster
Posts: 322
Joined: Thu Nov 01, 2012 12:18 pm


thepolm3 wrote:
Icecraft ftw
thepolm3 ftw :3
TB_
Post Demon
Post Demon
Posts: 998
Joined: Tue Nov 20, 2012 6:59 pm


hey thepolm, what is the timer set to?
Like, when it hits 8 players, how long does it have to hae 8 players before it changes to classicgen?
thepolm3
Scripter
Scripter
Posts: 424
Joined: Sat Feb 16, 2013 10:49 pm


ah, you misunderstand. The way it works is to set the NEXT map based on the number of players, so either when the intel cap is reached or when the timer runs out. YOu understand that the map would just be too complex if it was fixed when a certain number of players join
colorpinpoint
League Champs
League Champs
Posts: 60
Joined: Tue Nov 06, 2012 11:06 pm


Line 13 had a syntax error. Supposed to be:

return ("intelimap is ['ON', 'OFF'][connection.protocol.ovveruled] This round")

instead of:
return ("intelimap is" ["ON","OFF"][connection.protocol.ovveruled] "This round")
thepolm3
Scripter
Scripter
Posts: 424
Joined: Sat Feb 16, 2013 10:49 pm


sorry, but actually it should be
return ("intelimap is" + ["ON","OFF"][connection.protocol.ovveruled] + "This round")
sorry to correct your correction, and thanks for drawing my attention to it
Kamikaze_Blargle
Blue Master Race
Blue Master Race
Posts: 263
Joined: Mon Dec 17, 2012 5:43 pm


thepolm3 wrote:
the thing about the random thing is that it uses the existing map rotation in config for simplicity. If you want a pseudo-random one put your intervals close together. E.g [hallway,pinpoint,eggmap],[0,1,2]
Wouldn't you be able to put:
Code: Select all
    "maps" : ["pinpoint", "hallway", "classicgen", "random", "hallway"],
    "map_threshold" : [0,1,1,2,2] 
Where if the playercount is 1, it would choose either hallway or classicgen...
or if it was 2, it would choose either random or hallway.
Would this work? :/
thepolm3
Scripter
Scripter
Posts: 424
Joined: Sat Feb 16, 2013 10:49 pm


that, my friend, will be an implementation
Kamikaze_Blargle
Blue Master Race
Blue Master Race
Posts: 263
Joined: Mon Dec 17, 2012 5:43 pm


kk then, im a little new to scripting <3
thepolm3
Scripter
Scripter
Posts: 424
Joined: Sat Feb 16, 2013 10:49 pm


Kamikaze_Blargle wrote:
kk then, im a little new to scripting <3
Here we go! Now everyone's happy!
26 posts Page 1 of 2 First unread post
Return to “Completed Releases”

Who is online

Users browsing this forum: No registered users and 30 guests