Frictional Games Forum (read-only)

Full Version: Crowbar / Door
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
i don't know why when i put the crowbar in the door he breaks himself (the door unlock but the idea is interact with the crowbar)

My script:

Code:
////////////////////////////
// Run when enter map
void OnEnter()
{
AddEntityCollideCallback("crowbar_joint_1", "BreakDoor", "CollideAreaBreakDoor", true, 1);
AddUseItemCallback("crowbarondoor", "crowbar_1", "door_2","UseCrowbarOnDoor", true);
AddUseItemCallback("crowbaronframe", "crowbar_1", "AreaUseCrowbar", "UseCrowbarOnDoor", true);
}

void UseCrowbarOnDoor(string &in asItem, string &in asEntity)
{
    AddTimer(asEntity, 0.2, "TimerSwitchShovel");    
    PlaySoundAtEntity("pickupcrow","player_crouch.snt", "Player", 0.05, false);
    
    SetEntityPlayerInteractCallback("door_2", "", true);
    SetEntityPlayerInteractCallback("AreaUseCrowbar", "", true);
    
    RemoveItem(asItem);
}

void TimerSwitchShovel(string &in asTimer)
{
    PlaySoundAtEntity("attachshovel","puzzle_place_jar.snt", asTimer, 0, false);
    
    SetEntityActive("crowbar_joint_1", true);
}

void CollideAreaBreakDoor(string &in asParent, string &in asChild, int alState)
{
    GiveSanityBoostSmall();
    
    PlayMusic("10_puzzle01.ogg", false, 0.7, 0.1, 10, false);
    
    SetSwingDoorLocked("door_2", false, false);
    SetSwingDoorDisableAutoClose("porta_2", true);
    SetSwingDoorClosed("door_2", false,false);
    
    PlaySoundAtEntity("break","break_wood_metal", "AreaBreakEffect", 0, false);
    
    CreateParticleSystemAtEntity("breakps", "ps_hit_wood", "AreaBreakEffect", false);
    AddPropImpulse("door_2", -3, 0, 0, "world");
    
    SetEntityActive("crowbar_joint_1", false);
    SetEntityActive("crowbar_dyn_1", true);
    
    AddTimer("pushdoor", 0.1, "TimerPushDoor");    
}

void TimerPushDoor(string &in asTimer)
{
    AddPropImpulse("door_2", -1, 2, -4, "world");
    AddTimer("doorclose", 1.1, "TimerDoorCanClose");
}

void TimerDoorCanClose(string &in asTimer)
{
    SetSwingDoorDisableAutoClose("door_2", false);
}