예제 #1
0
def getDefaultPowerupDistribution(all=False):
    if gSettingsEnabled: settings = bs.get_settings()
    else: settings = {}
    powerups_all = {'tripleBombs': 3, 'iceBombs': 3, \
        'punch': 3, 'impactBombs': 3, 'shield': 2, \
        'landMines': 2, 'stickyBombs': 3, \
        'health': 2, 'curse': 1, 'yellowShield': 1, \
        'speedPunch': 1, 'fireworkBombs': 1, \
        'killLaKillBombs': 2, 'jumpingBombs': 1, \
        'tpBombs': 1, 'poisonBombs': 1, \
        'pandoraBox': 1, 'unbreakable': 1, \
        'dirtBombs': 1, 'multiBombs': 1}
    exclude_powerups = settings.get("exclude_powerups", [])
    active_powerups = powerups_all.keys()
    if not all:
        if settings.get("disable_powerups", False): active_powerups = []
        elif len(exclude_powerups) > 0:
            active_powerups = [
                i for i in powerups_all if i not in exclude_powerups
            ]
    return tuple([(i) if i[0] in active_powerups else (i[0], 0)
                  for i in powerups_all.items()])
    def __init__(self,
                 position=(0, 1, 0),
                 powerupType='tripleBombs',
                 expire=True):

        bs.Actor.__init__(self)
        factory = self.getFactory()

        if gSettingsEnabled: settings = bs.get_settings()
        else: settings = {}

        self.powerupType = powerupType
        self._powersGiven = False
        if powerupType == 'tripleBombs':
            tex = factory.texBomb
            name = 'TripleBombs'
        elif powerupType == 'multiBombs':
            tex = factory.texMultiBombs
            name = 'MultiBombs'
        elif powerupType == 'punch':
            tex = factory.texPunch
            name = 'Gloves'
        elif powerupType == 'speedPunch':
            tex = factory.texSpeedPunch
            name = 'Gloves 2.0'
        elif powerupType == 'fireworkBombs':
            tex = factory.texFireworkBomb
            name = 'FireWorks'
        elif powerupType == 'killLaKillBombs':
            tex = factory.texKillLaKillBomb
            name = 'KillAll'
        elif powerupType == 'poisonBombs':
            tex = factory.texPoisonBomb
            name = 'PoisonBomb'
        elif powerupType == 'pandoraBox':
            tex = factory.texPandoraBox
            name = 'PandoraBox'
        elif powerupType == 'yellowShield':
            tex = factory.texYellowShield
            name = 'YellowShield'
        elif powerupType == 'jumpingBombs':
            tex = factory.texJumpingBomb
            name = 'JumpingBomb'
        elif powerupType == 'tpBombs':
            tex = factory.texTpBombs
            name = 'TPBomb'
        elif powerupType == 'iceBombs':
            tex = factory.texIceBombs
            name = 'IcyBombs'
        elif powerupType == 'impactBombs':
            tex = factory.texImpactBombs
            name = 'ImpactBombs'
        elif powerupType == 'landMines':
            tex = factory.texLandMines
            name = 'LandMines'
        elif powerupType == 'stickyBombs':
            tex = factory.texStickyBombs
            name = 'StickyBombs'
        elif powerupType == 'shield':
            tex = factory.texShield
            name = 'Bubble'
        elif powerupType == 'health':
            tex = factory.texHealth
            name = 'Health'
        elif powerupType == 'curse':
            tex = factory.texCurse
            name = 'Pls Touch Me'
        elif powerupType == 'unbreakable':
            tex = factory.texUnb
            name = 'Unbreakable'
        elif powerupType == 'dirtBombs':
            tex = factory.texDirt
            name = 'DirtBomb'
        elif powerupType == 'speed':
            tex = factory.texSpeed  # new powerups begin
        elif powerupType == 'alan':
            tex = factory.texAlan
            name = 'Boss'
        elif powerupType == 'rdm':
            tex = factory.texRDM
            name = 'RandomBomb'
        elif powerupType == 'randomCharacter':
            tex = factory.RandomCharacter
            name = 'Random Char'
        elif powerupType == 'troll':
            tex = factory.Troll
            name = 'FunPack'
        elif powerupType == 'mj':
            tex = factory.texmj
            name = 'MJ'
        elif powerupType == 'impactMess':
            tex = factory.teximpactMess
            name = 'ImpactMess'
        elif powerupType == 'Motion':
            tex = factory.texMotion
            name = 'Motion'
        elif powerupType == 'invisibility':
            tex = factory.texInvisibility
            name = 'Invisibile'
        elif powerupType == 'hijump':
            tex = factory.texHiJump
            name = 'Hi-Jump'
        elif powerupType == 'ballon':
            tex = factory.texBallon
            name = 'Ballon'
        elif powerupType == 'BlockPowerup':
            tex = factory.texBlock
            name = 'Block'
        elif powerupType == 'iceImpact':
            tex = factory.texiceImpact
            name = 'IceImpact'
        elif powerupType == 'goldenBomb':
            tex = factory.texGoldenBomb
            name = 'BlastyBomb'
        elif powerupType == 'tbomb':
            tex = factory.textbomb
            name = 'TBomb'
        elif powerupType == 'gluebomb':
            tex = factory.texgluebomb
            name = 'Broken Glue'
        elif powerupType == 'weedbomb':
            tex = factory.texweedbomb
            name = 'WeedBomb'
        elif powerupType == 'bot':
            tex = factory.texBot
            name = 'Buddy Bot'
        elif powerupType == 'celebrate':
            tex = factory.texcelebrate
            name = 'Celebrate'
        elif powerupType == 'FloatingMine':
            tex = factory.texFloatingMine
            name = 'LandMines'
        elif powerupType == 'TouchMe':
            tex = factory.texTouchMe
            name = 'TouchMe'
        elif powerupType == 'radius':
            tex = factory.texRadius
            name = 'Radius'
        elif powerupType == 'sleep':
            tex = factory.texSleep
            name = 'Sleepy'
        elif powerupType == 'night':
            tex = factory.texNight
            name = 'NiteNite'
        elif powerupType == 'spazBomb':
            tex = factory.texSpazBomb
            name = 'SpazBomb'
        elif powerupType == 'curseBomb':
            tex = factory.texcurseBomb
            name = 'CurseBomb'
        elif powerupType == 'characterBomb':
            tex = factory.texcharacterBomb
            name = 'CharBomb'
        elif powerupType == 'mjBomb':
            tex = factory.texmjBomb
            name = 'MJBomb'
        elif powerupType == 'trioBomb':
            tex = factory.textrioBomb
            name = 'ImpactTrio'
        elif powerupType == 'speedBomb':
            tex = factory.texspeedBomb
            name = 'ShockWave'
        elif powerupType == 'healBomb':
            tex = factory.texhealBomb
            name = 'HealthBomb'
        elif powerupType == 'nightBomb':
            tex = factory.texNightBomb
            name = 'AtomBomb'
        elif powerupType == 'revengeBomb':
            tex = factory.texrevengeBomb
            name = 'RevengeBomb'
        elif powerupType == 'blastBomb':
            tex = factory.texblastBomb
            name = 'blastBomb'
        elif powerupType == 'knockBomb':
            tex = factory.texknockBomb
            name = 'KnockBomb'
        elif powerupType == 'stickyIce':
            tex = factory.texstickyIce
            name = 'StickyIce'
        elif powerupType == 'stickyIceTrio':
            tex = factory.texstickyIceTrio
            name = 'StickyIceTrio'
        elif powerupType == 'stickyIceMess':
            tex = factory.texstickyIceMess
            name = 'StickyIceMess'
        elif powerupType == 'stickyMess':
            tex = factory.texStickyMess
            name = 'StickyMess'
        elif powerupType == 'icyMess':
            tex = factory.texIcyMess
            name = 'IcyMess'
        elif powerupType == 'icyTrio':
            tex = factory.texicyTrio
            name = 'IcyTrio'
        elif powerupType == 'weee':
            tex = factory.texWeee
            name = 'Health'
        elif powerupType == 'tnt':
            tex = factory.texTnt
            name = 'TNT'
        elif powerupType == 'boomBomb':
            tex = factory.texboomBomb
            name = 'KaboomBomb'
        elif powerupType == 'name':
            tex = factory.texName
            name = 'NewName'
        elif powerupType == 'highlight':
            tex = factory.texHighlight
            name = 'HighLight'
        elif powerupType == 'spotlight':
            tex = factory.texSpotlight
            name = 'Spotlight'
        elif powerupType == 'jumpFly':
            tex = factory.texjumpFly
            name = 'FlyJump'
        elif powerupType == 'use':
            tex = factory.texuse
            name = 'FlyBomb'
        elif powerupType == "antiGrav":
            tex = factory.texAntiGrav
            name = 'AntiGrav'
        elif powerupType == "BlackHole":
            tex = factory.texBlackHole
            name = 'BlackHole'
        elif powerupType == "Slippery":
            tex = factory.texSlippery
            name = 'LuckyBlock'
        elif powerupType == "Box":
            tex = factory.texBox
            name = 'Box'
        elif powerupType == 'snoball':
            tex = factory.texSno
            mod = factory.snoModel
            name = "shieldBall"
        elif powerupType == 'pass':
            return
        else:
            raise Exception("invalid powerupType: " + str(powerupType))

        if len(position) != 3:
            raise Exception("expected 3 floats for position")

        if powerupType == 'poisonBombs':
            refScale = (0, 3, 0)
            ref = 'soft'
        elif powerupType == 'pandoraBox':
            ref = 'soft'
            refScale = (1, 1, 1)
        elif powerupType == 'dirtBombs':
            ref = 'soft'
            refScale = (1, 0.4, 0.16)
        else:
            refScale = [0.95]
            ref = 'powerup'
        self.node = bs.newNode('prop',
                               delegate=self,
                               attrs={
                                   'body':
                                   'box',
                                   'position':
                                   position,
                                   'model':
                                   factory.model,
                                   'lightModel':
                                   factory.modelSimple,
                                   'shadowSize':
                                   0.48,
                                   'colorTexture':
                                   tex,
                                   'reflection':
                                   ref,
                                   'reflectionScale':
                                   refScale,
                                   'materials':
                                   (factory.powerupMaterial,
                                    bs.getSharedObject('objectMaterial'))
                               })
        prefixAnim = {
            0: (1, 0, 0),
            250: (1, 1, 0),
            250 * 2: (0, 1, 0),
            250 * 3: (0, 1, 1),
            250 * 4: (1, 0, 1),
            250 * 5: (0, 0, 1),
            250 * 6: (1, 0, 0)
        }
        color = (0, 0, 1)

        if don.powerupName:
            m = bs.newNode('math',
                           owner=self.node,
                           attrs={
                               'input1': (0, 0.7, 0),
                               'operation': 'add'
                           })
            self.node.connectAttr('position', m, 'input2')
            self.nodeText = bs.newNode('text',
                                       owner=self.node,
                                       attrs={
                                           'text': str(name),
                                           'inWorld': True,
                                           'shadow': 1.0,
                                           'flatness': 1.0,
                                           'color': color,
                                           'scale': 0.0,
                                           'hAlign': 'center'
                                       })
            m.connectAttr('output', self.nodeText, 'position')
            bs.animate(self.nodeText, 'scale', {0: 0, 140: 0.016, 200: 0.01})
            bs.animateArray(
                self.nodeText, 'color', 3, {
                    0: (0, 0, 2),
                    500: (0, 2, 0),
                    1000: (2, 0, 0),
                    1500: (2, 2, 0),
                    2000: (2, 0, 2),
                    2500: (0, 1, 6),
                    3000: (1, 2, 0)
                }, True)
            bs.emitBGDynamics(position=self.nodeText.position,
                              velocity=self.node.position,
                              count=200,
                              scale=1.4,
                              spread=2.01,
                              chunkType='sweat')

        if don.shieldOnPowerUps:
            self.nodeShield = bs.newNode('shield',
                                         owner=self.node,
                                         attrs={
                                             'color':
                                             color,
                                             'position':
                                             (self.node.position[0],
                                              self.node.position[1],
                                              self.node.position[2] + 0.5),
                                             'radius':
                                             1.2
                                         })
            self.node.connectAttr('position', self.nodeShield, 'position')
            bsUtils.animateArray(self.nodeShield, 'color', 3, prefixAnim, True)

        if don.discoLights:
            self.nodeLight = bs.newNode('light',
                                        attrs={
                                            'position': self.node.position,
                                            'color': color,
                                            'radius': 0.2,
                                            'volumeIntensityScale': 0.5
                                        })
            self.node.connectAttr('position', self.nodeLight, 'position')
            bsUtils.animateArray(self.nodeLight, 'color', 3, prefixAnim, True)
            bs.animate(self.nodeLight,
                       "intensity", {
                           0: 1.0,
                           1000: 1.8,
                           2000: 1.0
                       },
                       loop=True)
            bs.gameTimer(8000, self.nodeLight.delete)

        if don.powerupTimer:
            self.powerupHurt = bs.newNode('shield',
                                          owner=self.node,
                                          attrs={
                                              'color': (1, 1, 1),
                                              'radius': 0.1,
                                              'hurt': 1,
                                              'alwaysShowHealthBar': True
                                          })
            self.node.connectAttr('position', self.powerupHurt, 'position')
            bs.animate(self.powerupHurt, 'hurt', {
                0: 0,
                defaultPowerupInterval - 1000: 1
            })
        bs.gameTimer(defaultPowerupInterval - 1000, bs.Call(self.do_delete))

        curve = bs.animate(self.node, "modelScale", {0: 0, 140: 1.6, 200: 1})
        bs.gameTimer(200, curve.delete)

        if expire:
            bs.gameTimer(defaultPowerupInterval - 2500,
                         bs.WeakCall(self._startFlashing))
            bs.gameTimer(defaultPowerupInterval - 1000,
                         bs.WeakCall(self.handleMessage, bs.DieMessage()))
def getDefaultPowerupDistribution(all=False):
    if gSettingsEnabled: settings = bs.get_settings()
    else: settings = {}
    powerups_all = {
        'tripleBombs': 3,
        'iceBombs': 3,
        'punch': 3,
        'impactBombs': 2,
        'shield': 2,
        'landMines': 2,
        'stickyBombs': 3,
        'health': 2,
        'curse': 1,
        'yellowShield': 1,
        'speedPunch': 1,
        'fireworkBombs': 2,
        'killLaKillBombs': 2,
        'jumpingBombs': 1,
        'tpBombs': 1,
        'poisonBombs': 0,  #does not work, am too lazy to fix it
        'pandoraBox': 1,
        'unbreakable': 1,
        'dirtBombs': 1,
        'speed': 1,  #new powerup start
        'alan': 2,
        'rdm': 2,
        'randomCharacter': 1,
        'troll': 2,
        'mj': 2,
        'impactMess': 2,
        'Motion': 2,
        'invisibility': 2,
        'hijump': 2,
        'ballon': 2,
        'BlockPowerup': 1,
        'iceImpact': 2,
        'goldenBomb': 2,
        'tbomb': 2,
        'weedbomb': 2,
        'gluebomb': 2,
        'bot': 2,
        'celebrate': 2,
        'FloatingMine': 2,
        'TouchMe': 2,
        'radius': 2,
        'sleep': 2,
        'night': 2,
        'spazBomb': 2,
        'curseBomb': 2,
        'healBomb': 2,
        'nightBomb': 2,
        'revengeBomb': 2,
        'blastBomb': 2,
        'knockBomb': 2,
        'speedBomb': 2,  #shockwave actually.
        'characterBomb': 2,
        'mjBomb': 2,
        'trioBomb': 2,
        'stickyIce': 2,
        'stickyIceTrio': 2,
        'stickyIceMess': 2,
        'stickyMess': 2,
        'icyMess': 2,
        'icyTrio': 2,
        'weee': 2,
        'tnt': 2,
        'use': 2,
        'name': 0,  #a bug so no enable
        'highlight': 2,
        'spotlight': 0,  #dont turn on xd
        'boomBomb': 2,
        'jumpFly': 2,
        'snoball': 2,
        'antiGrav': 2,
        'BlackHole': 2,
        'Box': 2,
        'Slippery': 2,
        'multiBombs': 1
    }
    exclude_powerups = settings.get("exclude_powerups", [])
    active_powerups = powerups_all.keys()
    if not all:
        if settings.get("disable_powerups", False): active_powerups = []
        elif len(exclude_powerups) > 0:
            active_powerups = [
                i for i in powerups_all if i not in exclude_powerups
            ]
    return tuple([(i) if i[0] in active_powerups else (i[0], 0)
                  for i in powerups_all.items()])
예제 #4
0
    def __init__(self,
                 position=(0, 1, 0),
                 powerupType='tripleBombs',
                 expire=True):

        bs.Actor.__init__(self)
        factory = self.getFactory()

        if gSettingsEnabled: settings = bs.get_settings()
        else: settings = {}

        self.powerupType = powerupType
        self._powersGiven = False
        if powerupType == 'tripleBombs': tex = factory.texBomb
        elif powerupType == 'multiBombs': tex = factory.texMultiBombs
        elif powerupType == 'punch': tex = factory.texPunch
        elif powerupType == 'speedPunch': tex = factory.texSpeedPunch
        elif powerupType == 'fireworkBombs': tex = factory.texFireworkBomb
        elif powerupType == 'killLaKillBombs': tex = factory.texKillLaKillBomb
        elif powerupType == 'poisonBombs': tex = factory.texPoisonBomb
        elif powerupType == 'pandoraBox': tex = factory.texPandoraBox
        elif powerupType == 'yellowShield': tex = factory.texYellowShield
        elif powerupType == 'jumpingBombs': tex = factory.texJumpingBomb
        elif powerupType == 'tpBombs': tex = factory.texTpBombs
        elif powerupType == 'iceBombs': tex = factory.texIceBombs
        elif powerupType == 'impactBombs': tex = factory.texImpactBombs
        elif powerupType == 'landMines': tex = factory.texLandMines
        elif powerupType == 'stickyBombs': tex = factory.texStickyBombs
        elif powerupType == 'shield': tex = factory.texShield
        elif powerupType == 'health': tex = factory.texHealth
        elif powerupType == 'curse': tex = factory.texCurse
        elif powerupType == 'unbreakable': tex = factory.texUnb
        elif powerupType == 'dirtBombs': tex = factory.texDirt
        elif powerupType == 'pass': return
        else: raise Exception("invalid powerupType: " + str(powerupType))

        if len(position) != 3:
            raise Exception("expected 3 floats for position")

        if powerupType == 'poisonBombs':
            refScale = (0, 3, 0)
            ref = 'soft'
        elif powerupType == 'pandoraBox':
            ref = 'soft'
            refScale = (1, 1, 1)
        elif powerupType == 'dirtBombs':
            ref = 'soft'
            refScale = (1, 0.4, 0.16)
        else:
            refScale = [0.95]
            ref = 'powerup'
        self.node = bs.newNode('prop',
                               delegate=self,
                               attrs={
                                   'body':
                                   'box',
                                   'position':
                                   position,
                                   'model':
                                   factory.model,
                                   'lightModel':
                                   factory.modelSimple,
                                   'shadowSize':
                                   0.48,
                                   'colorTexture':
                                   tex,
                                   'reflection':
                                   ref,
                                   'reflectionScale':
                                   refScale,
                                   'materials':
                                   (factory.powerupMaterial,
                                    bs.getSharedObject('objectMaterial'))
                               })
        if powerupType == 'pandoraBox':
            bsUtils.animateArray(self.node, 'reflectionScale', 3, {
                0: (1, 1, 1),
                1500: (5, 5, 5),
                3000: (-5, -5, -5),
                4500: (1, 1, 1)
            }, True)

        if settings.get("powerup_lighting", True):
            self.light = bs.newNode('light',
                                    owner=self.node,
                                    attrs={
                                        'position':
                                        position,
                                        'intensity':
                                        0,
                                        'radius':
                                        0,
                                        'color': (random.random() * 2.45,
                                                  random.random() * 2.45,
                                                  random.random() * 2.45)
                                    })
            self.node.connectAttr('position', self.light, 'position')
            bs.animate(self.light, "radius", {
                0: 0,
                140: 0.04,
                200: 0.09,
                400: 0.078
            })
            bs.animate(self.light,
                       "intensity", {
                           0: 1.0,
                           1000: 1.8,
                           2000: 1.0
                       },
                       loop=True)
            bsUtils.animateArray(
                self.light, "color", 3, {
                    0: (self.light.color[0], self.light.color[1],
                        self.light.color[2]),
                    1000:
                    (self.light.color[0] - 0.4, self.light.color[1] - 0.4,
                     self.light.color[2] - 0.4),
                    1500: (self.light.color[0], self.light.color[1],
                           self.light.color[2])
                }, True)

        if settings.get("timer_the_disappearance_of_the_powerup", True):
            self.powerupHurt = bs.newNode('shield',
                                          owner=self.node,
                                          attrs={
                                              'color': (1, 1, 1),
                                              'radius': 0.1,
                                              'hurt': 1,
                                              'alwaysShowHealthBar': True
                                          })
            self.node.connectAttr('position', self.powerupHurt, 'position')
            bs.animate(self.powerupHurt, 'hurt', {
                0: 0,
                defaultPowerupInterval - 1000: 1
            })
        bs.gameTimer(defaultPowerupInterval - 1000, bs.Call(self.do_delete))

        curve = bs.animate(self.node, "modelScale", {0: 0, 140: 1.6, 200: 1})
        bs.gameTimer(200, curve.delete)

        if expire:
            bs.gameTimer(defaultPowerupInterval - 2500,
                         bs.WeakCall(self._startFlashing))
            bs.gameTimer(defaultPowerupInterval - 1000,
                         bs.WeakCall(self.handleMessage, bs.DieMessage()))
예제 #5
0
    def __init__(self, position=(0,1,0), velocity=(0,0,0), bombType='normal',
                 blastRadius=2.0, sourcePlayer=None, owner=None):
        bs.Actor.__init__(self)

        factory = self.getFactory()

        settings = bs.get_settings()

        if not bombType in ('ice','impact','landMine','normal','sticky','tnt', 'firework', 'killLaKill', 'qq', 'tp', 'poison', 'dirt'):
            raise Exception("invalid bomb type: " + bombType)
        self.bombType = bombType
        self._exploded = False

        if self.bombType == 'sticky': self._lastStickySoundTime = 0

        self.blastRadius = blastRadius
        if self.bombType == 'ice': self.blastRadius *= 1.2
        elif self.bombType == 'qq': self.blastRadius *= 0.9
        elif self.bombType == 'firework': self.blastRadius *= 1.75
        elif self.bombType == 'impact': self.blastRadius *= 0.7
        elif self.bombType == 'killLaKill': self.blastRadius *= 0.945
        elif self.bombType == 'landMine': self.blastRadius *= 0.7
        elif self.bombType == 'tnt': self.blastRadius *= 1.45
        elif self.bombType == 'poison': self.blastRadius *= 1.2

        self._explodeCallbacks = []
        
        # the player this came from
        self.sourcePlayer = sourcePlayer

        # by default our hit type/subtype is our own, but we pick up types of
        # whoever sets us off so we know what caused a chain reaction
        self.hitType = 'explosion'
        self.hitSubType = self.bombType

        # if no owner was provided, use an unconnected node ref
        if owner is None: owner = bs.Node(None)

        # the node this came from
        self.owner = owner

        # adding footing-materials to things can screw up jumping and flying
        # since players carrying those things
        # and thus touching footing objects will think they're on solid ground..
        # perhaps we don't wanna add this even in the tnt case?..
        if self.bombType == 'tnt':
            materials = (factory.bombMaterial,
                         bs.getSharedObject('footingMaterial'),
                         bs.getSharedObject('objectMaterial'))
        else:
            materials = (factory.bombMaterial,
                         bs.getSharedObject('objectMaterial'))
            
        if self.bombType == 'impact':
            materials = materials + (factory.impactBlastMaterial,)
        elif self.bombType == 'qq':
            materials = materials + (factory.impactBlastMaterial,)
        elif self.bombType == 'landMine':
            materials = materials + (factory.landMineNoExplodeMaterial,)

        if self.bombType == 'sticky':
            materials = materials + (factory.stickyMaterial,)
        elif self.bombType not in ['dirt']:
            materials = materials + (factory.normalSoundMaterial,)

        if self.bombType == 'landMine':
            self.node = bs.newNode('prop', delegate=self, attrs={
                'position':position,
                'velocity':velocity,
                'model':factory.landMineModel,
                'lightModel':factory.landMineModel,
                'body':'landMine',
                'shadowSize':0.44,
                'colorTexture':factory.landMineTex,
                'reflection':'powerup',
                'reflectionScale':[1.0],
                'materials':materials})

        elif self.bombType == 'tnt':
            self.node = bs.newNode('prop', delegate=self, attrs={
                'position':position,
                'velocity':velocity,
                'model':factory.tntModel,
                'lightModel':factory.tntModel,
                'body':'crate',
                'shadowSize':0.5,
                'colorTexture':factory.tntTex,
                'reflection':'soft',
                'reflectionScale':[0.23],
                'materials':materials})
            
        elif self.bombType == 'impact':
            fuseTime = 20000
            self.node = bs.newNode('prop', delegate=self, attrs={
                'position':position,
                'velocity':velocity,
                'body':'sphere',
                'model':factory.impactBombModel,
                'shadowSize':0.3,
                'colorTexture':factory.impactTex,
                'reflection':'powerup',
                'reflectionScale':[1.5],
                'materials':materials})
            self.armTimer = bs.Timer(200, bs.WeakCall(self.handleMessage,
                                                      ArmMessage()))
            self.warnTimer = bs.Timer(fuseTime-1700,
                                      bs.WeakCall(self.handleMessage,
                                                  WarnMessage()))

        elif self.bombType == 'dirt':
            fuseTime = 4500
            self.node = bs.newNode('bomb', delegate=self, attrs={
                'position':position,
                'velocity':velocity,
                'body':'sphere',
                'model':factory.stickyBombModel,
                'shadowSize':0.3,
                'colorTexture':factory.poisonTex,
                'reflection':'soft',
                'reflectionScale':(1, 0.4, 0.16),
                'materials':materials})
            sound = bs.newNode('sound', owner=self.node, attrs={
                'sound':factory.fuseSound,
                'volume':0.25})
            self.node.connectAttr('position', sound, 'position')
            bsUtils.animate(self.node, 'fuseLength', {0:1.0, fuseTime:0.0})
            
        elif self.bombType == 'firework':
            fuseTime = 4500
            self.node = bs.newNode('prop', delegate=self, attrs={
                'position':position,
                'velocity':velocity,
                'body':'crate',
                'bodyScale':0.9,
                'model':factory.fireworkModel,
                'shadowSize':0.3,
                'colorTexture':factory.fireworkTex,
                'reflection':'soft',
                'reflectionScale':[0.23],
                'materials':materials})

        elif self.bombType == 'killLaKill':
            fuseTime = 3000
            self.node = bs.newNode('bomb', delegate=self, attrs={
                'position':position,
                'velocity':velocity,
                'body':'sphere',
                'model':factory.killLaKillModel,
                'shadowSize':0.3,
                'colorTexture':factory.killLaKillTex,
                'reflection':'sharper',
                'reflectionScale':[1.8],
                'materials':materials})
            sound = bs.newNode('sound', owner=self.node, attrs={
                'sound':factory.fuseSound,
                'volume':0.25})
            self.node.connectAttr('position', sound, 'position')
            bsUtils.animate(self.node, 'fuseLength', {0:1.0, fuseTime:0.0})

        elif self.bombType == 'poison':
            fuseTime = 4500
            self.node = bs.newNode('bomb', delegate=self, attrs={
                'position':position,
                'velocity':velocity,
                'body':'sphere',
                'model':factory.poisonModel,
                'shadowSize':0.3,
                'colorTexture':factory.poisonTex,
                'reflection':'soft',
                'reflectionScale':(1,1.5,1),
                'materials':materials})
            sound = bs.newNode('sound', owner=self.node, attrs={
                'sound':factory.fuseSound,
                'volume':0.25})
            self.node.connectAttr('position', sound, 'position')
            bsUtils.animate(self.node, 'fuseLength', {0:1.0, fuseTime:0.0})
              
        elif self.bombType == 'tp':
            fuseTime = 3000
            self.node = bs.newNode('bomb', delegate=self, attrs={
                'position':position,
                'velocity':velocity,
                'body':'sphere',
                'model':factory.tpModel,
                'shadowSize':0.3,
                'colorTexture':factory.tpTex,
                'reflection':'sharper',
                'reflectionScale':(0,1.8,0.68),
                'materials':materials})
            sound = bs.newNode('sound', owner=self.node, attrs={
                'sound':factory.fuseSound,
                'volume':0.25})
            self.node.connectAttr('position', sound, 'position')
            bsUtils.animate(self.node, 'fuseLength', {0:1.0, fuseTime:0.0})

        elif self.bombType == 'qq':
            fuseTime = 4500
            self.node = bs.newNode('bomb', delegate=self, attrs={
                'position':position,
                'velocity':velocity,
                'body':'sphere',
                'bodyScale':0.775,
                'density':1.772,
                'model':factory.qqModel,
                'shadowSize':0.3,
                'colorTexture':factory.qqTex,
                'owner':owner,
                'reflection':'sharper',
                'reflectionScale':[1.2],
                'materials':materials})
            sound = bs.newNode('sound', owner=self.node, attrs={
                'sound':factory.fuseSound,
                'volume':0.25})
            self.node.connectAttr('position', sound, 'position')
            bsUtils.animate(self.node, 'fuseLength', {0:1.0, fuseTime:0.0})
            bs.gameTimer(4320, bs.WeakCall(self.handleMessage, bs.DieMessage()))
            bs.gameTimer(4319, bs.Call(self.explode))
        else:
            fuseTime = 3000
            if self.bombType == 'sticky':
                sticky = True
                model = factory.stickyBombModel
                rType = 'sharper'
                rScale = 1.8
            else:
                sticky = False
                model = factory.bombModel
                rType = 'sharper'
                rScale = 1.8
            if self.bombType == 'ice': tex = factory.iceTex
            elif self.bombType == 'sticky': tex = factory.stickyTex
            else: tex = factory.regularTex
            self.node = bs.newNode('bomb', delegate=self, attrs={
                'position':position,
                'velocity':velocity,
                'model':model,
                'shadowSize':0.3,
                'colorTexture':tex,
                'sticky':sticky,
                'owner':owner,
                'reflection':rType,
                'reflectionScale':[rScale],
                'materials':materials})

            sound = bs.newNode('sound', owner=self.node, attrs={
                'sound':factory.fuseSound,
                'volume':0.25})
            self.node.connectAttr('position', sound, 'position')
            bsUtils.animate(self.node, 'fuseLength', {0:1.0, fuseTime:0.0})

        # light the fuse!!!
        if (self.bombType not in ('landMine','tnt')):
            bs.gameTimer(fuseTime, bs.WeakCall(self.handleMessage, ExplodeMessage()))
            if settings.get("timer_before_the_bomb_explode", True):
                m = bs.newNode('math', attrs={'input1': (0, 0.45, 0), 'operation': 'add'})
                self.node.connectAttr('position', m, 'input2')
                self._timer = bs.newNode('text', owner=self.node, attrs={
                    'text': '( )',
                    'position': (0, 0, 0),
                    'color': (0,3,0),
                    'scale': 0,
                    'inWorld': True,
                    'hAlign': 'center'})
                m.connectAttr('output', self._timer, 'position')        
                bsUtils.animate(self._timer, 'scale', {0: 0.0, 240: 0.009})
                bsUtils.animateArray(self._timer, 'color',3, {0: (0,3,0), fuseTime: (3,0,0)}, False)
        if self.bombType == 'firework': bsUtils.animate(self.node,"modelScale",{0:0, 200:0.85, 260:0.8})
        else: bsUtils.animate(self.node,"modelScale",{0:0, 200:1.3, 260:1})
예제 #6
0
def __init__(self,
             color=(1, 1, 1),
             highlight=(0.5, 0.5, 0.5),
             character="Spaz",
             player=None,
             powerupsExpire=True):
    a = bsInternal._getForegroundHostActivity()
    if player is None: player = bs.Player(None)
    if gSettingsEnabled: settings = bs.get_settings()
    else: settings = {}
    if a is not None:
        with bs.Context(a):
            account = player.getInputDevice()._getAccountName(True)
            skin = settings.get("skins", {}).get(account, None)
            if skin is not None:
                character_name = get_unformat_skin_name(skin)
                if character_name is not None and character_name in bsSpaz.appearances.keys(
                ):
                    character = character_name
    bsSpaz.Spaz.__init__(self,
                         color=color,
                         highlight=highlight,
                         character=character,
                         sourcePlayer=player,
                         startInvincible=True,
                         powerupsExpire=powerupsExpire)
    self.lastPlayerAttackedBy = None
    self.lastAttackedTime = 0
    self.lastAttackedType = None
    self.heldCount = 0
    self.lastPlayerHeldBy = None
    self._player = player
    if skin not in ["invincible"]:
        prefixes = settings.get("prefixes", {})
        vips, admins, hosts = settings.get("vips", []), settings.get(
            "admins", []), settings.get("hosts", [])
        profiles = self._player.getInputDevice()._getPlayerProfiles()
        if profiles == [] or profiles == {}:
            profiles = bs.getConfig()['Player Profiles']
        if prefixes.get(account) is not None:
            prefix_info = prefixes[account]
            if isinstance(prefix_info, list):
                prefix_info = {prefix_info[0]: prefix_info[1]}
            PermissionEffect(owner=self.node,
                             prefix=prefix_info.values()[0],
                             prefixAnim={
                                 0: self.node.color,
                                 5000: self.node.highlight,
                                 10000: self.node.color
                             },
                             type=prefix_info.keys()[0])
        elif settings.get("admins_prefix", True):
            if account in vips or account in admins or account in hosts:
                anim = {0: (0, 1, 1), 2500: (1, 0, 1), 5000: (0, 1, 1)}
                if account in hosts: prefix = 'Host'
                elif account in admins: prefix = 'Admin'
                elif account in vips:
                    prefix, anim = 'VIP', {
                        0: (1, 1, 0),
                        2500: (1, 0.75, 0),
                        5000: (1, 1, 0)
                    }
                PermissionEffect(owner=self.node,
                                 prefix=prefix,
                                 prefixAnim=anim)
    if player.exists():
        playerNode = bs.getActivity()._getPlayerNode(player)
        self.node.connectAttr('torsoPosition', playerNode, 'position')
        check_skin(account, self.node)
예제 #7
0
    def opt(self, clientID=None, msg=""):
        global gEvent, admins, vips, settings
        global banned, prefixes
        if gSettingsEnabled: 
            settings = bs.get_settings()
            admins, vips, banned, prefixes = settings.get("admins", []), settings.get("vips", []), \
                settings.get("banned", []), settings.get("prefixes", {})
        a = bsInternal._getForegroundHostActivity()
        roster = bsInternal._getGameRoster()
        if gEvent is None: gEvent = bsInternal._getAccountMiscReadVal('easter', False)
        def format_message(msg=''):
            msg = msg.replace("/", "")
            mg = msg.split(" ")
            command = mg[0].lower()
            if len(mg) > 1: 
                arg = mg[1:]
                for i in range(len(arg)):
                    key = arg[i]
                    c = is_account(key, True)
                    if c is not None: arg[i] = c
                    else: arg[i] = key.lower()
            else: arg = []
            if self.player is not None and self.player.exists() and command in ['s', 'summon'] and hasattr(self.player.actor.node, 'position'):
                if ('~' in arg) or ('^' in arg):
                    rng = (2, 5)
                    if len(arg) > 0:
                        if arg[0] in ['f','flag']: rng = (1, 4)
                    for i in range(rng[0], rng[1]):
                        if len(arg) > i and arg[i] in ["~", "^"]: arg[i] = self.player.actor.node.position[i-rng[0]]
            return msg, command, arg
        def check_player():
            global admins
            self.is_vip = self.is_admin = self.is_host = False
            self.player = None
            host = get_account_string(arg=bsInternal._getAccountDisplayString(True))
            if gSettingsEnabled:
                hosts = bs.get_setting("hosts", [])
                if host not in hosts: 
                    hosts.append(host)
                    bs.set_setting("hosts", hosts)
            else: hosts = []
            if len(roster) > 0:
                account = None
                for i in roster: 
                    if i['clientID'] == clientID: 
                        account = i['displayString'].decode('utf-8')
                        break
                if account is not None:
                    if account in vips: self.is_vip = True
                    if account in admins: self.is_vip = self.is_admin = True
                    if account == host or (account != host and account in hosts): self.is_host = self.is_admin = self.is_vip = True
                    for i in a.players:
                        if i.exists():
                            id = i.getInputDevice().getClientID()
                            if id == clientID: self.player = i
            else:
                self.is_host = self.is_admin = self.is_vip = True
                if len(a.players) > 0: self.player = a.players[0]
        check_player()
        msg, command, arg = format_message(msg=msg)
        if a is not None:
            with bs.Context(a):
                if command in ["h", "help"] and self.is_vip:
                    commands, num = {1: []}, 1
                    def add_commands(cmds=[], commands={1: []}, num=1):
                        for i in cmds:
                            if len(commands[num]) < 30: commands[num].append(i)
                            else:
                                num += 1
                                commands[num] = []
                                commands[num].append(i)
                        return commands, num
                    commands, num = add_commands(["help - помощь", "time - установить время", \
                        "skin - изменить облик", "kick - выгнать из игры", \
                        "end - закончить игру", "sm - замедленный режим игры", \
                        "rise - возродить", "frozen - заморозить", "shatter - разделить на части"], 
                        commands=commands, num=num)
                    if self.is_admin: 
                        commands, num = add_commands(['summon - вызвать объект', 'vip - выдать права vip-пользователя', \
                            'punch - сила удара', 'hitpoints - очки жизни', 'prefix - выдать префикс', \
                            'ban - забанить', 'mp - максимальное кол-во игроков', \
                            'pause - остановить/продолжить игру', \
                            'sleep - усыпить', 'head - ребят я черешня', \
                            'nodes - список всех типов объектов на карте', 'connect - а это че', \
                            'curse - проклятие'], commands=commands, num=num)
                    if gEvent:
                        commands, num = add_commands(['flex - хайпово флексить'], commands=commands, num=num)
                        if self.is_admin:
                            commands, num = add_commands(['dance - станцевать брейк', 'dance2 - станцевать лезгинку', 'party - устроить вечеринку'], commands=commands, num=num)
                    if self.is_host:
                        commands, num = add_commands(['default - отобрать права пользователя', \
                            'admin - выдать права администратора'], commands=commands, num=num)
                    commands, num = add_commands(['help [номер страницы] - следующий список команд', \
                        'команды могут выполняться через спец-символ ;', 'pause;/pause(перед каждой командой /)'], commands=commands, num=num)
                    num = 1
                    if len(arg) > 0 and bigger_than_zero(arg[0]): num=int(arg[0])
                    commands = commands.get(num, [])
                    for i in commands: send_message(i)

                elif command in ["l", "list"] and self.is_vip:
                    if len(roster) > 0:
                        players = []
                        for i in [[c["id"] for c in k["players"]] for k in roster]:
                            for d in i: players.append(d)
                        players.sort()
                        for i in roster:
                            data = [(", ").join([r["nameFull"] for r in i["players"]]) if len(i["players"]) > 0 else " - ", (", ").join([str(players.index(r)) for r in [c["id"] for c in i["players"]]]) if len(i["players"]) > 0 else " - "]
                            bsInternal._chatMessage(i["displayString"] + " : "+ data[0] + " : " + data[1])
                    else:
                        if len(a.players) > 0:
                            for i in a.players:
                                bsInternal._chatMessage(i.getInputDevice().getPlayer().getName(True) + " : " + str(a.players.index(i)))
                        else: send_message(" - ")

                elif command in ['timeset', 'time'] and self.is_vip:
                    if len(arg) > 0:
                        tint = get_tint()
                        self.time.update({"normal": get_normal_tint()})
                        for i in self.time:
                            if arg[0] == i:
                                bs.getSharedObject("globals").tint = tint = self.time[i]
                                break
                        if arg[0] == 'cycle': bs.getSharedObject('globals').tint = tint = get_normal_tint()
                        set_tint(tint=tint)
                    else:
                        for i in ['time [normal|sunrise|day|noon|sunset|night|cycle]', \
                            'timeset cycle - дневной цикл(плавная смена времени)', \
                            'timeset noon - середина дня', 'timeset sunset - закат']: send_message(i)
    
                elif command in ['summon','s'] and self.is_admin:
                    if len(arg) > 0:
                        if arg[0] in ['bomb','b']:
                            if len(arg) > 1:
                                bombs = [i.lower() for i in gBombs]
                                bombType, pos, count = 'normal', [0, 5, 0], 1
                                bombType = gBombs[bombs.index(arg[1].lower())] if arg[1].lower() in bombs else 'normal'
                                if len(arg) > 5: count = min(30, int(arg[5])) if bigger_than_zero(arg[5]) else 1
                                for i in range(2, 5):
                                    if len(arg) > i and is_num(arg[i]): pos[i-2] = float(arg[i])
                                for i in range(count):
                                    bs.Bomb(position=tuple(pos), bombType=bombType).autoRetain()
                            else:
                                mg = bs.text_split(words=gBombs)
                                mg += "s bomb [название] [позиция(3 числа)] [кол-во]\ns bomb normal 0 5 0 1"
                                for i in mg.split('\n'): send_message(i)
                        elif arg[0] in ['bot']:
                            if len(arg) > 1:
                                bots = [i.lower() for i in gBots]
                                botType, pos, count = 'BomberBot', [0, 5, 0], 1
                                botType = gBots[bots.index(arg[1].lower())] if arg[1].lower() in bots else 'BomberBot'
                                if len(arg) > 5: count = min(30, int(arg[5])) if bigger_than_zero(arg[5]) else 1
                                for i in range(2, 5):
                                    if len(arg) > i and is_num(arg[i]): pos[i-2] = float(arg[i])
                                if hasattr(bsSpaz, botType):
                                    bot = eval("bsSpaz."+botType)
                                    if not hasattr(self, "_bots") or (hasattr(self, "_bots") and self._bots is None): self._bots = bs.BotSet()
                                    for i in range(count):
                                        self._bots.spawnBot(bot, pos=tuple(pos), spawnTime=0, onSpawnCall=self._on_spawn)
                            else:
                                mg = bs.text_split(words=gBots, words_count=3)
                                mg += "s bot [название] [позиция(3 числа)] [кол-во]\ns bot BomberBot 0 5 0 1"
                                for i in mg.split('\n'): send_message(i)
                        elif arg[0] in ['flag','f']:
                            if len(arg) > 1:
                                pos, count, time_out, color = [0, 5, 0], 1, 20, [1, 1, 0]
                                if len(arg) > 4: count = min(30, int(arg[4])) if bigger_than_zero(arg[4]) else 1
                                if len(arg) > 5: time_out = int(arg[5]) if bigger_than_zero(arg[5]) else 20
                                for i in range(1, 4):
                                    if len(arg) > i and is_num(arg[i]): pos[i-1] = float(arg[i])
                                for i in range(6, 9):
                                    if len(arg) > i and is_num(arg[i]): color[i-6] = float(arg[i])
                                for i in range(count):
                                    bs.Flag(position=tuple(pos), droppedTimeout=time_out, color=color).autoRetain()
                            else:
                                for i in ["s flag [позиция(3 числа)] [кол-во] [тайм-аут] [цвет(3 числа)]", \
                                    "s flag 0 5 0", "s flag ~ ~ ~ 10 999 1 0 0"]: send_message(i)
                        elif arg[0] in ['powerup','p']:
                            if len(arg) > 1:
                                powerups = [i.lower() for i in gPowerups]
                                powerupType, pos, count = 'punch', [0, 5, 0], 1
                                powerupType = gPowerups[powerups.index(arg[1].lower())] if arg[1].lower() in powerups else 'punch'
                                if len(arg) > 5: count = min(30, int(arg[5])) if bigger_than_zero(arg[5]) else 1
                                for i in range(2, 5):
                                    if len(arg) > i and is_num(arg[i]): pos[i-2] = float(arg[i])
                                for i in range(count):
                                    bs.Powerup(position=tuple(pos),powerupType=powerupType).autoRetain()
                            else:
                                mg = bs.text_split(words=gPowerups)
                                mg += "s p [название] [позиция(3 числа)] [кол-во]\ns p punch 0 5 0 1"
                                for i in mg.split('\n'): send_message(i)
                        elif arg[0] in ['box']:
                            if len(arg) > 1:
                                boxTypes = ['s','small','big','b']
                                boxType, pos, count = 'small', [0, 5, 0], 1
                                boxType = arg[1].lower() if arg[1].lower() in boxTypes else 'small'
                                if len(arg) > 5: count = min(30, int(arg[5])) if bigger_than_zero(arg[5]) else 1
                                for i in range(2, 5):
                                    if len(arg) > i and is_num(arg[i]): pos[i-2] = float(arg[i])
                                for i in range(count):
                                    Box(pos=tuple(pos), scale=1 if boxType in ["s","small"] else 1.38, owner=None).autoRetain()
                            else:
                                for i in ["s box [small|big] [позиция] [кол-во]", \
                                    "s box small 0 5 0", "s box big ~ ~ ~ 5"]: send_message(i)
                    else:
                        for i in ["summon [bomb|powerup|bot|box|flag]", "bomb - вызвать бомбу.", "powerup - вызвать усилитель.", "bot - вызвать бота.", "box - вызвать коробку."]: send_message(i)

                elif command in ['skin'] and self.is_vip:
                    if len(arg) > 0:
                        if len(arg) < 2: arg.append(get_account_string(self.player))
                        if arg[0] in gSkins or arg[0] == 'delete':
                            account = is_account(arg[1], True)
                            if arg[1] == "all": 
                                if arg[0] == 'delete':
                                    for i in a.players: skins.delete_skin(i)
                                else: skins.change_skin(skin=arg[0], players=[a.players])
                            elif account is not None: 
                                if arg[0] == 'delete': skins.delete_skin(account)
                                else: skins.change_skin(skin=arg[0], players=[account])
                            elif is_num(arg[1]):
                                if len(a.players) > int(arg[1]) and int(arg[1]) >= 0: 
                                    if arg[0] == 'delete': skins.delete_skin(int(arg[1]))
                                    else: skins.change_skin(skin=arg[0], players=[int(arg[1])])
                            
                    else:
                        mg = bs.text_split(words=gSkins)
                        mg += "skin [название] [номер игрока]\nskin bunny 0\nskin pixie"
                        for i in mg.split('\n'): send_message(i)

                elif command in ['ph','punch','hp','hitpoints'] and self.is_admin:
                    if len(arg) > 0 and len(a.players) > 0:
                        if len(arg) < 2: player = [self.player]
                        if len(arg) > 1:
                            if is_num(arg[1]) and len(a.players) > int(arg[1]) and int(arg[1]) >= 0: player = [a.players[int(arg[1])]]
                            elif arg[1] == "all": player = a.players
                        if player is not None:
                            if bigger_than_zero(arg[0]):
                                arg[0] = int(arg[0])
                                if command in ["punch", "ph"] and arg[0] > 10: arg[0] = 10
                                for i in player:
                                    if i.exists():
                                        if command in ["punch", "ph"]: i.actor._punchPowerScale = arg[0]
                                        else: i.actor.hitPointsMax = i.actor.hitPoints = arg[0]
                    else:
                        for i in [command+" [число] [номер игрока | all]", \
                            command+" 1000 0", command+" 10 all"]: send_message(i)
    
                elif (command in ['vip'] and self.is_admin) or (command in ['admin'] and self.is_host):
                    if len(arg) > 0: self.add_admin(True if command == "admin" else False, get_account_string(arg[0]))
                    else:
                        for i in [command+" [номер игрока|имя аккаунта]", \
                            command+" 0", command+u" \ue030PC123456"]: send_message(i)
                        
                elif command in ['df','default'] and self.is_host:
                    if len(arg) > 0: self.del_admin(get_account_string(arg[0]))
                    else:
                        for i in [command+" [номер игрока|имя аккаунта]", \
                            command+" 0", command+u" \ue030PC123456"]: send_message(i)

                elif command in ['prefix'] and self.is_admin:
                    global prefixes
                    if len(arg) > 0:
                        type = arg[1] if len(arg) > 1 else "spark"
                        prefix = "prefix" if len(arg) < 3 else (" ").join(msg.split(" ")[3:])
                        if arg[0] == 'delete' and len(arg) > 1: account = get_account_string(arg[1])
                        elif arg[0] != 'delete': account = get_account_string(arg[0])
                        else: account = None
                        if arg[0] == 'delete': 
                            if account is not None and account in prefixes:
                                prefixes.pop(account)
                                if gSettingsEnabled: bs.set_setting("prefixes", prefixes)
                        else: self.set_prefix(account=account, prefix=prefix, type=type)
                    else:
                        for i in ["prefix [номер игрока | имя аккаунта] [slime|ice|spark|rock|metal] [префикс]", \
                            "prefix 0 spark клоун сбежал"]: send_message(i)

                elif command in ['kick'] and self.is_vip:
                    if len(arg) > 0:
                        account = get_account_string(arg[0])
                        if account is not None and len(roster) > 0:
                            id = None
                            for i in roster:
                                if i['displayString'].decode('utf-8') == account:
                                    id = i['clientID']
                                    break
                            if id is not None: bsInternal._disconnectClient(id, 300)
                    else:
                        for i in [command+" [номер игрока|имя аккаунта]", \
                            command+" 0", command+u" \ue030PC123456"]: send_message(i)
    
                elif command in ['ban'] and self.is_admin:
                    if len(arg) > 0: self.ban(account=get_account_string(arg[0]))
                    else:
                        for i in [command+" [номер игрока|имя аккаунта]", \
                            command+" 0", command+u" \ue030PC123456"]: send_message(i)
                    
                elif command in ['end'] and self.is_vip:
                    if hasattr(a, "endGame"): a.endGame()
                    else: send_message("Сейчас это недоступно")
                                   
                elif command in ['party','pt'] and self.is_admin:
                    if hasattr(a, 'cameraFlash') and gEvent:
                        time = 1000
                        def run(time=1000):
                            color = tuple([random.randrange(1,2) for i in range(3)])
                            a.cameraFlash(duration=time, color=color)
                        if hasattr(a, "_partyFlash") and a._partyFlash is not None: 
                            a._partyFlash = None
                            a._cameraFlash = []
                        else: 
                            run(time=time)
                            a._partyFlash = bs.Timer(time, bs.Call(run, time), True)
                    else: send_message("Сейчас это недоступно")

                elif command in ['sm'] and self.is_vip:
                    bs.getSharedObject("globals").slowMotion = motion = bs.getSharedObject("globals").slowMotion == False
                    set_motion(motion=motion)
                    
                elif command in ['pause'] and self.is_admin:
                    bs.getSharedObject("globals").paused = bs.getSharedObject("globals").paused == False

                elif command in ['max_players', 'mp'] and self.is_admin:
                    if bigger_than_zero(arg[0]): bsInternal._setPublicPartyMaxSize(int(arg[0]))
                    else:
                        for i in ["mp [кол-во игроков]", "mp 8", "максимальное кол-во игроков сейчас: "+str(bsInternal._getPublicPartyMaxSize())]: send_message(i)
                        
                elif command in ['shatter', 'sh'] and self.is_vip:
                    if len(arg) > 0:
                        def shatter(player=None, shatterMultiple=1): 
                            if player is not None and player.exists() and player.isAlive():
                                player.actor.node.shattered = shatterMultiple
                                player.actor.shattered = True if shatterMultiple > 0 else False
                        if bigger_than_zero(arg[0]):
                            if len(arg) > 1:
                                if is_num(arg[1]) and int(arg[1]) < len(a.players): shatter(a.players[int(arg[1])], int(arg[0]))
                                elif arg[1] == "all":
                                    for i in a.players: shatter(i, int(arg[0])) 
                            elif self.player is not None: shatter(self.player, int(arg[0]))
                    else: 
                        for i in [command+" [число] [номер игрока | all]", command+" 2 0", command+" 10"]: send_message(i)
                        
                elif command in ['frozen', 'fr'] and self.is_vip:
                    if len(arg) > 0:
                        def frozen(player=None):
                            if player is not None and player.exists() and player.isAlive():
                                player.actor.node.frozen = player.actor.node.frozen == 0
                                player.actor.frozen = player.actor.frozen == False
                        if is_num(arg[0]) and int(arg[0]) < len(a.players): frozen(a.players[int(arg[0])])
                        elif arg[0] == "all":
                            for i in a.players: frozen(i)
                        elif self.player is not None: frozen(self.player)
                    else:
                        for i in [command+" [номер игрока | all]", command+" 2", \
                            command+" me", "введи команду повторно, чтобы её отменить"]: send_message(i)
                        
                elif command in ['sleep','sl'] and self.is_admin:
                    if len(arg) > 0:
                        def sleep(player=None, sleepTime=5000):
                            def work(player=None, sleepTime=5000): 
                                if player is not None and player.exists() and player.isAlive():
                                    player.actor.node.handleMessage('knockout', sleepTime)
                                    if not hasattr(player.actor, 'sleepTime') or (hasattr(player.actor, 'sleepTime') and player.actor.sleepTime is None): 
                                        player.actor.sleepTime = sleepTime
                                    else: 
                                        player.actor.sleepTime -= 500
                                        if player.actor.sleepTime <= 0: 
                                            player.actor._sleep = player.actor.sleepTime = None
                            if player is not None and player.exists() and player.isAlive():
                                if sleepTime > 500:
                                    if hasattr(player.actor, '_sleep') and player.actor._sleep is not None: player.actor._sleep = None
                                    else: 
                                        player.actor._sleep = bs.Timer(500, bs.Call(work, player, sleepTime), repeat=True)
                                        work(player=player, sleepTime=sleepTime)
                                else: work(player=player, sleepTime=sleepTime)
                        if bigger_than_zero(arg[0]):
                            if len(arg) > 1:
                                if is_num(arg[1]) and int(arg[1]) < len(a.players): sleep(a.players[int(arg[1])], int(arg[0]))
                                elif arg[1] == "all":
                                    for i in a.players: sleep(i, int(arg[0]))
                            elif self.player is not None: sleep(self.player, int(arg[0]))
                    else:
                        for i in [command+" [число] [номер игрока | all]", command+" 2000 0", \
                            command+" 5000", "введи команду повторно, чтобы её отменить"]: send_message(i)
                    
                elif command in ['curse','cr'] and self.is_admin:
                    if len(arg) > 0:
                        def curse(player=None):
                            if player is not None and player.exists() and player.isAlive():
                                if hasattr(player.actor, 'curse'): player.actor.curse()
                        if is_num(arg[0]) and int(arg[0]) < len(a.players): curse(a.players[int(arg[0])])
                        elif arg[0] == "all":
                            for i in a.players: curse(i)
                        elif self.player is not None: curse(self.player)
                    else:
                        for i in [command+" [номер игрока | all]", command+" 2", command+" me"]: send_message(i)
                    
                elif command in ['nodes'] and self.is_admin:
                    if len(arg) > 0:
                        if arg[0] == 'types': nodes = list(set([i.getNodeType() for i in bsInternal.getNodes() if hasattr(i, "getNodeType")]))
                        if arg[0] == 'names': nodes = [i.getName() for i in bsInternal.getNodes() if hasattr(i, 'getName')]
                        if len(arg) > 1: nodes = [i for i in nodes if arg[1].lower() in i.lower()]
                        for i in bs.text_split(words=nodes, stroke_on_end=False).split('\n'): send_message(i)
                    else: 
                        for i in [command+' types spaz', command+' types', command+' names']: send_message(i)

                elif command in ['connect'] and self.is_admin:
                    def connect(node=None, connected_node=None, type='position'):
                        if node is not None and node.exists():
                            if connected_node is not None and connected_node.exists(): 
                                try: node.connectAttr(type, connected_node, type)
                                except: pass
                    if len(arg) > 0:
                        node = [i for i in bsInternal.getNodes() if hasattr(i, 'getName') and i.getName().lower() == arg[0].lower()]
                        if len(node) > 0: 
                            node = node[0]
                            if len(arg) < 3: arg[2] = 'position'
                            if is_num(arg[1]) and int(arg[1]) < len(a.players): 
                                player = a.players[int(arg[1])]
                                if player.exists(): connect(player.actor.node, node, arg[2])
                            elif arg[1] == "all":
                                for i in a.players: 
                                    if i.exists(): connect(i.actor.node, node, arg[2])
                            elif self.player is not None and self.player.exists(): connect(self.player.actor.node, node, arg[2])
                    else:
                        for i in [command+' [имя объекта (/nodes names)] [номер игрока | all] [тип присоединения]', \
                            command+' [email protected]:259 all position']: send_message(i)
                    
                        
                elif command in ['head'] and self.is_admin:
                    if len(arg) > 0:
                        def head(player=None):
                            if player is not None and player.exists() and player.isAlive():
                                player.actor.node.holdNode = player.actor.node
                        if is_num(arg[0]) and int(arg[0]) < len(a.players): head(a.players[int(arg[0])])
                        elif arg[0] == "all":
                            for i in a.players: head(i)
                        elif self.player is not None: head(self.player)
                    else:
                        for i in [command+" [номер игрока | all]", command+" 2", command+" me"]: send_message(i)

                elif command in ['rise', 'rs'] and self.is_vip:
                    if len(arg) > 0:
                        def respawn(player=None):
                            if player is not None and player.exists() and not player.isAlive():
                                player.gameData['respawnTimer'] = player.gameData['respawnIcon'] = None
                                with bs.Context(a): a.spawnPlayer(player=player)
                        if is_num(arg[0]) and int(arg[0]) < len(a.players): respawn(a.players[int(arg[0])])
                        elif arg[0] == "all":
                            for i in a.players: respawn(i)
                        elif self.player is not None: respawn(self.player)
                    else:
                        for i in [command+" [номер игрока | all]", command+" 2", command+" me"]: send_message(i)
                        
                elif command in ['flex','fl'] and self.is_vip:
                    if not gEvent:
                        send_message("Сейчас это недоступно")
                        return 
                    if len(arg) > 0:
                        def flex(actor=None):
                            def work(node=None):
                                if node is not None and node.exists(): node.handleMessage('celebrate', 1000)
                            if actor is not None and actor.exists():
                                if not hasattr(actor, '_flex') or (hasattr(actor, '_flex') and actor._flex is None):
                                    actor._flex = bs.Timer(1000, bs.Call(work, actor.node), repeat=True)
                                    work(node=actor.node)
                                else: actor._flex = None
                        if is_num(arg[0]) and int(arg[0]) < len(a.players): flex(a.players[int(arg[0])].actor)
                        elif arg[0] == 'all':
                            for i in find_players_and_bots(): flex(i)
                        elif self.player is not None and self.player.exists(): flex(self.player.actor)
                    else:
                        for i in [command+" [номер игрока|all]", command+" 0", command+" me", "введи команду повторно, чтобы её отменить"]: send_message(i)
                        
                elif command in ['dn', 'dance'] and self.is_admin:
                    if not gEvent:
                        send_message("Сейчас это недоступно")
                        return 
                    if len(arg) > 0:
                        def dance(actor=None):
                            def work(node=None):
                                if node is not None and node.exists():
                                    pos = (node.position[0], node.position[1] + 0.5, node.position[2])
                                    node.handleMessage("impulse", pos[0], pos[1], pos[2], 0, -2, 0, 2000, 0, 1, 0, 0, -2, 0)
                            if actor is not None and actor.exists(): 
                                if not hasattr(actor, '_dance') or (hasattr(actor, '_dance') and actor._dance is None):
                                    actor._dance = bs.Timer(100, bs.Call(work, actor.node), repeat=True)
                                    work(node=actor.node)
                                else: actor._dance = None
                        if is_num(arg[0]) and int(arg[0]) < len(a.players): dance(a.players[int(arg[0])].actor)
                        elif arg[0] == 'all':
                            for i in find_players_and_bots(): dance(i)
                        elif self.player is not None and self.player.exists(): dance(self.player.actor)
                    else:
                        for i in [command+" [номер игрока|all]", command+" 0", command+" me", "введи команду повторно, чтобы её отменить"]: send_message(i)
                        
                elif command in ['dn2', 'dance2'] and self.is_admin:
                    if not gEvent:
                        send_message("Сейчас это недоступно")
                        return 
                    if len(arg) > 0:
                        def dance2(actor=None):
                            def work(node=None):
                                if node is not None and node.exists():
                                    node.jumpPressed = True
                                    node.jumpPressed = False
                            if actor is not None and actor.exists(): 
                                if not hasattr(actor, '_dance2') or (hasattr(actor, '_dance2') and actor._dance2 is None):
                                    actor._dance2 = bs.Timer(500, bs.Call(work, actor.node), repeat=True)
                                    work(node=actor.node)
                                else: actor._dance2 = None
                        if is_num(arg[0]) and int(arg[0]) < len(a.players): dance2(a.players[int(arg[0])].actor)
                        elif arg[0] == 'all':
                            for i in find_players_and_bots(): dance2(i)
                        elif self.player is not None and self.player.exists(): dance2(self.player.actor)
                    else:
                        for i in [command+" [номер игрока|all]", command+" 0", command+" me", "введи команду повторно, чтобы её отменить"]: send_message(i)
예제 #8
0
gLang = bs.getLanguage()
gEvent = None

gSettingsEnabled = (hasattr(bs, "get_setting") and hasattr(bs, "set_setting"))

maps={"Doom Shroom":(0.82, 1.10, 1.15), "Hockey Stadium":(1.2,1.3,1.33), \
    "Football Stadium":(1.3, 1.2, 1.0), "Big G":(1.1, 1.2, 1.3), \
    "Roundabout":(1.0, 1.05, 1.1), "Monkey Face":(1.1, 1.2, 1.2), \
    "Bridgit":(1.1, 1.2, 1.3), "Zigzag":(1.0, 1.15, 1.15), \
    "The Pad":(1.1, 1.1, 1.0), "Lake Frigid":(1, 1, 1), \
    "Tip Top":(0.8, 0.9, 1.3), "Crag Castle":(1.15, 1.05, 0.75), \
    "Tower D":(1.15, 1.11, 1.03), "Happy Thoughts":(1.3, 1.23, 1.0), \
    "Step Right Up":(1.2, 1.1, 1.0), "Courtyard":(1.2, 1.17, 1.1), \
    "Rampage":(1.2, 1.1, 0.97)}

if gSettingsEnabled: settings = bs.get_settings()
else: settings = {}
admins, vips, banned, prefixes = settings.get("admins", []), settings.get("vips", []), \
    settings.get("banned", []), settings.get("prefixes", {})

motion_normal, map_tint, tint_normal = None, None, None

def get_normal_tint():
    global map_tint
    a=bsInternal._getForegroundHostActivity()
    if a is not None:
        if isinstance(a, bsMainMenu.MainMenuActivity): name = "The Pad"
        elif isinstance(a, bsTutorial.TutorialActivity): name = "Rampage"
        else: name = a.getMap().name if hasattr(a, "getMap") else None
        if name is not None and name in maps: map_tint = maps[name]
        else: