Giter VIP home page Giter VIP logo

borderlands2's Introduction

Read and write Borderlands 2 save files

A simple command line utility to extract player information from a Borderlands 2 save file, or to create a new save file from player information.

Note the following before trying to use it:

  • It has no graphical interface and is not easy to use
  • It does not provide any mechanisms for creating items or weapons
  • It is a proof of concept and will corrupt your save files if used improperly
  • It requires a working Python 2 interpreter (2.6 or later, not 3)

How do I modify values in a save file?

Modify save file data by changing one or more of "level", "skillpoints", "money", "eridium", "seraph", "tokens", "gunslots", "backpack", "bank", "unlocks", or "itemlevels":

python savefile.py -m eridium=99 old.sav new.sav

Set the levels of all your items and weapons (except those at level 1, which are left alone) to match your character's level:

python savefile.py -m itemlevels old.sav new.sav

Or to a specific level:

python savefile.py -m itemlevels=20 old.sav new.sav

Set the number of guns your character can have equipped to 2, 3, or 4:

python savefile.py -m gunslots=4 old.sav new.sav

Set the size of your character's backpack, and the corresponding number of purchased backpack SDUs:

python savefile.py -m backpack=27 old.sav new.sav

Set the size of your character's bank, and the corresponding number of purchased bank SDUs:

python savefile.py -m bank=16 old.sav new.sav

Unlock the Creature Slaughter Dome (Natural Selection Annex):

python savefile.py -m unlocks=slaughterdome old.sav new.sav

Unlock the True Vault Hunter mode:

python savefile.py -m unlocks=truevaulthunter old.sav new.sav

Unlock both at once:

python savefile.py -m unlocks=slaughterdome:truevaulthunter old.sav new.sav

Or many changes at once, separated by commas:

python savefile.py -m level=7,skillpoints=42,money=1234,eridium=12,seraph=120,itemlevels old.sav new.sav

Add --little-endian to write the save file in a format that should be readable by the PC version (the default is to write the data in big-endian format, for the console versions):

python savefile.py -m eridium=99 --little-endian old.sav new.sav

How do I convert a PC save to work on a console?

A PC save file is automatically detected and read, and the default is to write in the correct format for a console. If you don't want to make any changes except to the format:

python savefile.py -m "" pc.sav console.sav

How do I convert a console save to work on a PC?

As before, add --little-endian to the command to write the data in a format suitable for the PC. If you don't want to make any changes except to the format:

python savefile.py -m "" --little-endian console.sav pc.sav

How do I take a copy of all my character's items?

All items stored and held in the character's bank or inventory can be exported to a text file as a list of codes, in a format compatible with Gibbed's save editor:

python savefile.py -e items.txt your-save-game.sav

How do I import those items back into a character?

A text file of codes generated as above, or assembled by hand, can be imported into a character like so:

python savefile.py -i items.txt old.sav new.sav

(Don't forget to add --little-endian if you're creating a save file for the PC version.)

By default all items will be inserted into the inventory, but this can be changed with a line containing "; Bank" to indicate that all following items should go into the bank, or one of either "; Weapons" or "; Items" to indicate that all following items should go into the inventory. For example, importing a file containing the following will put a Vault Hunter's Relic into the inventory and a Righteous Infinity pistol into the bank:

; Bank
BL2(h0Hd1Z+jY/s2Qy++Zu8Ba9qXoOmjwJ6NhrlsOmhNMX+oJo5CfQns)
; Items
BL2(B2vuv4tz1zSQCf2pqLJCS5XD/tKN4FXpjRJLnn1v85U=)

How do I just extract the player data?

Extract the raw protocol buffer data from a save file:

python savefile.py -d your-save-game.sav player.p

Extract the data in JSON format (encoded purely to preserve all the raw information -- not very readable):

python savefile.py -d -j your-save-game.sav player.json

Extract the data in JSON format, applying further parsing to make the data as readable as possible:

python savefile.py -d -j -p your-save-game.sav player.json

It may help to copy and paste the contents of the .json file into a site like http://www.jsoneditoronline.org/ in order to view or modify the contents, to ensure that the necessary JSON formatting is preserved.

Note that if you modify any of the data you extract in this way there is a very high probability that you will corrupt your save file. Please make sure you have a backup first.

How do I write the player data back to a new save file?

Create a new save file from protocol buffer data:

python savefile.py player.p your-new-save-game.sav

Create a new save file from the JSON data:

python savefile.py -j player.json your-new-save-game.sav

As before, to write a save file that can be read by the PC version add the --little-endian flag to one of the above, eg:

python savefile.py -j --little-endian player.json your-new-save-game.sav

borderlands2's People

Contributors

pclifford avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

borderlands2's Issues

Saving Player.json back to SaveGame.sav

C:\BL2>python savefile.py -d -j -p savegame.sav player.json

C:\BL2>python savefile.py -j player.json savegamemodded.sav
Something went wrong, but please ensure you have the latest version from https:/
/github.com/pclifford/borderlands2 before reporting a bug. Information useful f
or a report follows:
['savefile.py', '-j', 'player.json', 'savegamemodded.sav']
Traceback (most recent call last):
File "savefile.py", line 1006, in
main()
File "savefile.py", line 1000, in main
player = write_protobuf(data)
File "savefile.py", line 293, in write_protobuf
write_protobuf_value(sub_b, wire_type, v)
File "savefile.py", line 310, in write_protobuf_value
write_varint(b, len(value))
TypeError: object of type 'int' has no len()

The only thing I have edited is the ammo in the backpack.

Bug report

Hi,
I'm running this on a Mac using Python v2.7.2

ukwm157:76561197971413131 david$ pwd
/Users/david/Library/Application Support/Borderlands 2/WillowGame/SaveData/76561197971413131
ukwm157:76561197971413131 david$ python /Users/david/Sites/borderlands2/savefile.py -m money=100000 Save0001.sav Save0002.sav 
Something went wrong, but please ensure you have the latest version from https://github.com/pclifford/borderlands2 before reporting a bug.  Information useful for a report follows:
['/Users/david/Sites/borderlands2/savefile.py', '-m', 'money=100000', 'Save0001.sav', 'Save0002.sav']
Traceback (most recent call last):
  File "/Users/david/Sites/borderlands2/savefile.py", line 1128, in <module>
    main(options, args)
  File "/Users/david/Sites/borderlands2/savefile.py", line 1099, in main
    output.write(modify_save(input.read(), changes, endian))
  File "/Users/david/Sites/borderlands2/savefile.py", line 891, in modify_save
    player = read_protobuf(unwrap_player_data(data))
  File "/Users/david/Sites/borderlands2/savefile.py", line 623, in unwrap_player_data
    raise BL2Error("Invalid save file")
__main__.BL2Error: Invalid save file
ukwm157:76561197971413131 david$ 

Parse issue or invalid data representation

In unwrap_item_info, there is an issue when parsing something like the Legendary Psycho Classmod that it returns 256 for the library rather than 0. This might be an issue where python doesn't support uint or some invalid offset issue. I'm not sure.

I feel retarded! :( need help

I'm following the instructions but i always get "SyntaxError: invalid syntax"
I know I'm doing something wrong but i can't figure it out :/

thanks for your hard work btw! :)

Issue with PS3 .sav file

Just downloaded the python file, ran it to convert console-to-pc file, and this is the ouptut:

❯ python savefile.py -m "" --little-endian SAVE0001.SAV PC.SAV
Something went wrong, but please ensure you have the latest version from https://github.com/pclifford/borderlands2 before reporting a bug.  Information useful for a report follows:
['savefile.py', '-m', '', '--little-endian', 'SAVE0001.SAV', 'PC.SAV']
Traceback (most recent call last):
  File "savefile.py", line 1130, in <module>
    main(options, args)
  File "savefile.py", line 1101, in main
    output.write(modify_save(input.read(), changes, endian))
  File "savefile.py", line 890, in modify_save
    player = read_protobuf(unwrap_player_data(data))
  File "savefile.py", line 623, in unwrap_player_data
    raise BL2Error("Invalid save file")
__main__.BL2Error: Invalid save file

Using Python version 2.7.5.

Experience not matching level.

After setting a level on a character the experience isn't changed, so you have the experience of level 1 at whatever level you set. This may be an intentional omission, but in case not here it is.

Weapon Data Structure

(Not an issue as such, just don't know where else to ask!)

I've noticed you've made some work on deconstructing weapon data. I've been poking around but found nothing, mostly because I have no clue what I'm doing.

Have you made any progress on working out what's what in that big array of item data?

ValueError: need more than 1 value to unpack

Hey, sorry about being a very stupid person.

After typing :

sudo python ./savefile.py -m
skillpoints=99,money=9999999,eridium=99,itemlevels <SAVE0001.SAV>
SAVE0002.SAV

I get:

Traceback (most recent call last):
File "./savefile.py", line 396, in
main()
File "./savefile.py", line 376, in main
k, v = m.split("=", 1)
ValueError: need more than 1 value to unpack

Have I missed a step?

I've never touched linux and python before today and I have set up everything from the ground up installing ubuntu and getting python and binding it with lzo. This seems to be the final step for me and I have 0 knowledge to help me figure this one out. Please be so kind to give me a hand.

XOR function optimization

xor_data function can be optimized if key is 0 the data will be the same so just return the data instead of iterating through it.

You need to use a program like Horizon or Modio to extract the SaveGame.sav file first

The error is clear and I know that I should use a program like that.. however, I am on Linux... so I, unless I use Wine, I cannot use those options.

Could you perhaps explain what exactly Modio/Horizon do to the savegame-file? CAN this even be done on a Linux machine? (Given the nature of the program being 'owned' by Microsoft)
And then one more question.. if I want to use my newly created SaveGame.sav I need to 'attach' it again to the "original" save-file I guess.. am I required to use a program like Modio/Horizon for that again?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.