Skip to content

Instantly share code, notes, and snippets.

@cympfh
Created January 20, 2022 17:56
Show Gist options
  • Save cympfh/3dc18c1ca21f328a525a0e11cbf70c31 to your computer and use it in GitHub Desktop.
Save cympfh/3dc18c1ca21f328a525a0e11cbf70c31 to your computer and use it in GitHub Desktop.
Original source code is available on https://www.speedrun.com/katamarireroll/resources . This script is patched for `start` and `reset`.
state("katamari")
{
byte levelID: "mono.dll", 0x0265110, 0x90, 0x10, 0x28, 0x408;
int frames: "mono.dll", 0x00265110, 0x90, 0x30, 0x20, 0x50, 0x51c;
float size: "PS2KatamariSimulation.dll", 0x16d77c;
int stage: "UnityPlayer.dll", 0x13FB8F8;
int newGameDialog: "UnityPlayer.dll", 0x0144F148, 0x14;
int newGameDialogValue: "mono.dll", 0x00268698, 0x190, 0x38, 0x268, 0xA40;
}
startup
{
settings.Add("splitOnMAS", true, "Split after MAS1-9");
settings.Add("splitOnBear", false, "Split after Ursa Major", "splitOnMAS");
}
init
{
print("Init! splitOnMAS=" + settings["splitOnMAS"] + ", splitOnBear=" + settings["splitOnBear"]);
refreshRate = 30;
vars.LEVEL_ID_URSA = 17;
vars.STAGE_ID_RESULTS = 114;
vars.STAGE_ID_OVERWORLD = 29;
vars.STAGE_ID_MAS1 = 1;
vars.STAGE_ID_MAS9 = 9;
vars.onResultsStage = false;
vars.alreadySplitAt300m = false;
vars.NEW_GAME_DIALOG_OPEN = 10167;
vars.NEW_GAME_DIALOG_CLOSED = 10162;
vars.NEW_GAME_DIALOG_VALUE_YES = 257;
vars.NEW_GAME_DIALOG_VALUE_NO = 1;
}
start
{
// On my PC, `newGameDialogValue` is doubtful...
// Ignore it!
if (old.newGameDialog == vars.NEW_GAME_DIALOG_OPEN && current.newGameDialog == vars.NEW_GAME_DIALOG_CLOSED) {
print("Let's Start!!");
return true;
} else {
return false;
}
return old.newGameDialog == vars.NEW_GAME_DIALOG_OPEN &&
current.newGameDialog == vars.NEW_GAME_DIALOG_CLOSED &&
old.newGameDialogValue == vars.NEW_GAME_DIALOG_VALUE_YES;
}
reset
{
if (old.newGameDialog == vars.NEW_GAME_DIALOG_OPEN && current.newGameDialog == vars.NEW_GAME_DIALOG_CLOSED) {
print("Restart");
return true;
} else {
return false;
}
}
isLoading
{
return current.frames == old.frames;
}
split
{
if (current.stage == vars.STAGE_ID_RESULTS) {
vars.onResultsStage = true;
return false;
}
if (current.stage == vars.STAGE_ID_OVERWORLD && vars.onResultsStage == true) {
vars.onResultsStage = false;
if (settings["splitOnMAS"] &&
current.levelID >= vars.STAGE_ID_MAS1 &&
current.levelID <= vars.STAGE_ID_MAS9
) {
return true;
}
if (settings["splitOnBear"] && current.levelID == vars.LEVEL_ID_URSA) {
return true;
}
return false;
}
if (!vars.alreadySplitAt300m && current.levelID == 10 && current.size >= 30000) {
vars.alreadySplitAt300m = true;
return true;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment