duck83
Veteran

Hello.
I made some questions in Q&A thread, but thought it's too much chaos now in there and will start a new thread.
In my mod I have trees that can be choppable. I want them to become trunks if destroyed. I can handle it pretty easy by moving the tree underground and spawning a trunk in it's place.
The thing is I want those trunks appear whenever I re-enter the scene. So far all scene props (including those trees) are loaded just as I have placed them while editing scene. If I destroy one tree, I will see a trunk spawn in it's place but the tree will appear again after I re-enter the scene.
I have made quite an odd code I think, as I barely can understand it myself.
Please, if any of you have a bit of time, look into it. I'm trying to use slot_scene_prop_chopped, defined in module_constants before "scene_prop_slots_end " in Scene props section. I don't know how it is meant to work, but so far my code doesn't make that slot to keep data about the tree being destroyed. The tree appears again, every time I enter my scene.
Here is the code:
I'm not a coder myself and I can't really check if the code is written well, beside the fact to see how it works in game. I have some thought that perhaps my trigger parameters are set somewhat wrong.
I know it's basically a boring thread for more experience moders, but if any of you was to share some thoughts on my code I would be most grateful. I also am not sure if I have defined that slot_scene_prop_chopped well in module_constants. Like I said it's before "scene_prop_slots_end" and after "scene_prop_belfry_platform_moved" and has set a number 6. That number was earlier used by "scene_prop_slots_end" and now it has 7. I don't know if it is also correct.
I made some questions in Q&A thread, but thought it's too much chaos now in there and will start a new thread.
In my mod I have trees that can be choppable. I want them to become trunks if destroyed. I can handle it pretty easy by moving the tree underground and spawning a trunk in it's place.
The thing is I want those trunks appear whenever I re-enter the scene. So far all scene props (including those trees) are loaded just as I have placed them while editing scene. If I destroy one tree, I will see a trunk spawn in it's place but the tree will appear again after I re-enter the scene.
I have made quite an odd code I think, as I barely can understand it myself.
Please, if any of you have a bit of time, look into it. I'm trying to use slot_scene_prop_chopped, defined in module_constants before "scene_prop_slots_end " in Scene props section. I don't know how it is meant to work, but so far my code doesn't make that slot to keep data about the tree being destroyed. The tree appears again, every time I enter my scene.
Here is the code:
###aspen_C
("tree_aspen_c",sokf_destructible,"chopable_aspen_c","bo_chopable_aspen_c",
[
(ti_on_init_scene_prop,
[
(store_trigger_param_1, ":instance_no"),
(store_trigger_param_2, ":chopped"),
(try_begin),
(scene_prop_set_hit_points, ":instance_no", 199),
####code by Dusk Voyager
(else_try),
(scene_prop_slot_eq, ":chopped", slot_scene_prop_chopped, 1),
(prop_instance_get_position, pos1, ":chopped"),
(set_spawn_position, pos1),
(spawn_scene_prop, "spr_trunk_aspen_c"),
(try_end),
####ends here
]),
(ti_on_scene_prop_destroy,
[
(this_or_next|multiplayer_is_server),#only serverside
(neg|game_in_multiplayer_mode),
(store_trigger_param_1, ":instance_id"),
(store_trigger_param_2, ":being_chopped"),
(prop_instance_get_position, pos1, ":instance_id"),
(set_spawn_position, pos1),
(spawn_scene_prop, "spr_preitem_aspen_c"),
(spawn_scene_prop, "spr_trunk_aspen_c"),
(position_set_z, pos1, -10000),
(prop_instance_set_position, ":instance_id", pos1, 0),
(play_sound, "snd_dummy_hit"),
(particle_system_burst, "psys_dummy_smoke", pos1, 3),
(particle_system_burst, "psys_dummy_straw", pos1, 10),
####another part of code by Dusk Voyager
(scene_prop_set_slot, ":being_chopped", slot_scene_prop_chopped, 1),
####ends here
]),
(ti_on_scene_prop_hit,
[
(play_sound, "snd_dummy_hit"),
(particle_system_burst, "psys_dummy_straw", pos1, 10),
]),
]),
("tree_aspen_c",sokf_destructible,"chopable_aspen_c","bo_chopable_aspen_c",
[
(ti_on_init_scene_prop,
[
(store_trigger_param_1, ":instance_no"),
(store_trigger_param_2, ":chopped"),
(try_begin),
(scene_prop_set_hit_points, ":instance_no", 199),
####code by Dusk Voyager
(else_try),
(scene_prop_slot_eq, ":chopped", slot_scene_prop_chopped, 1),
(prop_instance_get_position, pos1, ":chopped"),
(set_spawn_position, pos1),
(spawn_scene_prop, "spr_trunk_aspen_c"),
(try_end),
####ends here
]),
(ti_on_scene_prop_destroy,
[
(this_or_next|multiplayer_is_server),#only serverside
(neg|game_in_multiplayer_mode),
(store_trigger_param_1, ":instance_id"),
(store_trigger_param_2, ":being_chopped"),
(prop_instance_get_position, pos1, ":instance_id"),
(set_spawn_position, pos1),
(spawn_scene_prop, "spr_preitem_aspen_c"),
(spawn_scene_prop, "spr_trunk_aspen_c"),
(position_set_z, pos1, -10000),
(prop_instance_set_position, ":instance_id", pos1, 0),
(play_sound, "snd_dummy_hit"),
(particle_system_burst, "psys_dummy_smoke", pos1, 3),
(particle_system_burst, "psys_dummy_straw", pos1, 10),
####another part of code by Dusk Voyager
(scene_prop_set_slot, ":being_chopped", slot_scene_prop_chopped, 1),
####ends here
]),
(ti_on_scene_prop_hit,
[
(play_sound, "snd_dummy_hit"),
(particle_system_burst, "psys_dummy_straw", pos1, 10),
]),
]),
I'm not a coder myself and I can't really check if the code is written well, beside the fact to see how it works in game. I have some thought that perhaps my trigger parameters are set somewhat wrong.
I know it's basically a boring thread for more experience moders, but if any of you was to share some thoughts on my code I would be most grateful. I also am not sure if I have defined that slot_scene_prop_chopped well in module_constants. Like I said it's before "scene_prop_slots_end" and after "scene_prop_belfry_platform_moved" and has set a number 6. That number was earlier used by "scene_prop_slots_end" and now it has 7. I don't know if it is also correct.

