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
}
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
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?
- Install Cheat Engine
- Double-click the .CT file in order to open it.
- Click the PC icon in Cheat Engine in order to select the game process.
- Keep the list.
- Activate the trainer options by checking boxes or setting values from 0 to 1