CleverRaven / Cataclysm-DDA

Cataclysm - Dark Days Ahead. A turn-based survival game set in a post-apocalyptic world.
http://cataclysmdda.org
Other
10.28k stars 4.12k forks source link

Firing issues centering screen. #76190

Open Cupidatis opened 2 weeks ago

Cupidatis commented 2 weeks ago

Describe the bug

Sometimes there are issues with centering screen after firing with some weapons. It was being corrected with key reset centering, but when I was firing from different Z level (from top of the tree) resetting didn't help, save and quit also didn't help with it. So it shows me black screen, only looking around with x, V or f make you see something.

Attach save file

new-trimmed.tar.gz

Steps to reproduce

  1. Climb at tree
  2. Fire some zombies at different Z level
  3. Center of your screen is on different Z level

Expected behavior

Screen position need to be reseted after finishing firing.

Screenshots

Screenshot_2024-09-04-13-01-46-916_com cleverraven cataclysmdda experimental

Versions and configuration

Additional context

Edit: maybe it's Aftershock issue, I used v7 laser pistol.

Agnistel commented 2 weeks ago

I encountered a similar bug after shooting while driving, the center of the screen shifted several tiles to the side.

Anubioz commented 2 weeks ago

I got the same bug. Somehow after shooting from a roof to lower z-level, my view offset got permanently fixed on a lower level. Game Version: b38588a. To anyone who encounters this bug and want a fix - just edit your sav file - set "view_offset_z" back to 0 and then load... I wonder why would one even save view_offset_z in a first place...

CoroNaut commented 2 weeks ago

I did a quick test with a more vanilla mod list. I got into a tree with the V29 laser pistol and shot down at a debug monster on a lower Z level. it didn't even change my view to the Z-level that the debug monster was on, it stayed on the z-level of my character. It looks like a mod issue.

TESTING-trimmed.tar.gz

Anubioz commented 2 weeks ago

options.json I'm pretty sure it is related to options like snapping to target, try this option set, while I'll dig into the code. (Also the bug happened when I ran out of ammo.)

Cupidatis commented 2 weeks ago

Tried with vanilla. This bug work with v29 when you're firing to another Z level to moment when laser goes to VNT overheat.

Anubioz commented 1 week ago

I just compiled the latest source code & can confirm the bug is still there. It triggers when you run out of ammo, while having the "snap to target" option enabled and shooting a target on a different z-level.

I presume it can be fixed by replacing:

if( status == Status::OutOfAmmo && new_pos != src ) {
    // range == 0, no sense in moving cursor
    return false;
}

with

if( status == Status::OutOfAmmo && new_pos != src ) {
    set_view_offset(tripoint_zero); // move the view_offset back to player to fix shooting from a different z-layer
    return false;
}

in the ranged.cpp

But maybe a better solution would be implementing shifting view keys for z-level, so one can adjust the view_offset like one needs...

P.S. I can say playing with my code edits, which resets offset on running out of ammo seems much more comfortable for some reason, since you immediately can tell that you run out of ammo, when it snaps back to you, unlike when you needed to specifically look into sidebar log to tell why exactly your gun does not shoot...