"Spawnable" then Destroyable scene prop (SOLVED)

Users who are viewing this thread

Grendal-777

Veteran
I have been working on a scene prop that can be placed under ground and then raised via an action. Once raised it can then be destroyed and will fall back below ground. I have tried it several ways and believe I am close to achieving my objective. However, I get an error when I compile and am not knowledgeable enough to track down the cause.

These are located in my module_scene_props.py:
Code:
check_ftower_destroy = (ti_on_scene_prop_use,
     [
	  (store_trigger_param_1, ":agent_id"),
      (store_trigger_param_2, ":player_no"),
      (store_trigger_param_3, ":instance_id"),
	  (multiplayer_is_server),
      (assign, ":cost", 500), 
      (player_is_active, ":player_no"),
      (agent_get_player_id,":player_no",":agent_id"),
      (player_get_gold, ":player_gold", ":player_no"),
        (try_begin),
         (ge, ":player_gold", ":cost"), #Make sure player has gold 
         (prop_instance_get_position, pos2, ":instance_id"),
         (position_move_z,pos2,1200), 
         (prop_instance_animate_to_position, ":instance_id", 2, 800),
		 (val_sub, ":player_gold", ":cost"), 
         (player_set_gold, ":player_no", ":player_gold", multi_max_gold_that_can_be_stored),
        (try_end),
	])
and
Code:
("a_ftower_destructible",sokf_destructible|sokf_moveable|spr_use_time(2),"castle_f_tower_a","bo_castle_f_tower_a",[
 	
	(ti_on_scene_prop_use, 	[ 
     check_ftower_destroy,  
     ]),
    (ti_on_scene_prop_destroy,    [
	    (store_trigger_param_1, ":instance_no"),
	    (display_message, "@You destroyed the tower!"),
        (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, -2200),      #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, 100),      #percentage_burst_strength is 100
    ]),  
],2000),
If your curious about the "],2000)," I am using the prop hit point modifying script located here: http://forums.taleworlds.com/index.php/topic,58596.0.html
It is working fine on several other props in the same file.
However, I also tried editing it out and using;
("a_ftower_destructible",sokf_destructible|sokf_moveable|spr_use_time(2),"castle_f_tower_a","bo_castle_f_tower_a",[

(ti_on_init_scene_prop,
    [
      (store_trigger_param_1, ":instance_no"),
      (scene_prop_set_hit_points, ":instance_no", 2000),
    ]),
(ti_on_scene_prop_use, [
    check_ftower_destroy, 
    ]),
    (ti_on_scene_prop_destroy,    [
    (store_trigger_param_1, ":instance_no"),
    (display_message, "@You destroyed the tower!"),
        (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, -2200),      #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, 100),      #percentage_burst_strength is 100
    ]), 
]),
and got the exact same error when compiling.

The error I am getting is:
Exporting scene props...
Traceback (most recent call last):
  File "process_scene_props.py", line 40, in <module>
    save_scene_props(variables,variable_uses,tag_uses,quick_strings)
  File "process_scene_props.py", line 23, in save_scene_props
    save_simple_triggers(ofile,scene_prop[4]  , variable_list,variable_uses,tag_
uses,quick_strings)
  File "C:\Users\Chris\Desktop\M&B-M Mod\MS 1.131 fixed variables\process_operat
ions.py", line 469, in save_simple_triggers
    save_statement_block(ofile,0,1,trigger[1]  , variable_list, variable_uses,ta
g_uses,quick_strings)
  File "C:\Users\Chris\Desktop\M&B-M Mod\MS 1.131 fixed variables\process_operat
ions.py", line 449, in save_statement_block
    save_statement(ofile,opcode,no_variables,statement,variable_list,variable_us
es,local_vars, local_var_uses,tag_uses,quick_strings)
  File "C:\Users\Chris\Desktop\M&B-M Mod\MS 1.131 fixed variables\process_operat
ions.py", line 401, in save_statement
    ofile.write("%d "%operand)
TypeError: %d format: a number is required, not list

Anyone have any idea where I am messing up, or how to better do this?
 
Code:
check_ftower_destroy = (ti_on_scene_prop_use,
     [...
Code:
   (ti_on_scene_prop_use,    [
     check_ftower_destroy, 
     ]),
looks like nested ti_on_scene_prop_use? no no
 
And also, the store_trigger_param_* lines in your first trigger are nonsense; the correct ones for it are:
Code:
(store_trigger_param_1, ":agent_id"),
(store_trigger_param_2, ":instance_id"),
You are using the scene prop instance id as the player id, and using the probably unset trigger_param_3 as the instance. You could try figure out if param_3 is anything useful - but none of the native triggers use it, there is no mention of it in the header, and it is hardly necessary as you can get the player id with:
Code:
(agent_get_player_id, ":player_id", ":agent_id"),
 
If you're using Warband, then you have some other sutff available: Built-in hitpoints for props, the (spwan_scene_prop) command, etc., so don't use this method. As Sinisterius said, it's old and obsolete.
 
Thanks for the replies all.
I learned three valuable items:

1. Props in Warband can have hit points easily set on initialize
2. spawn_scene_prop works in Warband
3. Do not try to do it all in one script

I broke it down into two codes; created the destructible object complete with hit points and hit/destroy triggers, and then created a prop that activates the object spawner code and handles the gold exchange and prop spawn. I could just have easily made it activate with a key press or other action, but I need to control where players spawn them.

My codes (both are located in module_scene_props)
First is defining the new destructible item and is placed after the destructible door prop
("door_destructible",sokf_moveable|sokf_show_hit_point_bar|sokf_destructible|spr_use_time(2),"tutorial_door_a","bo_tutorial_door_a", [
    check_item_use_trigger,

  (ti_on_init_scene_prop,
    [
      (store_trigger_param_1, ":instance_no"),
      (scene_prop_set_hit_points, ":instance_no", 2000),
    ]),
   
  (ti_on_scene_prop_destroy,
    [
      (play_sound, "snd_dummy_destroyed"),
     
      (assign, ":rotate_side", 86),
     
      (try_begin),
        (this_or_next|multiplayer_is_server),
(neg|game_in_multiplayer_mode),

        (store_trigger_param_1, ":instance_no"),     
        (store_trigger_param_2, ":attacker_agent_no"),

        (set_fixed_point_multiplier, 100),
        (prop_instance_get_position, pos1, ":instance_no"),

        (try_begin),
          (ge, ":attacker_agent_no", 0),
          (agent_get_position, pos2, ":attacker_agent_no"),
          (try_begin),
            (position_is_behind_position, pos2, pos1),
            (val_mul, ":rotate_side", -1),
          (try_end),
        (try_end),
     
        (init_position, pos3),

        (try_begin),
          (ge, ":rotate_side", 0),
          (position_move_y, pos3, -100),
        (else_try),
          (position_move_y, pos3, 100),
        (try_end),
     
        (position_move_x, pos3, -50),
        (position_transform_position_to_parent, pos4, pos1, pos3),
        (position_move_z, pos4, 100),
        (position_get_distance_to_ground_level, ":height_to_terrain", pos4),
        (val_sub, ":height_to_terrain", 100),
        (assign, ":z_difference", ":height_to_terrain"),
        (val_div, ":z_difference", 3),

        (try_begin),
          (ge, ":rotate_side", 0),
          (val_add, ":rotate_side", ":z_difference"),
        (else_try),
          (val_sub, ":rotate_side", ":z_difference"),
        (try_end),

        (position_rotate_x, pos1, ":rotate_side"),
        (prop_instance_animate_to_position, ":instance_no", pos1, 70), #animate to position 1 in 0.7 second
      (try_end),
    ]),     

    (ti_on_scene_prop_hit,
    [
      (play_sound, "snd_dummy_hit"),
      (particle_system_burst, "psys_dummy_smoke", pos1, 3),
      (particle_system_burst, "psys_dummy_straw", pos1, 10),     
    ]),
  ]),
Code:
("a_spikes_destructible",sokf_destructible|sokf_show_hit_point_bar|sokf_moveable,"spike_group_a","bo_spike_group_a",  [
(ti_on_init_scene_prop,
    [
      (store_trigger_param_1, ":instance_no"),
      (scene_prop_set_hit_points, ":instance_no", 500),
    ]),

(ti_on_scene_prop_destroy,
    [
        (store_trigger_param_1, ":instance_no"),
        (prop_instance_get_position, pos2, ":instance_no"),
        (play_sound, "snd_dummy_destroyed"),
		(display_message, "@You destroyed the spikes!"),
 #     (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, 25),      #percentage_burst_strength was 100
    ]),     
 ]),
Second is creating the action when spawning prop is activated and is placed near top of file under ladder stuff
check_ladder_animation_finish_trigger = (ti_on_scene_prop_animation_finished,
    [
      (store_trigger_param_1, ":instance_id"),

      (prop_instance_enable_physics, ":instance_id", 1),
      ])
Code:
check_spawn_wall_spikes = (ti_on_scene_prop_use,
    [
      (store_trigger_param_1, ":agent_id"),
#      (store_trigger_param_2, ":instance_id"),
      (multiplayer_is_server),
      (assign, ":cost", 250), #:profit to gain, :cost to loose, edit amount of cost or profit
      (agent_get_player_id,":player_no",":agent_id"),
      (try_begin),
        (player_is_active, ":player_no"),
        (player_get_gold, ":player_gold", ":player_no"),
        (ge, ":player_gold", ":cost"), #:profit to gain, :cost to loose
		(agent_get_position, pos2, ":agent_id"),
		(position_move_y, pos2, 200),
		(position_move_z, pos2, 300),
        (set_spawn_position, pos2),
        (spawn_scene_prop,"spr_a_spikes_destructible"),    
        (display_message, "@You have placed some spikes."),
        (val_sub, ":player_gold", ":cost"), #Use val_sub to subtract and val_add to add, :profit to gain, :cost to loose
        (player_set_gold, ":player_no", ":player_gold", multi_max_gold_that_can_be_stored),
      (try_end),
    ])
 
Back
Top Bottom