question about module_scene_probs

Users who are viewing this thread

Gotha

Adimi h.c.
Baron
I´ve got a question . . . i wanna move an object for this i use the command prop_instance_animate_to_position. But i want that the object move (not teleport) between two positions without interruptions. Can somebody help me?

Thx
 
Well since I don't think props can be given orders, the way I'd do it is with a 1 second recurring trigger, then just move it a particular amount (in cms) depending on the speed (x) you want which would roughly work out at x cm per second.  I guess that is how it's done.  Never really looked closely at siege engine code to see.
 
No, prop_instance_animate_to_position is the correct operation to use. Note that you need the instance id of the scene_prop, not the scene_prop id. Also note that the duration is in 1/100 seconds.

Example:
Code:
#Do stuff above to get ":instance_id"; store desired position in pos5
(prop_instance_animate_to_position, ":instance_id", pos5, 20*100), #Move the desired prop to pos5 in 20 seconds.
 
Ahh so it does work a little like giving a prop movement orders.  Sorry I should have looked the command up before responding...
 
Okay, thx.
But, i want the objects to move between the positions without interruption (i mean from pos5 to pos6 and back and than again to pos6).
It would be enough if its move fifty times ... but permanent would be better.
Does somebody have an idea?
(i even use "prop_instance_animate_to_position").
 
Yep, that's perfectly doable. When you first start animating it, set a scene_prop_slot to show what direction the prop will be moving. Then, in the scene prop trigger ti_on_scene_prop_animation_finished, have it check that slot, set the proper animation, then set the slot to the next value.

Here's a quick example: The scene prop with these two triggers will oscillate 5 meters in 10 seconds as soon as the scene starts.
Code:
(ti_on_scene_prop_init, [
    (store_trigger_param_1. ":prop"),
    (prop_instance_get_position, pos4, ":prop"),
    (position_move_z, pos4, 500),                            #Move 5 meters up
    (scene_prop_set_slot, prop_animation_slot, 0), #set prop_animation_slot in module_constants or header_common
    (prop_instance_animate_to_position, ":prop", pos4, 500),
]),

(ti_on_scene_prop_animation_finished, [
    (store_trigger_param_1. ":prop"),
    (prop_instance_get_position, pos4, ":prop"),

    (try_begin),
        (scene_prop_slot_eq, prop_animation_slot, 0)
        (position_move_z, pos4, -500),                             #Move 5 meters down, to the original position
        (scene_prop_set_slot, prop_animation_slot, 1), 
        (prop_instance_animate_to_position, ":prop", pos4, 500),
    (else_try),
        (scene_prop_slot_eq, prop_animation_slot, 1)
        (position_move_z, pos4, 500),                               #move 5 meters up
        (scene_prop_set_slot, prop_animation_slot, 0), 
        (prop_instance_animate_to_position, ":prop", pos4, 500),
    (try_end),
]),
 
There are two operations you'll need to use.
(scene_prop_get_num_instances, destination, scene_prop_id)  and (scene_prop_get_instance, destination, scene_prop_id, instance_no).

The first one gets the number of instances of a scene prop in a scene. In the second operation, you'll get the instances unique id when you enter the same scene prop type and the any number in the range [0, number_of_instances-1]. If you have only one type of a particular scene prop in a scene, you can skip the first operation and simply use 0 as the instance_no in the second argument; otherwise, you'll want to try something like this.

Code:
(scene_prop_get_num_instances,":max", ":spr_my_prop"),
(try_for_range, ":cur", 0, ":max"),
     (scene_prop_get_instance, ":instance", ":spr_my_prop", ":cur"),
     #Check to see if this is the instance/one of the instances you want and do stuff with it
(try_end),
 
You can also rename a scene prop in the module system to have a unique name, insert it in your scene and just take the first instance with that name to keep from getting the wrong instance of the prop.

Here is an example of a door opening when the player walks near.

Code:
		(1,2,ti_once,
			[	(get_player_agent_no, ":player_agent"),
				(agent_is_alive, ":player_agent"),
				(agent_get_position, pos1, ":player_agent"),
				(set_fixed_point_multiplier, 100),
				(scene_prop_get_instance,":door", "spr_dungeon_door_entry_a",0),
				(prop_instance_get_position, pos2, ":door"),
				(get_distance_between_positions, ":cur_distance", pos1, pos2),
				(le, ":cur_distance", 1000),				
			],
			[	(set_fixed_point_multiplier, 100),
				(scene_prop_get_instance,":door", "spr_dungeon_door_entry_a",0),
				(prop_instance_get_position, pos2, ":door"),				
				(position_rotate_z, pos2, -100),
				(prop_instance_animate_to_position, ":door", pos2,200),
			]),


  This is code that will work in M&B  and Warband.  Warband has a few new commands for props that may also be useful, but I've yet to experiment with them.
 
Cool, thanks it´s working :grin:. I have got a new question. A server message should be sent when someone hit the object, like the dummys in singleplayer. However I don´t know how this should work with scene_props . . . can somebody tell me how? Thank you.
 
Back
Top Bottom