Skip to content

Commit

Permalink
BL3: Allow items to be deployed from library
Browse files Browse the repository at this point in the history
  • Loading branch information
Rosuav committed Sep 14, 2023
1 parent d44b15d commit e457488
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions BL3_find_items.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import binascii
import json
import pathlib
import random
from BL1_find_items import FunctionArg, Consumable
import Protobufs.OakSave_pb2 # protoc -I=../BL3SaveEditor/BL3Tools ../BL3SaveEditor/BL3Tools/Protobufs/*.proto --python_out=.
import Protobufs.OakProfile_pb2
Expand Down Expand Up @@ -325,6 +326,22 @@ def parse_savefile(fn, args):
else:
print(base64.b64encode(item.item_serial_number).decode())
print(base64.b64encode(obj.serial()).decode())
for serial in args.give.split(","):
if not serial: continue
serial, *changes = serial.split(":")
obj = Item.from_serial(unarmor_serial(serial))
if obj.seed == 50: obj.seed = random.randrange(1<<31) # Generate new seeds for library items
obj.level = level
for change in changes:
if not change: pass
if change[0].lower() == "l": obj.level = int(change[1:]) or level
print("GIVE:", obj)
item = Protobufs.OakSave_pb2.OakInventoryItemSaveGameData()
item.item_serial_number = obj.serial()
item.pickup_order_index = 0
item.flags = 3 # starred?
item.weapon_skin_path = ""
char.inventory_items.append(item)
raw = char.SerializeToString() # This does not fully round-trip. Hmm.
data = [
b"GVAS",
Expand Down Expand Up @@ -354,6 +371,7 @@ def main(args=None):
parser.add_argument("--steam-user", help="Steam user ID, or all or auto", default="auto")
parser.add_argument("--files", help="File name pattern", default="*.sav")
parser.add_argument("--library", action="store_true", help="List library IDs for all items")
parser.add_argument("--give", default="", help="Add items to your inventory")
# TODO: Know the standard directory and go looking there
args = parser.parse_args(args)
print(args)
Expand Down

0 comments on commit e457488

Please sign in to comment.