Example #1
0
        def on_position_update(self):
            if self.protocol.running_man:
                if self.link is not None and self.link.hp > 0:
                    dist = distance_3d_vector(self.world_object.position,
                                              self.link.world_object.position)
                    if dist > LINK_DISTANCE:
                        self.grenade_suicide()
                        self.link_deaths += 1
                        self.link.grenade_suicide()
                        self.link.link_deaths += 1

                        message = S_LINK_BREAK.format(player=self.link.name)
                        self.send_chat(message)
                        message = S_LINK_BREAK.format(player=self.name)
                        self.link.send_chat(message)
                    elif (dist > LINK_WARNING_DISTANCE and
                          (self.last_warning is None or
                           seconds() - self.last_warning > 2.0)):

                        self.last_warning = seconds()
                        self.link.last_warning = seconds()

                        message = S_LINK_WARNING.format(player=self.link.name)
                        self.send_chat(message)
                        message = S_LINK_WARNING.format(player=self.name)
                        self.link.send_chat(message)
            connection.on_position_update(self)
Example #2
0
 def on_hit(self, hit_amount, hit_player, type, grenade):
     result = connection.on_hit(self, hit_amount, hit_player, type,
                                grenade)
     if result == False:
         return False
     if grenade:  # Don't reduce damage when using grenade e.g. airstrike
         return connection.on_hit(self, hit_amount, hit_player, type,
                                  grenade)
     if self.world_object and hit_player.world_object:
         if result is not None:
             hit_amount = result
         dist = distance_3d_vector(self.world_object.position,
                                   hit_player.world_object.position)
         if self.weapon == RIFLE_WEAPON:
             pct = (100 * rifle_multiplier.get() -
                    rifle_pct_per_block.get() * dist)
         elif self.weapon == SMG_WEAPON:
             pct = (100 * smg_multiplier.get() -
                    smg_pct_per_block.get() * dist)
         elif self.weapon == SHOTGUN_WEAPON:
             pct = (100 * shotgun_multiplier.get() -
                    shotgun_pct_per_block.get() * dist)
         pct = max(0, pct) / 100.0
         hit_amount = int(hit_amount * pct)
         return hit_amount
Example #3
0
 def on_hit(self, hit_amount, hit_player, type, grenade):
     body_damage_values = [49, 29, 27]
     limb_damage_values =  [33, 18, 16]
     dist = int(distance_3d_vector(self.world_object.position, hit_player.world_object.position))
     weap = self.weapon_object.name
     self.pres_time = seconds()
     if self.prev_time is None:
         dt = None
     else: dt = (self.pres_time - self.prev_time) * 1000
     self.prev_time = seconds()
     if weap == "SMG" or weap == "Rifle":
         if dt is not None and dt  < 5:
             self.illegal_dt_count = self.illegal_dt_count + 1
     if weap == "Shotgun":
         if dist > 20:
             if dt < 8:
                 if hit_amount == self.spread_hit_amount and hit_player.name == self.spread_hit_player:
                     if type == HEADSHOT_KILL:
                         self.spread_hs_count = self.spread_hs_count +1
                     elif hit_amount in body_damage_values:
                         self.spread_hs_count = self.spread_bs_count +1
                     elif hit_amount in limb_damage_values:
                         self.spread_ls_count = self.spread_ls_count +1
                 else: 
                     self.spread_hs_count, self.spread_bs_count, self.spread_ls_count = 0, 0, 0
                     self.spread_hit_amount, self.spread_hit_player = None, None 
             else:
                 self.spread_hs_count, self.spread_bs_count, self.spread_ls_count = 0, 0, 0
                 self.spread_hit_amount, self.spread_hit_player = hit_amount, hit_player.name             
         else:  
              self.spread_hs_count, self.spread_bs_count, self.spread_ls_count = 0, 0, 0
              self.spread_hit_amount, self.spread_hit_player = None, None
     self.local_variable = self.shots_analyzed_by
     for names in self.local_variable:
         adminz = get_player(self.protocol, names)
         if type == HEADSHOT_KILL:
             adminz.hs = adminz.hs + 1
             if dt is not None:
                 adminz.send_chat('%s shot %s dist: %d blocks dT: %.0f ms %s HEADSHOT(%d)' % (self.name, hit_player.name, dist, dt, weap, adminz.hs))
             else:
                 adminz.send_chat('%s shot %s dist: %d blocks dT: NA %s HEADSHOT(%d)' % (self.name, hit_player.name, dist, weap, adminz.hs))
         if hit_amount in body_damage_values:
             adminz.bs = adminz.bs + 1
             if dt is not None:
                 adminz.send_chat('%s shot %s dist: %d blocks dT: %.0f ms %s Body(%d)' % (self.name, hit_player.name, dist, dt, weap, adminz.bs))
             else:
                 adminz.send_chat('%s shot %s dist: %d blocks dT: NA %s Body(%d)' % (self.name, hit_player.name, dist, weap, adminz.bs))
         if hit_amount in limb_damage_values:
             adminz.ls = adminz.ls + 1
             if dt is not None:
                 adminz.send_chat('%s shot %s dist: %d blocks dT: %.0f ms %s Limb(%d)' % (self.name, hit_player.name, dist, dt, weap, adminz.ls))
             else:
                 adminz.send_chat('%s shot %s dist: %d blocks dT: NA %s Limb(%d)' % (self.name, hit_player.name, dist, weap, adminz.ls))
     if self.illegal_dt_count >= 5:
         self.ban('Hack Detected - Multiple Bullets', 10080)
         return False
     if self.spread_hs_count >= 7 or self.spread_bs_count >= 7 or self.spread_ls_count >=7:
         self.ban('Hack Detected - No Spread', 10080)
         return False                      
     return connection.on_hit(self, hit_amount, hit_player, type, grenade)             
Example #4
0
 def on_position_update(self):
     if self.protocol.running_man:
         if self.link is not None and self.link.hp > 0:
             dist = distance_3d_vector(self.world_object.position,
                 self.link.world_object.position)
             if dist > LINK_DISTANCE:
                 self.grenade_suicide()
                 self.link_deaths += 1
                 self.link.grenade_suicide()
                 self.link.link_deaths += 1
                 
                 message = S_LINK_BREAK.format(player = self.link.name)
                 self.send_chat(message)
                 message = S_LINK_BREAK.format(player = self.name)
                 self.link.send_chat(message)
             elif (dist > LINK_WARNING_DISTANCE and 
                 (self.last_warning is None or 
                 seconds() - self.last_warning > 2.0)):
                 
                 self.last_warning = seconds()
                 self.link.last_warning = seconds()
                 
                 message = S_LINK_WARNING.format(player = self.link.name)
                 self.send_chat(message)
                 message = S_LINK_WARNING.format(player = self.name)
                 self.link.send_chat(message)
     connection.on_position_update(self)
Example #5
0
 def on_block_destroy(self, x, y, z, value):
     self.blockposition.x = x
     self.blockposition.y = y
     self.blockposition.z = z
     distance = int(distance_3d_vector(self.world_object.position,
                                       self.blockposition))
     if distance >= MAX_BLOCK_SHOOT_DISTANCE:
         return False
     return connection.on_block_destroy(self, x, y, z, value)
Example #6
0
        def get_horizontal_dist_to_player(self, player):
            # Calculate horizontal distance and pitch from self to player

            dist = distance_3d_vector(self.world_object.position, player.world_object.position)
            vdist = self.world_object.position.z - player.world_object.position.z

            theta = asin(vdist / dist) * (180 / pi)

            hdist = sqrt(dist ** 2 - vdist ** 2)

            return hdist, theta
Example #7
0
 def heal_team(self, value):
     for player in self.team.get_players():
         if player is None or player.hp <= 0:
             return
         dist = distance_3d_vector(self.world_object.position, player.world_object.position)
         if dist <= 16.0 or player == self:
             player.poison = 0
             player.poisoner = None
             player.set_hp(player.hp + value, type = FALL_KILL)
             if player != self:
                 player.send_chat("You have been healed by %s " % self.name)
Example #8
0
 def heal_team(self, value):
     for player in self.team.get_players():
         if player is None or player.hp <= 0:
             return
         dist = distance_3d_vector(self.world_object.position, player.world_object.position)
         if dist <= 16.0 or player == self:
             player.poison = 0
             player.poisoner = None
             player.set_hp(player.hp + value, type = FALL_KILL)
             if player != self:
                 player.send_chat("You have been healed by %s " % self.name)
Example #9
0
 def on_hit(self, hit_amount, hit_player, type, grenade):
     if self.name in analyzers.values():
         body_damage_values = [49, 29, 27]
         limb_damage_values = [33, 18, 16]
         if type == HEADSHOT_KILL or hit_amount in body_damage_values or hit_amount in limb_damage_values:
             if not grenade:
                 dist = int(
                     distance_3d_vector(
                         self.world_object.position,
                         hit_player.world_object.position))
                 weap = self.weapon_object.name
                 self.pres_time = seconds()
                 if self.prev_time is None:
                     dt = None
                 else:
                     dt = (self.pres_time - self.prev_time) * 1000
                 self.prev_time = seconds()
                 if type == HEADSHOT_KILL:
                     body_part = "HEADSHOT"
                 elif hit_amount in body_damage_values:
                     body_part = "Body"
                 elif hit_amount in limb_damage_values:
                     body_part = "Limb"
                 for name in analyzers.keys():
                     if analyzers[name] == self.name:
                         analyzer = get_player(self.protocol, name)
                         if analyzer not in self.protocol.players:
                             raise ValueError()
                         else:
                             if body_part == "HEADSHOT":
                                 analyzer.hs += 1
                                 counter = analyzer.hs
                             elif body_part == "Body":
                                 analyzer.bs += 1
                                 counter = analyzer.bs
                             elif body_part == "Limb":
                                 analyzer.ls += 1
                                 counter = analyzer.ls
                             if dt is not None:
                                 analyzer.send_chat(
                                     '%s shot %s dist: %d blocks dT: %.0f ms %s %s(%d)'
                                     %
                                     (self.name, hit_player.name, dist,
                                      dt, weap, body_part, counter))
                             else:
                                 analyzer.send_chat(
                                     '%s shot %s dist: %d blocks dT: NA %s %s(%d)'
                                     % (self.name, hit_player.name,
                                        dist, weap, body_part, counter))
     return connection.on_hit(self, hit_amount, hit_player, type,
                              grenade)
def log_block_removal(self, x, y, z):
    f = open(os.path.join(config.config_dir, "logs", "block_removal.log"), "a")
    self.blockposition.x = x
    self.blockposition.y = y
    self.blockposition.z = z
    distance = int(
        distance_3d_vector(self.world_object.position, self.blockposition))
    sep = ";"
    info = (self.name + sep + str(self.player_id) + sep + str(self.team.id) +
            sep + str(self.tool) + sep + str(self.weapon) + sep + str(
                (int(self.world_object.position.x),
                 int(self.world_object.position.y),
                 int(self.world_object.position.z))) + sep + str((x, y, z)) +
            sep + str(distance) + sep + self.address[0] + sep + str(seconds()))
    f.write(info + "\n")
    f.close()
Example #11
0
 def on_hit(self, hit_amount, hit_player, type, grenade):
     if self.name in analyzers.values():
         body_damage_values = [49, 29, 27]
         limb_damage_values = [33, 18, 16]
         if type == HEADSHOT_KILL or hit_amount in body_damage_values or hit_amount in limb_damage_values:
             if not grenade:
                 dist = int(distance_3d_vector(self.world_object.position, hit_player.world_object.position))
                 weap = self.weapon_object.name
                 self.pres_time = seconds()
                 if self.prev_time is None:
                     dt = None
                 else:
                     dt = (self.pres_time - self.prev_time) * 1000
                 self.prev_time = seconds()
                 if type == HEADSHOT_KILL:
                     body_part = "HEADSHOT"
                 elif hit_amount in body_damage_values:
                     body_part = "Body"
                 elif hit_amount in limb_damage_values:
                     body_part = "Limb"
                 for name in analyzers.keys():
                     if analyzers[name] == self.name:
                         analyzer = get_player(self.protocol, name)
                         if analyzer not in self.protocol.players:
                             raise ValueError()
                         else:
                             if body_part == "HEADSHOT":
                                 analyzer.hs += 1
                                 counter = analyzer.hs
                             elif body_part == "Body":
                                 analyzer.bs += 1
                                 counter = analyzer.bs
                             elif body_part == "Limb":
                                 analyzer.ls += 1
                                 counter = analyzer.ls
                             if dt is not None:
                                 analyzer.send_chat(
                                     "%s shot %s dist: %d blocks dT: %.0f ms %s %s(%d)"
                                     % (self.name, hit_player.name, dist, dt, weap, body_part, counter)
                                 )
                             else:
                                 analyzer.send_chat(
                                     "%s shot %s dist: %d blocks dT: NA %s %s(%d)"
                                     % (self.name, hit_player.name, dist, weap, body_part, counter)
                                 )
     return connection.on_hit(self, hit_amount, hit_player, type, grenade)
Example #12
0
        def on_hit(self, hit_amount, hit_player, type, grenade):
            body_damage_values = [49, 29, 27]
            limb_damage_values =  [33, 18, 16]
            if type == HEADSHOT_KILL or hit_amount in body_damage_values or hit_amount in limb_damage_values:
                if not grenade:

                    dist1 = int(distance_3d_vector(self.world_object.position, hit_player.world_object.position))
                    
                    weap1 = self.weapon_object.name
                    self.pres_time1 = seconds()

                    if self.prev_time1 is None:
                        dt1 = None
                    else: dt1 = (self.pres_time1 - self.prev_time1) * 1000
                    self.prev_time1 = seconds()

                    if type == HEADSHOT_KILL:
                        body_part1 = "HEADSHOT"
                    elif hit_amount in body_damage_values:
                        body_part1 = "Body"
                    elif hit_amount in limb_damage_values:
                        body_part1 = "Limb"
                     
                    self.presdist = dist1
                    if dt1 is not None and dt1 < 3000 and self.prev_xyz is not None:
                        if self.prev_xyz == hit_player.world_object.position:
                            theta = 0
                        else:
                            target2target_dist =  int(distance_3d_vector(hit_player.world_object.position, self.prev_xyz))
                            theta = int(math.acos((self.presdist ** 2 + self.prevdist ** 2 - target2target_dist ** 2) / (2 * self.presdist * self.prevdist)))
                            theta = math.degrees(theta)
                        
                    if weap1 == "Shotgun":
                        if dist1 > 23:
                            if dt1 < 8:
                                if body_part1 == self.spread_hit_type and hit_player.name == self.spread_hit_player:
                                    if body_part1 == "HEADSHOT":
                                        self.spread_hs_count += 1
                                    elif body_part1 == "Body":
                                        self.spread_bs_count += 1
                                    elif body_part1 == "Limb":
                                        self.spread_ls_count += 1
                                else: 
                                    self.spread_hs_count, self.spread_bs_count, self.spread_ls_count = 0, 0, 0
                                    self.spread_hit_type, self.spread_hit_player = None, None 
                            else:
                                self.spread_hs_count, self.spread_bs_count, self.spread_ls_count = 0, 0, 0
                                self.spread_hit_type, self.spread_hit_player = body_part1, hit_player.name             
                        else:  
                            self.spread_hs_count, self.spread_bs_count, self.spread_ls_count = 0, 0, 0
                            self.spread_hit_type, self.spread_hit_player = None, None
                    if self.spread_hs_count >= 7 or self.spread_bs_count >= 7 or self.spread_ls_count >= 7:
                        self.shotgun_nospread_count += 1
                        self.pres_nospread = seconds()
                        if self.prev_nospread is None:
                            nospread_timer = 0
                        else: nospread_timer = (self.pres_nospread - self.prev_nospread)
                        self.prev_nospread = seconds()
                        if nospread_timer >= 30:
                                self.shotun_nospread_count = 1
                    if self.shotgun_nospread_count >= 3:
                        self.ban('Hack Detected - No Spread    IGN: %s' % (self.name), 10080)
                        return False     
                    if weap1 == "SMG" or weap1 == "Rifle":
                        if dt1 is not None and dt1  < 5:
                            self.illegal_dt_count += 1
                            self.pres_illegal_dt = seconds()
                            if self.prev_illegal_dt is None:
                                dt_timer = 0
                            else: dt_timer = (self.pres_illegal_dt - self.prev_illegal_dt)
                            self.prev_illegal_dt = seconds()
                            if dt_timer >= 60:
                                self.illegal_dt_count = 1
                    if self.illegal_dt_count >= 7:
                        self.ban('Hack Detected - Multiple Bullets    IGN: %s' % (self.name), 10080)
                        return False   
                    
                    if weap1 == "SMG"  and dist1 >= 15 and self.prevdist >= 15:
                        if dt1 is not None and dt1 >= 5 and dt1 < 155:
                            if hit_player.name != self.prevtarget and body_part1 == self.prev_body_part: 
                                if theta >= 10:
                                    self.smg_snap_count += 1
                                    if theta >= 45:
                                        self.smg_snap_count +=1
                                        if theta >= 90:
                                            self.smg_snap_count += 1     
                                    self.pres_smg_snap = seconds()
                                    if self.prev_smg_snap is None:
                                        smg_snap_timer = 0
                                    else: smg_snap_timer = (self.pres_smg_snap - self.prev_smg_snap)
                                    if smg_snap_timer >= 60:
                                        self.smg_snap_count = 1
                    if self.smg_snap_count >= 4:
                        self.ban('Hack Detected - Aimbot    IGN: %s' % (self.name), 10080)                
                        return False              
                         
                    self.prevtarget = hit_player.name
                    self.prev_body_part = body_part1  
                    self.prevdist = dist1
                    self.prev_xyz = hit_player.world_object.position
                                       
            return connection.on_hit(self, hit_amount, hit_player, type, grenade)
Example #13
0
def grief_check(connection, player, minutes=2):
    player = get_player(connection.protocol, player)
    protocol = connection.protocol
    color = connection not in protocol.players and connection.colors
    minutes = float(minutes)
    if minutes <= 0.0:
        raise ValueError('minutes must be number greater than 0')
    time = seconds() - minutes * 60.0
    blocks_removed = player.blocks_removed or []
    blocks = [b[1] for b in blocks_removed if b[0] >= time]
    player_name = player.name
    if color:
        player_name = (('\x0303' if player.team.id else '\x0302') +
                       player_name + '\x0f')
    message = '%s removed %s block%s in the last ' % (
        player_name, len(blocks) or 'no', '' if len(blocks) == 1 else 's')
    if minutes == 1.0:
        minutes_s = 'minute'
    else:
        minutes_s = '{:.1f} minutes'.format(minutes)
    message += minutes_s + '.'
    if len(blocks):
        infos = set(blocks)
        infos.discard(None)
        if color:
            names = [('\x0303' if team else '\x0302') + name
                     for name, team in infos]
        else:
            names = set([name for name, team in infos])
        if len(names) > 0:
            message += (' Some of them were placed by ' +
                        ('\x0f, ' if color else ', ').join(names))
            message += '\x0f.' if color else '.'
        else:
            message += ' All of them were map blocks.'
        last = blocks_removed[-1]
        time_s = prettify_timespan(seconds() - last[0], get_seconds=True)
        message += ' Last one was destroyed %s ago' % time_s
        whom = last[1]
        if whom is None and len(names) > 0:
            message += ', and was part of the map'
        elif whom is not None:
            name, team = whom
            if color:
                name = ('\x0303' if team else '\x0302') + name + '\x0f'
            message += ', and belonged to %s' % name
        message += '.'
    switch_sentence = False
    if player.last_switch is not None and player.last_switch >= time:
        time_s = prettify_timespan(seconds() - player.last_switch,
                                   get_seconds=True)
        message += ' %s joined %s team %s ago' % (player_name,
                                                  player.team.name, time_s)
        switch_sentence = True
    teamkills = len([t for t in player.teamkill_times or [] if t >= time])
    if teamkills > 0:
        s = ', and killed' if switch_sentence else ' %s killed' % player_name
        message += s + ' %s teammates in the last %s' % (teamkills, minutes_s)
    if switch_sentence or teamkills > 0:
        message += '.'
    votekick = getattr(protocol, 'votekick', None)
    if (votekick and votekick.victim is player and votekick.victim.world_object
            and votekick.instigator.world_object):
        instigator = votekick.instigator
        tiles = int(
            distance_3d_vector(player.world_object.position,
                               instigator.world_object.position))
        instigator_name = (('\x0303' if instigator.team.id else '\x0302') +
                           instigator.name + '\x0f')
        message += (' %s is %d tiles away from %s, who started the votekick.' %
                    (player_name, tiles, instigator_name))
    return message
Example #14
0
def grief_check(connection, player, time = None):
    player = get_player(connection.protocol, player)
    protocol = connection.protocol
    color = connection not in protocol.players and connection.colors
    minutes = float(time or 2)
    if minutes < 0.0:
        raise ValueError()
    time = seconds() - minutes * 60.0
    blocks_removed = player.blocks_removed or []
    blocks = [b[1] for b in blocks_removed if b[0] >= time]
    player_name = player.name
    if color:
        player_name = (('\x0303' if player.team.id else '\x0302') +
            player_name + '\x0f')
    message = '%s removed %s block%s in the last ' % (player_name,
        len(blocks) or 'no', '' if len(blocks) == 1 else 's')
    if minutes == 1.0:
        minutes_s = 'minute'
    else:
        minutes_s = '%s minutes' % ('%f' % minutes).rstrip('0').rstrip('.')
    message += minutes_s + '.'
    if len(blocks):
        infos = set(blocks)
        infos.discard(None)
        if color:
            names = [('\x0303' if team else '\x0302') + name for name, team in
                infos]
        else:
            names = set([name for name, team in infos])
        namecheck = [[name, team, 0] for name, team in infos]
        if len(names) > 0:
            for f in range(len(namecheck)):
                for i in range(len(blocks_removed)):
                    if blocks_removed[i][1] is not None:
                        if namecheck[f][0] == blocks_removed[i][1][0] and namecheck[f][1] == blocks_removed[i][1][1] and blocks_removed[i][0] >= time:
                            namecheck[f][2] += 1
             
            message += (' Some of them were placed by ')
            for i in range(len(names)):
                message += ('\x0f, ' if color else ', ') + names[i] + "(" + str(namecheck[i][2]) + ")"
            userblocks = 0
            for i in range(len(namecheck)):
                userblocks = userblocks + namecheck[i][2]
            if userblocks == len(blocks):
                pass
            else:
                message += ('\x0f. ' if color else '. ') + str(len(blocks) - userblocks) + " were map blocks"
            message += '\x0f.' if color else '.'
        else:
            message += ' All of them were map blocks.'
        last = blocks_removed[-1]
        time_s = prettify_timespan(seconds() - last[0], get_seconds = True)
        message += ' Last one was destroyed %s ago' % time_s
        whom = last[1]
        if whom is None and len(names) > 0:
            message += ', and was part of the map'
        elif whom is not None:
            name, team = whom
            if color:
                name = ('\x0303' if team else '\x0302') + name + '\x0f'
            message += ', and belonged to %s' % name
        message += '.'
    switch_sentence = False
    if player.last_switch is not None and player.last_switch >= time:
        time_s = prettify_timespan(seconds() - player.last_switch,
            get_seconds = True)
        message += ' %s joined %s team %s ago' % (player_name,
            player.team.name, time_s)
        switch_sentence = True
    teamkills = len([t for t in player.teamkill_times or [] if t >= time])
    if teamkills > 0:
        s = ', and killed' if switch_sentence else ' %s killed' % player_name
        message += s + ' %s teammates in the last %s' % (teamkills, minutes_s)
    if switch_sentence or teamkills > 0:
        message += '.'
    votekick = getattr(protocol, 'votekick', None)
    if (votekick and votekick.victim is player and
        votekick.victim.world_object and votekick.instigator.world_object):
        instigator = votekick.instigator
        tiles = int(distance_3d_vector(player.world_object.position,
            instigator.world_object.position))
        instigator_name = (('\x0303' if instigator.team.id else '\x0302') +
            instigator.name + '\x0f')
        message += (' %s is %d tiles away from %s, who started the votekick.' %
            (player_name, tiles, instigator_name))
    return message
Example #15
0
 def network_update(self):
     delta = distance_3d_vector(self.last_position, self)
     if delta > SEND_THRESHOLD:
         self.last_moved = seconds()
         self.send_position()
         self.last_position.set_vector(self)
Example #16
0
 def on_hit(self, hit_amount, hit_player, type, grenade):
     body_damage_values = [49, 29, 27]
     limb_damage_values = [33, 18, 16]
     dist = int(
         distance_3d_vector(self.world_object.position,
                            hit_player.world_object.position))
     weap = self.weapon_object.name
     self.pres_time = seconds()
     if self.prev_time is None:
         dt = None
     else:
         dt = (self.pres_time - self.prev_time) * 1000
     self.prev_time = seconds()
     if weap == "SMG" or weap == "Rifle":
         if dt is not None and dt < 5:
             self.illegal_dt_count = self.illegal_dt_count + 1
     if weap == "Shotgun":
         if dist > 20:
             if dt < 8:
                 if hit_amount == self.spread_hit_amount and hit_player.name == self.spread_hit_player:
                     if type == HEADSHOT_KILL:
                         self.spread_hs_count = self.spread_hs_count + 1
                     elif hit_amount in body_damage_values:
                         self.spread_hs_count = self.spread_bs_count + 1
                     elif hit_amount in limb_damage_values:
                         self.spread_ls_count = self.spread_ls_count + 1
                 else:
                     self.spread_hs_count, self.spread_bs_count, self.spread_ls_count = 0, 0, 0
                     self.spread_hit_amount, self.spread_hit_player = None, None
             else:
                 self.spread_hs_count, self.spread_bs_count, self.spread_ls_count = 0, 0, 0
                 self.spread_hit_amount, self.spread_hit_player = hit_amount, hit_player.name
         else:
             self.spread_hs_count, self.spread_bs_count, self.spread_ls_count = 0, 0, 0
             self.spread_hit_amount, self.spread_hit_player = None, None
     self.local_variable = self.shots_analyzed_by
     for names in self.local_variable:
         adminz = get_player(self.protocol, names)
         if type == HEADSHOT_KILL:
             adminz.hs = adminz.hs + 1
             if dt is not None:
                 adminz.send_chat(
                     '%s shot %s dist: %d blocks dT: %.0f ms %s HEADSHOT(%d)'
                     % (self.name, hit_player.name, dist, dt, weap,
                        adminz.hs))
             else:
                 adminz.send_chat(
                     '%s shot %s dist: %d blocks dT: NA %s HEADSHOT(%d)'
                     % (self.name, hit_player.name, dist, weap,
                        adminz.hs))
         if hit_amount in body_damage_values:
             adminz.bs = adminz.bs + 1
             if dt is not None:
                 adminz.send_chat(
                     '%s shot %s dist: %d blocks dT: %.0f ms %s Body(%d)'
                     % (self.name, hit_player.name, dist, dt, weap,
                        adminz.bs))
             else:
                 adminz.send_chat(
                     '%s shot %s dist: %d blocks dT: NA %s Body(%d)' %
                     (self.name, hit_player.name, dist, weap,
                      adminz.bs))
         if hit_amount in limb_damage_values:
             adminz.ls = adminz.ls + 1
             if dt is not None:
                 adminz.send_chat(
                     '%s shot %s dist: %d blocks dT: %.0f ms %s Limb(%d)'
                     % (self.name, hit_player.name, dist, dt, weap,
                        adminz.ls))
             else:
                 adminz.send_chat(
                     '%s shot %s dist: %d blocks dT: NA %s Limb(%d)' %
                     (self.name, hit_player.name, dist, weap,
                      adminz.ls))
     if self.illegal_dt_count >= 5:
         self.ban('Hack Detected - Multiple Bullets', 10080)
         return False
     if self.spread_hs_count >= 7 or self.spread_bs_count >= 7 or self.spread_ls_count >= 7:
         self.ban('Hack Detected - No Spread', 10080)
         return False
     return connection.on_hit(self, hit_amount, hit_player, type,
                              grenade)
Example #17
0
 def network_update(self):
     delta = distance_3d_vector(self.last_position, self)
     if delta > SEND_THRESHOLD:
         self.last_moved = seconds()
         self.send_position()
         self.last_position.set_vector(self)