I've been working on a script which isn't working so well and I've tossed it to start new. I have also copied the script from the Study map and the tree does falling after increasing the prop force to 10000 vs. 1000 and the camera does it's shake and the scared sound and such but no falling tree music or sound.
I want the tree to fall on the player and knock him out by fading the screen out with a collision sound and such and have it fade in a few later. Anyone know a good way to do this?
-Grind to the Gore-
(This post was last modified: 08-17-2013, 11:33 PM by GoreGrinder99.)
(08-09-2013, 02:00 AM)Tomato Cat Wrote: What do you have so far?
Umm, nothing, I got rid of it because I couldn't get the map to load anymore from changing things so much. I later copied over the forest script from the study hps and used that but couldnt get any falling tree sound or music to play with it that's supposed to like in the original game. But I also want it to fall on the player when entering a script area and knock him out.
It might not be a genius solution, but try to turn off the players movements or slow him down. Make some other stuff happen also during this event. Like creaking sounds a little bit everywhere.
Just a tip, buddy.
(This post was last modified: 08-09-2013, 10:47 PM by Neelke.)
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.)
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
Very nice indeed, thank you! I was wondering if there was any way to implement the player being crashed to the ground as if he was really knocked down by the tree? I want to have the player fall to the ground on their side, if not that's okay I'll see what I can do otherwise, you've helped so much already!
It causes the player's head to tilt sideways.
fload afX = angle of rotation, positive is counter-clockwise
fload afSpeedMul = how fast it happens
fload afMaxSpeed = maximum speed of rotation
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_blackout", 7.5f, "timer_blackout"); //causes blackout AddTimer("timer_wakeup", 17.0f, "timer_wakeup"); //revives player AddPropForce("falling_tree_1", 0, 0, 1000, "world"); //makes tree fall SetPlayerMoveSpeedMul(0.2f); //slows down player a ton SetPlayerRunSpeedMul(0.2f); //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 AddTimer("timer_fallsideways", 7.0f, "timer_fallsideways"); //player falls over just before passing out }
void timer_fallsideways(string &in asTimer) { FadePlayerRollTo(65, 220, 220); //head is sideways on floor, 65 is highest possible without glitches PlaySoundAtEntity("hit", "player_falldamage_max.snt", "Player", 0.0f, false); //sound of tree hitting GivePlayerDamage(20.0f, "BloodSplat", false, false); // non-lethal damage to player }
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 AddTimer("timer_headnormal", 4.0f, "timer_headnormal"); //forces a bit of recovery time }
void timer_headnormal(string &in asTimer) { FadePlayerRollTo(0, 220, 220); //head back to normal }
void OnLeave() {
}
By the way, I'm getting all of this from here (in case you didn't know this existed). Just use "ctrl+f" and type in a keyword (crouch brings up SetPlayerCrouching).
Also, play around with the numbers I gave. You might end up with something you like better. If not, the original code is here and the scripts are in that link.
Oh, and one more thing: Have you set up a development environment yet? Once you have, load your map before making the .hps file for it.
Instead of crashing when you go to test your scripts (by clicking "Reload" from the dev bar), it just won't reload. You'll get a message on the screen telling you where the error is in your script and where it is (unless it's a missing ";" or "}" then you'll just get "unexpected end of file" and have to play Spot the Error).
(This post was last modified: 08-10-2013, 08:27 AM by CarnivorousJelly.)
(08-10-2013, 12:36 PM)Rapsis Wrote: Don't you think a falling tree would kill a person instead of just knocking him out?
Yeah, it will. Unless if the tree is small.
Well, I'm going to have it fall on them and knock them out and have them wake up near death. The scripts are working like a charm and I thank all of you. But I do have another question...
Where in the redist would you locate the files referring to the ui "hurt_pain" sounds? What I mean is when the player is hurt and near death the sounds he makes when he's in pain, like you've been mauled by the monsters and are about to die, what files are linked to those sounds and where are they? I have looked but with no luck of finding anything.