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 _dict_to_drop(drop_dict: dict) -> ParameterIO: pio = ParameterIO() pio.type = "xml" header = ParameterObject() header.params["TableNum"] = Parameter(len(drop_dict)) for i, table in enumerate(drop_dict.keys()): header.params[f"Table{i + 1:02}"] = Parameter( oead.FixedSafeString64(table)) pio.objects["Header"] = header for i, (table, contents) in enumerate(drop_dict.items()): header.params[f"Table{i:02}"] = table table_obj = ParameterObject() table_obj.params["RepeatNumMin"] = Parameter( contents["repeat_num_min"]) table_obj.params["RepeatNumMax"] = Parameter( contents["repeat_num_max"]) table_obj.params["ApproachType"] = Parameter(contents["approach_type"]) table_obj.params["OccurrenceSpeedType"] = Parameter( contents["occurrence_speed_type"]) table_obj.params["ColumnNum"] = Parameter(len(contents["items"])) for idx, item in enumerate(contents["items"]): table_obj.params[f"ItemName{idx + 1:02}"] = Parameter( oead.FixedSafeString64(item)) table_obj.params[f"ItemProbability{idx + 1:02}"] = Parameter( contents["items"][item]) pio.objects[table] = table_obj return pio
def do_model(self): old_name = self.get_name_from_sarc('bmodellist') new_name = f'Actor/ModelList/{self.name}.bmodellist' pio = get_raw_data(self.data.data_sarc, old_name) if self.bfres: bfres = self.bfres else: bfres = self.bfres_folder if self.mainmodel: mainmodel = self.mainmodel else: mainmodel = self.name pio.lists['ModelData'].lists['ModelData_0'].objects['Base'].params['Folder'] \ = oead.FixedSafeString64(bfres) pio.lists['ModelData'].lists['ModelData_0'].lists['Unit'].objects['Unit_0'].params['UnitName'] \ = oead.FixedSafeString64(mainmodel) update_sarc(pio, self.data, old_name, new_name)
def do_shopdata(self): old_name = f'Actor/ShopData/{self.bshop}.bshop' new_name = f'Actor/ShopData/{self.bshop}.bshop' pio = get_raw_data(self.data.data_sarc, old_name) table = self.get_pio_object(pio) #actors = dir_to_list(f'{self.pack_name}\\content\\Actor\\Pack') #iter = int(pio.objects[table].params['ColumnNum'].v) + 2 iter = int(pio.objects[table].params['ColumnNum'].v) size = 0 #items = [] #for w in self.data_json['Weapons']: items.append(w) #for a in self.data_json['Armors']: items.append(a) for w in self.items: size += 1 n = int_to_3digits(iter + size) pio.objects[table].params[f'ItemSort{n}'] = iter + size - 1 pio.objects[table].params[f'ItemName{n}'] = oead.FixedSafeString64( w) if 'Npc_DressFairy' in self.shop: pio.objects[table].params[f'ItemNum{n}'] = 0 else: pio.objects[table].params[f'ItemNum{n}'] = 1 pio.objects[table].params[f'ItemAdjustPrice{n}'] = 0 pio.objects[table].params[f'ItemLookGetFlg{n}'] = False pio.objects[table].params[f'ItemAmount{n}'] = 0 pio.objects[table].params['ColumnNum'] = size + iter update_sarc(pio, self.data, old_name, new_name)
def do_gparam(self): if self.effect_lv.isnumeric(): eff_lv = int(self.effect_lv) else: eff_lv = 0 if eff_lv > 3: eff_lv = 3 old_name = self.get_name_from_sarc('bgparamlist') new_name = f'Actor/GeneralParamList/{self.name}.bgparamlist' pio = get_raw_data(self.data.data_sarc, old_name) if self.price: pio.objects['Item'].params["BuyingPrice"] = int(self.price) if self.defence: pio.objects['Armor'].params["DefenceAddLevel"] = int(self.defence) if self.armorStarNum: pio.objects['Armor'].params["StarNum"] = int(self.armorStarNum) if self.series: pio.objects['SeriesArmor'].params[ "SeriesType"] = oead.FixedSafeString32(self.series) if self.itemUseIconActorName: pio.objects['Item'].params[ "UseIconActorName"] = oead.FixedSafeString64( self.itemUseIconActorName) if self.effect: if self.effect == 'None': pio.objects['ArmorEffect'].params[ "EffectType"] = oead.FixedSafeString32('') else: pio.objects['ArmorEffect'].params[ "EffectType"] = oead.FixedSafeString32(self.effect) if self.effect_lv: pio.objects['ArmorEffect'].params["EffectLevel"] = eff_lv if self.armorNextRankName: pio.objects['Armor'].params[ "NextRankName"] = oead.FixedSafeString64( self.armorNextRankName) update_sarc(pio, self.data, old_name, new_name)
def do_shop_grante(self): old_name = new_name = f'Actor/ShopData/{self.bshop}.bshop' pio = get_raw_data(self.data.data_sarc, old_name) tabs = self.get_all_tables(pio) for table in tabs: iter = int(pio.objects[table].params['ColumnNum'].v) size = 0 for w in self.items: size += 1 n = int_to_3digits(iter + size) pio.objects[table].params[f'ItemSort{n}'] = iter + size - 1 pio.objects[table].params[ f'ItemName{n}'] = oead.FixedSafeString64(w) pio.objects[table].params[f'ItemNum{n}'] = 1 pio.objects[table].params[f'ItemAdjustPrice{n}'] = 0 pio.objects[table].params[f'ItemLookGetFlg{n}'] = False pio.objects[table].params[f'ItemAmount{n}'] = 0 pio.objects[table].params['ColumnNum'] = size + iter update_sarc(pio, self.data, old_name, new_name)
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)