Driver
Driver is one of the core modules of the library.
The main purpose of the module is to encapsulate the low-level interactions with the game client's memory and provide an interface for accessing and manipulating game data.
Key responsibilities include:
- Memory access and manipulation
- Game entity management
- Process interaction handling
Important implementation details
The GameDriver
class automatically handles the following scenarios:
- Game client recreation
- Local player change
- Logging out & Logging in
The driver detects any of these events and automatically reinitiates affected dependencies.
icecap.infrastructure.driver
The module provides low-level tooling for interacting with the game client.
Classes:
-
GameDriver
–Provides an interface to interact with the game's memory and objects.
-
ObjectManager
–Represents the Object Manager in the game client.
GameDriver
GameDriver(
game_process_manager: GameProcessManager, memory_manager_getter: MemoryManagerGetter
)
Provides an interface to interact with the game's memory and objects.
It serves as the main entry point for low-level accessing game data and functionality.
Source code in icecap/infrastructure/driver/driver.py
game_process_manager
instance-attribute
game_process_manager: GameProcessManager = game_process_manager
Game process manager for interacting with the game process.
memory_manager
property
memory_manager: MemoryManager
A memory manager instance for accessing the game's memory.
The attribute may return different objects depending on the state of the driver.
memory_manager_getter
instance-attribute
Callable that returns a MemoryManager instance for the game process.
This is used to access the game's memory and objects. Can't use static memory_manager because game process may change.
name_resolver
property
name_resolver: NameResolver
A name resolver instance for resolving names of game entities.
The attribute may return different objects depending on the state of the driver.
object_manager
property
object_manager: ObjectManager
The object manager instance for accessing the game's objects.
The attribute may return different objects depending on the state of the driver.
get_client_connection_address
get_client_connection_address() -> int
This method reads the client connection address from memory using a static offset.
get_local_player_guid
get_local_player_guid() -> int
Retrieve the GUID of the local player using a static offset.
Uses static offset which is less reliable than dynamic address, but it is faster and does not require reading the object manager.
This is useful for quick checks or when the object manager is not available. For example, this can be used to check if the player is in the game world.
Source code in icecap/infrastructure/driver/driver.py
is_game_running
is_game_running() -> bool
is_player_in_game
is_player_in_game() -> bool
Check if the player is in the game world.
This method uses the local player GUID to determine if the player is in the game. The GUID is non-zero only when the player is in the game.
Source code in icecap/infrastructure/driver/driver.py
ObjectManager
ObjectManager(memory_manager: MemoryManager, address: int, max_objects: int = 1000)
Represents the Object Manager in the game client.
The Object Manager is responsible for keeping track of all game objects, units, and players in the game world. This class provides methods to access and interact with these entities through memory reading operations.
Source code in icecap/infrastructure/driver/object_manager.py
get_entity_position
get_entity_position(entity: Entity) -> ObjectPosition
Retrieve the position of an entity in the game world.
This method reads the entity's position data from memory and returns it as an ObjectPosition object containing x, y, z coordinates and rotation.
Source code in icecap/infrastructure/driver/object_manager.py
get_game_object_fields
get_game_object_fields(entity: Entity) -> GameObjectFields
Retrieve the game object fields of a game object entity.
This method reads the game object's field data from memory and returns it as a GameObjectFields object that corresponds to the C struct definition.
Source code in icecap/infrastructure/driver/object_manager.py
get_local_player_guid
get_local_player_guid() -> int
Retrieve the GUID of the local player using a dynamic address.
This method uses a dynamic address that should be more reliable than static offsets. It reads the local player GUID directly from the object manager.
Source code in icecap/infrastructure/driver/object_manager.py
get_map_id
get_map_id() -> int
Retrieve the map ID from the object manager.
It can be used to identify the current map and get extra information from the map database.
Source code in icecap/infrastructure/driver/object_manager.py
get_unit_fields
get_unit_fields(entity: Entity) -> UnitFields
Retrieve the unit fields of an entity.
This method reads the unit's field data from memory and returns it as a UnitFields object that corresponds to the C struct definition.
Source code in icecap/infrastructure/driver/object_manager.py
yield_objects
Yield all objects in the Object Manager.
This method iterates through the linked list of objects in the Object Manager and yields each one as an Entity object.