Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Restores Ralsei's manual as a readable book. Only works with the 2018 SURVEY_PROGRAM demo.
- EnsureDataLoaded();
- var scr_itemuse = Data.Scripts.ByName("scr_itemuse")?.Code;
- if (scr_itemuse == null)
- throw new Exception("scr_itemuse not found");
- bool patched = false;
- for (int i = 0; i < scr_itemuse.Instructions.Count; i++) {
- // there's a good chance of this breaking if scr_itemuse has already been modified.
- // let's just hope that's not the case.
- if (scr_itemuse.Instructions[i].Kind == UndertaleInstruction.Opcode.Pop &&
- scr_itemuse.Instructions[i].Destination.Target.Name.Content == "interact" &&
- scr_itemuse.Instructions[i-4].Kind == UndertaleInstruction.Opcode.Call &&
- scr_itemuse.Instructions[i-4].Function.Target.Name.Content == "scr_itemcomment" &&
- scr_itemuse.Instructions[i+28].Kind == UndertaleInstruction.Opcode.Call &&
- scr_itemuse.Instructions[i+28].Function.Target.Name.Content == "instance_create") {
- patched = true;
- if ((short)scr_itemuse.Instructions[i-1].Value == 1 && (short)scr_itemuse.Instructions[i+22].Value == 130) {
- ScriptMessage("Already patched!");
- } else {
- scr_itemuse.Instructions[i-1].Value = (short)1; // global.interact = 1
- scr_itemuse.Instructions[i+22].Value = (short)130; // set first arg of instance_create to obj_ralseibook
- ScriptMessage("Patched!");
- }
- break;
- }
- }
- if (!patched)
- throw new Exception("Patch point not found");
- ChangeSelection(scr_itemuse);
Advertisement
Add Comment
Please, Sign In to add comment