Texture based puffs and decals?

Ask about ACS, DECORATE, ZScript, or any other scripting questions here!

Moderator: GZDoom 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.

Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
Post Reply
User avatar
::Bloodfury::
Posts: 332
Joined: Mon Aug 01, 2011 7:39 pm
Graphics Processor: nVidia (Modern GZDoom)
Location: Finland

Texture based puffs and decals?

Post by ::Bloodfury:: »

Hi!

So I began to wonder is there a way to achieve texture dependent puffs and particles from attacks hitting
walls. Maybe even ceilings / floors.

To get the idea. If you have say, a sword and you hit a stone textured wall it leaves a decal and also spawns
puff with sparks. But if you would be hitting with that same sword on a wood textured wall it would then
naturally leave a different looking decal and splinters of wood would fly around.

Also the impact sound would be different depending on the surface you are hitting. Stone emits a metallic
clank and wood would naturally have a choppy or thudding sound.

Tried to browse through wiki to find some solution via decaldefs, actor properties and states and such.
But couldn't figure anything out. I do know how to make custom decals, puffs and impact sounds with
weapons etc. But need help to figure out how you could have a surface dependent variables.

Thx in advance from any help or tips. :)
User avatar
Caligari87
Admin
Posts: 6226
Joined: Thu Feb 26, 2004 3:02 pm
Preferred Pronouns: He/Him
Contact:

Re: Texture based puffs and decals?

Post by Caligari87 »

With ZScript this is now possible. You can have your puffs (or your weapon) do a Linetrace to get the impact texture and spawn the appropriate effects. Although keep in mind it would only be checking the texture name so if a mod changed the same texture to something else it may not match.

8-)
User avatar
::Bloodfury::
Posts: 332
Joined: Mon Aug 01, 2011 7:39 pm
Graphics Processor: nVidia (Modern GZDoom)
Location: Finland

Re: Texture based puffs and decals?

Post by ::Bloodfury:: »

Well I'm working on a full TC game. So it is not even intended to use mods on top of it. So that shouldn't be an issue. :D but good to know that a texture mod could cause issues.
Well.. I'll need to get into Zscript then. :) I thank thee very much!
User avatar
kodi
 
 
Posts: 1355
Joined: Mon May 06, 2013 8:02 am

Re: Texture based puffs and decals?

Post by kodi »

I've worked on something like this that I haven't finished yet.

Code: Select all

enum ImpactTypeIDs
{
	GTT_METAL = 1, //done
	GTT_ROCK_BROWN = 2, //done
	GTT_ROCK_GREY = 3, //done
	GTT_LAMP = 4, 
	GTT_GRASS = 5, //sound
	GTT_MARBLE_GREEN = 6,  ///use gray?
	GTT_CERAMIC = 7,
	GTT_PLASTIC = 8,
	GTT_DIRT = 9, //sound
	GTT_GRAVEL_BROWN = 10, 
	GTT_GRAVEL_GREY = 11, //sound
	GTT_SYNTHETIC_BROWN = 12, //sound
	GTT_SYNTHETIC_BLUE = 13, 
	GTT_FLESH = 14,
	GTT_BLOOD = 15,
	GTT_WATER = 16, //done
	GTT_SLIME = 17,
	GTT_LAVA = 18,
	GTT_SYNTHETIC_RED = 19,
	GTT_SYNTHETIC_GREY = 20,
	GTT_FABRIC_TAN = 21,
	GTT_WOOD = 22,
	GTT_ELECTRONIC = 23,
	GTT_GLASS_ARMORED = 24,
	GTT_TELEPORT = 25,
	GTT_NUKAGE = 26,
	GTT_CARTON = 27, //note: make it random grey/tan
	GTT_FIREBLU = 28,//jeez...
	GTT_FIRE = 29,
	GTT_ROCK_RED = 30,
	GTT_DRYWALL = 31
};
Came up with those types after going through all doom 2 textures. May still condense them further. An issue is that what's a nice carpet in one map may be hellish flesh-growth in another :P

Edit: video link
Image
User avatar
::Bloodfury::
Posts: 332
Joined: Mon Aug 01, 2011 7:39 pm
Graphics Processor: nVidia (Modern GZDoom)
Location: Finland

Re: Texture based puffs and decals?

Post by ::Bloodfury:: »

Yes that is exactly what I am after too! ;)
User avatar
::Bloodfury::
Posts: 332
Joined: Mon Aug 01, 2011 7:39 pm
Graphics Processor: nVidia (Modern GZDoom)
Location: Finland

Re: Texture based puffs and decals?

Post by ::Bloodfury:: »

Extremely nice work on those linetrace puffs.

I was wondering, since I am a total beginner with Zscript. Would it be
too much to ask if you could send an example file how you have achieved this.
Just a simple preview (without revealing too much from your own project) for me
to learn and to code my own similiar system. :) A tutorial of sorts. ;D

You will be appropriately credited in my project obviously.
User avatar
kodi
 
 
Posts: 1355
Joined: Mon May 06, 2013 8:02 am

Re: Texture based puffs and decals?

Post by kodi »

I can post a brief outline - the code isn't good enough even for copy-portions of it :P
Not sure how to best retrieve the floor/wall/ceiling when not using Linetrace, but with it you do something like

Code: Select all

FLineTraceData TraceData;
self.LineTrace(self.angle,SomeValue,self.pitch,TRF_THRUHITSCAN,0,0,0.0,TraceData);
if(TraceData.HitType != TraceData.TRACE_HitActor)
{
	name hit_texture_name = TexMan.GetName(TraceData.HitTexture);
	int textype = GetTextureType(hit_texture_name);
	DoTextureEffect(textype);
}
Where "GetTextureType" is a function you'll have to make yourself. There you compare the input, a Name variable, with texture lump names like 'FIREBLU1' in single quotes. Presumably in some kind of array. It should return an effect/material type id number. Then you either call another custom function that does various things depending on the effect type, or you jump states or something instead.
User avatar
::Bloodfury::
Posts: 332
Joined: Mon Aug 01, 2011 7:39 pm
Graphics Processor: nVidia (Modern GZDoom)
Location: Finland

Re: Texture based puffs and decals?

Post by ::Bloodfury:: »

Thank you very much sir. This is a good starting point. :)
ADoomedSpaceMarine
Posts: 3
Joined: Sun Jun 23, 2019 8:35 pm
Graphics Processor: nVidia (Modern GZDoom)

Re: Texture based puffs and decals?

Post by ADoomedSpaceMarine »

kodi wrote:I can post a brief outline - the code isn't good enough even for copy-portions of it :P
Not sure how to best retrieve the floor/wall/ceiling when not using Linetrace, but with it you do something like

Code: Select all

FLineTraceData TraceData;
self.LineTrace(self.angle,SomeValue,self.pitch,TRF_THRUHITSCAN,0,0,0.0,TraceData);
if(TraceData.HitType != TraceData.TRACE_HitActor)
{
	name hit_texture_name = TexMan.GetName(TraceData.HitTexture);
	int textype = GetTextureType(hit_texture_name);
	DoTextureEffect(textype);
}
Where "GetTextureType" is a function you'll have to make yourself. There you compare the input, a Name variable, with texture lump names like 'FIREBLU1' in single quotes. Presumably in some kind of array. It should return an effect/material type id number. Then you either call another custom function that does various things depending on the effect type, or you jump states or something instead.
So, I am going through my C++ sequence in my software engineering degree. Because ZScript behaves so much like C++ this is honestly makes sense and is something I have the knowledge to pull off. Definitely using an array would be easiest, one that once a function sorts through it returns an integer value to a puff/decal spawner function based on the number returned. For acquiring the results more efficiently, perhaps a bubble sort algorithm or at least a binary search where will work twice as fast may be beneficial for performance, especially if the user is firing a lot of rounds.

I was actually thinking about how to implement such a thing in my mod I'm working from the ground up, and was going to attempt texture-based bullet decals and puff. This gives me a really good ground to start on, and an idea of what to do to solve the problem I was presented with how to execute such a thing.
Post Reply

Return to “Scripting”