Custom Sprite #9988

Ask about editing graphics, sounds, models, music, etc here!
Shaders (GLSL) and SNDINFO questions also go here!

Moderators: GZDoom Developers, Raze Developers

Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.
Post Reply
Evil Space Tomato
Posts: 78
Joined: Tue Jul 20, 2004 7:56 pm
Graphics Processor: nVidia with Vulkan support

Custom Sprite #9988

Post by Evil Space Tomato »

I was looking into the CustomSprite object #9988 and I was not able to get it to display sprites.
I put the png image BTIL0000 and BTIL0001 between a TX_START and TX_END and then created a simple test map, but it does not show up.
I could not find a tutorial on how to do this or an example map anywhere.
Attachments
BITL Test Map.wad
(21.25 KiB) Downloaded 45 times
Gez
 
 
Posts: 17835
Joined: Fri Jul 06, 2007 3:22 pm

Re: Custom Sprite #9988

Post by Gez »

Using the "actorlist" console command on the test map, it only gives me DoomPlayer, so the customsprite object disappeared.

Then I looked at the ZScript code for it:

Code: Select all

// Needed for loading Build maps -------------------------------------------

class CustomSprite : Actor
{
	Default
	{
		+NOBLOCKMAP
		+NOGRAVITY
	}
	States
	{
	Spawn:
		TNT1 A -1;
		Stop;
	}
	
	override void BeginPlay ()
	{
		Super.BeginPlay ();

		String name = String.Format("BTIL%04d", args[0] & 0xffff);
		picnum = TexMan.CheckForTexture (name, TexMan.TYPE_Build);
		if (!picnum.Exists())
		{
			Destroy();
			return;
		}

		Scale.X = args[2] / 64.;
		Scale.Y = args[3] / 64.;

		int cstat = args[4];
		if (cstat & 2)
		{
			A_SetRenderStyle((cstat & 512) ? 0.6666 : 0.3333, STYLE_Translucent);
		}
		if (cstat & 4) bXFlip = true;
		if (cstat & 8) bYFlip = true;
		if (cstat & 16) bWallSprite = true;
		if (cstat & 32) bFlatSprite = true;
	}
}
It seems that it destroys itself if it doesn't find its texture.

So I just edited gzdoom.pk3 a bit to test this, adding an A_Log call when the customsprite is destroyed:

Code: Select all

	override void BeginPlay ()
	{
		Super.BeginPlay ();

		String name = String.Format("BTIL%04d", args[0] & 0xffff);
		picnum = TexMan.CheckForTexture (name, TexMan.TYPE_Build);
		if (!picnum.Exists())
		{
			A_Log(TEXTCOLOR_RED .. "Build tile " .. name .. " not found!\n");
			Destroy();
			return;
		}

		Scale.X = args[2] / 64.;
		Scale.Y = args[3] / 64.;

		int cstat = args[4];
		if (cstat & 2)
		{
			A_SetRenderStyle((cstat & 512) ? 0.6666 : 0.3333, STYLE_Translucent);
		}
		if (cstat & 4) bXFlip = true;
		if (cstat & 8) bYFlip = true;
		if (cstat & 16) bWallSprite = true;
		if (cstat & 32) bFlatSprite = true;
	}
And yes, I get that message on your test map (along with some missing textures). So I wondered if it was because they weren't actually in Build tiles. So just to be sure, I did this:

Code: Select all

	override void BeginPlay ()
	{
		Super.BeginPlay ();

		String name = String.Format("BTIL%04d", args[0] & 0xffff);
		picnum = TexMan.CheckForTexture (name, TexMan.TYPE_Build);
		if (!picnum.Exists())
		{
			A_Log(TEXTCOLOR_RED .. "Looking elsewhere for ".. name .. "!\n");
			picnum = TexMan.CheckForTexture (name, TexMan.TYPE_Any);
		}
		if (!picnum.Exists())
		{
			A_Log(TEXTCOLOR_RED .. "Build tile " .. name .. " not found!\n");
			Destroy();
			return;
		}

		Scale.X = args[2] / 64.;
		Scale.Y = args[3] / 64.;

		int cstat = args[4];
		if (cstat & 2)
		{
			A_SetRenderStyle((cstat & 512) ? 0.6666 : 0.3333, STYLE_Translucent);
		}
		if (cstat & 4) bXFlip = true;
		if (cstat & 8) bYFlip = true;
		if (cstat & 16) bWallSprite = true;
		if (cstat & 32) bFlatSprite = true;
	}
But the result was that I got both error messages: it didn't find them in Build tiles, but it also didn't find them when looking for any type of graphics... And that's where I noticed that your textures are actually named BITL0000 and BITL0001 instead of BTIL0000 and BTIL0001.

After renaming the lumps, it works without showing any error message, meaning that the vanilla code would work too, no need for my workaround. However, you'll probably want to give your custom sprite graphics some offsets. They're sprites, not textures. In-game, I only saw a little bit from the top, which was to the right of the actor, and if the actor wasn't on a tiny raised platform, the custom sprite graphic would be entirely clipped by the ground.
Post Reply

Return to “Assets (and other stuff)”