nipkownix / re4_tweaks

Fixes and tweaks for the "UHD" port of Resident Evil 4
zlib License
346 stars 32 forks source link

[Feature request] Allow binoculars to be used anywhere #429

Open linkthehylian opened 1 year ago

linkthehylian commented 1 year ago

Describe the feature you'd like to see added

In the Biohazard 4 Famitsu demo for Gamecube, you can press Z to allow Leon to bring out his binoculars anywhere rather than in the scripted cutscenes in the final game.

https://user-images.githubusercontent.com/20933012/210902398-578c218a-cb64-460f-855e-c8e6d0c27f33.mp4

I'm not sure whether there would be leftover existing code for this feature. But if there is, it would be really cool to see it be brought back. 😄

NintendoFan commented 1 year ago

This was brought up in #423 but it's interesting to see this in an actual video.

Maybe they thought the binoculars were redundant though, since rifles exist? What available buttons are there that can be allocated to this function?

Nitsug72 commented 1 year ago

I personally don't use L2 for anything, for example.

linkthehylian commented 1 year ago

This was brought up in #423 but it's interesting to see this in an actual video.

Huh, I even searched it up just to be sure it wasn't already an existing issue but it apparently is?

Well, here it is again lmao

RiasatSalminSami commented 1 year ago

Yeah it would be pretty neat feature to have.

pas-de-2 commented 1 year ago

There's some leftover code in a cPlayer::beginBinocular that never gets called, which sets the m_BinoRno_56F routine for cPlayer::moveBinocular, but neither of these actually initialize the binocular HUD. It looks like we need to replicate the middle of r101_Event00, without the fixed campos/target parameters.

Something else I noticed is that the sensitivity for the binocular controls is doubled at 60fps. CameraBinocular::move needs a bunch of deltaTime fixes, like CameraScope::move already has. E: fixed

I'd personally bind this to R3.

EDIT: Tried something with this, ~two problems~one problem:

kazuya-555 commented 1 year ago

Or the select button

pas-de-2 commented 1 year ago

Proof of concept:

https://user-images.githubusercontent.com/116680301/211245582-36c27562-e4cb-4691-bf7b-d295cecfa056.mp4

Will need to figure out how to get the HUD textures to load outside r101.

emoose commented 1 year ago

E: Looks like they're stored at different indexes in GlobalPtr()->pRoom_40 . That gets initialized in ReadAreaData on stage load... No idea how to get the game to load these outside r101 and r10b. :\

Maybe could extract the texture data from the stage file and just embed it in the DLL directly? Seems like they're just passing pointers to the data to IdBinocular::init. That init func does pass the pointers to IdTexDataLoad & IDSystem::set though, not sure if those might try using some value in the data to lookup more data inside pRoom maybe. Using a tool like RE4UHD_UDAS_Tool.exe should give you a bunch of files from the room udas, the ones for r10b should be XX_34 & XX_35 (for r101 it looks like XX_35 & XX_36)

If it does work with embedded textures maybe can set something up to read them from r101/r10b stage file later on, LFS crap might be a little annoying though, but maybe we can use the games reading funcs themselves for it...

pas-de-2 commented 1 year ago

Hmm, I tried adding r101_35.EFF and r101_36.UWF to dllmain.rc, but I can't seem to get FindResource to find them. I should be using g_module_handle as the HMODULE, yes? Does this look right?

HRSRC HRsrc1 = FindResource(g_module_handle, MAKEINTRESOURCE(IDR_EFF1), RT_RCDATA);
if (HRsrc1)
    // not happening
emoose commented 1 year ago

Looks fine to me, does GetLastError() tell you anything? If the files aren't too big you might be able to just include it in a C file, like we do inside roomInfo.cpp, might be some kind of file size limit with that though. (010 editor can let you copy the file contents as a C array)

albertre4HD commented 1 year ago

0265-0294 are the binocular UI textures inside 44000101.pack (in case the info is helpful) image