Scene props - swapping one for another

Users who are viewing this thread

I'm not sure how you would do it exactly, but I think this example from the training ground training mission template should help you figure it out. Look for the bits where you have to destroy gourds. I think what it does is replace the gourd prop with a destroyed gourd prop when you destroy one.

  (
    "training_ground_training", mtf_arena_fight, -1,
    "Training.",
    [
      (0,mtef_visitor_source|mtef_team_0,af_override_everything,aif_start_alarmed,1,[itm_practice_staff]),
      (1,mtef_visitor_source|mtef_team_1,af_override_everything,aif_start_alarmed,1,[itm_practice_staff]),
      (2,mtef_visitor_source|mtef_team_1,af_override_everything,aif_start_alarmed,1,[itm_practice_staff]),
      (3,mtef_visitor_source|mtef_team_1,af_override_everything,aif_start_alarmed,1,[itm_practice_staff]),
      (4,mtef_visitor_source|mtef_team_1,af_override_everything,aif_start_alarmed,1,[itm_practice_staff]),
      (8,mtef_visitor_source,af_override_weapons|af_override_horse|af_override_head,0,1,[]),
      (9,mtef_visitor_source,af_override_weapons|af_override_horse|af_override_head,0,1,[]),
      (10,mtef_visitor_source,af_override_weapons|af_override_horse|af_override_head,0,1,[]),
      (11,mtef_visitor_source,af_override_weapons|af_override_horse|af_override_head,0,1,[]),
      (12,mtef_visitor_source,af_override_weapons|af_override_horse|af_override_head,0,1,[]),
      (13,mtef_visitor_source,af_override_weapons|af_override_horse|af_override_head,0,1,[]),
      (14,mtef_visitor_source,af_override_weapons|af_override_horse|af_override_head,0,1,[]),
      (15,mtef_visitor_source,af_override_weapons|af_override_horse|af_override_head,0,1,[]),
    ],
    [
      (ti_before_mission_start, 0, 0, [],
      [
        (assign, "$g_last_destroyed_gourds", 0),
        (call_script, "script_change_banners_and_chest")]),
     
      common_arena_fight_tab_press,
     
      (ti_question_answered, 0, 0, [],
      [
        (store_trigger_param_1,":answer"),
        (eq,":answer",0),
        (assign, "$g_training_ground_training_success_ratio", 0),
        (jump_to_menu, "mnu_training_ground_training_result"),
        (finish_mission),
        ]),
     
      common_inventory_not_available,

      (0, 0, ti_once,
      [
        (try_begin),
          (eq, "$g_mt_mode", ctm_ranged),
          (set_fixed_point_multiplier, 100),
          (entry_point_get_position, pos1, 0),
          (init_position, pos2),
          (position_set_y, pos2, "$g_training_ground_ranged_distance"),
          (position_transform_position_to_parent, pos3, pos1, pos2),
          (copy_position, pos1, pos3),
          (assign, ":end_cond", 10),
          (assign, ":shift_value", 0),
          (try_for_range, ":cur_i", 0, ":end_cond"),
            (store_sub, ":cur_instance", ":cur_i", ":shift_value"),
            (scene_prop_get_instance, ":target_object", "spr_gourd", ":cur_instance"),
            (copy_position, pos2, pos1),
            (init_position, pos0),
            (store_random_in_range, ":random_no", 0, 360),
            (position_rotate_z, pos2, ":random_no"),
            (store_random_in_range, ":random_no", 50, 600),
            (position_move_x, pos2, ":random_no"),
            (store_random_in_range, ":random_no", 0, 360),
            (position_transform_position_to_local, pos3, pos1, pos2),
            (position_rotate_z, pos0, ":random_no"),
            (position_transform_position_to_parent, pos4, pos0, pos3),
            (position_transform_position_to_parent, pos2, pos1, pos4),
            (position_set_z_to_ground_level, pos2),
            (position_move_z, pos2, 150),
            (assign, ":valid", 1),
            (try_for_range, ":cur_instance_2", 0, 10),
              (eq, ":valid", 1),
              (neq, ":cur_instance", ":cur_instance_2"),
              (scene_prop_get_instance, ":target_object_2", "spr_gourd", ":cur_instance_2"),
              (prop_instance_get_position, pos3, ":target_object_2"),
              (get_distance_between_positions, ":dist", pos2, pos3),
              (lt, ":dist", 100),
              (assign, ":valid", 0),
            (try_end),
            (try_begin),
              (eq, ":valid", 0),
              (val_add, ":end_cond", 1),
              (val_add, ":shift_value", 1),
            (else_try),
              (prop_instance_set_position, ":target_object", pos2),
              (prop_instance_animate_to_position, ":target_object", pos2, 1),
              (scene_prop_get_instance, ":target_object_2", "spr_gourd_spike", ":cur_instance"),
              (position_move_z, pos2, -150), #moving back to ground level
              (prop_instance_set_position, ":target_object_2", pos2),
              (prop_instance_animate_to_position, ":target_object_2", pos2, 1),
            (try_end),
          (try_end),
        (else_try),
          (eq, "$g_mt_mode", ctm_mounted),
          (assign, ":num_gourds", 0),
          #First, placing gourds on the spikes
          (try_for_range, ":cur_i", 0, 100),
            (scene_prop_get_instance, ":target_object", "spr_gourd", ":cur_i"),
            (scene_prop_get_instance, ":target_object_2", "spr_gourd_spike", ":cur_i"),
            (ge, ":target_object", 0),
            (ge, ":target_object_2", 0),
            (val_add, ":num_gourds", 1),
            (prop_instance_get_position, pos0, ":target_object_2"),
            (position_move_z, pos0, 150),
            (prop_instance_set_position, ":target_object", pos0),
            (prop_instance_animate_to_position, ":target_object", pos0, 1),
          (try_end),
          (store_sub, ":end_cond", ":num_gourds", "$g_training_ground_training_num_gourds_to_destroy"),
          #Second, removing gourds and their spikes randomly
          (try_for_range, ":cur_i", 0, ":end_cond"),
            (store_random_in_range, ":random_instance", 0, ":num_gourds"),
            (scene_prop_get_instance, ":target_object", "spr_gourd", ":random_instance"),
            (prop_instance_get_position, pos0, ":target_object"),
            (position_get_z, ":pos_z", pos0),
            (try_begin),
              (lt, ":pos_z", -50000),
              (val_add, ":end_cond", 1), #removed already, try again
            (else_try),
              (position_set_z, pos0, -100000),
              (prop_instance_set_position, ":target_object", pos0),
              (prop_instance_animate_to_position, ":target_object", pos0, 1),
              (scene_prop_get_instance, ":target_object_2", "spr_gourd_spike", ":random_instance"),
              (prop_instance_set_position, ":target_object_2", pos0),
              (prop_instance_animate_to_position, ":target_object_2", pos0, 1),
            (try_end),
          (try_end),
        (try_end),
        ],
      []),
 
There is a replace_scene_props command, but I haven't experimented with it so I don't know if it replaces a single instance (which you get from scene_prop_get_instance) or if it replaces all instances.
 
I think it depends on what OP is trying to do.  Changing it in scene_props.py is a permanent change to every occurrence in every scene of that prop.  If they simply want to have an event occur in a single scene that causes a prop to change that'd probably be a bad way to go.
 
I need to have a single scene which will have different props depending on the two parties fighting over it - it's for sea battles, so sea raiders will spawn with longboats whereas merchants will have trade cogs, navies war galleys and so on.
 
I have a similar question... I used the code example from Gun Thunder to add destructible castle doors to my mod (script is below).  However, I plan to switch it to a semi-transparent force field, so I don't want to have the door fall over, I want to actually have it be destroyed\disapear....  It sounds like GetAssista's suggestion on moving it underground would work, but I'm not sure where to modify this code to have it move downwards?

Code:
#SW - made the castle drawbridges destructable
  ("castle_drawbridge_closed",sokf_destructible|sokf_moveable|spr_hit_points(100),"castle_drawbridges_closed","bo_castle_drawbridges_closed",   #hit_points don't work, max of 100
   [
    (ti_on_scene_prop_destroy,
    [
        (store_trigger_param_1, ":instance_no"),
        (prop_instance_get_starting_position, pos1, ":instance_no"),
        (get_player_agent_no, ":player_agent"),
        (agent_get_position, 2, ":player_agent"),
        (assign, ":rotate_side", 90),	# used to be 80, switched to 90
        (try_begin),
          (position_is_behind_position, 2, 1),
          (val_mul, ":rotate_side", -1),
        (try_end),
        (position_rotate_x, 1, ":rotate_side"),
        (position_set_z_to_ground_level, pos1),
		(prop_instance_animate_to_position, ":instance_no", 1, 70), #animate to position 1 in 0.7 second
        (play_sound, "snd_dummy_destroyed"),
		(particle_system_burst, "psys_explosion_fire", pos1, 100),
    ]),
    (ti_on_scene_prop_hit,
    [
        (play_sound, "snd_dummy_hit"),
        (particle_system_burst, "psys_dummy_smoke", pos1, 50),		#previously 3
    ]),
   ]),
 
I've posted some ideas to try out here:

http://forums.taleworlds.com/index.php/topic,58346.msg1509724.html#msg1509724

 
FYI - I figured out my question above about moving scene props.  Here's my current code: (some extra stuff is commented out from my testing)

Code:
#SW - made the castle drawbridges destructable
#  ("castle_drawbridge_closed",0,"castle_drawbridges_closed","bo_castle_drawbridges_closed", []),
  ("castle_drawbridge_closed",sokf_destructible|sokf_moveable|spr_hit_points(100),"castle_drawbridges_closed","bo_castle_drawbridges_closed",   #hit_points don't work, max of 100
   [
    (ti_on_scene_prop_destroy,
    [
        (store_trigger_param_1, ":instance_no"),
        (prop_instance_get_position, pos2, ":instance_no"),
        (play_sound, "snd_dummy_destroyed"),
		(particle_system_burst, "psys_explosion_fire", pos1, 100),		#percentage_burst_strength is 100
        #(position_rotate_x, 5),			#use these if you wish to rotate it
        #(position_rotate_y, 5),
        #(position_rotate_z, 5),		
        (position_move_z, pos2, -1200),		#up/down			#move the door out of the way (underground)
		#(position_move_x, pos2, -200),		#left/right
		#(position_move_y, pos2, -200),		#forward/back
        (prop_instance_animate_to_position, ":instance_no", 2, 800), #animate to position in 8 seconds
    ]),
    (ti_on_scene_prop_hit,
    [
        (play_sound, "snd_dummy_hit"),
        (particle_system_burst, "psys_dummy_smoke", pos1, 80),		#percentage_burst_strength is 100
    ]),		
   ]),

Now, after you shoot a castle door a few times it slowly lowers into the ground.

 
this sounds great...

so someday it will be possible to have a siege via battering ram ?? - So the destroyable gate is available...(as we all see..)
 
HokieBT said:
FYI - I figured out my question above about moving scene props.  Here's my current code: (some extra stuff is commented out from my testing)

Code:
#SW - made the castle drawbridges destructable
#  ("castle_drawbridge_closed",0,"castle_drawbridges_closed","bo_castle_drawbridges_closed", []),
  ("castle_drawbridge_closed",sokf_destructible|sokf_moveable|spr_hit_points(100),"castle_drawbridges_closed","bo_castle_drawbridges_closed",   #hit_points don't work, max of 100
   [
    (ti_on_scene_prop_destroy,
    [
        (store_trigger_param_1, ":instance_no"),
        (prop_instance_get_position, pos2, ":instance_no"),
        (play_sound, "snd_dummy_destroyed"),
		(particle_system_burst, "psys_explosion_fire", pos1, 100),		#percentage_burst_strength is 100
        #(position_rotate_x, 5),			#use these if you wish to rotate it
        #(position_rotate_y, 5),
        #(position_rotate_z, 5),		
        (position_move_z, pos2, -1200),		#up/down			#move the door out of the way (underground)
		#(position_move_x, pos2, -200),		#left/right
		#(position_move_y, pos2, -200),		#forward/back
        (prop_instance_animate_to_position, ":instance_no", 2, 800), #animate to position in 8 seconds
    ]),
    (ti_on_scene_prop_hit,
    [
        (play_sound, "snd_dummy_hit"),
        (particle_system_burst, "psys_dummy_smoke", pos1, 80),		#percentage_burst_strength is 100
    ]),		
   ]),

Now, after you shoot a castle door a few times it slowly lowers into the ground.



1 annother idea...

so could it be possible to code it, so the gates are destroyable by swords/pikes etc. ??
 
any weapon will damage it, so that is already done automatically.  The issue with destructible doors is that the hit_points setting doesn't work (so its a max of 100) so it gets destroyed very easily.....  The best option for a battering ram would be to remove the destructible flag and make the scene prop only movable.  Then, after every hit you would rotate the door a little backwards, and eventually after enough hits it would lay flat on the ground and you could walk in.  :smile:  This should be very easy to do.
 
HokieBT said:
FYI - I figured out my question above about moving scene props.  Here's my current code: (some extra stuff is commented out from my testing)

Code:
#SW - made the castle drawbridges destructable
#  ("castle_drawbridge_closed",0,"castle_drawbridges_closed","bo_castle_drawbridges_closed", []),
  ("castle_drawbridge_closed",sokf_destructible|sokf_moveable|spr_hit_points(100),"castle_drawbridges_closed","bo_castle_drawbridges_closed",   #hit_points don't work, max of 100
   [
    (ti_on_scene_prop_destroy,
    [
        (store_trigger_param_1, ":instance_no"),
        (prop_instance_get_position, pos2, ":instance_no"),
        (play_sound, "snd_dummy_destroyed"),
		(particle_system_burst, "psys_explosion_fire", pos1, 100),		#percentage_burst_strength is 100
        #(position_rotate_x, 5),			#use these if you wish to rotate it
        #(position_rotate_y, 5),
        #(position_rotate_z, 5),		
        (position_move_z, pos2, -1200),		#up/down			#move the door out of the way (underground)
		#(position_move_x, pos2, -200),		#left/right
		#(position_move_y, pos2, -200),		#forward/back
        (prop_instance_animate_to_position, ":instance_no", 2, 800), #animate to position in 8 seconds
    ]),
    (ti_on_scene_prop_hit,
    [
        (play_sound, "snd_dummy_hit"),
        (particle_system_burst, "psys_dummy_smoke", pos1, 80),		#percentage_burst_strength is 100
    ]),		
   ]),

Now, after you shoot a castle door a few times it slowly lowers into the ground.


How fast does it move?  does it slide down, or "teleport" down?
 
HokieBT said:
any weapon will damage it, so that is already done automatically.  The issue with destructible doors is that the hit_points setting doesn't work (so its a max of 100) so it gets destroyed very easily.....  The best option for a battering ram would be to remove the destructible flag and make the scene prop only movable.  Then, after every hit you would rotate the door a little backwards, and eventually after enough hits it would lay flat on the ground and you could walk in.  :smile:  This should be very easy to do.

THAT sounds like a very good idea, I think.
 
Another idea could be to make several overlapping doors.  Add to the number of props, but then you could have each next door looke more smashed in then the last.
 
you set how fast you want it to animate between the positions, so I currently have mine slowly slide down.
(prop_instance_animate_to_position, ":instance_no", 2, 800), #animate to position in 8 seconds

yeah, I also thought about making multiple destructible doors, or possibly invisible ones to simulate higher hit points, but I think that would require scene editing so mine just currently die in a few hits.  You might be able to put some code that if the door died you spawned another on in its place, and then after X times of doing that the door would eventually be destroyed....?
 
well, there is the replace code.  Probably a better idea and continue to swap it for (if you were using doors) ones that looked more busted up, until you break the last one.

I have a question for you, HokieBT.

I noticed that you move the object -1200.  In the editor, moving a well -5 puts it underground.  Is there a ratio to the distances shown in the editor compared to the distances coded?  I was trying to move a well just under the ground, so, according to the Editor, if I move it from 9.1 to 4, it will go below the ground.  Know I don't know if I am having other issues, as the display messages aren't showing either, but just curious.
 
....wow. Reading these forums makes me feel like the complete newb that I am. =-) You guys are awesome.

-Rhider
 
Guys this is a very good idea but i would have one problem with this, how could you make half of the army follow you and the rest to continue to go up the ladder or tower? And how could you put enemy forces to guard that door?
 
Back
Top Bottom