def teleport_to(destination): _validate_position(destination) # Write new position to memory base_address = multi_level_pointers.entity_base.address for dimension in ['x', 'y', 'z']: address = base_address + entity_base_offsets[dimension] data = c_float(getattr(destination, dimension)) write_address(address, data)
def last_cmd(self): # Write '' to memory if self._last_cmd: writable_address = single_level_pointers.last_cmd.address data = NULL_BUFFER write_address(writable_address, data) ret = self._last_cmd self._last_cmd = '' return ret
def _write_jump_dir(self, new_dir, jump_num): # Reset grav every time player lands jump_num = str(jump_num) player_jumping = self._jump_grav_start != 0 already_updated_jump_pull = self._has_updated_jump_pull[jump_num] if player_jumping and not already_updated_jump_pull: new_dir *= JUMP_DIR_PULL writable_address = multi_level_pointers.entity_base.address writable_address += client_offsets['jump_dir_' + jump_num] data = c_float(new_dir) write_address(writable_address, data) self._has_updated_jump_pull[jump_num] = True elif not player_jumping: print 'reset' self._has_updated_jump_pull[jump_num] = False return new_dir
def _rotate(position, destination, threshold=0.04): logger.debug('rotating') radian_diff = -math.atan2(destination.y - position.y, destination.x - position.x) next_heading = MovementEngine.radians_to_heading(radian_diff) next_heading = round(next_heading, 2) logger.debug('converted %f (%d degrees) to %f', radian_diff, math.degrees(radian_diff), next_heading) logger.debug('next heading: %f', next_heading) # Avoid needless rotate if abs(next_heading - position.heading) <= threshold: return # Write new heading to memory heading_address = multi_level_pointers.entity_base.address heading_address += entity_base_offsets.heading data = c_float(next_heading) write_address(heading_address, data) KeyboardInput.key_press('a', delay=50)
def set_target(target_address): writable_address = single_level_pointers.player_target.address data = c_ulonglong(target_address) write_address(writable_address, data)
def player_speed(self, new_speed): if new_speed != self._player_speed: writable_address = single_level_pointers.player_speed.address data = c_float(self.player_speed) write_address(writable_address, data)