Ability to tweak overlay bobbing

Post a reply

Smilies
:D :) :( :o :shock: :? 8-) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :wink: :geek: :ugeek: :!: :?: :idea: :arrow: :| :mrgreen: :3: :wub: >:( :blergh:
View more smilies

BBCode is ON
[img] is OFF
[url] is ON
Smilies are ON

Topic review
   

Expand view Topic review: Ability to tweak overlay bobbing

Re: Ability to tweak overlay bobbing

by RockstarRaccoon » Wed Apr 11, 2018 11:14 am

This would be a really nice touch to anything where both hands are on screen, like punching or double pistols.

Re: Ability to tweak overlay bobbing

by nazakomu » Fri Mar 30, 2018 5:52 am

_mental_ wrote:The first one must be reported. The second one is just a mod error in most cases.
Thanks! Off I go then!

Re: Ability to tweak overlay bobbing

by _mental_ » Fri Mar 30, 2018 5:49 am

This is a crash
gzdoom_crash.png
This is not

Code: Select all

VM execution aborted: tried to read from address zero.
Called from MyDumbActor.Tick at :zscript.txt, line 123
The first one must be reported. The second one is just a mod error in most cases.

Re: Ability to tweak overlay bobbing

by nazakomu » Fri Mar 30, 2018 5:33 am

_mental_ wrote:If GZDoom is still crashing (in the right meaning of this term), where is a bug report?
I couldn't tell if it was a bug or not. If that crash is not supposed to occur, then I'll make a bug report right away!

Re: Ability to tweak overlay bobbing

by _mental_ » Fri Mar 30, 2018 5:27 am

If GZDoom is still crashing (in the right meaning of this term), where is a bug report?

Re: Ability to tweak overlay bobbing

by Marisa the Magician » Fri Mar 30, 2018 5:23 am

Funny, I just had that same exact crash before. You have to also bail out when "player.playerstate == PST_DEAD". Calls to GetPSprite crash if you do it while dead.

Re: Ability to tweak overlay bobbing

by nazakomu » Thu Mar 29, 2018 7: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 all

	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. :?

Re: Ability to tweak overlay bobbing

by Xaser » Thu Mar 29, 2018 10: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.

Re: Ability to tweak overlay bobbing

by Matt » Wed Mar 28, 2018 9: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.

Re: Ability to tweak overlay bobbing

by Xaser » Wed Mar 28, 2018 12: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

Re: Ability to tweak overlay bobbing

by Marisa the Magician » Wed Mar 28, 2018 11:06 am

I'm not the best at explaining myself. :P

Re: Ability to tweak overlay bobbing

by Nash » Wed Mar 28, 2018 10: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".

Re: Ability to tweak overlay bobbing

by Xaser » Wed Mar 28, 2018 9: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.

Re: Ability to tweak overlay bobbing

by Nash » Wed Mar 28, 2018 9: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]

Re: Ability to tweak overlay bobbing

by Xaser » Wed Mar 28, 2018 8: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. :(

Top