From ecc78e66d9583a011d518e1cd062e178e15deee8 Mon Sep 17 00:00:00 2001 From: "Andrew Rove (Rover)" Date: Sat, 27 Oct 2018 23:55:15 -0500 Subject: [PATCH 1/2] Add transformer Set_Marine_Training_Cost_And_Time_Divisors to change marine training cost and time --- .../Transforms/T_Obj_Code/Marines.py | 37 ++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/X3_Customizer/Transforms/T_Obj_Code/Marines.py b/X3_Customizer/Transforms/T_Obj_Code/Marines.py index 2a5c624..b61ce33 100644 --- a/X3_Customizer/Transforms/T_Obj_Code/Marines.py +++ b/X3_Customizer/Transforms/T_Obj_Code/Marines.py @@ -260,4 +260,39 @@ def Make_Terran_Stations_Make_Terran_Marines( ) Apply_Obj_Patch(patch) - return \ No newline at end of file + return + +@File_Manager.Transform_Wrapper('L/x3story.obj', LU = False, TC = False) +def Set_Marine_Training_Cost_And_Time_Divisors( + cost_divisor = 5, + time_divisor = 5, + ): + ''' + The higher the divisor the cheaper/faster training will be + The lower the divisor the more expensive/slower training will be + ''' + + # Each skill has a max value of 100, so any value over 100 will always result in 0 + max_count = 100 + + cost_divisor = max(1, min(int(cost_divisor), max_count)) + time_divisor = max(1, min(int(time_divisor), max_count)) + + # Convert to hex strings, 1 byte each. + cost_divisor = Int_To_Hex_String(cost_divisor, 1) + time_divisor = Int_To_Hex_String(time_divisor, 1) + + patch_fields = [ + ['32' '000D3C7F' '0D' '0002' '05' '..' '51' '02' '46' '0D' '0004' '06' '1388', + '32' '000D3C7F' '0D' '0002' '05'+cost_divisor+'51' '02' '46' '0D' '0004' '06' '1388'], + ['32' '000D3D3F' '0D' '0002' '05' '..' '51' '02' '46' '0D' '0004' '06' '012C', + '32' '000D3D3F' '0D' '0002' '05'+time_divisor+'51' '02' '46' '0D' '0004' '06' '012C'], + ] + + patch_list = [] + for ref_code, replacement in patch_fields: + patch_list.append( Obj_Patch( + #offsets = [offset], + ref_code = ref_code, + new_code = replacement, + )) From 02acf5bfa1b694ec9b13f0b1a6dd15db6f9f12f7 Mon Sep 17 00:00:00 2001 From: "Andrew Rove (Rover)" Date: Sun, 28 Oct 2018 00:01:46 -0500 Subject: [PATCH 2/2] Forgot to add application of patch after creation and return. --- X3_Customizer/Transforms/T_Obj_Code/Marines.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/X3_Customizer/Transforms/T_Obj_Code/Marines.py b/X3_Customizer/Transforms/T_Obj_Code/Marines.py index b61ce33..ab06a90 100644 --- a/X3_Customizer/Transforms/T_Obj_Code/Marines.py +++ b/X3_Customizer/Transforms/T_Obj_Code/Marines.py @@ -296,3 +296,8 @@ def Set_Marine_Training_Cost_And_Time_Divisors( ref_code = ref_code, new_code = replacement, )) + + # Apply the patches. + Apply_Obj_Patch_Group(patch_list) + + return