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
PutraenusAlivius Offline
Posting Freak

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

(03-23-2013, 10:41 AM)Erik The Born Wrote:
(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!
Actually, you don't have to rename all the entities in order to have the script to work. Just change the entity names on the script to the one you have on the map.

"Veni, vidi, vici."
"I came, I saw, I conquered."
03-23-2013, 02:54 PM
Find
Knusper. Offline
Member

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

as i said:
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.

To have more doors:
I think just make everything as like the first door, and then just name all entities like:
breakdoor_2

so, maybe just for example add a 2 at the end.
And change the names in the script, witch you copy paste to have two.
Then you need to use new function names.
just with an other impactarea and so on.
I think that works, but i didnt test it.

No one knows, how "I" goes.
(This post was last modified: 03-23-2013, 06:10 PM by Knusper..)
03-23-2013, 06:09 PM
Find
PutraenusAlivius Offline
Posting Freak

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

(03-23-2013, 06:09 PM)Knusper. Wrote: as i said:
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.

To have more doors:
I think just make everything as like the first door, and then just name all entities like:
breakdoor_2

so, maybe just for example add a 2 at the end.
And change the names in the script, witch you copy paste to have two.
Then you need to use new function names.
just with an other impactarea and so on.
I think that works, but i didnt test it.

I didn't direct it to you. I was directing it to Erik The Born. And actually you can make another one.

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

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

(03-24-2013, 08:04 AM)JustAnotherPlayer Wrote:
(03-23-2013, 06:09 PM)Knusper. Wrote: as i said:
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.

To have more doors:
I think just make everything as like the first door, and then just name all entities like:
breakdoor_2

so, maybe just for example add a 2 at the end.
And change the names in the script, witch you copy paste to have two.
Then you need to use new function names.
just with an other impactarea and so on.
I think that works, but i didnt test it.

I didn't direct it to you. I was directing it to Erik The Born. And actually you can make another one.

Yes this is what my custom story has in its HPS file. However for some reason when I try to break a door. I hear the door break. But instead of the actual door im banging on geting broken, another door is lol. And then when I try to smash the door you actually need to smash it takes like infinity hits it never breaks. It might be me fucking something up but how? I paste my HPS to see if you can see some wrong in it.

PHP Code: (Select All)
void OnStart()
 {
 
AddEntityCollideCallback("Sledgehammer""ImpactArea""ImpactScript"false1);
 
AddEntityCollideCallback("Sledgehammer""ImpactArea_1""ImpactScript_1"false1);
 
AddUseItemCallback("""rusty_key""celler""UsedKeyOnDoor"true);
 }

 
// 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 asParentstring &in asChildint alState)
 {
 if(
GetLocalVarInt("BreakDoorInt") == 3)
 {
 
SetEntityActive("ImpactArea"false);
 
SetPropStaticPhysics("Pieces_2"false);
 
SetPropStaticPhysics("Pieces_1"false);
 
AddPropImpulse("Pieces_1"0.513"world");
 
AddPropImpulse("Pieces_2"0.60.32.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"0false);
 
SetPropHealth("BreakableDoor_1", -1);
 
AddPropImpulse("BreakableDoor_1"00, -0.5"world");
 } 
 
PlaySoundAtEntity("""break_wood.snt""BreakableDoor_1"0false);
 
AddLocalVarInt("BreakDoorInt"1);
 
CreateParticleSystemAtEntity("""ps_hit_wood""BreakEffect"false);
 
CreateParticleSystemAtEntity("""ps_hit_wood""BreakEffect2"false);
 }
void ImpactScript_1 (string &in asParentstring &in asChildint alState)
 {
 if(
GetLocalVarInt("BreakDoorInt") == 3)
 {
 
SetEntityActive("ImpactArea_1"false);
 
SetPropStaticPhysics("Pieces_4"false);
 
SetPropStaticPhysics("Pieces_3"false);
 
AddPropImpulse("Pieces_3"0.513"world");
 
AddPropImpulse("Pieces_4"0.60.32.5"world");
 
CreateParticleSystemAtEntity("""ps_hit_wood""BreakEffect_1"false);
 
PlayGuiSound("break_wood_metal.snt",2);
 } 

 if(
GetLocalVarInt("BreakDoorInt") == 2)
 {
 
PlaySoundAtEntity("""break_wood_metal.snt""Pieces_3"0false);
 
SetPropHealth("BreakableDoor_2", -1);
 
AddPropImpulse("BreakableDoor_2"00, -0.5"world");
 } 
 
PlaySoundAtEntity("""break_wood.snt""BreakableDoor_2"0false);
 
AddLocalVarInt("BreakDoorInt"1);
 
CreateParticleSystemAtEntity("""ps_hit_wood""BreakEffect_1"false);
 
CreateParticleSystemAtEntity("""ps_hit_wood""BreakEffect2"false);
 }
void ImpactScript_2 (string &in asParentstring &in asChildint alState)
 {
 if(
GetLocalVarInt("BreakDoorInt") == 3)
 {
 
SetEntityActive("ImpactArea_2"false);
 
SetPropStaticPhysics("Pieces_6"false);
 
SetPropStaticPhysics("Pieces_5"false);
 
AddPropImpulse("Pieces_5"0.513"world");
 
AddPropImpulse("Pieces_6"0.60.32.5"world");
 
CreateParticleSystemAtEntity("""ps_hit_wood""BreakEffect_2"false);
 
PlayGuiSound("break_wood_metal.snt",2);
 } 

 if(
GetLocalVarInt("BreakDoorInt") == 2)
 {
 
PlaySoundAtEntity("""break_wood_metal.snt""Pieces_5"0false);
 
SetPropHealth("BreakableDoor_2", -1);
 
AddPropImpulse("BreakableDoor_2"00, -0.5"world");
 } 
 
PlaySoundAtEntity("""break_wood.snt""BreakableDoor_3"0false);
 
AddLocalVarInt("BreakDoorInt"1);
 
CreateParticleSystemAtEntity("""ps_hit_wood""BreakEffect_2"false);
 
CreateParticleSystemAtEntity("""ps_hit_wood""BreakEffect2"false);
}
void UsedKeyOnDoor(string &in asItemstring &in asEntity)
{
SetSwingDoorLocked("celler"falsetrue);
PlaySoundAtEntity("""unlock_door""celler"0false);
RemoveItem("rusty_key");

(This post was last modified: 03-24-2013, 08:22 AM by Erik The Born.)
03-24-2013, 08:21 AM
Find
Knusper. Offline
Member

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

You need to have new names for the variables.
like: AddLocalVarInt("BreakDoorInt2", 1);
Thats why you seem to have to hit it infinity times.
I dont see more mistakes...

edit:

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

}

Why do you have both effects here?
You made that three times in your script.
I think its wrong, you just need the effect on the door where you hit Tongue

No one knows, how "I" goes.
(This post was last modified: 03-24-2013, 09:23 AM by Knusper..)
03-24-2013, 09:14 AM
Find
The chaser Offline
Posting Freak

Posts: 2,486
Threads: 76
Joined: Jun 2012
Reputation: 113
#16
RE: [SCRIPT] Breakable Door

*ehem*

Guys, you are complicating yourself. It's not hard to make a breakable door. With the sledge:

Make a area which fits the door, called, for example: AreaThatIsInTheDoor

void OnStart()
{
AddEntityCollideCallback("Sledge", "AreaThatIsInTheDoor", "Break_dammit", true, 1);
}

void Break_dammit (string &in asParent, string &in asChild, int alState)
{
SetPropHealth("DoorToBreak", 0); ///This will destroy it
SetPropHealth("DoorToBreak", 10); ///This will make it very destroyed but still in it's place
SetPropHealth("DoorToBreak", 40); ///This will crack it

CreateParticleSystemAtEntity("", "ps_hit_wood", "AreaThatIsInTheDoor", false);

////Choose between these to have your breakable door
}

THE OTHERWORLD (WIP)
[Image: k6vbdhu]

Aculy iz dolan.
03-24-2013, 11:55 AM
Find
Erik The Born Offline
Member

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

(03-24-2013, 09:14 AM)Knusper. Wrote: You need to have new names for the variables.
like: AddLocalVarInt("BreakDoorInt2", 1);
Thats why you seem to have to hit it infinity times.
I dont see more mistakes...

edit:

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

}

Why do you have both effects here?
You made that three times in your script.
I think its wrong, you just need the effect on the door where you hit Tongue

Ok I seem to be able to hit all the doors but... When I hit one of the doors I see particle effects and all that but when it breaks the door isnt broken! Instead Another door is broken. If I try to break that door it will do the same but it wont break any door at all. Whats wrong?

(03-24-2013, 11:55 AM)The chaser Wrote: *ehem*

Guys, you are complicating yourself. It's not hard to make a breakable door. With the sledge:

Make a area which fits the door, called, for example: AreaThatIsInTheDoor

void OnStart()
{
AddEntityCollideCallback("Sledge", "AreaThatIsInTheDoor", "Break_dammit", true, 1);
}

void Break_dammit (string &in asParent, string &in asChild, int alState)
{
SetPropHealth("DoorToBreak", 0); ///This will destroy it
SetPropHealth("DoorToBreak", 10); ///This will make it very destroyed but still in it's place
SetPropHealth("DoorToBreak", 40); ///This will crack it

CreateParticleSystemAtEntity("", "ps_hit_wood", "AreaThatIsInTheDoor", false);

////Choose between these to have your breakable door
}

I choose between the Health values? Why dont you make it so first hit it has 40. Second 10, and finally 0?
(This post was last modified: 03-24-2013, 12:08 PM by Erik The Born.)
03-24-2013, 12:05 PM
Find
PutraenusAlivius Offline
Posting Freak

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

(03-24-2013, 12:05 PM)Erik The Born Wrote:
(03-24-2013, 09:14 AM)Knusper. Wrote: You need to have new names for the variables.
like: AddLocalVarInt("BreakDoorInt2", 1);
Thats why you seem to have to hit it infinity times.
I dont see more mistakes...

edit:

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

}

Why do you have both effects here?
You made that three times in your script.
I think its wrong, you just need the effect on the door where you hit Tongue

Ok I seem to be able to hit all the doors but... When I hit one of the doors I see particle effects and all that but when it breaks the door isnt broken! Instead Another door is broken. If I try to break that door it will do the same but it wont break any door at all. Whats wrong?

(03-24-2013, 11:55 AM)The chaser Wrote: *ehem*

Guys, you are complicating yourself. It's not hard to make a breakable door. With the sledge:

Make a area which fits the door, called, for example: AreaThatIsInTheDoor

void OnStart()
{
AddEntityCollideCallback("Sledge", "AreaThatIsInTheDoor", "Break_dammit", true, 1);
}

void Break_dammit (string &in asParent, string &in asChild, int alState)
{
SetPropHealth("DoorToBreak", 0); ///This will destroy it
SetPropHealth("DoorToBreak", 10); ///This will make it very destroyed but still in it's place
SetPropHealth("DoorToBreak", 40); ///This will crack it

CreateParticleSystemAtEntity("", "ps_hit_wood", "AreaThatIsInTheDoor", false);

////Choose between these to have your breakable door
}

I choose between the Health values? Why dont you make it so first hit it has 40. Second 10, and finally 0?

If it hit first with the damage of 40, it will fall off.

"Veni, vidi, vici."
"I came, I saw, I conquered."
03-24-2013, 12:19 PM
Find
Erik The Born Offline
Member

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

(03-24-2013, 12:19 PM)JustAnotherPlayer Wrote:
(03-24-2013, 12:05 PM)Erik The Born Wrote:
(03-24-2013, 09:14 AM)Knusper. Wrote: You need to have new names for the variables.
like: AddLocalVarInt("BreakDoorInt2", 1);
Thats why you seem to have to hit it infinity times.
I dont see more mistakes...

edit:

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

}

Why do you have both effects here?
You made that three times in your script.
I think its wrong, you just need the effect on the door where you hit Tongue

Ok I seem to be able to hit all the doors but... When I hit one of the doors I see particle effects and all that but when it breaks the door isnt broken! Instead Another door is broken. If I try to break that door it will do the same but it wont break any door at all. Whats wrong?

(03-24-2013, 11:55 AM)The chaser Wrote: *ehem*

Guys, you are complicating yourself. It's not hard to make a breakable door. With the sledge:

Make a area which fits the door, called, for example: AreaThatIsInTheDoor

void OnStart()
{
AddEntityCollideCallback("Sledge", "AreaThatIsInTheDoor", "Break_dammit", true, 1);
}

void Break_dammit (string &in asParent, string &in asChild, int alState)
{
SetPropHealth("DoorToBreak", 0); ///This will destroy it
SetPropHealth("DoorToBreak", 10); ///This will make it very destroyed but still in it's place
SetPropHealth("DoorToBreak", 40); ///This will crack it

CreateParticleSystemAtEntity("", "ps_hit_wood", "AreaThatIsInTheDoor", false);

////Choose between these to have your breakable door
}

I choose between the Health values? Why dont you make it so first hit it has 40. Second 10, and finally 0?

If it hit first with the damage of 40, it will fall off.

What? Can you explain how to make it have 40 Health first hit. 10 after second hit. and at 3rd hit break? PS: This guys script didnt wokr at all. All I see is some very small particle effect no sound and most importantly it doesnt break. My apploligizes, I were stupid enough not to name the door to DoorToBreak lol. But I still need a way to make it so that you can hit 3 times and first tme 40 then 10 and last 0 so the door breaks. How does this work?
(This post was last modified: 03-24-2013, 01:18 PM by Erik The Born.)
03-24-2013, 12:27 PM
Find
PutraenusAlivius Offline
Posting Freak

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

(03-24-2013, 12:27 PM)Erik The Born Wrote:
(03-24-2013, 12:19 PM)JustAnotherPlayer Wrote:
(03-24-2013, 12:05 PM)Erik The Born Wrote:
(03-24-2013, 09:14 AM)Knusper. Wrote: You need to have new names for the variables.
like: AddLocalVarInt("BreakDoorInt2", 1);
Thats why you seem to have to hit it infinity times.
I dont see more mistakes...

edit:

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

}

Why do you have both effects here?
You made that three times in your script.
I think its wrong, you just need the effect on the door where you hit Tongue

Ok I seem to be able to hit all the doors but... When I hit one of the doors I see particle effects and all that but when it breaks the door isnt broken! Instead Another door is broken. If I try to break that door it will do the same but it wont break any door at all. Whats wrong?

(03-24-2013, 11:55 AM)The chaser Wrote: *ehem*

Guys, you are complicating yourself. It's not hard to make a breakable door. With the sledge:

Make a area which fits the door, called, for example: AreaThatIsInTheDoor

void OnStart()
{
AddEntityCollideCallback("Sledge", "AreaThatIsInTheDoor", "Break_dammit", true, 1);
}

void Break_dammit (string &in asParent, string &in asChild, int alState)
{
SetPropHealth("DoorToBreak", 0); ///This will destroy it
SetPropHealth("DoorToBreak", 10); ///This will make it very destroyed but still in it's place
SetPropHealth("DoorToBreak", 40); ///This will crack it

CreateParticleSystemAtEntity("", "ps_hit_wood", "AreaThatIsInTheDoor", false);

////Choose between these to have your breakable door
}

I choose between the Health values? Why dont you make it so first hit it has 40. Second 10, and finally 0?

If it hit first with the damage of 40, it will fall off.

What? Can you explain how to make it have 40 Health first hit. 10 after second hit. and at 3rd hit break? PS: This guys script didnt wokr at all. All I see is some very small particle effect no sound and most importantly it doesnt break. My apploligizes, I were stupid enough not to name the door to DoorToBreak lol. But I still need a way to make it so that you can hit 3 times and first tme 40 then 10 and last 0 so the door breaks. How does this work?

Hitting 40 first creates a big gap in the door. Using 10 makes a much smaller gap.

"Veni, vidi, vici."
"I came, I saw, I conquered."
03-24-2013, 02:14 PM
Find




Users browsing this thread: 1 Guest(s)