Frictional Games Forum (read-only)
Crowbar / Door - Printable Version

+- Frictional Games Forum (read-only) (https://www.frictionalgames.com/forum)
+-- Forum: Amnesia: The Dark Descent (https://www.frictionalgames.com/forum/forum-6.html)
+--- Forum: Custom Stories, TCs & Mods - Development (https://www.frictionalgames.com/forum/forum-38.html)
+---- Forum: Development Support (https://www.frictionalgames.com/forum/forum-39.html)
+---- Thread: Crowbar / Door (/thread-8972.html)



Crowbar / Door - H. Filipe - 07-05-2011

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);
}