Table of Contents

Opening A Door With A Crowbar

In this tutorial, I will teach you how to get a crowbar to open a door. First off, you need to understand why/how we use these little buggers.

The crowbar has become more popular over the past few months in custom stories, where it replaces the use of a key. You can also tweak the script and script areas to work on those wood planks we use as door barricades. I'm going to go over a few topics;

  1. Blowing open a door. That means when you use it, the door “explodes” open. (Hopefully not swinging back and hitting poor Daniel in the face) INTERMEDIATE
  2. Being able to pick up the crowbar again. Very handy! You only need to add an extra crowbar to drop which doesn't require much more effort. INTERMEDIATE

Basic Set-Up

We're going to begin with a basic, easy set-up.

First, find a nice door. Today for the example I'll be using a door named prison_1. (It's a prison door, if you didn't know.) Lock the door. You can re-name it whatever you'd like, just be sure to hit ENTER as always!

Next step. Place the crowbar in the room or in the map for the Player to pick up. We're using two different ones today, the joint and the regular one. Don't get confused by the names! I decided to hide my crowbar in a box under a bed. Make sure you select the crowbar called crowbar. Just plain old crowbar. Re-name your magic crowbar. I named mine crowbar_1. (Hit ENTER!)

Now we can place the joint crowbar. It's used on the door. That's the part where you grab it and move it on a joint to a certain degree until the door breaks open. Select crowbar_joint this time. When you place it in the door, avoid going too high. A tip to avoid this is to make the joint crowbar parallel to the door handle. Also make sure you're placing it on the right side. (Not where the hinges are.) See PICTURE 1. Once you're done, re-name it. I named mine crowbar_joint_1. Lastly, set it INACTIVE!

The last thing there is to do is place the Script areas. A lot of people find this the most confusing and difficult part. We need TWO script areas. One will be tall and skinny, and the other will be short and chubby.

The tall and skinny script area: This one is used for the joint crowbar. When you push it, the crowbar will hit the Script area and activate the dust and explosion effects, as well as open the door. Make sure you place it at a good distance from the joint crowbar. See PICTURE 2 and PICTURE 3. The tall and skinny script area is highlighted in white. My tall and skinny script area is called ScriptArea_1.

The short and chubby script area: This one is used for the dust effect. You can really place it anywhere around the door, but it's recommended you put it near the crowbar so the effect seems realistic. See PICTURE 4 and PICTURE 5. My short and chubby script area is called AreaBreakEffect.

Now we can work on the script!!

The Script

It's finally script time! I'm going to post the script as always, and then elaborate on it after. Here it is:

void OnStart()
{
AddUseItemCallback("", "crowbar_1", "prison_1", "UsedCrowbarOnDoor", true);
AddEntityCollideCallback("crowbar_joint_1", "ScriptArea_1", "CollideAreaBreakDoor", true, 1);
}
 
 
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_1", false, true);
 AddPropImpulse("prison_1", 0, 0, -50, "World");
 SetSwingDoorDisableAutoClose("prison_1", true);
 SetSwingDoorClosed("prison_1", false, false);
 SetMoveObjectState("prison_1", 1);
 PlaySoundAtEntity("","break_wood_metal", "AreaBreakEffect", 0, false);
 CreateParticleSystemAtEntity("", "ps_hit_wood", "AreaBreakEffect", false);
 SetEntityActive("crowbar_joint_1", false);
 SetLocalVarInt("Door", 1);
 } 
 
 
void OnEnter()
{
}
 
 
void OnLeave()
{
}

It's such a long script, no? This one is pretty basic- the door will unlock, explode open, and the crowbar will be lost forever. However, we can make it so another crowbar, the “same one”, is dropped back on the ground. We just have to add one function: SetEntityActive.

We will add the function in the last void section; CollideAreaBreakDoor. Now we just have to throw another crowbar into the map. To re-use the crowbar, you'll have to have TWO of these giant scripts. In the second one, be sure to change the names of the crowbar, crowbar joint, void function names(Like UsedCrowbarOnDoor. You'll have to change it to UsedCrowbarOnDoor2.) and door name.

Select a new plain old crowbar and place it in the air. Make sure it's very close to the original crowbar joint, to make it seem like it fell down. See PICTURE 6. Set the new crowbar inactive. Put the function SetEntityActive(“crowbar_2”, true); under the CollideAreaBreakDoor void. (The last one.) And that's it!

I hope you enjoyed my tutorial, be sure to request some if you want!

Created by JenniferOrange