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.
Custom Sprite #9988
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.
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.
-
- Posts: 78
- Joined: Tue Jul 20, 2004 7:56 pm
- Graphics Processor: nVidia with Vulkan support
Custom Sprite #9988
- Attachments
-
- BITL Test Map.wad
- (21.25 KiB) Downloaded 45 times
Re: Custom Sprite #9988
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:
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:
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:
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.
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;
}
}
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;
}
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;
}
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.