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


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[SCRIPT] Breakable Door
Vic7im Offline
Junior Member

Posts: 44
Threads: 9
Joined: Sep 2012
Reputation: 3
#1
[SCRIPT] Breakable Door





Enjoy. Script is right down here

Spoiler below!


void OnStart()
{
AddEntityCollideCallback("Sledgehammer", "ImpactArea", "ImpactScript", false, 1);
}

// BreakableDoor_1 == Mansion_1 door
// Pieces_1/2 == custom Mansion_Broken made static and undying (-1 lifetime)
// Pieces just behind the door, the ImpactArea veeery close to BreakableDoor_1.
// Sledgehammer= Item used to destroy it.
// BreakEffect areas are on BreakableDoor_1




void ImpactScript (string &in asParent, string &in asChild, int alState)
{
if(GetLocalVarInt("BreakDoorInt") == 3)
{
SetEntityActive("ImpactArea", false);
SetPropStaticPhysics("Pieces_2", false);
SetPropStaticPhysics("Pieces_1", false);
AddPropImpulse("Pieces_1", 0.5, 1, 3, "world");
AddPropImpulse("Pieces_2", 0.6, 0.3, 2.5, "world");
CreateParticleSystemAtEntity("", "ps_hit_wood", "BreakEffect", false);
PlayGuiSound("break_wood_metal.snt",2);
}

if(GetLocalVarInt("BreakDoorInt") == 2)
{
PlaySoundAtEntity("", "break_wood_metal.snt", "Pieces_1", 0, false);
SetPropHealth("BreakableDoor_1", -1);
AddPropImpulse("BreakableDoor_1", 0, 0, -0.5, "world");
}
PlaySoundAtEntity("", "break_wood.snt", "BreakableDoor_1", 0, false);
AddLocalVarInt("BreakDoorInt", 1);
CreateParticleSystemAtEntity("", "ps_hit_wood", "BreakEffect", false);
CreateParticleSystemAtEntity("", "ps_hit_wood", "BreakEffect2", false);
}


How To: Create the custom .ent
  • Go to your Amnesia/Entities/Door/Mansion folder
  • Copy-Paste mansion_broken.ent and rename it to mansion_broken_static
  • Open mansion_broken_static with a text editor
  • Find and replace the value 4 with -1
  • Open HPL, there should be another entity named Mansion_Broken_static and voilà, you have door pieces that don't fade. Check the STATICPHYSICS box and you're done.

In the video I've placed two mansion_broken_static entities right behind the door.
(This post was last modified: 09-26-2012, 02:41 PM by Vic7im.)
09-26-2012, 02:33 PM
Find
Robby Offline
Posting Freak

Posts: 2,549
Threads: 38
Joined: Jun 2009
Reputation: 47
#2
RE: I'll just leave this here.

Not bad. People who know scripting might have created something similar.

But yeah, this little tutorial can help some newer scripters who want to do something like this.

Infrequently active. Don't expect an immediate response. Best to contact me at a different locale. If I create a thread, expect me to be quite active.
09-26-2012, 02:34 PM
Website Find
Fatalist Offline
Member

Posts: 122
Threads: 8
Joined: Dec 2012
Reputation: 8
#3
RE: [SCRIPT] Breakable Door

Can you upload this map? Please.

And how to make breakable barrel?

12-22-2012, 08:59 AM
Find
Erik The Born Offline
Member

Posts: 59
Threads: 7
Joined: Mar 2013
Reputation: 0
#4
RE: [SCRIPT] Breakable Door

Yeah I really liek this idea. Could someone who knows how to do this give a noob friendly tutorial for it?
03-21-2013, 06:21 PM
Find
PutraenusAlivius Offline
Posting Freak

Posts: 4,713
Threads: 75
Joined: Dec 2012
Reputation: 119
#5
RE: [SCRIPT] Breakable Door

(03-21-2013, 06:21 PM)Erik The Born Wrote: Yeah I really liek this idea. Could someone who knows how to do this give a noob friendly tutorial for it?

Nope. You must do all the things above.

"Veni, vidi, vici."
"I came, I saw, I conquered."
03-22-2013, 03:13 AM
Find
Erik The Born Offline
Member

Posts: 59
Threads: 7
Joined: Mar 2013
Reputation: 0
#6
RE: [SCRIPT] Breakable Door

(03-22-2013, 03:13 AM)JustAnotherPlayer Wrote:
(03-21-2013, 06:21 PM)Erik The Born Wrote: Yeah I really liek this idea. Could someone who knows how to do this give a noob friendly tutorial for it?

Nope. You must do all the things above.

What? The script he gave in the spoiler doesnt work. So far I Think I have to do this. Tell me if im wrong in these steps. Make a mansion door. Place it in a map. Put 2 mansion_broken_static wich made some custom values? That part I could need help with. What value to change? And I placed 2 of those right behind the door. So now what? do I need to make a script and Place the script box on the door or what? Anyways it doesnt work. If you know the scripting could please post the script then. Or perhaps the script he posted does work fully? In that case I would like help to know wich value 4 I am suppose to change.

More Detailed of what I did.

1st. Going to to mansion door and copying mansion_broken.ent.
2nd. Renaming the copy to mansion_broken_static.ent.
Opening the mansion_broken_static with a text editor and changing the value 4 to - 1. The value is found is like this. I hope its the right value.
<Var Name="LifeLength" Value="-1" />

3rd. In my custom story I add a sledgehammer and a mansion door. The mansion door is locked so the player must use the sledgehammer in order to proceed
4th. I create 2 mansion_broken_static right behind the door. The 2 mansion_broken_static are overlapping right behind the door.
5th. I check StaticPhysic on both of the 2 mansion_broken_static.
6th. I save my level and make a hps file to my level.
7th. I copy the script from the spoiler this guy posted the script in.
8th. I save the hps file and start Amnesia.
9th. I choose to start my level and wtf. I pickup the sledgehammer and bash the door with it, and nothing happens!

What did I do wrong here?\forgot to do?
(This post was last modified: 03-23-2013, 09:42 AM by Erik The Born.)
03-23-2013, 09:01 AM
Find
Knusper. Offline
Member

Posts: 58
Threads: 7
Joined: Feb 2013
Reputation: 2
#7
RE: [SCRIPT] Breakable Door

value 4 is "BreakImpulse" Value= "-1""
You have to name all entities like they are named in the scripts
or name all entities in the scripts like you named them in the editor.
(the words behind "//" can help)
And you have to put the areas just at the place where the door is.
(impact area, breakeffect areas)
And ofc name them like they are named in the scripts, too.

Naming all entities right is very important.
Think of the hammer, the broken pieces and the areas!

then it should work.

The only thing i dont like is that if you just hit the door very weak, it breaks too.
I will try to make that you have to through an item.

No one knows, how "I" goes.
(This post was last modified: 03-23-2013, 10:39 AM by Knusper..)
03-23-2013, 10:33 AM
Find
Erik The Born Offline
Member

Posts: 59
Threads: 7
Joined: Mar 2013
Reputation: 0
#8
RE: [SCRIPT] Breakable Door

(03-23-2013, 10:33 AM)Knusper. Wrote: value 4 is "BreakImpulse" Value= "-1""
You have to name all entities like they are named in the scripts
or name all entities in the scripts like you named them in the editor.
(the words behind "//" can help)
And you have to put the areas just at the place where the door is.
(impact area, breakeffect areas)
And ofc name them like they are named in the scripts, too.

Naming all entities right is very important.
Think of the hammer, the broken pieces and the areas!

then it should work.

The only thing i dont like is that if you just hit the door very weak, it breaks too.
I will try to make that you have to through an item.

Thank you. I wil try to do this as you said. What about ImpactArea and BreakEffect areas? What is those? PS: I managed to do it finally Big Grin I will make a Tutorial now. Your a life saver man!

Heres hopefully a noob friendly turoial on how to make a door that you can destroy with a sledgehammer.

Step 1. Go to the entities folder then mansion and copy mansion_broken.ent. then paste it to the same folder and rename it to mansion_broken_static.ent. Open the mansion_broken_static.ent with a text editor such as notepad or notepad++. Look for breakimpulse. Theres a value there which should say 4. Change it to -1. Save the file and open your leveleditor. Make a room. Make a mansion door.

Like this
[Image: Step%201.png]

Step 2 This is very important. Rename the door you just added to BreakableDoor_1. Case sensetive.

Like this
[Image: Step%202.png]

Step 3. Add the new made mansion_broken_static to your map and Place it right behind your door. Also name it Piece_1.

Like this
[Image: Step%203.png]
Sry I know its big.
Step 4. With the mansion_broken_static selected, got to Entity tab in the editor and check the box StaticPhysic.

Step 5. Click CTRL + D in the editor with the mansion_broken_static selected.. This should make an exact copy of the mansion_broken_static at the same place you have placed the first 1. The editor should rename the second mansion_broken_static to Piece_2 but in case it doesnt, rename it to Piece_2. You done? NO! Now you need to add the areas mentioned. Its ImpactArea and BreakEffect.

Step 6. Add a script from the editor. Do this by clicking the black cube in the editor. To the right of the editor you should see "Area Type". Choose Script. Draw it around the door. Make it as Close to the door you can. Name the area to BreakEffect. Make Another Script and make it as Close to the door as you can. Name it ImpactArea.

Step 7. Add a sledgehammer. Its important that you name it in the entity tab "Sledgehammer" without qoutes. Its case sensetive. So make sure you do have a Big S in Sledgehammer!

Step 8. Save your map now. Your done in the level editor. Now you should have a .map file in your custom story. make a new textdocument. It has to have the EXACT same name as your .map has. Case sensetive. Open the txt file you made and paste the script that this guy had in his spoiler. Save it. Now you must change the file extension from txt to hps. Do that by simple chosing to rename the file and choose only to rename the extension from txt to hps. DONE!

Step 8. Enjoy your brekable door!

If you have any problems post your steps here you made exactly and I or some1 else might be able to tell you what you did wrong. Remember to rename the entites and areas exactly as described here!
(This post was last modified: 03-23-2013, 01:59 PM by Erik The Born.)
03-23-2013, 10:41 AM
Find
Knusper. Offline
Member

Posts: 58
Threads: 7
Joined: Feb 2013
Reputation: 2
#9
RE: [SCRIPT] Breakable Door

Great tut.

No one knows, how "I" goes.
03-23-2013, 12:01 PM
Find
Erik The Born Offline
Member

Posts: 59
Threads: 7
Joined: Mar 2013
Reputation: 0
#10
RE: [SCRIPT] Breakable Door

(03-23-2013, 12:01 PM)Knusper. Wrote: Great tut.

Thank you! BTW how do you make more doors to break? I can have 1 but I tried having more doors brekable how do I add more doors?
(This post was last modified: 03-23-2013, 02:08 PM by Erik The Born.)
03-23-2013, 01:48 PM
Find




Users browsing this thread: 1 Guest(s)