[Not a bug] Overlay re-centering issues

Bugs that have been investigated and resolved somehow.

Moderator: GZDoom Developers

Overlay re-centering issues

Postby Major Cooke » Mon Oct 31, 2016 11:50 am

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 allExpand view
//==========================================================================
    // 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
Major Cooke
Do unto others as you would have unto you. Judge yourself first.
 
Joined: 28 Jan 2007

Re: Overlay re-centering issues

Postby Leonard2 » Mon Oct 31, 2016 1:06 pm

Calling A_WeaponReady resets the offsets.
User avatar
Leonard2
 
Joined: 14 Aug 2012

Re: Overlay re-centering issues

Postby Graf Zahl » Mon Oct 31, 2016 1:12 pm

Does this mean [not a bug]? I haven't looked into this yet.
User avatar
Graf Zahl
Lead GZDoom Developer
Lead GZDoom Developer
 
Joined: 19 Jul 2003
Location: Germany

Re: Overlay re-centering issues

Postby Major Cooke » Mon Oct 31, 2016 1:59 pm

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 2:14 pm, edited 2 times in total.
User avatar
Major Cooke
Do unto others as you would have unto you. Judge yourself first.
 
Joined: 28 Jan 2007

Re: Overlay re-centering issues

Postby Graf Zahl » Mon Oct 31, 2016 2:02 pm

How can we test? Where is this weapon? The fragment is not enough.
User avatar
Graf Zahl
Lead GZDoom Developer
Lead GZDoom Developer
 
Joined: 19 Jul 2003
Location: Germany

Re: Overlay re-centering issues

Postby Major Cooke » Mon Oct 31, 2016 2:13 pm

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 17 times
User avatar
Major Cooke
Do unto others as you would have unto you. Judge yourself first.
 
Joined: 28 Jan 2007

Re: Overlay re-centering issues

Postby Major Cooke » Mon Oct 31, 2016 2:25 pm

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
Major Cooke
Do unto others as you would have unto you. Judge yourself first.
 
Joined: 28 Jan 2007

Re: Overlay re-centering issues

Postby Graf Zahl » Mon Oct 31, 2016 2:30 pm

Code: Select allExpand view
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
Graf Zahl
Lead GZDoom Developer
Lead GZDoom Developer
 
Joined: 19 Jul 2003
Location: Germany

Re: Overlay re-centering issues

Postby Major Cooke » Mon Oct 31, 2016 2:34 pm

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
Major Cooke
Do unto others as you would have unto you. Judge yourself first.
 
Joined: 28 Jan 2007

Re: Overlay re-centering issues

Postby Graf Zahl » Mon Oct 31, 2016 2:46 pm

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
Graf Zahl
Lead GZDoom Developer
Lead GZDoom Developer
 
Joined: 19 Jul 2003
Location: Germany

Re: Overlay re-centering issues

Postby Major Cooke » Mon Oct 31, 2016 3:06 pm

...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.
User avatar
Major Cooke
Do unto others as you would have unto you. Judge yourself first.
 
Joined: 28 Jan 2007


Return to Closed Bugs

Who is online

Users browsing this forum: No registered users and 0 guests