def generate_bpc(ore_values, assembler_efficiency): classes = E.BlueprintClasses( E.Class( E.Id( E.TypeId("BlueprintClassDefinition"), E.SubtypeId("Canister_BPC") ), E.DisplayName("Canisters"), E.Icon("Textures\\GUI\\Icons\\Icon_Canister.dds"), E.HighlightIcon("Textures\\GUI\\Icons\\buttons\\component_highlight.dds"), E.InputConstraintIcon("Textures\\GUI\\Icons\\filter_ingot.dds") ), E.Class( E.Id( E.TypeId("BlueprintClassDefinition"), E.SubtypeId("Credit_BPC"), ), E.DisplayName("Credits"), E.Icon("Textures\\GUI\\Icons\\Icon_Credit.dds"), E.HighlightIcon("Textures\\GUI\\Icons\\buttons\\large_block_highlight.dds"), E.InputConstraintIcon("Textures\\GUI\\Icons\\filter_ore.dds"), E.OutputConstraintIcon("Textures\\GUI\\Icons\\filter_ingot.dds") ) ) entries = E.BlueprintClassEntries() # Compress blueprints #<Id> # <TypeId>BlueprintDefinition</TypeId> # <SubtypeId>Canister_Ag</SubtypeId> #</Id> #<DisplayName>Silver Canister</DisplayName> #<Icon>Textures\GUI\Icons\Icon_Canister.dds</Icon> #<Prerequisites> # <Item Amount="500" TypeId="Ingot" SubtypeId="Silver" /> #</Prerequisites> #<Result Amount="1" TypeId="Component" SubtypeId="Canister_Ag_R" /> #<BaseProductionTimeInSeconds>10</BaseProductionTimeInSeconds> #</Blueprint> for ore in ore_values: entries.append(E.Entry(Class="Credit_BPC", BlueprintSubtypeId=ore.canister_id + "_Buy")) entries.append(E.Entry(Class="Credit_BPC", BlueprintSubtypeId=ore.canister_id + "_Sell")) entries.append(E.Entry(Class="Canister_BPC", BlueprintSubtypeId=ore.canister_id + "_Compress")) write_file("Data/BPC.sbc", [classes, entries])
def generate_comp(ore_values, assembler_efficiency): components = E.Components( E.Component( E.Id( E.TypeId("Component"), E.SubtypeId("Credit") ), E.DisplayName("Credits"), E.Icon("Textures\\GUI\\Icons\\Icon_Credit.dds"), E.Size( E.X("0.2"), E.Y("0.1"), E.Z("0.1") ), E.Mass("0.1"), E.Volume("0.1"), E.Model("Models\\Credit.mwm"), E.MaxIntegrity("30"), E.DropProbability("0.5") ) ) for ore in ore_values: components.append(E.Component( E.Id( E.TypeId("Component"), E.SubtypeId(ore.canister_id) ), E.DisplayName(ore.name + " Canister"), E.Icon("Textures\\GUI\\Icons\\Icon_Canister.dds"), E.Size( E.X("0.2"), E.Y("0.1"), E.Z("0.1") ), E.Mass("375"), E.Volume("2"), E.Model("Models\\Canister_Ag.mwm"), E.MaxIntegrity("30"), E.DropProbability("0.5") )) write_file("Data/Comp.sbc", components)
def generate_bp(ore_values, assembler_efficiency): root = etree.Element("Blueprints") # Compress blueprints #<Id> # <TypeId>BlueprintDefinition</TypeId> # <SubtypeId>Canister_Ag</SubtypeId> #</Id> #<DisplayName>Silver Canister</DisplayName> #<Icon>Textures\GUI\Icons\Icon_Canister.dds</Icon> #<Prerequisites> # <Item Amount="500" TypeId="Ingot" SubtypeId="Silver" /> #</Prerequisites> #<Result Amount="1" TypeId="Component" SubtypeId="Canister_Ag_R" /> #<BaseProductionTimeInSeconds>10</BaseProductionTimeInSeconds> #</Blueprint> for ore in ore_values: bp = E.Blueprint( E.Id( E.TypeId("BlueprintDefinition"), E.SubtypeId(ore.canister_id + "_Compress") ), E.DisplayName(ore.canister_name), E.Icon("Textures\\GUI\\Icons\\Icon_Canister.dds"), E.Prerequisites( E.Item(Amount="500", TypeId=ore.item_name, SubtypeId=ore.name) ), E.Result(Amount="1", TypeId="Component", SubtypeId=ore.canister_id), E.BaseProductionTimeInSeconds("10") ) root.append(bp) # Decompression not required since it's nativly provided by the game, doh! # Change for Credit #<Blueprint> # <Id> # <TypeId>BlueprintDefinition</TypeId> # <SubtypeId>Canister_Ag2</SubtypeId> # </Id> # <DisplayName>Silver Canister</DisplayName> # <Icon>Textures\GUI\Icons\Icon_Canister.dds</Icon> # <Prerequisites> # <Item Amount="10" TypeId="Component" SubtypeId="Credit" /> # </Prerequisites> # <Result Amount="3" TypeId="Component" SubtypeId="Canister_Ag_R" /> # <BaseProductionTimeInSeconds>0.1</BaseProductionTimeInSeconds> # </Blueprint> for ore in ore_values: # Calculate sell ratio, so that 10 credits = 3 cans for silver # Silver rate is 2.2 buy_rate = ore.rate * 1.5 # All results are gurantied to be biger than 20 min_dist = 20 min_div = 0 for i in range(1, 11): dist = (buy_rate * i) - int(buy_rate * i) if(dist < min_dist): min_dist = dist min_div = i credits = str(min_div) cans = str(int(min_div * buy_rate)) target_icon = Image.open("icons/png/" + ore.icon) buy_dds = "Textures/GUI/Icons/Icon_Buy_%s.dds" % ore.name if not path.exists(buy_dds): buy_icon = "icons/png/buy_%s.png" % ore.name.lower() create_convert_icon( credit_icon, target_icon, buy_icon ) convert_dds(buy_icon, buy_dds) sell_dds = "Textures/GUI/Icons/Icon_Sell_%s.dds" % ore.name if not path.exists(sell_dds): sell_icon = "icons/png/sell_%s.png" % ore.name.lower() create_convert_icon( target_icon, credit_icon, sell_icon ) convert_dds(sell_icon, sell_dds) bp = E.Blueprint( E.Id( E.TypeId("BlueprintDefinition"), E.SubtypeId(ore.canister_id + "_Buy") ), E.DisplayName("Buy " + ore.canister_name), E.Icon(buy_dds.replace("/", "\\")), E.Prerequisites( E.Item(Amount=credits, TypeId="Component", SubtypeId="Credit") ), E.Result(Amount=cans, TypeId="Component", SubtypeId=ore.canister_id), E.BaseProductionTimeInSeconds("0.5") ) root.append(bp) bp = E.Blueprint( E.Id( E.TypeId("BlueprintDefinition"), E.SubtypeId(ore.canister_id + "_Sell") ), E.DisplayName("Sell " + ore.canister_name), E.Icon(sell_dds.replace("/", "\\")), E.Prerequisites( E.Item(Amount=cans, TypeId="Component", SubtypeId=ore.canister_id) ), E.Result(Amount=credits, TypeId="Component", SubtypeId="Credit"), E.BaseProductionTimeInSeconds("0.5") ) root.append(bp) write_file("Data/BP.sbc", root)