[ZScript] Port of DaZombieKiller's footsteps

Post your example zscripts/ACS scripts/etc here.

[ZScript] Port of DaZombieKiller's footsteps

Postby vsonnier » Mon Jun 24, 2019 10:39 pm

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.)
You do not have the required permissions to view the files attached to this post.
vsonnier
 
Joined: 11 Apr 2019
Github ID: vsonnier
Operating System: Windows 10/8.1/8/201x 64-bit
Graphics Processor: nVidia with Vulkan support

Re: [ZScript] Port of DaZombieKiller's footsteps

Postby Kinsie » Mon Jun 24, 2019 10:43 pm

This is great! Transitioned MetaDoom from the old ACS script to this yesterday. Thanks so much for doing this!
User avatar
Kinsie
Dog Days
 
Joined: 22 Oct 2004
Location: MAP33
Discord: Find Me...
Twitch ID: thekinsie

Re: [ZScript] Port of DaZombieKiller's footsteps

Postby vsonnier » Mon Jun 24, 2019 10:53 pm

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.
vsonnier
 
Joined: 11 Apr 2019
Github ID: vsonnier
Operating System: Windows 10/8.1/8/201x 64-bit
Graphics Processor: nVidia with Vulkan support

Re: [ZScript] Port of DaZombieKiller's footsteps

Postby The Zombie Killer » Wed Jun 26, 2019 2:45 am

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.
User avatar
The Zombie Killer
King of the Kangaroos
 
Joined: 14 Jul 2011
Location: Gold Coast, Queensland, Australia
Discord: Zombie#1795

Re: [ZScript] Port of DaZombieKiller's footsteps

Postby fcas3t » Thu Apr 08, 2021 7:50 pm

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.)
You do not have the required permissions to view the files attached to this post.
fcas3t
 
Joined: 29 Nov 2020

Re: [ZScript] Port of DaZombieKiller's footsteps

Postby Hidden Hands » Wed Jun 30, 2021 12:08 pm

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
Hidden Hands
Cherub
 
Joined: 20 Sep 2016
Location: London, England
Discord: VGCtm
Operating System: Windows Vista/7/2008 32-bit

Re: [ZScript] Port of DaZombieKiller's footsteps

Postby Cherno » Wed Jun 30, 2021 4:29 pm

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
Cherno
 
Joined: 06 Dec 2016

Re: [ZScript] Port of DaZombieKiller's footsteps

Postby Hidden Hands » Wed Jun 30, 2021 7:56 pm

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
Cherub
 
Joined: 20 Sep 2016
Location: London, England
Discord: VGCtm
Operating System: Windows Vista/7/2008 32-bit

Re: [ZScript] Port of DaZombieKiller's footsteps

Postby Hidden Hands » Fri Jul 02, 2021 9:50 am

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
Hidden Hands
Cherub
 
Joined: 20 Sep 2016
Location: London, England
Discord: VGCtm
Operating System: Windows Vista/7/2008 32-bit

Re: [ZScript] Port of DaZombieKiller's footsteps

Postby vsonnier » Fri Jul 02, 2021 10:31 am

Looking at Kinsie's MetaDoom as an example and Brutal Doom Black Edition , you can do something like that:
Code: Select allExpand view
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 allExpand view
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 allExpand view
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);
     }
}
vsonnier
 
Joined: 11 Apr 2019
Github ID: vsonnier
Operating System: Windows 10/8.1/8/201x 64-bit
Graphics Processor: nVidia with Vulkan support

Re: [ZScript] Port of DaZombieKiller's footsteps

Postby Hidden Hands » Fri Jul 02, 2021 11:44 am

vsonnier wrote:Looking at Kinsie's MetaDoom as an example and Brutal Doom Black Edition , you can do something like that:
Code: Select allExpand view
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 allExpand view
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 allExpand view
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
Hidden Hands
Cherub
 
Joined: 20 Sep 2016
Location: London, England
Discord: VGCtm
Operating System: Windows Vista/7/2008 32-bit

Re: [ZScript] Port of DaZombieKiller's footsteps

Postby vsonnier » Fri Jul 02, 2021 12:37 pm

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.
vsonnier
 
Joined: 11 Apr 2019
Github ID: vsonnier
Operating System: Windows 10/8.1/8/201x 64-bit
Graphics Processor: nVidia with Vulkan support

Re: [ZScript] Port of DaZombieKiller's footsteps

Postby ramon.dexter » Sun Jul 04, 2021 2:26 am

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 allExpand view
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
ramon.dexter
rudebwoy
 
Joined: 20 Oct 2015
Location: Kozolupy, Bohemia
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: [ZScript] Port of DaZombieKiller's footsteps

Postby Hidden Hands » Fri Aug 06, 2021 3:52 pm

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
Hidden Hands
Cherub
 
Joined: 20 Sep 2016
Location: London, England
Discord: VGCtm
Operating System: Windows Vista/7/2008 32-bit

Re: [ZScript] Port of DaZombieKiller's footsteps

Postby ramon.dexter » Fri Aug 13, 2021 11:22 pm

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?
User avatar
ramon.dexter
rudebwoy
 
Joined: 20 Oct 2015
Location: Kozolupy, Bohemia
Operating System: Windows 10/8.1/8/201x 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: nVidia with Vulkan support

Next

Return to Script Library

Who is online

Users browsing this forum: No registered users and 0 guests