Port of DaZombieKiller's Footsteps in ZScript

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!)
Locked
User avatar
vsonnier
Posts: 80
Joined: Wed Apr 10, 2019 11:22 pm
Graphics Processor: nVidia with Vulkan support
Contact:

Port of DaZombieKiller's Footsteps in ZScript

Post by vsonnier »

Hello,
This is pretty much the title : I want to call make the equivalent of what do CheckActorFloorTexture in ACS, but in Zscript. Or a way to call the ACS form in ZScript

Thank you for your help.

Edit: Changed title, was : "How to CheckActorFloorTexture in Zscript ?" because I really wanted to have DaZombieKiller's Footsteps in Zscript. I managed to to so thanks to Graf advice, see the posts below for the solution.
Last edited by vsonnier on Sun Jun 23, 2019 10:16 pm, edited 1 time in total.
User avatar
Void Weaver
Posts: 724
Joined: Thu Dec 18, 2014 7:15 am
Contact:

Re: How to CheckActorFloorTexture in ZScript ?

Post by Void Weaver »

What about calling LineTrace with vector to floor and check for "HitTexture"?
User avatar
vsonnier
Posts: 80
Joined: Wed Apr 10, 2019 11:22 pm
Graphics Processor: nVidia with Vulkan support
Contact:

Re: How to CheckActorFloorTexture in ZScript ?

Post by vsonnier »

What about calling LineTrace with vector to floor and check for "HitTexture"?
Thanks, I'll give it a try !
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49067
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: How to CheckActorFloorTexture in ZScript ?

Post by Graf Zahl »

For most cases the actor's 'floorpic' member variable should do, but it's not 100% portal safe.

If that is not enough, the function to look for is Sector.NextLowestFloorAt. This is what ACS calls internally here.
No need for those awful hacks that were suggested.
User avatar
vsonnier
Posts: 80
Joined: Wed Apr 10, 2019 11:22 pm
Graphics Processor: nVidia with Vulkan support
Contact:

Re: How to CheckActorFloorTexture in ZScript ?

Post by vsonnier »

Thanks Graf, I'll try the 'floorpic' to see where it goes.
User avatar
vsonnier
Posts: 80
Joined: Wed Apr 10, 2019 11:22 pm
Graphics Processor: nVidia with Vulkan support
Contact:

Re: How to CheckActorFloorTexture in ZScript ?

Post by vsonnier »

Turns out `floorpic` do not work in a lot of cases.
If that is not enough, the function to look for is Sector.NextLowestFloorAt. This is what ACS calls internally here.
I gathered that much, and tried to emulate the ACS function before with the following code:

Code: Select all

Vector2 pos2d = (self.pos.x, self.pos.y);
           
                Sector footstep_Sector = Level.PointInSector(pos2d);
                Sector resSector;
                F3DFloor resFloor;
                double resDistance;
                textureid  floor_tx_id;
                    
                [resDistance, resSector, resFloor] = footstep_Sector.NextLowestFloorAt(self.pos.x, self.pos.y, self.pos.z, 0, self.floorz);
                
                if (resFloor) {
                    floor_tx_id = resFloor.top.texture; // Do not compile,  How to access top.texture like in p_acs.cpp (4505) ?
                }
                else {
                    floor_tx_id = resSector.planes.floor.texture;  // Idem, how to accesses planes.floor.texture like in p_acs.cpp (4505) ?
                }
I may be dumb but didn't found the right syntax to access neither Sector nor F3DFloor to gain the textureid.
User avatar
vsonnier
Posts: 80
Joined: Wed Apr 10, 2019 11:22 pm
Graphics Processor: nVidia with Vulkan support
Contact:

Re: How to CheckActorFloorTexture in ZScript ?

Post by vsonnier »

For most cases the actor's 'floorpic' member variable should do, but it's not 100% portal safe.
Nevermind, it was my mistake it indeed works :)
User avatar
vsonnier
Posts: 80
Joined: Wed Apr 10, 2019 11:22 pm
Graphics Processor: nVidia with Vulkan support
Contact:

Re: How to CheckActorFloorTexture in ZScript ?

Post by vsonnier »

I was asking the question about CheckActorFloorTexture in Zscript because I wanted initially to re-compile/modify DaZombieKiller Footsteps: https://github.com/DaZombieKiller/zk-resources
However, i never managed to to it properly with the latest GDCC 0.16.1 so I wanted an equivalent in ZScript. The reason DaZombieKiller Footsteps are using GDCC instead of "simple" ACS is to be able to call C strtok-like functions in order to parse the configuration and associate textures <==> sounds.
In Zscript however it is easier using String.Split and other string manipulation functions.

So the only remaining problem was to find an equivalent to CheckActorFloorTexture, or rather finding the texture the player was stepping in in Zscript.

Here it is finally, in full Zscript using `floorpic` as Graf suggested. The script parses the same configuration data as DaZombieKiller Footsteps in LANGUAGE and SOUNDINFO.
Attachments
Footsteps.txt
Port of DaZombieKiller footsteps in Zscript.
(4.56 KiB) Downloaded 48 times
User avatar
Cherno
Posts: 1311
Joined: Tue Dec 06, 2016 11:25 am

Re: How to CheckActorFloorTexture in ZScript ?

Post by Cherno »

vsonnier wrote:I was asking the question about CheckActorFloorTexture in Zscript because I wanted initially to re-compile/modify DaZombieKiller Footsteps: https://github.com/DaZombieKiller/zk-resources
However, i never managed to to it properly with the latest GDCC 0.16.1 so I wanted an equivalent in ZScript. The reason DaZombieKiller Footsteps are using GDCC instead of "simple" ACS is to be able to call C strtok-like functions in order to parse the configuration and associate textures <==> sounds.
In Zscript however it is easier using String.Split and other string manipulation functions.

So the only remaining problem was to find an equivalent to CheckActorFloorTexture, or rather finding the texture the player was stepping in in Zscript.

Here it is finally, in full Zscript using `floorpic` as Graf suggested. The script parses the same configuration data as DaZombieKiller Footsteps in LANGUAGE and SOUNDINFO.
This is great! Thank you very much. It always bugged me that the ACS footsteps had a rather long delay that didn't seem to fit the player speed. Now with the conversion to zScript, I can finally modify it to my tastes, although the default footstep sound delay seems already perfect! :wub:

I think you should create a new thread for this in the resources forum so more people see it 8-)

If anyone reads this and wonders how to use it, just add this to your Playerclass:

Code: Select all


Footsteps fsteps;

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

		Actor fstepsActor = Spawn("Footsteps",pos);
		if(fstepsActor != null)
		{
			fsteps = Footsteps(fstepsActor);
			fsteps.Init(self);
		}
	}
User avatar
vsonnier
Posts: 80
Joined: Wed Apr 10, 2019 11:22 pm
Graphics Processor: nVidia with Vulkan support
Contact:

Re: How to CheckActorFloorTexture in ZScript ?

Post by vsonnier »

For usage, what Cherno said :)

Here is a new version v2 :
- tuned so that step speed is more similar to DaZoombieKiller's, at least to my ears.
- Used Find() for array<> search for faster and more compact code.

You can notice that I dropped the `fs_enabled` CVAR because I didn't use it so don't forget to re-add it if you want to use it in your code.
Attachments
Footsteps2.txt
Port of DaZombieKiller's Footsteps in Zscript, version 2
(4.37 KiB) Downloaded 42 times
User avatar
vsonnier
Posts: 80
Joined: Wed Apr 10, 2019 11:22 pm
Graphics Processor: nVidia with Vulkan support
Contact:

Re: How to CheckActorFloorTexture in ZScript ?

Post by vsonnier »

I think you should create a new thread for this in the resources forum so more people see it 8-)
Well, this my first attempt at Zscript so I wouldn't want to show an exemple of bad practices.
User avatar
vsonnier
Posts: 80
Joined: Wed Apr 10, 2019 11:22 pm
Graphics Processor: nVidia with Vulkan support
Contact:

Re: Port of DaZombieKiller's Footsteps in ZScript

Post by vsonnier »

Changed the title for more visibility.

Summary:
This is a port of DAZombieKiller's Footsteps code in Zscript: https://github.com/DaZombieKiller/zk-resources.
It uses the same structure as the original in configuration and resources: CVARINFO, LANGUAGE, MENUDEF, SNDINFO + sounds/foutsteps...etc but the code itself is pure Zscript and do not use the GDCC compiler for an ACS/C hybrid.

Especially, REMOVE DAZombieKiller module from the list in LOADACS or you will get twice the footsteps effects :)

Changes in v3:
- re-added `fs_enabled` in Zscript
Attachments
Footsteps3.txt
Port of DaZombieKiller's Footsteps in Zscript, v3
(4.46 KiB) Downloaded 48 times
Blue Shadow
Posts: 4949
Joined: Sun Nov 14, 2010 12:59 am

Re: Port of DaZombieKiller's Footsteps in ZScript

Post by Blue Shadow »

In the future, please do not repurpose threads. You want to share something with people to use? We've got a resources forum just for that.
User avatar
Kinsie
Posts: 7399
Joined: Fri Oct 22, 2004 9:22 am
Graphics Processor: nVidia with Vulkan support
Location: MAP33
Contact:

Re: Port of DaZombieKiller's Footsteps in ZScript

Post by Kinsie »

Thanks for this, I've been looking for exactly this for a while now.

It should definitely be posted in the resources forum for added visibility, too.
User avatar
vsonnier
Posts: 80
Joined: Wed Apr 10, 2019 11:22 pm
Graphics Processor: nVidia with Vulkan support
Contact:

Re: Port of DaZombieKiller's Footsteps in ZScript

Post by vsonnier »

It should definitely be posted in the resources forum for added visibility, too.
Indeed. As suggested bu Blue Shadow, I've cross-posted there: viewtopic.php?f=105&t=65173. Sorry for the duplicates.
Locked

Return to “Scripting”