//-------------------------------------------------------
//GENERAL HELPERS
//This starts an event timer, with the state set to 0 (just to be sure)
void ResumeEventTimer(string &in asTimer)
{
SetLocalVarInt(asTimer, 0);
ResumeEventTimer(asTimer, 0);
}
//Resumes an event timer after a step is over.
void ResumeEventTimer(string &in asTimer, float afTime)
{
AddTimer(asTimer, afTime, asTimer);
}
//-------------------------------------------------------
void OnStart()
{
AddEntityCollideCallback("Player", "AreaBreath", "CollideAreaBreath", true, 1);
SetEntityPlayerInteractCallback("FakeCrank", "InteractWithCrank", true);
SetEntityPlayerInteractCallback("LadderArea", "InteractWithLadder", true);
SetMessage("Messages", "chapter2", 0);
GiveSanityBoostSmall();
AddEntityCollideCallback("Player","AreaDustEnter","CollideDustPaper",true,1);
AddEntityCollideCallback("Player","DieFool","CollideDieFool",false,1);
AddEntityCollideCallback("Player","Fall","FallEvent",true,1);
AddUseItemCallback("getoil", "DirtyContainer", "AreaGetOil", "UseContainerOnOil", false);
AddUseItemCallback("", "glass_container_oil_1", "FakeCrank", "OilContainerOnFakeCrank", false);
AddUseItemCallback("", "LadderPiece1", "LadderPiece_1", "UseLadder1Onarea", false);
AddUseItemCallback("", "LadderPiece2", "LadderPiece_2", "UseLadder2Onarea", false);
GiveSanityBoostSmall();
PlayMusic("19_puzzle_inject.ogg", false, 0.7f, 0, 10, false);
AddEntityCollideCallback("wood_box03_1", "DamageArea_1", "Impact1", false, 1);
AddEntityCollideCallback("wood_box03_1", "DamageArea", "Impact2", false, 1);
AddEntityCollideCallback("wood_box01_1", "DamageArea", "Impact2", false, 1);
AddEntityCollideCallback("wood_box01_1", "DamageArea_1", "Impact1", false, 1);
AddEntityCollideCallback("wood_box01_2", "DamageArea_1", "Impact1", false, 1);
AddEntityCollideCallback("wood_box01_2", "DamageArea", "Impact2", false, 1);
AddEntityCollideCallback("wood_box_small01_1", "DamageArea", "Impact2", false, 1);
AddEntityCollideCallback("wood_box_small01_1", "DamageArea_1", "Impact1", false, 1);
AddEntityCollideCallback("chair_wood02_1", "DamageArea", "Impact2", false, 1);
AddEntityCollideCallback("chair_wood02_1", "DamageArea_1", "Impact1", false, 1);
AddEntityCollideCallback("Fall_1", "Player", "CollideRockVSPlayer", true, 1);
SetPropHealth("castle_1", 50.0f);
}
void FallEvent(string &in asParent, string &in asChild, int alState)
{
ResumeEventTimer("TimerFallEvent");
StartScreenShake(0.02f, 0.5f, 0.8f, 2.0f);
PlaySoundAtEntity("rumble", "general_rock_rumble_no3d.snt", "Player", 0.5f, true);
}
void TimerFallEvent(string &in asTimer)
{
string sEvent = asTimer; //Using first timer name for variable, timer name and callback for the timer that loops
AddLocalVarInt(sEvent, 1); //What step to play in the event (if sEvent is 1, case 1 is played)
float fEventSpeed = 1.0f; //The default time between steps in an event
bool bPauseAtStep = false; //Pauses after current step is done (a ResumeEventTimer would unpause)
switch(GetLocalVarInt(sEvent)){
case 1:
StartScreenShake(0.009f, 0.0f, 4.0f, 2.0f);
´ PlaySoundAtEntity("scare", "explosion_rock_large", "Fall_2", 1, false);
StopSound("rumble", 0.2f);
fEventSpeed = 0.1f; //Set this as temporarly default time
break;
case 2:
StartPlayerLookAt("Fall_2", 2, 1, "");
fEventSpeed = 0.1f;
break;
case 3:
SetEntityActive("Fall_1",true);
bPauseAtStep = true; //Pause here until the rocks hits the player
break;
case 4:
StopPlayerLookAt(); //Just in case
SetPlayerActive(false);
ChangePlayerStateToNormal(); //In case the player still manages to hold the ladder
PlaySoundAtEntity("scare", "player_falldamage_med.snt", "Player", 0.5, false);
PlaySoundAtEntity("scare", "player_bodyfall.snt", "Player", 0, false);
StartPlayerLookAt("servant_grunt_1", 2, 1, "");
TeleportPlayer("PlayerStartArea_3");
fEventSpeed = 0.1f;
break;
case 5:
//Before showing vision to player, make it look like player is lying down (legit)
FadePlayerRollTo(75, 10, 100);
MovePlayerHeadPos(-0.2f, -1.3f, 0, 10, 0.5f);
SetRadialBlurStartDist(0.5f); //Blur vision too :D
FadeRadialBlurTo(0.1f, 0.01f);
break;
case 6:
PlayGuiSound("react_breath", 1.0f);
fEventSpeed = 4.0f;
break;
case 7:
SetMessage("Messages", "hoursago", 0);
fEventSpeed = 5.0f;
break;
case 8:
SetEntityActive("servant_grunt_1", true);
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_3", 0.0f, "");
FadeIn(2);
//AddEffectVoice("voices", "BackHere.ogg", "Voice", "BackHere", false, "Player", 1, 1);
fEventSpeed = 3.0f;
break;
case 9:
FadeOut(3);
StartPlayerLookAt("ScriptArea_3", 4.0f, 4.0f, "");
PlayGuiSound("react_sigh", 1.0f);
fEventSpeed = 4.0f;
break;
case 10:
//SetRadialBlurStartDist(1.0f);
FadeRadialBlurTo(0, 0.1f);
StopMusic(3.0, 0);
ChangeMap("11_Start_Redux","PlayerStartArea_1","22_end","");
//Use FadePlayerRollTo(0, 10, 60); & MovePlayerHeadPos(0, 0, 0, 1, 0.5f); when
//you wanna tilt his head back to normal
break;
}
if(GetLocalVarInt(sEvent) <= 10 && bPauseAtEvent==false)
{
ResumeEventTimer(sEvent, fEventSpeed);
}
}
void CollideRockVSPlayer(string &in asParent, string &in asChild, int alState)
{
FadeOut(0.1f);
//Impact sound
PlaySoundAtEntity("rockcrush", "impact_rock_high.snt", "Player", 0.0f, false);
PlaySoundAtEntity("rockcrush", "impact_organic_med.snt", "Player", 0.0f, false);
ResumeEventTimer("TimerFallEvent", 1.0f);
}
//-------------------------------------------------------
void UseLadder1Onarea(string &in asItem, string &in asEntity)
{
RemoveItem(asItem);
SetPropActiveAndFade("ladder_mount_2", true, 0.5f);
SetEntityActive("LadderPiece_2", true);
PlaySoundAtEntity("breaths", "05_attach_ladder.ogg", "ladder_mount_2", 0.0f, false);
}
void UseLadder2Onarea(string &in asItem, string &in asEntity)
{
RemoveItem(asItem);
SetPropActiveAndFade("ladder_mount_1", true, 0.5f);
SetEntityActive("LadderArea_1", true);
PlaySoundAtEntity("breaths", "05_attach_ladder.ogg", "ladder_mount_1", 0.0f, false);
}
void CollideAreaBreath(string &in asParent, string &in asChild, int alState)
{
PlaySoundAtEntity("rocks", "03_rock_move.snt", "AreaBreath_1", 0.0f, false);
CreateParticleSystemAtEntity("warnps", "ps_cave_monster_warn.ps", "AreaBreath_1", false);
StartScreenShake(0.01f, 0.5f, 2.0f, 3.5f);
PlaySoundAtEntity("breaths", "04_breath.snt", "AreaBreath_1", 0.0f, false);
PlaySoundAtEntity("rocksm", "03_rock_move.snt", "AreaBreath_1", RandFloat(2.0f,6.0f), false);
CreateParticleSystemAtEntity("breathps", "ps_cave_monster_breath.ps", "AreaBreath_1", false);
}
void CollideDieFool(string &in asParent, string &in asChild, int alState)
{
PlaySoundAtEntity("fallaaaaaah", "11_fall", "Player", 0, false);
CheckPoint ("", "PlayerStartArea_2", "CheckPoint03", "Hints", "Hint3");
FadeOut(0.5f);
AddTimer("death1", 0.5f, "TimerFallDeath");
AddTimer("death2", 1, "TimerFallDeath");
}
void TimerFallDeath(string &in asTimer)
{
if(asTimer == "death1"){
PlaySoundAtEntity("bump1", "player_bodyfall", "Player", 0, false);
return;
}
DisableDeathStartSound();
AddPlayerHealth(-200);
PlaySoundAtEntity("pain", "player_falldamage_max", "Player", 0, false);
PlaySoundAtEntity("bump2", "player_bodyfall", "Player", 0, false);
}
void CollideDustPaper(string &in asParent, string &in asChild, int alState)
{
PlaySoundAtEntity("Wind", "general_wind_whirl", "Player", 2, false);
CreateParticleSystemAtEntity("PSDoor_3", "ps_dust_whirl.ps", "AreaDust", false);
}
void InteractWithCrank(string &in asEntity)
{
SetMessage("Messages", "NeedOil", 0);
AddQuest("InteractWithCrank", "Oil");
PlaySoundAtEntity("rocks", "16_lever_stuck.ogg", "FakeCrank", 0.0f, false);
}
void InteractWithLadder(string &in asEntity)
{
SetMessage("Messages", "Ladder", 0);
AddQuest("InteractWithLadder", "Ladder");
PlaySoundAtEntity("rocks", "18_touch_bridge1.ogg", "LadderArea", 0.0f, false);
}
void UseContainerOnOil(string &in asItem, string &in asEntity)
{
RemoveItem(asItem);
AddTimer("AddContainer", 1.1f, "TimerAddContainer");
AddTimer("StartCrouch", 0.8f, "TimerCrouch");
AddTimer("StopCrouch", 1.4f, "TimerCrouch");
AddTimer("AddContainer", 1.6f, "TimerStopLookAt");
SetLocalVarInt("FilledContainer", 1);
SetEntityPlayerInteractCallback("AreaOil", "", false);
StartPlayerLookAt("AreaLookAtContainer", 3, 3, "");
}
void TimerAddContainer(string &in asTimer)
{
DestroyParticleSystem("ParticleSystem_42");
SetEntityActive("glass_container_oil_1", true);
CreateParticleSystemAtEntity("fill", "ps_oil_jar", "glass_container_oil_1", true);
PlaySoundAtEntity("slurp", "16_fill_oil", "glass_container_oil_1", 0.0f, false);
}
void TimerCrouch(string &in asTimer)
{
if(asTimer == "StartCrouch"){
SetPlayerCrouching(true);
PlaySoundAtEntity("crouch", "player_crouch", "Player", 0.0f, false);
PlaySoundAtEntity("slurp2", "16_water_stream", "glass_container_oil_1", 0.3f, false);
return;
}
SetPlayerCrouching(false);
PlaySoundAtEntity("stand", "player_stand", "Player", 0.0f, false);
}
void TimerStopLookAt(string &in asTimer)
{
StopPlayerLookAt();
StopSound("slurp2", 4.0f);
}
void EntityCallGlassContainer(string &in asEntity, string &in type)
{
DestroyParticleSystem("fill");
CreateParticleSystemAtEntity("oilsplah", "ps_oil_splash.ps", "AreaLookAtContainer", true);
SetEntityPlayerInteractCallback("AreaOil", "InteractAreaOil02", false);
}
void OilContainerOnFakeCrank(string &in asItem, string &in asEntity)
{
SetLeverStuckState(asEntity, 0, true);
RemoveItem(asItem);
GiveItemFromFile("DirtyContainer", "glass_container.ent");
CompleteQuest("InteractWithCrank", "Oil");
SetEntityActive("crank_iron_1", true);
CreateParticleSystemAtEntity("oilsplah", "ps_oil_grease.ps", "PS", true);
PlaySoundAtEntity("stand", "16_grease_lever.ogg", "FakeCrank", 0.0f, false);
}
void MoveBridge(string &in asEntity, int LeverState)
{
if(LeverState == 1)
{
PlaySoundAtEntity("unstucksound", "16_bridge_unstuck", "ladder", 0.0f, false);
PlaySoundAtEntity("fall", "16_winch_bridge", "ladder", 1.0f, true);
AddTimer("hitground", 1.0f, "TimerBridgeHitGround");
StartScreenShake(0.05f, 0.5f, 0.1f, 0.3f);
SetMoveObjectStateExt("ladder", 1.12, 8, 8, 0.5, false);
GiveSanityBoostSmall();
PlayMusic("23_puzzle.ogg", false, 0.7f, 0, 10, false);
SetLeverStuckState(asEntity, LeverState, false);
}
}
void TimerBridgeHitGround(string &in asTimer)
{
StopSound("fall", 0.3f);
StartScreenShake(0.01f, 1.0f, 0.1f, 0.5f);
PlaySoundAtEntity("stucksound", "18_bridge_hit", "ladder", 0.0f, false);
}
//Break through the jammed door, barrel and stone can be used to break through.
float Distance = 0.25f;
void TooLight(string &in asParent , string &in asChild , int alState)
{
SetMessage("Messages", "TooLight", 0);
}
void Impact1(string &in asParent , string &in asChild , int alState)
{
AddTimer("ImpactTime" , 1.0f , "HitTime"); // This doesnt need to call anything
}
void Impact2(string &in asParent, string &in asChild, int alState)
{
float Time = (1.05f - GetTimerTimeLeft("ImpactTime")); // Get's the time taken to impact
float Speed = (Distance / Time); // Gets the speed
if(Speed >= 1.8f) // Minimum necessary speed
{
if (GetPropHealth("castle_1") == 50)
{
SetPropHealth("castle_1", 30.0f);
}
else
{
SetPropHealth("castle_1", 0.0f);
}
}
else
{
SetMessage("Messages", "TooWeakThrown", 0);
}
}
void OnEnter()
{
PlayMusic("16_amb.ogg", true, 0.7, 1, 0, true);
AutoSave();
}
void OnLeave()
{
}