void OnStart()
{
for(int i=1; i<=4; ++i) AddUseItemCallback("crowbarondoors", "Crowbar_1", "Door_"+i, "UseCrowbarOnDoor", false);
for(int i=1; i<=4; ++i) AddEntityCollideCallback("Joint_Door_"+i, "AreaBreak_"+i, "BreakDoor", true, 1);
}
void UseCrowbarOnDoor(string &in asItem, string &in asEntity)
{
RemoveItem("asItem");
PlaySoundAtEntity("", "player_crouch.snt", "Player", 0.05, false);
AddTimer(asEntity, 0.2, "TimerPlaceCrowbar");
SetLocalVarString("CrowbarDoor", asEntity);
}
void TimerPlaceCrowbar(string &in asTimer)
{
SetEntityActive("Joint_"+asTimer, true);
PlaySoundAtEntity("", "puzzle_place_jar.snt", asTimer, 0, false);
}
void BreakDoor(string &in asParent, string &in asChild, int alState)
{
SetEntityActive(asParent, false);
SetSwingDoorLocked(GetLocalVarString("CrowbarDoor"), false, false);
SetSwingDoorClosed(GetLocalVarString("CrowbarDoor"), false, false);
SetSwingDoorDisableAutoClose(GetLocalVarString("CrowbarDoor"), true);
AddPropImpulse(GetLocalVarString("CrowbarDoor"), 0, 0, 3, "world");
CreateParticleSystemAtEntity("", "ps_hit_wood.ps", "AreaEffect", false);
PlaySoundAtEntity("", "break_wood_metal", "AreaEffect", 0, false);
GiveSanityBoostSmall();
PlayMusic("10_puzzle01.ogg", false, 0.7, 0.1, 10, false);
AddTimer("", 0.1, "TimerPushDoor");
GiveItem("crowbar", "Puzzle", "crowbar", "crowbar.tga", 1);
}
void TimerPushDoor(string &in asTimer)
{
AddPropImpulse(GetLocalVarString("CrowbarDoor"), -4, 2, 1, "world");
AddTimer("", 1.1, "TimerDoorCanClose");
}
void TimerDoorCanClose(string &in asTimer)
{
SetSwingDoorDisableAutoClose(GetLocalVarString("CrowbarDoor"), false);
}