Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add QuestLogic and JournalData stuff #399

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 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: 1 addition & 1 deletion docs/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -697,7 +697,7 @@ def print_lf(lf):
[] if type_name not in ps.constructors else ps.constructors[type_name]
)
for var in ctors + type["vars"]:
if "comment" in var and "NoDoc" in var["comment"]:
if "comment" in var and var["comment"] and "NoDoc" in var["comment"]:
continue
var_name = var["name"]
search_link = (
Expand Down
25 changes: 17 additions & 8 deletions docs/parse_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -647,13 +647,18 @@ def run_parse():
cpp_type = type[2]
name = type[3]
attr = type[4]
extra_comments = {}
if container:
extra = []
n = re.findall(
r"(?<! NoDoc )" + container + r'\[([\w":]+)\] = ([^;]+);', data
r'(/// [\w _\-+<>.,`"\'=]*?)?' + container + r'\[([\w":]+)\] = ([^;]+);', data
)
for var in n:
extra.append(",".join(var))
if var[0].startswith("/// NoDoc"):
continue
if var[0]:
extra_comments[var[1].replace('"', '')] = var[0][4:]
extra.append(",".join(var[1:3]))
extra = ",".join(extra)
if attr:
attr = attr + "," + extra
Expand Down Expand Up @@ -711,9 +716,9 @@ def run_parse():
var[1] = var[1][:-1]

var_name = var[0]
cpp = replace_fun(var[1]) # should probably be done later, so the regex doesn't have to relay on some of the changes, also generate_emmylua.py uses some unique formats replacements
cpp = replace_fun(var[1]) #TODO: should probably be done later, so the regex doesn't have to relay on some of the changes, also generate_emmylua.py uses some unique formats replacements

if var[1].startswith("sol::property"):
if var[1].startswith("sol::property"): # fix for sol::property
param_match = re.match(
rf"property\(\[\]\({underlying_cpp_type['name']}&(\w+)\)",
cpp,
Expand Down Expand Up @@ -745,7 +750,7 @@ def run_parse():
"comment": fun["comment"],
}
)
elif cpp.startswith("[]("):
elif cpp.startswith("[]("): # lambdas
param_match = re.match(r"\[\]\(([\w &*:,]+)?\) -> ([\w.*&<>\?\[\]:]+)?(?: )?{", cpp)
if param_match:
ret = param_match.group(2)
Expand All @@ -764,7 +769,7 @@ def run_parse():
"name": var_name,
"type": cpp,
"signature": f"{ret} {var_name}({sig})",
"comment": "",
"comment": [extra_comments[var_name]] if var_name in extra_comments else [],
"function": True,
"cb_signature": "",
}
Expand All @@ -783,6 +788,8 @@ def run_parse():
if fun["comment"]
else None
)
if var_name in extra_comments:
fun["comment"].append(extra_comments[var_name])

vars.append(
{
Expand Down Expand Up @@ -817,6 +824,8 @@ def run_parse():
sig += underlying_cpp_var["name"][
underlying_cpp_var["name"].find("[") :
]
if var_name in extra_comments:
underlying_cpp_var["comment"].append(extra_comments[var_name])
vars.append(
{
"name": var_name,
Expand All @@ -833,10 +842,10 @@ def run_parse():
type = replace_fun(m_return_type[1])
sig = f"{type} {var_name}"
vars.append(
{"name": var_name, "type": cpp, "signature": sig}
{"name": var_name, "type": cpp, "signature": sig, "comment": [extra_comments[var_name]] if var_name in extra_comments else []}
)
else:
vars.append({"name": var_name, "type": cpp})
vars.append({"name": var_name, "type": cpp, "comment": [extra_comments[var_name]] if var_name in extra_comments else []})

if name in vtables_by_usertype:
vtable = vtables_by_usertype[name]
Expand Down
77 changes: 77 additions & 0 deletions docs/src/includes/_types.md
Original file line number Diff line number Diff line change
Expand Up @@ -779,6 +779,20 @@ Type | Name | Description
[ENT_TYPE](#ENT_TYPE) | [owner_type](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=owner_type) |
int | [owner_uid](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=owner_uid) |

### JournalPageData

Used in [SaveRelated](#SaveRelated)

Type | Name | Description
---- | ---- | -----------
int | [page_nr](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=page_nr) |
int | [sprite_id](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=sprite_id) |
[STRINGID](#Aliases) | [name](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=name) |
[STRINGID](#Aliases) | [description](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=description) |
float | [scale](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=scale) |
float | [offset_x](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=offset_x) |
float | [offset_y](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=offset_y) |

### KeyboardKey


Expand Down Expand Up @@ -1028,6 +1042,15 @@ Type | Name | Description
int | [column](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=column) |
int | [row](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=row) |

### StickersData

Used in [SaveRelated](#SaveRelated)

Type | Name | Description
---- | ---- | -----------
int | [sprite_id](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=sprite_id) |
[TEXTURE](#TEXTURE) | [texture](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=texture) |

### Triangle


Expand Down Expand Up @@ -1188,6 +1211,19 @@ array&lt;[ControllerInput](#ControllerInput), 12&gt; | [controller](https://gith
## Journal types


### JournalBestiaryData

Used in [SaveRelated](#SaveRelated)
Derived from [JournalPageData](#JournalPageData)


Type | Name | Description
---- | ---- | -----------
[TEXTURE](#TEXTURE) | [texture](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=texture) |
int | [background_sprite_id](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=background_sprite_id) |
bool | [killed_by_NA](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=killed_by_NA) |
bool | [defeated_NA](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=defeated_NA) |

### JournalPage

Used in [set_callback](#set_callback) with [ON](#ON).RENDER_POST_JOURNAL_PAGE
Expand Down Expand Up @@ -1368,6 +1404,31 @@ Type | Name | Description
[TextureRenderingInfo](#TextureRenderingInfo) | [trap_icon](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=trap_icon) |
[TextureRenderingInfo](#TextureRenderingInfo) | [trap_background](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=trap_background) |

### JournalPeopleData

Used in [SaveRelated](#SaveRelated)
Derived from [JournalPageData](#JournalPageData)


Type | Name | Description
---- | ---- | -----------
[TEXTURE](#TEXTURE) | [texture](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=texture) |
int | [background_sprite_id](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=background_sprite_id) |
bool | [killed_by_NA](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=killed_by_NA) |
bool | [defeated_NA](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=defeated_NA) |
[TEXTURE](#TEXTURE) | [portrait_texture](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=portrait_texture) |

### JournalTrapData

Used in [SaveRelated](#SaveRelated)
Derived from [JournalPageData](#JournalPageData)


Type | Name | Description
---- | ---- | -----------
[TEXTURE](#TEXTURE) | [texture](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=texture) |
int | [background_sprite_id](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=background_sprite_id) |

## Levelgen types


Expand Down Expand Up @@ -1966,6 +2027,7 @@ float | [sinewave_angle](https://github.com/spelunky-fyi/overlunky/search?l=Lua&

### JournalPopupUI

Used in [SaveRelated](#SaveRelated)

Type | Name | Description
---- | ---- | -----------
Expand Down Expand Up @@ -2052,10 +2114,21 @@ int | [visibility](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=visi

### SaveRelated

Used in [GameManager](#GameManager)

Type | Name | Description
---- | ---- | -----------
[JournalPopupUI](#JournalPopupUI) | [journal_popup_ui](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=journal_popup_ui) |
map&lt;int, [JournalPageData](#JournalPageData)&gt; | [places_data](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=places_data) | Scale and offset not used in those pages. Can't add more
map&lt;[ENT_TYPE](#ENT_TYPE), [JournalBestiaryData](#JournalBestiaryData)&gt; | [bestiary_data](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=bestiary_data) |
map&lt;[ENT_TYPE](#ENT_TYPE), [ENT_TYPE](#ENT_TYPE)&gt; | [monster_part_to_main](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=monster_part_to_main) | used to map stuff like Osiris_Hand -> Osiris_Head, [Hundun](#Hundun) limbs -> [Hundun](#Hundun) etc.
map&lt;[ENT_TYPE](#ENT_TYPE), [JournalPeopleData](#JournalPeopleData)&gt; | [people_info](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=people_info) |
map&lt;[ENT_TYPE](#ENT_TYPE), [ENT_TYPE](#ENT_TYPE)&gt; | [people_part_to_main](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=people_part_to_main) | used to map shopkeeper clone to shopkeeper only
map&lt;[ENT_TYPE](#ENT_TYPE), [JournalPageData](#JournalPageData)&gt; | [item_info](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=item_info) |
map&lt;[ENT_TYPE](#ENT_TYPE), [JournalPageData](#JournalPageData)&gt; | [trap_info](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=trap_info) |
map&lt;[ENT_TYPE](#ENT_TYPE), [ENT_TYPE](#ENT_TYPE)&gt; | [trap_part_to_main](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=trap_part_to_main) | used for stuff like upsidedown_spikes -> spikes, skulldrop skulls -> skulldrop trap etc.
map&lt;[ENT_TYPE](#ENT_TYPE), [StickersData](#StickersData)&gt; | [stickers_data](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=stickers_data) |
[SaveData](#SaveData) | [get_savegame()](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=get_savegame) | Gets local version of the [SaveData](#SaveData)

### Screen

Expand Down Expand Up @@ -2306,6 +2379,10 @@ array&lt;float, MAX_PLAYERS&gt; | [player_quickselect_wiggle_angle](https://gith
float | [topleft_woodpanel_esc_slidein](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=topleft_woodpanel_esc_slidein) |
float | [start_panel_slidein](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=start_panel_slidein) |
float | [action_buttons_keycap_size](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=action_buttons_keycap_size) |
bool | [screen_loading](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=screen_loading) |
bool | [seeded_run](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=seeded_run) |
bool | [daily_challenge](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=daily_challenge) |
bool | [arena](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=arena) | Short for `screen->next_screen_to_load == SCREEN.TEAM_SELECT and not screen->seeded_run and not screen->daily_challenge`
int | [next_screen_to_load](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=next_screen_to_load) |
bool | [not_ready_to_start_yet](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=not_ready_to_start_yet) |
int | [available_mine_entrances](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=available_mine_entrances) |
Expand Down
2 changes: 2 additions & 0 deletions src/game_api/drops.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,8 @@ std::vector<DropEntry> drop_entries{
/// Special:
///

/// Change item used to open the door (still requires hedjet, crown or eggplant crown)
{"DOOR_COG_SCEPTER", "\x81\x78\x14\x4C\x02\x00\x00"sv, VTABLE_OFFSET::FLOOR_DOOR_COG, 25, 3, 2}, // is not the exact virtual, but function that the virtual uses
/// It's not ENT_TYPE but amount of health, with elixir it will be this value * 2
{"MOTHERSTATUE_HEALTH", "\xBD\x04\x00\x00\x00\xD3"sv, VTABLE_OFFSET::FLOOR_MOTHER_STATUE, 2, 1},
/// It's not ENT_TYPE but amount of health, with elixir it will be this value * 2
Expand Down
81 changes: 77 additions & 4 deletions src/game_api/game_manager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@
#include <cstddef> // for size_t
#include <cstdint> // for uint32_t, uint8_t, int8_t

#include "aliases.hpp" // for MAX_PLAYERS
#include "render_api.hpp" // for TextureRenderingInfo
#include "sound_manager.hpp"
#include "thread_utils.hpp" // for OnHeapPointer
#include "aliases.hpp" // for MAX_PLAYERS
#include "containers/game_unordered_map.hpp" // for game_unordered_map
#include "containers/identity_hasher.hpp" // for identity_hasher
#include "render_api.hpp" // for TextureRenderingInfo
#include "sound_manager.hpp" // for BackgroundSound
#include "thread_utils.hpp" // for OnHeapPointer

struct SaveData;
class ScreenCamp;
Expand Down Expand Up @@ -35,12 +37,83 @@ struct JournalPopupUI
uint32_t timer;
float slide_position;
uint8_t unknown;
// uint8_t padding[3]; // probably?
};

class JournalPageData
{
public:
uint32_t page_nr;
uint32_t sprite_id;
STRINGID name;
STRINGID description;
float scale;
float offset_x;
float offset_y;
};

class JournalPeopleData : public JournalPageData
{
public:
TEXTURE texture;
uint32_t background_sprite_id;
bool killed_by_NA;
bool defeated_NA;
// uint16_t padding;
TEXTURE portrait_texture;
};

// probably same as JournalPeopleData, just not using portrait_texture
class JournalBestiaryData : public JournalPageData
{
public:
TEXTURE texture;
uint32_t background_sprite_id;
bool killed_by_NA;
bool defeated_NA;
};

// this is probably part of JournalPageData, just only used for bestiary, people and trap
class JournalTrapData : public JournalPageData
{
public:
TEXTURE texture;
uint32_t background_sprite_id;
};

struct StickersData
{
uint32_t sprite_id;
TEXTURE texture;
};

struct SaveRelated
{
OnHeapPointer<SaveData> savedata;
JournalPopupUI journal_popup_ui;

ENT_TYPE player_entity; // for the journal stuff, probably the leader?
ENT_TYPE progress_stickers_powerups[29]; // pre-journal progress setup, maybe gathering from all players or something?

/// Scale and offset not used in those pages. Can't add more
game_unordered_map<uint8_t, JournalPageData, identity_hasher<>> places_data;
game_unordered_map<ENT_TYPE, JournalBestiaryData, identity_hasher<>> bestiary_data;
/// used to map stuff like Osiris_Hand -> Osiris_Head, Hundun limbs -> Hundun etc.
game_unordered_map<ENT_TYPE, ENT_TYPE, identity_hasher<>> monster_part_to_main;
game_unordered_map<ENT_TYPE, JournalPeopleData, identity_hasher<>> people_info;
/// used to map shopkeeper clone to shopkeeper only
game_unordered_map<ENT_TYPE, ENT_TYPE, identity_hasher<>> people_part_to_main;
game_unordered_map<ENT_TYPE, JournalPageData, identity_hasher<>> item_info;
game_unordered_map<ENT_TYPE, JournalPageData, identity_hasher<>> trap_info;
/// used for stuff like upsidedown_spikes -> spikes, skulldrop skulls -> skulldrop trap etc.
game_unordered_map<ENT_TYPE, ENT_TYPE, identity_hasher<>> trap_part_to_main;
game_unordered_map<ENT_TYPE, StickersData, identity_hasher<>> stickers_data;

/// Gets local version of the SaveData
SaveData* get_savegame()
{
return savedata.decode_local();
}
};

struct BGMUnknown
Expand Down
Loading
Loading