Okay, the final variant is hereby presented for the community to use.
Insert this anywhere:
Insert this into any mission template where you want conditional object removal (assuming you need mission-based control over objects, otherwise just don't use these lines and remove corresponding check in module_scene_props.py):
Insert this anywhere, preferably at the end of the file:
Insert this at the very end of the file:
Quick guide for scene editors.
Insert this anywhere:
Code:
situational_scene_var_id = 127 ## When a scene prop has this number as first variation ID, it is subject to situational removal, all other scene props are ignored
Insert this into any mission template where you want conditional object removal (assuming you need mission-based control over objects, otherwise just don't use these lines and remove corresponding check in module_scene_props.py):
Code:
(ti_before_mission_start, 0, 0, [], [(assign, "$g_scene_requires_objects_removal", 1)]),
(ti_after_mission_start, 0, 0, [], [(assign, "$g_scene_requires_objects_removal", 0)]),
Insert this anywhere, preferably at the end of the file:
Code:
# script_scene_prop_needs_removal
# Input: scene_prop_id, variation_id
# Output: reg0 should contain 1 or 0 (needs removal or not)
# This is a dummy script which always tells to never remove anything.
# Replace this with actual code according to your needs.
("scene_prop_needs_removal",
[
#(store_script_param_1, ":scene_prop_instance_id"),
#(prop_instance_get_scene_prop_kind, ":scene_prop_id", ":scene_prop_instance_id"), ## For checks on scene_prop type etc
(assign, reg0, 0),
]
),
Insert this at the very end of the file:
Code:
from ID_scripts import *
append_to_props_list = (ti_on_scene_prop_init,
[
(try_begin),
(eq, "$g_scene_requires_objects_removal", 1), # If scene doesn't want situational control over scene props, we exit immediately
(store_trigger_param_1, ":scene_prop_instance_id"),
(prop_instance_get_variation_id, ":var_id", ":scene_prop_instance_id"),
(eq, ":var_id", situational_scene_var_id), ## We check that first variation ID matches the one defined in constants as situational flag
(call_script, "script_scene_prop_needs_removal", ":scene_prop_instance_id"),
(eq, reg0, 1),
(prop_instance_get_position, pos1, ":scene_prop_instance_id"),
(position_set_z, pos1, -1000),
(prop_instance_set_position, ":scene_prop_instance_id", pos1),
(try_end),
]
)
for key in range(len(scene_props)):
scene_props[key][4].append(append_to_props_list)
Quick guide for scene editors.
1. Put 127 as the variation ID #1 to make the prop subject to situational removal.
2. Put conditional code (supplied by module scripters) as the variation ID #2.
3. Voila, when the condition defined by the conditional code is met, the prop will not appear on the scene.
4. All you need is the list of conditional codes, which will look like follows:
2. Put conditional code (supplied by module scripters) as the variation ID #2.
3. Voila, when the condition defined by the conditional code is met, the prop will not appear on the scene.
4. All you need is the list of conditional codes, which will look like follows:
Code:
{1} Village has blacksmith
{2} Village does not have blacksmith
{3} Village has mill
{4} Village does not have mill
(etc)