Frictional Games Forum (read-only)
How to use crowbar to unlock door? (Solved) - 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: How to use crowbar to unlock door? (Solved) (/thread-6131.html)

Pages: 1 2


How to use crowbar to unlock door? (Solved) - HumiliatioN - 01-09-2011

Okay why my Crowbar is not working with the door?

What i am doing wrong? Simple Script using crowbar on "Prison door"
i use that crowbar but then it disappears and its gone.. And door is locked..

Full Script just in case:


void OnStart()
{
SetPlayerLampOil(0);
//if(ScriptDebugOn())
//{
// GiveItemFromFile("lantern", "lantern.ent");
// for(int i=0;i<10;i++) GiveItemFromFile("tinderbox_"+i, "tinderbox.ent");
// SetPlayerLampOil(100);
//}
AddUseItemCallback("", "crowbar_1", "prison_section_1", "UsedCrowbarOnDoor", true);
AddEntityCollideCallback("crowbar_joint_1", "ScriptArea_1", "CollideAreaBreakDoor", true, 1);
}

void OnEnter()
{
}

/// Actual Functions

void UsedCrowbarOnDoor(string &in asItem, string &in asEntity)
{
AddTimer("", 0.2, "TimerSwitchShovel");
RemoveItem("crowbar_1");
}

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

void CollideAreaBreakDoor(string &in asParent, string &in asChild, int alState)
{
AddPlayerSanity(25);
PlayMusic("10_puzzle01.ogg", false, 0.7, 0.1, 10, false);
SetSwingDoorLocked("prison_section_1", false, true);
SetMoveObjectState("prison_section_1", 1);
PlaySoundAtEntity("","break_wood_metal", "AreaBreakEffect", 0, false);
CreateParticleSystemAtEntity("", "ps_hit_wood", "AreaBreakEffect", false);
SetEntityActive("crowbar_joint_1", false);
SetLocalVarInt("Door", 1);
}


RE: How to use crowbar to unlock door? - triadtimes - 01-09-2011

(01-09-2011, 09:24 PM)HumiliatioN Wrote: Okay why my Crowbar is not working with the door?

What i am doing wrong? Simple Script using crowbar on "Prison door"
i use that crowbar but then it disappears and its gone.. And door is locked..

Full Script just in case:

Spoiler below!

void OnStart()
{
SetPlayerLampOil(0);
//if(ScriptDebugOn())
//{
// GiveItemFromFile("lantern", "lantern.ent");
// for(int i=0;i<10;i++) GiveItemFromFile("tinderbox_"+i, "tinderbox.ent");
// SetPlayerLampOil(100);
//}
AddUseItemCallback("", "crowbar_1", "prison_section_1", "UsedCrowbarOnDoor", true);
AddEntityCollideCallback("crowbar_joint_1", "ScriptArea_1", "CollideAreaBreakDoor", true, 1);
}

void OnEnter()
{
}

/// Actual Functions

void UsedCrowbarOnDoor(string &in asItem, string &in asEntity)
{
AddTimer("", 0.2, "TimerSwitchShovel");
RemoveItem("crowbar_1");
}

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

void CollideAreaBreakDoor(string &in asParent, string &in asChild, int alState)
{
AddPlayerSanity(25);
PlayMusic("10_puzzle01.ogg", false, 0.7, 0.1, 10, false);
SetSwingDoorLocked("prison_section_1", false, true);
SetMoveObjectState("prison_section_1", 1);
PlaySoundAtEntity("","break_wood_metal", "AreaBreakEffect", 0, false);
CreateParticleSystemAtEntity("", "ps_hit_wood", "AreaBreakEffect", false);
SetEntityActive("crowbar_joint_1", false);
SetLocalVarInt("Door", 1);
}


Here is what I have
(Must have gotten it from the same place.)

Spoiler below!

void UsedCrowbarOnDoor(string &in asItem, string &in asEntity)
{
AddTimer("", 0.2, "TimerSwitchShovel");
RemoveItem("crowbar_1");
CompleteQuest("BrokenLock", "BrokenLock");
CompleteQuest("BrokenLock", "BrokenLock2");
}

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

void CollideAreaBreakDoor(string &in asParent, string &in asChild, int alState)
{
AddPlayerSanity(25);
PlayMusic("10_puzzle01.ogg", false, 0.7, 0.1, 10, false);
SetSwingDoorLocked("mansion_3", false, true);
SetMoveObjectState("mansion_3", 1);
PlaySoundAtEntity("","break_wood_metal", "AreaBreakEffect", 0, false);
CreateParticleSystemAtEntity("", "ps_hit_wood", "AreaBreakEffect", false);
SetEntityActive("crowbar_joint_1", false);
SetLocalVarInt("Door", 1);
}


What is the problem? Can you not interact with the crowbar once it is in the door? Is the crowbar showing up at all?


RE: How to use crowbar to unlock door? - HumiliatioN - 01-09-2011

What is the problem? Can you not interact with the crowbar once it is in the door? Is the crowbar showing up at all?

I cant interact and its not showing at all. :/


RE: How to use crowbar to unlock door? - triadtimes - 01-09-2011

(01-09-2011, 10:53 PM)HumiliatioN Wrote: What is the problem? Can you not interact with the crowbar once it is in the door? Is the crowbar showing up at all?

I cant interact and its not showing at all. :/

Do you have a "crowbar_joint" which is not active on your door in the Level Editor? Because the code does the following:

Spoiler below!

void OnStart()
{
AddUseItemCallback("", "crowbar_1", "prison_section_1", "UsedCrowbarOnDoor", true); <-- This makes UsedCrowbarOnDoor run if crowbar_1 is used on prison_section_1
AddEntityCollideCallback("crowbar_joint_1", "ScriptArea_1", "CollideAreaBreakDoor", true, 1); <-- Once crowbar_joint_1 hits ScriptArea_1 it runs CollideAreaBreakDoor
}

void UsedCrowbarOnDoor(string &in asItem, string &in asEntity)
{
AddTimer("", 0.2, "TimerSwitchShovel"); <-- runs timer
RemoveItem("crowbar_1"); <-- Removes crowbar_1
}

void TimerSwitchShovel(string &in asTimer)
{
PlaySoundAtEntity("","puzzle_place_jar.snt", "", 0, false); <-- Plays a sound
SetEntityActive("crowbar_joint_1", true); <-- Makes crowbar_joint_1 active. There must be a non-active crowbar_joint_1 in the map for this to work
}

void CollideAreaBreakDoor(string &in asParent, string &in asChild, int alState)
{
AddPlayerSanity(25);<-- Sanity Boost
PlayMusic("10_puzzle01.ogg", false, 0.7, 0.1, 10, false);<-- Plays Music
SetSwingDoorLocked("prison_section_1", false, true);<-- Unlocks the door
SetMoveObjectState("prison_section_1", 1);<-- Moves the door into state 1 (Open I think (This didn't work in mine but it is more aesthetic and won't interfere with gameplay))
PlaySoundAtEntity("","break_wood_metal", "AreaBreakEffect", 0, false);<-- Plays a sound
CreateParticleSystemAtEntity("", "ps_hit_wood", "AreaBreakEffect", false);<-- Creates a particle effect at entity AreaBreakEffect
SetEntityActive("crowbar_joint_1", false);<-- makes the crowbar_joint_1 not active
SetLocalVarInt("Door", 1);<-- Sets the Variable Door to 1
}


The problems might be that you don't have a crowbar_joint_1 (which should be not active) at prison_section_1, and you might not have all of the necessary scripting areas.


RE: How to use crowbar to unlock door? - HumiliatioN - 01-09-2011

The problems might be that you don't have a crowbar_joint_1 (which should be not active) at prison_section_1, and you might not have all of the necessary scripting areas.

Oh, I Forgot that thanks... But now its only opens and there is that Area effect but not that when you must turn that crowbar to open.. Only Soundeffect and particle then its open not that Crowbar animation i mean Smile


RE: How to use crowbar to unlock door? - triadtimes - 01-09-2011

(01-09-2011, 11:38 PM)HumiliatioN Wrote: The problems might be that you don't have a crowbar_joint_1 (which should be not active) at prison_section_1, and you might not have all of the necessary scripting areas.

Oh, I Forgot that thanks... But now its only opens and there is that Area effect but not that when you must turn that crowbar to open.. Only Soundeffect and particle then its open not that Crowbar animation i mean Smile

I think your problem is that you have your area directly on the crowbar

It should look (somewhat) like this:
Spoiler below!
[Image: Crowbar01.jpg]
Notice that the crowbar_joint_1 is not in the ScriptArea but can be moved into it

I think yours looks like this:
Spoiler below!
[Image: Crowbar02.jpg]
See that the crowbar is in the ScriptArea and will automatically fire AddEntityCollideCallback("crowbar_joint_1", "ScriptArea_1", "CollideAreaBreakDoor", true, 1);


RE: How to use crowbar to unlock door? - HumiliatioN - 01-09-2011

Oh many thanks now it works Tongue

You are good with scripting Smile


RE: How to use crowbar to unlock door? (Solved) - Tony32 - 01-11-2011

Surely an intresting script. I think I'll use it aswell. Thank you! Smile


RE: How to use crowbar to unlock door? (Solved) - Vradcly - 01-28-2011

Now I am trying this aswell, but there is one thing that is a bit unclear.

Where do I create the joint?, Is the joint also a script area or what is it and how do I create it?
Cant find joint creation on the level editor, so it must be something else that i just move into position and call a joint?


RE: How to use crowbar to unlock door? (Solved) - Vradcly - 01-28-2011

Nwm, now i understand, its an entity of the crowbar Smile