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

Breakable glass in UDMF

Recommended Posts

I'm trying to make breakable glass, trying to use the line action special #49 but it doesn't work, can anyone give me step by step direction to make breakable glass work in ZDoom(UDMF) format? Also I'm using Doombuilder 2.

Share this post

Link to post

I tried this, you need to have your line settings set to "impassible" and action settings set to "when projectile crosses". I tried it in Skulltag and it worked but no glass shards were spawned I'm thinking there is no decorate defined/missing sprites so make sure those resources are available.

Share this post

Link to post


"Normally you should set the line's activation type to projectile hits and the flags to impassible."

For the hardcoded GlassJunk actors to successfully spawn, you need to provide SHARD0, SHARE0 and SHARF0 sprites. You can get them from the Strife teaser demo if you want.

For the "glass break" sound to play, you need to have it set as the switch sound for your glass texture in ANIMDEFS.

Share this post

Link to post

Gez: what you linked is the Hexen glass break special isn't it? That description does not sound anything like the Strife special. It only spawns 3-4 glass objects IIRC.

Share this post

Link to post

There's no dedicated Hexen glass break effect; in the Raven game it's all handled by ACS.

The function is indeed from Strife. If there's differences with what you got from your reverse engineering, then either Randy made a mistake or thought it would be better this way.

// GlassBreak (bNoJunk)
	bool switched;
	bool quest1, quest2;

	switched = P_ChangeSwitchTexture (ln->sidedef[0], false, 0, &quest1);
	ln->special = 0;
	if (ln->sidedef[1] != NULL)
		switched |= P_ChangeSwitchTexture (ln->sidedef[1], false, 0, &quest2);
		quest2 = quest1;
	if (switched)
		if (!arg0)
		{ // Break some glass
			fixed_t x, y;
			AActor *glass;
			angle_t an;
			int speed;

			x = ln->v1->x + ln->dx/2;
			y = ln->v1->y + ln->dy/2;
			x += (ln->frontsector->soundorg[0] - x) / 5;
			y += (ln->frontsector->soundorg[1] - y) / 5;

			for (int i = 0; i < 7; ++i)
				glass = Spawn("GlassJunk", x, y, ONFLOORZ, ALLOW_REPLACE);

				glass->z += 24 * FRACUNIT;
				glass->SetState (glass->SpawnState + (pr_glass() % glass->health));
				an = pr_glass() << (32-8);
				glass->angle = an;
				speed = pr_glass() & 3;
				glass->velx = finecosine[an] * speed;
				glass->vely = finesine[an] * speed;
				glass->velz = (pr_glass() & 7) << FRACBITS;
				// [RH] Let the shards stick around longer than they did in Strife.
				glass->tics += pr_glass();
		if (quest1 || quest2)
		{ // Up stats and signal this mission is complete
			if (it == NULL)
				for (int i = 0; i < MAXPLAYERS; ++i)
					if (playeringame[i])
						it = players[i].mo;
			if (it != NULL)
				it->GiveInventoryType (QuestItemClasses[28]);
				it->GiveInventoryType (RUNTIME_CLASS(AUpgradeAccuracy));
				it->GiveInventoryType (RUNTIME_CLASS(AUpgradeStamina));
	// We already changed the switch texture, so don't make the main code switch it back.
	return false;

Share this post

Link to post

Yeah I'm still not quite understanding how to do it in UDMF and I downloaded strife and I've got the sprites, but tel me more about the switch sound? How do I implement that using XWE and would that replace the sound for all the switches in the game?

Share this post

Link to post

Gez: Yeah you were right, just bad memory on my part.

This is the "original" code (from Chocolate Strife, but as you know our goal was to be as high-fidelity as possible):

// P_SpawnBrokenGlass
// villsa [STRIFE] new function
static void P_SpawnBrokenGlass(line_t* line)
    fixed_t x1;
    fixed_t x2;
    fixed_t y1;
    fixed_t y2;
    int i;
    mobj_t* glass;
    angle_t an;

    x1 = (line->v2->x + line->v1->x) / 2;
    y1 = (line->v2->y + line->v1->y) / 2;
    x2 = ((line->frontsector->soundorg.x - x1) / 5) + x1;
    y2 = ((line->frontsector->soundorg.y - y1) / 5) + y1;

    for(i = 0; i < 7; i++)
        glass = P_SpawnMobj(x2, y2, ONFLOORZ, MT_JUNK);
        glass->z += (24*FRACUNIT);
        glass->flags |= (MF_SHADOW|MF_MVIS);

        P_SetMobjState(glass, P_Random() % 3 + S_SHRD_03); // 284

        an = ((P_Random() << 13) / 255);

        glass->angle = (an << ANGLETOFINESHIFT);
        glass->momx = FixedMul(finecosine[an], (P_Random() & 3) << FRACBITS);
        glass->momy = FixedMul(finesine[an],   (P_Random() & 3) << FRACBITS);
        glass->momz = (P_Random() & 7) << FRACBITS;
        glass->tics += (P_Random() + 7) & 7;

Share this post

Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now