void OnStart()
{
AddEntityCollideCallback("Player", "area_ko", "script_ko", true, 0);
}
void OnEnter()
{
}
void Intro()
{
}
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_blackout(string &in asTimer)
{
FadeOut(0.0f); //instant blackout
PlaySoundAtEntity("insanity_ear_ring", "insanity_ear_ring.snt", "Player", 3.0f, false); //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(0, 220, 220); //head back to normal
}
void OnLeave()
{
}