Overlay re-centering issues

Bugs that have been investigated and resolved somehow.

Moderator: GZDoom Developers

Forum rules
Please don't bump threads here if you have a problem - it will often be forgotten about if you do. Instead, make a new thread here.
Post Reply
User avatar
Major Cooke
Posts: 8175
Joined: Sun Jan 28, 2007 3:55 pm
Preferred Pronouns: He/Him
Location: QZDoom Maintenance Team

Overlay re-centering issues

Post by Major Cooke »

This was a feature I was working on for D4D v2 but the centering only ever happens after the firing is finished, no matter what i try.


Code: Select all

//==========================================================================
    // Overlay:         Gun Shifting (WIP)
    // Offsets the weapon whenever turning the camera angle/pitch.
    //==========================================================================
    // (Currently buggy with firing weapons. Needs more fine tuning.)
    Overlay.AnglePitch:
        M666 A 1
        {
            if (GetCvar(D4D_TurningBehavior))
            {
                if (abs(user_offsets[0]) < 10.0)
                {
                    user_offsets[0] += (GetPlayerInput(INPUT_YAW,DefPtr) / 32767.0) * 10.0;
                    //A_LogFloat(user_offsets[0]);
                }
                if (user_offsets[0] != 0.0)
                {
                    if (user_offsets[0] < 1.0 && user_offsets[0] > -1.0)
                    {
                        A_WeaponOffset(user_offsets[0],0,WOF_ADD);
                        user_offsets[0] = 0;
                    }
                    else if (user_offsets[0] < 0.0)
                    {
                        A_WeaponOffset(user_offsets[0],0,WOF_ADD);
                        user_offsets[0] += 1.0;
                    }
                    else if (user_offsets[0] > 0.0)
                    {
                        A_WeaponOffset(user_offsets[0],0,WOF_ADD);
                        user_offsets[0] -= 1.0;
                    }
                }
            }
            else
            {    A_SetTics(35);    }
        }
        Loop
User avatar
Leonard2
Posts: 313
Joined: Tue Aug 14, 2012 6:10 pm

Re: Overlay re-centering issues

Post by Leonard2 »

Calling A_WeaponReady resets the offsets.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49067
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: Overlay re-centering issues

Post by Graf Zahl »

Does this mean [not a bug]? I haven't looked into this yet.
User avatar
Major Cooke
Posts: 8175
Joined: Sun Jan 28, 2007 3:55 pm
Preferred Pronouns: He/Him
Location: QZDoom Maintenance Team

Re: Overlay re-centering issues

Post by Major Cooke »

But that's the problem. I want it to stay centered at all times. So I still think of it as a bug.

Also I tried calling A_WeaponReady during this, for the rocket launcher itself with WRF_NOFIRE|WRF_NOBOB. Didn't help.
Last edited by Major Cooke on Mon Oct 31, 2016 1:14 pm, edited 2 times in total.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49067
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: Overlay re-centering issues

Post by Graf Zahl »

How can we test? Where is this weapon? The fragment is not enough.
User avatar
Major Cooke
Posts: 8175
Joined: Sun Jan 28, 2007 3:55 pm
Preferred Pronouns: He/Him
Location: QZDoom Maintenance Team

Re: Overlay re-centering issues

Post by Major Cooke »

Turns out I commented out the overlay bit needed to run this piece.

Download here. Graf, what you have should suffice already.
Spoiler: Option 1: Use attachment
Spoiler: Option 2: Uncomment line
Go to console: D4D_TurningBehavior 1; give d4rocketlauncher; sv_infiniteammo 1. When you turn about, the weapon automatically recenters itself as expected. But when you fire, that's when it goes kinda weird.
Attachments
D4Dt.pk3
Option 2: Load after d4d.pk3
(5.97 KiB) Downloaded 37 times
User avatar
Major Cooke
Posts: 8175
Joined: Sun Jan 28, 2007 3:55 pm
Preferred Pronouns: He/Him
Location: QZDoom Maintenance Team

Re: Overlay re-centering issues

Post by Major Cooke »

Hmm. It seems WRF_NOBOB is the cause of it. But removing that causes some weird funkiness to go on and attempts to ALWAYS recenter it in that case, disregarding the added offsets. (I did a search & replace for |WRF_NOBOB to nothing in Decorate/Weapons/RocketLauncher.AED)
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49067
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: Overlay re-centering issues

Post by Graf Zahl »

Code: Select all

void DoReadyWeaponToBob (AActor *self)
{
	if (self && self->player && self->player->ReadyWeapon)
	{
		// Prepare for bobbing action.
		self->player->WeaponState |= WF_WEAPONBOBBING;
		self->player->GetPSprite(PSP_WEAPON)->x = 0;
		self->player->GetPSprite(PSP_WEAPON)->y = WEAPONTOP;
	}
}
Yep, that's where the weapon offset gets reset. I assume you want this but without setting the WF_WEAPONBOBBIN, right? can'T you replace the A_WeaponReady call with A_WeaponOffset?
User avatar
Major Cooke
Posts: 8175
Joined: Sun Jan 28, 2007 3:55 pm
Preferred Pronouns: He/Him
Location: QZDoom Maintenance Team

Re: Overlay re-centering issues

Post by Major Cooke »

Which means I'm going to just have to rely on hard numbers rather than the add flag. Great...

Welp, I know this won't be a problem with scripting thanks to local variables in weapons.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49067
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: Overlay re-centering issues

Post by Graf Zahl »

Whether you reset it by letting A_WeaponReady reset it or by letting A_WeaponOffset reset it shouldn't matter, should it? Or are you trying to set the offset in one overlay from another one? If that's the case, I fear my answer is indeed WFDS.
User avatar
Major Cooke
Posts: 8175
Joined: Sun Jan 28, 2007 3:55 pm
Preferred Pronouns: He/Him
Location: QZDoom Maintenance Team

Re: Overlay re-centering issues

Post by Major Cooke »

...Oh. Snap! The example above is on the player actor itself, and I did make OverlayX/Y/ID() for similar purposes. Well, there I go. Guess I won't have to wait for zscript after all. I think this can be closed.
Post Reply

Return to “Closed Bugs [GZDoom]”