Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 3 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Tutorial] Use crowbar to open a door
SilentStriker Offline
Posting Freak

Posts: 950
Threads: 26
Joined: Jul 2011
Reputation: 43
#1
[Tutorial] Use crowbar to open a door

Hello everyone! Because alot of people has been asking how to open a door with a crowbar and get all the flashy effects of pulling and particles etc, here is a tutorial on how to do it! Smile

Important thing: All the items and things name can be changed they don't need to be named the same as I have in this tutorial but if you change the name remember to change inside the script!

Step 1: Choose the door of your liking on which you will use the crowbar, Then create the following so it looks like this:

[Image: 2011cz.png]

The AreaUseCrowbar is the tall script area, and should be placed in the aligned with the doors side.

The AreaBreakEffect is the little box placed near the handle of the door, you can place it a bit to the left of the handle and it should look good
It is used to make a dust effect when the door is unlocked

The BreakDoor script area is the big square on the right, It is there because when the crowbar hits the area it calls the function which opens the door.

The Crowbar_joint should be placed where the area is on the AreaUseCrowbar and should be sized up to 1.2, 1.2, 1.2. You can test how far in you want to crowbar to be Smile

The crowbar_dyn should be placed a bit to the right of the crowbar_joint and should be placed so the head of the crowbar is a little bit inside the BreakDoor area. And it should also be sized to 1.2, 1.2, 1.2
And is activated when the crowbar_joint hits the BreakDoor area and if you want the crowbar to break change the Entity file of the crowbar_dyn to Crowbar_broken

Remember: Make the crowbars inactive in the level editor

Step 2: And when all that is done it is time for the script. This is almost the same script (I removed some unecessary stuff) that Frictional games uses in Amnesia: TDD

PHP Code: (Select All)
////////////////////////////
// Run first time starting map
void OnStart()
{
//Makes it able for the Crowbar_joint to collide with the area in my case I call it BreakDoor
AddEntityCollideCallback("NAMEOFTHECROWBAR_JOINT""NAMEOFTHEAREA""CollideAreaBreakDoor"true1);

//Makes it able for the item crowbar to be used in the world, this one calls the callback if you place the crowbar on the door
AddUseItemCallback("crowbarondoor""NAMEOFTHECROWBAR""NAMEOFTHEDOOR""UseCrowbarOnDoor"true);

//Same as above but this one creates the callback if you place the crowbar in the area in my case the AreaUseCrowbar. 
//Remember that they call the same function so it doesn't matter where you use your crowbar
AddUseItemCallback("crowbaronframe""NAMEOFTHECROWBAR""NAMEOFTHEAREA""UseCrowbarOnDoor"true);
}

////////////////////
//BEGIN BREAK DOOR//

//The function called from the AddUseItemCallback
void UseCrowbarOnDoor(string &in asItemstring &in asEntity)
{
//Calls a timer that places the crowbar in the door frame.
AddTimer(asEntity0.2"TimerAttachCrowbar");

//Plays a sound of the player crouching. 
PlaySoundAtEntity("pickupcrow","player_crouch.snt""Player"0.05false);

//Removes the Crowbar.
RemoveItem(asItem);
}

//The timer we called before
void TimerAttachCrowbar(string &in asTimer)
{
//Plays the sound of the player putting the crowbar in the doorframe
PlaySoundAtEntity("attachcrowbar","puzzle_place_jar.snt""Player"0false);

//Sets the crowbar_joint active
SetEntityActive("NAMEOFTHECROWBAR_JOINT"true);
}

//The function we called from the AddEntityCollideCallback
void CollideAreaBreakDoor(string &in asParentstring &in asChildint alState)
{
//Gives a small boost of sanity
GiveSanityBoostSmall();

//Plays music because you completed the puzzle
PlayMusic("10_puzzle01.ogg"false0.70.110false);

//Unlocks the door
SetSwingDoorLocked("NAMEOFYOURDOOR"falsefalse);

//Makes the door not auto close on itself
SetSwingDoorDisableAutoClose("NAMEOFYOURDOOR"true);

//Opens the door slightly
SetSwingDoorClosed("NAMEOFYOURDOOR"false,false);

//Plays the sound of wood breaking.
PlaySoundAtEntity("break","break_wood_metal""NAMEOFYOURBREAKEFFECTAREA"0false);

//Creates a small dust smoke
CreateParticleSystemAtEntity("breakps""ps_hit_wood""NAMEOFYOURBREAKEFFECTAREA"false);

//Adds a impulse on the door. This may need some adjusting since your door may be facing another direction than mine
AddPropImpulse("NAMEOFYOURDOOR"003"world");

//Sets your crowbar_joint inactive
SetEntityActive("NAMEOFYOURCROWBAR_JOINT"false);

//Sets your dynamic crowbar active, In this case it's the Broken crowbar that will fall to the ground.
//You can use the crowbar_dyn then it will fall to the ground without being broken
SetEntityActive("NAMEOFYOURDYNAMICCROWBAR"true);

//Creates a timer that will make the door open slightly
AddTimer("pushdoor"0.1"TimerPushDoor"); 

//A debug showing that the door is open
AddDebugMessage("Break door!"false); 
}

//A timer that is going to push the door open
void TimerPushDoor(string &in asTimer)
{
//Adds a impulse on the door so it opens. Needs to be adjusted according to where your door is facing
AddPropImpulse("NAMEOFYOURDOOR", -12, -4"world");

//Creates a Timer so the door can auto close again.
AddTimer("doorclose"1.1"TimerDoorCanClose");
}
//Timer we just called
void TimerDoorCanClose(string &in asTimer)
{
//Makes the door able to auto close.
SetSwingDoorDisableAutoClose("NAMEOFYOURDOOR"false);
}

//END BREAK DOOR//
////////////////// 

If I missed something please let me know and I fix it ^^


I will maybe do a video tutorial on this if you guys want Smile

Almost forgot!

Here's a map + code for download, so you can look and see how it works yourself

http://www.mediafire.com/?a38095gcamuhat9
(This post was last modified: 05-15-2012, 03:03 PM by SilentStriker.)
02-01-2012, 04:04 PM
Find
UnseenLegend ( NL ) Offline
Member

Posts: 171
Threads: 10
Joined: Sep 2011
Reputation: 12
#2
RE: [Tutorial] Use crowbar to open a door

From who you getting it from xD... You guess it.

[Image: read-image.asp?n=n-20121202110321-m.jpg&r=8]
02-01-2012, 07:46 PM
Find
SilentStriker Offline
Posting Freak

Posts: 950
Threads: 26
Joined: Jul 2011
Reputation: 43
#3
RE: [Tutorial] Use crowbar to open a door

(02-01-2012, 07:46 PM)UnseenLegend ( NL ) Wrote: From who you getting it from xD... You guess it.
what? xD


02-01-2012, 07:48 PM
Find
trollox Offline
Member

Posts: 215
Threads: 16
Joined: Dec 2011
Reputation: 3
#4
RE: [Tutorial] Use crowbar to open a door

+1 for epic tortorial i actually needed this for my next map thanks a lot dude!
02-01-2012, 08:08 PM
Find
SilentStriker Offline
Posting Freak

Posts: 950
Threads: 26
Joined: Jul 2011
Reputation: 43
#5
RE: [Tutorial] Use crowbar to open a door

(02-01-2012, 08:08 PM)trollox Wrote: +1 for epic tortorial i actually needed this for my next map thanks a lot dude!
No problem dude Smile I know alot of people have asked on how to make this work Smile

02-01-2012, 08:34 PM
Find
Elven Offline
Posting Freak

Posts: 862
Threads: 37
Joined: Aug 2011
Reputation: 26
#6
RE: [Tutorial] Use crowbar to open a door

I hate that is is always like that:

door > crowbar
chest > crowbar
glass bottle > crowbar
my epic por ... nvm

The Interrogation
Chapter 1

My tutorials
02-02-2012, 04:20 PM
Find
SilentStriker Offline
Posting Freak

Posts: 950
Threads: 26
Joined: Jul 2011
Reputation: 43
#7
RE: [Tutorial] Use crowbar to open a door

(02-02-2012, 04:20 PM)Elven Wrote: I hate that is is always like that:

door > crowbar
chest > crowbar
glass bottle > crowbar
my epic por ... nvm
Yea I know.. but I rather use the crowbar like this then like a key Smile



02-02-2012, 07:57 PM
Find
Juby Away
Senior Member

Posts: 290
Threads: 2
Joined: May 2011
Reputation: 5
#8
RE: [Tutorial] Use crowbar to open a door

(02-02-2012, 07:57 PM)SilentStriker Wrote:
(02-02-2012, 04:20 PM)Elven Wrote: I hate that is is always like that:

door > crowbar
chest > crowbar
glass bottle > crowbar
my epic por ... nvm
Yea I know.. but I rather use the crowbar like this then like a key Smile

It still makes no sense to me why the crowbar breaks after use, it is a perfectly good crowbar you could use for... say golfing, beating up monsters, cheating the vending machines, hitting bananas, and etc...


Insanity. Static.
(This post was last modified: 02-05-2012, 05:04 AM by Juby.)
02-05-2012, 05:03 AM
Find
SilentStriker Offline
Posting Freak

Posts: 950
Threads: 26
Joined: Jul 2011
Reputation: 43
#9
RE: [Tutorial] Use crowbar to open a door

(02-05-2012, 05:03 AM)Juby Wrote:
(02-02-2012, 07:57 PM)SilentStriker Wrote:
(02-02-2012, 04:20 PM)Elven Wrote: I hate that is is always like that:

door > crowbar
chest > crowbar
glass bottle > crowbar
my epic por ... nvm
Yea I know.. but I rather use the crowbar like this then like a key Smile

It still makes no sense to me why the crowbar breaks after use, it is a perfectly good crowbar you could use for... say golfing, beating up monsters, cheating the vending machines, hitting bananas, and etc...
haha yea that's true but it's easy to not make the crowbar break Wink



02-05-2012, 05:04 PM
Find
RenanFOX2 Offline
Junior Member

Posts: 5
Threads: 2
Joined: Apr 2012
Reputation: 0
#10
RE: [Tutorial] Use crowbar to open a door

This Tutorial is not working.

It says "Unexpected end of file" on the end of your sprict.

Please can you tell how to call your script?
04-18-2012, 04:29 PM
Find




Users browsing this thread: 2 Guest(s)