Add simple script to edit item stat property values
This commit is contained in:
64
contrib/createitem.py
Normal file
64
contrib/createitem.py
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
from bitarray import bitarray
|
||||||
|
from bitarray.util import int2ba, hex2ba
|
||||||
|
from textwrap import wrap
|
||||||
|
from struct import pack
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
|
||||||
|
|
||||||
|
def make_stat(id, len, value):
|
||||||
|
id_bits = int2ba(id, length=9, endian="little")
|
||||||
|
value_bits = int2ba(value, length=len, endian="little")
|
||||||
|
return id_bits + value_bits
|
||||||
|
|
||||||
|
|
||||||
|
def make_stash(item_list: list[bytes]) -> bytes:
|
||||||
|
count = len(item_list)
|
||||||
|
items = b"".join(item_list)
|
||||||
|
return (
|
||||||
|
bytes.fromhex("55aa55aa010000006300000000000000")
|
||||||
|
+ pack("I", len(items) + 68)
|
||||||
|
+ bytes.fromhex(
|
||||||
|
"0000000000000000000000000000000000000000000000"
|
||||||
|
"0000000000000000000000000000000000000000004a4d"
|
||||||
|
)
|
||||||
|
+ pack("H", count)
|
||||||
|
+ items
|
||||||
|
+ bytes.fromhex(
|
||||||
|
"55aa55aa01000000630000000000000044000000000000"
|
||||||
|
"0000000000000000000000000000000000000000000000"
|
||||||
|
"0000000000000000000000000000000000004a4d000055"
|
||||||
|
"aa55aa0100000063000000000000004400000000000000"
|
||||||
|
"0000000000000000000000000000000000000000000000"
|
||||||
|
"00000000000000000000000000000000004a4d0000"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def make_item() -> bytes:
|
||||||
|
bits = bitarray(endian="little")
|
||||||
|
bits.frombytes(
|
||||||
|
bytes.fromhex(
|
||||||
|
"10008000050014df170e5b7eca14c6ee66af344848981946c07101828715d15a3c1be3f90f"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
# 9% cold ress
|
||||||
|
# stat = make_stat(43, 9, 200 + 9)
|
||||||
|
# print(stat)
|
||||||
|
# print(bits.find(stat))
|
||||||
|
bits[231 : 231 + 18] = (
|
||||||
|
make_stat(0, 8, 32 + 16) + make_stat(1, 7, 32 + 16) + make_stat(2, 7, 32 + 16)
|
||||||
|
)
|
||||||
|
return bits.tobytes()
|
||||||
|
|
||||||
|
|
||||||
|
createpath = os.getenv("CREATEITEM_PATH")
|
||||||
|
if not createpath:
|
||||||
|
print(
|
||||||
|
"set the environment variable CREATEITEM_PATH to the stash file you want to overwrite"
|
||||||
|
)
|
||||||
|
print("THIS WILL PERMANENTLY DESTROY ALL ITEMS IN THAT FILE")
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
with open(createpath, "wb") as f:
|
||||||
|
f.write(make_stash([make_item()]))
|
||||||
Reference in New Issue
Block a user