Skip to content

Commit

Permalink
Merge pull request #8 from kel-z/dev
Browse files Browse the repository at this point in the history
v0.2.0: Reimplement character scan
  • Loading branch information
kel-z authored Jul 29, 2023
2 parents d5fcc32 + 9622f36 commit 96c0957
Show file tree
Hide file tree
Showing 13 changed files with 4,434 additions and 4,334 deletions.
31 changes: 20 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
# Honkai: Star Rail - Data Scanner

Easily export light cones, relics, and character data from Honkai: Star Rail to JSON format using OCR.

## Installation

If you haven't already, download and install [Microsoft Visual C++ Redistributable for Visual Studio 2015-2022](https://docs.microsoft.com/en-us/cpp/windows/latest-supported-vc-redist?view=msvc-170#visual-studio-2015-2017-2019-and-2022) (x86 or x64 depending on system).

[Download latest HSR Scanner](https://github.com/kel-z/HSR-Scanner/releases/latest) and then run as administrator (required to simulate keyboard and mouse presses).

## Instructions

1. Set in-game resolution to one that has an aspect ratio of 16:9 (e.g. 1920x1080, 1280x720).
<!-- - Changing off from an ultra-wide resolution requires a game restart to reset the UI layout. -->
<!-- ^^ wait... is this a thing in Star Rail? I know it was for Genshin -->
2. **In Star Rail, look away from any bright colours.** *Yes, really.* The inventory screen is translucent and bright colours can bleed through to make the text harder to accurately detect and recognize. Looking towards the ground usually works in most cases, as long as the right side of the screen is relatively dark. (Double-check by opening the inventory page and see if the item info on the right contrasts well with the background.) You can skip this step if you're only scanning characters.
<!-- - Changing off from an ultra-wide resolution requires a game restart to reset the UI layout. -->
<!-- ^^ wait... is this a thing in Star Rail? I know it was for Genshin -->
2. **In Star Rail, look away from any bright colours.** _Yes, really._ The inventory screen is translucent and bright colours can bleed through to make the text harder to accurately detect and recognize. Looking towards the ground usually works in most cases, as long as the right side of the screen is relatively dark. (Double-check by opening the inventory page and see if the item info on the right contrasts well with the background.) You can skip this step if you're only scanning characters.
3. Open the cellphone menu (ESC menu).
4. Configure the necessary [scanner settings](#scanner-settings-and-configurations) in HSR Scanner.
5. Start the scan.
Expand All @@ -26,17 +29,21 @@ HSR Scanner has the following scan options:
- Filter light cones and relics based on a minimum rarity or level threshhold.

## Output

The output is loosely based off of Genshin's `.GOOD` export format. **Please note that the current output format is subject to change.**

### Notes

- Flat sub-stats and percentage sub-stats are differentiated by an underscore suffix in the key.
- Main stats will never have an underscore suffix.
- The `_id` value for light cones and relics is arbitrarily assigned during the scanning process. It is intended for easy lookup in case of any errors logged during the scan, for double-checking or manual correction purposes.
- For character traces, `ability_#` and `stat_#` are ordered by earliest availability (i.e. `stat_1` can be unlocked at Ascension 0, but `stat_2` requires Ascension 2).
- In the case of ties, namely two stat bonuses *X* and *Y* that both unlock at the same Ascension level, the one that visually connects to the highest `stat_#` on the in-game character traces page comes first. For example, if a stat bonus *X* connects to `stat_2` and stat bonus *Y* connects to `stat_1`, then *X* would be `stat_3` and *Y* would be `stat_4`.
- If *X* and *Y* both connect to the same `stat_#` (only found in Erudition), then visually assign from top to bottom.
- In the case of ties, namely two stat bonuses _X_ and _Y_ that both unlock at the same Ascension level, the one that visually connects to the highest `stat_#` on the in-game character traces page comes first. For example, if a stat bonus _X_ connects to `stat_2` and stat bonus _Y_ connects to `stat_1`, then _X_ would be `stat_3` and _Y_ would be `stat_4`.
- If _X_ and _Y_ both connect to the same `stat_#` (only found in Erudition), then visually assign from top to bottom.
- The exact string values used can be found [here](src/utils/game_data_helpers.py).

Current output sample:
Current output sample:

```
{
"light_cones": [
Expand All @@ -47,7 +54,7 @@ Current output sample:
"superimposition": 2,
"location": "Seele",
"lock": true,
"_id": "light_cone_0"
"_id": "light_cone_1"
},
{
"key": "Meshing Cogs",
Expand All @@ -56,7 +63,7 @@ Current output sample:
"superimposition": 5,
"location": "",
"lock": true,
"_id": "light_cone_1"
"_id": "light_cone_2"
}
],
"relics": [
Expand Down Expand Up @@ -86,7 +93,7 @@ Current output sample:
],
"location": "Bronya",
"lock": true,
"_id": "relic_0"
"_id": "relic_1"
},
{
"setKey": "Thief of Shooting Meteor",
Expand All @@ -106,7 +113,7 @@ Current output sample:
],
"location": "",
"lock": false,
"_id": "relic_1"
"_id": "relic_2"
}
],
"characters": [
Expand Down Expand Up @@ -164,10 +171,12 @@ Current output sample:
"stat_10": false
}
}
],
]
}
```

Check [sample_output.json](sample_output.json) for a full-sized, unfiltered example.

## Dev notes

- This app relies on reading text from images captured during the scan process, as opposed to reading directly from memory. As a result, OCR is prone to errors, especially given the variability of relic sub-stats and lack of a model optimized for Star Rail. It also doesn't help that the inventory screen is translucent, as mentioned in step two of [instructions](#instructions). This issue can be alleviated via error-checking in future releases once every possible sub-stat value is known and can be checked against.
Loading

0 comments on commit 96c0957

Please sign in to comment.