コード例 #1
0
def hegrenade_detonate(event_var):
    # Get the userid as int
    userid = int(event_var['userid'])

    # If the player is not on an active team, return
    if int(event_var['es_userteam']) < 2:
        return

    # If the player is not on hegrenade level, return
    if Player(userid).weapon != 'hegrenade':
        return

    # If the player is dead, return
    if getPlayer(userid).isdead:
        return

    # If there is a limit to the number of nades a player can get...
    if int(gg_multi_nade_max_nades) > 0:

        # Don't keep counting if the player has already hit the max
        if Player(userid).grenades_detonated < int(gg_multi_nade_max_nades):
            # Increment the player's grenades_detonated count
            Player(userid).grenades_detonated += 1

        # Find out if they exceeded the limit and break out if so
        if Player(userid).grenades_detonated >= int(gg_multi_nade_max_nades):
            return

    # Give the player a new hegrenade
    spe.giveNamedItem(userid, "weapon_hegrenade")
コード例 #2
0
def hegrenade_detonate(event_var):
    # Get the userid as int
    userid = int(event_var['userid'])

    # If the player is not on an active team, return
    if int(event_var['es_userteam']) < 2:
        return

    # If the player is not on hegrenade level, return
    if Player(userid).weapon != 'hegrenade':
        return

    # If the player is dead, return
    if getPlayer(userid).isdead:
        return

    # If there is a limit to the number of nades a player can get...
    if int(gg_multi_nade_max_nades) > 0:

        # Don't keep counting if the player has already hit the max
        if Player(userid).grenades_detonated < int(gg_multi_nade_max_nades):
            # Increment the player's grenades_detonated count
            Player(userid).grenades_detonated += 1

        # Find out if they exceeded the limit and break out if so
        if Player(userid).grenades_detonated >= int(gg_multi_nade_max_nades):
            return

    # Give the player a new hegrenade
    spe.giveNamedItem(userid, "weapon_hegrenade")
コード例 #3
0
def do_multi_level(userid):
    # Check userid validity
    if not es.exists('userid', userid):
        return

    # Retrieve the player's name
    name = es.getplayername(userid)

    # Tell everyone we leveled!
    centermsg('#all', "CenterMultiLevelled", {'name': name})
    saytext2('#all', Player(userid).index, 'MultiLevelled', {'name': name})

    # Play game sound
    sound = Player(userid).emitsound('multilevel')

    # Add the player to the multi-leveling dictionary with the sound to
    # remove
    currentMultiLevel[userid] = sound

    # Create env_spark
    spark_instance = spe.giveNamedItem(userid, "env_spark")
    spark_index = spe.getIndexOfEntity(spark_instance)

    cmd = 'es_xfire %s env_spark SetParent !activator;' % userid
    cmd += 'es_xfire %s env_spark AddOutput "spawnflags 896";' % userid
    cmd += 'es_xfire %s env_spark AddOutput "angles -90 0 0";' % userid
    cmd += 'es_xfire %s env_spark AddOutput "magnitude 8";' % userid
    cmd += 'es_xfire %s env_spark AddOutput "traillength 3";' % userid
    cmd += 'es_xfire %s env_spark StartSpark' % userid
    es.server.queuecmd(cmd)

    # Set the player's speed
    getPlayer(userid).speed = int(gg_multi_level_speed) / 100.0

    # If gg_multi_level_gravity is enabled, ajust the player's gravity
    if int(gg_multi_level_gravity) != 100 and int(gg_multi_level_gravity) >= 0:
        gravity.addGravityChange(userid, int(gg_multi_level_gravity) * 0.01)

    # Append the spark's index to this player's list
    if spark_index:
        Player(userid).multiLevelEntities.append(spark_index)

    # Set up the gg_multi_level event
    gg_multi_level_event = GG_Multi_Level(userid=userid, leveler=userid)

    # Fire the gg_multi_level event
    gg_multi_level_event.fire()
コード例 #4
0
def do_multi_level(userid):
    # Check userid validity
    if not es.exists('userid', userid):
        return

    # Retrieve the player's name
    name = es.getplayername(userid)

    # Tell everyone we leveled!
    centermsg('#all', "CenterMultiLevelled", {'name': name})
    saytext2('#all', Player(userid).index, 'MultiLevelled', {'name': name})

    # Play game sound
    sound = Player(userid).emitsound('multilevel')

    # Add the player to the multi-leveling dictionary with the sound to
    # remove
    currentMultiLevel[userid] = sound

    # Create env_spark
    spark_instance = spe.giveNamedItem(userid, "env_spark")
    spark_index = spe.getIndexOfEntity(spark_instance)

    cmd = 'es_xfire %s env_spark SetParent !activator;' % userid
    cmd += 'es_xfire %s env_spark AddOutput "spawnflags 896";' % userid
    cmd += 'es_xfire %s env_spark AddOutput "angles -90 0 0";' % userid
    cmd += 'es_xfire %s env_spark AddOutput "magnitude 8";' % userid
    cmd += 'es_xfire %s env_spark AddOutput "traillength 3";' % userid
    cmd += 'es_xfire %s env_spark StartSpark' % userid
    es.server.queuecmd(cmd)

    # Set the player's speed
    getPlayer(userid).speed = int(gg_multi_level_speed) / 100.0

    # If gg_multi_level_gravity is enabled, ajust the player's gravity
    if int(gg_multi_level_gravity) != 100 and int(gg_multi_level_gravity) >= 0:
        gravity.addGravityChange(userid, int(gg_multi_level_gravity) * 0.01)

    # Append the spark's index to this player's list
    if spark_index:
        Player(userid).multiLevelEntities.append(spark_index)

    # Set up the gg_multi_level event
    gg_multi_level_event = GG_Multi_Level(userid=userid, leveler=userid)

    # Fire the gg_multi_level event
    gg_multi_level_event.fire()
コード例 #5
0
def loadRandomPoints(userid):
    # Remove existing spawnpoints
    for tSpawn in es.getEntityIndexes('info_player_terrorist'):
        es.server.cmd('es_xremove %s' % tSpawn)
    for ctSpawn in es.getEntityIndexes('info_player_counterterrorist'):
        es.server.cmd('es_xremove %s' % ctSpawn)

    # Loop through the spawnpoints
    for spawn in spawnPoints:
        for team in ('info_player_terrorist', 'info_player_counterterrorist'):
            # Create the spawnpoint and get the index
            index = spe.getIndexOfEntity(spe.giveNamedItem(userid, team))

            # Set the spawnpoint position and rotation
            es.setindexprop(index, 'CBaseEntity.m_vecOrigin',
                '%s,%s,%s' % (spawn[0], spawn[1], spawn[2]))
            es.setindexprop(index, 'CBaseEntity.m_angRotation',
                '0,%s,0' % spawn[4])
コード例 #6
0
def loadRandomPoints(userid):
    # Remove existing spawnpoints
    for tSpawn in es.getEntityIndexes('info_player_terrorist'):
        es.server.cmd('es_xremove %s' % tSpawn)
    for ctSpawn in es.getEntityIndexes('info_player_counterterrorist'):
        es.server.cmd('es_xremove %s' % ctSpawn)

    # Loop through the spawnpoints
    for spawn in spawnPoints:
        for team in ('info_player_terrorist', 'info_player_counterterrorist'):
            # Create the spawnpoint and get the index
            index = spe.getIndexOfEntity(spe.giveNamedItem(userid, team))

            # Set the spawnpoint position and rotation
            es.setindexprop(index, 'CBaseEntity.m_vecOrigin',
                            '%s,%s,%s' % (spawn[0], spawn[1], spawn[2]))
            es.setindexprop(index, 'CBaseEntity.m_angRotation',
                            '0,%s,0' % spawn[4])
コード例 #7
0
ファイル: weapons.py プロジェクト: robtomlinson/GunGame
    def give_weapon(self):
        '''
        Gives a player their current levels weapon.
        '''
        error = None
        # Make sure player is on a team
        if self.team < 2:
            error = ('Unable to give player weapon (%s): ' % self.userid +
                     'is not on a team.')

        # Make sure player is alive
        elif _getPlayer(self.userid).isdead:
            error = ('Unable to give player weapon (%s): ' % self.userid +
                     'is not alive.')

        # Error ?
        if error:
            raise GunGameError(error)

        # Knife ?
        if self.weapon == 'knife':
            # Make them use their knife
            _es.server.queuecmd('es_xsexec %s "use weapon_knife"' %
                                (self.userid))

            # If there is a level below the user's current level
            if self.level > 1:
                # Strip previous weapons
                self.strip_weapons(_level_weapon(self.level - 1))
            else:
                self.strip()

        # Nade ?
        elif self.weapon == 'hegrenade':
            # Give them a grenade.
            given_weapon = _spe.giveNamedItem(self.userid, "weapon_hegrenade")

            # Make them use the grenade
            _es.server.queuecmd('es_xsexec %s "use weapon_hegrenade"' %
                                (self.userid))

            # If there is a level below the user's current level
            if self.level > 1:
                # Strip previous weapons
                self.strip_weapons(_level_weapon(self.level - 1))
            else:
                self.strip()

        else:
            # Player owns this weapon.
            if _spe.ownsWeapon(self.userid, "weapon_%s" % self.weapon):
                # Make them use it. If we don't do this, a very
                # strange bug comes up which prevents the player
                # from getting their current level's weapon after
                # being stripped,
                _es.server.queuecmd('es_xsexec %s "use weapon_%s"' %
                                    (self.userid, self.weapon))

                return

            # Player DOES NOT own this weapon.
            else:
                # Retrieve a list of all weapon names in the player's
                # possession
                playerWeapons = _spe.getWeaponDict(self.userid)

                if playerWeapons:
                    # See if there is a primary weapon in the list of weapons
                    pWeapon = set(
                        playerWeapons.keys()).intersection(list_pWeapons)

                    # See if there is a primary weapon in the list of weapons
                    sWeapon = set(
                        playerWeapons.keys()).intersection(list_sWeapons)

                    # Set up the weapon to strip
                    weapToStrip = None

                    # Strip secondary weapon ?
                    if 'weapon_' + self.weapon in list_sWeapons and sWeapon:
                        weapToStrip = sWeapon.pop()

                    # Strip primary weapon ?
                    elif 'weapon_' + self.weapon in list_pWeapons and pWeapon:
                        weapToStrip = pWeapon.pop()

                    if weapToStrip:
                        # Make them drop the weapon
                        _spe.dropWeapon(self.userid, weapToStrip)

                        # Now remove it
                        _spe.removeEntityByInstance(
                            playerWeapons[weapToStrip]["instance"])

                # Now give them the weapon and save the weapon instance
                given_weapon = _spe.giveNamedItem(self.userid,
                                                  "weapon_%s" % self.weapon)

                # Retrieve the weapon instance of the weapon they "should" own
                weapon_check = _spe.ownsWeapon(self.userid,
                                               "weapon_%s" % self.weapon)

                # Make sure that the player owns the weapon we gave them
                if weapon_check != given_weapon:
                    # Remove the given weapon since the player does not own it
                    _spe.removeEntityByInstance(given_weapon)

                    # If they don't have the right weapon, fire give_weapon()
                    if not weapon_check:
                        self.give_weapon()
                        return

                _es.server.queuecmd('es_xsexec %s "use weapon_%s"' %
                                    (self.userid, self.weapon))
コード例 #8
0
ファイル: weapons.py プロジェクト: robtomlinson/GunGame
    def give(self, weapon, useWeapon=False, strip=False):
        '''
        Gives a player the specified weapon.
        Weapons given by this method will not be stripped by gg_dead_strip.

        Setting strip to True will make it strip the weapon currently
        held in the slot you are trying to give to.
        '''
        # Format weapon
        weapon = 'weapon_%s' % str(weapon).replace('weapon_', '')

        # Check if weapon is valid
        if weapon not in list_pWeapons + list_sWeapons + [
                'weapon_hegrenade', 'weapon_flashbang', 'weapon_smokegrenade'
        ]:
            raise ValueError('Unable to give "%s": ' % weapon[7:] +
                             'is not a valid weapon')

        # Add weapon to strip exceptions so gg_dead_strip will not
        #   strip the weapon
        if int(_es.ServerVar('gg_dead_strip')):
            self.stripexceptions.append(weapon[7:])

            # Delay removing the weapon long enough for gg_dead_strip to fire
            _gamethread.delayed(0.10, self.stripexceptions.remove,
                                (weapon[7:]))

        # If the player owns the weapon and the player is not being given a
        # second flashbang, stop here
        if (_spe.ownsWeapon(self.userid, weapon)
                and not (weapon == "weapon_flashbang"
                         and _getPlayer(self.userid).getFB() < 2)):
            return

        # Strip the weapon ?
        if strip:
            # Retrieve a list of all weapon names in the player's possession
            playerWeapons = _spe.getWeaponDict(self.userid)

            if playerWeapons:
                # See if there is a primary weapon in the list of weapons
                pWeapon = set(playerWeapons.keys()).intersection(list_pWeapons)

                # See if there is a primary weapon in the list of weapons
                sWeapon = set(playerWeapons.keys()).intersection(list_sWeapons)

                stripWeapon = None

                # Holding a primary weapon ?
                if weapon in list_pWeapons and pWeapon:
                    stripWeapon = pWeapon.pop()

                # Holding a secondary weapon ?
                elif weapon in list_sWeapons and sWeapon:
                    stripWeapon = sWeapon.pop()

                # Strip the weapon
                if stripWeapon:
                    # Make them drop the weapon
                    _spe.dropWeapon(self.userid, stripWeapon)

                    # Remove the weapon
                    _spe.removeEntityByInstance(
                        playerWeapons[stripWeapon]["instance"])

        # Give the player the weapon
        _spe.giveNamedItem(self.userid, weapon)

        if useWeapon:
            _es.server.queuecmd('es_xsexec %s "use %s"' %
                                (self.userid, weapon))
コード例 #9
0
ファイル: weapons.py プロジェクト: cagemonkey/GunGame
    def give_weapon(self):
        '''
        Gives a player their current levels weapon.
        '''
        error = None
        # Make sure player is on a team
        if self.team < 2:
            error = ('Unable to give player weapon (%s): ' % self.userid +
                     'is not on a team.')

        # Make sure player is alive
        elif _getPlayer(self.userid).isdead:
            error = ('Unable to give player weapon (%s): ' % self.userid +
                     'is not alive.')

        # Error ?
        if error:
            raise GunGameError(error)

        # Knife ?
        if self.weapon == 'knife':
            # Make them use their knife
            _es.server.queuecmd('es_xsexec %s "use weapon_knife"' % (
                                                                self.userid))

            # If there is a level below the user's current level
            if self.level > 1:
                # Strip previous weapons
                self.strip_weapons(_level_weapon(self.level - 1))
            else:
                self.strip()

        # Nade ?
        elif self.weapon == 'hegrenade':
            # Give them a grenade.
            given_weapon = _spe.giveNamedItem(self.userid, "weapon_hegrenade")

            # Make them use the grenade
            _es.server.queuecmd('es_xsexec %s "use weapon_hegrenade"' % (
                                                                self.userid))

            # If there is a level below the user's current level
            if self.level > 1:
                # Strip previous weapons
                self.strip_weapons(_level_weapon(self.level - 1))
            else:
                self.strip()

        else:
            # Player owns this weapon.
            if _spe.ownsWeapon(self.userid, "weapon_%s" % self.weapon):
                # Make them use it. If we don't do this, a very
                # strange bug comes up which prevents the player
                # from getting their current level's weapon after
                # being stripped,
                _es.server.queuecmd('es_xsexec %s "use weapon_%s"'
                    % (self.userid, self.weapon))

                return

            # Player DOES NOT own this weapon.
            else:
                # Retrieve a list of all weapon names in the player's
                # possession
                playerWeapons = _spe.getWeaponDict(self.userid)

                if playerWeapons:
                    # See if there is a primary weapon in the list of weapons
                    pWeapon = set(playerWeapons.keys()).intersection(
                                                                list_pWeapons)

                    # See if there is a primary weapon in the list of weapons
                    sWeapon = set(playerWeapons.keys()).intersection(
                                                                list_sWeapons)

                    # Set up the weapon to strip
                    weapToStrip = None

                    # Strip secondary weapon ?
                    if 'weapon_' + self.weapon in list_sWeapons and sWeapon:
                        weapToStrip = sWeapon.pop()

                    # Strip primary weapon ?
                    elif 'weapon_' + self.weapon in list_pWeapons and pWeapon:
                        weapToStrip = pWeapon.pop()

                    if weapToStrip:
                        # Make them drop the weapon
                        _spe.dropWeapon(self.userid, weapToStrip)

                        # Now remove it
                        _spe.removeEntityByInstance(playerWeapons
                                                    [weapToStrip]["instance"])

                # Now give them the weapon and save the weapon instance
                given_weapon = _spe.giveNamedItem(self.userid,
                    "weapon_%s" % self.weapon)

                # Retrieve the weapon instance of the weapon they "should" own
                weapon_check = _spe.ownsWeapon(self.userid, "weapon_%s"
                    % self.weapon)

                # Make sure that the player owns the weapon we gave them
                if weapon_check != given_weapon:
                    # Remove the given weapon since the player does not own it
                    _spe.removeEntityByInstance(given_weapon)

                    # If they don't have the right weapon, fire give_weapon()
                    if not weapon_check:
                        self.give_weapon()
                        return

                _es.server.queuecmd('es_xsexec %s "use weapon_%s"'
                    % (self.userid, self.weapon))
コード例 #10
0
ファイル: weapons.py プロジェクト: cagemonkey/GunGame
    def give(self, weapon, useWeapon=False, strip=False):
        '''
        Gives a player the specified weapon.
        Weapons given by this method will not be stripped by gg_dead_strip.

        Setting strip to True will make it strip the weapon currently
        held in the slot you are trying to give to.
        '''
        # Format weapon
        weapon = 'weapon_%s' % str(weapon).replace('weapon_', '')

        # Check if weapon is valid
        if weapon not in list_pWeapons + list_sWeapons + [
          'weapon_hegrenade', 'weapon_flashbang', 'weapon_smokegrenade']:
            raise ValueError('Unable to give "%s": ' % weapon[7:] +
                             'is not a valid weapon')

        # Add weapon to strip exceptions so gg_dead_strip will not
        #   strip the weapon
        if int(_es.ServerVar('gg_dead_strip')):
            self.stripexceptions.append(weapon[7:])

            # Delay removing the weapon long enough for gg_dead_strip to fire
            _gamethread.delayed(0.10, self.stripexceptions.remove,
                                (weapon[7:]))

        # If the player owns the weapon and the player is not being given a
        # second flashbang, stop here
        if (_spe.ownsWeapon(self.userid, weapon) and not
          (weapon == "weapon_flashbang" and
          _getPlayer(self.userid).getFB() < 2)):
            return

        # Strip the weapon ?
        if strip:
            # Retrieve a list of all weapon names in the player's possession
            playerWeapons = _spe.getWeaponDict(self.userid)

            if playerWeapons:
                # See if there is a primary weapon in the list of weapons
                pWeapon = set(playerWeapons.keys()).intersection(list_pWeapons)

                # See if there is a primary weapon in the list of weapons
                sWeapon = set(playerWeapons.keys()).intersection(list_sWeapons)

                stripWeapon = None

                # Holding a primary weapon ?
                if weapon in list_pWeapons and pWeapon:
                    stripWeapon = pWeapon.pop()

                # Holding a secondary weapon ?
                elif weapon in list_sWeapons and sWeapon:
                    stripWeapon = sWeapon.pop()

                # Strip the weapon
                if stripWeapon:
                    # Make them drop the weapon
                    _spe.dropWeapon(self.userid, stripWeapon)

                    # Remove the weapon
                    _spe.removeEntityByInstance(playerWeapons[stripWeapon][
                                                                "instance"])

        # Give the player the weapon
        _spe.giveNamedItem(self.userid, weapon)

        if useWeapon:
            _es.server.queuecmd('es_xsexec %s "use %s"' % (self.userid,
                                                           weapon))