def _get_class_id(self): vtable = win32.read_memory(self.game, self._get_offset() + 0x08, 'i') get_client_class = win32.read_memory(self.game, vtable + 0x08, 'i') get_client_class_pointer = win32.read_memory(self.game, get_client_class + 0x01, 'i') return win32.read_memory(self.game, get_client_class_pointer + 0x14, 'i')
def is_visible_fov(self, entity): if not self.is_alive(): return False mask = win32.read_memory( self.game, entity._get_offset() + self.offset['netvars']['m_bSpottedByMask'], 'i') base = win32.read_memory(self.game, self._get_offset() + 0x64, 'i') - 1 return (mask & (1 << base)) > 0
def get_name(self): convar_name_entry = win32.read_memory(self.pycsapi.game, self.address + 0xc, 'i') convar_name = '' for i in range(constant.CONVAR_NAME_SIZE): char = win32.read_memory(self.pycsapi.game, convar_name_entry + i, 'c') if char == b'\x00': break convar_name += char.decode() return convar_name
def get_punch(self): x, y = 0.0, 0.0 if not self.is_alive(): return (x, y) x = win32.read_memory( self.game, self._get_offset() + self.offset['netvars']['m_aimPunchAngle'], 'f') y = win32.read_memory( self.game, self._get_offset() + self.offset['netvars']['m_aimPunchAngle'] + constant.TYPE_FLOAT_SIZE, 'f') return (x, y)
def get_view_angle(self): x, y = 0.0, 0.0 if not self.player.is_alive(): return (x, y) x = win32.read_memory( self.game, self._get_engine_pointer() + self.offset['signatures']['dwClientState_ViewAngles'], 'f') y = win32.read_memory( self.game, self._get_engine_pointer() + self.offset['signatures']['dwClientState_ViewAngles'] + constant.TYPE_FLOAT_SIZE, 'f') return (x, y)
def get_string(self): convar_string_entry = win32.read_memory(self.pycsapi.game, self.address + 0x24, 'i') convar_string = '' for i in range(constant.CONVAR_STRING_SIZE): char = win32.read_memory(self.pycsapi.game, convar_string_entry + i, 'c') if char == b'\x00': break try: convar_string += char.decode() except: break return convar_string
def get_weapon(self): if not self.is_player() or not self.is_alive(): return 0 active_weapon = win32.read_memory( self.game, self._get_offset() + self.offset['netvars']['m_hActiveWeapon'], 'i') & 0xFFF entity = win32.read_memory( self.game, self.client + self.offset['signatures']['dwEntityList'] + ((active_weapon - 1) * constant.ENTITY_SIZE), 'i') return win32.read_memory( self.game, entity + self.offset['netvars']['m_iItemDefinitionIndex'], 'i')
def set_string(self, value): convar_string_entry = win32.read_memory(self.pycsapi.game, self.address + 0x24, 'i') win32.write_memory(self.pycsapi.game, convar_string_entry, value, 'c', len(value)) for i in range(len(value), constant.CONVAR_STRING_SIZE): char = win32.read_memory(self.pycsapi.game, convar_string_entry + i, 'c') if char != b'\x00': win32.write_memory(self.pycsapi.game, convar_string_entry + i, 0, 'b') else: break return True
def get_max_players(self): if not self.get_player().is_in_game(): return 0 return win32.read_memory( self.game, self._get_engine_pointer() + self.offset['signatures']['dwClientState_MaxPlayer'], 'i')
def get_origin(self): x, y, z = 0.0, 0.0, 0.0 if not self.is_alive(): return (x, y, z) x = win32.read_memory( self.game, self._get_offset() + self.offset['netvars']['m_vecOrigin'], 'f') y = win32.read_memory( self.game, self._get_offset() + self.offset['netvars']['m_vecOrigin'] + constant.TYPE_FLOAT_SIZE, 'f') z = win32.read_memory( self.game, self._get_offset() + self.offset['netvars']['m_vecOrigin'] + constant.TYPE_FLOAT_SIZE * 2, 'f') return (x, y, z)
def is_dormant(self): if not self.is_player() or not self.is_alive(): return False return win32.read_memory( self.game, self._get_offset() + self.offset['netvars']['m_bGunGameImmunity'], 'b') == constant.STATE_DORMANT
def is_scoped(self): if not self.is_player() or not self.is_alive(): return False return win32.read_memory( self.game, self._get_offset() + self.offset['netvars']['m_bIsScoped'], 'b') == constant.STATE_SCOPED
def is_has_helmet(self): if not self.is_player() or not self.is_alive(): return False return bool( win32.read_memory( self.game, self._get_offset() + self.offset['netvars']['m_bHasHelmet'], 'b'))
def get_entity(self): return Entity( self.pycsapi, self, win32.read_memory( self.game, self._get_engine_pointer() + self.offset['signatures']['dwClientState_GetLocalPlayer'], 'i') + 1)
def get_health(self): if self.player.is_in_game() and self.get_team_id(): health = win32.read_memory( self.game, self._get_offset() + self.offset['netvars']['m_iHealth'], 'i') if 100 >= health > 0: return health return 0
def load(self): convar_base = win32.find_pattern( self.pycsapi.game, constant.VSTDLIB_DLL, constant.PATTERN_CONVAR, True) + constant.PATTERN_CONVAR_OFFSET convar_base_pointer = win32.read_memory(self.pycsapi.game, convar_base, 'i') short_cuts = win32.read_memory(self.pycsapi.game, convar_base_pointer + 0x34, 'i') hash_map_entry = win32.read_memory(self.pycsapi.game, short_cuts, 'i') while hash_map_entry: convar_address = win32.read_memory(self.pycsapi.game, hash_map_entry + 0x4, 'i') convar = Convar(self.pycsapi, convar_address) if convar.get_name(): self.convars[convar.get_name()] = convar hash_map_entry = win32.read_memory(self.pycsapi.game, hash_map_entry + 0x4, 'i')
def get_team_id(self): if self.player.is_in_game(): state = win32.read_memory( self.game, self._get_offset() + self.offset['netvars']['m_iTeamNum'], 'i') if state == constant.TEAM_ID_SPECTATOR or state == constant.TEAM_ID_T or state == constant.TEAM_ID_CT: return state return 0
def get_crosshair_entity(self): if not self.is_alive(): return None id = win32.read_memory( self.game, self._get_offset() + self.offset['netvars']['m_iCrosshairId'], 'i') if not id: return None return Entity(self.pycsapi, self, id)
def get_spectator_target(self): if not self.player.is_in_game() or self.is_alive(): return False return Entity( self.pycsapi, self.player, win32.read_memory( self.game, self._get_offset() + self.offset['netvars']['m_hObserverTarget'], 'i') & 0xFFF)
def set_glow(self, color=(255, 255, 255, 255)): if not self.player.is_alive() or not self.is_alive( ) or not self.player.get_team_id(): return False if len(color) == 3: color = (color[0], color[1], color[2], 255) elif len(color) != 4: color = (255, 255, 255, 255) r, g, b, a = color[0] / 255, color[1] / 255, color[2] / 255, color[ 3] / 255 if r > 1.0 or r < 0.0: r = 1.0 if g > 1.0 or g < 0.0: g = 1.0 if b > 1.0 or b < 0.0: b = 1.0 if a > 1.0 or a < 0.0: a = 1.0 entity_glow_index = win32.read_memory( self.game, self._get_offset() + self.offset['netvars']['m_iGlowIndex'], 'i') glow_pointer = win32.read_memory( self.game, self.client + self.offset['signatures']['dwGlowObjectManager'], 'i') win32.write_memory( self.game, glow_pointer + (entity_glow_index * constant.GLOW_INDEX_SIZE) + constant.TYPE_FLOAT_SIZE, r, 'f') win32.write_memory( self.game, glow_pointer + (entity_glow_index * constant.GLOW_INDEX_SIZE) + constant.TYPE_FLOAT_SIZE * 2, g, 'f') win32.write_memory( self.game, glow_pointer + (entity_glow_index * constant.GLOW_INDEX_SIZE) + constant.TYPE_FLOAT_SIZE * 3, b, 'f') win32.write_memory( self.game, glow_pointer + (entity_glow_index * constant.GLOW_INDEX_SIZE) + constant.TYPE_FLOAT_SIZE * 4, a, 'f') win32.write_memory( self.game, glow_pointer + (entity_glow_index * constant.GLOW_INDEX_SIZE) + 0x24, 1, 'i') win32.write_memory( self.game, glow_pointer + (entity_glow_index * constant.GLOW_INDEX_SIZE) + 0x25, 0, 'i') return True
def is_able_to_shoot(self): if not self.is_alive(): return False active_weapon = win32.read_memory( self.game, self._get_offset() + self.offset['netvars']['m_hActiveWeapon'], 'i') & 0xFFF entity = win32.read_memory( self.game, self.client + self.offset['signatures']['dwEntityList'] + ((active_weapon - 1) * constant.ENTITY_SIZE), 'i') next_attack = win32.read_memory( self.game, entity + self.offset['netvars']['m_flNextPrimaryAttack'], 'f') server_time = win32.read_memory( self.game, self._get_offset() + self.offset['netvars']['m_nTickBase'], 'i') * constant.INTERVAL_PER_TICK return next_attack <= server_time
def get_view_matrix(self): matrix = [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]] if not self.get_player().is_alive(): return matrix for row in range(4): for column in range(4): matrix[row][column] = win32.read_memory( self.game, self.client + self.offset['signatures']['dwViewMatrix'] + ((row * 4) + (column)) * constant.TYPE_FLOAT_SIZE, 'f') return matrix
def get_game_dir(self): name = '' if not self.get_player().is_in_game(): return name for char in win32.read_memory( self.game, self.engine + self.offset['signatures']['dwGameDir'], 'c', constant.GAME_DIR_SIZE): if char == b'\x00': return name name += char.decode() return name
def get_collision(self): x_min, y_min, z_min, x_max, y_max, z_max = 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 if not self.is_alive(): return ((x_min, y_min, z_min), (x_max, y_max, z_max)) x_min = win32.read_memory( self.game, self._get_offset() + self.offset['netvars']['m_Collision'] + constant.VEC_MIN, 'f') y_min = win32.read_memory( self.game, self._get_offset() + self.offset['netvars']['m_Collision'] + constant.VEC_MIN + constant.TYPE_FLOAT_SIZE, 'f') z_min = win32.read_memory( self.game, self._get_offset() + self.offset['netvars']['m_Collision'] + constant.VEC_MIN + constant.TYPE_FLOAT_SIZE * 2, 'f') x_max = win32.read_memory( self.game, self._get_offset() + self.offset['netvars']['m_Collision'] + constant.VEC_MAX, 'f') y_max = win32.read_memory( self.game, self._get_offset() + self.offset['netvars']['m_Collision'] + constant.VEC_MAX + constant.TYPE_FLOAT_SIZE, 'f') z_max = win32.read_memory( self.game, self._get_offset() + self.offset['netvars']['m_Collision'] + constant.VEC_MAX + constant.TYPE_FLOAT_SIZE * 2, 'f') return ((x_min, y_min, z_min), (x_max, y_max, z_max))
def get_map_directory(self): name = '' if not self.get_player().is_in_game(): return name for char in win32.read_memory( self.game, self._get_engine_pointer() + self.offset['signatures']['dwClientState_MapDirectory'], 'c', constant.MAP_DIRECTORY_SIZE): if char == b'\x00': return name name += char.decode() return name
def get_position(self, bone_id=constant.HITBOX_ID_HEAD): x, y, z = 0.0, 0.0, 0.0 if not self.is_alive(): return (x, y, z) if self.player.get_entity().get_id() == self.get_id(): x = win32.read_memory( self.game, self._get_offset() + self.offset['netvars']['m_vecOrigin'], 'f') y = win32.read_memory( self.game, self._get_offset() + self.offset['netvars']['m_vecOrigin'] + constant.TYPE_FLOAT_SIZE, 'f') z = win32.read_memory( self.game, self._get_offset() + self.offset['netvars']['m_vecOrigin'] + constant.TYPE_FLOAT_SIZE * 2, 'f') + win32.read_memory( self.game, self._get_offset() + self.offset['netvars']['m_vecViewOffset'] + constant.TYPE_FLOAT_SIZE * 2, 'f') else: entity_bones = win32.read_memory( self.game, self._get_offset() + self.offset['netvars']['m_dwBoneMatrix'], 'i') x = win32.read_memory( self.game, entity_bones + constant.BONE_MATRIX_SIZE * bone_id + 0x0C, 'f') y = win32.read_memory( self.game, entity_bones + constant.BONE_MATRIX_SIZE * bone_id + 0x1C, 'f') z = win32.read_memory( self.game, entity_bones + constant.BONE_MATRIX_SIZE * bone_id + 0x2C, 'f') return (x, y, z)
def get_int(self): return win32.read_memory(self.pycsapi.game, self.address + 0x30, 'i') - self.address
def get_float(self): return win32.read_memory(self.pycsapi.game, self.address + 0x2C, 'f') - self.address
def is_in_game(self): return win32.read_memory( self.game, self._get_engine_pointer() + self.offset['signatures']['dwClientState_State'], 'i') == constant.STATE_IN_GAME_CONNECTED
def get_flags(self): return util.ConvarFlags( win32.read_memory(self.pycsapi.game, self.address + 0x14, 'i'))