Guest User

Rogue Legacy Save Editor Source Code

a guest
Aug 15th, 2013
736
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 9.93 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.IO;
  6.  
  7. namespace Boost
  8. {
  9.     class Program
  10.     {
  11.         public static void Main(string[] args)
  12.         {
  13.             Console.WriteLine("Welcome to Rogue Legacy Savegame Editor");
  14.  
  15.             int input = -1;
  16.  
  17.             while (input != 0)
  18.             {
  19.                 Console.WriteLine("What would you like to do? (enter a number)");
  20.                 Console.WriteLine("1 - Give me money");
  21.                 Console.WriteLine("2 - Unlock Gear & Enchantments");
  22.                 Console.WriteLine("3 - Boost my stats");
  23.                 Console.WriteLine("4 - Supercharge my stats");
  24.                 Console.WriteLine("0 - Exit");
  25.                 input = Convert.ToInt32(Console.ReadLine());
  26.  
  27.                 switch (input)
  28.                 {
  29.                     case 0:
  30.                         break;
  31.                     case 1:
  32.                         Money();
  33.                         Console.WriteLine("Money Given\n");
  34.                         break;
  35.                     case 2:
  36.                         GearAndEnchantments();
  37.                         Console.WriteLine("Gear & Enchantments Given\n");
  38.                         break;
  39.                     case 3:
  40.                         Boost();
  41.                         Console.WriteLine("Boosted\n");
  42.                         break;
  43.                     case 4:
  44.                         SuperBoost();
  45.                         Console.WriteLine("SuperBoosted\n");
  46.                         break;
  47.                 }
  48.  
  49.             }
  50.         }
  51.  
  52.         protected static void Money()
  53.         {
  54.             try
  55.             {
  56.                 // Create a copy of the file that we will be adjusting, just to be safe.
  57.                 File.Delete(@".\Backup-RogueLegacyPlayer.rcdat");
  58.                 File.Copy(@".\RogueLegacyPlayer.rcdat", @".\Backup-RogueLegacyPlayer.rcdat");
  59.  
  60.                 // Open the backup copy of the file. This file will not be edited, just read.
  61.                 BinaryReader reader = new BinaryReader(new FileStream(@".\Backup-RogueLegacyPlayer.rcdat", FileMode.Open), new ASCIIEncoding());
  62.  
  63.                 // Open the other file for writing.
  64.                 BinaryWriter writer = new BinaryWriter(new FileStream(@".\RogueLegacyPlayer.rcdat", FileMode.Truncate));
  65.  
  66.                 writer.Write(2000000000); reader.ReadInt32(); // money
  67.  
  68.                 while (reader.PeekChar() != -1) // Everything else
  69.                     writer.Write(reader.ReadByte());
  70.  
  71.                 reader.Close();
  72.                 writer.Close();
  73.  
  74.             }
  75.             catch (FileNotFoundException ex)
  76.             {
  77.                 Console.WriteLine("Error: " + ex.ToString());
  78.             }
  79.         }
  80.         protected static void Boost()
  81.         {
  82.             try
  83.             {
  84.                 // Create a copy of the file that we will be adjusting, just to be safe.
  85.                 File.Delete(@".\Backup-RogueLegacyPlayer.rcdat");
  86.                 File.Copy(@".\RogueLegacyPlayer.rcdat", @".\Backup-RogueLegacyPlayer.rcdat");
  87.  
  88.                 // Open the backup copy of the file. This file will not be edited, just read.
  89.                 BinaryReader reader = new BinaryReader(new FileStream(@".\Backup-RogueLegacyPlayer.rcdat", FileMode.Open), new ASCIIEncoding());
  90.  
  91.                 // Open the other file for writing.
  92.                 BinaryWriter writer = new BinaryWriter(new FileStream(@".\RogueLegacyPlayer.rcdat", FileMode.Truncate));
  93.  
  94.  
  95.                 /* The basic idea here is to use the reader to read data from the backup save and use the writer
  96.                  * to write most of that same data to the new save file. The data which is entered manually and not from the reader
  97.                  * is what makes the differences in the new save file.
  98.                  */
  99.                 writer.Write(reader.ReadInt32()); // money
  100.                 writer.Write(reader.ReadInt32()); // currentHealth
  101.                 writer.Write(reader.ReadInt32()); // currentMana
  102.                 writer.Write(reader.ReadByte());
  103.                 writer.Write(reader.ReadByte());
  104.                 writer.Write(reader.ReadByte()); // spell
  105.                 writer.Write(reader.ReadByte()); // class
  106.                 writer.Write(reader.ReadByte()); // special item
  107.                 writer.Write(reader.ReadByte()); // trait 0
  108.                 writer.Write(reader.ReadByte()); // trait 1
  109.                 Byte nameLength = reader.ReadByte();
  110.                 writer.Write(nameLength);
  111.                 writer.Write(reader.ReadChars(nameLength)); // name
  112.                 writer.Write(reader.ReadByte());
  113.                 writer.Write(reader.ReadByte());
  114.                 writer.Write(reader.ReadByte());
  115.                 writer.Write(reader.ReadByte()); // diary entries
  116.                 writer.Write(reader.ReadInt32() + 20); // bonus health
  117.                 writer.Write(reader.ReadInt32() + 10); // bonus strength
  118.                 writer.Write(reader.ReadInt32() + 20); // bonus mana
  119.                 writer.Write(reader.ReadInt32() + 20); // bonus defence
  120.                 writer.Write(reader.ReadInt32()); // bonus weight
  121.                 writer.Write(reader.ReadInt32() + 10); // bonus magic
  122.  
  123.                 while (reader.PeekChar() != -1) // Everything else
  124.                     writer.Write(reader.ReadByte());
  125.  
  126.                 reader.Close();
  127.                 writer.Close();
  128.  
  129.             }
  130.             catch (FileNotFoundException ex)
  131.             {
  132.                 Console.WriteLine("Error: " + ex.ToString());
  133.             }
  134.         }
  135.         protected static void SuperBoost()
  136.         {
  137.             try
  138.             {
  139.                 // Create a copy of the file that we will be adjusting, just to be safe.
  140.                 File.Delete(@".\Backup-RogueLegacyPlayer.rcdat");
  141.                 File.Copy(@".\RogueLegacyPlayer.rcdat", @".\Backup-RogueLegacyPlayer.rcdat");
  142.  
  143.                 // Open the backup copy of the file. This file will not be edited, just read.
  144.                 BinaryReader reader = new BinaryReader(new FileStream(@".\Backup-RogueLegacyPlayer.rcdat", FileMode.Open), new ASCIIEncoding());
  145.  
  146.                 // Open the other file for writing.
  147.                 BinaryWriter writer = new BinaryWriter(new FileStream(@".\RogueLegacyPlayer.rcdat", FileMode.Truncate));
  148.  
  149.  
  150.                 /* The basic idea here is to use the reader to read data from the backup save and use the writer
  151.                  * to write most of that same data to the new save file. The data which is entered manually and not from the reader
  152.                  * is what makes the differences in the new save file.
  153.                  */
  154.                 writer.Write(reader.ReadInt32()); // money
  155.                 writer.Write(reader.ReadInt32()); // currentHealth
  156.                 writer.Write(reader.ReadInt32()); // currentMana
  157.                 writer.Write(reader.ReadByte());
  158.                 writer.Write(reader.ReadByte());
  159.                 writer.Write(reader.ReadByte()); // spell
  160.                 writer.Write(reader.ReadByte()); // class
  161.                 writer.Write((Byte)4); reader.ReadByte(); // special item
  162.                 writer.Write((Byte)16); reader.ReadByte(); // trait 0
  163.                 writer.Write((Byte)23); reader.ReadByte(); // trait 1
  164.                 Byte nameLength = reader.ReadByte();
  165.                 writer.Write(nameLength);
  166.                 writer.Write(reader.ReadChars(nameLength)); // name
  167.                 writer.Write(reader.ReadByte());
  168.                 writer.Write(reader.ReadByte());
  169.                 writer.Write(reader.ReadByte());
  170.                 writer.Write((Byte)25); reader.ReadByte(); // diary entries
  171.                 writer.Write(10000); reader.ReadInt32(); // bonus health
  172.                 writer.Write(1000); reader.ReadInt32(); // bonus strength
  173.                 writer.Write(10000); reader.ReadInt32(); // bonus mana
  174.                 writer.Write(1000); reader.ReadInt32(); // bonus defence
  175.                 writer.Write(500); reader.ReadInt32(); // bonus weight
  176.                 writer.Write(1000); reader.ReadInt32(); // bonus magic
  177.  
  178.                 while (reader.PeekChar() != -1) // Everything else
  179.                     writer.Write(reader.ReadByte());
  180.  
  181.                 reader.Close();
  182.                 writer.Close();
  183.  
  184.             }
  185.             catch (FileNotFoundException ex)
  186.             {
  187.                 Console.WriteLine("Error: " + ex.ToString());
  188.             }
  189.         }
  190.         protected static void GearAndEnchantments()
  191.         {
  192.             try
  193.             {
  194.                 // Create a copy of the file that we will be adjusting, just to be safe.
  195.                 File.Delete(@".\Backup-RogueLegacyBP.rcdat");
  196.                 File.Copy(@".\RogueLegacyBP.rcdat", @".\Backup-RogueLegacyBP.rcdat");
  197.  
  198.                 // Open the backup copy of the file. This file will not be edited, just read.
  199.                 BinaryReader reader = new BinaryReader(new FileStream(@".\Backup-RogueLegacyBP.rcdat", FileMode.Open), new ASCIIEncoding());
  200.  
  201.                 // Open the other file for writing.
  202.                 BinaryWriter writer = new BinaryWriter(new FileStream(@".\RogueLegacyBP.rcdat", FileMode.Truncate));
  203.  
  204.                 // Write 3 to the first 130 bytes. 130 bytes for the (5 * 15) equipment from the blacksmith and (5 * 11) for all of the
  205.                 //  runes from the enchantress. 3 is the value of the enum meaning purchased.
  206.                 for (int i = 0; i < 5 * 15 + 5 * 11; i++)
  207.                     writer.Write((Byte)3);
  208.                
  209.                 // Then read past the first 130 bytes
  210.                 reader.ReadBytes(130);
  211.  
  212.                 while (reader.PeekChar() != -1) // Everything else
  213.                     writer.Write(reader.ReadByte());
  214.  
  215.                 reader.Close();
  216.                 writer.Close();
  217.  
  218.             }
  219.             catch (FileNotFoundException ex)
  220.             {
  221.                 Console.WriteLine("Error: " + ex.ToString());
  222.             }
  223.         }
  224.     }
  225. }
Advertisement
Add Comment
Please, Sign In to add comment