Skip to content

Commit

Permalink
Add unlockables
Browse files Browse the repository at this point in the history
  • Loading branch information
Dregu committed Aug 25, 2024
1 parent 8d009e1 commit ab97866
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 1 deletion.
4 changes: 4 additions & 0 deletions max.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -543,6 +543,10 @@ State Max::state() {

Minimap Max::minimap() { return *(size_t *)get_address("slots") + 0x2490b8; }

SaveData *Max::save() {
return (SaveData *)(*(size_t *)get_address("slots") + 0x400);
}

uint8_t *Max::slot_number() {
return (uint8_t *)(*(size_t *)get_address("slots") + 0x40c);
}
Expand Down
14 changes: 14 additions & 0 deletions max.h
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,19 @@ struct Kangaroo {
uint8_t state;
};

struct SaveData {
uint32_t version;
uint32_t achievements;
uint32_t seed;
uint8_t slot;
uint8_t hash;
bool edited;
uint8_t unknown;
uint32_t unlockables;
// Slot slot[3];
// Options options;
};

// TODO: This is a horrible prototype still
struct Max {
static Max &get();
Expand All @@ -246,6 +259,7 @@ struct Max {
Minimap minimap();
uint8_t *slot_number();
Slot slot();
SaveData *save();
Player player();
S32Vec2 *player_room();
FVec2 *player_position();
Expand Down
62 changes: 61 additions & 1 deletion ui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,19 @@ std::array progress_names{
"Game Started", "Unknown", "Ready to hatch", "Show HP", "Drop House Key",
};

std::array unlockable_names{
"Stopwatch", "Pedometer",
"Pink phone", "Souvenir Cup",
"Origami Fig.", "Rabbits Fig.",
"Owl Fig.", "Cat Fig.",
"Fish Fig.", "Donkey Fig.",
"Decorative Rabbit", "Mama Cha",
"Giraffe Fig.", "Incense Burner",
"Peacock Fig.", "Otter Fig.",
"Duck Fig.", "",
"Pedometer wingding", "",
};

const std::map<std::string, PLAYER_INPUT> notes{
{"A4", (PLAYER_INPUT)(PLAYER_INPUT::RIGHT | PLAYER_INPUT::LB)},
{"A#4",
Expand Down Expand Up @@ -1339,7 +1352,54 @@ void UI::DrawPlayer() {
}
}
} else if (*Max::get().equipment() == 0) {
*Max::get().item() == 0;
*Max::get().item() = 0;
}
if (ImGui::CollapsingHeader("Unlockables")) {
ImGui::PushID("GlobalUnlockables");
auto *save = Max::get().save();
DebugPtr(&save->unlockables);
bool all = (save->unlockables & 0x5ffff) == 0x5ffff;
if (ImGui::Checkbox("Unlock all unlockables##UnlockAllUnlockables", &all)) {
if (all) {
save->unlockables = 0x5ffff;
} else {
save->unlockables = 0;
}
}
ImGui::Separator();
auto goto_item =
Flags(unlockable_names, &save->unlockables, false, 0, true);
if (goto_item != -1) {
static const std::array<TargetTile, 32> item_tiles{{
{583, 12, 5, 2}, // stopwatch
{799, 0, 2, 0}, // pedometer
{795}, // pink phone
{231}, // souvenir cup
{619, 0, 2, 3}, // origami
{818, 0, 0, 0, 1}, // rabbits
{237, 0, 12, 16, 0}, // owl
{237, 0, 19, 14, 0}, // cat
{237, 0, 12, 16, 2}, // fish
{237, 0, 19, 14, 2}, // donkey
{237, 0, 5, 14, 2}, // decorabbit
{811, 0, 0, 1}, // mama cha
{169}, // giraffe (flute)
{237, 0, 5, 14, 0}, // incense burner
{799, 0, 2, 0}, // peacock (pedometer)
{799, 0, 2, 0}, // otter (pedometer)
{169}, // duck (flute)
{u16_max}, // unused
{799, 0, 2, 0}, // pedometer wingding
{u16_max}, // unused
}};
auto tileId = item_tiles[goto_item].tile;
auto tile = GetNthTile(tileId, item_tiles[goto_item].n,
item_tiles[goto_item].map);
if (tile.has_value())
WarpToTile(tile.value(), item_tiles[goto_item].x,
item_tiles[goto_item].y);
}
ImGui::PopID();
}
ImGui::PopItemWidth();
}
Expand Down

0 comments on commit ab97866

Please sign in to comment.