Skip to content

Commit

Permalink
Merge pull request #319 from Cosine256/expose-journal-fields
Browse files Browse the repository at this point in the history
Expose journal fields
  • Loading branch information
Dregu authored Sep 2, 2023
2 parents 40018a6 + 050e2ca commit b00b1a1
Show file tree
Hide file tree
Showing 8 changed files with 124 additions and 26 deletions.
23 changes: 23 additions & 0 deletions docs/game_data/spel2.lua

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions docs/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -592,6 +592,8 @@ def print_lf(lf):
"Camera",
"QuestsInfo",
"PlayerSlot",
"JournalProgressStickerSlot",
"JournalProgressStainSlot"
]
):
cat = "State types"
Expand Down
2 changes: 1 addition & 1 deletion docs/src/includes/_enums.md
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ Name | Data | Description

Name | Data | Description
---- | ---- | -----------
[DAMSEL_STYLE](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=GAME_SETTING.DAMSEL_STYLE) | 0 |
[WINDOW_SCALE](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=GAME_SETTING.WINDOW_SCALE) | 0 |
...check [game_settings.txt](game_data/game_settings.txt)... | |
[CROSSPROGRESS_AUTOSYNC](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=GAME_SETTING.CROSSPROGRESS_AUTOSYNC) | 47 |

Expand Down
33 changes: 33 additions & 0 deletions docs/src/includes/_types.md
Original file line number Diff line number Diff line change
Expand Up @@ -2423,6 +2423,33 @@ int | [leader](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=leader)
array<[Inventory](#Inventory), MAX_PLAYERS> | [player_inventory](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=player_inventory) |
array<[SelectPlayerSlot](#SelectPlayerSlot), MAX_PLAYERS> | [player_select](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=player_select) |

### JournalProgressStainSlot

Used in [StateMemory](#StateMemory)

Type | Name | Description
---- | ---- | -----------
float | [x](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=x) |
float | [y](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=y) |
float | [angle](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=angle) |
float | [scale](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=scale) |
int | [texture_column](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=texture_column) |
int | [texture_row](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=texture_row) |
int | [texture_range](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=texture_range) |

### JournalProgressStickerSlot

Used in [StateMemory](#StateMemory)

Type | Name | Description
---- | ---- | -----------
int | [theme](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=theme) |
int | [grid_position](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=grid_position) |
[ENT_TYPE](#ENT_TYPE) | [entity_type](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=entity_type) |
float | [x](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=x) |
float | [y](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=y) |
float | [angle](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=angle) |

### PlayerSlot


Expand Down Expand Up @@ -2570,6 +2597,12 @@ int | [time_startup](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=ti
int | [storage_uid](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=storage_uid) | entity uid of the first floor_storage entity
array<[ENT_TYPE](#ENT_TYPE), 99> | [waddler_storage](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=waddler_storage) |
array<int, 99> | [waddler_metadata](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=waddler_metadata) |
int | [journal_progress_sticker_count](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=journal_progress_sticker_count) |
array<[JournalProgressStickerSlot](#JournalProgressStickerSlot), 40> | [journal_progress_sticker_slots](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=journal_progress_sticker_slots) | stickers for notable items and entities in journal progress page
int | [journal_progress_stain_count](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=journal_progress_stain_count) |
array<[JournalProgressStainSlot](#JournalProgressStainSlot), 30> | [journal_progress_stain_slots](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=journal_progress_stain_slots) | blood splats and paw prints in journal progress page
int | [journal_progress_theme_count](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=journal_progress_theme_count) |
array<int, 9> | [journal_progress_theme_slots](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=journal_progress_theme_slots) | visited themes in journal progress page
[ThemeInfo](#ThemeInfo) | [theme_info](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=theme_info) | Points to the current [ThemeInfo](#ThemeInfo)
[LogicList](#LogicList) | [logic](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=logic) | Level logic like dice game and cutscenes
[LiquidPhysics](#LiquidPhysics) | [liquid](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=liquid) |
Expand Down
2 changes: 1 addition & 1 deletion src/game_api/script/lua_vm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2468,7 +2468,7 @@ end

/// Paramater to get_setting (and set_setting in unsafe mode)
lua.create_named_table("GAME_SETTING"
//, "DAMSEL_STYLE", 0
//, "WINDOW_SCALE", 0
//, "", ...check__[game_settings.txt]\[game_data/game_settings.txt\]...
//, "CROSSPROGRESS_AUTOSYNC", 47
);
Expand Down
40 changes: 40 additions & 0 deletions src/game_api/script/usertypes/state_lua.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,40 @@ void register_usertypes(sol::state& lua)
arenastate_type["breath_cooldown"] = &ArenaState::breath_cooldown;
arenastate_type["punish_ball"] = &ArenaState::punish_ball;

/// Used in StateMemory
lua.new_usertype<JournalProgressStickerSlot>(
"JournalProgressStickerSlot",
"theme",
&JournalProgressStickerSlot::theme,
"grid_position",
&JournalProgressStickerSlot::grid_position,
"entity_type",
&JournalProgressStickerSlot::entity_type,
"x",
&JournalProgressStickerSlot::x,
"y",
&JournalProgressStickerSlot::y,
"angle",
&JournalProgressStickerSlot::angle);

/// Used in StateMemory
lua.new_usertype<JournalProgressStainSlot>(
"JournalProgressStainSlot",
"x",
&JournalProgressStainSlot::x,
"y",
&JournalProgressStainSlot::y,
"angle",
&JournalProgressStainSlot::angle,
"scale",
&JournalProgressStainSlot::scale,
"texture_column",
&JournalProgressStainSlot::texture_column,
"texture_row",
&JournalProgressStainSlot::texture_row,
"texture_range",
&JournalProgressStainSlot::texture_range);

/// Used in Items
lua.new_usertype<SelectPlayerSlot>(
"SelectPlayerSlot",
Expand Down Expand Up @@ -357,6 +391,12 @@ void register_usertypes(sol::state& lua)
statememory_type["storage_uid"] = &StateMemory::waddler_floor_storage;
statememory_type["waddler_storage"] = &StateMemory::waddler_storage;
statememory_type["waddler_metadata"] = &StateMemory::waddler_storage_meta;
statememory_type["journal_progress_sticker_count"] = &StateMemory::journal_progress_sticker_count;
statememory_type["journal_progress_sticker_slots"] = &StateMemory::journal_progress_sticker_slots;
statememory_type["journal_progress_stain_count"] = &StateMemory::journal_progress_stain_count;
statememory_type["journal_progress_stain_slots"] = &StateMemory::journal_progress_stain_slots;
statememory_type["journal_progress_theme_count"] = &StateMemory::journal_progress_theme_count;
statememory_type["journal_progress_theme_slots"] = &StateMemory::journal_progress_theme_slots;
statememory_type["theme_info"] = &StateMemory::current_theme;
statememory_type["logic"] = &StateMemory::logic;
statememory_type["liquid"] = &StateMemory::liquid_physics;
Expand Down
19 changes: 12 additions & 7 deletions src/game_api/state.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include <vector> // for vector

#include "aliases.hpp" // for ENT_TYPE, LAYER
#include "state_structs.hpp" // for JournalProgressionSlot, Illumination (p...
#include "state_structs.hpp" // for JournalProgressStickerSlot, Illumination (p...

class Entity;
class ScreenArenaIntro;
Expand Down Expand Up @@ -160,12 +160,17 @@ struct StateMemory
uint8_t unknown2d;
std::array<ENT_TYPE, 99> waddler_storage;
std::array<int16_t, 99> waddler_storage_meta; // to store mattock durability for example
uint16_t journal_progression_count;
std::array<JournalProgressionSlot, 40> journal_progression_slots;
uint8_t death_screen_blood_splats_count;
uint8_t skip2[3]; // padding
std::array<DeathScreenBloodSlot, 30> death_screen_blood_splats;
ThemeProgression theme_progression;
uint8_t journal_progress_sticker_count;
uint8_t padding4;
/// stickers for notable items and entities in journal progress page
std::array<JournalProgressStickerSlot, 40> journal_progress_sticker_slots;
uint8_t journal_progress_stain_count;
uint8_t padding5[3];
/// blood splats and paw prints in journal progress page
std::array<JournalProgressStainSlot, 30> journal_progress_stain_slots;
uint8_t journal_progress_theme_count;
/// visited themes in journal progress page
std::array<uint8_t, 9> journal_progress_theme_slots;
uint8_t unknown3;
uint8_t unknown4;
uint8_t unknown5a;
Expand Down
29 changes: 12 additions & 17 deletions src/game_api/state_structs.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,22 +187,28 @@ struct Camera
uint32_t unknown7;
};

struct JournalProgressionSlot
struct JournalProgressStickerSlot
{
uint8_t unknown1;
uint8_t theme;
int8_t grid_position; // -1 = unassigned, will be assigned when opening the journal and gets the zoom effect
uint8_t unknown3;
uint8_t unknown4;
ENT_TYPE entity;
ENT_TYPE entity_type;
float x;
float y;
float angle;
};

struct ThemeProgression
struct JournalProgressStainSlot
{
uint8_t count;
uint8_t visited_themes[9];
float x;
float y;
float angle;
float scale;
int32_t texture_column;
int32_t texture_row;
uint8_t texture_range; // when stain is first displayed, rolls [0, texture_range] and adds it to texture_column
uint8_t padding[3];
};

struct ArenaConfigArenas // size: 40 bytes
Expand Down Expand Up @@ -995,14 +1001,3 @@ struct MultiLineTextRendering
float x; // center of the text box?
float z; // center of the text box?
};

struct DeathScreenBloodSlot
{
float x;
float y;
float size_x; /* Unsure */
float size_y; /* Unsure */
int32_t texture_column; // normally set to 4
int32_t texture_row; // normally set to 5
int32_t texture_range; // when the death screens renders it rools 0 to this value, normally the value is 2 so it can roll 0, 1, or 2 (?)
};

0 comments on commit b00b1a1

Please sign in to comment.