[ZScript] Port of DaZombieKiller's footsteps

Post your example zscripts/ACS scripts/etc here.
Forum rules
The Projects forums are only for projects. If you are asking questions about a project, either find that project's thread, or start a thread in the General section instead.

Got a cool project idea but nothing else? Put it in the project ideas thread instead!

Projects for any Doom-based engine (especially 3DGE) are perfectly acceptable here too.

Please read the full rules for more details.
User avatar
vsonnier
Posts: 80
Joined: Wed Apr 10, 2019 11:22 pm
Graphics Processor: nVidia with Vulkan support
Contact:

[ZScript] Port of DaZombieKiller's footsteps

Post by vsonnier »

This is a port of DAZombieKiller's Footsteps code in pure Zscript, see here for the original: https://github.com/DaZombieKiller/zk-resources ,or here for it's discussion: viewtopic.php?f=105&t=35388

It uses the same structure as the original for 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.

I wanted initially to re-compile/modify DaZombieKiller Footsteps but never managed to to it properly with the latest GDCC 0.16.1 so I wanted an equivalent in ZScript. The reason DaZombieKiller Footsteps is using GDCC instead of a "simple" ACS compiler is to be able to call C strtok-like functions 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 ACS CheckActorFloorTexture, or rather finding the texture the player was stepping in, in Zscript.

Graf suggested using checking Actor's`floorpic` and it works, so here it is !

The script parses the same configuration data as DaZombieKiller Footsteps and uses the same resource files structure as his, so can be used as a replacement of it's ACS module while keeping the rest of the structure.
Except REMOVE the module from the LOADACS list or you will get twice the footsteps effects :)

(The initial discussion is here : viewtopic.php?f=122&t=65137. I should have started that topic direclty here but it"s too late now so this present topic is essentially a cross-post suggested by the moderators. I won't do that again, promise.)
Attachments
Footsteps3.txt
Port of ZombieKiller's footsteps in Zscript, v3
(4.46 KiB) Downloaded 877 times
User avatar
Kinsie
Posts: 7399
Joined: Fri Oct 22, 2004 9:22 am
Graphics Processor: nVidia with Vulkan support
Location: MAP33
Contact:

Re: [ZScript] Port of DaZombieKiller's footsteps

Post by Kinsie »

This is great! Transitioned MetaDoom from the old ACS script to this yesterday. Thanks so much for doing this!
User avatar
vsonnier
Posts: 80
Joined: Wed Apr 10, 2019 11:22 pm
Graphics Processor: nVidia with Vulkan support
Contact:

Re: [ZScript] Port of DaZombieKiller's footsteps

Post by vsonnier »

This is great! Transitioned MetaDoom from the old ACS script to this yesterday. Thanks so much for doing this!
You are welcome :) However, Graf said that Actor's `floorpic` is "not 100% portal-safe" whatever that meant. It worked well enough for me.

Another advantage I didn't mention is that the Zscript version should be quite faster than the ACS one: The configuration is parsed only once, not each time a sound is to be played. Plus, the search for the right texture is only a linear array<int>::Find() among ids, while the ACS checked every single parsed texture by CheckActorFloorTexture until it returned true. And from what I see in GZDoom code, CheckActorFloorTexture is not cheap, checking geometry and such.
User avatar
The Zombie Killer
Posts: 1528
Joined: Thu Jul 14, 2011 12:06 am
Location: Gold Coast, Queensland, Australia

Re: [ZScript] Port of DaZombieKiller's footsteps

Post by The Zombie Killer »

Just for reference, I had already ported the footsteps code to ZScript a while ago, which is available here. I just neglected to post about it on the forums. This version is different to the original though, it uses a custom lump rather than dealing with the LANGUAGE lump. EDIT: It should also be noted that my version is a bit less "plug and play" than this one, so if you're looking for something that you can just drop into your project, you'll most likely want to go with the version in this thread instead of the one I just linked.
fcas3t
Posts: 43
Joined: Sun Nov 29, 2020 6:46 pm

Re: [ZScript] Port of DaZombieKiller's footsteps

Post by fcas3t »

Attached is my refactor of this code, which I did as part of my personal fork of EVP.

Note that one comment mentions AutoWalking, which is provided by my AutoMove mod. You don't need this mod to use my Footsteps code.

(For EVP users, I retained only one CVar, but it's named differently than regular EVP. So this is not a drop-in for EVP, but can easily be modified to work with regular EVP.)
Attachments
Footsteps_evp.txt
(2.79 KiB) Downloaded 102 times
User avatar
Hidden Hands
Posts: 1053
Joined: Tue Sep 20, 2016 8:11 pm
Location: London, England
Contact:

Re: [ZScript] Port of DaZombieKiller's footsteps

Post by Hidden Hands »

vsonnier wrote:This is a port of DAZombieKiller's Footsteps code in pure Zscript, see here for the original: https://github.com/DaZombieKiller/zk-resources ,or here for it's discussion: viewtopic.php?f=105&t=35388

It uses the same structure as the original for 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.

I wanted initially to re-compile/modify DaZombieKiller Footsteps but never managed to to it properly with the latest GDCC 0.16.1 so I wanted an equivalent in ZScript. The reason DaZombieKiller Footsteps is using GDCC instead of a "simple" ACS compiler is to be able to call C strtok-like functions 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 ACS CheckActorFloorTexture, or rather finding the texture the player was stepping in, in Zscript.

Graf suggested using checking Actor's`floorpic` and it works, so here it is !

The script parses the same configuration data as DaZombieKiller Footsteps and uses the same resource files structure as his, so can be used as a replacement of it's ACS module while keeping the rest of the structure.
Except REMOVE the module from the LOADACS list or you will get twice the footsteps effects :)

(The initial discussion is here : viewtopic.php?f=122&t=65137. I should have started that topic direclty here but it"s too late now so this present topic is essentially a cross-post suggested by the moderators. I won't do that again, promise.)
How do I actually use this? How can I get this to load up in my game when it starts? I've incorporated the zscript file, the sounds are in the sounds/footstep folder but NOTHING. It just does not work for me. Why?
User avatar
Cherno
Posts: 1309
Joined: Tue Dec 06, 2016 11:25 am

Re: [ZScript] Port of DaZombieKiller's footsteps

Post by Cherno »

IIRC you have to give the PlayerPawn an inventory, or make it hold an instance of a class relatd to the ZScript footsteps as a variable's value. Something like this. I believe you also need the correct entries in your LANGUAGE lump, at least for the Default sound.
User avatar
Hidden Hands
Posts: 1053
Joined: Tue Sep 20, 2016 8:11 pm
Location: London, England
Contact:

Re: [ZScript] Port of DaZombieKiller's footsteps

Post by Hidden Hands »

Can you share an example at all? I can't seem to figure this out I've been trying for about 4 hours.
User avatar
Hidden Hands
Posts: 1053
Joined: Tue Sep 20, 2016 8:11 pm
Location: London, England
Contact:

Re: [ZScript] Port of DaZombieKiller's footsteps

Post by Hidden Hands »

EDIT : I still can't get these footsteps to work. Please, can someone show me a setup that works? I can't really progress much in development without a little help with this.
User avatar
vsonnier
Posts: 80
Joined: Wed Apr 10, 2019 11:22 pm
Graphics Processor: nVidia with Vulkan support
Contact:

Re: [ZScript] Port of DaZombieKiller's footsteps

Post by vsonnier »

Looking at Kinsie's MetaDoom as an example and Brutal Doom Black Edition , you can do something like that:

Code: Select all

class MyDoomPlayer : Replaces DoomPlayer // Here MyDoomPlayer is your replacement of the Doom player
{
	...
       // Footsteps Code
	Footsteps fsteps;

	// Stuff that happens the moment the player is spawned.
	override void PostBeginPlay()
	{
		...

		// Footsteps Code, call the Init() function here
		Actor fstepsActor = Spawn("Footsteps",pos);
		if(fstepsActor != null)
		{
			fsteps = Footsteps(fstepsActor);
			fsteps.Init(self);
		}
	}
}
Doomplayer replacement is not automatic like the monsters, and you have to declare it's new name MyDoomPlayer in MAPINFO:

Code: Select all

GameInfo
{
AddEventHandlers =  "TiltPlusPlusHandler", "BEShaderEvent","BEEventHandler", "HeadshotHandler", "BootPrintsHandler", "DarkDoomZ_SectorLightAdjust", "MBlurHandler"
 
PlayerClasses = "MyDoomPlayer "
}
Alternatively, you can call Init() in an Event handler listed in AddEventHandlers : here as an example taken from BD: Black Edtion, Init() is called in the BEEventHandler:

Code: Select all

class BEEventHandler : EventHandler
{
        override void PlayerEntered(PlayerEvent e)
	{
		let player = PlayerPawn(players[e.PlayerNumber].mo);
		//BEGIN VSO : Some Wads crash here with VM Abort because player can be NULL
		if (player == NULL) {
			return;
		}
		//END VSO

              //VSO: Attach footsteps to player:
               Footsteps fsteps = Footsteps(Actor.Spawn("Footsteps",player.pos));
	       fsteps.Init(player);
     }
}
User avatar
Hidden Hands
Posts: 1053
Joined: Tue Sep 20, 2016 8:11 pm
Location: London, England
Contact:

Re: [ZScript] Port of DaZombieKiller's footsteps

Post by Hidden Hands »

vsonnier wrote:Looking at Kinsie's MetaDoom as an example and Brutal Doom Black Edition , you can do something like that:

Code: Select all

class MyDoomPlayer : Replaces DoomPlayer // Here MyDoomPlayer is your replacement of the Doom player
{
	...
       // Footsteps Code
	Footsteps fsteps;

	// Stuff that happens the moment the player is spawned.
	override void PostBeginPlay()
	{
		...

		// Footsteps Code, call the Init() function here
		Actor fstepsActor = Spawn("Footsteps",pos);
		if(fstepsActor != null)
		{
			fsteps = Footsteps(fstepsActor);
			fsteps.Init(self);
		}
	}
}
Doomplayer replacement is not automatic like the monsters, and you have to declare it's new name MyDoomPlayer in MAPINFO:

Code: Select all

GameInfo
{
AddEventHandlers =  "TiltPlusPlusHandler", "BEShaderEvent","BEEventHandler", "HeadshotHandler", "BootPrintsHandler", "DarkDoomZ_SectorLightAdjust", "MBlurHandler"
 
PlayerClasses = "MyDoomPlayer "
}
Alternatively, you can call Init() in an Event handler listed in AddEventHandlers : here as an example taken from BD: Black Edtion, Init() is called in the BEEventHandler:

Code: Select all

class BEEventHandler : EventHandler
{
        override void PlayerEntered(PlayerEvent e)
	{
		let player = PlayerPawn(players[e.PlayerNumber].mo);
		//BEGIN VSO : Some Wads crash here with VM Abort because player can be NULL
		if (player == NULL) {
			return;
		}
		//END VSO

              //VSO: Attach footsteps to player:
               Footsteps fsteps = Footsteps(Actor.Spawn("Footsteps",player.pos));
	       fsteps.Init(player);
     }
}
Ok. So in your first code block, that can be used in DECORATE? Or does it have to be ZSCRIPT? Because my custom player class is currently defined in DECORATE.
User avatar
vsonnier
Posts: 80
Joined: Wed Apr 10, 2019 11:22 pm
Graphics Processor: nVidia with Vulkan support
Contact:

Re: [ZScript] Port of DaZombieKiller's footsteps

Post by vsonnier »

So, either convert your player class in Zscript (which is rather simple, ex : https://zdoom.org/wiki/Converting_DECOR ... to_ZScript ) or use the "plug-in" way using the Event handler method which should work even if your PlayerPawn-derived class is in DECORATE.
User avatar
ramon.dexter
Posts: 1520
Joined: Tue Oct 20, 2015 12:50 pm
Graphics Processor: nVidia with Vulkan support
Location: Kozolupy, Bohemia

Re: [ZScript] Port of DaZombieKiller's footsteps

Post by ramon.dexter »

vsonnier wrote: Alternatively, you can call Init() in an Event handler listed in AddEventHandlers : here as an example taken from BD: Black Edtion, Init() is called in the BEEventHandler:

Code: Select all

class BEEventHandler : EventHandler
{
        override void PlayerEntered(PlayerEvent e)
	{
		let player = PlayerPawn(players[e.PlayerNumber].mo);
		//BEGIN VSO : Some Wads crash here with VM Abort because player can be NULL
		if (player == NULL) {
			return;
		}
		//END VSO

              //VSO: Attach footsteps to player:
               Footsteps fsteps = Footsteps(Actor.Spawn("Footsteps",player.pos));
	       fsteps.Init(player);
     }
}
That's the exact thing I was missing! Many thanks, vsonnier!
User avatar
Hidden Hands
Posts: 1053
Joined: Tue Sep 20, 2016 8:11 pm
Location: London, England
Contact:

Re: [ZScript] Port of DaZombieKiller's footsteps

Post by Hidden Hands »

I've tried endlessly but I cannot get these working. Exactly what do I have to do? I have a zscript entry for the footsteps code, the footsteps are all in the sounds folder, what am I missing?
User avatar
ramon.dexter
Posts: 1520
Joined: Tue Oct 20, 2015 12:50 pm
Graphics Processor: nVidia with Vulkan support
Location: Kozolupy, Bohemia

Re: [ZScript] Port of DaZombieKiller's footsteps

Post by ramon.dexter »

HiddenHands: Without seeing your whole wad, we cannot decide anything. Do you have the eventhandler also? Is the eventhandler registered in gameinfo block in mapinfo?
Post Reply

Return to “Script Library”