Destroy "Bulletpuff" on Liquid Terrain?

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!)

Destroy "Bulletpuff" on Liquid Terrain?

Postby Pompous Seed » Sat Nov 03, 2018 4:53 pm

Is there a way to completely avoid spawning any puff actors once a hitscan comes into contact with liquid terrain?
Pompous Seed
 
Joined: 05 Aug 2016

Re: Destroy "Bulletpuff" on Liquid Terrain?

Postby Matt » Sat Nov 03, 2018 11:14 pm

Here's the liquid floor checking code that I think I took from Nash (and apolgies to the actual source if not).
Code: Select allExpand view
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.
User avatar
Matt
Putting the XD into *xdeath since 2007
 
Joined: 04 Jan 2004
Location: Gotham City SAR, Wyld-Lands of the Lotus People, Dominionist PetroConfederacy of Saudi Canadia

Re: Destroy "Bulletpuff" on Liquid Terrain?

Postby Pompous Seed » Sun Nov 04, 2018 4:21 am

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.
Pompous Seed
 
Joined: 05 Aug 2016

Re: Destroy "Bulletpuff" on Liquid Terrain?

Postby Apeirogon » Mon Nov 05, 2018 7:57 am

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
Code: Select allExpand view
class thing
{
    first block of a code here
}

so that gzdoom load it properly.
User avatar
Apeirogon
I have a strange sense of humour
 
Joined: 12 Jun 2017

Re: Destroy "Bulletpuff" on Liquid Terrain?

Postby Matt » Mon Nov 05, 2018 1:17 pm

I think my edits to my post should make it runnable, though I haven't tested it yet.
User avatar
Matt
Putting the XD into *xdeath since 2007
 
Joined: 04 Jan 2004
Location: Gotham City SAR, Wyld-Lands of the Lotus People, Dominionist PetroConfederacy of Saudi Canadia

Re: Destroy "Bulletpuff" on Liquid Terrain?

Postby Pompous Seed » Mon Nov 05, 2018 3:23 pm

Thanks, I wasn't sure what to write at the beginning of that first block of code. However, it throws this error.
Code: Select allExpand view
Script error, "zscript.txt:ZSCRIPT" line 30:
Unexpected '{'
Expecting ';' or ','


I marked line 30 for the sake of convenience. Not sure what the problem is.
Code: Select allExpand view
class BulletSplashless:BulletPuff replaces BulletPuff{
    override void postbeginplay{                             // LINE 30
        if(MiscFunctions.CheckLiquidTexture(self)){
            destroy();
            return;
        }
        super.postbeginplay();
    }
}
Pompous Seed
 
Joined: 05 Aug 2016

Re: Destroy "Bulletpuff" on Liquid Terrain?

Postby Apeirogon » Mon Nov 05, 2018 3:48 pm

Add () between "postbeginplay" and "{"
User avatar
Apeirogon
I have a strange sense of humour
 
Joined: 12 Jun 2017

Re: Destroy "Bulletpuff" on Liquid Terrain?

Postby Pompous Seed » Mon Nov 05, 2018 4:58 pm

Alright, solved that problem. Now there's a couple of other little boogers.
Code: Select allExpand view
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 allExpand view
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;
    }
}
Pompous Seed
 
Joined: 05 Aug 2016

Re: Destroy "Bulletpuff" on Liquid Terrain?

Postby Matt » Mon Nov 05, 2018 8:23 pm

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.
User avatar
Matt
Putting the XD into *xdeath since 2007
 
Joined: 04 Jan 2004
Location: Gotham City SAR, Wyld-Lands of the Lotus People, Dominionist PetroConfederacy of Saudi Canadia

Re: Destroy "Bulletpuff" on Liquid Terrain?

Postby Pompous Seed » Mon Nov 05, 2018 9:54 pm

Darn, it just keeps throwing errors. Here's what it read this time.
Code: Select allExpand view
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'


This is starting to get a little lengthy, so I'll start putting the code in a spoiler.
Spoiler:
Pompous Seed
 
Joined: 05 Aug 2016

Re: Destroy "Bulletpuff" on Liquid Terrain?

Postby Player701 » Tue Nov 06, 2018 6:37 am

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[i]" in line 18 to "MiscFunctions.lq[i]".
User avatar
Player701
 
 
 
Joined: 13 May 2009
Location: Russia
Discord: Player701#8214
Operating System: Windows 10/8.1/8/201x 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: nVidia with Vulkan support

Re: Destroy "Bulletpuff" on Liquid Terrain?

Postby Pompous Seed » Tue Nov 06, 2018 10:26 am

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:
Pompous Seed
 
Joined: 05 Aug 2016

Re: Destroy "Bulletpuff" on Liquid Terrain?

Postby Mikk- » Tue Nov 06, 2018 10:38 am

You need to check if the puff is actually hitting the ground
User avatar
Mikk-
yooooooooooo
 
Joined: 30 Jun 2009
Location: Somewhere off Kanagawa
Discord: Mikk0451#3922

Re: Destroy "Bulletpuff" on Liquid Terrain?

Postby Matt » Tue Nov 06, 2018 11:32 am

Mikk- wrote:You need to check if the puff is actually hitting the ground

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.

(didn't touch the thing about the member class problem though, and I agree with Player701 that this looks like a GZDoom bug)
User avatar
Matt
Putting the XD into *xdeath since 2007
 
Joined: 04 Jan 2004
Location: Gotham City SAR, Wyld-Lands of the Lotus People, Dominionist PetroConfederacy of Saudi Canadia

Re: Destroy "Bulletpuff" on Liquid Terrain?

Postby Pompous Seed » Tue Nov 06, 2018 12:35 pm

Yes! That works perfectly! Thanks for all your help, folks!
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.

The puff actors would actually still occasionally spawn even after your edit. But I believe I fixed it by replacing the 4 with 8.

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:
Pompous Seed
 
Joined: 05 Aug 2016


Return to Scripting

Who is online

Users browsing this forum: No registered users and 0 guests