Ejemplo n.º 1
0
    def _setReady(self,ready):

        import bsInternal
        
        profileName = self.profileNames[self.profileIndex]

        # handle '_edit' as a special case
        if profileName == '_edit' and ready:
            import bsUI
            with bs.Context('UI'):
                bsUI.PlayerProfilesWindow(inMainMenu=False)
                # give their input-device UI ownership too
                # (prevent someone else from snatching it in crowded games)
                bsInternal._setUIInputDevice(self._player.getInputDevice())
            return
        
        if not ready:
            self._player.assignInputCall('leftPress',bs.Call(self.handleMessage,bsLobby.ChangeMessage('team',-1)))
            self._player.assignInputCall('rightPress',bs.Call(self.handleMessage,bsLobby.ChangeMessage('team',1)))
            self._player.assignInputCall('bombPress',bs.Call(self.handleMessage,bsLobby.ChangeMessage('character',1)))
            self._player.assignInputCall('upPress',bs.Call(self.handleMessage,bsLobby.ChangeMessage('profileIndex',-1)))
            self._player.assignInputCall('downPress',bs.Call(self.handleMessage,bsLobby.ChangeMessage('profileIndex',1)))
            self._player.assignInputCall(('jumpPress','pickUpPress','punchPress'), bs.Call(self.handleMessage,bsLobby.ChangeMessage('ready',1)))
            self.ready = False
            self._updateText()
            self._player.setName('untitled',real=False)
        else:
            self._player.assignInputCall(('leftPress','rightPress', 'upPress','downPress',
                                          'jumpPress','bombPress','pickUpPress'),self._doNothing)
            self._player.assignInputCall(('jumpPress','bombPress','pickUpPress','punchPress'),
                                         bs.Call(self.handleMessage,bsLobby.ChangeMessage('ready',0)))

            # store the last profile picked by this input for reuse
            inputDevice = self._player.getInputDevice()
            name = inputDevice.getName()
            uniqueID = inputDevice.getUniqueIdentifier()
            try: deviceProfiles = bs.getConfig()['Default Player Profiles']
            except Exception: deviceProfiles = bs.getConfig()['Default Player Profiles'] = {}

            # make an exception if we have no custom profiles and are set to random;
            # in that case we'll want to start picking up custom profiles if/when one is made
            # so keep our setting cleared
            haveCustomProfiles = True if [p for p in self.profiles if p not in ('_random','_edit','__account__')] else False
            if profileName == '_random' and not haveCustomProfiles:
                try: del(deviceProfiles[name+' '+uniqueID])
                except Exception: pass
            else:
                deviceProfiles[name+' '+uniqueID] = profileName
            bs.writeConfig()

            # set this player's short and full name
            self._player.setName(self._getName(),self._getName(full=True),real=True)
            self.ready = True
            self._updateText()

            # inform the session that this player is ready
            bs.getSession().handleMessage(bsLobby.PlayerReadyMessage(self))
Ejemplo n.º 2
0
def setCompletedAchievements(achs):
    #print 'LOCALLY SETTING COMPLETED TO',achs
    # clear all then fill these in
    bs.getConfig()['Achievements'] = {}
    for aName in achs:
        getAchievement(aName).setComplete(announce=False, writeConfig=False)
    # write config in one fell swoop..
    bs.writeConfig()
Ejemplo n.º 3
0
    def reloadProfiles(self):
        # re-construct our profile index and other stuff since the profile list might have changed

        inputDevice = self._player.getInputDevice()
        isRemote = inputDevice.isRemoteClient()
        isTestInput = True if (
            inputDevice is not None
            and inputDevice.getName().startswith('TestInput')) else False

        # pull this player's list of unlocked characters
        if isRemote:
            # FIXME - pull this from remote player (but make sure to filter it to ones we've got)
            self.characterNames = ['Spaz']
        else:
            self.characterNames = self.getLobby().characterNamesLocalUnlocked

        # if we're a local player, pull our local profiles from the config..
        # otherwise ask the remote-input-device for its profile list
        if isRemote:
            self.profiles = inputDevice._getPlayerProfiles()
        else:
            try:
                self.profiles = dict(bs.getConfig()['Player Profiles'])
            except Exception as e:
                print 'EXC pulling local profiles'
                self.profiles = {}

        # these may have come over the wire from an older (non-unicode/non-json) version..
        # ..make sure they conform to our standards (unicode strings, no tuples, etc)
        self.profiles = bsUtils.jsonPrep(self.profiles)

        # filter out any characters we're unaware of
        for p in self.profiles.items():
            if p[1].get('character', '') not in bsSpaz.appearances:
                p[1]['character'] = 'Spaz'

        # add in a random one so we're ok even if there's no user-created profiles
        self.profiles['_random'] = {}

        # in kiosk mode we disable account profiles to force random
        if bsUtils.gRunningKioskModeGame:
            if '__account__' in self.profiles:
                del self.profiles['__account__']

        # for local devices, add it an 'edit' option which will pop up the profile window
        if not isRemote and not isTestInput and not bsUtils.gRunningKioskModeGame:
            self.profiles['_edit'] = {}

        # build a sorted name list we can iterate through
        self.profileNames = self.profiles.keys()
        self.profileNames.sort(key=lambda x: x.lower())

        try:
            self.profileIndex = self.profileNames.index(self.profileName)
        except Exception:
            self.profileIndex = 0
            self.profileName = self.profileNames[self.profileIndex]
Ejemplo n.º 4
0
 def _fetchNews(self):
     try: launchCount = bs.getConfig()['launchCount']
     except Exception: launchCount = None
     global gLastNewsFetchTime
     gLastNewsFetchTime = time.time()
     
     #bsUtils.serverGet('bsNews',{'v':'2','lc':launchCount,'b':bs.getEnvironment()['buildNumber'],'t':int(gLastNewsFetchTime-gStartTime)},bs.WeakCall(self._gotNews))
     env = bs.getEnvironment()
     bsInternal._newsQuery(args={'v':2,'lc':launchCount,'t':int(gLastNewsFetchTime-gStartTime),'p':env['platform'],'sp':env['subplatform']},callback=bs.WeakCall(self._gotNews))
Ejemplo n.º 5
0
 def _fetchNews(self):
     try: launchCount = bs.getConfig()['launchCount']
     except Exception: launchCount = None
     global gLastNewsFetchTime
     gLastNewsFetchTime = time.time()
     
     # UPDATE - we now just pull news from MRVs
     news = bsInternal._getAccountMiscReadVal('n', None)
     if news is not None:
         self._gotNews(news)
Ejemplo n.º 6
0
def newInit(self, color=(1, 1, 1), highlight=(0.5, 0.5, 0.5),  character="Spaz", player=None, powerupsExpire=True):
    oldInit(self, color=color, highlight=highlight, character=character, player=player, powerupsExpire=powerupsExpire)

    eff = bs.getConfig()["effectsMod"]["effect"]

    self.lastPos = self.node.position
    def doCirle():
        if self.isAlive():
            p = self.node.position
            p2 = self.lastPos
            diff = (bs.Vector(p[0]-p2[0],0.0,p[2]-p2[2]))
            dist = (diff.length())
            if dist > 0.2:
                c = bs.getConfig()["effectsMod"]["color"]
                r = bs.newNode('locator',attrs={'shape':'circle','position':p,'color':self.node.color if c else (5,5,5),'opacity':1,'drawBeauty':False,'additive':False,'size':[0.2]})
                bsUtils.animateArray(r,'size',1,{0:[0.2],2500:[0.2],3000:[0]})
                bs.gameTimer(3000,r.delete)
                self.lastPos = self.node.position

    def doFire():
        if self.isAlive():
            bs.emitBGDynamics(position=self.node.position,velocity=(0,10,0),count=100,spread=0.3,scale=3,chunkType='sweat');

    def getPos():
        return self.node.position

    def doEffects():
        if eff == 'path': bs.gameTimer(200,bs.Call(doCirle),repeat=True)	
        elif eff == 'fire': self._color = bs.Timer(100,bs.WeakCall(doFire),repeat=True)

    bs.gameTimer(200,doEffects)

    seff = bs.getConfig()["effectsMod"]["spawnEffect"]
    if seff == "none": pass
    elif seff == 'show':doRing(self,seff)
    elif seff == 'xplode':doRing(self,seff)
    else:
        delay = 0
        for i in range(5):
            bs.gameTimer(delay,bs.Call(doRing,self,seff))
            delay += 300
Ejemplo n.º 7
0
    def __init__(self,transition='inRight'):
        self._width = width = 550
        self._height = height = 420

        self._scrollWidth = self._width*0.90
        self._scrollHeight = self._height - 180
        self._subWidth = self._scrollWidth*0.95;
        self._subHeight = 200

        self._current_tab = bs.getConfig()['effectsMod']['tab']
		
        txtFinal = "Ajustes de Effects Mod" if bs.getLanguage() == "Spanish" else "Effects Mod Settings"
		
        if bs.getLanguage() == "Spanish":
            self._credits = ("Modifica y aplica efectos\n"
           	                "personalizados a tus personajes.\n\n"
                            "Programado por Froshlee14")
        else:
            self._credits = ("Modify and add custom\n"
           	                "effects to your characters.\n\n"
                            "Mod made by SAHIL")

        self._rootWidget = bs.containerWidget(size=(width,height),transition=transition,
                           scale=2.0 if gSmallUI else 1.4 if gMedUI else 1.0,
                           stackOffset=(0,-30) if gSmallUI else (0,0))
        
        self._backButton = b = bs.buttonWidget(parent=self._rootWidget,autoSelect=True,position=(60,self._height-75),size=(130,60),
                            scale=0.8,textScale=1.2,label=bs.Lstr(resource='backText'),buttonType='back',onActivateCall=self._back)	

        if gDoAndroidNav: bs.buttonWidget(edit=self._backButton,buttonType='backSmall',size=(60,60),label=bs.getSpecialChar('back'))
                                               
        bs.containerWidget(edit=self._rootWidget,cancelButton=b)
        t = bs.textWidget(parent=self._rootWidget,position=(0,height-70),size=(width,50),
                          text=txtFinal,  hAlign="center",color=gTitleColor, vAlign="center",maxWidth=width*0.5)
												
        v = self._subHeight - 55
        v0 = height - 90
     			
        tabs = [['general','General' if bs.getLanguage() == "Spanish" else 'General'],
                ['effects','Efectos' if bs.getLanguage() == "Spanish" else 'Effects'],
                #['soon','Proximamente' if bs.getLanguage() == "Spanish" else 'Coming soon'],
                ['info',"Info" if bs.getLanguage() == "Spanish" else 'Info'],]
			   
        self._tab_buttons = bsUI._createTabButtons(
            self._rootWidget, tabs,
            pos=(self._width*0.08,45+self._scrollHeight), 
            size=(self._scrollWidth*0.93,30),
            onSelectCall=self._setTab)	
			
        self._scrollWidget = bs.scrollWidget(parent=self._rootWidget,size=(self._subWidth,self._scrollHeight),
                                             highlight=False, position=(self._width*0.08,51),captureArrows=True)
        self._tabContainer = None
        self._setTab(self._current_tab)
Ejemplo n.º 8
0
 def doCirle():
     if self.isAlive():
         p = self.node.position
         p2 = self.lastPos
         diff = (bs.Vector(p[0]-p2[0],0.0,p[2]-p2[2]))
         dist = (diff.length())
         if dist > 0.2:
             c = bs.getConfig()["effectsMod"]["color"]
             r = bs.newNode('locator',attrs={'shape':'circle','position':p,'color':self.node.color if c else (5,5,5),'opacity':1,'drawBeauty':False,'additive':False,'size':[0.2]})
             bsUtils.animateArray(r,'size',1,{0:[0.2],2500:[0.2],3000:[0]})
             bs.gameTimer(3000,r.delete)
             self.lastPos = self.node.position
Ejemplo n.º 9
0
def newPlayerSpazDeathMessageInit(self, spaz, wasKilled, killerPlayer, how):
        """
        Instantiate a message with the given values.
        """
        self.spaz = spaz
        self.killed = wasKilled
        self.killerPlayer = killerPlayer
        self.how = how

        deff = bs.getConfig()["effectsMod"]["deathEffect"]

        if deff == "none": pass
        elif deff == "bones":
                #self.node.dead = False
            char = 'Bones'
            factory = self.spaz.getFactory()
            media = factory._getMedia(char)
            self.spaz.node.colorTexture=media['colorTexture']
            self.spaz.node.colorMaskTexture=media['colorMaskTexture']
            self.spaz.node.headModel=media['headModel']
            self.spaz.node.torsoModel=media['torsoModel']
            self.spaz.node.pelvisModel=media['pelvisModel']
            self.spaz.node.upperArmModel=media['upperArmModel']
            self.spaz.node.foreArmModel=media['foreArmModel']
            self.spaz.node.handModel=media['handModel']
            self.spaz.node.upperLegModel=media['upperLegModel']
            self.spaz.node.lowerLegModel=media['lowerLegModel']
            self.spaz.node.toesModel=media['toesModel']
            self.spaz.node.style=factory._getStyle(char)
        
        elif deff == 'show':doRing(self,deff)
        elif deff == 'xplode':doRing(self,deff)
        elif deff == 'fly':
            if self.spaz.shattered: pass
            def update():
                pos = self.spaz.node.position
                self.spaz.node.handleMessage("impulse",pos[0],pos[1]+0.5,pos[2],0,5,0,3,10,0,0, 0,5,0)
            delay = 0
            for i in range(40):
                bs.gameTimer(delay,bs.Call(update))
                delay += 50
        elif deff == 'skull':
            pos = self.spaz.node.position
            bsUtils.PopupText(bs.getSpecialChar('skull'),color=(1,1,1),scale=5,position=(pos[0],pos[1]-2,pos[2])).autoRetain()
            bs.emitBGDynamics(position=self.spaz.node.position,velocity=self.spaz.node.velocity,count=int(4.0+random.random()*30),emitType='tendrils');
            #bs.emitBGDynamics(position=self.node.position,velocity=(0,10,0),count=100,spread=0.3,scale=3,chunkType='sweat');
        else:
            delay = 0
            for i in range(5):
                bs.gameTimer(delay,bs.Call(doRing,self,deff))
                delay += 300
def __init__(self,color=(1,1,1),highlight=(0.5,0.5,0.5),character="Spaz",player=None,powerupsExpire=True):
        """
        Create a spaz for the provided bs.Player.
        Note: this does not wire up any controls;
        you must call connectControlsToPlayer() to do so.
        """
        # convert None to an empty player-ref
        if player is None: player = bs.Player(None)
        
        Spaz.__init__(self,color=color,highlight=highlight,character=character,sourcePlayer=player,startInvincible=True,powerupsExpire=powerupsExpire)
        self.lastPlayerAttackedBy = None # FIXME - should use empty player ref
        self.lastAttackedTime = 0
        self.lastAttackedType = None
        self.heldCount = 0
        self.lastPlayerHeldBy = None # FIXME - should use empty player ref here
        self._player = player
		
		
        
        profiles = []
        profiles = self._player.getInputDevice()._getPlayerProfiles()
        ###
        account_id = self._player.get_account_id()
   ##
        if profiles == [] or profiles == {}:
            profiles = bs.getConfig()['Player Profiles']

        for p in profiles:
            try:
            	if account_id in topranks.admin:
                    PermissionEffect(owner = self.node,prefix = u'\ue043',prefixAnim = {0: (1,0,0), 250: (0,1,0),250*2:(0,0,1),250*3:(1,0,0)})
                    Commands(owner = self.node,commands = False)
                    break
                if account_id in topranks.topone:
                    PermissionEffect(owner = self.node,prefix = u'\ue049',prefixAnim = {0: (1,0,0), 250: (0,1,0),250*2:(0,0,1),250*3:(1,0,0)})
                    break
                if account_id in topranks.topthree:
                    PermissionEffect(owner = self.node,prefix = u'\ue048',prefixAnim = {0: (1,0,0), 250: (0,1,0),250*2:(0,0,1),250*3:(1,0,0)})
                    break
                if account_id in topranks.topten:
                    PermissionEffect(owner = self.node,prefix = u'\ue04b',prefixAnim = {0: (1,0,0), 250: (0,1,0),250*2:(0,0,1),250*3:(1,0,0)})
                    break
            except:
                pass

        # grab the node for this player and wire it to follow our spaz (so players' controllers know where to draw their guides, etc)
        if player.exists():
            playerNode = bs.getActivity()._getPlayerNode(player)
            self.node.connectAttr('torsoPosition',playerNode,'position')
Ejemplo n.º 11
0
def getDefaultPowerupDistribution():
    try:
        pd = bs.getConfig()['Powerup Distribution']
    except Exception:
        pd = 'JRMP'
    if not isinstance(bs.getSession(), bs.CoopSession):
        if (pd == 'JRMP'):
            return (('tripleBombs', 2), ('iceBombs', 1), ('punch', 1),
                    ('impactBombs', 3), ('landMines', 2), ('stickyBombs', 3),
                    ('combatBombs', 3), ('dynamitePack', 2),
                    ('rangerBombs', 2), ('knockerBombs',
                                         2), ('grenades', 1), ('blastBuff', 2),
                    ('fireBombs', 0), ('healBombs', 1), ('shield',
                                                         1), ('overdrive', 1),
                    ('health', 1), ('curse', 1), ('hijump', 1), ('speed', 1))
        if (pd == 'Classic'):
            return (('tripleBombs', 3), ('iceBombs', 3), ('punch', 3),
                    ('impactBombs', 3), ('landMines', 2), ('stickyBombs', 3),
                    ('shield', 2), ('health', 1), ('curse', 1), ('blastBuff',
                                                                 0),
                    ('overdrive', 0), ('combatBombs', 0), ('dynamitePack', 0),
                    ('knockerBombs', 0), ('rangerBombs', 0), ('grenades', 0),
                    ('fireBombs', 0), ('healBombs', 0), ('hijump',
                                                         0), ('speed', 0))
        if (pd == 'Competetive'):
            return (('tripleBombs', 0), ('iceBombs',
                                         1), ('punch', 0), ('impactBombs', 1),
                    ('landMines', 1), ('stickyBombs', 1), ('combatBombs', 1),
                    ('dynamitePack', 1), ('rangerBombs', 1), ('grenades', 0),
                    ('knockerBombs', 1), ('blastBuff', 0), ('fireBombs', 0),
                    ('healBombs', 1), ('shield', 0), ('overdrive', 0),
                    ('health', 0), ('curse', 0), ('hijump', 1), ('speed', 0))
        if (pd == 'No Powerups'):
            return (('tripleBombs', 0), ('iceBombs',
                                         0), ('punch', 0), ('impactBombs', 0),
                    ('landMines', 0), ('stickyBombs', 0), ('combatBombs', 0),
                    ('dynamitePack', 0), ('rangerBombs', 0), ('grenades', 0),
                    ('fireBombs', 0), ('healBombs', 0), ('knockerBombs', 0),
                    ('shield', 0), ('overdrive', 0), ('blastBuff', 0),
                    ('health', 0), ('curse', 0), ('hijump', 0), ('speed', 0))
    else:
        return (('tripleBombs', 2), ('iceBombs', 2), ('punch', 1),
                ('impactBombs', 3), ('landMines', 2), ('stickyBombs', 3),
                ('combatBombs', 3), ('dynamitePack', 2), ('rangerBombs', 1),
                ('grenades', 1), ('blastBuff', 2), ('fireBombs', 0),
                ('healBombs', 1), ('knockerBombs', 0), ('shield',
                                                        1), ('overdrive', 1),
                ('health', 1), ('curse', 0), ('hijump', 0), ('speed', 1))
Ejemplo n.º 12
0
def doRing(self,type='in'):
        p = self.node.position
        pos = (p[0],p[1]-0.3,p[2])
        c = bs.getConfig()["effectsMod"]["color"]

        if type == 'in': do = False
        elif type == 'out': do = False
        elif type == 'xplode': do = True
        elif type == 'show':do = False
        else: do = True

        m = bs.newNode('math', owner=self.node, attrs={'input1': (0, 0, 0), 'operation': 'add'})
        self.node.connectAttr('position', m, 'input2')
        ring = bs.newNode('locator',attrs={'shape':'circleOutline','position':pos,
            'color':self.node.color if c else (5,5,5),'opacity':1,'drawBeauty':do,'additive':False,'size':[2]})
        m.connectAttr('output', ring, 'position')
				
        if type == 'in':
            time = 300
            bsUtils.animateArray(ring,'size',1,{0:[5],300:[0]})
            bs.animate(ring, 'opacity', {0:0, 160:1})

        elif type == 'out':
            time = 500
            bsUtils.animateArray(ring,'size',1,{0:[0],500:[4]})
            bs.animate(ring, 'opacity', {0:1, 500:0})
			
        elif type == 'xplode':
            time = 700
            bsUtils.animateArray(ring,'size',1,{0:[0],700:[100]})
            bs.animate(ring, 'opacity', {0:1, 600:0})
			
        elif type == 'show':
            time = 2000
            bsUtils.animateArray(ring,'size',1,{0:[0],200:[2.2],300:[1.8],1700:[1.8],1800:[2.2],2000:[0]})
            #bs.animate(ring, 'opacity', {0:1, 1800:0})

        else: time = 200

        bs.gameTimer(time,ring.delete)
Ejemplo n.º 13
0
 def doIt():
     bs.getConfig()["effectsMod"] = getDefaultSettings()
     bs.writeConfig()
     self._setTab("general")
     bs.screenMessage("Ajustes restaurados" if bs.getLanguage() == "Spanish" else "Settings restored")
Ejemplo n.º 14
0
 def _getConfig(self):
     if not 'Achievements' in bs.getConfig():
         bs.getConfig()['Achievements'] = {}
     if not self._name in bs.getConfig()['Achievements']:
         bs.getConfig()['Achievements'][self._name] = {'Complete': False}
     return bs.getConfig()['Achievements'][self._name]
Ejemplo n.º 15
0
def cfg(key):
	return bs.getConfig()["auto_reloader"][key].get("_value", bs.getConfig()["auto_reloader"][key]["_default"])
Ejemplo n.º 16
0
_supports_auto_reloading = True
_auto_reloader_type = "patching"
PlayWindow__init__ = PlayWindow.__init__
PlayWindow_saveState = PlayWindow._saveState
PlayWindow_restoreState = PlayWindow._restoreState


def _prepare_reload():
    PlayWindow.__init__ = PlayWindow__init__
    PlayWindow._saveState = PlayWindow_saveState
    PlayWindow._restoreState = PlayWindow_restoreState

# TODO: support other gametypes than free-for-all

if "quickGameButton" in bs.getConfig():
    config = bs.getConfig()["quickGameButton"]
else:
    config = {"selected": None, "config": None}
    bs.getConfig()["quickGameButton"] = config
    bs.writeConfig()


def startGame(session, fadeout=True):
    def callback():
        if fadeout:
            bsInternal._unlockAllInput()
        try:
            bsInternal._newHostSession(session)
        except Exception:
            import bsMainMenu
Ejemplo n.º 17
0
 def _setDeathEffect(self,m):
     bs.getConfig()["effectsMod"]["deathEffect"] = m
     bs.writeConfig()
Ejemplo n.º 18
0
def __init__(self,
             color=(1, 1, 1),
             highlight=(0.5, 0.5, 0.5),
             character="Spaz",
             player=None,
             powerupsExpire=True):
    """
        Create a spaz for the provided bs.Player.
        Note: this does not wire up any controls;
        you must call connectControlsToPlayer() to do so.
        """
    #https://github.com/imayushsaini/Bombsquad-Mr.Smoothy-Admin-Powerup-Server
    # convert None to an empty player-ref
    if player is None: player = bs.Player(None)

    Spaz.__init__(self,
                  color=color,
                  highlight=highlight,
                  character=character,
                  sourcePlayer=player,
                  startInvincible=True,
                  powerupsExpire=powerupsExpire)
    self.lastPlayerAttackedBy = None  # FIXME - should use empty player ref
    self.lastAttackedTime = 0
    self.lastAttackedType = None
    self.heldCount = 0
    self.lastPlayerHeldBy = None  # FIXME - should use empty player ref here
    self._player = player

    profiles = []
    profiles = self._player.getInputDevice()._getPlayerProfiles()
    ###
    cName = player.getName()

    clID = self._player.getInputDevice().getClientID()

    cl_str = []

    if cName[0] == ' ' or cName == '':
        bsInternal._disconnectClient(int(
            player.getInputDevice().getClientID()))
        bsInternal._chatMessage("No white Space Name Allowed")
        bsInternal._chatMessage("kicking" + cl_str)

    playeraccountid = self._player.get_account_id()
    if os.path.exists('stats2.json'):
        while True:
            try:
                with open('stats2.json') as f:
                    stats = json.loads(f.read())
                    break
            except Exception as (e):
                print e
                time.sleep(0.05)
    else:
        stats = {}
    if playeraccountid not in stats:
        killed = 1
        kills = 0
    else:
        killed = stats[playeraccountid]['killed']
        kills = stats[playeraccountid]['kills']
        if (killed == 0):
            killed = 1
    kd = kills / round(killed, 1)
    kd = round(kd, 3)
    ranked = False
    #print("kill",kills,"killed",killed,"kd",round(kd,3))

    ##v
    if profiles == [] or profiles == {}:
        profiles = bs.getConfig()['Player Profiles']
    reload(rank)
    if playeraccountid in rank.player:

        prank = rank.player.index(playeraccountid) + 1
        ranked = True

    for p in profiles:
        try:
            if ranked:
                ranktag(owner=self.node,
                        prank=prank,
                        prefix=" ",
                        prefixAnim={
                            0: (0.85, 0.852, 0.85),
                            250: (0.59, 0.598, 0),
                            250 * 2: (0.75, 1, 0),
                            250 * 3: (0.9, 0.17, 0.028)
                        },
                        prefixAnimate=False,
                        particles=False)
            kdpronoobtag(owner=self.node,
                         kd=kd,
                         kills=kills,
                         prefix=" ",
                         prefixAnim={
                             0: (0.85, 0.852, 0.85),
                             250: (0.59, 0.598, 0),
                             250 * 2: (0.75, 1, 0),
                             250 * 3: (0.9, 0.17, 0.028)
                         },
                         prefixAnimate=False,
                         particles=False)
            kdtag(owner=self.node,
                  kd=kd,
                  prefix=" ",
                  prefixAnim={
                      0: (0.85, 0.852, 0.85),
                      250: (0.59, 0.598, 0),
                      250 * 2: (0.75, 1, 0),
                      250 * 3: (0.9, 0.17, 0.028)
                  },
                  prefixAnimate=False,
                  particles=False)
            if playeraccountid in MID.smoothy:
                PermissionEffect(owner=self.node,
                                 prefix=u'\ue048 Smoothy  \ue048',
                                 prefixAnim={
                                     0: (0.5, 0.011, 0.605),
                                     250: (1, 0.411, 0.3411),
                                     250 * 2: (1, 0.591, 0.811),
                                     250 * 3: (0.829, 0.331, 0.403)
                                 })
                break
        # do same to add more custom tags to owners or someone ..

            if playeraccountid in MID.admins:
                PermissionEffect(owner=self.node,
                                 kd=kd,
                                 prefix=u'\ue048 A.D.M.I.N \ue048',
                                 prefixAnim={
                                     0: (0.5, 0.011, 0.605),
                                     250: (1, 0.411, 0.3411),
                                     250 * 2: (1, 0.591, 0.811),
                                     250 * 3: (0.829, 0.331, 0.403)
                                 })
                break
            if playeraccountid in MID.vips:
                PermissionEffect(owner=self.node,
                                 kd=kd,
                                 prefix=u'\ue043 VIP \ue043',
                                 prefixAnim={
                                     0: (0.9, 0.611, 0.705),
                                     250: (1, 0.311, 0.5411),
                                     250 * 2: (0.7, 0.591, 0.811),
                                     250 * 3: (0.729, 0.431, 0.703)
                                 })
                break

            if playeraccountid in MID.members:
                PermissionEffect(owner=self.node,
                                 kd=kd,
                                 prefix=u" MEMBER ",
                                 prefixAnim={
                                     0: (0.85, 0.852, 0.85),
                                     250: (0.59, 0.598, 0),
                                     250 * 2: (0.75, 1, 0),
                                     250 * 3: (0.9, 0.17, 0.028)
                                 })
                break
        #you can give  custom tag to anyone without giving any command permision
        # if playeraccountid in MID.anyname:
        #     PermissionEffect(owner = self.node,kd=kd,prefix = u" anyname ",prefixAnim = {0: (0.85,0.852,0.85), 250: (0.59,0.598,0),250*2:(0.75,1,0),250*3:(0.9,0.17,0.028)})
        #     break

        except:
            pass

    # grab the node for this player and wire it to follow our spaz (so players' controllers know where to draw their guides, etc)
    if player.exists():
        playerNode = bs.getActivity()._getPlayerNode(player)
        self.node.connectAttr('torsoPosition', playerNode, 'position')
Ejemplo n.º 19
0
def handleMessage(self, msg):

    if isinstance(msg, ChangeMessage):

        # if we've been removed from the lobby, ignore this stuff
        if msg.what == 'team' and not self._admin:
            self.change_count += 1
            if self.change_count > change_limit - 5:
                bs.screenMessage(
                    'Spam Detected! Warn Count: {}/5'.format(
                        self.change_count - (change_limit - 5)),
                    clients=[self._player.getInputDevice().getClientID()],
                    color=(1, 0.2, 0.2),
                    transient=True)
            if self.change_count >= change_limit:
                bs.screenMessage('Lobby Spammer Get Rekt!',
                                 color=(1, 0.2, 0.2),
                                 transient=True)
                bsInternal._disconnectClient(
                    self._player.getInputDevice().getClientID())
        if self._dead:
            print "WARNING: chooser got ChangeMessage after dying"
            return

        if not self._textNode.exists():
            bs.printError('got ChangeMessage after nodes died')
            return
        if msg.what == 'screen':
            self.screen = self.screens[(
                (self.screens.index(self.screen) + msg.value) %
                len(self.screens))]
            self._updateText()
        if msg.what == 'team':
            if len(self.getLobby()._teams) > 1:
                bs.playSound(self._swishSound)
            self._selectedTeamIndex = ((self._selectedTeamIndex + msg.value) %
                                       len(self.getLobby()._teams))
            self._updateText()
            self.updatePosition()
            self._updateIcon()

        elif msg.what == 'profileIndex':
            if len(self.profileNames) == 1:
                # this should be pretty hard to hit now with
                # automatic local accounts..
                bs.playSound(bs.getSound('error'))
            else:
                # pick the next player profile and assign our name
                # and character based on that
                bs.playSound(self._deekSound)
                self.profileIndex = ((self.profileIndex + msg.value) %
                                     len(self.profileNames))
                self.updateFromPlayerProfile()

        elif msg.what == 'character':
            bs.playSound(self._clickSound)
            # update our index in our local list of characters
            self.characterIndex = ((self.characterIndex + msg.value) %
                                   len(self.characterNames))
            # bs.screenMessage(self.characterNames[self.characterIndex])
            self._updateText()
            self._updateIcon()

        elif msg.what == 'ready':
            forceTeamSwitch = False
            # team auto-balance kicks us to another team if we try to
            # join the team with the most players
            if not self.ready:
                if bs.getConfig().get('Auto Balance Teams', False):
                    lobby = self.getLobby()
                    if len(lobby._teams) > 1:
                        session = bs.getSession()
                        # first, calc how many players are on each team
                        # ..we need to count both active players and
                        # choosers that have been marked as ready.
                        teamPlayerCounts = {}
                        for team in lobby._teams:
                            teamPlayerCounts[team().getID()] = \
                                len(team().players)
                        for chooser in lobby.choosers:
                            if chooser.ready:
                                teamPlayerCounts[
                                    chooser.getTeam().getID()] += 1
                        largestTeamSize = max(teamPlayerCounts.values())
                        smallestTeamSize = \
                            min(teamPlayerCounts.values())
                        # force switch if we're on the biggest team
                        # and there's a smaller one available
                        if (largestTeamSize != smallestTeamSize
                                and teamPlayerCounts[self.getTeam().getID()] >=
                                largestTeamSize):
                            forceTeamSwitch = True

            if forceTeamSwitch:
                bs.playSound(self._errorSound)
                self.handleMessage(ChangeMessage('team', 1))
                bs.screenMessage(
                    "Unequal Teams!",
                    color=(0.8, 0.5, 0.2),
                    clients=[self._player.getInputDevice().getClientID()],
                    transient=True)
            else:
                if msg.value != 2:
                    bs.playSound(self._punchSound)
                self._setReady(msg.value)
def __init__(self,
             color=(1, 1, 1),
             highlight=(0.5, 0.5, 0.5),
             character="Spaz",
             player=None,
             powerupsExpire=True):
    """
        Create a spaz for the provided bs.Player.
        Note: this does not wire up any controls;
        you must call connectControlsToPlayer() to do so.
        """
    # convert None to an empty player-ref
    if player is None: player = bs.Player(None)

    Spaz.__init__(self,
                  color=color,
                  highlight=highlight,
                  character=character,
                  sourcePlayer=player,
                  startInvincible=True,
                  powerupsExpire=powerupsExpire)
    self.lastPlayerAttackedBy = None  # FIXME - should use empty player ref
    self.lastAttackedTime = 0
    self.lastAttackedType = None
    self.heldCount = 0
    self.lastPlayerHeldBy = None  # FIXME - should use empty player ref here
    self._player = player

    profiles = []
    profiles = self._player.getInputDevice()._getPlayerProfiles()
    ###
    clID = self._player.getInputDevice().getClientID()
    cl_str = []
    for client in bsInternal._getGameRoster():
        if client['clientID'] == clID:
            cl_str = client['displayString']

    for spclient in bsInternal._getForegroundHostSession().players:
        spPlayerID = spclient.get_account_id()

    ##
    if profiles == [] or profiles == {}:
        profiles = bs.getConfig()['Player Profiles']

    for p in profiles:
        try:
            if cl_str in gph.vipHashes:
                PermissionEffect(owner=self.node,
                                 prefix='[PAID MEMBER]',
                                 prefixAnim={
                                     0: (1, 0, 0),
                                     250: (0, 1, 0),
                                     250 * 2: (0, 0, 1),
                                     250 * 3: (1, 0, 0)
                                 })
                break
            if cl_str in gph.sneha:
                PermissionEffect(owner=self.node,
                                 prefix='[QUEEN]',
                                 prefixAnim={
                                     0: (1, 0, 0),
                                     250: (0, 1, 0),
                                     250 * 2: (0, 0, 1),
                                     250 * 3: (1, 0, 0)
                                 })
                break
            if cl_str in gph.ayush:
                PermissionEffect(owner=self.node,
                                 prefix='[KING]',
                                 prefixAnim={
                                     0: (1, 0, 0),
                                     250: (0, 1, 1),
                                     250 * 2: (1, 0, 1),
                                     250 * 3: (1, 0, 0)
                                 })
                break
            if cl_str in gph.adminHashes:
                PermissionEffect(owner=self.node,
                                 prefix='[OWNER]',
                                 prefixAnim={
                                     0: (1, 0, 0),
                                     250: (0, 1, 0),
                                     250 * 2: (0, 0, 1),
                                     250 * 3: (1, 0, 0)
                                 })
                break
            if cl_str in gph.frndHashes:
                PermissionEffect(owner=self.node,
                                 prefix='[TEAM MEMBER]',
                                 prefixAnim={
                                     0: (1, 0, 0),
                                     250: (0, 1, 0),
                                     250 * 2: (0, 0, 1),
                                     250 * 3: (1, 0, 0)
                                 })
                break
            if spPlayerID in gph.autoKickList:
                PermissionEffect(owner=self.node,
                                 prefix='[LOOSER]',
                                 prefixAnim={
                                     0: (1, 0, 0),
                                     250: (0, 1, 0),
                                     250 * 2: (0, 0, 1),
                                     250 * 3: (1, 0, 0)
                                 })
                break
            if cl_str in gph.royalpass:
                PermissionEffect(owner=self.node,
                                 prefix='[ROYAL PASS]',
                                 prefixAnim={
                                     0: (1, 0, 0),
                                     250: (0, 1, 0),
                                     250 * 2: (0, 0, 1),
                                     250 * 3: (1, 0, 0)
                                 })
                break
                '''   
                else:
                    PermissionEffect(owner = self.node,prefix = '[ADMIN]',prefixAnim = {0: (1,0,0), 250: (0,1,0),250*2:(0,0,1),250*3:(1,0,0)})
                    break
                       '''
        except:
            pass

    # grab the node for this player and wire it to follow our spaz (so players' controllers know where to draw their guides, etc)
    if player.exists():
        playerNode = bs.getActivity()._getPlayerNode(player)
        self.node.connectAttr('torsoPosition', playerNode, 'position')
import bsGame
import bsTeamGame
import bsMap
from bsUI import PlayWindow, AddGameWindow, gSmallUI, gMedUI, gTitleColor, uiGlobals
import bsUtils
import copy

_supports_auto_reloading = True
_auto_reloader_type = "patching"
PlayWindow__init__ = PlayWindow.__init__
def _prepare_reload():
	PlayWindow.__init__ = PlayWindow__init__

# TODO: support other gametypes than free-for-all

if "quickGameButton" in bs.getConfig():
	config = bs.getConfig()["quickGameButton"]
else:
	config = {"selected": None, "config": None}
	bs.getConfig()["quickGameButton"] = config
	bs.writeConfig()

def startGame(session, fadeout=True):
	def callback():
		if fadeout:
			bsInternal._unlockAllInput()
		try:
			bsInternal._newHostSession(session)
		except Exception:
			import bsMainMenu
			bs.printException("exception running session", session)
MainMenuWindow__init__ = MainMenuWindow.__init__
def _prepare_reload():
	settingsButton.remove()
	MainMenuWindow.__init__ = MainMenuWindow__init__
	del MainMenuWindow._cb_checkUpdateData
	StoreWindow._setTab = StoreWindow_setTab
	del StoreWindow._onGetMoreGamesPress

def bsGetAPIVersion():
	return 3

quittoapply = None
checkedMainMenu = False


if not 'mod_manager_config' in bs.getConfig():
	bs.getConfig()['mod_manager_config'] = {}
	bs.writeConfig()

config = bs.getConfig()['mod_manager_config']

def index_file(branch=None):
	if branch:
		return "https://rawgit.com/Mrmaxmeier/BombSquad-Community-Mod-Manager/" + branch + "/index.json"
	return "https://rawgit.com/Mrmaxmeier/BombSquad-Community-Mod-Manager/" + config.get("branch", "master") + "/index.json"

web_cache = config.get("web_cache", {})
config["web_cache"] = web_cache


def get_index(callback, branch=None, force=False):
Ejemplo n.º 23
0
import bs
import bsInternal
import urllib2
import bsUtils
import DB_Manager

try:
    req = urllib2.Request('http://icanhazip.com', data=None)
    response = urllib2.urlopen(req, timeout=5)
    ip = str(bs.uni(response.read())).rstrip()
except:
    ip = 'Failed To Fetch IP'
port = str(bs.getConfig().get('Port', 43210))


def restart():
    bsInternal._chatMessage('Rebooting Server... Thanks For Playing!')
    bsInternal._chatMessage('You Can Also Join Again Using IP & Port')
    text = 'IP: %s  Port: %s' % (ip, port)
    bsInternal._chatMessage(text)
    bs.realTimer(3000, bs.Call(bs.quit))


bs.realTimer(3 * 60 * 60 * 1000, restart)


def warn():
    bs.screenMessage('Server is going to reboot in 1 minute', transient=True)


bs.realTimer((3 * 60 * 60 * 1000) - 60000, warn)
Ejemplo n.º 24
0
 def preload(self):
     for profile in bs.getConfig()['Player Profiles'].keys():
         self.commands.append(profile + ':')
     self.commands.append(bsInternal._getAccountDisplayString() + ':')
     self.commands.append(bsInternal._getAccountName() + ':')
Ejemplo n.º 25
0
import os
import os.path
from md5 import md5
import weakref
import imp
import sys

default = {
	"_version": 1,
	"_name": "Auto Reload",
	"enabled": dict(_default=True, _name="Enable"),
	"check_interval": dict(_default=2.5, _min=1, _inc=0.5, _max=10, _name="Check interval"),
	"folder": dict(_default="auto_reloader_mods", _name="Folder")
}

if bs.getConfig().get("auto_reloader", default)["_version"] != default["_version"]:
	bs.getConfig()["auto_reloader"] = default
bs.getConfig()["auto_reloader"] = bs.getConfig().get("auto_reloader", default)

def cfg(key):
	return bs.getConfig()["auto_reloader"][key].get("_value", bs.getConfig()["auto_reloader"][key]["_default"])

CHECK_INTERVAL = int(cfg("check_interval") * 1000)
IMPORT_FOLDER = bs.getEnvironment()['userScriptsDirectory'] + "/" + cfg("folder") + "/"
sys.path.append(IMPORT_FOLDER) # FIXME

class GameWrapper(object):
	_game = None
	_type = None
	_instances = weakref.WeakSet()
	def __init__(self, filename):
Ejemplo n.º 26
0
def popupMenuSelectedChoice(self, popupWindow, choice):

    if choice == "kickOrg":
        if self._popupPartyMemberIsHost:
            bs.playSound(bs.getSound('error'))
            bs.screenMessage(bs.Lstr(resource='internal.cantKickHostError'),
                             color=(1, 0, 0))
        else:
            #print self._popupPartyMemberClientID
            result = bsInternal._disconnectClient(
                self._popupPartyMemberClientID)
            if not result:
                bs.playSound(bs.getSound('error'))
                bs.screenMessage(
                    bs.Lstr(resource='getTicketsWindow.unavailableText'),
                    color=(1, 0, 0))

    elif choice == "kick":
        bsInternal._chatMessage("/" + choice + " " +
                                (str(self._popupPartyMemberClientID)))

    elif choice == "ban":
        for client in bsInternal._getGameRoster():
            if client['clientID'] == self._popupPartyMemberClientID:
                try:
                    bsInternal._chatMessage("/" + choice + " " +
                                            str(client['players'][0]['name']))
                except:
                    pass

    elif choice == "unban":
        for client in bsInternal._getGameRoster():
            if client['clientID'] == self._popupPartyMemberClientID:
                try:
                    bsInternal._chatMessage("/" + choice + " " +
                                            str(client['players'][0]['name']))
                except:
                    pass

    elif choice == "remove":
        for client in bsInternal._getGameRoster():
            if client['clientID'] == self._popupPartyMemberClientID:
                try:
                    bsInternal._chatMessage("/" + choice + " " +
                                            str(client['players'][0]['name']))
                except:
                    pass

    elif choice == "curse":
        for client in bsInternal._getGameRoster():
            if client['clientID'] == self._popupPartyMemberClientID:
                try:
                    bsInternal._chatMessage("/" + choice + " " +
                                            str(client['players'][0]['name']))
                except:
                    pass

    elif choice == "celebrate":
        for client in bsInternal._getGameRoster():
            if client['clientID'] == self._popupPartyMemberClientID:
                try:
                    bsInternal._chatMessage("/" + choice + " " +
                                            str(client['players'][0]['name']))
                except:
                    pass

    elif choice == "freeze":
        for client in bsInternal._getGameRoster():
            if client['clientID'] == self._popupPartyMemberClientID:
                try:
                    bsInternal._chatMessage("/" + choice + " " +
                                            str(client['players'][0]['name']))
                except:
                    pass

    elif choice == "thaw":
        for client in bsInternal._getGameRoster():
            if client['clientID'] == self._popupPartyMemberClientID:
                try:
                    bsInternal._chatMessage("/" + choice + " " +
                                            str(client['players'][0]['name']))
                except:
                    pass

    elif choice == "kill":
        for client in bsInternal._getGameRoster():
            if client['clientID'] == self._popupPartyMemberClientID:
                try:
                    bsInternal._chatMessage("/" + choice + " " +
                                            str(client['players'][0]['name']))
                except:
                    pass

    elif choice == "knock":
        for client in bsInternal._getGameRoster():
            if client['clientID'] == self._popupPartyMemberClientID:
                try:
                    bsInternal._chatMessage("/" + choice + " " +
                                            str(client['players'][0]['name']))
                except:
                    pass

    elif choice == "punch":
        for client in bsInternal._getGameRoster():
            if client['clientID'] == self._popupPartyMemberClientID:
                try:
                    bsInternal._chatMessage("/" + choice + " " +
                                            str(client['players'][0]['name']))
                except:
                    pass

    elif choice == "headless":
        for client in bsInternal._getGameRoster():
            if client['clientID'] == self._popupPartyMemberClientID:
                try:
                    bsInternal._chatMessage("/" + choice + " " +
                                            str(client['players'][0]['name']))
                except:
                    pass

    elif choice == "heal":
        for client in bsInternal._getGameRoster():
            if client['clientID'] == self._popupPartyMemberClientID:
                try:
                    bsInternal._chatMessage("/" + choice + " " +
                                            str(client['players'][0]['name']))
                except:
                    pass

    elif choice == "shield":
        for client in bsInternal._getGameRoster():
            if client['clientID'] == self._popupPartyMemberClientID:
                try:
                    bsInternal._chatMessage("/" + choice + " " +
                                            str(client['players'][0]['name']))
                except:
                    pass

    elif choice == "list":
        bsInternal._chatMessage("/" + choice)

    elif choice == "camera":
        bsInternal._chatMessage("/" + choice)

    elif choice == "slow":
        bsInternal._chatMessage("/" + choice)

    elif choice == "amnesty":
        bsInternal._chatMessage("/" + choice)

    elif choice == "help":
        bsInternal._chatMessage("/" + choice)

    elif choice == "end":
        bsInternal._chatMessage("/" + choice)

    elif choice == "headlessall":
        bsInternal._chatMessage("/" + choice)

    elif choice == "killall":
        bsInternal._chatMessage("/" + choice)

    elif choice == "freezeall":
        bsInternal._chatMessage("/" + choice)

    elif choice == "curseall":
        bsInternal._chatMessage("/" + choice)

    elif choice == "shieldall":
        bsInternal._chatMessage("/" + choice)

    elif choice == "healall":
        bsInternal._chatMessage("/" + choice)

    elif choice == "knockall":
        bsInternal._chatMessage("/" + choice)

    elif choice == "thawall":
        bsInternal._chatMessage("/" + choice)

    elif choice == "punchall":
        bsInternal._chatMessage("/" + choice)

    elif choice == "celebrateall":
        bsInternal._chatMessage("/" + choice)

    elif self._popupType == 'menu':
        if choice in ('mute', 'unmute'):
            bsConfig = bs.getConfig()
            bsConfig['Chat Muted'] = (choice == 'mute')
            bs.writeConfig()
            bs.applySettings()
            self._update()

    else:
        bs.textWidget(edit=self._textField, text='')
Ejemplo n.º 27
0
def popupMenuSelectedChoice(self, popupWindow, choice):
    def getIndex():
        for i in bsInternal._getGameRoster():
            if i['clientID'] == self._popupPartyMemberClientID:
                return bsInternal._getGameRoster().index(i)

    if self._popupType == 'partyMemberPress':
        if choice in [
                'Kick', 'Vote to Kick', 'Изгнать', 'Голосовать за вылет'
        ]:
            if self._popupPartyMemberIsHost:
                bs.playSound(bs.getSound('error'))
                bs.screenMessage(
                    bs.Lstr(resource='internal.cantKickHostError'),
                    color=(1, 0, 0))
            else:
                result = bsInternal._disconnectClient(
                    self._popupPartyMemberClientID)
                if not result:
                    bs.playSound(bs.getSound('error'))
                    bs.screenMessage(
                        bs.Lstr(resource='getTicketsWindow.unavailableText'),
                        color=(1, 0, 0))

        elif choice in ['Departure without a vote', 'Вылет без голосования']:
            bsInternal._chatMessage('/kick ' +
                                    str(self._popupPartyMemberClientID))

        elif choice in ['Ban for teaming', 'Бан за тиминг']:
            bsInternal._chatMessage('/ban' + ' device ' + eval(
                bsInternal._getGameRoster()[getIndex()]['specString'])['n'] +
                                    ' team')

        elif choice in ['Ban for bad words', 'Бан за плохие слова']:
            bsInternal._chatMessage('/ban' + ' device ' + eval(
                bsInternal._getGameRoster()[getIndex()]['specString'])['n'] +
                                    ' badwords')

        elif choice in [
                'Ban for exile without reason', 'Бан за изгнание без причины'
        ]:
            bsInternal._chatMessage('/ban' + ' device ' + eval(
                bsInternal._getGameRoster()[getIndex()]['specString'])['n'] +
                                    ' freeKick')

        elif choice in ['Account profile', 'Профиль аккаунта']:
            for i in bsInternal._getGameRoster():
                if i['clientID'] == self._popupPartyMemberClientID:
                    bs.screenMessage(i['displayString'])

        else:
            if choice in ['Defrost', 'Разморозить']:
                _choice = 'thaw'
            elif choice in ['Turn into box', 'Превратить в коробку']:
                _choice = 'box'
            elif choice in ['Remove from game', 'Убрать из игры']:
                _choice = 'remove'
            elif choice in ['Cure', 'Вылечить']:
                _choice = 'heal'
            elif choice in ['Rainbow skin', 'Радужный скин']:
                _choice = 'rainbow'
            elif choice in ['Put to sleep', 'Усыпить']:
                _choice = 'sleep'
            elif choice in ['To freeze', 'Заморозить']:
                _choice = 'freeze'
            elif choice in ['To revive', 'Возродить']:
                _choice = 'rise'
            elif choice in ['Invisibility', 'Невидимость']:
                _choice = 'inv'
            elif choice in ['Fly', 'Полет']:
                _choice = 'fly'
            elif choice in ['New fly', 'Новый полет']:
                _choice = 'fly3d'
            elif choice in ['Kill', 'Убить']:
                _choice = 'kill'
            elif choice in ['Curse', 'Проклятие']:
                _choice = 'curse'
            elif choice in ['God mode', 'Режим бога']:
                _choice = 'gm'

            bsInternal._chatMessage('/' + _choice + ' device ' + eval(
                bsInternal._getGameRoster()[getIndex()]['specString'])['n'])

    elif self._popupType == 'menu':
        if choice in ('mute', 'unmute'):
            bsConfig = bs.getConfig()
            bsConfig['Chat Muted'] = (choice == 'mute')
            bs.writeConfig()
            bs.applySettings()
            self._update()
        elif choice == 'favoritesChatMenuAddButton':
            configLastServer = bs.getConfig()['BombDash Last Server']
            configFavoritesServers = bs.getConfig(
            )['BombDash Favorites Servers']
            if not configLastServer:
                bs.screenMessage(bs.Lstr(resource='favoritesLastServerNone'),
                                 (1, 0, 0))
            elif configLastServer in configFavoritesServers:
                bs.screenMessage(
                    bs.Lstr(resource='favoritesLastServerInFavorites'),
                    (1, 0, 0))
            else:
                bs.getConfig()['BombDash Favorites Servers'].append(
                    configLastServer)
                bs.writeConfig()
                bs.screenMessage(bs.Lstr(resource='favoritesLastServerAdded'),
                                 (0, 1, 0))

    else:
        print 'unhandled popup type: ' + str(self._popupType)
Ejemplo n.º 28
0
    def __init__(self, vPos, player, lobby):

        import bsInternal

        self._deekSound = bs.getSound('deek')
        self._clickSound = bs.getSound('click01')
        self._punchSound = bs.getSound('punch01')
        self._swishSound = bs.getSound('punchSwish')
        self._errorSound = bs.getSound('error')
        self._maskTexture = bs.getTexture('characterIconMask')
        self._vPos = vPos
        self._lobby = weakref.ref(lobby)
        self._player = player
        self._inited = False
        self._dead = False

        # load available profiles either from the local config or from the
        # remote device..
        self.reloadProfiles()

        # note: this is just our local index out of available teams; *not*
        # the team ID!
        self._selectedTeamIndex = self.getLobby().nextAddTeam

        # store a persistent random character index; we'll use this for the
        # '_random' profile. Let's use their inputDevice id to seed it.. this
        # will give a persistent character for them between games and will
        # distribute characters nicely if everyone is random
        try:
            inputDeviceID = self._player.getInputDevice().getID()
        except Exception as e:
            print 'ERROR: exc getting inputDeviceID for chooser creation:', e
            inputDeviceID = 0
            import traceback
            traceback.print_stack()

        # we want the first device that asks for a chooser to always get
        # spaz as a random character..
        global gRandomCharIndexOffset
        if gRandomCharIndexOffset is None:
            # scratch that.. we now kinda accomplish the same thing with
            # account profiles so lets just be fully random here..
            gRandomCharIndexOffset = random.randrange(1000)

        # to calc our random index we pick a random character out of our
        # unlocked list and then locate that character's index in the full list
        self._randomCharacterIndex = (
            (inputDeviceID + gRandomCharIndexOffset) %
            len(self.characterNames))
        self._randomColor, self._randomHighlight = \
            bsUtils.getPlayerProfileColors(None)
        global gAccountProfileDeviceID
        # attempt to pick an initial profile based on what's been stored
        # for this input device
        try:
            inputDevice = self._player.getInputDevice()
            name = inputDevice.getName()
            uniqueID = inputDevice.getUniqueIdentifier()
            self.profileName = (
                bs.getConfig()['Default Player Profiles'][name + ' ' +
                                                          uniqueID])
            self.profileIndex = self.profileNames.index(self.profileName)

            # if this one is __account__ and is local and we havn't marked
            # anyone as the account-profile device yet, mark this guy as it.
            # (prevents the next joiner from getting the account profile too)
            if (self.profileName == '__account__'
                    and not inputDevice.isRemoteClient()
                    and gAccountProfileDeviceID is None):
                gAccountProfileDeviceID = inputDeviceID

        # well hmm that didn't work.. pick __account__, _random, or some
        # other random profile..
        except Exception:

            profileNames = self.profileNames

            # we want the first local input-device in the game to latch on to
            # the account profile
            if (not inputDevice.isRemoteClient()
                    and not inputDevice.isControllerApp()):
                if (gAccountProfileDeviceID is None
                        and '__account__' in profileNames):
                    gAccountProfileDeviceID = inputDeviceID

            # if this is the designated account-profile-device, try to default
            # to the account profile
            if (inputDeviceID == gAccountProfileDeviceID
                    and '__account__' in profileNames):
                self.profileIndex = profileNames.index('__account__')
            else:
                # if this is the controller app, it defaults to using a random
                # profile (since we can pull the random name from the app)
                if inputDevice.isControllerApp():
                    self.profileIndex = profileNames.index('_random')
                else:
                    # if its a client connection, for now just force the account
                    # profile if possible.. (need to provide a way for clients
                    # to specify/remember their default profile)
                    if (inputDevice.isRemoteClient()
                            and '__account__' in profileNames):
                        self.profileIndex = profileNames.index('__account__')
                    else:
                        global gRandProfileIndex
                        # cycle through our non-random profiles once; after
                        # that, everyone gets random.
                        while (gRandProfileIndex < len(profileNames)
                               and profileNames[gRandProfileIndex]
                               in ('_random', '__account__', '_edit')):
                            gRandProfileIndex += 1
                        if gRandProfileIndex < len(profileNames):
                            self.profileIndex = gRandProfileIndex
                            gRandProfileIndex += 1
                        else:
                            self.profileIndex = profileNames.index('_random')

            self.profileName = profileNames[self.profileIndex]

        self.characterIndex = self._randomCharacterIndex
        self._color = self._randomColor
        self._highlight = self._randomHighlight
        self.ready = False
        self._textNode = bs.newNode('text',
                                    delegate=self,
                                    attrs={
                                        'position': (-100, self._vPos),
                                        'maxWidth': 160,
                                        'shadow': 0.5,
                                        'vrDepth': -20,
                                        'hAlign': 'left',
                                        'vAlign': 'center',
                                        'vAttach': 'top'
                                    })

        bsUtils.animate(self._textNode, 'scale', {0: 0, 100: 1.0})
        self.icon = bs.newNode('image',
                               owner=self._textNode,
                               attrs={
                                   'position': (-130, self._vPos + 20),
                                   'maskTexture': self._maskTexture,
                                   'vrDepth': -10,
                                   'attach': 'topCenter'
                               })

        bsUtils.animateArray(self.icon, 'scale', 2, {0: (0, 0), 100: (45, 45)})

        self._setReady(False)

        # set our initial name to '<choosing player>' in case anyone asks..
        self._player.setName(bs.Lstr(resource='choosingPlayerText').evaluate(),
                             real=False)

        self.updateFromPlayerProfile()
        self.updatePosition()
        self._inited = True
Ejemplo n.º 29
0
def __init__(self,
             color=(1, 1, 1),
             highlight=(0.5, 0.5, 0.5),
             character="Spaz",
             player=None,
             powerupsExpire=True):
    """
        Create a spaz for the provided bs.Player.
        Note: this does not wire up any controls;
        you must call connectControlsToPlayer() to do so.
        """
    # convert None to an empty player-ref
    if player is None: player = bs.Player(None)

    Spaz.__init__(self,
                  color=color,
                  highlight=highlight,
                  character=character,
                  sourcePlayer=player,
                  startInvincible=True,
                  powerupsExpire=powerupsExpire)
    self.lastPlayerAttackedBy = None  # FIXME - should use empty player ref
    self.lastAttackedTime = 0
    self.lastAttackedType = None
    self.heldCount = 0
    self.lastPlayerHeldBy = None  # FIXME - should use empty player ref here
    self._player = player

    profiles = []
    profiles = self._player.getInputDevice()._getPlayerProfiles()
    ###
    clID = self._player.getInputDevice().getClientID()
    cl_str = []
    for client in bsInternal._getGameRoster():
        if client['clientID'] == clID:
            cl_str = client['displayString']

    ##
    if profiles == [] or profiles == {}:
        profiles = bs.getConfig()['Player Profiles']

    for p in profiles:
        try:
            if cl_str in gph.co:
                PermissionEffect(owner=self.node,
                                 prefix='~<CO-LEADER>~',
                                 prefixAnim={
                                     0: (1, 0, 0),
                                     250: (0, 1, 0),
                                     250 * 2: (0, 0, 1),
                                     250 * 3: (1, 0, 0)
                                 })
                break
            if cl_str in gph.elder:
                PermissionEffect(owner=self.node,
                                 prefix='{Elder}',
                                 prefixAnim={
                                     0: (1, 0, 0),
                                     250: (0, 1, 0),
                                     250 * 2: (0, 0, 1),
                                     250 * 3: (1, 0, 0)
                                 })
                break
            if cl_str in gph.member:
                PermissionEffect(owner=self.node,
                                 prefix='-Member-',
                                 prefixAnim={
                                     0: (1, 0, 0),
                                     250: (0, 1, 0),
                                     250 * 2: (0, 0, 1),
                                     250 * 3: (1, 0, 0)
                                 })
                break
            if cl_str in gph.vipHashes:
                PermissionEffect(owner=self.node,
                                 prefix='[VIP+]',
                                 prefixAnim={
                                     0: (1, 0, 0),
                                     250: (0, 1, 0),
                                     250 * 2: (0, 0, 1),
                                     250 * 3: (1, 0, 0)
                                 })
                break
            if cl_str in gph.adminHashes:
                PermissionEffect(owner=self.node,
                                 prefix='~<{LEADER}>~',
                                 prefixAnim={
                                     0: (1, 0, 0),
                                     250: (0, 1, 0),
                                     250 * 2: (0, 0, 1),
                                     250 * 3: (1, 0, 0)
                                 })
                break
        except:
            PermissionEffect(owner=self.node,
                             prefix='Player',
                             prefixAnim={
                                 0: (1, 0, 0),
                                 250: (0, 1, 0),
                                 250 * 2: (0, 0, 1),
                                 250 * 3: (1, 0, 0)
                             })

    # grab the node for this player and wire it to follow our spaz (so players' controllers know where to draw their guides, etc)
    if player.exists():
        playerNode = bs.getActivity()._getPlayerNode(player)
        self.node.connectAttr('torsoPosition', playerNode, 'position')
Ejemplo n.º 30
0
 def _setSetting(self,setting,m):
     bs.getConfig()["effectsMod"][setting] =  False if m==0 else True
     bs.writeConfig()
def __init__(self,
             color=(1, 1, 1),
             highlight=(0.5, 0.5, 0.5),
             character="Spaz",
             player=None,
             powerupsExpire=True):
    """
        Create a spaz for the provided bs.Player.
        Note: this does not wire up any controls;
        you must call connectControlsToPlayer() to do so.
        """
    #https://github.com/imayushsaini/Bombsquad-Mr.Smoothy-Admin-Powerup-Server
    # convert None to an empty player-ref
    if player is None: player = bs.Player(None)

    Spaz.__init__(self,
                  color=color,
                  highlight=highlight,
                  character=character,
                  sourcePlayer=player,
                  startInvincible=True,
                  powerupsExpire=powerupsExpire)
    self.lastPlayerAttackedBy = None  # FIXME - should use empty player ref
    self.lastAttackedTime = 0
    self.lastAttackedType = None
    self.heldCount = 0
    self.lastPlayerHeldBy = None  # FIXME - should use empty player ref here
    self._player = player

    profiles = []
    profiles = self._player.getInputDevice()._getPlayerProfiles()
    ###
    cName = player.getName()

    clID = self._player.getInputDevice().getClientID()

    #bsInternal._chatMessage(str(clID)+'clid')
    #bsInternal._chatMessage(str(self._player.get_account_id()))
    #bsInternal._chatMessage(str(self._player.getID()))
    cl_str = []

    if cName[0] == ' ' or cName == '':
        bsInternal._disconnectClient(int(
            player.getInputDevice().getClientID()))
        bsInternal._chatMessage("No white Space Name Allowed")
        bsInternal._chatMessage("kicking" + cl_str)

    playeraccountid = self._player.get_account_id()

    ##
    if profiles == [] or profiles == {}:
        profiles = bs.getConfig()['Player Profiles']

    for p in profiles:
        try:
            if playeraccountid in MID.admins:
                PermissionEffect(owner=self.node,
                                 prefix=u'\ue048 A.D.M.I.N \ue048',
                                 prefixAnim={
                                     0: (0.5, 0.011, 0.605),
                                     250: (1, 0.411, 0.3411),
                                     250 * 2: (1, 0.591, 0.811),
                                     250 * 3: (0.829, 0.331, 0.403)
                                 })
                break
            if playeraccountid in MID.vips:
                PermissionEffect(owner=self.node,
                                 prefix=u'\ue043 VIP \ue043',
                                 prefixAnim={
                                     0: (0.9, 0.611, 0.705),
                                     250: (1, 0.311, 0.5411),
                                     250 * 2: (0.7, 0.591, 0.811),
                                     250 * 3: (0.729, 0.431, 0.703)
                                 })
                break

            if playeraccountid in MID.members:
                PermissionEffect(owner=self.node,
                                 prefix=u" MEMBER ",
                                 prefixAnim={
                                     0: (0.85, 0.852, 0.85),
                                     250: (0.59, 0.598, 0),
                                     250 * 2: (0.75, 1, 0),
                                     250 * 3: (0.9, 0.17, 0.028)
                                 })
                break

        except:
            pass

    # grab the node for this player and wire it to follow our spaz (so players' controllers know where to draw their guides, etc)
    if player.exists():
        playerNode = bs.getActivity()._getPlayerNode(player)
        self.node.connectAttr('torsoPosition', playerNode, 'position')
import os
import os.path
from md5 import md5
import weakref
import imp
import sys

default = {
	"_version": 1,
	"_name": "Auto Reload",
	"enabled": dict(_default=True, _name="Enable"),
	"check_interval": dict(_default=2.5, _min=1, _inc=0.5, _max=10, _name="Check interval"),
	"folder": dict(_default="auto_reloader_mods", _name="Folder")
}

if bs.getConfig().get("auto_reloader", default)["_version"] != default["_version"]:
	bs.getConfig()["auto_reloader"] = default
bs.getConfig()["auto_reloader"] = bs.getConfig().get("auto_reloader", default)

def cfg(key):
	return bs.getConfig()["auto_reloader"][key].get("_value", bs.getConfig()["auto_reloader"][key]["_default"])

CHECK_INTERVAL = int(cfg("check_interval") * 1000)
IMPORT_FOLDER = bs.getEnvironment()['userScriptsDirectory'] + "/" + cfg("folder") + "/"
sys.path.append(IMPORT_FOLDER) # FIXME

class GameWrapper(object):
	_game = None
	_type = None
	_instances = weakref.WeakSet()
	def __init__(self, filename):
Ejemplo n.º 33
0
    def handleMessage(self, msg):

        if isinstance(msg, ChangeMessage):

            # if we've been removed from the lobby, ignore this stuff
            if self._dead:
                print "WARNING: chooser got ChangeMessage after dying"
                return

            if not self._textNode.exists():
                bs.printError('got ChangeMessage after nodes died')
                return

            if msg.what == 'team':
                if len(self.getLobby()._teams) > 1:
                    bs.playSound(self._swishSound)
                self._selectedTeamIndex = (
                    (self._selectedTeamIndex + msg.value) %
                    len(self.getLobby()._teams))
                self._updateText()
                self.updatePosition()
                self._updateIcon()

            elif msg.what == 'profileIndex':
                if len(self.profileNames) == 1:
                    # this should be pretty hard to hit now with
                    # automatic local accounts..
                    bs.playSound(bs.getSound('error'))
                else:
                    # pick the next player profile and assign our name
                    # and character based on that
                    bs.playSound(self._deekSound)
                    self.profileIndex = ((self.profileIndex + msg.value) %
                                         len(self.profileNames))
                    self.updateFromPlayerProfile()

            elif msg.what == 'character':
                bs.playSound(self._clickSound)
                # update our index in our local list of characters
                self.characterIndex = ((self.characterIndex + msg.value) %
                                       len(self.characterNames))
                self._updateText()
                self._updateIcon()

            elif msg.what == 'ready':
                forceTeamSwitch = False
                # team auto-balance kicks us to another team if we try to
                # join the team with the most players
                if not self.ready:
                    if bs.getConfig().get('Auto Balance Teams', False):
                        lobby = self.getLobby()
                        if len(lobby._teams) > 1:
                            session = bs.getSession()
                            # first, calc how many players are on each team
                            # ..we need to count both active players and
                            # choosers that have been marked as ready.
                            teamPlayerCounts = {}
                            for team in lobby._teams:
                                teamPlayerCounts[team().getID()] = \
                                    len(team().players)
                            for chooser in lobby.choosers:
                                if chooser.ready:
                                    teamPlayerCounts[
                                        chooser.getTeam().getID()] += 1
                            largestTeamSize = max(teamPlayerCounts.values())
                            smallestTeamSize = \
                                min(teamPlayerCounts.values())
                            # force switch if we're on the biggest team
                            # and there's a smaller one available
                            if (largestTeamSize != smallestTeamSize
                                  and teamPlayerCounts[self.getTeam().getID()] \
                                  >= largestTeamSize):
                                forceTeamSwitch = True

                if forceTeamSwitch:
                    bs.playSound(self._errorSound)
                    self.handleMessage(ChangeMessage('team', 1))
                else:
                    bs.playSound(self._punchSound)
                    self._setReady(msg.value)
def cfg(key):
	return bs.getConfig()["auto_reloader"][key].get("_value", bs.getConfig()["auto_reloader"][key]["_default"])