Destroy "Bulletpuff" on Liquid Terrain?
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!)
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!)
Destroy "Bulletpuff" on Liquid Terrain?
Is there a way to completely avoid spawning any puff actors once a hitscan comes into contact with liquid terrain?
- Matt
- Posts: 9696
- Joined: Sun Jan 04, 2004 5:37 pm
- Preferred Pronouns: They/Them
- Operating System Version (Optional): Debian Bullseye
- Location: Gotham City SAR, Wyld-Lands of the Lotus People, Dominionist PetroConfederacy of Saudi Canadia
- Contact:
Re: Destroy "Bulletpuff" on Liquid Terrain?
Here's the liquid floor checking code that I think I took from Nash (and apolgies to the actual source if not).
Code: Select all
version "3.6"
struct MiscFunctions play{
//seeing if you're standing on a liquid texture
static const string lq[]={
"MFLR8_4","MFLR8_2", //I think some of these are snake floors or sand
"SFLR6_1","SFLR6_4", //or something - the original code is for putting out fires
"SFLR7_1","SFLR7_4", //please delete as appropriate
"FWATER1","FWATER2","FWATER3","FWATER4",
"BLOOD1","BLOOD2","BLOOD3",
"SLIME1","SLIME2","SLIME3","SLIME4",
"SLIME5","SLIME6","SLIME7","SLIME8"
};
static bool CheckLiquidTexture(actor caller){
int lqlength=lq.size();
let fp=caller.floorpic;
for(int i=0;i<lqlength;i++){
TextureID tx=TexMan.CheckForTexture(lq[i],TexMan.Type_Flat);
if (tx&&fp==tx){
return true;
}
}
return false;
}
}
//Then you can put something like:
class BulletSplashless:BulletPuff replaces BulletPuff{
override void postbeginplay{
if(MiscFunctions.CheckLiquidTexture(self)&&pos.z-floorz<4){
destroy();
return;
}
super.postbeginplay();
}
}
Last edited by Matt on Tue Nov 06, 2018 11:32 am, edited 5 times in total.
Re: Destroy "Bulletpuff" on Liquid Terrain?
Sorry to be a bother, but would you mind fixing this up into something that's functional? I can make things work if I at least have an example of how to put this to use. I tried putting it together, but the zscript format is just something I'm not accustomed to.
Re: Destroy "Bulletpuff" on Liquid Terrain?
Create file with name zscript, put in in the root of the pack and copy paste in it both code block.
But you must put first one in definition of some class.
Like
so that gzdoom load it properly.
But you must put first one in definition of some class.
Like
Code: Select all
class thing
{
first block of a code here
}
- Matt
- Posts: 9696
- Joined: Sun Jan 04, 2004 5:37 pm
- Preferred Pronouns: They/Them
- Operating System Version (Optional): Debian Bullseye
- Location: Gotham City SAR, Wyld-Lands of the Lotus People, Dominionist PetroConfederacy of Saudi Canadia
- Contact:
Re: Destroy "Bulletpuff" on Liquid Terrain?
I think my edits to my post should make it runnable, though I haven't tested it yet.
Re: Destroy "Bulletpuff" on Liquid Terrain?
Thanks, I wasn't sure what to write at the beginning of that first block of code. However, it throws this error.
I marked line 30 for the sake of convenience. Not sure what the problem is.
Code: Select all
Script error, "zscript.txt:ZSCRIPT" line 30:
Unexpected '{'
Expecting ';' or ','
Code: Select all
class BulletSplashless:BulletPuff replaces BulletPuff{
override void postbeginplay{ // LINE 30
if(MiscFunctions.CheckLiquidTexture(self)){
destroy();
return;
}
super.postbeginplay();
}
}
Re: Destroy "Bulletpuff" on Liquid Terrain?
Add () between "postbeginplay" and "{"
Re: Destroy "Bulletpuff" on Liquid Terrain?
Alright, solved that problem. Now there's a couple of other little boogers.
Code: Select all
Script error, "zscript.txt:ZSCRIPT" line 15:
self used outside of a member function
Script error, "zscript.txt:ZSCRIPT" line 17:
Unknown identifier 'lqlength'
Code: Select all
struct MiscFunctions play{
//seeing if you're standing on a liquid texture
static const string lq[]={
"MFLR8_4","MFLR8_2", //I think some of these are snake floors or sand
"SFLR6_1","SFLR6_4", //or something - the original code is for putting out fires
"SFLR7_1","SFLR7_4", //please delete as appropriate
"FWATER1","FWATER2","FWATER3","FWATER4",
"BLOOD1","BLOOD2","BLOOD3",
"SLIME1","SLIME2","SLIME3","SLIME4",
"SLIME5","SLIME6","SLIME7","SLIME8"
};
static bool CheckLiquidTexture(actor caller){
int lqlength=lq.size(); // LINE 15
let fp=caller.floorpic;
for(int i=0;i<lqlength;i++){ // LINE 17
TextureID tx=TexMan.CheckForTexture(lq[i],TexMan.Type_Flat);
if (tx&&fp==tx){
return true;
}
}
return false;
}
}
- Matt
- Posts: 9696
- Joined: Sun Jan 04, 2004 5:37 pm
- Preferred Pronouns: They/Them
- Operating System Version (Optional): Debian Bullseye
- Location: Gotham City SAR, Wyld-Lands of the Lotus People, Dominionist PetroConfederacy of Saudi Canadia
- Contact:
Re: Destroy "Bulletpuff" on Liquid Terrain?
Possibly try replacing lq.size() with MiscFunctions.lq.size()?
I don't see why that would be required but it's the only thing I can imagine being wrong.
I don't see why that would be required but it's the only thing I can imagine being wrong.
Re: Destroy "Bulletpuff" on Liquid Terrain?
Darn, it just keeps throwing errors. Here's what it read this time.
This is starting to get a little lengthy, so I'll start putting the code in a spoiler.
Code: Select all
Script error, "zscript.txt:ZSCRIPT" line 18:
self used outside of a member function
Script error, "zscript.txt:ZSCRIPT" line 19:
Unknown identifier 'tx'
Script error, "zscript.txt:ZSCRIPT" line 19:
Unknown identifier 'tx'
Spoiler:
- Player701
-
- Posts: 1632
- Joined: Wed May 13, 2009 3:15 am
- Graphics Processor: nVidia with Vulkan support
- Contact:
Re: Destroy "Bulletpuff" on Liquid Terrain?
This looks like a bug to me, since lq is declared within the same type it is used from. I've filed a bug report. Your code can be fixed by changing "lq" in line 18 to "MiscFunctions.lq".
Re: Destroy "Bulletpuff" on Liquid Terrain?
Thank you, it finally works now. Only one problem remains. The puff actors don't spawn on liquid terrain as expected, but if a hitscan travels above a liquid texture, the puff actor doesn't spawn on any walls that are connected to sectors with liquid textures defined. Here are some screenshots to demonstrate the problem.
Spoiler:
Re: Destroy "Bulletpuff" on Liquid Terrain?
You need to check if the puff is actually hitting the ground
- Matt
- Posts: 9696
- Joined: Sun Jan 04, 2004 5:37 pm
- Preferred Pronouns: They/Them
- Operating System Version (Optional): Debian Bullseye
- Location: Gotham City SAR, Wyld-Lands of the Lotus People, Dominionist PetroConfederacy of Saudi Canadia
- Contact:
Re: Destroy "Bulletpuff" on Liquid Terrain?
Edited again. The 4 is because I think puffs spawn just a little behind their impact point and I don't know off the top of my head how much that would affect this.Mikk- wrote:You need to check if the puff is actually hitting the ground
(didn't touch the thing about the member class problem though, and I agree with Player701 that this looks like a GZDoom bug)
Re: Destroy "Bulletpuff" on Liquid Terrain?
Yes! That works perfectly! Thanks for all your help, folks!
I'm going to post the resulting code I'm using just in case any curious browsers want to take it for a spin.
The puff actors would actually still occasionally spawn even after your edit. But I believe I fixed it by replacing the 4 with 8.Matt wrote:The 4 is because I think puffs spawn just a little behind their impact point and I don't know off the top of my head how much that would affect this.
I'm going to post the resulting code I'm using just in case any curious browsers want to take it for a spin.
Spoiler: