Ability to tweak overlay bobbing

Remember, just because you request it, that doesn't mean you'll get it.

Moderator: GZDoom Developers

Ability to tweak overlay bobbing

Postby Marisa Kirisame » Tue Mar 27, 2018 11:54 am

I was wondering if it's possible to add something to set overlays in weapons to bob in a different way than the main layer. Take for example the first person hands in Duke Nukem 3D when shrunk, where each hand bobs at a different phase when walking, that's the kind of behaviour I'm looking for.
User avatar
Marisa Kirisame
ZScript Magician
 
 
 
Joined: 08 Feb 2008
Location: Vigo, Galicia
Discord: Marisa Kirisame#4689
Twitch ID: magusmarisa
Github ID: OrdinaryMagician
Operating System: Other Linux 64-bit
Graphics Processor: nVidia with Vulkan support

Re: Ability to tweak overlay bobbing

Postby Nash » Tue Mar 27, 2018 12:06 pm




You can already add as many overlays as you want. This is already possible (although it is DIY)
User avatar
Nash
 
 
 
Joined: 27 Oct 2003
Location: Kuala Lumpur, Malaysia
Github ID: nashmuhandes
Operating System: Windows 10/8.1/8 64-bit
Graphics Processor: nVidia with Vulkan support

Re: Ability to tweak overlay bobbing

Postby Marisa Kirisame » Tue Mar 27, 2018 12:14 pm

Yeah but I'm talking about bobbing, not offsets.
User avatar
Marisa Kirisame
ZScript Magician
 
 
 
Joined: 08 Feb 2008
Location: Vigo, Galicia
Discord: Marisa Kirisame#4689
Twitch ID: magusmarisa
Github ID: OrdinaryMagician
Operating System: Other Linux 64-bit
Graphics Processor: nVidia with Vulkan support

Re: Ability to tweak overlay bobbing

Postby Apeirogon » Tue Mar 27, 2018 12:30 pm

Nash means "you can make any bobbing you can imagine, if you add >9000 ofsets, each part of which be a part of custom bobbing animations".

I hope I wrote that right and understandable.
Apeirogon
I have a strange sense of humour
 
Joined: 12 Jun 2017

Re: Ability to tweak overlay bobbing

Postby Nash » Tue Mar 27, 2018 12:52 pm

Apeirogon wrote:Nash means "you can make any bobbing you can imagine, if you add >9000 ofsets, each part of which be a part of custom bobbing animations".

I hope I wrote that right and understandable.


Yeah that's what I meant... make your own overlays and you can do any kind of bobbing patterns by yourself. "Bobbing" is technically speaking just (mathematically and with phase) offsetting, anyway o_O.

The sprinting hand in my videos is pretty much bobbing except it's more obvious in Y than in X, so it doesn't have a "U" pattern.
User avatar
Nash
 
 
 
Joined: 27 Oct 2003
Location: Kuala Lumpur, Malaysia
Github ID: nashmuhandes
Operating System: Windows 10/8.1/8 64-bit
Graphics Processor: nVidia with Vulkan support

Re: Ability to tweak overlay bobbing

Postby Marisa Kirisame » Wed Mar 28, 2018 5:55 am

Yeah but I DON'T want to do it like that. I want to take advantage of the already existing bobbing mechanic. Why should I implement my own bobbing in the weapon states themselves when I only want this to work exactly like the already existing bobbing except with, say, giving some overlay a different bobbing phase than the main weapon so they bob at a different time within the ready state sequence without me having to handcraft some convoluted custom bobbing system in the zscript side?
User avatar
Marisa Kirisame
ZScript Magician
 
 
 
Joined: 08 Feb 2008
Location: Vigo, Galicia
Discord: Marisa Kirisame#4689
Twitch ID: magusmarisa
Github ID: OrdinaryMagician
Operating System: Other Linux 64-bit
Graphics Processor: nVidia with Vulkan support

Re: Ability to tweak overlay bobbing

Postby Xaser » Wed Mar 28, 2018 9:44 am

I feel like we shouldn't need to remind longtime forum regulars about the old "don't suggest convoluted workarounds" rule at this point. C'mon. :(
User avatar
Xaser
anarchivist
 
 
 
Joined: 20 Jul 2003

Re: Ability to tweak overlay bobbing

Postby Nash » Wed Mar 28, 2018 10:18 am

No, I wasn't suggesting a workaround; rather I did not fully understand what the OP wanted.

It literally stated "hands like Duke Nukem being shrunk" so I offered a solution that the engine already allows. Because I know if I SPECIFICALLY wanted "hands like Duke Nukem with inversed bobbing phase" it would get No'd for being too specific, or rather [DIY]
User avatar
Nash
 
 
 
Joined: 27 Oct 2003
Location: Kuala Lumpur, Malaysia
Github ID: nashmuhandes
Operating System: Windows 10/8.1/8 64-bit
Graphics Processor: nVidia with Vulkan support

Re: Ability to tweak overlay bobbing

Postby Xaser » Wed Mar 28, 2018 10:47 am

Nash wrote:No, I wasn't suggesting a workaround

Sorry, no -- you definitely were. The OP was quite clear about wishing to use the existing bobbing mechanics -- scripting it via offsets is a workaround, full stop.

I'd normally understand the "whoops! I misread" angle, 'cause that happens, but you're doubling down on your mistake here.
User avatar
Xaser
anarchivist
 
 
 
Joined: 20 Jul 2003

Re: Ability to tweak overlay bobbing

Postby Nash » Wed Mar 28, 2018 11:42 am

No man, I really did not understand what MK wanted at first. When I posted my reply, I really thought it was one of those "you can already do that".
User avatar
Nash
 
 
 
Joined: 27 Oct 2003
Location: Kuala Lumpur, Malaysia
Github ID: nashmuhandes
Operating System: Windows 10/8.1/8 64-bit
Graphics Processor: nVidia with Vulkan support

Re: Ability to tweak overlay bobbing

Postby Marisa Kirisame » Wed Mar 28, 2018 12:06 pm

I'm not the best at explaining myself. :P
User avatar
Marisa Kirisame
ZScript Magician
 
 
 
Joined: 08 Feb 2008
Location: Vigo, Galicia
Discord: Marisa Kirisame#4689
Twitch ID: magusmarisa
Github ID: OrdinaryMagician
Operating System: Other Linux 64-bit
Graphics Processor: nVidia with Vulkan support

Re: Ability to tweak overlay bobbing

Postby Xaser » Wed Mar 28, 2018 1:40 pm

I suppose we'd best chalk it down to a minor "oopsie" and move on. I'm getting too confuzzled about this. :P
User avatar
Xaser
anarchivist
 
 
 
Joined: 20 Jul 2003

Re: Ability to tweak overlay bobbing

Postby Matt » Wed Mar 28, 2018 10:02 pm

What I'd like to know is how bobbing works at all... there seem to be like 9000 different components in it, some apparently exposed to ZS and some not, and it's not at all clear how they interact to ultimately get the head bobbing and weapon bobbing we see on the screen.
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: Ability to tweak overlay bobbing

Postby Xaser » Thu Mar 29, 2018 11:19 am

View bobbing and weapon bobbing are technically two separate things. I don't know much about the former, but the latter is controlled in P_BobWeapon, which is called by the renderers when drawing HUD sprites. The function checks if the player is carrying a weapon that's in a bobbable state (i.e. has just called A_WeaponReady without WRF_NOBOB set), inspects the player's current speed, and does some funky math to determine the bob position.

The bob properties on the Weapon class (BobStyle et.al) are things that influence the "funky math". BobStyle selects from a set of formulas (via an ugly switch statement; for shame, past-me!), and BobRange/BobSpeed are fed as "parameters" into the formula along with the player's speed and the current leveltime to figure out where the weapon should be drawn. That's about it.

It's all a bit rudimentary since the bob properties were uber-basic things I added ages ago, but there are essentially two big ways to extend this feature:
  • Add bobbing properties to PSPrites (i.e. overlay layers), then add a function to set them a la A_OverlayFlags (this is what Marisa's asking for).
  • Add a BobWeapon virtual function (UI scope). This would let users implement their own bobbing patterns freely.

It gets a tiny bit tricker if we wish to add both extensions. Best I can think of offhand for is to add a "layer" param to the BobWeapon virtual function then let modders figure it out themselves. Curious if anyone has any thoughts here.
User avatar
Xaser
anarchivist
 
 
 
Joined: 20 Jul 2003

Re: Ability to tweak overlay bobbing

Postby nazakomu » Thu Mar 29, 2018 8:19 pm

This is an interesting topic for me, since recently, I've been working on PSprites and such. As far as I can tell, currently they're somewhat difficult to work with, and that can definitely be my fault for not being adept with ZScript.
The way I'm handling the bobbing and other PSprite work is in an override of Tick() in the PlayerPawn class I have, and it seemingly is the worst place to do it as there is an atrocious bug that comes out of doing it (i.e. when the player moves while entering their death state, the game crashes).
A code example is:
Code: Select allExpand view
   override void Tick()
   {
      if (!player || !player.mo || player.mo != self)
      {
         Super.Tick();
         return;
      }
      // The CheckWeaponSelected function is written elsewhere, but is the exact same function from the status bars. It is used as a check to make sure I can do things with specific weapons, such as changing the speed and intensity.
      if (CheckWeaponSelected("Pistol"))
      {
         let psp = player.GetPSprite(PSP_WEAPON); // I also tried player.FindPSprite, to which was no success.
         if (player.onground)
         {
            // Bobbing gets done here.
         }
      }
   }

The reason the crashing seems to be happening is because of the way I'm accessing the PSprite (let psp = player.GetPSprite(PSP_WEAPON)). It has caused crashing before if just openly put in the Tick() override without any checks, too.
I alternatively, tried transitioning the bobbing itself into the weapon instead, to which didn't work out so well, again probably due to me not being so experienced with it..
Perhaps, I'm really just doing things wrong. :?
User avatar
nazakomu
iddqd
 
Joined: 30 Nov 2016
Discord: Nazakomu#2197

Next

Return to Feature Suggestions

Who is online

Users browsing this forum: No registered users and 1 guest