aboutsummaryrefslogtreecommitdiff
path: root/srb_lib.py
diff options
context:
space:
mode:
authorB. Stack <bgstack15@gmail.com>2024-04-05 16:59:45 -0400
committerB. Stack <bgstack15@gmail.com>2024-04-05 16:59:45 -0400
commit9f94a372f0aabc2967efa38023086ca904f59c2d (patch)
treee82eac38eadbce2a481c273ddc6b5309202aa757 /srb_lib.py
parentlib: rename to completed_levels, tk: show enabled levels (diff)
downloadsrb_lib-9f94a372f0aabc2967efa38023086ca904f59c2d.tar.gz
srb_lib-9f94a372f0aabc2967efa38023086ca904f59c2d.tar.bz2
srb_lib-9f94a372f0aabc2967efa38023086ca904f59c2d.zip
all: add reset breakables
Diffstat (limited to 'srb_lib.py')
-rw-r--r--srb_lib.py22
1 files changed, 21 insertions, 1 deletions
diff --git a/srb_lib.py b/srb_lib.py
index be3683a..3cfa318 100644
--- a/srb_lib.py
+++ b/srb_lib.py
@@ -21,7 +21,6 @@
# <https://gamefaqs.gamespot.com/pc/930591-snoopy-vs-the-red-baron/faqs/46161>
# Improve:
# Rewrite as a class so we do not have to pass data around everywhere?
-# Write: set level breakables
# Documentation:
# winetricks vd=1024x768
# winetricks vd=off
@@ -412,6 +411,27 @@ def get_collected_breakables(data_object,profile_id, level, silent=False):
print(f"Debug: abs 0x{CHECKSUM_LENGTH+pos_level_which_breakables:04x} which breakables: b{profile_level_which_breakables:05b}")
return ','.join(breakables_list), breakables_mask
+def set_collected_breakables(data_object, profile_id, level, amount = "none"):
+ """ This resets the collected breakables for a level. Returns silently if given a level that does not have breakables. """
+ data = _get_data_from_data_object(data_object)
+ level_obj, message = get_level_info(level)
+ if message != "" or level == -1:
+ return -1, f"Unable to set collected breakables for {level}."
+ levelset_obj, message = get_levelset_info(level_obj["setid"])
+ if message != "" or levelset_obj == -1:
+ return -1, f"Unable to get levelset info for {level_obj['setid']}."
+ if not level_obj["r"]:
+ return data, ""
+ else:
+ thisint = 0 if amount == "none" else 5
+ thismask = 0 if amount == "none" else [i["p"] for i in BREAKABLES if i["name"] == "all"][0]
+ pos_level_balloons = PROFILE_START_POSITION[profile_id]+POS_LEVEL_BALLOONS+(level_obj["setid"]*POS_LEVEL_BALLOONS_MULTIPLIER_LEVELSET)+(POS_LEVEL_BALLOONS_MULTIPLIER_LEVEL*level_obj["set_pos"])
+ pos_level_breakables = pos_level_balloons + ((-2 * levelset_obj["id"]) + 12) * INT_SIZE
+ pos_level_which_breakables = pos_level_breakables + INT_SIZE
+ data = srb_pack("<1I",data,pos_level_breakables,thisint)
+ data = srb_pack("<1I",data,pos_level_which_breakables,thismask)
+ return data, ""
+
def set_level_status(data_object,profile_id,level,status,fix_levelset_completed_levels=True):
""" Set completion rank for a level, e.g., general """
data = _get_data_from_data_object(data_object)
bgstack15