Port of DaZombieKiller's Footsteps in ZScript
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!)
- 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
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.
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.
- Void Weaver
- Posts: 724
- Joined: Thu Dec 18, 2014 7:15 am
- Contact:
Re: How to CheckActorFloorTexture in ZScript ?
What about calling LineTrace with vector to floor and check for "HitTexture"?
- vsonnier
- Posts: 80
- Joined: Wed Apr 10, 2019 11:22 pm
- Graphics Processor: nVidia with Vulkan support
- Contact:
Re: How to CheckActorFloorTexture in ZScript ?
Thanks, I'll give it a try !What about calling LineTrace with vector to floor and check for "HitTexture"?
- Graf Zahl
- Lead GZDoom+Raze Developer
- Posts: 49067
- Joined: Sat Jul 19, 2003 10:19 am
- Location: Germany
Re: How to CheckActorFloorTexture in ZScript ?
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.
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.
- vsonnier
- Posts: 80
- Joined: Wed Apr 10, 2019 11:22 pm
- Graphics Processor: nVidia with Vulkan support
- Contact:
Re: How to CheckActorFloorTexture in ZScript ?
Thanks Graf, I'll try the 'floorpic' to see where it goes.
- vsonnier
- Posts: 80
- Joined: Wed Apr 10, 2019 11:22 pm
- Graphics Processor: nVidia with Vulkan support
- Contact:
Re: How to CheckActorFloorTexture in ZScript ?
Turns out `floorpic` do not work in a lot of cases.
I may be dumb but didn't found the right syntax to access neither Sector nor F3DFloor to gain the textureid.
I gathered that much, and tried to emulate the ACS function before with the following code:If that is not enough, the function to look for is Sector.NextLowestFloorAt. This is what ACS calls internally here.
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) ?
}
- vsonnier
- Posts: 80
- Joined: Wed Apr 10, 2019 11:22 pm
- Graphics Processor: nVidia with Vulkan support
- Contact:
Re: How to CheckActorFloorTexture in ZScript ?
Nevermind, it was my mistake it indeed worksFor most cases the actor's 'floorpic' member variable should do, but it's not 100% portal safe.
- vsonnier
- Posts: 80
- Joined: Wed Apr 10, 2019 11:22 pm
- Graphics Processor: nVidia with Vulkan support
- Contact:
Re: How to CheckActorFloorTexture in ZScript ?
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.
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
Re: How to CheckActorFloorTexture in ZScript ?
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!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.
I think you should create a new thread for this in the resources forum so more people see it
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);
}
}
- vsonnier
- Posts: 80
- Joined: Wed Apr 10, 2019 11:22 pm
- Graphics Processor: nVidia with Vulkan support
- Contact:
Re: How to CheckActorFloorTexture in ZScript ?
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.
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
- vsonnier
- Posts: 80
- Joined: Wed Apr 10, 2019 11:22 pm
- Graphics Processor: nVidia with Vulkan support
- Contact:
Re: How to CheckActorFloorTexture in ZScript ?
Well, this my first attempt at Zscript so I wouldn't want to show an exemple of bad practices.I think you should create a new thread for this in the resources forum so more people see it
- 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
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
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
-
- Posts: 4949
- Joined: Sun Nov 14, 2010 12:59 am
Re: Port of DaZombieKiller's Footsteps in ZScript
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.
- 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
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.
It should definitely be posted in the resources forum for added visibility, too.
- 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
Indeed. As suggested bu Blue Shadow, I've cross-posted there: viewtopic.php?f=105&t=65173. Sorry for the duplicates.It should definitely be posted in the resources forum for added visibility, too.