Scene props - swapping one for another

Users who are viewing this thread

I didn't compare how much it moved in the editor to how much it moved in the code, I just did some tests with different numbers.  From what I remember a -50 barely moved it at all, -500 was about half way to 3/4, and -1000 completely made it disappear.  I did -1200 just to guarantee that it was completely gone from all scenes in-case the elevation of the land made a difference or something.....

I'm not really sure how to get the AI to behave correctly.  Most of the siege scenes have an AI limiter scene prop in front of each door so I was able to walk through but they weren't.  I manually removed it in one of the quick battle scenes, but even then the AI didn't want to follow me through the door.  I believe you can manually place entry points, or something like that,  that will tell the AI where they should run but I haven't used those before.  I don't have time to play with this too much or manually edit scenes to remove any AI limiters in front of doors, so my plan is probably to add this concept into the Star Wars mod, but for right now it will probably only be helpful if the player wants to assault the castle through the door while the troops attack with the ladders...
 
HokieBT said:
I didn't compare how much it moved in the editor to how much it moved in the code, I just did some tests with different numbers.  From what I remember a -50 barely moved it at all, -500 was about half way to 3/4, and -1000 completely made it disappear.  I did -1200 just to guarantee that it was completely gone from all scenes in-case the elevation of the land made a difference or something.....
kind of sucks for me...  I wanted to move an object based on if it's in the correct position or not.  That means I need to know where it is, and where it will be.  I guess I will have to go with the placeholder method...
 
if 500 made it move halfway and 1000 all the way, maybe it's a percentage? i.e. 1000 = 100% of prop size

Doesn't make much sense, but there you go.

Anyway, surely it has to be a linear proportion? Just a matter of testing a few different settings.
 
Tis true.  I might be making all the village scenes identical in my mod, possibly with stuff just shifted around a bit.

I was working towards moving the object up and down, but really, it just needs to be moved up.  If HokieBT had to move his door 1000, I will try that.  Still have no idea why my key triggers aren't working in scene...  May have to throw that back into native and see if something is broken which is causing this...
 
just saw this in a native script:

(position_set_z_to_ground_level, pos63),

So basically, it doesn't matter where the ground level is, you can just use that one to make sure it goes up properly.

In that case it also doesn't matter how far underground you put it, but if you know how big your object is, you can set pos63 (or whatever nr you choose) to ground lvl first, and then lower it the amount it needs to be lowered for that particular prop to be completely underground.
 
Make sure you look in operations.py.  the comment for that operation states it only works in missions.  This would mean that you will have to add the code to the mission template for entering the villages.  I think that's what I will test out.  Man, so many ways to do things.

My mind keeps jumping around....  The worst part is that all these coding problems/ideas pop up and they are on the lines of what I want to do.  I feel if I don't act on them I'll lose the info...  Threads get burried quit often.  For now I am going to focus on my village creation code blocks.  Once that is done, I will then make my first scene, then test this out.  Lucky for me I have a (quite long) document on my mod, that I store all the useful info I find. 
 
that's smart.. and I know what you mean about the stuff popping up :smile:

Setting it in the mission template isn't necessarily a bad thing, if it's much easier. Just use a common trigger and add that to all the village related templates.
 
the hard part is grabbing the instance.  You can't play around with props (outside of the the way HokieBT did it) with out finding the instance.  Since I have just played with theories, I'd assume that the first would be either 0 or 1.  1 would seem more logical.  I will test it soon.  Just working out the relations of distance between parties...
 
ok, now with the messages working, I was able to test and get moving an object from underground to ground position.  I used a key stroke command, but you can do this on entering the scene:

(0,0,0,[(key_clicked, key_o)],
[(display_message,"@You pressed o"),
  (display_message,"@WELL 0 should be visible"),
  (scene_prop_get_instance,":holdprop","spr_water_well_a", 0),
  (prop_instance_get_position,pos1,":holdprop"),
  (position_set_z_to_ground_level, pos1),
  (prop_instance_set_position,":holdprop",pos1),
]
),

If you noticed, the first object (in my case a well) placed will be instance 0.  So with 2 wells, I would have to move both 0 and 1.

One thing to note, this does not hold, and the well will reset once you leave the scene.  Again, just use code similar to what I have above as a 1 time trigger for each object.  You just need to make sure you test what object neede to be moved.
 
so it worked? nice :smile:

I better get my checkered shirt and work pants ready for soon I can play your mod and be a farmer :grin:
 
It worked, but it's kind of sketchy.

If hit O 2 times, it moves up 2 times.  The second time is just slightly higher.  After that it's set.  Luckily most objects have long enough "foundations" to make this ok.  But again, this is all reset when you re-enter the scene.  I just did a quick test, I haven't made my scenes yet, but the test was for more the numbering.  When I tried it with 1, nothing happened.  Kind of got me scared.  But it works.  It just pops into place.

Once I make my scene, I will try to test with checking against party slots labeled for these items.  Since the instances can be checked, I can do it for several of the same objects.
 
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.



Hiya HokieBT, I love this bit of code, and have used it myself in trying to make a bridge collapse under some enemies as they run across it.  With a few minor changes (just speeding up the fall) it works, and the visible object appears to take damage and then collapse into the ground below.  The problem is that the "Visible" object is not the same as the "physical" object, so the guys just keep running across as if the bridge was still there, though some do seem to fall initially when the object moves.

Would there be any way to fix this problem that anyone knows about?  I'm trying to add various "traps" and destructible objects to my mod for a bit of added fun during sieges and quick battles. 

 
Flanged said:
Hiya HokieBT, I love this bit of code, and have used it myself in trying to make a bridge collapse under some enemies as they run across it.  With a few minor changes (just speeding up the fall) it works, and the visible object appears to take damage and then collapse into the ground below.  The problem is that the "Visible" object is not the same as the "physical" object, so the guys just keep running across as if the bridge was still there, though some do seem to fall initially when the object moves.

Would there be any way to fix this problem that anyone knows about?  I'm trying to add various "traps" and destructible objects to my mod for a bit of added fun during sieges and quick battles.

I would suggest as the object is destroyed, move it down and thrown in the other object (I assume you are replacing the existing bridge with a new object?).  If you move it, the colision model should move with it.  Did you create the broken objects?
 
No, I haven't made any models of the broken bridge, the only way in which it can be seen to take damage is that there is a plume of smoke from it where it is struck (I don't seem to have the explosion psys_object for some reason, though).  After it's been hit a few times the bridge just falls into the earth (might be smarter to have it fall in water, so it's disappearance doesn't look as odd).  But the men on top don't seem to fall with it.  I might just need to test it more.

This same kind of action could be used to make covered spike traps I thought.  Hopefully it will work, though I'd either have to increase falling damage or make a terrain type that it's deadly to stand on (is that even possible?  I'm not sure, but I think I've seen traps of a kind in mods for older versions). 
 
I guess your problem is related to the collision meshes. Here's an example: place an enterable tower in a scene, get on top and delete it. Now walk around on the top. Yes, you will be able to walk 'on air'. You don't fall down, even though the tower is deleted. Might be the same thing here. I hope it's not but oh well. Because I doubt you'd be able to move 'bo_bridge' in any way because it's no scene prop.

About the deadly terrain type: are terrains defined in modules? I thought they're in the main M&B folder.
 
Flanged said:
No, I haven't made any models of the broken bridge, the only way in which it can be seen to take damage is that there is a plume of smoke from it where it is struck (I don't seem to have the explosion psys_object for some reason, though).  After it's been hit a few times the bridge just falls into the earth (might be smarter to have it fall in water, so it's disappearance doesn't look as odd).  But the men on top don't seem to fall with it.  I might just need to test it more.

This same kind of action could be used to make covered spike traps I thought.  Hopefully it will work, though I'd either have to increase falling damage or make a terrain type that it's deadly to stand on (is that even possible?  I'm not sure, but I think I've seen traps of a kind in mods for older versions).

This is kind of odd.  Doesn't HokieTB move a wall and people can then pass through the space?  This would mean that the colision model is moved as well.  As for deleting an object from a scene with the editor, yes I have seen that, but I would think it was different than moving a scene prop.  The reason I say this is because the belfry is moved, so the bo has to be moved with it or:
1. it wouldn't block your path as it was moving
2.  You wouldn't be able to use it once it was in place.

Maybe you should look at how the mesh is defined in meshes.py.  Maybe the bridge is done differently?

As to the dangerous terrain, I would think that would be more of a trigger that checks the area of the trap and deals out damage.  In the case where it's a trap you fall into, get the pos of the trap, and then constantly check agents to see if they are in the area around it.  Then run an impale animation! :twisted:
 
Hmm, well I had the belfry example in mind, too. But have you noticed that if you get soldiers on top of it they won't move with the siege tower?
 
Soil said:
Hmm, well I had the belfry example in mind, too. But have you noticed that if you get soldiers on top of it they won't move with the siege tower?

Never tried that, but that messes with the ideas I gave for the chariot being a scene prop....  Though, I'm sure they would move with it if you scripted the movement of an agent that is on the object with it.  Would be easy if when the agent gets on the object it triggers the movement.  Guess the chariot scene prop is still good.

What this means is that (like in most cases) the physics of friction are not defined, so there is nothing holding the agent object onto the prop.  You just need to map the same movements to the agent on board.
 
Which is hard for things like siege towers, bridges etc...

I think a constantly walking AI would 'move' with the object, though.
 
Soil said:
Which is hard for things like siege towers, bridges etc...

I think a constantly walking AI would 'move' with the object, though.

Not true.  Each game object moves itself.  So if I walk while on a moving object 2 two motions don't interact, they are independant.
 
Back
Top Bottom