diff options
Diffstat (limited to 'srb_lib.py')
-rw-r--r-- | srb_lib.py | 22 |
1 files changed, 21 insertions, 1 deletions
@@ -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) |