def __init__(self, settings): bs.TeamGameActivity.__init__(self, settings) self._winSound = bs.getSound("score") self._cheerSound = bs.getSound("cheer") self._chantSound = bs.getSound("crowdChant") self._foghornSound = bs.getSound("foghorn") self._swipSound = bs.getSound("swip") self._whistleSound = bs.getSound("refWhistle") self._puckModel = bs.getModel("puck") self._puckTex = bs.getTexture("puckColor") self._puckSound = bs.getSound("metalHit") self._puckMaterial = bs.Material() self._puckMaterial.addActions(actions=(("modifyPartCollision", "friction", 0.1))) self._puckMaterial.addActions( conditions=("theyHaveMaterial", bs.getSharedObject("pickupMaterial")), actions=(("modifyPartCollision", "collide", False)), ) self._puckMaterial.addActions( conditions=(("weAreYoungerThan", 100), "and", ("theyHaveMaterial", bs.getSharedObject("objectMaterial"))), actions=(("modifyNodeCollision", "collide", False)), ) self._puckMaterial.addActions( conditions=("theyHaveMaterial", bs.getSharedObject("footingMaterial")), actions=(("impactSound", self._puckSound, 0.2, 5)), ) # keep track of which player last touched the puck self._puckMaterial.addActions( conditions=("theyHaveMaterial", bs.getSharedObject("playerMaterial")), actions=(("call", "atConnect", self._handlePuckPlayerCollide),), ) # we want the puck to kill powerups; not get stopped by them self._puckMaterial.addActions( conditions=("theyHaveMaterial", bs.Powerup.getFactory().powerupMaterial), actions=( ("modifyPartCollision", "physical", False), ("message", "theirNode", "atConnect", bs.DieMessage()), ), ) # dis is kill self._puckMaterial.addActions( conditions=("theyHaveMaterial", bs.getSharedObject("playerMaterial")), actions=( ("modifyPartCollision", "physical", False), ("message", "ourNode", "atConnect", PuckTouchedMessage()), ), ) self._scoreBoard = bs.ScoreBoard() self._killsToWin = self.settings["Kills to Win"] self._scoreSound = bs.getSound("score") self.pucks = []
def __init__(self): """ Instantiate a PowerupFactory. You shouldn't need to do this; call bs.Powerup.getFactory() to get a shared instance. """ self._lastPowerupType = None self.model = bs.getModel("powerup") self.modelSimple = bs.getModel("powerupSimple") self.texSpeed = bs.getTexture("achievementGotTheMoves") self.texBomb = bs.getTexture("powerupBomb") self.texPunch = bs.getTexture("powerupPunch") self.texIceBombs = bs.getTexture("powerupIceBombs") self.texStickyBombs = bs.getTexture("powerupStickyBombs") self.texAtomBombs = bs.getTexture('eggTex') self.texShield = bs.getTexture("powerupShield") self.texImpactBombs = bs.getTexture("powerupImpactBombs") self.texHealth = bs.getTexture("powerupHealth") self.texLandMines = bs.getTexture("powerupLandMines") self.texCurse = bs.getTexture("powerupCurse") self.texIvincible = bs.getTexture("achievementFlawlessVictory") self.texLuckyBlock = bs.getTexture("achievementEmpty") self.shockWaveTex = bs.getTexture("medalGold") self.texEgg = bs.getTexture('eggTex2') self.texSno = bs.getTexture( "bunnyColor") #Bunny is most uniform plain white color. self.snoModel = bs.getModel("frostyPelvis") self.texSlow = bs.getTexture('coin') self.texNight = bs.getTexture('empty') self.inv = bs.getTexture('rock') self.healthPowerupSound = bs.getSound("healthPowerup") self.powerupSound = bs.getSound("powerup01") self.powerdownSound = bs.getSound("powerdown01") self.dropSound = bs.getSound("boxDrop") # material for powerups self.powerupMaterial = bs.Material() # material for anyone wanting to accept powerups self.powerupAcceptMaterial = bs.Material() # pass a powerup-touched message to applicable stuff self.powerupMaterial.addActions( conditions=(("theyHaveMaterial", self.powerupAcceptMaterial)), actions=(("modifyPartCollision", "collide", True), ("modifyPartCollision", "physical", False), ("message", "ourNode", "atConnect", _TouchedMessage()))) # we dont wanna be picked up self.powerupMaterial.addActions( conditions=("theyHaveMaterial", bs.getSharedObject('pickupMaterial')), actions=(("modifyPartCollision", "collide", False))) self.powerupMaterial.addActions( conditions=("theyHaveMaterial", bs.getSharedObject('footingMaterial')), actions=(("impactSound", self.dropSound, 0.5, 0.1))) self._powerupDist = [] for p, freq in getDefaultPowerupDistribution(): for i in range(int(freq)): self._powerupDist.append(p)
def showCompletionBanner(self, sound=True): global gLastAchievementDisplayTime gLastAchievementDisplayTime = bs.getRealTime() # just piggy-back onto any current activity... # (should we use the session instead?..) activity = bs.getActivity(exceptionOnNone=False) # if this gets called while this achievement is occupying a slot # already, ignore it.. (probably should never happen in real # life but whatevs..) if self._completionBannerSlot is not None: return if activity is None: print 'showCompletionBanner() called with no current activity!' return if sound: bs.playSound(bs.getSound('achievement'), hostOnly=True) else: bs.gameTimer( 500, bs.Call(bs.playSound, bs.getSound('ding'), hostOnly=True)) yOffs = 0 inTime = 300 outTime = 3500 baseVRDepth = 200 # find the first free slot i = 0 while True: if not i in gCompletionBannerSlots: #print 'ADDING SLOT',i,'FOR',self gCompletionBannerSlots.add(i) self._completionBannerSlot = i # remove us from that slot when we close.. # use a real-timer in the UI context so the removal runs even # if our activity/session dies with bs.Context('UI'): bs.realTimer(inTime + outTime, self._removeBannerSlot) break i += 1 yOffs = 110 * self._completionBannerSlot objs = [] obj = bsUtils.Image(bs.getTexture('shadow'), position=(-30, 30 + yOffs), front=True, attach='bottomCenter', transition='inBottom', vrDepth=baseVRDepth - 100, transitionDelay=inTime, transitionOutDelay=outTime, color=(0.0, 0.1, 0, 1), scale=(1000, 300)).autoRetain() objs.append(obj) obj.node.hostOnly = True obj = bsUtils.Image(bs.getTexture('light'), position=(-180, 60 + yOffs), front=True, attach='bottomCenter', vrDepth=baseVRDepth, transition='inBottom', transitionDelay=inTime, transitionOutDelay=outTime, color=(1.8, 1.8, 1.0, 0.0), scale=(40, 300)).autoRetain() objs.append(obj) obj.node.hostOnly = True obj.node.premultiplied = True c = bs.newNode('combine', owner=obj.node, attrs={'size': 2}) bsUtils.animate( c, 'input0', { inTime: 0, inTime + 400: 30, inTime + 500: 40, inTime + 600: 30, inTime + 2000: 0 }) bsUtils.animate( c, 'input1', { inTime: 0, inTime + 400: 200, inTime + 500: 500, inTime + 600: 200, inTime + 2000: 0 }) c.connectAttr('output', obj.node, 'scale') bsUtils.animate(obj.node, 'rotate', {0: 0.0, 350: 360.0}, loop=True) obj = bsUtils.Image(self.getIconTexture(True), position=(-180, 60 + yOffs), attach='bottomCenter', front=True, vrDepth=baseVRDepth - 10, transition='inBottom', transitionDelay=inTime, transitionOutDelay=outTime, scale=(100, 100)).autoRetain() objs.append(obj) obj.node.hostOnly = True # flash color = self.getIconColor(True) c = bs.newNode('combine', owner=obj.node, attrs={'size': 3}) keys = { inTime: 1.0 * color[0], inTime + 400: 1.5 * color[0], inTime + 500: 6.0 * color[0], inTime + 600: 1.5 * color[0], inTime + 2000: 1.0 * color[0] } bsUtils.animate(c, 'input0', keys) keys = { inTime: 1.0 * color[1], inTime + 400: 1.5 * color[1], inTime + 500: 6.0 * color[1], inTime + 600: 1.5 * color[1], inTime + 2000: 1.0 * color[1] } bsUtils.animate(c, 'input1', keys) keys = { inTime: 1.0 * color[2], inTime + 400: 1.5 * color[2], inTime + 500: 6.0 * color[2], inTime + 600: 1.5 * color[2], inTime + 2000: 1.0 * color[2] } bsUtils.animate(c, 'input2', keys) c.connectAttr('output', obj.node, 'color') obj = bsUtils.Image(bs.getTexture('achievementOutline'), modelTransparent=bs.getModel('achievementOutline'), position=(-180, 60 + yOffs), front=True, attach='bottomCenter', vrDepth=baseVRDepth, transition='inBottom', transitionDelay=inTime, transitionOutDelay=outTime, scale=(100, 100)).autoRetain() obj.node.hostOnly = True # flash color = (2, 1.4, 0.4, 1) c = bs.newNode('combine', owner=obj.node, attrs={'size': 3}) keys = { inTime: 1.0 * color[0], inTime + 400: 1.5 * color[0], inTime + 500: 6.0 * color[0], inTime + 600: 1.5 * color[0], inTime + 2000: 1.0 * color[0] } bsUtils.animate(c, 'input0', keys) keys = { inTime: 1.0 * color[1], inTime + 400: 1.5 * color[1], inTime + 500: 6.0 * color[1], inTime + 600: 1.5 * color[1], inTime + 2000: 1.0 * color[1] } bsUtils.animate(c, 'input1', keys) keys = { inTime: 1.0 * color[2], inTime + 400: 1.5 * color[2], inTime + 500: 6.0 * color[2], inTime + 600: 1.5 * color[2], inTime + 2000: 1.0 * color[2] } bsUtils.animate(c, 'input2', keys) c.connectAttr('output', obj.node, 'color') objs.append(obj) obj = bsUtils.Text(bs.Lstr(value='${A}:', subs=[('${A}', bs.Lstr(resource='achievementText')) ]), position=(-120, 91 + yOffs), front=True, vAttach='bottom', vrDepth=baseVRDepth - 10, transition='inBottom', flatness=0.5, transitionDelay=inTime, transitionOutDelay=outTime, color=(1, 1, 1, 0.8), scale=0.65).autoRetain() objs.append(obj) obj.node.hostOnly = True obj = bsUtils.Text(self.getDisplayString(), position=(-120, 50 + yOffs), front=True, vAttach='bottom', transition='inBottom', vrDepth=baseVRDepth, flatness=0.5, transitionDelay=inTime, transitionOutDelay=outTime, flash=True, color=(1, 0.8, 0, 1.0), scale=1.5).autoRetain() objs.append(obj) obj.node.hostOnly = True obj = bsUtils.Text(bs.getSpecialChar('ticket'), position=(-120 - 170 + 5, 75 + yOffs - 20), front=True, vAttach='bottom', hAlign='center', vAlign='center', transition='inBottom', vrDepth=baseVRDepth, transitionDelay=inTime, transitionOutDelay=outTime, flash=True, color=(0.5, 0.5, 0.5, 1), scale=3.0).autoRetain() objs.append(obj) obj.node.hostOnly = True obj = bsUtils.Text('+' + str(self.getAwardTicketValue()), position=(-120 - 180 + 5, 80 + yOffs - 20), vAttach='bottom', front=True, hAlign='center', vAlign='center', transition='inBottom', vrDepth=baseVRDepth, flatness=0.5, shadow=1.0, transitionDelay=inTime, transitionOutDelay=outTime, flash=True, color=(0, 1, 0, 1), scale=1.5).autoRetain() objs.append(obj) obj.node.hostOnly = True # add the 'x 2' if we've got pro if bsUtils._havePro(): obj = bsUtils.Text('x 2', position=(-120 - 180 + 45, 80 + yOffs - 50), vAttach='bottom', front=True, hAlign='center', vAlign='center', transition='inBottom', vrDepth=baseVRDepth, flatness=0.5, shadow=1.0, transitionDelay=inTime, transitionOutDelay=outTime, flash=True, color=(0.4, 0, 1, 1), scale=0.9).autoRetain() objs.append(obj) obj.node.hostOnly = True obj = bsUtils.Text(self.getDescriptionComplete(), position=(-120, 30 + yOffs), front=True, vAttach='bottom', transition='inBottom', vrDepth=baseVRDepth - 10, flatness=0.5, transitionDelay=inTime, transitionOutDelay=outTime, color=(1.0, 0.7, 0.5, 1.0), scale=0.8).autoRetain() objs.append(obj) obj.node.hostOnly = True for obj in objs: bs.gameTimer(outTime + 1000, bs.WeakCall(obj.handleMessage, bs.DieMessage()))
def createDisplay(self, x, y, delay, outDelay=None, color=None, style='postGame'): if style == 'postGame': inGameColors = False inMainMenu = False hAttach = vAttach = attach = 'center' elif style == 'inGame': inGameColors = True inMainMenu = False hAttach = 'left' vAttach = 'top' attach = 'topLeft' elif style == 'news': inGameColors = True inMainMenu = True hAttach = 'center' vAttach = 'top' attach = 'topCenter' else: raise Exception('invalid style "' + style + '"') # attempt to determine what campaign we're in # (so we know whether to show "hard mode only") if inMainMenu: hmo = False else: try: hmo = (self._hardModeOnly and bs.getSession()._campaignInfo['campaign'] == 'Easy') except Exception: bs.printException("unable to determine campaign") hmo = False activity = bs.getActivity() if inGameColors: objs = [] outDelayFin = (delay + outDelay) if outDelay is not None else None if color is not None: c1 = (2.0 * color[0], 2.0 * color[1], 2.0 * color[2], color[3]) c2 = color else: c1 = (1.5, 1.5, 2, 1.0) c2 = (0.8, 0.8, 1.0, 1.0) if hmo: c1 = (c1[0], c1[1], c1[2], c1[3] * 0.6) c2 = (c2[0], c2[1], c2[2], c2[3] * 0.2) objs.append( bsUtils.Image(self.getIconTexture(False), hostOnly=True, color=c1, position=(x - 25, y + 5), attach=attach, transition='fadeIn', transitionDelay=delay, vrDepth=4, transitionOutDelay=outDelayFin, scale=(40, 40)).autoRetain()) txt = self.getDisplayString() txtS = 0.85 txtMaxW = 300 objs.append( bsUtils.Text(txt, hostOnly=True, maxWidth=txtMaxW, position=(x, y + 2), transition='fadeIn', scale=txtS, flatness=0.6, shadow=0.5, hAttach=hAttach, vAttach=vAttach, color=c2, transitionDelay=delay + 50, transitionOutDelay=outDelayFin).autoRetain()) txt2S = 0.62 txt2MaxW = 400 objs.append( bsUtils.Text(self.getDescriptionFull() if inMainMenu else self.getDescription(), hostOnly=True, maxWidth=txt2MaxW, position=(x, y - 14), transition='fadeIn', vrDepth=-5, hAttach=hAttach, vAttach=vAttach, scale=txt2S, flatness=1.0, shadow=0.5, color=c2, transitionDelay=delay + 100, transitionOutDelay=outDelayFin).autoRetain()) if hmo: t = bsUtils.Text(bs.Lstr(resource='difficultyHardOnlyText'), hostOnly=True, maxWidth=txt2MaxW * 0.7, position=(x + 60, y + 5), transition='fadeIn', vrDepth=-5, hAttach=hAttach, vAttach=vAttach, hAlign='center', vAlign='center', scale=txtS * 0.8, flatness=1.0, shadow=0.5, color=(1, 1, 0.6, 1), transitionDelay=delay + 100, transitionOutDelay=outDelayFin).autoRetain() t.node.rotate = 10 objs.append(t) # ticket-award awardX = -100 objs.append( bsUtils.Text(bs.getSpecialChar('ticket'), hostOnly=True, position=(x + awardX + 33, y + 7), transition='fadeIn', scale=1.5, hAttach=hAttach, vAttach=vAttach, hAlign='center', vAlign='center', color=(1, 1, 1, 0.2 if hmo else 0.4), transitionDelay=delay + 50, transitionOutDelay=outDelayFin).autoRetain()) objs.append( bsUtils.Text('+' + str(self.getAwardTicketValue()), hostOnly=True, position=(x + awardX + 28, y + 16), transition='fadeIn', scale=0.7, flatness=1, hAttach=hAttach, vAttach=vAttach, hAlign='center', vAlign='center', color=(c2), transitionDelay=delay + 50, transitionOutDelay=outDelayFin).autoRetain()) else: complete = self.isComplete() objs = [] cIcon = self.getIconColor(complete) if hmo and not complete: cIcon = (cIcon[0], cIcon[1], cIcon[2], cIcon[3] * 0.3) objs.append( bsUtils.Image(self.getIconTexture(complete), hostOnly=True, color=cIcon, position=(x - 25, y + 5), attach=attach, vrDepth=4, transition='inRight', transitionDelay=delay, transitionOutDelay=None, scale=(40, 40)).autoRetain()) if complete: objs.append( bsUtils.Image( bs.getTexture('achievementOutline'), hostOnly=True, modelTransparent=bs.getModel('achievementOutline'), color=(2, 1.4, 0.4, 1), vrDepth=8, position=(x - 25, y + 5), attach=attach, transition='inRight', transitionDelay=delay, transitionOutDelay=None, scale=(40, 40)).autoRetain()) else: if not complete: awardX = -100 objs.append( bsUtils.Text(bs.getSpecialChar('ticket'), hostOnly=True, position=(x + awardX + 33, y + 7), transition='inRight', scale=1.5, hAttach=hAttach, vAttach=vAttach, hAlign='center', vAlign='center', color=(1, 1, 1, 0.4) if complete else (1, 1, 1, (0.1 if hmo else 0.2)), transitionDelay=delay + 50, transitionOutDelay=None).autoRetain()) objs.append( bsUtils.Text('+' + str(self.getAwardTicketValue()), hostOnly=True, position=(x + awardX + 28, y + 16), transition='inRight', scale=0.7, flatness=1, hAttach=hAttach, vAttach=vAttach, hAlign='center', vAlign='center', color=((0.8, 0.93, 0.8, 1.0) if complete else (0.6, 0.6, 0.6, (0.2 if hmo else 0.4))), transitionDelay=delay + 50, transitionOutDelay=None).autoRetain()) # show 'hard-mode-only' only over incomplete achievements # when that's the case.. if hmo: t = bsUtils.Text( bs.Lstr(resource='difficultyHardOnlyText'), hostOnly=True, maxWidth=300 * 0.7, position=(x + 60, y + 5), transition='fadeIn', vrDepth=-5, hAttach=hAttach, vAttach=vAttach, hAlign='center', vAlign='center', scale=0.85 * 0.8, flatness=1.0, shadow=0.5, color=(1, 1, 0.6, 1), transitionDelay=delay + 50, transitionOutDelay=None).autoRetain() t.node.rotate = 10 objs.append(t) objs.append( bsUtils.Text( self.getDisplayString(), hostOnly=True, maxWidth=300, position=(x, y + 2), transition='inRight', scale=0.85, flatness=0.6, hAttach=hAttach, vAttach=vAttach, color=(achievementsCompleteNamesColor if complete else (achievementsNotCompleteNamesColor[0], achievementsNotCompleteNamesColor[1], achievementsNotCompleteNamesColor[2], (0.2 if hmo else 0.4))), transitionDelay=delay + 50, transitionOutDelay=None).autoRetain()) objs.append( bsUtils.Text( self.getDescriptionComplete() if complete else self.getDescription(), hostOnly=True, maxWidth=400, position=(x, y - 14), transition='inRight', vrDepth=-5, hAttach=hAttach, vAttach=vAttach, scale=0.62, flatness=1.0, color=(achievementsCompleteDescriptionColor if complete else (achievementsNotCompleteDescriptionColor[0], achievementsNotCompleteDescriptionColor[1], achievementsNotCompleteDescriptionColor[2], (0.2 if hmo else 0.4))), transitionDelay=delay + 100, transitionOutDelay=None).autoRetain()) return objs
def onTransitionIn(self): bs.Activity.onTransitionIn(self) global gDidInitialTransition random.seed(123) try: import install except ImportError: pass else: # check needed methods if hasattr(bs, "get_setting") and hasattr(install, "update_modpack"): if bs.get_setting("auto-update", False): install.update_modpack(True) self._logoNode = None self._customLogoTexName = None self._wordActors = [] env = bs.getEnvironment() vrMode = bs.getEnvironment()['vrMode'] if not bs.getEnvironment().get('toolbarTest', True): self.myName = bs.NodeActor(bs.newNode('text', attrs={ 'vAttach':'bottom', 'hAlign':'center', 'color':(1, 1, 1, 1) if vrMode else (1, 1, 1, 1), 'flatness':1.0, 'shadow':1.0 if vrMode else 0.5, 'scale':(0.65 if (env['interfaceType'] == 'small' or vrMode) else 0.7), # FIXME need a node attr for this 'position': (0, 25), 'vrDepth':-10, 'text':u'\xa9 2019 Eric Froemling'})) fullScreen = bsInternal._getSetting("TV Border") if env['interfaceType'] != 'small' or env['vrMode']: if fullScreen: position = (0, -10) else: position = (-425, 10) else: if fullScreen: position = (0, -10) else: position = (-425, 35) self.moderName = bs.NodeActor(bs.newNode('text', attrs={ 'vAttach':'bottom', 'hAlign':'center', 'color':(0.8, 0.8, 0.8, 0.8) if vrMode else (0.8, 0.8, 0.8, 0.8), 'flatness':1.0, 'shadow':1.0 if vrMode else 0.5, 'scale':(0.55 if (env['interfaceType'] == 'small' or vrMode) else 0.7), # FIXME need a node attr for this 'position': position, 'vrDepth':-10, 'text':u'\xa9 ModPack is created by Delitel'})) self._hostIsNavigatingText = bs.NodeActor(bs.newNode('text', attrs={ 'text':bs.Lstr(resource='hostIsNavigatingMenusText', subs=[('${HOST}', bsInternal._getAccountDisplayString())]), 'clientOnly':True, 'position':(0,-200), 'flatness':1.0, 'hAlign':'center'})) if not gDidInitialTransition: if hasattr(self, 'myName'): bs.animate(self.myName.node, 'opacity', {2300:0,3000:1.0}) if hasattr(self, 'moderName'): bs.animate(self.moderName.node, 'opacity', {2300:0,3300:1.0}) # FIXME - shouldn't be doing things conditionally based on whether # the host is vr mode or not (clients may not be or vice versa) # - any differences need to happen at the engine level # so everyone sees things in their own optimal way vrMode = env['vrMode'] interfaceType = env['interfaceType'] # in cases where we're doing lots of dev work lets # always show the build number forceShowBuildNumber = True if not bs.getEnvironment().get('toolbarTest', True): text = "Delitel ModPack" try: from multiversion import get_version except ImportError: path = os.path.join(env["userScriptsDirectory"], "about_modpack.json") if os.path.exists(path): try: data = json.load(open(path)) except Exception: pass else: text += " v."+str(data.get("version", {"v": "???"}).get("v")) else: text += " v." + str(get_version()) if env['debugBuild'] or env['testBuild']: if env['debugBuild']: text += " [debug]" else: text += " [test]" if forceShowBuildNumber: text = "based on "+str(env['version'])+"\n" + text self.version = bs.NodeActor(bs.newNode('text', attrs={ 'vAttach':'bottom', 'hAttach':'right', 'hAlign':'right', 'flatness':1.0, 'vrDepth':-10, 'shadow': 0.5, 'color': (0.5,0.6,0.5,0.7), 'scale':0.7 if (interfaceType == 'small' or vrMode) else 0.85, 'position':(-260,10) if vrMode else (-10,30), 'text': text})) if not gDidInitialTransition: bs.animate(self.version.node,'opacity',{0:0, 3000:0, 4000:1.0}) # throw in beta info.. self.betaInfo = self.betaInfo2 = None if env['testBuild'] and not env['kioskMode']: self.betaInfo = bs.NodeActor(bs.newNode('text', attrs={ 'vAttach':'center', 'hAlign':'center', 'color':(1,1,1,1), 'shadow':0.5, 'flatness':0.5, 'scale':1, 'vrDepth':-60, 'position':(230,125) if env['kioskMode'] else (230,35), 'text': bs.Lstr(resource="testBuildText")})) if not gDidInitialTransition: bs.animate(self.betaInfo.node,'opacity',{1300:0,1800:1.0}) model = bs.getModel('thePadLevel') treesModel = bs.getModel('trees') bottomModel = bs.getModel('thePadLevelBottom') borModel = bs.getCollideModel('thePadLevelCollide') testColorTexture = bs.getTexture('thePadLevelColor') treesTexture = bs.getTexture('treesColor') bgTex = bs.getTexture('alwaysLandBGColor') bgModel = bs.getModel('alwaysLandBG') vrBottomFillModel = bs.getModel('thePadVRFillBottom') vrTopFillModel = bs.getModel('thePadVRFillTop') bsGlobals = bs.getSharedObject('globals') bsGlobals.cameraMode = 'rotate' bsGlobals.tint = (1.1,1.1,1.0) self.bottom = bs.NodeActor(bs.newNode('terrain', attrs={ 'model':bottomModel, 'lighting':False, 'reflection':'soft', 'reflectionScale':[0.45], 'colorTexture':testColorTexture})) self.node = bs.newNode('terrain', delegate=self, attrs={ 'collideModel':borModel, 'model':model, 'colorTexture':testColorTexture, 'materials':[bs.getSharedObject('footingMaterial')]}) self.vrBottomFill = bs.NodeActor(bs.newNode('terrain', attrs={ 'model':vrBottomFillModel, 'lighting':False, 'vrOnly':True, 'colorTexture':testColorTexture})) self.vrTopFill = bs.NodeActor(bs.newNode('terrain', attrs={ 'model':vrTopFillModel, 'vrOnly':True, 'lighting':False, 'colorTexture':bgTex})) self.terrain = bs.NodeActor(bs.newNode('terrain', attrs={ 'model':model, 'colorTexture':testColorTexture, 'reflection':'soft', 'reflectionScale':[0.3]})) self.trees = bs.NodeActor(bs.newNode('terrain', attrs={ 'model':treesModel, 'lighting':False, 'reflection':'char', 'reflectionScale':[0.1], 'colorTexture':treesTexture})) self.bg = bs.NodeActor(bs.newNode('terrain', attrs={ 'model':bgModel, 'color':(0.92,0.91,0.9), 'lighting':False, 'background':True, 'colorTexture':bgTex})) textOffsetV = 0 self._ts = 0.86 self._language = None self._updateTimer = bs.Timer(2000, bs.Call(self._update, False), repeat=True) self._update(True) bs.gameTimer(55000, bs.Call(self.fireworks)) bsUtils.animateArray(bs.getSharedObject("globals"), "tint", 3, {0:(1.1,1.1,1.0), 7500:(1.25, 1.21, 1.075), 30000:(1.25, 1.21, 1.075), \ 57500:(1.1, 0.86, 0.74), 67500:(1.1, 0.86, 0.74), \ 90000:(0, 0.27, 0.51), 120000:(0, 0.27, 0.51), 142500:(1.3, 1.06, 1.02), \ 157500:(1.3, 1.06, 1.02), 180000:(1.3, 1.25, 1.2), 195500:(1.3, 1.25, 1.2), \ 220000:(1.1,1.1,1.0)}) bsInternal._addCleanFrameCallback(bs.WeakCall(self._startPreloads)) random.seed() class News(object): def __init__(self,activity): self._valid = True self._messageDuration = 10000 self._messageSpacing = 2000 self._text = None self._activity = weakref.ref(activity) self._fetchTimer = bs.Timer(1000,bs.WeakCall(self._tryFetchingNews),repeat=True) self._tryFetchingNews() def _tryFetchingNews(self): if bsInternal._getAccountState() == 'SIGNED_IN': self._fetchNews() self._fetchTimer = None 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) def _changePhrase(self): global gLastNewsFetchTime if time.time()-gLastNewsFetchTime > 100.0: self._fetchNews() self._text = None else: if self._text is not None: if len(self._phrases) == 0: for p in self._usedPhrases: self._phrases.insert(0,p) val = self._phrases.pop() if val == '__ACH__': vr = bs.getEnvironment()['vrMode'] bsUtils.Text( bs.Lstr(resource='nextAchievementsText'), color=(1,1,1,1) if vr else (0.95,0.9,1,0.4), hostOnly=True, maxWidth=200, position=(-300, -35), hAlign='right', transition='fadeIn', scale=0.9 if vr else 0.7, flatness=1.0 if vr else 0.6, shadow=1.0 if vr else 0.5, hAttach="center", vAttach="top", transitionDelay=1000, transitionOutDelay=self._messageDuration)\ .autoRetain() import bsAchievement achs = [a for a in bsAchievement.gAchievements if not a.isComplete()] if len(achs) > 0: a = achs.pop(random.randrange(min(4,len(achs)))) a.createDisplay(-180, -35, 1000, outDelay=self._messageDuration, style='news') if len(achs) > 0: a = achs.pop(random.randrange(min(8,len(achs)))) a.createDisplay(180, -35, 1250, outDelay=self._messageDuration, style='news') else: s = self._messageSpacing keys = {s:0, s+1000:1.0, s+self._messageDuration-1000:1.0, s+self._messageDuration:0.0} bs.animate(self._text.node, "opacity", dict([[k,v] for k,v in keys.items()])) self._text.node.text = val def _gotNews(self, news): # run this stuff in the context of our activity since we need # to make nodes and stuff.. should fix the serverGet call so it activity = self._activity() if activity is None or activity.isFinalized(): return with bs.Context(activity): self._phrases = [] # show upcoming achievements in non-vr versions # (currently too hard to read in vr) self._usedPhrases = ( ['__ACH__'] if not bs.getEnvironment()['vrMode'] else []) + [s for s in news.split('<br>\n') if s != ''] self._phraseChangeTimer = bs.Timer( self._messageDuration+self._messageSpacing, bs.WeakCall(self._changePhrase), repeat=True) sc = 1.2 if (bs.getEnvironment()['interfaceType'] == 'small' or bs.getEnvironment()['vrMode']) else 0.8 self._text = bs.NodeActor(bs.newNode('text', attrs={ 'vAttach':'top', 'hAttach':'center', 'hAlign':'center', 'vrDepth':-20, 'shadow':1.0 if bs.getEnvironment()['vrMode'] else 0.4, 'flatness':0.8, 'vAlign':'top', 'color':((1, 1, 1, 1) if bs.getEnvironment()['vrMode'] else (0.7, 0.65, 0.75, 1.0)), 'scale':sc, 'maxWidth':900.0/sc, 'position':(0,-10)})) self._changePhrase() if not env['kioskMode'] and not env.get('toolbarTest', True): self._news = News(self) # bring up the last place we were, or start at the main menu otherwise with bs.Context('UI'): try: mainWindow = bsUI.gMainWindow except Exception: mainWindow = None # when coming back from a kiosk-mode game, jump to # the kiosk start screen.. if bsUtils.gRunningKioskModeGame: if bs.getEnvironment()['kioskMode']: bsUI.uiGlobals['mainMenuWindow'] = \ bsUI.KioskWindow().getRootWidget() # ..or in normal cases go back to the main menu else: if mainWindow == 'Gather': bsUI.uiGlobals['mainMenuWindow'] = \ bsUI.GatherWindow(transition=None).getRootWidget() elif mainWindow == 'Watch': bsUI.uiGlobals['mainMenuWindow'] = \ bsUI.WatchWindow(transition=None).getRootWidget() elif mainWindow == 'Team Game Select': bsUI.uiGlobals['mainMenuWindow'] = \ bsUI.TeamsWindow(sessionType=bs.TeamsSession, transition=None).getRootWidget() elif mainWindow == 'Free-for-All Game Select': bsUI.uiGlobals['mainMenuWindow'] = \ bsUI.TeamsWindow(sessionType=bs.FreeForAllSession, transition=None).getRootWidget() elif mainWindow == 'Coop Select': bsUI.uiGlobals['mainMenuWindow'] = \ bsUI.CoopWindow(transition=None).getRootWidget() else: bsUI.uiGlobals['mainMenuWindow'] = \ bsUI.MainMenuWindow(transition=None).getRootWidget() # attempt to show any pending offers immediately. # If that doesn't work, try again in a few seconds # (we may not have heard back from the server) # ..if that doesn't work they'll just have to wait # until the next opportunity. if not bsUI._showOffer(): def tryAgain(): if not bsUI._showOffer(): # try one last time.. bs.realTimer(2000, bsUI._showOffer) bs.realTimer(2000, tryAgain) gDidInitialTransition = True
def __init__(self,settings): bs.TeamGameActivity.__init__(self,settings) self._scoreBoard = bs.ScoreBoard() self._cheerSound = bs.getSound("cheer") self._chantSound = bs.getSound("crowdChant") self._scoreSound = bs.getSound("score") self._swipSound = bs.getSound("swip") self._whistleSound = bs.getSound("refWhistle") self._ballModel = bs.getModel("shield") self._ballTex = bs.getTexture("eggTex1") self._ballSound = bs.getSound("impactMedium2") self._flagKaleTex = bs.getTexture("star") self._kaleSound = bs.getSound("metalHit") self._nightModel = bs.getModel("shield") self._nightTex = bs.getTexture("black") self._kaleMaterial = bs.Material() #add friction to flags for standing our position (as far as) self._kaleMaterial.addActions(conditions=("theyHaveMaterial",bs.getSharedObject('footingMaterial')), actions=( ("modifyPartCollision","friction",9999.5))) self._kaleMaterial.addActions(conditions=("theyHaveMaterial",bs.getSharedObject('pickupMaterial')), actions=( ("modifyPartCollision","collide",False) ) ) self._kaleMaterial.addActions(conditions=( ("weAreYoungerThan",100),'and', ("theyHaveMaterial",bs.getSharedObject('objectMaterial')) ), actions=( ("modifyNodeCollision","collide",False) ) ) #dont collide with bombs #FIXME "standing" self._kaleMaterial.addActions(conditions=("theyHaveMaterial",bs.Bomb.getFactory().blastMaterial), actions=(("modifyPartCollision","collide",False), ("modifyPartCollision","physical",False))) self._kaleMaterial.addActions(conditions=("theyHaveMaterial",bs.Bomb.getFactory().bombMaterial), actions=(("modifyPartCollision","collide",False), ("modifyPartCollision","physical",False))) self._kaleMaterial.addActions( conditions=('theyHaveMaterial',bs.getSharedObject('objectMaterial')), actions=(('impactSound',self._kaleSound,2,5))) #we dont wanna hit the night so self._nightMaterial = bs.Material() self._nightMaterial.addActions( conditions=(('theyHaveMaterial',bs.getSharedObject('pickupMaterial')),'or', ('theyHaveMaterial',bs.getSharedObject('attackMaterial'))), actions=(('modifyPartCollision','collide',False))) # we also dont want anything moving it self._nightMaterial.addActions( conditions=(('theyHaveMaterial',bs.getSharedObject('objectMaterial')),'or', ('theyDontHaveMaterial',bs.getSharedObject('footingMaterial'))), actions=(('modifyPartCollision','collide',False), ('modifyPartCollision','physical',False))) self._ballMaterial = bs.Material() self._ballMaterial.addActions(actions=( ("modifyPartCollision","friction",0.75))) self._ballMaterial.addActions(conditions=("theyHaveMaterial",bs.getSharedObject('pickupMaterial')), actions=( ("modifyPartCollision","collide",False) ) ) self._ballMaterial.addActions(conditions=( ("weAreYoungerThan",100),'and', ("theyHaveMaterial",bs.getSharedObject('objectMaterial')) ), actions=( ("modifyNodeCollision","collide",False) ) ) self._ballMaterial.addActions(conditions=("theyHaveMaterial",bs.getSharedObject('footingMaterial')), actions=(("impactSound",self._ballSound,2,0.8))) # keep track of which player last touched the ball self._ballMaterial.addActions(conditions=("theyHaveMaterial",bs.getSharedObject('playerMaterial')), actions=(("call","atConnect",self._handleBallPlayerCollide),)) # we want the ball to kill powerups; not get stopped by them self._ballMaterial.addActions(conditions=("theyHaveMaterial",bs.Powerup.getFactory().powerupMaterial), actions=(("modifyPartCollision","physical",False), ("message","theirNode","atConnect",bs.DieMessage()))) self._scoreRegionMaterial = bs.Material() self._scoreRegionMaterial.addActions(conditions=("theyHaveMaterial",self._ballMaterial), actions=(("modifyPartCollision","collide",True), ("modifyPartCollision","physical",False), ("call","atConnect",self._handleScore)))
def box(a): bs.getSession().players[int(a)].actor.node.torsoModel = bs.getModel("tnt")
def __init__(self): self.botModel = bs.getModel("impactBomb") self.botTexture = bs.getTexture("bg") self.targetSound = bs.getSound("activateBeep") self.popSound = bs.getSound("pop01")
def __init__(self): """ Instantiate a PowerupFactory. You shouldn't need to do this; call bs.Powerup.getFactory() to get a shared instance. """ self._lastPowerupType = None self.model = bs.getModel("powerup") self.modelSimple = bs.getModel("powerupSimple") self.texBomb = bs.getTexture("powerupBomb") self.texPunch = bs.getTexture("powerupPunch") self.texIceBombs = bs.getTexture("powerupIceBombs") self.texStickyBombs = bs.getTexture("powerupStickyBombs") self.texShield = bs.getTexture("powerupShield") self.texImpactBombs = bs.getTexture("powerupImpactBombs") self.texHealth = bs.getTexture("powerupHealth") self.texLandMines = bs.getTexture("powerupLandMines") self.texRangerBombs = bs.getTexture("powerupRangerBombs") self.texCombatBombs = bs.getTexture("powerupCombatBombs") self.texFireBombs = bs.getTexture("powerupFireBombs") self.texDynamitePack = bs.getTexture("powerupDynamitePack") self.texGrenades = bs.getTexture("powerupGrenade") self.texHealBombs = bs.getTexture("powerupHealBombs") self.texKnockerBombs = bs.getTexture("powerupKnockerBombs") self.texCurse = bs.getTexture("powerupCurse") self.texOverdrive = bs.getTexture("powerupOverdrive") self.texHijump = bs.getTexture("powerupHijump") self.texSpeed = bs.getTexture("powerupSpeed") self.texBlast = bs.getTexture("powerupBlast") self.healthPowerupSound = bs.getSound("healthPowerup") self.overdrivePowerupSound = bs.getSound("overdrivePowerup") self.powerupSound = bs.getSound("powerup01") self.powerdownSound = bs.getSound("powerdown01") self.dropSound = bs.getSound("boxDrop") # material for powerups self.powerupMaterial = bs.Material() # material for anyone wanting to accept powerups self.powerupAcceptMaterial = bs.Material() # pass a powerup-touched message to applicable stuff self.powerupMaterial.addActions( conditions=(("theyHaveMaterial", self.powerupAcceptMaterial)), actions=(("modifyPartCollision", "collide", True), ("modifyPartCollision", "physical", False), ("message", "ourNode", "atConnect", _TouchedMessage()))) # we dont wanna be picked up self.powerupMaterial.addActions( conditions=("theyHaveMaterial", bs.getSharedObject('pickupMaterial')), actions=(("modifyPartCollision", "collide", False))) self.powerupMaterial.addActions( conditions=("theyHaveMaterial", bs.getSharedObject('footingMaterial')), actions=(("impactSound", self.dropSound, 0.5, 0.1))) self._powerupDist = [] for p, freq in getDefaultPowerupDistribution(): for i in range(int(freq)): self._powerupDist.append(p)
def handleMessage(self, msg): self._handleMessageSanityCheck() if isinstance(msg, PowerupAcceptMessage): factory = self.getFactory() if self.powerupType == 'health': bs.playSound(factory.healthPowerupSound, 3, position=self.node.position) bs.playSound(factory.powerupSound, 3, position=self.node.position) self._powersGiven = True self.handleMessage(bs.DieMessage()) elif isinstance(msg, _TouchedMessage): if not self._powersGiven: node = bs.getCollisionInfo("opposingNode") if node is not None and node.exists(): if self.powerupType == "sloMo": bs.getSharedObject( 'globals').slowMotion = bs.getSharedObject( 'globals').slowMotion == False self._powersGiven = True self.handleMessage(bs.DieMessage()) bsUtils.PopupText( "SloMo", color=(1, 2, 1), scale=1.5, position=self.node.position).autoRetain() elif self.powerupType == "TNT": p = node.positionForward self._powersGiven = True self.handleMessage(bs.DieMessage()) bs.Bomb((p[0] + 0.43, p[1] + 4, p[2] - 0.25), velocity=(0, -6, 0), bombType='tnt').autoRetain() bsUtils.PopupText( "TNT", color=(1, 2, 1), scale=1.5, position=self.node.position).autoRetain() elif self.powerupType == "strongICE": p = node.positionForward self._powersGiven = True self.handleMessage(bs.DieMessage()) bs.Bomb((p[0] + 0.43, p[1] + 4, p[2] - 0.25), velocity=(0, -6, 0), bombType='ice').autoRetain() bs.Bomb((p[0] + 0.43, p[1] + 4, p[2] - 0.25), velocity=(0, -6, 0), bombType='ice').autoRetain() bs.Bomb((p[0] + 0.43, p[1] + 4, p[2] - 0.25), velocity=(0, -6, 0), bombType='ice').autoRetain() bsUtils.PopupText( "ICY", color=(1, 2, 1), scale=1.5, position=self.node.position).autoRetain() elif self.powerupType == "speedBoots": self._powersGiven = True self.handleMessage(bs.DieMessage()) node.hockey = True bsUtils.PopupText( "Speed away", color=(1, 2, 1), scale=1.5, position=self.node.position).autoRetain() elif self.powerupType == "invisible": self._powersGiven = True self.handleMessage(bs.DieMessage()) node.name = ' ' node.style = 'agent' node.headModel = None node.torsoModel = None node.pelvisModel = None node.upperArmModel = None node.foreArmModel = None node.handModel = None node.upperLegModel = None node.lowerLegModel = None node.toesModel = None bsUtils.PopupText( "Invisible", color=(1, 2, 1), scale=1.5, position=self.node.position).autoRetain() elif self.powerupType == "character": self._powersGiven = True self.handleMessage(bs.DieMessage()) testingEvent = 0 event = random.randint( 1, 6) if testingEvent == 0 else testingEvent print 'Patron And Oore282 <3: ' + str(event) if event in [1]: node.colorTexture = bs.getTexture('frostyColor') node.colorMaskTexture = bs.getTexture( 'frostyColorMask') node.headModel = bs.getModel('frostyHead') node.upperArmModel = bs.getModel('kronkUpperArm') node.torsoModel = bs.getModel('frostyTorso') node.pelvisModel = bs.getModel('frostyPelvis') node.foreArmModel = bs.getModel('frostyForeArm') node.handModel = bs.getModel('frostyHand') node.upperLegModel = bs.getModel('frostyUpperLeg') node.lowerLegModel = bs.getModel('frostyLowerLeg') node.toesModel = bs.getModel('frostyToes') node.style = 'frosty' bsUtils.PopupText( "Frosty The Snowman", color=(1, 2, 1), scale=1.5, position=self.node.position).autoRetain() elif event in [2]: node.colorTexture = bs.getTexture('santaColor') node.colorMaskTexture = bs.getTexture( 'santaColorMask') node.headModel = bs.getModel('santaHead') node.upperArmModel = bs.getModel('santaUpperArm') node.torsoModel = bs.getModel('santaTorso') node.pelvisModel = bs.getModel('kronkPelvis') node.foreArmModel = bs.getModel('santaForeArm') node.handModel = bs.getModel('santaHand') node.upperLegModel = bs.getModel('santaUpperLeg') node.lowerLegModel = bs.getModel('santaLowerLeg') node.toesModel = bs.getModel('santaToes') node.style = 'santa' bsUtils.PopupText( "SANTA", color=(1, 2, 1), scale=1.5, position=self.node.position).autoRetain() elif event in [3]: node.colorTexture = bs.getTexture('wizardColor') node.colorMaskTexture = bs.getTexture( 'wizardColorMask') node.headModel = bs.getModel('wizardHead') node.upperArmModel = bs.getModel('wizardUpperArm') node.torsoModel = bs.getModel('wizardTorso') node.pelvisModel = bs.getModel('wizardPelvis') node.foreArmModel = bs.getModel('wizardForeArm') node.handModel = bs.getModel('wizardHand') node.upperLegModel = bs.getModel('wizardUpperLeg') node.lowerLegModel = bs.getModel('wizardLowerLeg') node.toesModel = bs.getModel('wizardToes') node.style = 'wizard' bsUtils.PopupText( "EVIL SCEPTER WIZARD MAN", color=(1, 2, 1), scale=1.5, position=self.node.position).autoRetain() elif event in [4]: node.colorTexture = bs.getTexture('pixieColor') node.colorMaskTexture = bs.getTexture( 'pixieColorMask') node.headModel = bs.getModel('pixieHead') node.upperArmModel = bs.getModel('pixieUpperArm') node.torsoModel = bs.getModel('pixieTorso') node.pelvisModel = bs.getModel('pixiePelvis') node.foreArmModel = bs.getModel('pixieForeArm') node.handModel = bs.getModel('pixieHand') node.upperLegModel = bs.getModel('pixieUpperLeg') node.lowerLegModel = bs.getModel('pixieLowerLeg') node.toesModel = bs.getModel('pixieToes') node.style = 'pixie' bsUtils.PopupText( "PIXIEL-ATED", color=(1, 2, 1), scale=1.5, position=self.node.position).autoRetain() elif event in [5]: node.colorTexture = bs.getTexture('cyborgColor') node.colorMaskTexture = bs.getTexture( 'cyborgColorMask') node.headModel = bs.getModel('cyborgHead') node.upperArmModel = bs.getModel('cyborgUpperArm') node.torsoModel = bs.getModel('cyborgTorso') node.pelvisModel = bs.getModel('cyborgPelvis') node.foreArmModel = bs.getModel('cyborgForeArm') node.handModel = bs.getModel('cyborgHand') node.upperLegModel = bs.getModel('cyborgUpperLeg') node.lowerLegModel = bs.getModel('cyborgLowerLeg') node.toesModel = bs.getModel('cyborgToes') node.style = 'cyborg' bsUtils.PopupText( "The Robo", color=(1, 2, 1), scale=1.5, position=self.node.position).autoRetain() elif event in [6]: node.colorTexture = bs.getTexture('ninjaColor') node.colorMaskTexture = bs.getTexture( 'ninjaColorMask') node.headModel = bs.getModel('ninjaHead') node.upperArmModel = bs.getModel('ninjaUpperArm') node.torsoModel = bs.getModel('ninjaTorso') node.pelvisModel = bs.getModel('ninjaPelvis') node.foreArmModel = bs.getModel('ninjaForeArm') node.handModel = bs.getModel('ninjaHand') node.upperLegModel = bs.getModel('ninjaUpperLeg') node.lowerLegModel = bs.getModel('ninjaLowerLeg') node.toesModel = bs.getModel('ninjaToes') node.style = 'ninja' node.nameColor = (0, 0, 0) node.color = (0, 0, 0) node.highlight = (0, 0, 0) bsUtils.PopupText( "PC||Modder", color=(1, 2, 1), scale=1.5, position=self.node.position).autoRetain() elif self.powerupType == "spazColor": self._powersGiven = True self.handleMessage(bs.DieMessage()) node.color = ((0 + random.random() * 6.5), (0 + random.random() * 6.5), (0 + random.random() * 6.5)) node.highlight = ((0 + random.random() * 6.5), (0 + random.random() * 6.5), (0 + random.random() * 6.5)) node.nameColor = ((0 + random.random() * 1.5), (0 + random.random() * 1.5), (0 + random.random() * 1.5)) node.name += random.choice([ '\nTHE BOSS', '\nNOOB', '\nPRO', '\nKill Me', '\nNooby' ]) bsUtils.PopupText( "PC||Modder", color=(1, 2, 1), scale=1.5, position=self.node.position).autoRetain() elif self.powerupType == "troll": self._powersGiven = True self.handleMessage(bs.DieMessage()) node.handleMessage(bs.FreezeMessage()) node.handleMessage(bs.FreezeMessage()) node.handleMessage( bs.PowerupMessage(powerupType='curse')) bsUtils.PopupText( "TRoLL", color=(1, 2, 1), scale=1.5, position=self.node.position).autoRetain() elif self.powerupType == "champ": self._powersGiven = True self.handleMessage(bs.DieMessage()) node.handleMessage( bs.PowerupMessage(powerupType='punch')) node.handleMessage( bs.PowerupMessage(powerupType='shield')) bsUtils.PopupText( "Champ", color=(1, 2, 1), scale=1.5, position=self.node.position).autoRetain() else: node.handleMessage( PowerupMessage(self.powerupType, sourceNode=self.node)) elif isinstance(msg, bs.DieMessage): if self.node.exists(): if (msg.immediate): self.node.delete() else: curve = bs.animate(self.node, "modelScale", {0: 1, 100: 0}) bs.gameTimer(100, self.node.delete) bs.gameTimer(100, self.nodeLight.delete) elif isinstance(msg, bs.OutOfBoundsMessage): self.handleMessage(bs.DieMessage()) elif isinstance(msg, bs.HitMessage): # dont die on punches (thats annoying) if msg.hitType != 'punch': self.handleMessage(bs.DieMessage()) else: bs.Actor.handleMessage(self, msg)
def __init__(self): self._lastPowerupType = None self.model = bs.getModel("powerup") self.modelSimple = bs.getModel("powerupSimple") self.texBomb = bs.getTexture("powerupBomb") self.texPunch = bs.getTexture("powerupPunch") self.texIceBombs = bs.getTexture("powerupIceBombs") self.texStickyBombs = bs.getTexture("powerupStickyBombs") self.texShield = bs.getTexture("powerupShield") self.texImpactBombs = bs.getTexture("powerupImpactBombs") self.texHealth = bs.getTexture("powerupHealth") self.texLandMines = bs.getTexture("powerupLandMines") self.texCurse = bs.getTexture("powerupCurse") self.texSuperStar = bs.getTexture("levelIcon") #for superStar powerup self.texSpeed = bs.getTexture("powerupSpeed") #for speed powerup self.texIceCube = bs.getTexture("tipTopBGColor") #for iceCube powerup self.texSurprise = bs.getTexture( "powerupHealth") #for surprise powerup self.texMartyrdom = bs.getTexture( "achievementCrossHair") #for martyrdom self.healthPowerupSound = bs.getSound("healthPowerup") self.powerupSound = bs.getSound("powerup01") self.powerdownSound = bs.getSound("powerdown01") self.dropSound = bs.getSound("boxDrop") self.superStarSound = bs.getSound("ooh") #for superstar self.speedSound = bs.getSound("shieldUp") #for speed self.surpriseSound = bs.getSound("hiss") #for surprise self.iceCubeSound = bs.getSound("freeze") #for iceCube self.martyrdomSound = bs.getSound("activateBeep") #for martyrdom drop self.martyrdomPickSound = bs.getSound( "gunCocking") #for martyrdom pick self.blockSound = bs.getSound('block') #for blocking # material for powerups self.powerupMaterial = bs.Material() # material for anyone wanting to accept powerups self.powerupAcceptMaterial = bs.Material() # pass a powerup-touched message to applicable stuff self.powerupMaterial.addActions( conditions=(("theyHaveMaterial", self.powerupAcceptMaterial)), actions=(("modifyPartCollision", "collide", True), ("modifyPartCollision", "physical", False), ("message", "ourNode", "atConnect", _TouchedMessage()))) # we dont wanna be picked up self.powerupMaterial.addActions( conditions=("theyHaveMaterial", bs.getSharedObject('pickupMaterial')), actions=(("modifyPartCollision", "collide", False))) self.powerupMaterial.addActions( conditions=("theyHaveMaterial", bs.getSharedObject('footingMaterial')), actions=(("impactSound", self.dropSound, 0.5, 0.1))) self._powerupDist = [] for p, freq in getDefaultPowerupDistribution(): for i in range(int(freq)): self._powerupDist.append(p)
def __init__(self, map): bs.Actor.__init__(self) self.controlled = False self.sourcePlayer = None self.floaterMaterial = bs.Material() self.floaterMaterial.addActions( conditions=('theyHaveMaterial', bs.getSharedObject('playerMaterial')), actions=(('modifyNodeCollision', 'collide', True), ('modifyPartCollision', 'physical', True))) self.floaterMaterial.addActions( conditions=(('theyDontHaveMaterial', bs.getSharedObject('playerMaterial')), 'and', ('theyHaveMaterial', bs.getSharedObject('objectMaterial')), 'or', ('theyHaveMaterial', bs.getSharedObject('footingMaterial'))), actions=(('modifyPartCollision', 'physical', False), )) self.pos = map.getDefBoundBox('levelBounds') self.px = "random.uniform(self.pos[0],self.pos[3])" self.py = "random.uniform(self.pos[1],self.pos[4])" self.pz = "random.uniform(self.pos[2],self.pos[5])" # self.node = bs.newNode('prop',attrs={'position':(eval(self.px),eval(self.py),eval(self.pz)),'sticky':False,'body':'landMine','model':bs.getModel('landMine'),'colorTexture':bs.getTexture('logo'),'bodyScale':4.0,'reflection': 'powerup','density':99999999999999999,'reflectionScale': [1.0],'modelScale':4.0,'gravityScale':0,'shadowSize':0.1,'isAreaOfInterest':True,'materials':[bs.getSharedObject('footingMaterial'),self.floaterMaterial]}) self.node = bs.newNode( 'prop', delegate=self, owner=None, attrs={ 'position': (eval(self.px), eval(self.py), eval(self.pz)), 'model': bs.getModel('landMine'), 'lightModel': bs.getModel('landMine'), 'body': 'landMine', 'bodyScale': 4, 'modelScale': 4, 'shadowSize': 0.25, 'density': 9999999999999999999, 'gravityScale': 0.0, 'colorTexture': bs.getTexture('logo'), 'reflection': 'soft', 'reflectionScale': [0.25], 'materials': [bs.getSharedObject('footingMaterial'), self.floaterMaterial] }) #self.node.position = map.getDefPoints('flag')[0][:3] self.node2 = bs.newNode( 'prop', owner=self.node, attrs={ 'position': (0, 0, 0), 'sticky': False, 'body': 'sphere', 'model': None, 'colorTexture': bs.getTexture('logo'), 'bodyScale': 1.0, 'reflection': 'powerup', 'density': 99999999999999999, 'reflectionScale': [1.0], 'modelScale': 1.0, 'gravityScale': 0, 'shadowSize': 0.1, 'isAreaOfInterest': True, 'materials': [bs.getSharedObject('objectMaterial'), self.floaterMaterial] }) self.node.connectAttr('position', self.node2, 'position') #self.node.velocity = (0,0.1,0) # bs.gameTimer(500,bs.WeakCall(self.move)) # bs.gameTimer(2000,bs.WeakCall(self.drop),True) self.move()
def __init__(self, position=(0, 1, 0), velocity=(0, 0, 0), bombType='normal', blastRadius=2, sourcePlayer=None, owner=None): if not sourcePlayer.isAlive(): return bs.Actor.__init__(self) factory = self.getFactory() if not bombType in ('ice', 'impact', 'landMine', 'normal', 'sticky', 'tnt'): raise Exception("invalid bomb type: " + bombType) self.bombType = bombType self._exploded = False self.blastRadius = blastRadius self._explodeCallbacks = [] self.sourcePlayer = sourcePlayer self.hitType = 'explosion' self.hitSubType = self.bombType if owner is None: owner = bs.Node(None) self.owner = owner materials = (factory.bombMaterial, bs.getSharedObject('objectMaterial')) materials = materials + (factory.impactBlastMaterial, ) players = self.getActivity().players i = 0 # This gives each player a unique orb color, made possible by the powerup textures within the game. while players[i] != sourcePlayer: i += 1 color = ("powerupIceBombs", "powerupPunch", "powerupStickyBombs", "powerupBomb", "powerupCurse", "powerupHealth", "powerupShield", "powerupLandMines")[i] if isinstance( self.getActivity().getSession(), bs.TeamsSession ): # unless we're on teams, so we'll overide the color to be the team's color if sourcePlayer in self.getActivity().teams[0].players: color = "powerupIceBombs" # for blue else: color = "powerupPunch" # for red self.node = bs.newNode('prop', delegate=self, attrs={ 'position': position, 'velocity': velocity, 'body': 'sphere', 'model': bs.getModel("shield"), 'shadowSize': 0.3, 'density': 1, 'bodyScale': 3, 'colorTexture': bs.getTexture(color), 'reflection': 'soft', 'reflectionScale': [1.5], 'materials': materials }) self.armTimer = bs.Timer(200, bs.WeakCall(self.handleMessage, ArmMessage())) self.node.addDeathAction( bs.WeakCall(self.handleMessage, _BombDiedMessage())) bsUtils.animate(self.node, "modelScale", {0: 0, 200: 1.3, 260: 1})
def path(): p = bs.newNode('prop', attrs={ 'position': (6, 2.0, 2), 'velocity': (2.0, 0.8, 0), 'sticky': False, 'body': 'landMine', 'model': bs.getModel('landMine'), 'colorTexture': bs.getTexture('achievementWall'), 'bodyScale': 1.0, 'reflection': 'powerup', 'density': 9999999999999999, 'reflectionScale': [1.0], 'modelScale': 1.0, 'gravityScale': 0, 'shadowSize': 0.0, 'materials': [ bs.getSharedObject('objectMaterial'), bs.getSharedObject('footingMaterial') ] }) bs.gameTimer(4000, p.delete) p = bs.newNode('prop', attrs={ 'position': (6, 2.0, -2), 'velocity': (2.0, 0.8, 0), 'sticky': False, 'body': 'landMine', 'model': bs.getModel('landMine'), 'colorTexture': bs.getTexture('achievementWall'), 'bodyScale': 1.0, 'reflection': 'powerup', 'density': 9999999999999999, 'reflectionScale': [1.0], 'modelScale': 1.0, 'gravityScale': 0, 'shadowSize': 0.0, 'materials': [ bs.getSharedObject('objectMaterial'), bs.getSharedObject('footingMaterial') ] }) bs.gameTimer(4000, p.delete)
def __init__(self): Map.__init__(self) platform = bs.newNode('prop', delegate=self, attrs={ 'position': (-8.00, 0.9515026107, -2.0), 'velocity': (0, 0, 0), 'sticky': False, 'body': 'crate', 'model': bs.getModel('tnt'), 'density': 0.00000, 'colorTexture': bs.getTexture('menuBG'), 'bodyScale': 6.0, 'reflection': 'powerup', 'damping': 9999999999999, 'reflectionScale': [0], 'modelScale': 6.0, 'shadowSize': 0.0, 'materials': [bs.getSharedObject('footingMaterial')] }) platform = bs.newNode('prop', delegate=self, attrs={ 'position': (-8.00, 0.9515026107, 2.0), 'velocity': (0, 0, 0), 'sticky': False, 'body': 'crate', 'model': bs.getModel('tnt'), 'density': 0.00000, 'colorTexture': bs.getTexture('menuBG'), 'bodyScale': 6.0, 'reflection': 'powerup', 'damping': 9999999999999, 'reflectionScale': [0], 'modelScale': 6.0, 'shadowSize': 0.0, 'materials': [bs.getSharedObject('footingMaterial')] }) self.node = bs.newNode('terrain', delegate=self, attrs={ 'model': self.preloadData['model'], 'collideModel': self.preloadData['collideModel'], 'colorTexture': self.preloadData['tex'], 'materials': [bs.getSharedObject('footingMaterial')] }) bs.newNode('terrain', attrs={ 'model': self.preloadData['vrFillModel'], 'lighting': False, 'vrOnly': True, 'background': True, 'colorTexture': self.preloadData['tex'] }) def credittext(): #bySoby text = bs.newNode('text', attrs={ 'text': 'Mod By SobyDamn', 'scale': 1.0, 'maxWidth': 0, 'position': (0, 0), 'shadow': 1.0, 'flatness': 0.50, 'hAlign': 'center', 'vAttach': 'bottom' }) bs.animate(text, 'opacity', { 0: 0.0, 500: 1.0, 10500: 1.0, 11000: 0.0 }) bs.gameTimer(11500, text.delete) bs.gameTimer(2000, bs.Call(credittext)) def path(): p = bs.newNode('prop', attrs={ 'position': (-5.750, 4.3515026107, -2.0), 'velocity': (2.0, 1.0, 0), 'sticky': False, 'body': 'landMine', 'model': bs.getModel('landMine'), 'colorTexture': bs.getTexture('achievementWall'), 'bodyScale': 1.0, 'reflection': 'powerup', 'density': 9999999999999999, 'reflectionScale': [1.0], 'modelScale': 1.0, 'gravityScale': 0, 'shadowSize': 0.0, 'materials': [ bs.getSharedObject('objectMaterial'), bs.getSharedObject('footingMaterial') ] }) bs.gameTimer(3000, p.delete) p = bs.newNode('prop', attrs={ 'position': (-5.750, 4.3515026107, 2.0), 'velocity': (2.0, 1.0, 0), 'sticky': False, 'body': 'landMine', 'model': bs.getModel('landMine'), 'colorTexture': bs.getTexture('achievementWall'), 'bodyScale': 1.0, 'reflection': 'powerup', 'density': 9999999999999999, 'reflectionScale': [1.0], 'modelScale': 1.0, 'gravityScale': 0, 'shadowSize': 0.0, 'materials': [ bs.getSharedObject('objectMaterial'), bs.getSharedObject('footingMaterial') ] }) bs.gameTimer(3000, p.delete) bs.gameTimer(600, bs.Call(path), repeat=True) def platform(): p = bs.newNode('prop', attrs={ 'position': (0, 2, -2), 'velocity': (0, 0, 1), 'sticky': False, 'body': 'landMine', 'model': bs.getModel('landMine'), 'colorTexture': bs.getTexture('achievementWall'), 'bodyScale': 5.0, 'reflection': 'powerup', 'density': 9999999999999999, 'reflectionScale': [1.0], 'modelScale': 5.0, 'gravityScale': 0, 'shadowSize': 0.0, 'materials': [ bs.getSharedObject('objectMaterial'), bs.getSharedObject('footingMaterial') ] }) bs.gameTimer(7000, p.delete) p = bs.newNode('prop', attrs={ 'position': (0, 1, 2), 'velocity': (2.0, 0.1, 0), 'sticky': False, 'body': 'landMine', 'model': bs.getModel('landMine'), 'colorTexture': bs.getTexture('eggTex2'), 'bodyScale': 4.0, 'reflection': 'powerup', 'density': 9999999999999999, 'reflectionScale': [0.0], 'modelScale': 4.0, 'gravityScale': 0, 'shadowSize': 0.0, 'materials': [ bs.getSharedObject('objectMaterial'), bs.getSharedObject('footingMaterial') ] }) bs.gameTimer(4000, p.delete) p = bs.newNode('prop', attrs={ 'position': (0, 1, -1.5), 'velocity': (2.0, 0.1, 0), 'sticky': False, 'body': 'landMine', 'model': bs.getModel('landMine'), 'colorTexture': bs.getTexture('eggTex2'), 'bodyScale': 4.0, 'reflection': 'powerup', 'density': 9999999999999999, 'reflectionScale': [0.0], 'modelScale': 4.0, 'gravityScale': 0, 'shadowSize': 0.0, 'materials': [ bs.getSharedObject('objectMaterial'), bs.getSharedObject('footingMaterial') ] }) bs.gameTimer(4000, p.delete) bs.gameTimer(200, bs.Call(platform)) bs.gameTimer(5000, bs.Call(platform), repeat=True) def path(): p = bs.newNode('prop', attrs={ 'position': (6, 2.0, 2), 'velocity': (2.0, 0.8, 0), 'sticky': False, 'body': 'landMine', 'model': bs.getModel('landMine'), 'colorTexture': bs.getTexture('achievementWall'), 'bodyScale': 1.0, 'reflection': 'powerup', 'density': 9999999999999999, 'reflectionScale': [1.0], 'modelScale': 1.0, 'gravityScale': 0, 'shadowSize': 0.0, 'materials': [ bs.getSharedObject('objectMaterial'), bs.getSharedObject('footingMaterial') ] }) bs.gameTimer(4000, p.delete) p = bs.newNode('prop', attrs={ 'position': (6, 2.0, -2), 'velocity': (2.0, 0.8, 0), 'sticky': False, 'body': 'landMine', 'model': bs.getModel('landMine'), 'colorTexture': bs.getTexture('achievementWall'), 'bodyScale': 1.0, 'reflection': 'powerup', 'density': 9999999999999999, 'reflectionScale': [1.0], 'modelScale': 1.0, 'gravityScale': 0, 'shadowSize': 0.0, 'materials': [ bs.getSharedObject('objectMaterial'), bs.getSharedObject('footingMaterial') ] }) bs.gameTimer(4000, p.delete) bs.gameTimer(600, bs.Call(path), repeat=True) g = bs.getSharedObject('globals') g.tint = (1.3, 1.2, 1.0) g.ambientColor = (1.3, 1.2, 1.0) g.vignetteOuter = (0.57, 0.57, 0.57) g.vignetteInner = (0.9, 0.9, 0.9) g.vrCameraOffset = (0, -0.8, -1.1) g.vrNearClip = 0.5
def __init__(self): self._lastPowerupType = None self.model = bs.getModel("powerup") self.modelSimple = bs.getModel("powerupSimple") self.texBomb = bs.getTexture("powerupBomb") self.texJumpingBomb = bs.getTexture("eggTex3") self.texPunch = bs.getTexture("powerupPunch") self.texYellowShield = bs.getTexture("coin") self.texKillLaKillBomb = bs.getTexture("black") self.texPoisonBomb = bs.getTexture("black") self.texSpeedPunch = bs.getTexture("achievementSuperPunch") self.texPandoraBox = bs.getTexture("chestIcon") self.texMultiBombs = bs.getTexture("logo") self.texFireworkBomb = bs.getTexture("eggTex1") self.texIceBombs = bs.getTexture("powerupIceBombs") self.texStickyBombs = bs.getTexture("powerupStickyBombs") self.texTpBombs = bs.getTexture("bombStickyColor") self.texShield = bs.getTexture("powerupShield") self.texImpactBombs = bs.getTexture("powerupImpactBombs") self.texHealth = bs.getTexture("powerupHealth") self.texLandMines = bs.getTexture("powerupLandMines") self.texCurse = bs.getTexture("powerupCurse") self.texBalls = bs.getTexture("achievementOutline") self.texUnb = bs.getTexture("puckColor") self.texDirt = bs.getTexture('nub') self.healthPowerupSound = bs.getSound("healthPowerup") self.powerupSound = bs.getSound("powerup01") self.powerdownSound = bs.getSound("pixie2") self.dropSound = bs.getSound("boxDrop") # material for powerups self.powerupMaterial = bs.Material() # material for anyone wanting to accept powerups self.powerupAcceptMaterial = bs.Material() # pass a powerup-touched message to applicable stuff self.powerupMaterial.addActions( conditions=(("theyHaveMaterial", self.powerupAcceptMaterial)), actions=(("modifyPartCollision", "collide", True), ("modifyPartCollision", "physical", False), ("message", "ourNode", "atConnect", _TouchedMessage()))) # we dont wanna be picked up self.powerupMaterial.addActions( conditions=("theyHaveMaterial", bs.getSharedObject('pickupMaterial')), actions=(("modifyPartCollision", "collide", True))) self.powerupMaterial.addActions( conditions=("theyHaveMaterial", bs.getSharedObject('footingMaterial')), actions=(("impactSound", self.dropSound, 0.5, 0.1))) self._powerupDist = [] for p, freq in getDefaultPowerupDistribution(): for i in range(int(freq)): self._powerupDist.append(p)
def opt(self, nick, msg): if self.checkDevice(nick): m = msg.split(' ')[0] # command a = msg.split(' ')[1:] # arguments activity = bsInternal._getForegroundHostActivity() with bs.Context(activity): if m == '/kick': if a == []: bsInternal._chatMessage( 'Using: /kick name or clientID') else: if len(a[0]) > 3: self.kickByNick(a[0]) bsInternal._chatMessage('Player Kicked By Admin') else: try: s = int(a[0]) bsInternal._chatMessage( 'Player Kicked By Admin') bsInternal._disconnectClient(int(a[0])) except: self.kickByNick(a[0]) elif m == '/admin': clID = int(a[0]) for client in bsInternal._getGameRoster(): if client['clientID'] == clID: if a[1] == 'add': newadmin = client['displayString'] updated_admins = gph.adminHashes.append( newadmin) elif a[1] == 'remove': newadmin = client['displayString'] if newadmin in gph.adminHashes: updated_admins = gph.adminHashes.remove( newadmin) with open(bs.getEnvironment()['systemScriptsDirectory'] + "/getPermissionsHashes.py") as file: s = [row for row in file] s[0] = 'vipHashes = []' + '\n' s[1] = 'adminHashes = ' + updated_admins + '\n' f = open( bs.getEnvironment()['systemScriptsDirectory'] + "/getPermissionsHashes.py", 'w') for i in s: f.write(i) f.close() elif m == '/ban': clID = int(a[0]) for client in bsInternal._getGameRoster(): if client['clientID'] == clID: if a[1] == 'add': ban = client['displayString'] updated_ban = gph.ban.append(ban) bs.screenMessage('Banning...') elif a[1] == 'remove': ban = client['displayString'] if ban in gph.ban: updated_ban = gph.ban.remove(ban) with open(bs.getEnvironment()['systemScriptsDirectory'] + "/getPermissionsHashes.py") as file: s = [row for row in file] s[0] = 'vipHashes = []' + '\n' s[1] = 'admin = []' + '\n' s[2] = 'ass = []' + '\n' s[3] = 'ban = ' + updated_ban + '\n' f = open( bs.getEnvironment()['systemScriptsDirectory'] + "/getPermissionsHashes.py", 'w') for i in s: f.write(i) f.close() elif m == '/ass': clID = int(a[0]) for client in bsInternal._getGameRoster(): if client['clientID'] == clID: if a[1] == 'add': ass = client['displayString'] updated_ass = gph.ass.append(ass) elif a[1] == 'remove': ass = client['displayString'] if ass in gph.ass: updated_ass = gph.ass.remove(ass) with open(bs.getEnvironment()['systemScriptsDirectory'] + "/getPermissionsHashes.py") as file: s = [row for row in file] s[0] = 'vipHashes = []' + '\n' s[1] = 'admin= []' + '\n' s[2] = 'ass = ' + updated_admins + '\n' f = open( bs.getEnvironment()['systemScriptsDirectory'] + "/getPermissionsHashes.py", 'w') for i in s: f.write(i) f.close() elif m == '/vip': clID = int(a[0]) for client in bsInternal._getGameRoster(): if client['clientID'] == clID: if a[1] == 'add': vip = client['displayString'] updated_vip = gph.vip.append(vip) elif a[1] == 'remove': vip = client['displayString'] if vip in gph.vip: updated_vip = gph.vip.remove(vip) with open(bs.getEnvironment()['systemScriptsDirectory'] + "/getPermissionsHashes.py") as file: s = [row for row in file] s[0] = 'vip = ' + updated_admins + '\n' f = open( bs.getEnvironment()['systemScriptsDirectory'] + "/getPermissionsHashes.py", 'w') for i in s: f.write(i) f.close() elif m == '/list': bsInternal._chatMessage( "======== FOR /kick ONLY: ========") for i in bsInternal._getGameRoster(): try: bsInternal._chatMessage( i['players'][0]['nameFull'] + " (/kick " + str(i['clientID']) + ")") except: pass bsInternal._chatMessage( "==================================") bsInternal._chatMessage( "======= For other commands: =======") for s in bsInternal._getForegroundHostSession().players: bsInternal._chatMessage( s.getName() + " " + str(bsInternal._getForegroundHostSession( ).players.index(s))) elif m == '/ooh': if a is not None and len(a) > 0: s = int(a[0]) def oohRecurce(c): bs.playSound(bs.getSound('ooh'), volume=2) c -= 1 if c > 0: bs.gameTimer( int(a[1]) if len(a) > 1 and a[1] is not None else 1000, bs.Call(oohRecurce, c=c)) oohRecurce(c=s) else: bs.playSound(bs.getSound('ooh'), volume=2) elif m == '/playSound': if a is not None and len(a) > 1: s = int(a[1]) def oohRecurce(c): bs.playSound(bs.getSound(str(a[0])), volume=2) c -= 1 if c > 0: bs.gameTimer( int(a[2]) if len(a) > 2 and a[2] is not None else 1000, bs.Call(oohRecurce, c=c)) oohRecurce(c=s) else: bs.playSound(bs.getSound(str(a[0])), volume=2) elif m == '/quit': bsInternal.quit() elif m == '/nv': if self.tint is None: self.tint = bs.getSharedObject('globals').tint bs.getSharedObject('globals').tint = ( 0.5, 0.7, 1) if a == [] or not a[0] == u'off' else self.tint elif m == '/freeze': if a == []: bsInternal._chatMessage( 'Using: /freeze all or number of list') else: if a[0] == 'all': for i in bs.getSession().players: try: i.actor.node.handleMessage( bs.FreezeMessage()) except: pass else: bs.getSession().players[int( a[0])].actor.node.handleMessage( bs.FreezeMessage()) elif m == '/thaw': if a == []: bsInternal._chatMessage( 'Using: /thaw all or number of list') else: if a[0] == 'all': for i in bs.getSession().players: try: i.actor.node.handleMessage( bs.ThawMessage()) except: pass else: bs.getSession().players[int( a[0])].actor.node.handleMessage( bs.ThawMessage()) elif m == '/sleep': if a == []: bsInternal._chatMessage('Using: number of list') else: if a[0] == 'all': for i in bs.getSession().players: try: i.actor.node.handleMessage( "knockout", 5000) except: pass else: bs.getSession().players[int( a[0])].actor.node.handleMessage( "knockout", 5000) elif m == '/kill': if a == []: bsInternal._chatMessage( 'Using: /kill all or number of list') else: if a[0] == 'all': for i in bs.getSession().players: try: i.actor.node.handleMessage(bs.DieMessage()) except: pass else: bs.getSession().players[int( a[0])].actor.node.handleMessage( bs.DieMessage()) elif m == '/curse': if a == []: bsInternal._chatMessage( 'Using: /curse all or number of list') else: if a[0] == 'all': for i in bs.getSession().players: try: i.actor.curse() except: pass else: bs.getSession().players[int(a[0])].actor.curse() elif m == '/box': if a == []: bsInternal._chatMessage( 'Using: /box all or number of list') else: try: if a[0] == 'all': for i in bs.getSession().players: try: i.actor.node.torsoModel = bs.getModel( "tnt") except: print 'error' for i in bs.getSession().players: try: i.actor.node.colorMaskTexture = bs.getTexture( "tnt") except: print 'error' for i in bs.getSession().players: try: i.actor.node.colorTexture = bs.getTexture( "tnt") except: print 'error' for i in bs.getSession().players: try: i.actor.node.highlight = (1, 1, 1) except: print 'error' for i in bs.getSession().players: try: i.actor.node.color = (1, 1, 1) except: print 'error' for i in bs.getSession().players: try: i.actor.node.headModel = None except: print 'error' for i in bs.getSession().players: try: i.actor.node.style = "cyborg" except: print 'error' else: n = int(a[0]) bs.getSession().players[ n].actor.node.torsoModel = bs.getModel( "tnt") bs.getSession().players[ n].actor.node.colorMaskTexture = bs.getTexture( "tnt") bs.getSession().players[ n].actor.node.colorTexture = bs.getTexture( "tnt") bs.getSession( ).players[n].actor.node.highlight = (1, 1, 1) bs.getSession().players[n].actor.node.color = ( 1, 1, 1) bs.getSession( ).players[n].actor.node.headModel = None bs.getSession( ).players[n].actor.node.style = "cyborg" except: bs.screenMessage('Ошибка!', color=(1, 0, 0)) elif m == '/spaz': if a == []: bsInternal._chatMessage( 'Using: /spaz all or number of list') else: try: if a[0] == 'all': for i in bs.getSession().players: t = i.actor.node try: t.colorTexture = bs.getTexture(a[1] + "Color") t.colorMaskTexture = bs.getTexture( a[1] + "ColorMask") t.headModel = bs.getModel(a[1] + "Head") t.torsoModel = bs.getModel(a[1] + "Torso") t.pelvisModel = bs.getModel(a[1] + "Pelvis") t.upperArmModel = bs.getModel( a[1] + "UpperArm") t.foreArmModel = bs.getModel(a[1] + "ForeArm") t.handModel = bs.getModel(a[1] + "Hand") t.upperLegModel = bs.getModel( a[1] + "UpperLeg") t.lowerLegModel = bs.getModel( a[1] + "LowerLeg") t.toesModel = bs.getModel(a[1] + "Toes") t.style = a[1] except: print 'error' else: n = int(a[0]) t = bs.getSession().players[n].actor.node t.colorTexture = bs.getTexture(a[1] + "Color") t.colorMaskTexture = bs.getTexture(a[1] + "ColorMask") t.headModel = bs.getModel(a[1] + "Head") t.torsoModel = bs.getModel(a[1] + "Torso") t.pelvisModel = bs.getModel(a[1] + "Pelvis") t.upperArmModel = bs.getModel(a[1] + "UpperArm") t.foreArmModel = bs.getModel(a[1] + "ForeArm") t.handModel = bs.getModel(a[1] + "Hand") t.upperLegModel = bs.getModel(a[1] + "UpperLeg") t.lowerLegModel = bs.getModel(a[1] + "LowerLeg") t.toesModel = bs.getModel(a[1] + "Toes") t.style = a[1] except: bs.screenMessage('error', color=(1, 0, 0)) elif m == '/inv': if a == []: bsInternal._chatMessage( 'Using: /spaz all or number of list') else: try: if a[0] == 'all': for i in bs.getSession().players: t = i.actor.node try: t.headModel = None t.torsoModel = None t.pelvisModel = None t.upperArmModel = None t.foreArmModel = None t.handModel = None t.upperLegModel = None t.lowerLegModel = None t.toesModel = None t.style = "cyborg" except: print 'error' else: n = int(a[0]) t = bs.getSession().players[n].actor.node t.headModel = None t.torsoModel = None t.pelvisModel = None t.upperArmModel = None t.foreArmModel = None t.handModel = None t.upperLegModel = None t.lowerLegModel = None t.toesModel = None t.style = "cyborg" except: bs.screenMessage('error', color=(1, 0, 0)) elif m == '/tex': if a == []: bsInternal._chatMessage( 'Using: /tex all or number of list') else: try: if a[0] == 'all': for i in bs.getSession().players: try: i.actor.node.colorMaskTexture = bs.getTexture( "egg1") except: print 'error' for i in bs.getSession().players: try: i.actor.node.colorTexture = bs.getTexture( "egg1") except: print 'error' else: n = int(a[0]) bs.getSession().players[ n].actor.node.colorMaskTexture = bs.getTexture( "egg1") bs.getSession().players[ n].actor.node.colorTexture = bs.getTexture( "egg1") except: bs.screenMessage('Ошибка!', color=(1, 0, 0)) elif m == '/remove': if a == []: bsInternal._chatMessage( 'Using: /remove all or number of list') else: if a[0] == 'all': for i in bs.getSession().players: try: i.removeFromGame() except: pass else: bs.getSession().players[int(a[0])].removeFromGame() elif m == '/end': try: bsInternal._getForegroundHostActivity().endGame() except: pass elif m == '/hug': if a == []: bsInternal._chatMessage( 'Using: /hug all or number of list') else: try: if a[0] == 'all': try: bsInternal._getForegroundHostActivity( ).players[ 0].actor.node.holdNode = bsInternal._getForegroundHostActivity( ).players[1].actor.node except: pass try: bsInternal._getForegroundHostActivity( ).players[ 1].actor.node.holdNode = bsInternal._getForegroundHostActivity( ).players[0].actor.node except: pass try: bsInternal._getForegroundHostActivity( ).players[ 3].actor.node.holdNode = bsInternal._getForegroundHostActivity( ).players[2].actor.node except: pass try: bsInternal._getForegroundHostActivity( ).players[ 4].actor.node.holdNode = bsInternal._getForegroundHostActivity( ).players[3].actor.node except: pass try: bsInternal._getForegroundHostActivity( ).players[ 5].actor.node.holdNode = bsInternal._getForegroundHostActivity( ).players[6].actor.node except: pass try: bsInternal._getForegroundHostActivity( ).players[ 6].actor.node.holdNode = bsInternal._getForegroundHostActivity( ).players[7].actor.node except: pass else: bsInternal._getForegroundHostActivity( ).players[int( a[0] )].actor.node.holdNode = bsInternal._getForegroundHostActivity( ).players[int(a[1])].actor.node except: bs.screenMessage('Ошибка!', color=(1, 0, 0)) elif m == '/gm': if a == []: for i in range(len(activity.players)): if activity.players[i].getName().encode( 'utf-8').find( nick.encode('utf-8').replace( '...', '').replace(':', '')) != -1: activity.players[ i].actor.node.hockey = activity.players[ i].actor.node.hockey == False activity.players[ i].actor.node.invincible = activity.players[ i].actor.node.invincible == False activity.players[ i].actor._punchPowerScale = 5 if activity.players[ i].actor._punchPowerScale == 1.2 else 1.2 else: activity.players[int( a[0])].actor.node.hockey = activity.players[int( a[0])].actor.node.hockey == False activity.players[int( a[0])].actor.node.invincible = activity.players[ int(a[0])].actor.node.invincible == False activity.players[int( a[0] )].actor._punchPowerScale = 5 if activity.players[int( a[0])].actor._punchPowerScale == 1.2 else 1.2 elif m == '/tint': if a == []: bsInternal._chatMessage('Using: /tint R G B') bsInternal._chatMessage('OR') bsInternal._chatMessage('Using: /tint r bright speed') else: if a[0] == 'r': m = 1.3 if a[1] is None else float(a[1]) s = 1000 if a[2] is None else float(a[2]) bsUtils.animateArray( bs.getSharedObject('globals'), 'tint', 3, { 0: (1 * m, 0, 0), s: (0, 1 * m, 0), s * 2: (0, 0, 1 * m), s * 3: (1 * m, 0, 0) }, True) else: try: if a[1] is not None: bs.getSharedObject('globals').tint = ( float(a[0]), float(a[1]), float(a[2])) else: bs.screenMessage('Error!', color=(1, 0, 0)) except: bs.screenMessage('Error!', color=(1, 0, 0)) elif m == 'pause': bs.getSharedObject('globals').paused = bs.getSharedObject( 'globals').paused == False elif m == '/sm': bs.getSharedObject( 'globals').slowMotion = bs.getSharedObject( 'globals').slowMotion == False elif m == '/bunny': if a == []: bsInternal._chatMessage( 'Using: /bunny count owner(number of list)') import BuddyBunny for i in range(int(a[0])): p = bs.getSession().players[int(a[1])] if not 'bunnies' in p.gameData: p.gameData['bunnies'] = BuddyBunny.BunnyBotSet(p) p.gameData['bunnies'].doBunny() elif m == '/cameraMode': try: if bs.getSharedObject( 'globals').cameraMode == 'follow': bs.getSharedObject('globals').cameraMode = 'rotate' else: bs.getSharedObject('globals').cameraMode = 'follow' except: pass elif m == '/lm': arr = [] for i in range(100): try: arr.append(bsInternal._getChatMessages()[-1 - i]) except: pass arr.reverse() for i in arr: bsInternal._chatMessage(i) elif m == '/gp': if a == []: bsInternal._chatMessage('Using: /gp number of list') else: s = bsInternal._getForegroundHostSession() for i in s.players[int( a[0])].getInputDevice()._getPlayerProfiles(): try: bsInternal._chatMessage(i) except: pass elif m == '/icy': bsInternal._getForegroundHostActivity().players[int( a[0] )].actor.node = bsInternal._getForegroundHostActivity( ).players[int(a[1])].actor.node elif m == '/fly': if a == []: bsInternal._chatMessage( 'Using: /fly all or number of list') else: if a[0] == 'all': for i in bsInternal._getForegroundHostActivity( ).players: i.actor.node.fly = True else: bsInternal._getForegroundHostActivity( ).players[int( a[0] )].actor.node.fly = bsInternal._getForegroundHostActivity( ).players[int(a[0])].actor.node.fly == False elif m == '/floorReflection': bs.getSharedObject( 'globals').floorReflection = bs.getSharedObject( 'globals').floorReflection == False elif m == '/ac': if a == []: bsInternal._chatMessage('Using: /ac R G B') bsInternal._chatMessage('OR') bsInternal._chatMessage('Using: /ac r bright speed') else: if a[0] == 'r': m = 1.3 if a[1] is None else float(a[1]) s = 1000 if a[2] is None else float(a[2]) bsUtils.animateArray( bs.getSharedObject('globals'), 'ambientColor', 3, { 0: (1 * m, 0, 0), s: (0, 1 * m, 0), s * 2: (0, 0, 1 * m), s * 3: (1 * m, 0, 0) }, True) else: try: if a[1] is not None: bs.getSharedObject( 'globals').ambientColor = (float(a[0]), float(a[1]), float(a[2])) else: bs.screenMessage('Error!', color=(1, 0, 0)) except: bs.screenMessage('Error!', color=(1, 0, 0)) elif m == '/iceOff': try: activity.getMap().node.materials = [ bs.getSharedObject('footingMaterial') ] activity.getMap().isHockey = False except: pass try: activity.getMap().floor.materials = [ bs.getSharedObject('footingMaterial') ] activity.getMap().isHockey = False except: pass for i in activity.players: i.actor.node.hockey = False elif m == '/maxPlayers': if a == []: bsInternal._chatMessage( 'Using: /maxPlayers count of players') else: try: bsInternal._getForegroundHostSession( )._maxPlayers = int(a[0]) bsInternal._setPublicPartyMaxSize(int(a[0])) bsInternal._chatMessage('Players limit set to ' + str(int(a[0]))) except: bs.screenMessage('Error!', color=(1, 0, 0)) elif m == '/heal': if a == []: bsInternal._chatMessage( 'Using: /heal all or number of list') else: try: bsInternal._getForegroundHostActivity().players[ int(a[0])].actor.node.handleMessage( bs.PowerupMessage(powerupType='health')) except: bs.screenMessage('Error!', color=(1, 0, 0)) elif m == '/reflections': if a == [] or len(a) < 2: bsInternal._chatMessage( 'Using: /reflections type(1/0) scale') rs = [int(a[1])] type = 'soft' if int(a[0]) == 0 else 'powerup' try: bsInternal._getForegroundHostActivity().getMap( ).node.reflection = type bsInternal._getForegroundHostActivity().getMap( ).node.reflectionScale = rs except: pass try: bsInternal._getForegroundHostActivity().getMap( ).bg.reflection = type bsInternal._getForegroundHostActivity().getMap( ).bg.reflectionScale = rs except: pass try: bsInternal._getForegroundHostActivity().getMap( ).floor.reflection = type bsInternal._getForegroundHostActivity().getMap( ).floor.reflectionScale = rs except: pass try: bsInternal._getForegroundHostActivity().getMap( ).center.reflection = type bsInternal._getForegroundHostActivity().getMap( ).center.reflectionScale = rs except: pass elif m == '/shatter': if a == []: bsInternal._chatMessage( 'Using: /shatter all or number of list') else: if a[0] == 'all': for i in bsInternal._getForegroundHostActivity( ).players: i.actor.node.shattered = int(a[1]) else: bsInternal._getForegroundHostActivity().players[ int(a[0])].actor.node.shattered = int(a[1]) elif m == '/cm': if a == []: time = 8000 else: time = int(a[0]) op = 0.08 std = bs.getSharedObject('globals').vignetteOuter bsUtils.animateArray( bs.getSharedObject('globals'), 'vignetteOuter', 3, { 0: bs.getSharedObject('globals').vignetteOuter, 17000: (0, 1, 0) }) try: bsInternal._getForegroundHostActivity().getMap( ).node.opacity = op except: pass try: bsInternal._getForegroundHostActivity().getMap( ).bg.opacity = op except: pass try: bsInternal._getForegroundHostActivity().getMap( ).bg.node.opacity = op except: pass try: bsInternal._getForegroundHostActivity().getMap( ).node1.opacity = op except: pass try: bsInternal._getForegroundHostActivity().getMap( ).node2.opacity = op except: pass try: bsInternal._getForegroundHostActivity().getMap( ).node3.opacity = op except: pass try: bsInternal._getForegroundHostActivity().getMap( ).steps.opacity = op except: pass try: bsInternal._getForegroundHostActivity().getMap( ).floor.opacity = op except: pass try: bsInternal._getForegroundHostActivity().getMap( ).center.opacity = op except: pass def off(): op = 1 try: bsInternal._getForegroundHostActivity().getMap( ).node.opacity = op except: pass try: bsInternal._getForegroundHostActivity().getMap( ).bg.opacity = op except: pass try: bsInternal._getForegroundHostActivity().getMap( ).bg.node.opacity = op except: pass try: bsInternal._getForegroundHostActivity().getMap( ).node1.opacity = op except: pass try: bsInternal._getForegroundHostActivity().getMap( ).node2.opacity = op except: pass try: bsInternal._getForegroundHostActivity().getMap( ).node3.opacity = op except: pass try: bsInternal._getForegroundHostActivity().getMap( ).steps.opacity = op except: pass try: bsInternal._getForegroundHostActivity().getMap( ).floor.opacity = op except: pass try: bsInternal._getForegroundHostActivity().getMap( ).center.opacity = op except: pass bsUtils.animateArray( bs.getSharedObject('globals'), 'vignetteOuter', 3, { 0: bs.getSharedObject('globals').vignetteOuter, 100: std }) bs.gameTimer(time, bs.Call(off)) elif m == 'help': bsInternal._chatMessage( bs.Lstr(resource='help1').evaluate()) bsInternal._chatMessage( bs.Lstr(resource='help2').evaluate()) bsInternal._chatMessage( bs.Lstr(resource='help3').evaluate()) bsInternal._chatMessage( bs.Lstr(resource='help4').evaluate()) bsInternal._chatMessage( bs.Lstr(resource='help5').evaluate()) bsInternal._chatMessage( bs.Lstr(resource='help6').evaluate()) bsInternal._chatMessage( bs.Lstr(resource='help7').evaluate()) bsInternal._chatMessage( bs.Lstr(resource='help8').evaluate()) bsInternal._chatMessage( bs.Lstr(resource='help9').evaluate()) bsInternal._chatMessage( bs.Lstr(resource='help10').evaluate()) bsInternal._chatMessage( bs.Lstr(resource='help11').evaluate()) bsInternal._chatMessage( bs.Lstr(resource='help12').evaluate()) bsInternal._chatMessage( bs.Lstr(resource='help13').evaluate()) bsInternal._chatMessage( bs.Lstr(resource='help14').evaluate()) bsInternal._chatMessage( bs.Lstr(resource='help15').evaluate()) bsInternal._chatMessage( bs.Lstr(resource='help16').evaluate()) bsInternal._chatMessage( bs.Lstr(resource='help17').evaluate()) bsInternal._chatMessage( bs.Lstr(resource='help18').evaluate()) bsInternal._chatMessage( bs.Lstr(resource='help19').evaluate()) bsInternal._chatMessage( bs.Lstr(resource='help20').evaluate()) bsInternal._chatMessage( bs.Lstr(resource='help21').evaluate()) bsInternal._chatMessage( bs.Lstr(resource='help22').evaluate()) bsInternal._chatMessage( bs.Lstr(resource='help23').evaluate()) bsInternal._chatMessage( bs.Lstr(resource='help24').evaluate()) bsInternal._chatMessage( bs.Lstr(resource='help25').evaluate()) bsInternal._chatMessage( bs.Lstr(resource='help26').evaluate()) bsInternal._chatMessage( bs.Lstr(resource='help27').evaluate()) bsInternal._chatMessage( bs.Lstr(resource='help28').evaluate()) bsInternal._chatMessage( bs.Lstr(resource='help29').evaluate()) bsInternal._chatMessage( bs.Lstr(resource='help30').evaluate()) bsInternal._chatMessage( bs.Lstr(resource='help31').evaluate()) bsInternal._chatMessage( bs.Lstr(resource='help32').evaluate())
def __init__(self): """ Instantiate a PowerupFactory. You shouldn't need to do this; call bs.Powerup.getFactory() to get a shared instance. """ self._lastPowerupType = None self.model = bs.getModel("powerup") self.modelSimple = bs.getModel("powerupSimple") self.texBomb = bs.getTexture("powerupBomb") self.texPunch = bs.getTexture("powerupPunch") self.texSpeed = bs.getTexture("achievementGotTheMoves") self.texRchar = bs.getTexture("achievementEmpty") self.texInv = bs.getTexture("achievementMedalSmall") self.texTroll = bs.getTexture("achievementOffYouGo") self.texParty = bs.getTexture("eggTex1") self.texBunny = bs.getTexture('achievementFreeLoader') self.texBot = bs.getTexture('star') self.texIceBombs = bs.getTexture("powerupIceBombs") self.texStickyBombs = bs.getTexture("powerupStickyBombs") self.texShield = bs.getTexture("powerupShield") self.texImpactBombs = bs.getTexture("powerupImpactBombs") self.texHealth = bs.getTexture("powerupHealth") self.texLandMines = bs.getTexture("powerupLandMines") self.texCurse = bs.getTexture("powerupCurse") self.texiceMine = bs.getTexture("gameCircleIcon") self.textrioBomb = bs.getTexture("crossOutMask") self.healthPowerupSound = bs.getSound("healthPowerup") self.powerupSound = bs.getSound("powerup01") self.powerdownSound = bs.getSound("powerdown01") self.dropSound = bs.getSound("boxDrop") # material for powerups self.powerupMaterial = bs.Material() # material for anyone wanting to accept powerups self.powerupAcceptMaterial = bs.Material() # pass a powerup-touched message to applicable stuff self.powerupMaterial.addActions( conditions=(("theyHaveMaterial",self.powerupAcceptMaterial)), actions=(("modifyPartCollision","collide",True), ("modifyPartCollision","physical",False), ("message","ourNode","atConnect",_TouchedMessage()))) # we dont wanna be picked up self.powerupMaterial.addActions( conditions=("theyHaveMaterial", bs.getSharedObject('pickupMaterial')), actions=( ("modifyPartCollision","collide",False))) self.powerupMaterial.addActions( conditions=("theyHaveMaterial", bs.getSharedObject('footingMaterial')), actions=(("impactSound",self.dropSound,0.5,0.1))) self._powerupDist = [] for p,freq in getDefaultPowerupDistribution(): for i in range(int(freq)): self._powerupDist.append(p)
def boxall(): for i in bs.getSession().players: try: i.actor.node.torsoModel = bs.getModel("tnt") except: print 'error'
def __init__(self, scoreboard, team, doCover, scale, label, flashLength): self._scoreboard = weakref.ref(scoreboard) self._doCover = doCover self._scale = scale self._flashLength = flashLength self._width = 140.0 * self._scale self._height = 32.0 * self._scale self._barWidth = 2.0 * self._scale self._barHeight = 32.0 * self._scale self._barTex = self._backingTex = bs.getTexture('bar') self._coverTex = bs.getTexture('cuteSpaz') self._model = bs.getModel('meterTransparent') safeTeamColor = bs.getSafeColor(team.color, targetIntensity=1.0) vr = bs.getEnvironment()['vrMode'] if self._doCover: if vr: self._backingColor = [0.1 + c * 0.1 for c in safeTeamColor] else: self._backingColor = [0.05 + c * 0.17 for c in safeTeamColor] else: self._backingColor = [0.05 + c * 0.1 for c in safeTeamColor] self._backing = bs.NodeActor( bs.newNode('image', attrs={ 'scale': (self._width, self._height), 'opacity': (0.8 if vr else 0.8) if self._doCover else 0.5, 'color': self._backingColor, 'vrDepth': -3, 'attach': 'topLeft', 'texture': self._backingTex })) self._barColor = safeTeamColor self._bar = bs.NodeActor( bs.newNode('image', attrs={ 'opacity': 0.7, 'color': self._barColor, 'attach': 'topLeft', 'texture': self._barTex })) self._barScale = bs.newNode('combine', owner=self._bar.node, attrs={ 'size': 2, 'input0': self._barWidth, 'input1': self._barHeight }) self._barScale.connectAttr('output', self._bar.node, 'scale') self._barPosition = bs.newNode('combine', owner=self._bar.node, attrs={ 'size': 2, 'input0': 0, 'input1': 0 }) self._barPosition.connectAttr('output', self._bar.node, 'position') self._coverColor = safeTeamColor if self._doCover: self._cover = bs.NodeActor( bs.newNode('image', attrs={ 'scale': (self._width * 1.15, self._height * 1.6), 'opacity': 1.0, 'color': self._coverColor, 'vrDepth': 2, 'attach': 'topLeft', 'texture': self._coverTex, 'modelTransparent': self._model })) c = safeTeamColor self._scoreText = bs.NodeActor( bs.newNode('text', attrs={ 'hAttach': 'left', 'vAttach': 'top', 'hAlign': 'right', 'vAlign': 'center', 'maxWidth': 130.0 * (1.0 - scoreboard._scoreSplit), 'vrDepth': 2, 'scale': self._scale * 0.9, 'text': '', 'shadow': 1.0 if vr else 0.5, 'flatness': (1.0 if vr else 0.5) if self._doCover else 1.0, 'color': c })) c = safeTeamColor if label is not None: teamNameLabel = label else: teamNameLabel = team.name # we do our own clipping here; should probably try to tap into some # existing functionality if type(teamNameLabel) is bs.Lstr: # hmmm; if the team-name is a non-translatable value lets go # ahead and clip it otherwise we leave it as-is so # translation can occur.. if teamNameLabel.isFlatValue(): v = teamNameLabel.evaluate() # in python < 3.5 some unicode chars can have length 2, # so we need to convert to raw int vals for safer trimming vChars = bs.uniToInts(v) if len(vChars) > 10: teamNameLabel = bs.Lstr( value=bs.uniFromInts(vChars[:10]) + '...') else: # in python < 3.5 some unicode chars can have length 2, # so we need to convert to raw int vals for safe trimming teamNameLabelChars = bs.uniToInts(teamNameLabel) if len(teamNameLabelChars) > 10: teamNameLabel = bs.uniFromInts( teamNameLabelChars[:10]) + '...' teamNameLabel = bs.Lstr(value=teamNameLabel) self._nameText = bs.NodeActor( bs.newNode('text', attrs={ 'hAttach': 'left', 'vAttach': 'top', 'hAlign': 'left', 'vAlign': 'center', 'vrDepth': 2, 'scale': self._scale * 0.9, 'shadow': 1.0 if vr else 0.5, 'flatness': (1.0 if vr else 0.5) if self._doCover else 1.0, 'maxWidth': 130 * scoreboard._scoreSplit, 'text': teamNameLabel, 'color': c + (1.0, ) })) self._score = None
def __init__(self): """ Instantiate a BombFactory. You shouldn't need to do this; call bs.Bomb.getFactory() to get a shared instance. """ self.bombModel = bs.getModel('bomb') self.stickyBombModel = bs.getModel('bombSticky') self.impactBombModel = bs.getModel('impactBomb') self.landMineModel = bs.getModel('landMine') self.tntModel = bs.getModel('tnt') self.regularTex = bs.getTexture('bombColor') self.iceTex = bs.getTexture('bombColorIce') self.stickyTex = bs.getTexture('bombStickyColor') self.impactTex = bs.getTexture('impactBombColor') self.impactLitTex = bs.getTexture('impactBombColorLit') self.landMineTex = bs.getTexture('landMine') self.landMineLitTex = bs.getTexture('landMineLit') self.tntTex = bs.getTexture('tnt') self.hissSound = bs.getSound('hiss') self.debrisFallSound = bs.getSound('debrisFall') self.woodDebrisFallSound = bs.getSound('woodDebrisFall') self.explodeSounds = (bs.getSound('explosion01'), bs.getSound('explosion02'), bs.getSound('explosion03'), bs.getSound('explosion04'), bs.getSound('explosion05')) self.freezeSound = bs.getSound('freeze') self.fuseSound = bs.getSound('fuse01') self.activateSound = bs.getSound('activateBeep') self.warnSound = bs.getSound('warnBeep') # set up our material so new bombs dont collide with objects # that they are initially overlapping self.bombMaterial = bs.Material() self.normalSoundMaterial = bs.Material() self.stickyMaterial = bs.Material() self.bombMaterial.addActions( conditions=((('weAreYoungerThan', 100), 'or', ('theyAreYoungerThan', 100)), 'and', ('theyHaveMaterial', bs.getSharedObject('objectMaterial'))), actions=(('modifyNodeCollision', 'collide', False))) # we want pickup materials to always hit us even if we're currently not # colliding with their node (generally due to the above rule) self.bombMaterial.addActions( conditions=('theyHaveMaterial', bs.getSharedObject('pickupMaterial')), actions=(('modifyPartCollision', 'useNodeCollide', False))) self.bombMaterial.addActions(actions=('modifyPartCollision', 'friction', 0.3)) self.landMineNoExplodeMaterial = bs.Material() self.landMineBlastMaterial = bs.Material() self.landMineBlastMaterial.addActions( conditions=(('weAreOlderThan', 200), 'and', ('theyAreOlderThan', 200), 'and', ('evalColliding', ), 'and', (('theyDontHaveMaterial', self.landMineNoExplodeMaterial), 'and', (('theyHaveMaterial', bs.getSharedObject('objectMaterial')), 'or', ('theyHaveMaterial', bs.getSharedObject('playerMaterial'))))), actions=(('message', 'ourNode', 'atConnect', ImpactMessage()))) self.impactBlastMaterial = bs.Material() self.impactBlastMaterial.addActions( conditions=(('weAreOlderThan', 200), 'and', ('theyAreOlderThan', 200), 'and', ('evalColliding', ), 'and', (('theyHaveMaterial', bs.getSharedObject('footingMaterial')), 'or', ('theyHaveMaterial', bs.getSharedObject('objectMaterial')))), actions=(('message', 'ourNode', 'atConnect', ImpactMessage()))) self.blastMaterial = bs.Material() self.blastMaterial.addActions( conditions=(('theyHaveMaterial', bs.getSharedObject('objectMaterial'))), actions=(('modifyPartCollision', 'collide', True), ('modifyPartCollision', 'physical', False), ('message', 'ourNode', 'atConnect', ExplodeHitMessage()))) self.dinkSounds = (bs.getSound('bombDrop01'), bs.getSound('bombDrop02')) self.stickyImpactSound = bs.getSound('stickyImpact') self.rollSound = bs.getSound('bombRoll01') # collision sounds self.normalSoundMaterial.addActions( conditions=('theyHaveMaterial', bs.getSharedObject('footingMaterial')), actions=(('impactSound', self.dinkSounds, 2, 0.8), ('rollSound', self.rollSound, 3, 6))) self.stickyMaterial.addActions(actions=(('modifyPartCollision', 'stiffness', 0.1), ('modifyPartCollision', 'damping', 1.0))) self.stickyMaterial.addActions( conditions=(('theyHaveMaterial', bs.getSharedObject('playerMaterial')), 'or', ('theyHaveMaterial', bs.getSharedObject('footingMaterial'))), actions=(('message', 'ourNode', 'atConnect', SplatMessage())))
def __init__(self): """ Instantiate a PowerupFactory. You shouldn't need to do this; call bs.Powerup.getFactory() to get a shared instance. """ self._lastPowerupType = None self.model = bs.getModel('powerup') self.modelSimple = bs.getModel('powerupSimple') self.snoModel = bs.getModel('frostyPelvis') self.texBomb = bs.getTexture('powerupBomb') self.texPunch = bs.getTexture('powerupPunch') self.texIceBombs = bs.getTexture('powerupIceBombs') self.texStickyBombs = bs.getTexture('powerupStickyBombs') self.texShield = bs.getTexture('powerupShield') self.texImpactBombs = bs.getTexture('powerupImpactBombs') self.texHealth = bs.getTexture('powerupHealth') self.texLandMines = bs.getTexture('powerupLandMines') self.texCurse = bs.getTexture('powerupCurse') self.texLuckyBlock = bs.getTexture('powerupLuckyBlock') self.texExtraAccelerator = bs.getTexture('powerupExtraAccelerator') self.texStickyForce = bs.getTexture('powerupStickyForce') self.texDirt = bs.getTexture('powerupDirt') self.texSpeed = bs.getTexture('powerupSpeed') self.texLego = bs.getTexture('powerupLego') self.texCannon = bs.getTexture('powerupCannon') self.textoxic = bs.getTexture('powerupToxic') self.texPoison = bs.getTexture('powerupPoison') self.texSlipper = bs.getTexture('powerupSlipper') self.texArtillery = bs.getTexture('powerupArtillery') self.texHealthBomb = bs.getTexture('powerupHealthBomb') self.texBanana = bs.getTexture('powerupBanana') self.shockWaveTex = bs.getTexture('powerupShockwave') self.texMolotov = bs.getTexture('powerupMolotov') self.texPetard = bs.getTexture('powerupPetard') self.texHolyBomb = bs.getTexture('powerupHolyBomb') self.texPortalBomb = bs.getTexture('powerupPortalBomb') self.texElonMuskMine = bs.getTexture('powerupElonMine') self.texAirstrike = bs.getTexture('powerupAirstrike') self.texColorBomb = bs.getTexture('powerupPaintBomb') self.texHighJump = bs.getTexture('powerupJump') self.texBot = bs.getTexture('neoSpazIcon') self.texSno = bs.getTexture('bunnyColor') self.texBlessing = bs.getTexture('powerupBlessing') self.texRailgun = bs.getTexture('powerupRailgun') self.healthPowerupSound = bs.getSound('healthPowerup') self.powerupSound = bs.getSound('powerup01') self.powerdownSound = bs.getSound('powerdown01') self.dropSound = bs.getSound('boxDrop') # material for powerups self.powerupMaterial = bs.Material() # material for anyone wanting to accept powerups self.powerupAcceptMaterial = bs.Material() # pass a powerup-touched message to applicable stuff self.powerupMaterial.addActions( conditions=(('theyHaveMaterial', self.powerupAcceptMaterial)), actions=(('modifyPartCollision', 'collide', True), ('modifyPartCollision', 'physical', False), ('message', 'ourNode', 'atConnect', _TouchedMessage()))) # we dont wanna be picked up self.powerupMaterial.addActions( conditions=('theyHaveMaterial', bs.getSharedObject('pickupMaterial')), actions=(('modifyPartCollision', 'collide', False))) self.powerupMaterial.addActions( conditions=('theyHaveMaterial', bs.getSharedObject('footingMaterial')), actions=(('impactSound', self.dropSound, 0.5, 0.1))) self._powerupDist = [] for p, freq in getDefaultPowerupDistribution(): for i in range(int(freq)): self._powerupDist.append(p)