Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Script for falling tree/knock player out?
CarnivorousJelly Offline
Posting Freak

Posts: 1,196
Threads: 41
Joined: Dec 2012
Reputation: 80
#7
RE: Script for falling tree/knock player out?

(spoilers for size)
Spoiler below!

PHP Code: (Select All)
void FadePlayerRollTo(float afXfloat afSpeedMulfloat afMaxSpeed); 
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

To lower him/her to the ground, use
PHP Code: (Select All)
SetPlayerCrouching(true); 
So, all together, you get this:

PHP Code: (Select All)
void OnStart()
{
    
AddEntityCollideCallback("Player""area_ko""script_ko"true0);
}

void OnEnter()
{

}

void Intro()
{

}

void script_ko(string &in asParentstring &in asChildint alState)
{
    
SetPlayerCrouching(true); // make tree fall further
    
SetPlayerJumpDisabled(true); //slow movement
    
StartPlayerLookAt("falling_tree_1"5.0f8.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"001000"world"); //makes tree fall
    
SetPlayerMoveSpeedMul(0.2f); //slows down player a ton
    
SetPlayerRunSpeedMul(0.2f); //applies slowness to running
    
StartScreenShake(0.05f4.0f0.5f10.0f); //shakes screen for 10 seconds
    
PlaySoundAtEntity("fallingtree""11_forest_minor.snt""Player"0false); //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(65220220); //head is sideways on floor, 65 is highest possible without glitches
    
PlaySoundAtEntity("hit""player_falldamage_max.snt""Player"0.0ffalse); //sound of tree hitting
    
GivePlayerDamage(20.0f"BloodSplat"falsefalse); // non-lethal damage to player
}

void timer_blackout(string &in asTimer)
{
    
FadeOut(0.0f); //instant blackout
    
PlaySoundAtEntity("insanity_ear_ring""insanity_ear_ring.snt""Player"3.0ffalse); //plays ringing noise
    
StopPlayerLookAt();
}

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(0220220); //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).

[Image: quote_by_rueppells_fox-d9ciupp.png]
(This post was last modified: 08-10-2013, 08:27 AM by CarnivorousJelly.)
08-10-2013, 07:45 AM
Find


Messages In This Thread
RE: Script for falling tree/knock player out? - by CarnivorousJelly - 08-10-2013, 07:45 AM



Users browsing this thread: 1 Guest(s)