Wasteland 3 Pointer Table

Upload your cheat tables here (No requests)
Post Reply
kaptain kek
Cheater
Cheater
Posts: 26
Joined: Thu Mar 16, 2017 12:15 pm
Reputation: 16

Re: Wasteland 3 Pointer Table

Post by kaptain kek »

ADDING ITEMS TO INVENTORY GUIDE

This only works on Steam and GOG version. XGP has different saves

Big thanks to u/JitterJohn on the wasteland 3 subreddit for taking his time, he's responsible for most of the code. Also big thanks to Chaser324 on Github for his CLZF2 decompress script.

Using this method you are able to add any item to your inventory.

1. First, you will need to download LINGpad5. Yes, version 5. You can find it here: [Link]

2. Open LINQpad5, and set the Laguange to C# Program.

3. Copy this code into LINGpad5.

Code: Select all

void Main()
{
	//Be carefull when editing quicksaves, the backup can be out-of-date if you never delete it.
	var saveName = "your save file name all lower case";
	
	//The names of the characters that will be edited.
	//Unique characters like Marshal Kwon don't have a display name. 
	// *THIS IS LEFT OVER FROM JITTERJOHNS CODE. Not relevant to item adding. Leave it in and ignore.
	var pcNames = new HashSet<string> { "asdfeagfdfsdgs", "lkjhoisdgreczhk" };
	
	var path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), @"My Games\Wasteland3\Save Games\", saveName, saveName + ".bak");
	if(!File.Exists(path))
	{
		File.Copy(Path.ChangeExtension(path, ".xml"), path);
	}
	var saveData = Load(path);
	var xml = saveData.SaveState;
	//Dumps the xml part of the save to a new output panel with syntax highlighting.
	//PanelManager.DisplaySyntaxColoredText(xml.ToString(), SyntaxLanguageStyle.XML); return;
	//I was trying to get quantity working, however never got it to work. Ignore quantity.
	foreach (string item in File.ReadAllLines(@"C:\path\to\you\items\.txt")){
	var sp = item.Split(',');
string itemname = sp[0];
int qty = 1;
try { int.TryParse(sp[1], out qty); } catch {}
	xml.Root.Element("hostInventory")
		.Add(new XElement("item",
			new XElement("templateName", itemname),
			new XElement("slot", 0),
			new XElement("ammoLoaded", 0),
			new XElement("quantity", 1),
			new XElement("uid", Guid.NewGuid()),
			new XElement("isLockedForMerchant", false),
			new XElement("merchantBarterLevelRequirement", 0)));
			}

	
	Save(Path.ChangeExtension(saveData.Path, ".xml"), saveData);
}

public static void DuplicateMods(SaveData saveData, int duplicateCount)
{
	var items = saveData.SaveState.Root.Element("hostInventory");
	foreach (var item in items.Descendants("item").Where(itm => itm.Element("templateName").Value.Contains("Mod_")).ToList())
	{
		var templateName = item.Element("templateName").Value;
		while (items.Descendants("item").Where(itm => itm.Element("templateName").Value.Equals(templateName, StringComparison.Ordinal)).Count() < duplicateCount)
		{
			var copy = new XElement(item);
			copy.SetElementValue("uid", Guid.NewGuid());
			items.Add(copy);
		}
	}
}


public sealed class SaveData 
{
	public string Path {get;}
	public XDocument SaveState {get;}
	public IReadOnlyList<string> Header {get;}
	
	public SaveData(string path, XDocument saveState, IEnumerable<string> header)
	{
		Path = path;
		SaveState = saveState;
		Header = header.ToList().AsReadOnly();
	}
}

public static SaveData Load(string path)
{
	var contents = File.ReadAllBytes(path);
	var index = 0;
	var header = new List<string>();
	for (int lfFound = 0; lfFound < 11; lfFound++)
	{
		var next = Array.FindIndex(contents, index, b => b == (byte)'\n') + 1;
		header.Add(Encoding.UTF8.GetString(contents, index, next - index));
		index = next;
	}
	
	var compressed = new byte[contents.Length - index];
	Array.Copy(contents, index, compressed, 0, contents.Length - index);
	var result = CLZF2.Decompress(compressed);
	var xml = XDocument.Load(new MemoryStream(result));
	
	return new SaveData(path, xml, header);
}

public static void Save(string path, SaveData saveData)
{
	var tempStream = new MemoryStream();
	var xmlSettings = new XmlWriterSettings
	{
		OmitXmlDeclaration = true,
		Indent = false,
	};
	using (var writer = XmlWriter.Create(tempStream, xmlSettings))
	{
		saveData.SaveState.Save(writer);
	}
	var changedData = tempStream.ToArray();
	var compressedChangedData = CLZF2.Compress(changedData);
	using (var newSave = File.Create(path))
	{
		for (int i = 0; i < saveData.Header.Count; i++)
		{
			var line = saveData.Header[i];
			if (i == 4 || i == 5)
			{
				line = Regex.Replace(line, @"(\d+)", i == 4 ? changedData.Length.ToString() : compressedChangedData.Length.ToString());
			}
			var lineBytes = Encoding.UTF8.GetBytes(line);
			newSave.Write(lineBytes, 0, lineBytes.Length);
		}
		newSave.Write(compressedChangedData, 0, compressedChangedData.Length);
	}
}

public static class LinqToXmlExtensions
{
	public static void EnsurePerkCount(this XContainer perksContainer, string perkname, int count)
	{
		if(count < 0)
			return;
		
		var chosenPerkEntries =
			perksContainer.Elements("perk")
						  .Where(p => string.Equals(p.Element("perkname").Value, perkname, StringComparison.Ordinal));
		
		chosenPerkEntries.Skip(count).Remove();
		var perksToAdd = count - chosenPerkEntries.Count();
		for (int i = 0; i < perksToAdd; i++)
		{
			perksContainer.AddFirst(new XElement("perk", new XElement("perkname", perkname)));
		}
	}
	
	public static void AddFirstUntilCount(this XContainer container, Func<XElement> factory, Func<XElement, bool> predicate, int count)
	{
		while (container.Elements().Count(predicate) < count)
		{
			container.AddFirst(factory());
		}
	}
}

// Define other methods and classes here

/// <summary>
/// Improved C# LZF Compressor, a very small data compression library. The compression algorithm is extremely fast.
/// </summary>
public class CLZF2
{
    #region Tunable Constants

    /// <summary>
    /// Multiple of input size used to estimate work/output buffer size.
    /// Larger values increase initial memory usage but potentially reduces number of allocations.
    /// </summary>
    private const int BUFFER_SIZE_ESTIMATE = 2;

    /// <summary>
    /// Size of hashtable is 2^HLOG bytes. 
    /// Decompression is independent of the hash table size.
    /// The difference between 15 and 14 is very small
    /// for small blocks (and 14 is usually a bit faster).
    /// For a low-memory/faster configuration, use HLOG == 13;
    /// For best compression, use 15 or 16 (or more, up to 22).
    /// </summary>
    private const uint HLOG = 14;

    #endregion

    # region Other Constants (Do Not Modify)

    private const uint HSIZE = (1 << (int)HLOG);
    private const uint MAX_LIT = (1 << 5);
    private const uint MAX_OFF = (1 << 13);
    private const uint MAX_REF = ((1 << 8) + (1 << 3));

    #endregion

    #region Fields

    /// <summary>
    /// Hashtable, that can be allocated only once.
    /// </summary>
    private static readonly long[] HashTable = new long[HSIZE];

    /// <summary>
    /// Lock object for access to hashtable so that we can keep things thread safe.
    /// Still up to the caller to make sure any shared outputBuffer use is thread safe.
    /// </summary>
    private static readonly object locker = new object();

    #endregion

    #region Public Methods

    /// <summary>
    /// Compress input bytes.
    /// </summary>
    /// <param name="inputBytes">Bytes to compress.</param>
    /// <returns>Compressed bytes.</returns>
    public static byte[] Compress(byte[] inputBytes)
    {
        return Compress(inputBytes, inputBytes.Length);
    }

    /// <summary>
    /// Compress input bytes.
    /// </summary>
    /// <param name="inputBytes">Bytes to compress.</param>
    /// <param name="inputLength">Length of data in inputBytes to decompress.</param>
    /// <returns>Compressed bytes.</returns>
    public static byte[] Compress(byte[] inputBytes, int inputLength)
    {
        byte[] tempBuffer = null;
        int byteCount = Compress(inputBytes, ref tempBuffer, inputLength);

        byte[] outputBytes = new byte[byteCount];
        Buffer.BlockCopy(tempBuffer, 0, outputBytes, 0, byteCount);
        return outputBytes;
    }

    /// <summary>
    /// Compress input bytes.
    /// </summary>
    /// <param name="inputBytes">Bytes to compress.</param>
    /// <param name="outputBuffer">Output/work buffer. Upon completion, will contain the output.</param>
    /// <returns>Length of output.</returns>
    public static int Compress(byte[] inputBytes, ref byte[] outputBuffer)
    {
        return Compress(inputBytes, ref outputBuffer, inputBytes.Length);
    }

    /// <summary>
    /// Compress input bytes.
    /// </summary>
    /// <param name="inputBytes">Bytes to compress.</param>
    /// <param name="outputBuffer">Output/work buffer. Upon completion, will contain the output.</param>
    /// <param name="inputLength">Length of data in inputBytes.</param>
    /// <returns>Length of output.</returns>
    public static int Compress(byte[] inputBytes, ref byte[] outputBuffer, int inputLength)
    {
        // Estimate necessary output buffer size.
        int outputByteCountGuess = inputBytes.Length * BUFFER_SIZE_ESTIMATE;
        if (outputBuffer == null || outputBuffer.Length < outputByteCountGuess)
            outputBuffer = new byte[outputByteCountGuess];

        int byteCount = lzf_compress(inputBytes, ref outputBuffer, inputLength);

        // If byteCount is 0, increase buffer size and try again.
        while (byteCount == 0)
        {
            outputByteCountGuess *= 2;
            outputBuffer = new byte[outputByteCountGuess];
            byteCount = lzf_compress(inputBytes, ref outputBuffer, inputLength);
        }

        return byteCount;
    }

    /// <summary>
    /// Decompress input bytes.
    /// </summary>
    /// <param name="inputBytes">Bytes to decompress.</param>
    /// <returns>Decompressed bytes.</returns>
    public static byte[] Decompress(byte[] inputBytes)
    {
        return Decompress(inputBytes, inputBytes.Length);
    }

    /// <summary>
    /// Decompress input bytes.
    /// </summary>
    /// <param name="inputBytes">Bytes to decompress.</param>
    /// <param name="inputLength">Length of data in inputBytes to decompress.</param>
    /// <returns>Decompressed bytes.</returns>
    public static byte[] Decompress(byte[] inputBytes, int inputLength)
    {
        byte[] tempBuffer = null;
        int byteCount = Decompress(inputBytes, ref tempBuffer, inputLength);

        byte[] outputBytes = new byte[byteCount];
        Buffer.BlockCopy(tempBuffer, 0, outputBytes, 0, byteCount);
        return outputBytes;
    }

    /// <summary>
    /// Decompress input bytes.
    /// </summary>
    /// <param name="inputBytes">Bytes to decompress.</param>
    /// <param name="outputBuffer">Output/work buffer. Upon completion, will contain the output.</param>
    /// <returns>Length of output.</returns>
    public static int Decompress(byte[] inputBytes, ref byte[] outputBuffer)
    {
        return Decompress(inputBytes, ref outputBuffer, inputBytes.Length);
    }

    /// <summary>
    /// Decompress input bytes.
    /// </summary>
    /// <param name="inputBytes">Bytes to decompress.</param>
    /// <param name="outputBuffer">Output/work buffer. Upon completion, will contain the output.</param>
    /// <param name="inputLength">Length of data in inputBytes.</param>
    /// <returns>Length of output.</returns>
    public static int Decompress(byte[] inputBytes, ref byte[] outputBuffer, int inputLength)
    {
        // Estimate necessary output buffer size.
        int outputByteCountGuess = inputBytes.Length * BUFFER_SIZE_ESTIMATE;
        if (outputBuffer == null || outputBuffer.Length < outputByteCountGuess)
            outputBuffer = new byte[outputByteCountGuess];

        int byteCount = lzf_decompress(inputBytes, ref outputBuffer, inputLength);

        // If byteCount is 0, increase buffer size and try again.
        while (byteCount == 0)
        {
            outputByteCountGuess *= 2;
            outputBuffer = new byte[outputByteCountGuess];
            byteCount = lzf_decompress(inputBytes, ref outputBuffer, inputLength);
        }

        return byteCount;
    }
    
    #endregion

    #region Private Methods

    /// <summary>
    /// Compresses the data using LibLZF algorithm.
    /// </summary>
    /// <param name="input">Reference to the data to compress.</param>
    /// <param name="output">Reference to a buffer which will contain the compressed data.</param>
    /// <param name="inputLength">Length of input bytes to process.</param>
    /// <returns>The size of the compressed archive in the output buffer.</returns>
    private static int lzf_compress(byte[] input, ref byte[] output, int inputLength)
    {
        int outputLength = output.Length;

        long hslot;
        uint iidx = 0;
        uint oidx = 0;
        long reference;

        uint hval = (uint)(((input[iidx]) << 8) | input[iidx + 1]); // FRST(in_data, iidx);
        long off;
        int lit = 0;

        // Lock so we have exclusive access to hashtable.
        lock (locker)
        {
            Array.Clear(HashTable, 0, (int)HSIZE);

            for (; ; )
            {
                if (iidx < inputLength - 2)
                {
                    hval = (hval << 8) | input[iidx + 2];
                    hslot = ((hval ^ (hval << 5)) >> (int)(((3 * 8 - HLOG)) - hval * 5) & (HSIZE - 1));
                    reference = HashTable[hslot];
                    HashTable[hslot] = (long)iidx;

                    if ((off = iidx - reference - 1) < MAX_OFF
                        && iidx + 4 < inputLength
                        && reference > 0
                        && input[reference + 0] == input[iidx + 0]
                        && input[reference + 1] == input[iidx + 1]
                        && input[reference + 2] == input[iidx + 2]
                        )
                    {
                        /* match found at *reference++ */
                        uint len = 2;
                        uint maxlen = (uint)inputLength - iidx - len;
                        maxlen = maxlen > MAX_REF ? MAX_REF : maxlen;

                        if (oidx + lit + 1 + 3 >= outputLength)
                            return 0;

                        do
                            len++;
                        while (len < maxlen && input[reference + len] == input[iidx + len]);

                        if (lit != 0)
                        {
                            output[oidx++] = (byte)(lit - 1);
                            lit = -lit;
                            do
                                output[oidx++] = input[iidx + lit];
                            while ((++lit) != 0);
                        }

                        len -= 2;
                        iidx++;

                        if (len < 7)
                        {
                            output[oidx++] = (byte)((off >> 8) + (len << 5));
                        }
                        else
                        {
                            output[oidx++] = (byte)((off >> 8) + (7 << 5));
                            output[oidx++] = (byte)(len - 7);
                        }

                        output[oidx++] = (byte)off;

                        iidx += len - 1;
                        hval = (uint)(((input[iidx]) << 8) | input[iidx + 1]);

                        hval = (hval << 8) | input[iidx + 2];
                        HashTable[((hval ^ (hval << 5)) >> (int)(((3 * 8 - HLOG)) - hval * 5) & (HSIZE - 1))] = iidx;
                        iidx++;

                        hval = (hval << 8) | input[iidx + 2];
                        HashTable[((hval ^ (hval << 5)) >> (int)(((3 * 8 - HLOG)) - hval * 5) & (HSIZE - 1))] = iidx;
                        iidx++;
                        continue;
                    }
                }
                else if (iidx == inputLength)
                    break;

                /* one more literal byte we must copy */
                lit++;
                iidx++;

                if (lit == MAX_LIT)
                {
                    if (oidx + 1 + MAX_LIT >= outputLength)
                        return 0;

                    output[oidx++] = (byte)(MAX_LIT - 1);
                    lit = -lit;
                    do
                        output[oidx++] = input[iidx + lit];
                    while ((++lit) != 0);
                }
            } // for
        } // lock

        if (lit != 0)
        {
            if (oidx + lit + 1 >= outputLength)
                return 0;

            output[oidx++] = (byte)(lit - 1);
            lit = -lit;
            do
                output[oidx++] = input[iidx + lit];
            while ((++lit) != 0);
        }

        return (int)oidx;
    }

    /// <summary>
    /// Decompresses the data using LibLZF algorithm.
    /// </summary>
    /// <param name="input">Reference to the data to decompress.</param>
    /// <param name="output">Reference to a buffer which will contain the decompressed data.</param>
    /// <param name="inputLength">Length of input bytes to process.</param>
    /// <returns>The size of the decompressed archive in the output buffer.</returns>
    private static int lzf_decompress(byte[] input, ref byte[] output, int inputLength)
    {
        int outputLength = output.Length;

        uint iidx = 0;
        uint oidx = 0;

        do
        {
            uint ctrl = input[iidx++];

            if (ctrl < (1 << 5)) /* literal run */
            {
                ctrl++;

                if (oidx + ctrl > outputLength)
                {
                    //SET_ERRNO (E2BIG);
                    return 0;
                }

                do
                    output[oidx++] = input[iidx++];
                while ((--ctrl) != 0);
            }
            else /* back reference */
            {
                uint len = ctrl >> 5;

                int reference = (int)(oidx - ((ctrl & 0x1f) << 8) - 1);

                if (len == 7)
                    len += input[iidx++];

                reference -= input[iidx++];

                if (oidx + len + 2 > outputLength)
                {
                    //SET_ERRNO (E2BIG);
                    return 0;
                }

                if (reference < 0)
                {
                    //SET_ERRNO (EINVAL);
                    return 0;
                }

                output[oidx++] = output[reference++];
                output[oidx++] = output[reference++];

                do
                    output[oidx++] = output[reference++];
                while ((--len) != 0);
            }
        }
        while (iidx < inputLength);

        return (int)oidx;
    }

    #endregion

}
4. Having copied the code over, your LINQpad should look like this:
Image

5. Now in the region that says var saveName = "your save file name all lower case"; enter the name of the save you wish to add items to. if your save in the save directory is called ranger hq, then put ranger hq with the space all lowercase.

6. If your save directory is not in documents, you will need to change the var path to your save directory. I think there is not way to change save location, but putting this here just in case.

7. you will need a .txt with the names of the items you want. Here is a pastebin with all the weapons, armors, mods, and vehicle parts. [Link] . Here is another pastebin with all items, including story and progression items. [Link]. I don't recommend adding any story items as it could softlock/break the game. The first pastebin is safe, I've tried it.

8. Save the lines for the items that you want in a .txt and put it anywhere on your computer. Put this path in this line: foreach (string item in File.ReadAllLines(@"C:\path\to\you\items\.txt"). so it should read something like: @"C:\Users\Default\Documents\cheat.txt"

Here's an image to help navigate the LINQpad
Image

9. Press the big green start button at the top and you're done if you don't get any errors!(you shouldn't if you've done everything correct).



Important Notes: *The code automatically backs up your save in it's folder as a .bak file. Rename it a .xml if you want to restore backup. You don't have to delete it.
*I was trying to get quantity to work, however the only way to get it to give you multiple of a non-stackable is to put that item's name multiple times in the .txt file. so if you want 5 ITM_LAXATIVE you need to put it 5 times in the .txt

Thanks again to u/JitterJohn on reddit. Goodluck with the cheats guys!

How to use this cheat table?
  1. Install Cheat Engine
  2. Double-click the .CT file in order to open it.
  3. Click the PC icon in Cheat Engine in order to select the game process.
  4. Keep the list.
  5. Activate the trainer options by checking boxes or setting values from 0 to 1

Valson
What is cheating?
What is cheating?
Posts: 1
Joined: Thu Apr 02, 2020 11:07 am
Reputation: 1

Re: Wasteland 3 Pointer Table

Post by Valson »

It's works! You breathtaking!
kaptain kek wrote:
Mon Aug 31, 2020 12:12 pm
Spoiler
ADDING ITEMS TO INVENTORY GUIDE

This only works on Steam and GOG version. XGP has different saves

Big thanks to u/JitterJohn on the wasteland 3 subreddit for taking his time, he's responsible for most of the code. Also big thanks to Chaser324 on Github for his CLZF2 decompress script.

Using this method you are able to add any item to your inventory.

1. First, you will need to download LINGpad5. Yes, version 5. You can find it here: [Link]

2. Open LINQpad5, and set the Laguange to C# Program.

3. Copy this code into LINGpad5.

Code: Select all

void Main()
{
 //Be carefull when editing quicksaves, the backup can be out-of-date if you never delete it.
 var saveName = "your save file name all lower case";
 
 //The names of the characters that will be edited.
 //Unique characters like Marshal Kwon don't have a display name. 
 // *THIS IS LEFT OVER FROM JITTERJOHNS CODE. Not relevant to item adding. Leave it in and ignore.
 var pcNames = new HashSet<string> { "asdfeagfdfsdgs", "lkjhoisdgreczhk" };
 
 var path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), @"My Games\Wasteland3\Save Games\", saveName, saveName + ".bak");
 if(!File.Exists(path))
 {
 File.Copy(Path.ChangeExtension(path, ".xml"), path);
 }
 var saveData = Load(path);
 var xml = saveData.SaveState;
 //Dumps the xml part of the save to a new output panel with syntax highlighting.
 //PanelManager.DisplaySyntaxColoredText(xml.ToString(), SyntaxLanguageStyle.XML); return;
 //I was trying to get quantity working, however never got it to work. Ignore quantity.
 foreach (string item in File.ReadAllLines(@"C:\path\to\you\items\.txt")){
 var sp = item.Split(',');
string itemname = sp[0];
int qty = 1;
try { int.TryParse(sp[1], out qty); } catch {}
 xml.Root.Element("hostInventory")
 .Add(new XElement("item",
 new XElement("templateName", itemname),
 new XElement("slot", 0),
 new XElement("ammoLoaded", 0),
 new XElement("quantity", 1),
 new XElement("uid", Guid.NewGuid()),
 new XElement("isLockedForMerchant", false),
 new XElement("merchantBarterLevelRequirement", 0)));
 }

 
 Save(Path.ChangeExtension(saveData.Path, ".xml"), saveData);
}

public static void DuplicateMods(SaveData saveData, int duplicateCount)
{
 var items = saveData.SaveState.Root.Element("hostInventory");
 foreach (var item in items.Descendants("item").Where(itm => itm.Element("templateName").Value.Contains("Mod_")).ToList())
 {
 var templateName = item.Element("templateName").Value;
 while (items.Descendants("item").Where(itm => itm.Element("templateName").Value.Equals(templateName, StringComparison.Ordinal)).Count() < duplicateCount)
 {
 var copy = new XElement(item);
 copy.SetElementValue("uid", Guid.NewGuid());
 items.Add(copy);
 }
 }
}


public sealed class SaveData 
{
 public string Path {get;}
 public XDocument SaveState {get;}
 public IReadOnlyList<string> Header {get;}
 
 public SaveData(string path, XDocument saveState, IEnumerable<string> header)
 {
 Path = path;
 SaveState = saveState;
 Header = header.ToList().AsReadOnly();
 }
}

public static SaveData Load(string path)
{
 var contents = File.ReadAllBytes(path);
 var index = 0;
 var header = new List<string>();
 for (int lfFound = 0; lfFound < 11; lfFound++)
 {
 var next = Array.FindIndex(contents, index, b => b == (byte)'\n') + 1;
 header.Add(Encoding.UTF8.GetString(contents, index, next - index));
 index = next;
 }
 
 var compressed = new byte[contents.Length - index];
 Array.Copy(contents, index, compressed, 0, contents.Length - index);
 var result = CLZF2.Decompress(compressed);
 var xml = XDocument.Load(new MemoryStream(result));
 
 return new SaveData(path, xml, header);
}

public static void Save(string path, SaveData saveData)
{
 var tempStream = new MemoryStream();
 var xmlSettings = new XmlWriterSettings
 {
 OmitXmlDeclaration = true,
 Indent = false,
 };
 using (var writer = XmlWriter.Create(tempStream, xmlSettings))
 {
 saveData.SaveState.Save(writer);
 }
 var changedData = tempStream.ToArray();
 var compressedChangedData = CLZF2.Compress(changedData);
 using (var newSave = File.Create(path))
 {
 for (int i = 0; i < saveData.Header.Count; i++)
 {
 var line = saveData.Header[i];
 if (i == 4 || i == 5)
 {
 line = Regex.Replace(line, @"(\d+)", i == 4 ? changedData.Length.ToString() : compressedChangedData.Length.ToString());
 }
 var lineBytes = Encoding.UTF8.GetBytes(line);
 newSave.Write(lineBytes, 0, lineBytes.Length);
 }
 newSave.Write(compressedChangedData, 0, compressedChangedData.Length);
 }
}

public static class LinqToXmlExtensions
{
 public static void EnsurePerkCount(this XContainer perksContainer, string perkname, int count)
 {
 if(count < 0)
 return;
 
 var chosenPerkEntries =
 perksContainer.Elements("perk")
 .Where(p => string.Equals(p.Element("perkname").Value, perkname, StringComparison.Ordinal));
 
 chosenPerkEntries.Skip(count).Remove();
 var perksToAdd = count - chosenPerkEntries.Count();
 for (int i = 0; i < perksToAdd; i++)
 {
 perksContainer.AddFirst(new XElement("perk", new XElement("perkname", perkname)));
 }
 }
 
 public static void AddFirstUntilCount(this XContainer container, Func<XElement> factory, Func<XElement, bool> predicate, int count)
 {
 while (container.Elements().Count(predicate) < count)
 {
 container.AddFirst(factory());
 }
 }
}

// Define other methods and classes here

/// <summary>
/// Improved C# LZF Compressor, a very small data compression library. The compression algorithm is extremely fast.
/// </summary>
public class CLZF2
{
 #region Tunable Constants

 /// <summary>
 /// Multiple of input size used to estimate work/output buffer size.
 /// Larger values increase initial memory usage but potentially reduces number of allocations.
 /// </summary>
 private const int BUFFER_SIZE_ESTIMATE = 2;

 /// <summary>
 /// Size of hashtable is 2^HLOG bytes. 
 /// Decompression is independent of the hash table size.
 /// The difference between 15 and 14 is very small
 /// for small blocks (and 14 is usually a bit faster).
 /// For a low-memory/faster configuration, use HLOG == 13;
 /// For best compression, use 15 or 16 (or more, up to 22).
 /// </summary>
 private const uint HLOG = 14;

 #endregion

 # region Other Constants (Do Not Modify)

 private const uint HSIZE = (1 << (int)HLOG);
 private const uint MAX_LIT = (1 << 5);
 private const uint MAX_OFF = (1 << 13);
 private const uint MAX_REF = ((1 << 8) + (1 << 3));

 #endregion

 #region Fields

 /// <summary>
 /// Hashtable, that can be allocated only once.
 /// </summary>
 private static readonly long[] HashTable = new long[HSIZE];

 /// <summary>
 /// Lock object for access to hashtable so that we can keep things thread safe.
 /// Still up to the caller to make sure any shared outputBuffer use is thread safe.
 /// </summary>
 private static readonly object locker = new object();

 #endregion

 #region Public Methods

 /// <summary>
 /// Compress input bytes.
 /// </summary>
 /// <param name="inputBytes">Bytes to compress.</param>
 /// <returns>Compressed bytes.</returns>
 public static byte[] Compress(byte[] inputBytes)
 {
 return Compress(inputBytes, inputBytes.Length);
 }

 /// <summary>
 /// Compress input bytes.
 /// </summary>
 /// <param name="inputBytes">Bytes to compress.</param>
 /// <param name="inputLength">Length of data in inputBytes to decompress.</param>
 /// <returns>Compressed bytes.</returns>
 public static byte[] Compress(byte[] inputBytes, int inputLength)
 {
 byte[] tempBuffer = null;
 int byteCount = Compress(inputBytes, ref tempBuffer, inputLength);

 byte[] outputBytes = new byte[byteCount];
 Buffer.BlockCopy(tempBuffer, 0, outputBytes, 0, byteCount);
 return outputBytes;
 }

 /// <summary>
 /// Compress input bytes.
 /// </summary>
 /// <param name="inputBytes">Bytes to compress.</param>
 /// <param name="outputBuffer">Output/work buffer. Upon completion, will contain the output.</param>
 /// <returns>Length of output.</returns>
 public static int Compress(byte[] inputBytes, ref byte[] outputBuffer)
 {
 return Compress(inputBytes, ref outputBuffer, inputBytes.Length);
 }

 /// <summary>
 /// Compress input bytes.
 /// </summary>
 /// <param name="inputBytes">Bytes to compress.</param>
 /// <param name="outputBuffer">Output/work buffer. Upon completion, will contain the output.</param>
 /// <param name="inputLength">Length of data in inputBytes.</param>
 /// <returns>Length of output.</returns>
 public static int Compress(byte[] inputBytes, ref byte[] outputBuffer, int inputLength)
 {
 // Estimate necessary output buffer size.
 int outputByteCountGuess = inputBytes.Length * BUFFER_SIZE_ESTIMATE;
 if (outputBuffer == null || outputBuffer.Length < outputByteCountGuess)
 outputBuffer = new byte[outputByteCountGuess];

 int byteCount = lzf_compress(inputBytes, ref outputBuffer, inputLength);

 // If byteCount is 0, increase buffer size and try again.
 while (byteCount == 0)
 {
 outputByteCountGuess *= 2;
 outputBuffer = new byte[outputByteCountGuess];
 byteCount = lzf_compress(inputBytes, ref outputBuffer, inputLength);
 }

 return byteCount;
 }

 /// <summary>
 /// Decompress input bytes.
 /// </summary>
 /// <param name="inputBytes">Bytes to decompress.</param>
 /// <returns>Decompressed bytes.</returns>
 public static byte[] Decompress(byte[] inputBytes)
 {
 return Decompress(inputBytes, inputBytes.Length);
 }

 /// <summary>
 /// Decompress input bytes.
 /// </summary>
 /// <param name="inputBytes">Bytes to decompress.</param>
 /// <param name="inputLength">Length of data in inputBytes to decompress.</param>
 /// <returns>Decompressed bytes.</returns>
 public static byte[] Decompress(byte[] inputBytes, int inputLength)
 {
 byte[] tempBuffer = null;
 int byteCount = Decompress(inputBytes, ref tempBuffer, inputLength);

 byte[] outputBytes = new byte[byteCount];
 Buffer.BlockCopy(tempBuffer, 0, outputBytes, 0, byteCount);
 return outputBytes;
 }

 /// <summary>
 /// Decompress input bytes.
 /// </summary>
 /// <param name="inputBytes">Bytes to decompress.</param>
 /// <param name="outputBuffer">Output/work buffer. Upon completion, will contain the output.</param>
 /// <returns>Length of output.</returns>
 public static int Decompress(byte[] inputBytes, ref byte[] outputBuffer)
 {
 return Decompress(inputBytes, ref outputBuffer, inputBytes.Length);
 }

 /// <summary>
 /// Decompress input bytes.
 /// </summary>
 /// <param name="inputBytes">Bytes to decompress.</param>
 /// <param name="outputBuffer">Output/work buffer. Upon completion, will contain the output.</param>
 /// <param name="inputLength">Length of data in inputBytes.</param>
 /// <returns>Length of output.</returns>
 public static int Decompress(byte[] inputBytes, ref byte[] outputBuffer, int inputLength)
 {
 // Estimate necessary output buffer size.
 int outputByteCountGuess = inputBytes.Length * BUFFER_SIZE_ESTIMATE;
 if (outputBuffer == null || outputBuffer.Length < outputByteCountGuess)
 outputBuffer = new byte[outputByteCountGuess];

 int byteCount = lzf_decompress(inputBytes, ref outputBuffer, inputLength);

 // If byteCount is 0, increase buffer size and try again.
 while (byteCount == 0)
 {
 outputByteCountGuess *= 2;
 outputBuffer = new byte[outputByteCountGuess];
 byteCount = lzf_decompress(inputBytes, ref outputBuffer, inputLength);
 }

 return byteCount;
 }
 
 #endregion

 #region Private Methods

 /// <summary>
 /// Compresses the data using LibLZF algorithm.
 /// </summary>
 /// <param name="input">Reference to the data to compress.</param>
 /// <param name="output">Reference to a buffer which will contain the compressed data.</param>
 /// <param name="inputLength">Length of input bytes to process.</param>
 /// <returns>The size of the compressed archive in the output buffer.</returns>
 private static int lzf_compress(byte[] input, ref byte[] output, int inputLength)
 {
 int outputLength = output.Length;

 long hslot;
 uint iidx = 0;
 uint oidx = 0;
 long reference;

 uint hval = (uint)(((input[iidx]) << 8) | input[iidx + 1]); // FRST(in_data, iidx);
 long off;
 int lit = 0;

 // Lock so we have exclusive access to hashtable.
 lock (locker)
 {
 Array.Clear(HashTable, 0, (int)HSIZE);

 for (; ; )
 {
 if (iidx < inputLength - 2)
 {
 hval = (hval << 8) | input[iidx + 2];
 hslot = ((hval ^ (hval << 5)) >> (int)(((3 * 8 - HLOG)) - hval * 5) & (HSIZE - 1));
 reference = HashTable[hslot];
 HashTable[hslot] = (long)iidx;

 if ((off = iidx - reference - 1) < MAX_OFF
 && iidx + 4 < inputLength
 && reference > 0
 && input[reference + 0] == input[iidx + 0]
 && input[reference + 1] == input[iidx + 1]
 && input[reference + 2] == input[iidx + 2]
 )
 {
 /* match found at *reference++ */
 uint len = 2;
 uint maxlen = (uint)inputLength - iidx - len;
 maxlen = maxlen > MAX_REF ? MAX_REF : maxlen;

 if (oidx + lit + 1 + 3 >= outputLength)
 return 0;

 do
 len++;
 while (len < maxlen && input[reference + len] == input[iidx + len]);

 if (lit != 0)
 {
 output[oidx++] = (byte)(lit - 1);
 lit = -lit;
 do
 output[oidx++] = input[iidx + lit];
 while ((++lit) != 0);
 }

 len -= 2;
 iidx++;

 if (len < 7)
 {
 output[oidx++] = (byte)((off >> 8) + (len << 5));
 }
 else
 {
 output[oidx++] = (byte)((off >> 8) + (7 << 5));
 output[oidx++] = (byte)(len - 7);
 }

 output[oidx++] = (byte)off;

 iidx += len - 1;
 hval = (uint)(((input[iidx]) << 8) | input[iidx + 1]);

 hval = (hval << 8) | input[iidx + 2];
 HashTable[((hval ^ (hval << 5)) >> (int)(((3 * 8 - HLOG)) - hval * 5) & (HSIZE - 1))] = iidx;
 iidx++;

 hval = (hval << 8) | input[iidx + 2];
 HashTable[((hval ^ (hval << 5)) >> (int)(((3 * 8 - HLOG)) - hval * 5) & (HSIZE - 1))] = iidx;
  iidx++;
 continue;
 }
 }
 else if (iidx == inputLength)
 break;

 /* one more literal byte we must copy */
 lit++;
 iidx++;

 if (lit == MAX_LIT)
 {
 if (oidx + 1 + MAX_LIT >= outputLength)
 return 0;

 output[oidx++] = (byte)(MAX_LIT - 1);
 lit = -lit;
 do
 output[oidx++] = input[iidx + lit];
 while ((++lit) != 0);
 }
 } // for
 } // lock

 if (lit != 0)
 {
 if (oidx + lit + 1 >= outputLength)
 return 0;

 output[oidx++] = (byte)(lit - 1);
 lit = -lit;
 do
 output[oidx++] = input[iidx + lit];
 while ((++lit) != 0);
 }

 return (int)oidx;
 }

 /// <summary>
 /// Decompresses the data using LibLZF algorithm.
 /// </summary>
 /// <param name="input">Reference to the data to decompress.</param>
 /// <param name="output">Reference to a buffer which will contain the decompressed data.</param>
 /// <param name="inputLength">Length of input bytes to process.</param>
 /// <returns>The size of the decompressed archive in the output buffer.</returns>
 private static int lzf_decompress(byte[] input, ref byte[] output, int inputLength)
 {
 int outputLength = output.Length;

 uint iidx = 0;
 uint oidx = 0;

 do
 {
 uint ctrl = input[iidx++];

 if (ctrl < (1 << 5)) /* literal run */
 {
 ctrl++;

 if (oidx + ctrl > outputLength)
 {
 //SET_ERRNO (E2BIG);
 return 0;
 }

 do
 output[oidx++] = input[iidx++];
 while ((--ctrl) != 0);
 }
 else /* back reference */
 {
 uint len = ctrl >> 5;

 int reference = (int)(oidx - ((ctrl & 0x1f) << 8) - 1);

 if (len == 7)
 len += input[iidx++];

 reference -= input[iidx++];

 if (oidx + len + 2 > outputLength)
 {
 //SET_ERRNO (E2BIG);
 return 0;
 }

 if (reference < 0)
 {
 //SET_ERRNO (EINVAL);
 return 0;
 }

 output[oidx++] = output[reference++];
 output[oidx++] = output[reference++];

 do
 output[oidx++] = output[reference++];
 while ((--len) != 0);
 }
 }
 while (iidx < inputLength);

 return (int)oidx;
 }

 #endregion

}
4. Having copied the code over, your LINQpad should look like this:
Image

5. Now in the region that says var saveName = "your save file name all lower case"; enter the name of the save you wish to add items to. if your save in the save directory is called ranger hq, then put ranger hq with the space all lowercase.

6. If your save directory is not in documents, you will need to change the var path to your save directory. I think there is not way to change save location, but putting this here just in case.

7. you will need a .txt with the names of the items you want. Here is a pastebin with all the weapons, armors, mods, and vehicle parts. [Link] . Here is another pastebin with all items, including story and progression items. [Link]. I don't recommend adding any story items as it could softlock/break the game. The first pastebin is safe, I've tried it.

8. Save the lines for the items that you want in a .txt and put it anywhere on your computer. Put this path in this line: foreach (string item in File.ReadAllLines(@"C:\path\to\you\items\.txt"). so it should read something like: @"C:\Users\Default\Documents\cheat.txt"

Here's an image to help navigate the LINQpad
Image

9. Press the big green start button at the top and you're done if you don't get any errors!(you shouldn't if you've done everything correct).



Important Notes: *The code automatically backs up your save in it's folder as a .bak file. Rename it a .xml if you want to restore backup. You don't have to delete it.
*I was trying to get quantity to work, however the only way to get it to give you multiple of a non-stackable is to put that item's name multiple times in the .txt file. so if you want 5 ITM_LAXATIVE you need to put it 5 times in the .txt

Thanks again to u/JitterJohn on reddit. Goodluck with the cheats guys!

User avatar
Csimbi
RCE Fanatics
RCE Fanatics
Posts: 516
Joined: Sat Apr 29, 2017 9:04 pm
Reputation: 536

Re: Wasteland 3 Pointer Table

Post by Csimbi »

Anyone figured out how to remove hotkeys?

Neobleak
What is cheating?
What is cheating?
Posts: 3
Joined: Thu May 24, 2018 5:07 pm
Reputation: 0

Re: Wasteland 3 Pointer Table

Post by Neobleak »

Thank kaptain kek it work!! :wub:

kaptain kek
Cheater
Cheater
Posts: 26
Joined: Thu Mar 16, 2017 12:15 pm
Reputation: 16

Re: Wasteland 3 Pointer Table

Post by kaptain kek »

Csimbi wrote:
Mon Aug 31, 2020 5:25 pm
Anyone figured out how to remove hotkeys?
Which hotkeys do you mean? Like "K" for character sheet, "I" for inventory?

bloodaxis
Expert Cheater
Expert Cheater
Posts: 300
Joined: Thu Apr 13, 2017 5:09 am
Reputation: 23

Re: Wasteland 3 Pointer Table

Post by bloodaxis »

kaptain kek wrote:
Mon Aug 31, 2020 12:12 pm
ADDING ITEMS TO INVENTORY GUIDE
Huge thanks for this, would you by any chance have the item codes for the ammo as well? Specifically the sawblade ammo, since apparently whoever designed the loot figured it'd be a good idea to give you a weapon that you can't get ammo for, at least I didn't manage to get any to drop in 50+ hours of gameplay.

kaptain kek
Cheater
Cheater
Posts: 26
Joined: Thu Mar 16, 2017 12:15 pm
Reputation: 16

Re: Wasteland 3 Pointer Table

Post by kaptain kek »

bloodaxis wrote:
Mon Aug 31, 2020 7:48 pm
kaptain kek wrote:
Mon Aug 31, 2020 12:12 pm
ADDING ITEMS TO INVENTORY GUIDE
Huge thanks for this, would you by any chance have the item codes for the ammo as well? Specifically the sawblade ammo, since apparently whoever designed the loot figured it'd be a good idea to give you a weapon that you can't get ammo for, at least I didn't manage to get any to drop in 50+ hours of gameplay.
No problem! i'm away from my computer, but I'll look into it. I got the dump from the resources.assets file located in (x86)\Steam\steamapps\common\Wasteland 3\WL3_Data, I might have missed them when I dumped everything else, or the codes for ammo could be located in another file. I'll decompress and have a look for you when I can!

bloodaxis
Expert Cheater
Expert Cheater
Posts: 300
Joined: Thu Apr 13, 2017 5:09 am
Reputation: 23

Re: Wasteland 3 Pointer Table

Post by bloodaxis »

kaptain kek wrote:
Mon Aug 31, 2020 8:03 pm
I'll decompress and have a look for you when I can!
Thanks, it's much appreciated.

User avatar
Csimbi
RCE Fanatics
RCE Fanatics
Posts: 516
Joined: Sat Apr 29, 2017 9:04 pm
Reputation: 536

Re: Wasteland 3 Pointer Table

Post by Csimbi »

kaptain kek wrote:
Mon Aug 31, 2020 6:26 pm
Csimbi wrote:
Mon Aug 31, 2020 5:25 pm
Anyone figured out how to remove hotkeys?
Which hotkeys do you mean? Like "K" for character sheet, "I" for inventory?
Any one in the left column.
For example, Insert.
I want to use either RightShift or NUMPAD0 (Insert) for item highlight.
RightShift is not recognized, but I do see it at one of the other bindings.
NUMPAD0 is bound to zoom, too, so using that for item highlight adjusts the camera, too - which is not what I want.
Thanks!

Zanzer
RCE Fanatics
RCE Fanatics
Posts: 516
Joined: Fri Mar 03, 2017 10:48 pm
Reputation: 1066

Re: Wasteland 3 Pointer Table

Post by Zanzer »

viewtopic.php?f=4&t=13511&p=150404#p150404

I added a search and replace for Global Variables (reputation and other things)

palo224
Noobzor
Noobzor
Posts: 5
Joined: Thu Sep 05, 2019 5:00 am
Reputation: 2

Re: Wasteland 3 Pointer Table

Post by palo224 »

hedop wrote:
Sat Aug 29, 2020 4:56 pm
hedop wrote:
Sat Aug 29, 2020 4:45 pm
Btw. I have the same problems deciphering the savegame. There has to be some sort of decryption there given that half the stuff in there is garbled letters. For one of my chars the line reads: "ITM_Eq !_Weapon_AssaultRifle_Tier*_M%.Maker" when it should read: "ITM_Equip_Weapon_AssaultRifle_Tier4-3_MeatMaker"

So I'm not exactly sure what the issue is there. It's an .xml file and I have been trying to edit it by opening it in Notepad++
Sorry that copied wrong it actually says: !CAN_Weapon_AssaultRifle_Tier*RSSOH_M%.EOTMaker
The stuff in bold letters is written white on black in capital letters.

EDIT 1: So I thought I would try converting the file... funnily enough I get errors with every save game when trying to convert the .xml file. So again... anybody got any clue?
What you want is CompressSaveGames boolean field in GameConfig. If you can turn it to false (and assuming that the other methods don't set *again*), you'll be having uncompressesd saving and loading.

That is, if you can get over the small problem of Wasteland 3 being il2cpp. tfigment and Zanzer might be able to tell you more.

CaesarCzech
Expert Cheater
Expert Cheater
Posts: 273
Joined: Fri Mar 03, 2017 2:00 pm
Reputation: 28

Re: Wasteland 3

Post by CaesarCzech »

Zanzer wrote:
Fri Aug 28, 2020 10:15 pm
Snip
I feel like idiot but how do i do the global variable stuff ? im on Gog and i dont know how im supposed to find the global variables.

Edit : Scratch that somehow i missed empty value next to string and throught String was value and not type due to brainfart.
So anybody having same brainfart just type the global variable from the list into the string and if you have the number add number as well

dd156
Noobzor
Noobzor
Posts: 5
Joined: Thu Apr 09, 2020 1:22 am
Reputation: 0

Re: Wasteland 3 Pointer Table

Post by dd156 »

Zanzer wrote:
Mon Aug 31, 2020 10:47 pm
viewtopic.php?f=4&t=13511&p=150404#p150404

I added a search and replace for Global Variables (reputation and other things)
Thanks for the work but once I click Reputation Pointer, was there supposed to be a few more options that pop up? I clicked Reputation Pointer but nothing comes up other than it's active.

User avatar
Empress_Ravenna
Expert Cheater
Expert Cheater
Posts: 229
Joined: Mon Oct 09, 2017 11:42 pm
Reputation: 24

Re: Wasteland 3 Pointer Table

Post by Empress_Ravenna »

ok edit:


Enable the function to Rep Pointers, then enter Name in Strings, like posted above, do Search first, then replace number to like 100 as example or anything then do Replace.. will get Popups saying found and updated!

works great!

bapexxx
Novice Cheater
Novice Cheater
Posts: 17
Joined: Thu Mar 08, 2018 8:48 pm
Reputation: 1

Re: Wasteland 3 Pointer Table

Post by bapexxx »

kaptain kek wrote:
Mon Aug 31, 2020 12:12 pm
ADDING ITEMS TO INVENTORY GUIDE

This only works on Steam and GOG version. XGP has different saves

Big thanks to u/JitterJohn on the wasteland 3 subreddit for taking his time, he's responsible for most of the code. Also big thanks to Chaser324 on Github for his CLZF2 decompress script.

Using this method you are able to add any item to your inventory.

1. First, you will need to download LINGpad5. Yes, version 5. You can find it here: [Link]

2. Open LINQpad5, and set the Laguange to C# Program.

3. Copy this code into LINGpad5.

Code: Select all

void Main()
{
	//Be carefull when editing quicksaves, the backup can be out-of-date if you never delete it.
	var saveName = "your save file name all lower case";
	
	//The names of the characters that will be edited.
	//Unique characters like Marshal Kwon don't have a display name. 
	// *THIS IS LEFT OVER FROM JITTERJOHNS CODE. Not relevant to item adding. Leave it in and ignore.
	var pcNames = new HashSet<string> { "asdfeagfdfsdgs", "lkjhoisdgreczhk" };
	
	var path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), @"My Games\Wasteland3\Save Games\", saveName, saveName + ".bak");
	if(!File.Exists(path))
	{
		File.Copy(Path.ChangeExtension(path, ".xml"), path);
	}
	var saveData = Load(path);
	var xml = saveData.SaveState;
	//Dumps the xml part of the save to a new output panel with syntax highlighting.
	//PanelManager.DisplaySyntaxColoredText(xml.ToString(), SyntaxLanguageStyle.XML); return;
	//I was trying to get quantity working, however never got it to work. Ignore quantity.
	foreach (string item in File.ReadAllLines(@"C:\path\to\you\items\.txt")){
	var sp = item.Split(',');
string itemname = sp[0];
int qty = 1;
try { int.TryParse(sp[1], out qty); } catch {}
	xml.Root.Element("hostInventory")
		.Add(new XElement("item",
			new XElement("templateName", itemname),
			new XElement("slot", 0),
			new XElement("ammoLoaded", 0),
			new XElement("quantity", 1),
			new XElement("uid", Guid.NewGuid()),
			new XElement("isLockedForMerchant", false),
			new XElement("merchantBarterLevelRequirement", 0)));
			}

	
	Save(Path.ChangeExtension(saveData.Path, ".xml"), saveData);
}

public static void DuplicateMods(SaveData saveData, int duplicateCount)
{
	var items = saveData.SaveState.Root.Element("hostInventory");
	foreach (var item in items.Descendants("item").Where(itm => itm.Element("templateName").Value.Contains("Mod_")).ToList())
	{
		var templateName = item.Element("templateName").Value;
		while (items.Descendants("item").Where(itm => itm.Element("templateName").Value.Equals(templateName, StringComparison.Ordinal)).Count() < duplicateCount)
		{
			var copy = new XElement(item);
			copy.SetElementValue("uid", Guid.NewGuid());
			items.Add(copy);
		}
	}
}


public sealed class SaveData 
{
	public string Path {get;}
	public XDocument SaveState {get;}
	public IReadOnlyList<string> Header {get;}
	
	public SaveData(string path, XDocument saveState, IEnumerable<string> header)
	{
		Path = path;
		SaveState = saveState;
		Header = header.ToList().AsReadOnly();
	}
}

public static SaveData Load(string path)
{
	var contents = File.ReadAllBytes(path);
	var index = 0;
	var header = new List<string>();
	for (int lfFound = 0; lfFound < 11; lfFound++)
	{
		var next = Array.FindIndex(contents, index, b => b == (byte)'\n') + 1;
		header.Add(Encoding.UTF8.GetString(contents, index, next - index));
		index = next;
	}
	
	var compressed = new byte[contents.Length - index];
	Array.Copy(contents, index, compressed, 0, contents.Length - index);
	var result = CLZF2.Decompress(compressed);
	var xml = XDocument.Load(new MemoryStream(result));
	
	return new SaveData(path, xml, header);
}

public static void Save(string path, SaveData saveData)
{
	var tempStream = new MemoryStream();
	var xmlSettings = new XmlWriterSettings
	{
		OmitXmlDeclaration = true,
		Indent = false,
	};
	using (var writer = XmlWriter.Create(tempStream, xmlSettings))
	{
		saveData.SaveState.Save(writer);
	}
	var changedData = tempStream.ToArray();
	var compressedChangedData = CLZF2.Compress(changedData);
	using (var newSave = File.Create(path))
	{
		for (int i = 0; i < saveData.Header.Count; i++)
		{
			var line = saveData.Header[i];
			if (i == 4 || i == 5)
			{
				line = Regex.Replace(line, @"(\d+)", i == 4 ? changedData.Length.ToString() : compressedChangedData.Length.ToString());
			}
			var lineBytes = Encoding.UTF8.GetBytes(line);
			newSave.Write(lineBytes, 0, lineBytes.Length);
		}
		newSave.Write(compressedChangedData, 0, compressedChangedData.Length);
	}
}

public static class LinqToXmlExtensions
{
	public static void EnsurePerkCount(this XContainer perksContainer, string perkname, int count)
	{
		if(count < 0)
			return;
		
		var chosenPerkEntries =
			perksContainer.Elements("perk")
						  .Where(p => string.Equals(p.Element("perkname").Value, perkname, StringComparison.Ordinal));
		
		chosenPerkEntries.Skip(count).Remove();
		var perksToAdd = count - chosenPerkEntries.Count();
		for (int i = 0; i < perksToAdd; i++)
		{
			perksContainer.AddFirst(new XElement("perk", new XElement("perkname", perkname)));
		}
	}
	
	public static void AddFirstUntilCount(this XContainer container, Func<XElement> factory, Func<XElement, bool> predicate, int count)
	{
		while (container.Elements().Count(predicate) < count)
		{
			container.AddFirst(factory());
		}
	}
}

// Define other methods and classes here

/// <summary>
/// Improved C# LZF Compressor, a very small data compression library. The compression algorithm is extremely fast.
/// </summary>
public class CLZF2
{
    #region Tunable Constants

    /// <summary>
    /// Multiple of input size used to estimate work/output buffer size.
    /// Larger values increase initial memory usage but potentially reduces number of allocations.
    /// </summary>
    private const int BUFFER_SIZE_ESTIMATE = 2;

    /// <summary>
    /// Size of hashtable is 2^HLOG bytes. 
    /// Decompression is independent of the hash table size.
    /// The difference between 15 and 14 is very small
    /// for small blocks (and 14 is usually a bit faster).
    /// For a low-memory/faster configuration, use HLOG == 13;
    /// For best compression, use 15 or 16 (or more, up to 22).
    /// </summary>
    private const uint HLOG = 14;

    #endregion

    # region Other Constants (Do Not Modify)

    private const uint HSIZE = (1 << (int)HLOG);
    private const uint MAX_LIT = (1 << 5);
    private const uint MAX_OFF = (1 << 13);
    private const uint MAX_REF = ((1 << 8) + (1 << 3));

    #endregion

    #region Fields

    /// <summary>
    /// Hashtable, that can be allocated only once.
    /// </summary>
    private static readonly long[] HashTable = new long[HSIZE];

    /// <summary>
    /// Lock object for access to hashtable so that we can keep things thread safe.
    /// Still up to the caller to make sure any shared outputBuffer use is thread safe.
    /// </summary>
    private static readonly object locker = new object();

    #endregion

    #region Public Methods

    /// <summary>
    /// Compress input bytes.
    /// </summary>
    /// <param name="inputBytes">Bytes to compress.</param>
    /// <returns>Compressed bytes.</returns>
    public static byte[] Compress(byte[] inputBytes)
    {
        return Compress(inputBytes, inputBytes.Length);
    }

    /// <summary>
    /// Compress input bytes.
    /// </summary>
    /// <param name="inputBytes">Bytes to compress.</param>
    /// <param name="inputLength">Length of data in inputBytes to decompress.</param>
    /// <returns>Compressed bytes.</returns>
    public static byte[] Compress(byte[] inputBytes, int inputLength)
    {
        byte[] tempBuffer = null;
        int byteCount = Compress(inputBytes, ref tempBuffer, inputLength);

        byte[] outputBytes = new byte[byteCount];
        Buffer.BlockCopy(tempBuffer, 0, outputBytes, 0, byteCount);
        return outputBytes;
    }

    /// <summary>
    /// Compress input bytes.
    /// </summary>
    /// <param name="inputBytes">Bytes to compress.</param>
    /// <param name="outputBuffer">Output/work buffer. Upon completion, will contain the output.</param>
    /// <returns>Length of output.</returns>
    public static int Compress(byte[] inputBytes, ref byte[] outputBuffer)
    {
        return Compress(inputBytes, ref outputBuffer, inputBytes.Length);
    }

    /// <summary>
    /// Compress input bytes.
    /// </summary>
    /// <param name="inputBytes">Bytes to compress.</param>
    /// <param name="outputBuffer">Output/work buffer. Upon completion, will contain the output.</param>
    /// <param name="inputLength">Length of data in inputBytes.</param>
    /// <returns>Length of output.</returns>
    public static int Compress(byte[] inputBytes, ref byte[] outputBuffer, int inputLength)
    {
        // Estimate necessary output buffer size.
        int outputByteCountGuess = inputBytes.Length * BUFFER_SIZE_ESTIMATE;
        if (outputBuffer == null || outputBuffer.Length < outputByteCountGuess)
            outputBuffer = new byte[outputByteCountGuess];

        int byteCount = lzf_compress(inputBytes, ref outputBuffer, inputLength);

        // If byteCount is 0, increase buffer size and try again.
        while (byteCount == 0)
        {
            outputByteCountGuess *= 2;
            outputBuffer = new byte[outputByteCountGuess];
            byteCount = lzf_compress(inputBytes, ref outputBuffer, inputLength);
        }

        return byteCount;
    }

    /// <summary>
    /// Decompress input bytes.
    /// </summary>
    /// <param name="inputBytes">Bytes to decompress.</param>
    /// <returns>Decompressed bytes.</returns>
    public static byte[] Decompress(byte[] inputBytes)
    {
        return Decompress(inputBytes, inputBytes.Length);
    }

    /// <summary>
    /// Decompress input bytes.
    /// </summary>
    /// <param name="inputBytes">Bytes to decompress.</param>
    /// <param name="inputLength">Length of data in inputBytes to decompress.</param>
    /// <returns>Decompressed bytes.</returns>
    public static byte[] Decompress(byte[] inputBytes, int inputLength)
    {
        byte[] tempBuffer = null;
        int byteCount = Decompress(inputBytes, ref tempBuffer, inputLength);

        byte[] outputBytes = new byte[byteCount];
        Buffer.BlockCopy(tempBuffer, 0, outputBytes, 0, byteCount);
        return outputBytes;
    }

    /// <summary>
    /// Decompress input bytes.
    /// </summary>
    /// <param name="inputBytes">Bytes to decompress.</param>
    /// <param name="outputBuffer">Output/work buffer. Upon completion, will contain the output.</param>
    /// <returns>Length of output.</returns>
    public static int Decompress(byte[] inputBytes, ref byte[] outputBuffer)
    {
        return Decompress(inputBytes, ref outputBuffer, inputBytes.Length);
    }

    /// <summary>
    /// Decompress input bytes.
    /// </summary>
    /// <param name="inputBytes">Bytes to decompress.</param>
    /// <param name="outputBuffer">Output/work buffer. Upon completion, will contain the output.</param>
    /// <param name="inputLength">Length of data in inputBytes.</param>
    /// <returns>Length of output.</returns>
    public static int Decompress(byte[] inputBytes, ref byte[] outputBuffer, int inputLength)
    {
        // Estimate necessary output buffer size.
        int outputByteCountGuess = inputBytes.Length * BUFFER_SIZE_ESTIMATE;
        if (outputBuffer == null || outputBuffer.Length < outputByteCountGuess)
            outputBuffer = new byte[outputByteCountGuess];

        int byteCount = lzf_decompress(inputBytes, ref outputBuffer, inputLength);

        // If byteCount is 0, increase buffer size and try again.
        while (byteCount == 0)
        {
            outputByteCountGuess *= 2;
            outputBuffer = new byte[outputByteCountGuess];
            byteCount = lzf_decompress(inputBytes, ref outputBuffer, inputLength);
        }

        return byteCount;
    }
    
    #endregion

    #region Private Methods

    /// <summary>
    /// Compresses the data using LibLZF algorithm.
    /// </summary>
    /// <param name="input">Reference to the data to compress.</param>
    /// <param name="output">Reference to a buffer which will contain the compressed data.</param>
    /// <param name="inputLength">Length of input bytes to process.</param>
    /// <returns>The size of the compressed archive in the output buffer.</returns>
    private static int lzf_compress(byte[] input, ref byte[] output, int inputLength)
    {
        int outputLength = output.Length;

        long hslot;
        uint iidx = 0;
        uint oidx = 0;
        long reference;

        uint hval = (uint)(((input[iidx]) << 8) | input[iidx + 1]); // FRST(in_data, iidx);
        long off;
        int lit = 0;

        // Lock so we have exclusive access to hashtable.
        lock (locker)
        {
            Array.Clear(HashTable, 0, (int)HSIZE);

            for (; ; )
            {
                if (iidx < inputLength - 2)
                {
                    hval = (hval << 8) | input[iidx + 2];
                    hslot = ((hval ^ (hval << 5)) >> (int)(((3 * 8 - HLOG)) - hval * 5) & (HSIZE - 1));
                    reference = HashTable[hslot];
                    HashTable[hslot] = (long)iidx;

                    if ((off = iidx - reference - 1) < MAX_OFF
                        && iidx + 4 < inputLength
                        && reference > 0
                        && input[reference + 0] == input[iidx + 0]
                        && input[reference + 1] == input[iidx + 1]
                        && input[reference + 2] == input[iidx + 2]
                        )
                    {
                        /* match found at *reference++ */
                        uint len = 2;
                        uint maxlen = (uint)inputLength - iidx - len;
                        maxlen = maxlen > MAX_REF ? MAX_REF : maxlen;

                        if (oidx + lit + 1 + 3 >= outputLength)
                            return 0;

                        do
                            len++;
                        while (len < maxlen && input[reference + len] == input[iidx + len]);

                        if (lit != 0)
                        {
                            output[oidx++] = (byte)(lit - 1);
                            lit = -lit;
                            do
                                output[oidx++] = input[iidx + lit];
                            while ((++lit) != 0);
                        }

                        len -= 2;
                        iidx++;

                        if (len < 7)
                        {
                            output[oidx++] = (byte)((off >> 8) + (len << 5));
                        }
                        else
                        {
                            output[oidx++] = (byte)((off >> 8) + (7 << 5));
                            output[oidx++] = (byte)(len - 7);
                        }

                        output[oidx++] = (byte)off;

                        iidx += len - 1;
                        hval = (uint)(((input[iidx]) << 8) | input[iidx + 1]);

                        hval = (hval << 8) | input[iidx + 2];
                        HashTable[((hval ^ (hval << 5)) >> (int)(((3 * 8 - HLOG)) - hval * 5) & (HSIZE - 1))] = iidx;
                        iidx++;

                        hval = (hval << 8) | input[iidx + 2];
                        HashTable[((hval ^ (hval << 5)) >> (int)(((3 * 8 - HLOG)) - hval * 5) & (HSIZE - 1))] = iidx;
                        iidx++;
                        continue;
                    }
                }
                else if (iidx == inputLength)
                    break;

                /* one more literal byte we must copy */
                lit++;
                iidx++;

                if (lit == MAX_LIT)
                {
                    if (oidx + 1 + MAX_LIT >= outputLength)
                        return 0;

                    output[oidx++] = (byte)(MAX_LIT - 1);
                    lit = -lit;
                    do
                        output[oidx++] = input[iidx + lit];
                    while ((++lit) != 0);
                }
            } // for
        } // lock

        if (lit != 0)
        {
            if (oidx + lit + 1 >= outputLength)
                return 0;

            output[oidx++] = (byte)(lit - 1);
            lit = -lit;
            do
                output[oidx++] = input[iidx + lit];
            while ((++lit) != 0);
        }

        return (int)oidx;
    }

    /// <summary>
    /// Decompresses the data using LibLZF algorithm.
    /// </summary>
    /// <param name="input">Reference to the data to decompress.</param>
    /// <param name="output">Reference to a buffer which will contain the decompressed data.</param>
    /// <param name="inputLength">Length of input bytes to process.</param>
    /// <returns>The size of the decompressed archive in the output buffer.</returns>
    private static int lzf_decompress(byte[] input, ref byte[] output, int inputLength)
    {
        int outputLength = output.Length;

        uint iidx = 0;
        uint oidx = 0;

        do
        {
            uint ctrl = input[iidx++];

            if (ctrl < (1 << 5)) /* literal run */
            {
                ctrl++;

                if (oidx + ctrl > outputLength)
                {
                    //SET_ERRNO (E2BIG);
                    return 0;
                }

                do
                    output[oidx++] = input[iidx++];
                while ((--ctrl) != 0);
            }
            else /* back reference */
            {
                uint len = ctrl >> 5;

                int reference = (int)(oidx - ((ctrl & 0x1f) << 8) - 1);

                if (len == 7)
                    len += input[iidx++];

                reference -= input[iidx++];

                if (oidx + len + 2 > outputLength)
                {
                    //SET_ERRNO (E2BIG);
                    return 0;
                }

                if (reference < 0)
                {
                    //SET_ERRNO (EINVAL);
                    return 0;
                }

                output[oidx++] = output[reference++];
                output[oidx++] = output[reference++];

                do
                    output[oidx++] = output[reference++];
                while ((--len) != 0);
            }
        }
        while (iidx < inputLength);

        return (int)oidx;
    }

    #endregion

}
4. Having copied the code over, your LINQpad should look like this:
Image

5. Now in the region that says var saveName = "your save file name all lower case"; enter the name of the save you wish to add items to. if your save in the save directory is called ranger hq, then put ranger hq with the space all lowercase.

6. If your save directory is not in documents, you will need to change the var path to your save directory. I think there is not way to change save location, but putting this here just in case.

7. you will need a .txt with the names of the items you want. Here is a pastebin with all the weapons, armors, mods, and vehicle parts. [Link] . Here is another pastebin with all items, including story and progression items. [Link]. I don't recommend adding any story items as it could softlock/break the game. The first pastebin is safe, I've tried it.

8. Save the lines for the items that you want in a .txt and put it anywhere on your computer. Put this path in this line: foreach (string item in File.ReadAllLines(@"C:\path\to\you\items\.txt"). so it should read something like: @"C:\Users\Default\Documents\cheat.txt"

Here's an image to help navigate the LINQpad
Image

9. Press the big green start button at the top and you're done if you don't get any errors!(you shouldn't if you've done everything correct).



Important Notes: *The code automatically backs up your save in it's folder as a .bak file. Rename it a .xml if you want to restore backup. You don't have to delete it.
*I was trying to get quantity to work, however the only way to get it to give you multiple of a non-stackable is to put that item's name multiple times in the .txt file. so if you want 5 ITM_LAXATIVE you need to put it 5 times in the .txt

Thanks again to u/JitterJohn on reddit. Goodluck with the cheats guys!
Any chance of making this works with XGP version?

Post Reply

Who is online

Users browsing this forum: Fayrisu, Google [Bot], hoonsta, lemaun, mooya5000, Numira123, P0P0karimu, speedway, StupidDog, tomitomy, xros