Skip to content

Commit 98a5b03

Browse files
committed
v2.2.8: Bugfixes for Alberta map and Snowfall Update
1 parent 7366d3e commit 98a5b03

11 files changed

Lines changed: 208 additions & 176 deletions

modbuilder/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
__app_name__ = "modbuilder"
2-
__version__ = "2.2.7"
2+
__version__ = "2.2.8"

modbuilder/mods2.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99
from modbuilder import mods
1010

1111

12-
def deserialize_adf(filename: str) -> Adf:
13-
modded_file = mods.get_modded_file(filename)
12+
def deserialize_adf(filename: str, modded: bool = True) -> Adf:
13+
file = mods.get_modded_file(filename) if modded else mods.get_org_file(filename)
1414
adf = Adf()
15-
with ArchiveFile(open(modded_file, 'rb')) as f:
15+
with ArchiveFile(open(file, 'rb')) as f:
1616
adf.deserialize(f)
1717
return adf
1818

modbuilder/plugins/clean_scope_lenses.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def format(options: dict) -> str:
2727
def get_files(options: dict) -> list[str]:
2828
night_vision = options.get("remove_night_vision_tint")
2929
if night_vision:
30-
return [NIGHT_VISION_FILE, NIGHT_VISION_WHITE_FILE]
30+
return [NIGHT_VISION_FILE]
3131
return []
3232

3333
def merge_files(files: list[str], options: dict) -> None:
@@ -41,7 +41,7 @@ def merge_files(files: list[str], options: dict) -> None:
4141
def process(options: dict) -> None:
4242
night_vision = options.get("remove_night_vision_tint")
4343
if night_vision:
44-
white_adf = mods2.deserialize_adf(NIGHT_VISION_WHITE_FILE)
44+
white_adf = mods2.deserialize_adf(NIGHT_VISION_WHITE_FILE, modded=False)
4545
tint_index = white_adf.table_instance_full_values[0].value["Hashes"].value.index(2219558163)
4646
tint_value_1 = white_adf.table_instance_full_values[0].value["Parameters"].value[tint_index].value["Keys"].value[0]
4747
tint_value_2 = white_adf.table_instance_full_values[0].value["Parameters"].value[tint_index].value["Values"].value[0]

modbuilder/plugins/decrease_wobble.py

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import List
1+
from modbuilder import mods2
22

33
DEBUG = False
44
NAME = "Decrease Wobble"
@@ -28,24 +28,21 @@ def format(options: dict) -> str:
2828
prone_percent = options['reduce_prone_percent']
2929
return f"Decrease Wobble (-{int(stand_percent)}% stand, -{int(crouch_percent)}% crouch, -{int(prone_percent)}% prone)"
3030

31-
def update_values_at_offset(options: dict) -> List[dict]:
32-
stand_percent = options['reduce_stand_percent']
33-
crouch_percent = options['reduce_crouch_percent']
34-
prone_percent = options['reduce_prone_percent']
35-
stand_value = round(1.0 - stand_percent / 100, 1)
36-
crouch_value = round(1.0 - crouch_percent / 100, 1)
37-
prone_value = round(1.0 - prone_percent / 100, 1)
38-
return [
31+
def update_values_at_offset(options: dict) -> None:
32+
movement_file = mods2.deserialize_adf(FILE)
33+
weapon_settings = movement_file.table_instance_full_values[0].value["FpsSettings"].value["WeaponSkillSettings"].value
34+
updates = [
3935
{
40-
"offset": 444,
41-
"value": stand_value
36+
"offset": weapon_settings["StandingWoobleModifier"].data_offset,
37+
"value": round(1.0 - options['reduce_stand_percent'] / 100, 1),
4238
},
4339
{
44-
"offset": 448,
45-
"value": crouch_value
40+
"offset": weapon_settings["CrouchWoobleModifier"].data_offset,
41+
"value": round(1.0 - options['reduce_crouch_percent'] / 100, 1),
4642
},
4743
{
48-
"offset": 452,
49-
"value": prone_value
50-
}
51-
]
44+
"offset": weapon_settings["CrawlWoobleModifier"].data_offset,
45+
"value": round(1.0 - options['reduce_prone_percent'] / 100, 1),
46+
},
47+
]
48+
return updates
Lines changed: 32 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import List
1+
from modbuilder import mods2
22

33
DEBUG = False
44
NAME = "Increase Speed"
@@ -23,7 +23,9 @@ def format(options: dict) -> str:
2323
prone_sprint_multiplier = options['prone_sprint_speed_multiplier']
2424
return f"Increase Speed ({round(stand_multiplier, 1)}/{round(stand_sprint_multiplier, 1)}x, {round(crouch_multiplier, 1)}/{round(crouch_sprint_multiplier, 1)}x, {round(prone_multiplier, 1)}/{round(prone_sprint_multiplier, 1)}x)"
2525

26-
def update_values_at_offset(options: dict) -> List[dict]:
26+
def update_values_at_offset(options: dict) -> None:
27+
movement_file = mods2.deserialize_adf(FILE)
28+
fps_settings = movement_file.table_instance_full_values[0].value["FpsSettings"].value
2729
stand_multiplier = options['stand_speed_multiplier']
2830
crouch_multiplier = options['crouch_speed_multiplier']
2931
prone_multiplier = options['prone_speed_multiplier']
@@ -32,70 +34,75 @@ def update_values_at_offset(options: dict) -> List[dict]:
3234
prone_sprint_multiplier = options['prone_sprint_speed_multiplier']
3335
jump_multiplier = options['jump_speed_multiplier']
3436

35-
return [
37+
updates = [
38+
# Gamepad settings
3639
{
37-
"offset": 176,
40+
"offset": fps_settings["GamepadStanceStandSpeedModifier"].data_offset,
3841
"transform": "multiply",
3942
"value": stand_multiplier
4043
},
4144
{
42-
"offset": 180,
45+
"offset": fps_settings["GamepadStanceStandSprintSpeedModifier"].data_offset,
4346
"transform": "multiply",
4447
"value": stand_sprint_multiplier
4548
},
4649
{
47-
"offset": 200,
50+
"offset": fps_settings["GamepadStanceCrouchSpeedModifier"].data_offset,
4851
"transform": "multiply",
49-
"value": stand_multiplier
52+
"value": crouch_multiplier
5053
},
5154
{
52-
"offset": 204,
55+
"offset": fps_settings["GamepadStanceCrouchSprintModifier"].data_offset,
5356
"transform": "multiply",
54-
"value": stand_sprint_multiplier
57+
"value": crouch_sprint_multiplier
5558
},
5659
{
57-
"offset": 184,
60+
"offset": fps_settings["GamepadStanceProneSpeedModifier"].data_offset,
5861
"transform": "multiply",
59-
"value": crouch_multiplier
62+
"value": prone_multiplier
6063
},
6164
{
62-
"offset": 188,
65+
"offset": fps_settings["GamepadStanceProneSprintModifier"].data_offset,
6366
"transform": "multiply",
64-
"value": crouch_sprint_multiplier
67+
"value": prone_sprint_multiplier
6568
},
69+
# Keyboard settings
6670
{
67-
"offset": 208,
71+
"offset": fps_settings["KeyboardStanceStandSpeedModifier"].data_offset,
6872
"transform": "multiply",
69-
"value": crouch_multiplier
73+
"value": stand_multiplier
7074
},
7175
{
72-
"offset": 212,
76+
"offset": fps_settings["KeyboardStanceStandSprintSpeedModifier"].data_offset,
7377
"transform": "multiply",
74-
"value": crouch_sprint_multiplier
78+
"value": stand_sprint_multiplier
7579
},
7680
{
77-
"offset": 192,
81+
"offset": fps_settings["KeyboardStanceCrouchSpeedModifier"].data_offset,
7882
"transform": "multiply",
79-
"value": prone_multiplier
83+
"value": crouch_multiplier
8084
},
8185
{
82-
"offset": 196,
86+
"offset": fps_settings["KeyboardStanceCrouchSprintModifier"].data_offset,
8387
"transform": "multiply",
84-
"value": prone_sprint_multiplier
88+
"value": crouch_sprint_multiplier
8589
},
8690
{
87-
"offset": 216,
91+
"offset": fps_settings["KeyboardStanceProneSpeedModifier"].data_offset,
8892
"transform": "multiply",
8993
"value": prone_multiplier
9094
},
9195
{
92-
"offset": 220,
96+
"offset": fps_settings["KeyboardStanceProneSprintModifier"].data_offset,
9397
"transform": "multiply",
9498
"value": prone_sprint_multiplier
9599
},
100+
# Jump settings
96101
{
97-
"offset": 228,
102+
"offset": fps_settings["JumpSpeed"].data_offset,
98103
"transform": "multiply",
99104
"value": jump_multiplier
100105
}
101-
]
106+
]
107+
108+
return updates

modbuilder/plugins/increase_weapon_fov.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from modbuilder import mods
1+
from modbuilder import mods, mods2
22

33
DEBUG = False
44
NAME = "Increase Weapon FOV"
@@ -28,5 +28,9 @@ def get_files(options: dict) -> list[str]:
2828

2929
def process(options: dict) -> None:
3030
weapon_fov = options["first-person_weapon_fov"]
31-
mods.update_file_at_offset(FIRST_PERSON_FOV_FILE, 248, weapon_fov)
32-
mods.update_file_at_offset(PRONE_FOV_FILE, 248, weapon_fov)
31+
first_person_file = mods2.deserialize_adf(FIRST_PERSON_FOV_FILE)
32+
first_person_fov = first_person_file.table_instance_full_values[0].value["ForeGroundFOV"]
33+
prone_file = mods2.deserialize_adf(FIRST_PERSON_FOV_FILE)
34+
prone_fov = prone_file.table_instance_full_values[0].value["ForeGroundFOV"]
35+
mods.update_file_at_offset(FIRST_PERSON_FOV_FILE, first_person_fov.data_offset, weapon_fov)
36+
mods.update_file_at_offset(PRONE_FOV_FILE, prone_fov.data_offset, weapon_fov)

modbuilder/plugins/modify_animal_senses.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,12 +97,15 @@ def process(options: dict) -> list[dict]:
9797
defensive_duration_percent = 1 - options.get('reduce_defensive_duration_percent', 0) / 100
9898
mods2.update_file_at_multiple_coordinates_with_value(ANIMAL_SENSES_FILE, "species_data", ["B14", "B15", "B16", "B17"], defensive_duration_percent, transform="multiply", skip_add_data=True)
9999

100+
ai_data = mods2.deserialize_adf(AI_FILE)
101+
ai_data_ranges = ai_data.table_instance_full_values[0].value["Perception"].value["EventRanges"].value
100102
tent_distance = options.get("tent_detection_distance")
101103
if tent_distance is not None:
102-
mods.update_file_at_offset(AI_FILE, 800, tent_distance)
104+
mods.update_file_at_offset(AI_FILE, ai_data_ranges["SpookInRadius"].data_offset, tent_distance)
103105

104106
weapon_fire_distance = options.get("weapon_fire_detection_distance")
105107
if weapon_fire_distance is not None:
106108
weapon_fire_distance_multiplier = weapon_fire_distance / 300 # default range
107109
weapon_fire_coordinates = mods2.get_coordinates_range_from_file(ANIMAL_SENSES_FILE, "weapon_data", rows=(3, 4), cols=("B", None))
108110
mods2.update_file_at_multiple_coordinates_with_value(ANIMAL_SENSES_FILE, "weapon_data", weapon_fire_coordinates, weapon_fire_distance_multiplier, transform="multiply", skip_add_data=True)
111+
mods.update_file_at_offset(AI_FILE, ai_data_ranges["WeaponFire"].data_offset, weapon_fire_distance)

modbuilder/plugins/modify_atv.py

Lines changed: 76 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -122,71 +122,57 @@ def get_files(options: dict) -> list[str]:
122122
return atv_files
123123

124124
def _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+
199211
def 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

Comments
 (0)