Exemple #1
0
def player_hurt(event_var):
    """
    Executed when a player is damaged. Retrieve the victims level and speed
    them up if they aren't already in the adrenaline mode
    
    @PARAM event_var - an automatically passed event instance
    """
    userid = event_var['userid']
    player = sourcerpg.players[userid]
    level = player[skillName]
    if level:
        """ Player is at least level 1 in this skill """
        if not player['adrenalined'] and not player['slowed']:
            """ Player is not already in the adrenaline mode """
            attacker = event_var['attacker']
            if attacker and attacker.isdigit() and int(attacker) > 1:
                """ If the attacker is a valid attacker """
                if event_var['es_attackerteam'] != event_var['es_userteam']:
                    """ If the attacker is not on the user's team """
                    if "Frost Pistol" in sourcerpg.skills:
                        """ If frost pistol is loaded check if the attack was a frost pistol attack """
                        if sourcerpg.players[attacker]['Frost Pistol']:
                            """ If the attacker has a frost pistol level """
                            weapon = event_var['weapon']
                            weapon = weaponlib.getWeapon(weapon)
                            if weapon is None:
                                return
                            weapon = weapon.name  # format the weapon name
                            if weapon in weaponlib.getWeaponNameList(
                                    "#secondary"):
                                """ The attack was a frost pistol attack, return early """
                                return

                    player['adrenalined'] = True
                    amount = level / 10.
                    speed = player['maxSpeed'] + amount
                    """ Set the speed and the delay """
                    playerlibInstance = playerlib.getPlayer(userid)
                    playerlibInstance.speed = speed

                    if int(refreshAmmo):
                        currentWeapon = weaponlib.getWeapon(
                            playerlibInstance.weapon)
                        if currentWeapon is not None:
                            if random.randint(
                                    1, 100) <= float(clipRefreshPct) * level:
                                playerlibInstance.clip[
                                    currentWeapon.name] = currentWeapon.clip

                    gamethread.delayedname(
                        float(length), 'sourcerpg_adrenaline_user%s' % userid,
                        reset, (userid, speed - amount))
def clientFilter(userid, args):
    """
    Executed when a client command is issued from a player. Test to see if drop
    was the command; if so, then remove the weapon.

    @PARAM userid - the id of the user who issued the client command
    @PARAM args - a list of arguments, with index 0 being the command.
    """
    if args and args[0].lower() == "drop":
        """ Player is about to issue the drop command """
        player = sourcerpg.players[userid]
        level  = player[skillName]
        if level:
            """ The player has recover weapons, get their active weapn and remove it """
            weapon = weaponlib.getWeapon(playerlib.getPlayer(userid).get("weapon"))
            if weapon is None:
                # The user has no weapons, allow them to run the drop command
                return True

            weapon = weapon.name # return formated weapon
            
            if level >= 3 and weapon in weaponlib.getWeaponNameList("#primary"):
                player['primary'] = None

            elif level >= 2 and weapon in weaponlib.getWeaponNameList("#secondary"):
                player['secondary'] = None

    return True
def item_pickup(event_var):
    """
    Exeecuted when a player picks up a weapon. Store their current weapon
    so it remembers the value

    @PARAM event_var - an automatically passed event instance
    """
    weapon = weaponlib.getWeapon(event_var['item'])
    if weapon is None:
        """ The item picked up is not a valid weapon, return early """
        return
    weapon = weapon.name # format the weapon name
    userid = event_var['userid']
    player = sourcerpg.players[userid]
    if player is not None:
        level  = player[skillName]
        if level:
            """ Player is at least level 1 in this skill """
            if weapon in weaponlib.getWeaponNameList('#primary') and level >= 3:
                player['primary'] = weapon

            elif weapon in weaponlib.getWeaponNameList('#secondary') and level >= 2:
                if weapon != {2 : "weapon_glock", 3 : "weapon_usp"}[es.getplayerteam(userid)]:
                    player['secondary'] = weapon

            elif weapon in weaponlib.getWeaponNameList('#grenade'):
                player[weapon] += 1
Exemple #4
0
def player_hurt(event_var):
    """
    Executed when a player is damaged. Retrieve the victims level and speed
    them up if they aren't already in the adrenaline mode
    
    @PARAM event_var - an automatically passed event instance
    """
    userid = event_var['userid']
    player = sourcerpg.players[userid]
    level  = player[skillName]
    if level:
        """ Player is at least level 1 in this skill """
        if not player['adrenalined'] and not player['slowed']:
            """ Player is not already in the adrenaline mode """
            attacker = event_var['attacker']
            if attacker and attacker.isdigit() and int(attacker) > 1:
                """ If the attacker is a valid attacker """
                if event_var['es_attackerteam'] != event_var['es_userteam']:
                    """ If the attacker is not on the user's team """
                    if "Frost Pistol" in sourcerpg.skills:
                        """ If frost pistol is loaded check if the attack was a frost pistol attack """
                        if sourcerpg.players[attacker]['Frost Pistol']:
                            """ If the attacker has a frost pistol level """
                            weapon = event_var['weapon']
                            weapon = weaponlib.getWeapon(weapon)
                            if weapon is None:
                                return
                            weapon = weapon.name # format the weapon name
                            if weapon in weaponlib.getWeaponNameList("#secondary"):
                                """ The attack was a frost pistol attack, return early """
                                return
                            
                    player['adrenalined'] = True
                    amount = level / 10.
                    speed  = player['maxSpeed'] + amount

                    """ Set the speed and the delay """
                    playerlibInstance = playerlib.getPlayer(userid)
                    playerlibInstance.speed = speed
                    
                    if int(refreshAmmo):
                        currentWeapon = weaponlib.getWeapon(playerlibInstance.weapon)
                        if currentWeapon is not None:
                            if random.randint(1, 100) <= float(clipRefreshPct) * level:
                                playerlibInstance.clip[currentWeapon.name] = currentWeapon.clip
                    
                    gamethread.delayedname( float(length), 'sourcerpg_adrenaline_user%s' % userid, reset, (userid, speed - amount))
def weapon_fire(ev):
   userid = ev['userid']
   if not superhero.hasHero(userid, 'Punisher'):
      return
   weapon = getWeapon(ev['weapon'])
   if weapon is not None and weapon.slot in (1, 2):
      player = getPlayer(ev['userid'])
      if not player.getClip(weapon):
         player.setClip(weapon, weapon.clip)
Exemple #6
0
def player_death(event_var):
    # Get the userids of the attacker and victim
    attacker = int(event_var['attacker'])
    userid = int(event_var['userid'])

    # If there is no attacker (falling to death), return
    if not attacker:
        return

    # If the kill was a suicide, return
    if attacker == userid:
        return

    # If the kill was a teamkill, return
    if event_var['es_attackerteam'] == event_var['es_userteam']:
        return

    # Get the name of the weapon used to get the kill
    weapon = event_var['weapon']

    ggPlayer = Player(attacker)
    level = ggPlayer.level

    # If the player has already leveled up internally, check their last level
    if attacker in recentlyLeveled:
        level -= 1
        level = 1 if level < 1 else level

    reloadWeapons = [get_level_weapon(level)]
    # If nade bonus is loaded, add the bonus weapons to reloadWeapons
    if not str(gg_nade_bonus) in ('', '0'):
        reloadWeapons.extend(get_weapon(userid))

    # If the weapon name doesn't match the player's level's weapon name at the
    # time, return
    if not weapon in reloadWeapons:
        return

    # If the player is on hegrenade or knife level, return
    if weapon in ('hegrenade', 'knife'):
        return

    # Get the weapon object and the size if its clip
    weaponObject = getWeapon(weapon)

    # Find the attacker's weapon index to be used to reload the weapon
    playerHandle = es.getplayerhandle(attacker)

    for index in weaponObject.indexlist:
        # When the attacker's handle matches the index handle we have found
        # the attacker's weapon index
        if es.getindexprop(index,
                           'CBaseEntity.m_hOwnerEntity') == playerHandle:
            # Set the clip to the maximum ammo allowed
            getPlayer(attacker)['clip'][weaponObject] = weaponObject.clip
            break
Exemple #7
0
def player_death(event_var):
    # Get the userids of the attacker and victim
    attacker = int(event_var['attacker'])
    userid = int(event_var['userid'])

    # If there is no attacker (falling to death), return
    if not attacker:
        return

    # If the kill was a suicide, return
    if attacker == userid:
        return

    # If the kill was a teamkill, return
    if event_var['es_attackerteam'] == event_var['es_userteam']:
        return

    # Get the name of the weapon used to get the kill
    weapon = event_var['weapon']

    ggPlayer = Player(attacker)
    level = ggPlayer.level

    # If the player has already leveled up internally, check their last level
    if attacker in recentlyLeveled:
        level -= 1
        level = 1 if level < 1 else level

    reloadWeapons = [get_level_weapon(level)]
    # If nade bonus is loaded, add the bonus weapons to reloadWeapons
    if not str(gg_nade_bonus) in ('', '0'):
        reloadWeapons.extend(get_weapon(userid))

    # If the weapon name doesn't match the player's level's weapon name at the
    # time, return
    if not weapon in reloadWeapons:
        return

    # If the player is on hegrenade or knife level, return
    if weapon in ('hegrenade', 'knife'):
        return

    # Get the weapon object and the size if its clip
    weaponObject = getWeapon(weapon)

    # Find the attacker's weapon index to be used to reload the weapon
    playerHandle = es.getplayerhandle(attacker)

    for index in weaponObject.indexlist:
        # When the attacker's handle matches the index handle we have found
        # the attacker's weapon index
        if es.getindexprop(index,
          'CBaseEntity.m_hOwnerEntity') == playerHandle:
            # Set the clip to the maximum ammo allowed
            getPlayer(attacker)['clip'][weaponObject] = weaponObject.clip
            break
def giveDeagle(userid):
   for x in xrange(7): # CSS players can have up to 7 weapons
      handle = es.getplayerprop(userid, 'CBaseCombatCharacter.m_hMyWeapons.%03d' % x)
      if handle > 0:
         index = es.getindexfromhandle(handle)
         weapon = weaponlib.getWeapon(es.entitygetvalue(index, 'classname'))
         if weapon is not None and 'secondary' in weapon.tags:
            if weapon != 'weapon_deagle':
               es.entitysetvalue(index, 'targetname', 'kill_me')
               es.server.insertcmd('es_xfire %(userid)s kill_me Kill;'
                                   'es_xgive %(userid)s weapon_deagle' % 
                                   {'userid': userid})
            break
def giveDeagle(userid):
    for x in xrange(7):  # CSS players can have up to 7 weapons
        handle = es.getplayerprop(userid,
                                  'CBaseCombatCharacter.m_hMyWeapons.%03d' % x)
        if handle > 0:
            index = es.getindexfromhandle(handle)
            weapon = weaponlib.getWeapon(es.entitygetvalue(index, 'classname'))
            if weapon is not None and 'secondary' in weapon.tags:
                if weapon != 'weapon_deagle':
                    es.entitysetvalue(index, 'targetname', 'kill_me')
                    es.server.insertcmd('es_xfire %(userid)s kill_me Kill;'
                                        'es_xgive %(userid)s weapon_deagle' %
                                        {'userid': userid})
                break
def wep_remove(userid):
    player = playerlib.getPlayer(userid)
    if int(player.isdead) != 1:
        if userid != '0':
            player = playerlib.getPlayer(userid)
            primary = player.getPrimary()
            for x in xrange(7):
                handle = es.getplayerprop(userid, 'CBaseCombatCharacter.m_hMyWeapons.%03d' % x)
                if handle > 0:
                    index = es.getindexfromhandle(handle)
                    weapon = weaponlib.getWeapon(es.entitygetvalue(index, 'classname'))
                    if weapon is not None and 'primary' in weapon.tags:
                        es.entitysetvalue(index, 'targetname', 'kill_me')
                        es.server.queuecmd('es_xfire %s kill_me kill'%userid)
                        
def weapon_give(userid, weapon, popupname):

    userid = str(userid)

    weapon = str(weapon)
    player = playerlib.getPlayer(userid)
    if int(player.isdead) != 1:
        batlist = 'tmp,mp5navy,p90,ak47,m4a1,sg552'

        if weapon in batlist:

            weapon_give = 'weapon_' + weapon

            primary = player.getPrimary()

            for x in xrange(7):

                handle = es.getplayerprop(
                    userid, 'CBaseCombatCharacter.m_hMyWeapons.%03d' % x)

                if handle > 0:

                    index = es.getindexfromhandle(handle)

                    weapon = weaponlib.getWeapon(
                        es.entitygetvalue(index, 'classname'))

                    # Loop through all usps to find the one belonging to the player

                    if weapon is not None and 'primary' in weapon.tags:

                        es.entitysetvalue(index, 'targetname', 'kill_me')

                        es.server.queuecmd('es_xfire %s kill_me kill' % userid)

            es.server.queuecmd('es_xgive %s %s' % (userid, weapon_give))

            if popuplib.isqueued('bat_menu', userid):

                popuplib.close('bat_menu', userid)

        else:

            es.tell(
                userid, '#multi',
                '#green[SH] #lightgreenWeapon has already been picked once this round'
            )
def wep_remove(userid):
    player = playerlib.getPlayer(userid)
    if int(player.isdead) != 1:
        if userid != '0':
            player = playerlib.getPlayer(userid)
            primary = player.getPrimary()
            for x in xrange(7):
                handle = es.getplayerprop(
                    userid, 'CBaseCombatCharacter.m_hMyWeapons.%03d' % x)
                if handle > 0:
                    index = es.getindexfromhandle(handle)

                    weapon = weaponlib.getWeapon(
                        es.entitygetvalue(index, 'classname'))
                    if weapon is not None and 'primary' in weapon.tags:
                        es.entitysetvalue(index, 'targetname', 'kill_me')

                        es.server.queuecmd('es_xfire %s kill_me kill' % userid)
def weapon_give(userid,weapon,popupname):

    userid = str(userid)

    weapon = str(weapon)
    player = playerlib.getPlayer(userid)
    if int(player.isdead) != 1:
        batlist = 'tmp,mp5navy,p90,ak47,m4a1,sg552'

        if weapon in batlist:

            weapon_give = 'weapon_'+weapon

            primary = player.getPrimary()

            for x in xrange(7):

                handle = es.getplayerprop(userid, 'CBaseCombatCharacter.m_hMyWeapons.%03d' % x)

                if handle > 0:

                    index = es.getindexfromhandle(handle)

                    weapon = weaponlib.getWeapon(es.entitygetvalue(index, 'classname'))

                    # Loop through all usps to find the one belonging to the player

                    if weapon is not None and 'primary' in weapon.tags:

                        es.entitysetvalue(index, 'targetname', 'kill_me')

                        es.server.queuecmd('es_xfire %s kill_me kill'%userid)

            es.server.queuecmd('es_xgive %s %s'%(userid, weapon_give))

            if popuplib.isqueued('bat_menu', userid):

                popuplib.close('bat_menu', userid)

        else:

            es.tell(userid,'#multi','#green[SH] #lightgreenWeapon has already been picked once this round')
Exemple #14
0
def bullet_impact(ev):
    x, y, z = getplayerlocation(ev['userid'])
    x1, y1, z1 = float(ev['x']), float(ev['y']), float(ev['z'])
    r, g, b = randint(0, 255), randint(0, 255), randint(0, 255)
    msg('%s (number %s/%s)' % (_effects[_users[ev['userid']]], _users[ev['userid']], len(_effects) - 1))
    ServerVar('est_userid').set(ev['userid'])
    ServerVar('wcs_x1').set(x)
    ServerVar('wcs_y1').set(y)
    ServerVar('wcs_z1').set(z)
    ServerVar('wcs_x2').set(x1)
    ServerVar('wcs_y2').set(y1)
    ServerVar('wcs_z2').set(z1)
    if int(_users[ev['userid']]) < 234:
        server.queuecmd('es_doblock effects/%s' % _effects[_users[ev['userid']]])
    else:
        exec("ice_test.ice_test.%s(%s)" % (_effects[_users[ev['userid']]], [(x, y, z), (x1, y1, z1)]))
    weapon = getWeapon(getPlayer(ev['userid']).weapon)
    if weapon.slot == 1:
        getPlayer(ev['userid']).clip.primary += 1
    elif weapon.slot==2:
        getPlayer(ev['userid']).clip.secondary += 1