Elden Ring#
This module contains the game interface for Elden Ring.
- class soulsgym.games.eldenring.EldenRing#
Bases:
GameElden Ring game interface.
- __init__()#
Create a new EldenRing game interface and set the game speed to 1.0.
- property img: ndarray#
Get the current game image as numpy array.
Warning
If the game was paused (i.e.
game_speed = 0) before the current`Gameinstance has been created, this method won’t return. The game needs to be unpaused at least once before invoking this method.Images have a shape of [90, 160, 3] with RGB channels.
- property img_resolution: tuple[int, int]#
The game image resolution.
Note
This is NOT the game resolution. The game image resolution is the resolution of the image returned by :meth:.EldenRing.img.
- Returns:
The game resolution.
- property player_hp: int#
The player’s current hit points.
- Returns:
The player’s current hit points.
- property player_sp: int#
The player’s current stamina points.
- Returns:
The player’s current stamina points.
- property player_mp: int#
The player’s current mana points.
- Returns:
The player’s current mana points.
- property player_max_hp: int#
The player’s maximum hit points.
- Returns:
The player’s maximum hit points.
- property player_max_sp: int#
The player’s maximum stamina points.
- Returns:
The player’s maximum stamina points.
- property player_max_mp: int#
The player’s maximum mana points.
- Returns:
The player’s maximum mana points.
- reset_player_hp()#
Reset the player’s hit points to its current maximum.
- reset_player_sp()#
Reset the player’s stamina points to its current maximum.
- reset_player_mp()#
Reset the player’s mana points to its current maximum.
- property player_pose: ndarray#
The player’s current pose.
Poses are the combination of position and rotation. In the case of game entities (e.g. the player or bosses) the rotation is given as a single angle in radians around the z axis.
Setting the player’s pose is more complex than just overwriting the pose values. The player might be killed if the teleported distance is interpreted as a fall. We save the player death game flag, disable player deaths and gravity, set the coordinates and restore the player death flag to its previous state. Gravity is always enabled after a teleport.
Warning
Pose modifications are particularly affected by race conditions!
- Returns:
The current player pose as [x, y, z, a].
- property player_animation: int#
The player’s current animation ID.
Note
The player animation cannot be overwritten.
- Returns:
The player’s current animation ID.
- property allow_player_death: bool#
Disable/enable player deaths ingame.
- property player_stats: tuple[int]#
The current player stats from the game.
The stats can be overwritten by a tuple of matching dimension (9) and order. Stats are ordered as follows: Soul Level, Vigor, Mind, Endurance, Strength, Dexterity, Intelligence, Faith, Arcane.
- Returns:
A tuple with all player attributes in the same order as in the game.
- property camera_pose: ndarray#
Read the camera’s current position and rotation.
The camera orientation is specified as the normal of the camera plane. Since the plane never rotates around this normal the camera pose is fully specified by this 3D vector.
- Returns:
The current camera rotation as normal vector and position as coordinates [x, y, z, nx, ny, nz].
- property is_ingame: bool#
Flag that checks if the player is currently loaded into the game.
- Returns:
True if the player is ingame, else False.
- property last_bonfire: int#
The bonfire name the player has rested at last.
The bonfire name has to be in the
bonfiresdictionary.- Returns:
The bonfire name.
- property lock_on: bool#
The player’s current lock on status.
Note
Lock on cannot be set.
- Returns:
True if the player is currently locked on a target, else False.
- property gravity: bool#
The current gravity activation status.
- Returns:
True if gravity is active, else False.
- property allow_weapon_durability_dmg: bool#
Legacy parameter to comply with souls games that have weapon durability models.
- Returns:
Always false.
- reload()#
Kill the player, clear the address cache and wait for the player to respawn.
- property time: int#
Ingame time.
Measured as the current game save play time in milliseconds.
Note
Also increases when global game speed is set to 0, but should not increase during lags.
Warning
Possibly overflows after 1193h of play time.
- Returns:
The current game time.
- static timed(tend: int, tstart: int) float#
Safe game time difference function.
If time has overflowed, uses 0 as best guess for tstart. Divides by 1000 to get the time difference in seconds.
- Parameters:
tend – End time.
tstart – Start time.
- Returns:
The time difference.
- sleep(t: float)#
Custom sleep function.
Guarantees the specified time has passed in ingame time.
- Parameters:
t – Time interval in seconds.
- property game_speed: float#
The game loop speed.
Note
Setting this value to 0 will effectively pause the game. Default speed is 1.
Warning
The process slows down with game speeds lower than 1. Values close to 0 may cause windows to assume the process has frozen.
Warning
Values significantly higher than 1 (e.g. 5+) may not be achievable for the game loop. This is probably dependant on the available hardware.
- Returns:
The game loop speed.
- Raises:
ValueError – The game speed was set to negative values.