quae

manual.csx

Dec 5th, 2018 (edited)
821
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.48 KB | None | 0 0
  1. // Restores Ralsei's manual as a readable book. Only works with the 2018 SURVEY_PROGRAM demo.
  2.  
  3. EnsureDataLoaded();
  4.  
  5. var scr_itemuse = Data.Scripts.ByName("scr_itemuse")?.Code;
  6. if (scr_itemuse == null)
  7.   throw new Exception("scr_itemuse not found");
  8.  
  9. bool patched = false;
  10. for (int i = 0; i < scr_itemuse.Instructions.Count; i++) {
  11.   // there's a good chance of this breaking if scr_itemuse has already been modified.
  12.   // let's just hope that's not the case.
  13.   if (scr_itemuse.Instructions[i].Kind == UndertaleInstruction.Opcode.Pop &&
  14.       scr_itemuse.Instructions[i].Destination.Target.Name.Content == "interact" &&
  15.       scr_itemuse.Instructions[i-4].Kind == UndertaleInstruction.Opcode.Call &&
  16.       scr_itemuse.Instructions[i-4].Function.Target.Name.Content == "scr_itemcomment" &&
  17.       scr_itemuse.Instructions[i+28].Kind == UndertaleInstruction.Opcode.Call &&
  18.       scr_itemuse.Instructions[i+28].Function.Target.Name.Content == "instance_create") {
  19.  
  20.     patched = true;
  21.     if ((short)scr_itemuse.Instructions[i-1].Value == 1 && (short)scr_itemuse.Instructions[i+22].Value == 130) {
  22.       ScriptMessage("Already patched!");
  23.     } else {
  24.       scr_itemuse.Instructions[i-1].Value = (short)1; // global.interact = 1
  25.       scr_itemuse.Instructions[i+22].Value = (short)130; // set first arg of instance_create to obj_ralseibook
  26.       ScriptMessage("Patched!");
  27.     }
  28.     break;
  29.   }
  30. }
  31. if (!patched)
  32.   throw new Exception("Patch point not found");
  33.  
  34. ChangeSelection(scr_itemuse);
Advertisement
Add Comment
Please, Sign In to add comment