def do_bfres(self): #path = f'{get_def_path()}\\Model\\' if get_endianness(): #files = [f'{path}{self.base}.sbfres', f'{path}{self.base}.Tex1.sbfres', f'{path}{self.base}.Tex2.sbfres'] files = [ get_file_path(f'Model\\{self.base}.sbfres'), get_file_path(f'Model\\{self.base}.Tex1.sbfres'), get_file_path(f'Model\\{self.base}.Tex2.sbfres') ] else: #files = [f'{path}{self.base}.sbfres', f'{path}{self.base}.Tex.sbfres'] files = [ get_file_path(f'Model\\{self.base}.sbfres'), get_file_path(f'Model\\{self.base}.Tex.sbfres') ] for file in files: if not os.path.exists(file): return for file in files: output = self.pack_name + '\\content\\Model\\' + file.split( '\\')[-1].replace(self.base, self.name) if not os.path.exists(output): with open(file, "rb") as f: content = oead.yaz0.decompress(f.read()) to_write = content.replace( self.base.replace('Weapon_', '').encode(), self.name.replace('Weapon_', '').encode()) to_write = oead.yaz0.compress(to_write) with open(output, "wb") as f: f.write(to_write)
def do_physics(self, OldPhysicsUser): if not self.physics: return '' #file = f'{get_def_path()}\\Actor\\Pack\\{self.physics}.sbactorpack' file = get_file_path(f'Actor\\Pack\\{self.physics}.sbactorpack') if os.path.exists(file): data = Sarc_file(file) else: print(f'Cant find base actor {file}') return '' #Removing old physics files from actorpack to_rem = [] for file in self.data.data_writer.files: if 'Physics/' in file and not '.bphysics' in file: to_rem.append(file) for file in to_rem: del self.data.data_writer.files[file] PhysicsUser = '' for file in data.data_writer.files: if '.bphysics' in file and 'Actor/Physics/' in file: PhysicsUser = os.path.basename(file).split('.')[0] pio = get_raw_data(data.data_sarc, file) old_name = f'Actor/Physics/{OldPhysicsUser}.bphysics' new_name = f'Actor/Physics/{PhysicsUser}.bphysics' update_sarc(pio, self.data, old_name, new_name) elif 'Physics/' in file and not '.bphysics' in file: self.data.data_writer.files[file] = data.data_sarc.get_file( file).data.tobytes() return PhysicsUser
def get_recipe(self): template = 'Weapon_Shield_038' recipe = f'{self.name}.brecipe' path = f'cache\\{template}.sbactorpack' if not os.path.exists(path): #copyfile(f'{get_def_path()}\\Actor\\Pack\\{template}.sbactorpack', path) copyfile(get_file_path(f'Actor\\Pack\\{template}.sbactorpack'), path) data = Sarc_file(path) pio = get_raw_data(data.data_sarc, f'Actor/Recipe/{template}.brecipe') if self.item1 and self.item1_n: pio.objects['Normal0'].params[ 'ItemName01'] = oead.FixedSafeString64(self.item1) pio.objects['Normal0'].params['ItemNum01'] = int(self.item1_n) if self.item1 and self.item1_n and self.item2 and self.item2_n: pio.objects['Normal0'].params[ 'ItemName02'] = oead.FixedSafeString64(self.item2) pio.objects['Normal0'].params['ItemNum02'] = int(self.item2_n) else: pio.objects['Normal0'].params['ItemNum02'] = 1 if self.item1 and self.item1_n and self.item2 and self.item2_n and self.item3 and self.item3_n: pio.objects['Normal0'].params[ 'ItemName03'] = oead.FixedSafeString64(self.item3) pio.objects['Normal0'].params['ItemNum03'] = int(self.item3_n) else: pio.objects['Normal0'].params[ 'ItemName03'] = oead.FixedSafeString64('Item_Enemy_00') self.data.data_writer.files[ f'Actor/Recipe/{recipe}'] = oead.aamp.ParameterIO.to_binary(pio)
def get_actorpack_data(self): #file = f'{get_def_path()}\\Actor\\Pack\\{self.base}.sbactorpack' file = get_file_path(f'Actor\\Pack\\{self.base}.sbactorpack') if os.path.exists(file): return Sarc_file(file) else: print(f'Cant find base actor {file}') sys.exit()
def do_anims(self): if 'Weapon_Lsword_' in self.name: template = 'Weapon_Lsword_019' else: template = 'Weapon_Sword_019' path = f'cache\\{template}.sbactorpack' if not os.path.exists(path): #copyfile(f'{get_def_path()}\\Actor\\Pack\\{template}.sbactorpack', path) copyfile(get_file_path(f'Actor\\Pack\\{template}.sbactorpack'), path) data = Sarc_file(path) for file in self.data.data_writer.files: if '.baiprog' in file or '.baslist' in file or '.bas' in file: del self.data.data_writer.files[file] new_AI = '' new_name_baslist = '' for file in data.data_writer.files: if '.baiprog' in file: new_AI = get_internal_name('.baiprog', data) pio = get_raw_data(data.data_sarc, new_AI) self.data.data_writer.files[ new_AI] = oead.aamp.ParameterIO.to_binary(pio) elif '.baslist' in file: new_name_baslist = file.replace(template, self.name) pio = get_raw_data(data.data_sarc, file) raw_text = pio.to_text() raw_text = raw_text.replace(template, self.name) pio = oead.aamp.ParameterIO.from_text(raw_text) self.data.data_writer.files[ new_name_baslist] = oead.aamp.ParameterIO.to_binary(pio) elif '.bas' in file: new_name = file.replace(template, self.name) pio = get_raw_data(data.data_sarc, file) self.data.data_writer.files[ new_name] = oead.aamp.ParameterIO.to_binary(pio) #duplicate_bfres(f'{get_def_path()}\\Model\\{template}_Animation.sbfres', f'{self.pack_name}\\content\\Model\\{self.name}_Animation.sbfres', template, self.name) duplicate_bfres( get_file_path(f'Model\\{template}_Animation.sbfres'), f'{self.pack_name}\\content\\Model\\{self.name}_Animation.sbfres', template, self.name) return os.path.basename(new_AI).split('.')[0], os.path.basename( new_name_baslist).split('.')[0]
def do_actorinfo(self): actors = get_res('Actors') A = 'ActorInfo.product.sbyml' source = f'cache\\{A}' #path = get_def_path() + '\\Actor' path = get_file_path(f'Actor\\{A}') if not os.path.exists(source): #copyfile(f'{path}\\{A}', source) copyfile(path, source) with open(source, "rb") as f: byml = oead.yaz0.decompress(f.read()) actorinfo = oead.byml.from_binary(byml) for weapon in self.weapons: actorinfo = weapon_iter(weapon, actorinfo, actors) if weapon.sheath == 'custom': actorinfo = sheath_iter(weapon, actorinfo) for armor in self.armors: actorinfo = armor_iter(armor, actorinfo, actors) with open(f'{self.pack_name}\\content\\Actor\\{A}', 'wb') as f: f.write( oead.yaz0.compress( oead.byml.to_binary(actorinfo, big_endian=get_endianness())))
def duplicate(self): base, name = self.base, self.name try: base, name = check_base(base, name, self.profile) except: pass #path = f'{get_def_path()}\\Model\\' #if get_endianness(): # base_bfres = [path + base + '.sbfres', path + base + '.Tex1.sbfres', path + base + '.Tex2.sbfres'] #else: # base_bfres = [path + base + '.sbfres', path + base + '.Tex.sbfres'] if get_endianness(): base_bfres = [get_file_path(f'Model\\{base}.sbfres'), get_file_path(f'Model\\{base}.Tex1.sbfres'), get_file_path(f'Model\\{base}.Tex2.sbfres')] else: base_bfres = [get_file_path(f'Model\\{base}.sbfres'), get_file_path(f'Model\\{base}.Tex.sbfres')] for file in base_bfres: if os.path.exists(file): output = self.pack_name + '\\content\\Model\\' + file.split('\\')[-1].replace(base, name) duplicate_bfres(file, output, old_bfres_name=base, new_bfres_name=name) #icon = get_def_path() + '\\UI\\StockItem\\' + self.base + '.sbitemico' icon = get_file_path(f'UI\\StockItem\\{self.base}.sbitemico') if os.path.exists(icon): output = self.pack_name + '\\content\\UI\\StockItem\\' + icon.split('\\')[-1].replace(self.base, self.name) duplicate_bfres(icon, output, old_bfres_name=self.base, new_bfres_name=self.name) #try_copy(f'{get_def_path()}\\UI\\StockItem\\{self.base}.01.sbitemico', f'{self.pack_name}\\content\\UI\\StockItem\\{self.name}.01.sbitemico') #icon_01_base = f'{get_def_path()}\\UI\\StockItem\\{self.base}.01.sbitemico' icon_01_base = get_file_path(f'UI\\StockItem\\{self.base}.01.sbitemico') icon_01_out = f'{self.pack_name}\\content\\UI\\StockItem\\{self.name}.01.sbitemico' duplicate_bfres(icon_01_base, icon_01_out, old_bfres_name=self.base, new_bfres_name=self.name)
def init_oven(self): #path = f'{get_def_path()}\\Actor\\Pack\\{self.shop}.sbactorpack' path = get_file_path(f'Actor\\Pack\\{self.shop}.sbactorpack') if not os.path.exists(f'cache\\{self.shop}.sbactorpack'): copyfile(path, f'cache\\{self.shop}.sbactorpack') return f'cache\\{self.shop}.sbactorpack'
def do_korok_mask(self): if not 'Head' in self.name: return template = 'Armor_176_Head' path = f'cache\\{template}.sbactorpack' if not os.path.exists(path): #copyfile(f'{get_def_path()}\\Actor\\Pack\\{template}.sbactorpack', path) copyfile(get_file_path(f'Actor\\Pack\\{template}.sbactorpack'), path) data = Sarc_file(path) if 'Actor/AS/Head_Common_ColorChange.bas' in self.data.data_writer.files: ColorChange = True else: ColorChange = False #removing misc files if 'Actor/ASList/Head_ColorChangeOnly.baslist' in self.data.data_writer.files: del self.data.data_writer.files[ 'Actor/ASList/Head_ColorChangeOnly.baslist'] for file in self.data.data_writer.files: if file == 'Actor/AS/Head_Common_ColorChange.bas': continue if '.bas' in file: del self.data.data_writer.files[file] if '.baiprog' in file or '.baslist' in file: del self.data.data_writer.files[file] for file in data.data_writer.files: if '.baiprog' in file: pio = get_raw_data(data.data_sarc, 'Actor/AIProgram/Armor_Korok_Head.baiprog') self.data.data_writer.files[ 'Actor/AIProgram/Armor_Korok_Head.baiprog'] = oead.aamp.ParameterIO.to_binary( pio) elif '.baslist' in file: new_name = file.replace(template, self.name) pio = get_raw_data(data.data_sarc, file) if ColorChange: pio.lists['ASDefines'].objects[ 'ASDefine_2'] = copy.deepcopy( pio.lists['ASDefines'].objects['ASDefine_0']) pio.lists['ASDefines'].objects['ASDefine_2'].params[ 'Name'] = oead.FixedSafeString64('ColorChange') pio.lists['ASDefines'].objects['ASDefine_2'].params[ 'Filename'] = oead.FixedSafeString64( 'Head_Common_ColorChange') raw_text = pio.to_text() raw_text = raw_text.replace(template, self.name) pio = oead.aamp.ParameterIO.from_text(raw_text) self.data.data_writer.files[ new_name] = oead.aamp.ParameterIO.to_binary(pio) elif '.bas' in file: new_name = file.replace(template, self.name) pio = get_raw_data(data.data_sarc, file) raw_text = pio.to_text() raw_text = raw_text.replace(template, self.name) pio = oead.aamp.ParameterIO.from_text(raw_text) self.data.data_writer.files[ new_name] = oead.aamp.ParameterIO.to_binary(pio) #duplicate_bfres(f'{get_def_path()}\\Model\\{template}_Animation.sbfres', f'{self.pack_name}\\content\\Model\\{self.name}_Animation.sbfres', template, self.name) duplicate_bfres( get_file_path(f'Model\\{template}_Animation.sbfres'), f'{self.pack_name}\\content\\Model\\{self.name}_Animation.sbfres', template, self.name)