Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
PhilibusMo

Breakable glass

Recommended Posts

How do you create breakable glass? I have searched the forums, checked out the relevent threads, looked at some example scripts and yet i am still completly clueless on how to create the damn stuff. I have a map with currently 6 windows in very different places and I would like all of them to be breakable to make the enviroment seem more realistic and to give a couple of moments more drama.
I realise that you have to use the breakable glass linedef and a script but otherwise I just don't have a clue what to do. I am using zdoom; doom in hexen format, so it should work but I am still mightily confused. I am also working on a wad with multiple maps so it will have to work for more than 1 map.

Share this post


Link to post

A vanilla-compatible approach is to use shootable switches, with the broken window being the on-state. For a working example (first one that springs to mind) check out Gulph - gulphgf.wad in particular.

Share this post


Link to post

That is pretty good and I like the noise but I want transparent glass that disappears when shot, causing 'shards of glass' to be spawned and flung in the opposite direction that the projectile that hit it was going (must be both player and monster bullets and projectiles). Is this possible? I am using zdoom doom in hexen format and see the breakable glass option in the linedef actions pane but can't for the life of me work out how to get it to work.

Share this post


Link to post

Personally, I prefer the scripted method to the line type method as it gives a bit more flexibility. If you're interested, go here

http://members.lycos.co.uk/enjay001/

And about 3/4 of the way down the page look for the example called:

"A Smashable Mirror For Zdoom"

This is, obviously, a mirror, but the same effect can be used for simple glass windows. It's the same basic effect that Hexen used in its first map.

My Marine Assault also used the effect extensively

http://www.doomworld.com/idgames/index.php?id=12214

Though I have a nasty feeling that I may have forgot to include the script source in the file.

Share this post


Link to post

Check Hexen's MAP01.

The glass is a raised plataform with the glass lower wall texture, and with a broken glass midle texture. You must make a script that instantly lowers the sector when hit by a shoot, and create the glass particles.

Share this post


Link to post

There are better ways to do that, though. In particular, the method used in Hexen is not compatible with transparent windows.

I used ZPack E1M1 as a reference, personally.

Share this post


Link to post

I really don't understand how to change thw script in the sample wad that you provided Enjay. I have had a good look and there are just too mnay things I don't understand.
What I want is a window that is translucent using Shawn2 as the texture (if possible) where if the glass is shot then you get a noise and the glass disappears and becomes non blocking with 'glass shards' flying in the direction that the projectile hit. I understand the glass break line def action even less than I understand the acs script. Could some one give me a basic script that could work with multiple windows in a level that I could modify to suit my needs?

Share this post


Link to post

Note that script 1 is only for Hexen-format, and should not be used in UDMF as there these properties are set directly in the editor rather than set through a script.

Here I have several windows, which are linedefs with map spots put along them. (In that level, they're stained glass windows and the flying monsters are the Heretic disciples and Hexen bishops.) I set them up so that along with window 20, the map spots are given TIDs of 21 to 29. That way the script works.

This script is kinda more complex than it needs to be, but it should be clear enough.

#include "zcommon.acs"


// Window scripts shamelessly stolen from ZPack E1M1 by Captain Toenail.
// He said "special thanks to Randy and Enjay for these! :D" so, same thing.


#define FIRSTWINDOW 20
#define LASTWINDOW 180

// Set up the stained glass windows as translucent and breakable,
// let flying monsters pass through for uberfreakiness.
script 1 OPEN
{
	int i;

	For (i = FIRSTWINDOW; i <= LASTWINDOW; i+=10)
	{
		SetLineBlocking(i, BLOCK_PLAYERS);
		TranslucentLine(i, 216, false);
		SetLineSpecial(i, ACS_Execute, 2, 0, i, 0, 0);
	}
}

// Breaks the stained glass window, with broken glass sound and shower of shards
script 2 (int id)
{
	int i;
	SetLineSpecial(id,0,0,0,0,0);
	ThingSound(id, "world/glass", 200);
	SetLineBlocking(id, off);
	If (id == 20) // Central branch main window
	{
		SetLineTexture(id, SIDE_FRONT, TEXTURE_MIDDLE, "SGLASS3S");
		SetLineTexture(id, SIDE_BACK, TEXTURE_MIDDLE, "SGLASS4S");
		i = 64;
	}
	Else If (id == 30 || id == 40) // Side branch main windows
	{
			SetLineTexture(id, SIDE_FRONT, TEXTURE_MIDDLE, "SGLASS3T");
			SetLineTexture(id, SIDE_BACK, TEXTURE_MIDDLE, "SGLASS4T");
			i = 64;
	}
	Else // Side windows
	{
		SetLineTexture(id, SIDE_FRONT, TEXTURE_MIDDLE, "SGLASS1B");
		SetLineTexture(id, SIDE_BACK, TEXTURE_MIDDLE, "SGLASS1R");
		i = 24;
	}
	Delay(const:1);
	For(; i > 0; i--)
	{
		// Each window has nine points of origin for a more convincing explosion. 
		// And good thing the SpawnIDs for glass shards are a continuous range.
		Thing_ProjectileGravity(id+random(0,8), random(T_STAINEDGLASS1, T_STAINEDGLASS0),
 random(0, 255), random(10, 40), random(5, 20));
	}
}

Share this post


Link to post

the glass that I want to be breakable is linedef 8418 and 8421
I do not want flying monster to be able to get through.
is this correct?
I want there to be no texture displayed in the window hole once it has been smashed.
my glass shard projectiles are called GLASS01 and GLASS02
EDIT: I now understand how to position them but don't understand their relation to the code.

#include "zcommon.acs"


// Window scripts shamelessly stolen by Gez from ZPack E1M1 by Captain Toenail then passed on to me.
// He said "special thanks to Randy and Enjay for these! :D" so, same thing.


#define FIRSTWINDOW 20 
#define LASTWINDOW 180
//DO NOT UNDERSTAND WHAT THAT MEANS

script 1 OPEN
{
	int i;

	For (i = FIRSTWINDOW; i <= LASTWINDOW; i+=10)
	{
		SetLineBlocking(i, BLOCK_PLAYERS);
		TranslucentLine(i, 216, false);
		SetLineSpecial(i, ACS_Execute, 2, 0, i, 0, 0);
	}
}


script 2 (int id)
{
	int i;
	SetLineSpecial(id,0,0,0,0,0);
	ThingSound(id, "world/glass", 200);
	SetLineBlocking(id, off);
	If (id == 20)
	
	}
	Delay(const:1);
	For(; i > 0; i--)
	{
		// Each window has nine points of origin for a more convincing explosion. 
		// And good thing the SpawnIDs for glass shards are a continuous range.
		Thing_ProjectileGravity(id+random(0,8), random(GLASS01, GLASS02),
 random(0, 255), random(10, 40), random(5, 20));
	}
}

Share this post


Link to post

To make the window block monsters as well, replace the SetLineBlocking instruction by something more appropriate. Look here, this function is better than SetLineBlocking, more flexible.

The defines are just constants. I have a setup where my windows are given tags of 20, 30, 40, 50 [..] 160, 170, 180. Since this was a Hexen-format map, these tags are given to them by giving them the 121:Line_SetIdentification special. The tag is the first parameter. The rest can be left to a blank value of 0. The linedef numbers are irrelevant.

So, if you only have two windows, then they could be set to, say, 20 and 30. It doesn't really matter. What counts is that if you decide to add more breakable windows, you've got only a define to change in the script.

Feel free to experiment with different values for the TranslucentLine special. I used 216 for stained glass, you'll probably want something
a bit more clear for normal glass.

Now, the explosion. You want to remove the texture entirely, so you'll need to put back a part that you removed from the script.

	SetLineTexture(id, SIDE_FRONT, TEXTURE_MIDDLE, "-");
	SetLineTexture(id, SIDE_BACK, TEXTURE_MIDDLE, "-");
	i = 24;
Without these instructions, you do not give a value to i (which is used as the total amount of glass shards; I have large windows giving up 64 fragments and small windows breaking up in only 24 pieces. Use an amount you deem reasonable. The SetLineTexture calls are what change the texture. For ZDoom, "-" means "no texture" so it removes it entirely. You need to remove both the front and the back middle textures.

Another point:

PhilibusMo said:

my glass shard projectiles are called GLASS01 and GLASS02

The identifiers T_STAINEDGLASS1 and T_STAINEDGLASS0 are the constant names for SpawnIDs. The corresponding actors are the various derived classes from GlassShard. If GLASS01 and GLASS02 are actor names, you can't use them directly. You need to give them spawnids, in a range (e.g.: 251 and 252), and use these numbers instead. I used a function that use spawnids rather than actor name so that the choice could be randomized; it's easier to obtain a random number than a random name.



For the map spots, you place them where you want them to be (don't forget height!) and you give them appropriate TID in the editor. Since you use 5, rather than 9, the first parameter for Thing_ProjectileGravity will need to be id+random(0,4), not random(0,8). Then, supposing you went with tag 20 for the first window and 30 for the second, you'll give to the map spots of the first window the tids 20, 21, 22, 23 and 24. The second window's spots will be 30, 31, 32, 33 and 34.


Does the working of the script seems clearer now?

Share this post


Link to post
Gez said:

To make the window block monsters as well, replace the SetLineBlocking instruction by something more appropriate. Look here, this function is better than SetLineBlocking, more flexible.

The defines are just constants. I have a setup where my windows are given tags of 20, 30, 40, 50 [..] 160, 170, 180. Since this was a Hexen-format map, these tags are given to them by giving them the 121:Line_SetIdentification special. The tag is the first parameter. The rest can be left to a blank value of 0. The linedef numbers are irrelevant.

So, if you only have two windows, then they could be set to, say, 20 and 30. It doesn't really matter. What counts is that if you decide to add more breakable windows, you've got only a define to change in the script...

...For the map spots, you place them where you want them to be (don't forget height!) and you give them appropriate TID in the editor. Since you use 5, rather than 9, the first parameter for Thing_ProjectileGravity will need to be id+random(0,4), not random(0,8). Then, supposing you went with tag 20 for the first window and 30 for the second, you'll give to the map spots of the first window the tids 20, 21, 22, 23 and 24. The second window's spots will be 30, 31, 32, 33 and 34.


I'm afraid I still don't understand these bits.
This is what I have done:
The 2 linedefs I want to be glass I have set an action of 121.
Then in the 'set line ID' box I have typed 20 for one of the windows and 30 for the other.
I have changed the trigger to projectile hits.

The map spots I have given a tag of 21, 22, 23, 24 and 25 for the ones at the first window and 31, 32, 33, 34 and 35 for the ones at the second window.
in the code I changed it to: id+random(0,4)
This is what my script currently looks like:

#include "zcommon.acs"


// Window scripts shamelessly stolen by Gez from ZPack E1M1 by Captain Toenail then passed on to me.
// He said "special thanks to Randy and Enjay for these! :D" so, same thing.


#define FIRSTWINDOW 20 
#define LASTWINDOW 180
//DO NOT UNDERSTAND WHAT THAT MEANS

script 1 OPEN
{
	int i;

	For (i = FIRSTWINDOW; i <= LASTWINDOW; i+=10)
	{
		SetLineBlocking(i, BLOCKF_EVERYTHING);
		TranslucentLine(i, 216, false);
		SetLineSpecial(i, ACS_Execute, 2, 0, i, 0, 0);
	}
}


script 2 (int id)
{
	int i;
	SetLineSpecial(id,0,0,0,0,0);
	ThingSound(id, "world/glass", 200);
	SetLineBlocking(id, off);
	If (id == 20) // Central branch main window
	{
		SetLineTexture(id, SIDE_FRONT, TEXTURE_MIDDLE, "-");
		SetLineTexture(id, SIDE_BACK, TEXTURE_MIDDLE, "-");
		i = 64;
	}

	
	Delay(const:1);
	For(; i > 0; i--)
	{

		Thing_ProjectileGravity(id+random(0,4), random(250, 251),
 random(0, 255), random(10, 40), random(5, 20));
	}
}
the windows aren't appearing in game. What is wrong. I cannot see how the linedefs are meant to know to use the script.

Share this post


Link to post

Let's fix a few trivial mistakes

#include "zcommon.acs"


// Window scripts shamelessly stolen by Gez from ZPack E1M1 by Captain Toenail then passed on to me.
// He said "special thanks to Randy and Enjay for these! :D" so, same thing.


#define FIRSTWINDOW 20 
#define LASTWINDOW 30

script 1 OPEN
{
	int i;

	For (i = FIRSTWINDOW; i <= LASTWINDOW; i+=10)
	{
		Line_SetBlocking(i, BLOCKF_EVERYTHING);
		TranslucentLine(i, 216, false);
		SetLineSpecial(i, ACS_Execute, 2, 0, i, 0, 0);
	}
}


script 2 (int id)
{
	int i;
	SetLineSpecial(id,0,0,0,0,0);
	ThingSound(id, "world/glass", 200);
	SetLineBlocking(id, off);
	SetLineTexture(id, SIDE_FRONT, TEXTURE_MIDDLE, "-");
	SetLineTexture(id, SIDE_BACK, TEXTURE_MIDDLE, "-");
	i = 64;

	
	Delay(const:1);
	For(; i > 0; i--)
	{

		Thing_ProjectileGravity(id+random(0,4), random(250, 251),
 random(0, 255), random(10, 40), random(5, 20));
	}
}

PhilibusMo said:

the windows aren't appearing in game. What is wrong.

I don't know. What do you mean by "aren't appearing in game" exactly?

PhilibusMo said:

I cannot see how the linedefs are meant to know to use the script.

The linedefs have their specials changed to ACS_Execute (2, 0, i, 0, 0). This is done in Script 1, with the call to 80:SetLineSpecial. This is how they know about the script. So for window 20, its special is changed to 80(2, 0, 20), and window 30 gets 80(2, 0, 30). This 20 or 30 is the "id" parameter used by script 2.

Then you've got script 2.
Line by line:
- declares a variable
- clears out the special, so that once run, the script won't be triggered again.
- plays a sound at mapspot 20/30
- makes the linedef not blocking anymore
- clears both front and back textures
- sets the variable to a number
- then we've got a delay of one tic to avoid problems with the loop
- and the loop in which we spawn randomly-chosen glass shards at randomly-chosen spots with randomly chosen speeds.

So, script 1 does the initialization needed for Hexen format, and script 2 does the magic.

Share this post


Link to post

by not appearing in game i mean that in the place where the windows should be there is nothing but fresh air. Noting to shoot nothing to block the player, nothing. absolutaly nothing.

Share this post


Link to post

Did you give them SHAWN2, since that's what you want to use, as their midtexture on both front and back sidedefs? That's something you must do in the editor.

Share this post


Link to post

Is there any possibility I could send the wad to someone to have a look at to see if they can work out what the problem is? I have looked and looked and I am out of ideas as to what the problem is. I don't know if it is the acs for the window, the tags and tid for the windows and map point the decorate script for the glass shards or some other miscilanious problem.
The map could also be playtested at the same time as it is practically finished as just some seeable but not reachable details need to be added to it. along with a couple of new sprites and textures in 1 area once I have photoshop up and running again.

Share this post


Link to post

Use this simpler script

SCRIPT 1 (void)
{
Floor_LowerInstant(20,0,128);
thingsound(18, "GlassShatter", 127);
Thing_ProjectileGravity(18, random(54, 63), random(0, 255), random(10, 40), random(5, 20));
}

make a sector and make it the same height as the ceiling.
The lower texture should be glass with character, middle texture should be broken glass, and upper should be weapon glass.

set the glass linedef action to 80 script execute and projectile hits.

Share this post


Link to post
Rycky91 said:

Use this simpler script

No offense, man, but I think they got it. After all, they had 7 years to figure something out between the last post and yours.

Share this post


Link to post
Guest
This topic is now closed to further replies.
×