string& asCoordSystem = coordinates to use (should be "world")
Use the level editor to figure out which direction the tree should fall.
Arrows point in the positive directions when you're using the move tool
red is x, green is y, blue is z in the level editor
Which you would have to use in a script, probably the one where the tree falls. I would personally do something similar to ATDD where Daniel's in the Wine Cellar and a barrel falls on his head. This isn't exactly the same, but:
(using ko as an abbreviation for knock-out, assuming area_ko is right under the tree)
void OnStart() { AddEntityCollideCallback("Player", "area_ko", "script_ko", true, 0); } void script_ko(string &in asParent, string &in asChild, int alState) { SetPlayerCrouching(true); // make tree fall further SetPlayerJumpDisabled(true); //slow movement StartPlayerLookAt("falling_tree_1", 5.0f, 8.0f, ""); //makes them look at tree AddTimer("timer_stoplook", 7.0f, "timer_stoplook"); //terminates "look" AddTimer("timer_blackout", 7.0f, "timer_blackout"); //this will depend on how long the tree takes to fall, 4.0f is 4 seconds AddTimer("timer_wakeup", 17.0f, "timer_wakeup"); //revives player AddPropForce("falling_tree_1", 0, 0, 1000, "world"); //makes tree fall SetPlayerMoveSpeedMul(0.5f); //slows down player a ton SetPlayerRunSpeedMul(0.5f); //applies slowness to running StartScreenShake(0.05f, 4.0f, 0.5f, 10.0f); //shakes screen for 10 seconds }
void timer_wakeup(string &in asTimer) { FadeIn(4.0f); //4 seconds to wake up, takes a little longer SetPlayerMoveSpeedMul(1.0f); //returns normal speed SetPlayerRunSpeedMul(1.0f); SetPlayerCrouching(false); SetPlayerJumpDisabled(false);
}
Make sure the tree has room to fall and that it has the same name in the level editor (falling_tree_1) as it does in your script.
I'm going to test this out quickly so I can let ya know if it works.
Also, make sure you're actually using one of the trees that fall (under Entities/Special)
UPDATE
Tree stops falling because the ground is in the way, lift the tree up to 1.25 above the plane it's on.
5 seconds isn't long enough for the tree to fall, changed times a bit
I made the script better c:
void script_ko(string &in asParent, string &in asChild, int alState) { SetPlayerCrouching(true); // make tree fall further SetPlayerJumpDisabled(true); //slow movement StartPlayerLookAt("falling_tree_1", 5.0f, 8.0f, ""); //makes them look at tree AddTimer("timer_stoplook", 7.0f, "timer_stoplook"); //terminates "look" AddTimer("timer_blackout", 7.0f, "timer_blackout"); //this will depend on how long the tree takes to fall, 4.0f is 4 seconds AddTimer("timer_wakeup", 17.0f, "timer_wakeup"); //revives player AddPropForce("falling_tree_1", 0, 0, 1000, "world"); //makes tree fall SetPlayerMoveSpeedMul(0.5f); //slows down player a ton SetPlayerRunSpeedMul(0.5f); //applies slowness to running StartScreenShake(0.05f, 4.0f, 0.5f, 10.0f); //shakes screen for 10 seconds PlaySoundAtEntity("fallingtree", "11_forest_minor.snt", "Player", 0, false); //makes cracking branches sounds }
void timer_wakeup(string &in asTimer) { FadeIn(4.0f); //4 seconds to wake up, takes a little longer SetPlayerMoveSpeedMul(1.0f); //returns normal walking speed SetPlayerRunSpeedMul(1.0f); //returns normal running speed SetPlayerJumpDisabled(false); //lets player jump again StopSound("insanity_ear_ring", 4.0f); //stops ringing noise }
I checked this and it works. If you're still having problems making it work:
Check if your .hps and map file are in the same folder (obvious, I know, but that's usually my problem)
Make sure the level editor names for areas (area_ko) and objects (falling_tree_1) are the same as in the script
Make sure the tree's not actually touching the ground when it's standing - cover up the bottom with bushes (turn off collide)
delete any map.cache files you have
Feel free to ask if you want me to explain something in-depth
(This post was last modified: 08-10-2013, 01:12 AM by CarnivorousJelly.)