@@ -122,71 +122,57 @@ def get_files(options: dict) -> list[str]:
122122 return atv_files
123123
124124def _update_gears (values : list [float ], start_offset : int ) -> None :
125+ updates = []
125126 for i , value in enumerate (values ):
126- mods .update_file_at_offset (TRANSMISSION_FILE , start_offset + (i * 4 ), float (value ))
127-
128- def process (options : dict ) -> None :
129- options = map_options (options )
130- top_speed = options ["top_speed" ]
131- acceleration = options ["acceleration" ]
132- traction = options ["traction" ]
133- noise = options ["noise_distance" ]
134- vision = options ["vision_distance" ]
135-
136- if top_speed == "90" :
137- speed_options = SPEED_90
138- elif top_speed == "120" :
139- speed_options = SPEED_120
140- elif top_speed == "150" :
141- speed_options = SPEED_150
142- elif top_speed == "170" :
143- speed_options = SPEED_170
144- else :
145- speed_options = SPEED_70
146-
147- if acceleration == "medium" :
148- torque_option = TORQUE_MEDIUM
149- elif acceleration == "high" :
150- torque_option = TORQUE_HIGH
151- else :
152- torque_option = TORQUE_DEFAULT
153-
154- if traction == "medium" :
155- traction_option = TRACTION_MEDIUM
156- elif traction == "high" :
157- traction_option = TRACTION_HIGH
158- else :
159- traction_option = TRACTION_DEFAULT
160-
161- gears = speed_options ["gears" ]
162- upshift = speed_options ["upshift" ]
163- downshift = speed_options ["downshift" ]
164-
165- _update_gears ([gears [0 ], gears [1 ], gears [2 ], gears [3 ], gears [4 ], gears [5 ], gears [6 ], gears [7 ]], 196 )
166- _update_gears ([upshift [0 ], upshift [1 ], upshift [2 ], upshift [3 ], upshift [4 ], upshift [5 ], upshift [6 ], upshift [7 ]], 228 )
167- _update_gears ([downshift [0 ], downshift [1 ], downshift [2 ], downshift [3 ], downshift [4 ], downshift [5 ], downshift [6 ], downshift [7 ]], 260 )
168-
169- mods .update_file_at_offset (TRANSMISSION_FILE , 192 , 1 )
170- mods .update_file_at_offset (TRANSMISSION_FILE , 316 , 250.0 )
171- mods .update_file_at_offset (TRANSMISSION_FILE , 332 , 3.0 )
172-
173- mods .update_file_at_offset (LANDGLOBAL_FILE , 236 , traction_option ["front_friction" ])
174- mods .update_file_at_offset (LANDGLOBAL_FILE , 240 , 0.0 )
175- mods .update_file_at_offset (LANDGLOBAL_FILE , 268 , traction_option ["rear_friction" ])
176- mods .update_file_at_offset (LANDGLOBAL_FILE , 272 , 0.0 )
177- mods .update_file_at_offset (LANDGLOBAL_FILE , 228 , 0 , format = "sint08" )
178- mods .update_file_at_offset (LANDGLOBAL_FILE , 260 , 0 , format = "sint08" )
179- mods .update_file_at_offset (LANDENGINE_FILE , 196 , 0.05 )
180- mods .update_file_at_offset (LANDENGINE_FILE , 208 , speed_options ["max_rpm" ])
181- mods .update_file_at_offset (LANDENGINE_FILE , 216 , speed_options ["optimal_rpm" ])
182- mods .update_file_at_offset (LANDENGINE_FILE , 220 , torque_option ["max" ])
183- mods .update_file_at_offset (LANDENGINE_FILE , 224 , torque_option ["min" ])
184- mods .update_file_at_offset (LANDENGINE_FILE , 228 , torque_option ["optimal" ])
185-
186- mods .update_file_at_offset (AERODYNAMICS_FILE , 192 , 1.25 )
187- mods .update_file_at_offset (AERODYNAMICS_FILE , 196 , 0.3 )
188- mods .update_file_at_offset (AERODYNAMICS_FILE , 200 , 0.3 )
189-
127+ updates .append ({"offset" : start_offset + (i * 4 ), "value" : float (value )})
128+ return updates
129+
130+ def update_transmission_file (speed_options : dict ) -> None :
131+ transmission = mods2 .deserialize_adf (TRANSMISSION_FILE ).table_instance_full_values [0 ].value
132+ updates = [
133+ {"offset" : transmission ["nitrous_gears" ].data_offset , "value" : 1 },
134+ {"offset" : transmission ["top_speed" ].data_offset , "value" : 250.0 },
135+ {"offset" : transmission ["reverse_gear_ratio" ].data_offset , "value" : 3.0 },
136+ ]
137+ updates .extend (_update_gears (speed_options ["gears" ], transmission ["gear_ratios" ].data_offset ))
138+ updates .extend (_update_gears (speed_options ["upshift" ], transmission ["upshift_rpm" ].data_offset ))
139+ updates .extend (_update_gears (speed_options ["downshift" ], transmission ["downshift_rpm" ].data_offset ))
140+ mods .apply_updates_to_file (TRANSMISSION_FILE , updates )
141+
142+ def update_landengine_file (speed_options : dict , torque_option : dict ) -> None :
143+ landengine = mods2 .deserialize_adf (LANDENGINE_FILE ).table_instance_full_values [0 ].value
144+ updates = [
145+ {"offset" : landengine ["resistance_at_max_rpm" ].data_offset , "value" : 0.05 },
146+ {"offset" : landengine ["max_rpm" ].data_offset , "value" : speed_options ["max_rpm" ]},
147+ {"offset" : landengine ["optimal_rpm" ].data_offset , "value" : speed_options ["optimal_rpm" ]},
148+ {"offset" : landengine ["torque_factor_at_max_rpm" ].data_offset , "value" : torque_option ["max" ]},
149+ {"offset" : landengine ["torque_factor_at_min_rpm" ].data_offset , "value" : torque_option ["min" ]},
150+ {"offset" : landengine ["torque_factor_at_optimal_rpm" ].data_offset , "value" : torque_option ["optimal" ]},
151+ ]
152+ mods .apply_updates_to_file (LANDENGINE_FILE , updates )
153+
154+ def update_landglobal_file (traction_option : dict ) -> None :
155+ landglobal = mods2 .deserialize_adf (LANDGLOBAL_FILE ).table_instance_full_values [0 ].value
156+ updates = [
157+ {"offset" : landglobal ["front_wheels" ].value ["arcade_friction_multiplier" ].data_offset , "value" : traction_option ["front_friction" ]},
158+ {"offset" : landglobal ["front_wheels" ].value ["arcade_drag_multiplier" ].data_offset , "value" : 0.0 },
159+ {"offset" : landglobal ["rear_wheels" ].value ["arcade_friction_multiplier" ].data_offset , "value" : traction_option ["rear_friction" ]},
160+ {"offset" : landglobal ["rear_wheels" ].value ["arcade_drag_multiplier" ].data_offset , "value" : 0.0 },
161+ {"offset" : landglobal ["front_wheels" ].value ["use_shape_cast" ].data_offset , "value" : 0 , "format" : "sint08" },
162+ {"offset" : landglobal ["rear_wheels" ].value ["use_shape_cast" ].data_offset , "value" : 0 , "format" : "sint08" },
163+ ]
164+ mods .apply_updates_to_file (LANDGLOBAL_FILE , updates )
165+
166+ def update_aerodynamics_file () -> None :
167+ aerodynamics = mods2 .deserialize_adf (AERODYNAMICS_FILE ).table_instance_full_values [0 ].value
168+ updates = [
169+ {"offset" : aerodynamics ["frontal_area" ].data_offset , "value" : 1.25 },
170+ {"offset" : aerodynamics ["drag_coefficient" ].data_offset , "value" : 0.3 },
171+ {"offset" : aerodynamics ["top_speed_drag_coefficient" ].data_offset , "value" : 0.3 },
172+ ]
173+ mods .apply_updates_to_file (AERODYNAMICS_FILE , updates )
174+
175+ def update_noise_file (noise : float , vision : float ) -> None :
190176 if noise != 500.0 :
191177 mods2 .update_file_at_multiple_coordinates_with_value (NOISE_PATH , "vehicle_data" , ["B4" , "C4" ], int (noise ))
192178 if noise < 150 :
@@ -196,6 +182,32 @@ def process(options: dict) -> None:
196182 if vision < 50 :
197183 mods2 .update_file_at_multiple_coordinates_with_value (NOISE_PATH , "vehicle_data" , ["B8" , "C8" ], int (noise ))
198184
185+ def process (options : dict ) -> None :
186+ options = map_options (options )
187+
188+ speed_options = {
189+ "90" : SPEED_90 ,
190+ "120" : SPEED_120 ,
191+ "150" : SPEED_150 ,
192+ "170" : SPEED_170 ,
193+ }.get (options ["top_speed" ], SPEED_70 )
194+
195+ torque_option = {
196+ "medium" : TORQUE_MEDIUM ,
197+ "high" : TORQUE_HIGH ,
198+ }.get (options ["acceleration" ], TORQUE_DEFAULT )
199+
200+ traction_option = {
201+ "medium" : TRACTION_MEDIUM ,
202+ "high" : TRACTION_HIGH ,
203+ }.get (options ["traction" ], TRACTION_DEFAULT )
204+
205+ update_transmission_file (speed_options )
206+ update_landengine_file (speed_options , torque_option )
207+ update_landglobal_file (traction_option )
208+ update_aerodynamics_file ()
209+ update_noise_file (options ["noise_distance" ], options ["vision_distance" ])
210+
199211def merge_files (files : list [str ], options : dict ) -> None :
200212 for bundle_file in [RED_MERGE_PATH , SILVER_MERGE_PATH , JADE_MERGE_PATH ]:
201213 bundle_lookup = mods .get_sarc_file_info (mods .APP_DIR_PATH / "org" / bundle_file )
0 commit comments