SilentStriker
Posting Freak
Posts: 950
Threads: 26
Joined: Jul 2011
Reputation:
43
|
[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!
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:
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
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
//////////////////////////// // 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", true, 1);
//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 asItem, string &in asEntity) { //Calls a timer that places the crowbar in the door frame. AddTimer(asEntity, 0.2, "TimerAttachCrowbar");
//Plays a sound of the player crouching. PlaySoundAtEntity("pickupcrow","player_crouch.snt", "Player", 0.05, false);
//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", 0, false);
//Sets the crowbar_joint active SetEntityActive("NAMEOFTHECROWBAR_JOINT", true); }
//The function we called from the AddEntityCollideCallback void CollideAreaBreakDoor(string &in asParent, string &in asChild, int alState) { //Gives a small boost of sanity GiveSanityBoostSmall();
//Plays music because you completed the puzzle PlayMusic("10_puzzle01.ogg", false, 0.7, 0.1, 10, false);
//Unlocks the door SetSwingDoorLocked("NAMEOFYOURDOOR", false, false);
//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", 0, false);
//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", 0, 0, 3, "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", -1, 2, -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
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 |
|
UnseenLegend ( NL )
Member
Posts: 171
Threads: 10
Joined: Sep 2011
Reputation:
12
|
RE: [Tutorial] Use crowbar to open a door
From who you getting it from xD... You guess it.
|
|
02-01-2012, 07:46 PM |
|
SilentStriker
Posting Freak
Posts: 950
Threads: 26
Joined: Jul 2011
Reputation:
43
|
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 |
|
trollox
Member
Posts: 215
Threads: 16
Joined: Dec 2011
Reputation:
3
|
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 |
|
SilentStriker
Posting Freak
Posts: 950
Threads: 26
Joined: Jul 2011
Reputation:
43
|
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 I know alot of people have asked on how to make this work
|
|
02-01-2012, 08:34 PM |
|
Elven
Posting Freak
Posts: 862
Threads: 37
Joined: Aug 2011
Reputation:
26
|
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
|
|
02-02-2012, 04:20 PM |
|
SilentStriker
Posting Freak
Posts: 950
Threads: 26
Joined: Jul 2011
Reputation:
43
|
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
|
|
02-02-2012, 07:57 PM |
|
Juby
Senior Member
Posts: 290
Threads: 2
Joined: May 2011
Reputation:
5
|
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
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 |
|
SilentStriker
Posting Freak
Posts: 950
Threads: 26
Joined: Jul 2011
Reputation:
43
|
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
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
|
|
02-05-2012, 05:04 PM |
|
RenanFOX2
Junior Member
Posts: 5
Threads: 2
Joined: Apr 2012
Reputation:
0
|
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 |
|
|