Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unused code & other oddities #21

Open
emoose opened this issue Nov 30, 2022 · 5 comments
Open

Unused code & other oddities #21

emoose opened this issue Nov 30, 2022 · 5 comments

Comments

@emoose
Copy link
Owner

emoose commented Nov 30, 2022

Some oddities I've come across looking through different RE4 builds/ports, been wanting to add to the RE4 TCRF page for a while but the only RE4 page there is marked GC only - almost all unused things in GC got carried forward to later ports though, GC seems to have very little unique to it, so not sure why it's marked like that.

Hopefully my request to move that page from a couple months ago might get answered eventually, until then I'll write whatever I find here to keep me from forgetting anything 😸

PSX / PlayStation SDK graphics code

For whatever reason the game includes a bunch of graphics functions with names taken straight from the PSX / PsyQ SDK, eg. ClearOTagR, DrawOTag - these names are unique to the PSX and aren't used by any other console / SDK. (TODO: IIRC there were a couple other PSX functions too)

These take the same parameters/structs as the PSX SDK functions did but don't actually use any PSX SDK code inside them, instead it seems some effort was made to emulate the behavior using Gamecubes GX functions.

Best guess is these were to help bring small parts of Capcom PSX code over to the new engine without too much work, or maybe these were added to make Capcom's PSX developers feel more at home working on the new system - alternately maybe some single component of the game (UI/Sound/FMV/Debug?) required these functions to work.

(or maybe the RE4/PN03 engine actually started back on PSX, and RE4 gamecube is just another port in disguise? who can say :P)

TODO: check with PN03 .MAP file and other symbol sources to find what object file these functions are compiled under, maybe the filename could reveal something more.

Unused rooms

Data for a bunch of unused rooms is included, Albert from RE4HD has made a great video documenting these here: https://www.youtube.com/watch?v=tyoy2NPmXcY (ENG subtitles can be enabled for non-Spanish speakers)

There's also code (but no data) for even more unused rooms under the R1XX/R2XX stage IDs - seems the code of these is mostly copied from other existing (and in-use) rooms, and since this unused code was only introduced with the PS2+ releases that included Separate Ways - which also copied from existing rooms - it's plausible these could be earlier versions of those Separate Ways duplicates.
Maybe before they knew they could put Separate Ways as R5XX stages they were first added into the R1XX/R2XX code, and then forgotten to be removed after moving.

It's not known if these are any different, and without room data for them there's likely no chance of seeing any kind of visual differences neither - maybe copying the room data from the R1XX/R2XX stage it was duplicated from (or the R5XX SW duplicate) could let them be loaded in though, to see if they play any differently.

The PS2 release also contained mentions of rooms R021 thru R026, but without any early/debug PS2 builds available to check it's not known if any room data is actually available for these (oddly, the code for them was actually included with the 2007 SourceNext release though, but sadly still no room data: #20)

BIO5 ESL enemy list

All the ESL enemy spawning lists are named as emleonXX.esl / omakeXX.esl in the games files, but PS2 symbols reveal that the code internally has an enum that associates those files with actual names:

typedef enum {
EM_LIST_FALSE = -1,
EM_LIST_ST1_0,
[..],
EM_LIST_BIO5,
EM_LIST_ADA,
} EM_LIST_KIND;

Of note there is EM_LIST_BIO5, which is associated with emleon09.esl - that ESL is pretty stripped down & boring in the UHD release, but the PS2 emleon09.esl actually contains spawns for enemies on the unused R7XX maps! (aka the maps that look very similar to RE5 in Albert's video above 🤔)
#18 (comment) shows the map loaded with those enemy spawns in place.

The code that actually maps the R7XX stages to that ESL file is also only present on PS2 builds and later, likely meaning this was added sometime between the GC and PS2 release.

DebugTrg

Many room & event functions seem to have calls to a certain function, and appear to skip certain triggers depending on what that function returned - this func is named by debug symbols as DebugTrg, however in almost every build checked the function was empty with no code/implementation inside it (even inside debug builds), leaving it unknown how it was meant to work.

In 2022 speedrunners for the 2007 SourceNext port found that pressing a specific button combo at certain moments could allow them to skip sections of the game: https://www.speedrun.com/re4console/guide/43pbn
Some digging into a non-DRM-protected version of 2007 showed that this was likely DebugTrg - SourceNext appears to be the only build available publicly that actually includes it. (more info at #20)

Thanks to this re4_tweaks can now optionally re-enable DebugTrg in the UHD version, along with including keyboard bindings for it & an on-screen message to indicate when the game is actively checking it, hopefully coming in useful for modders & others that need to test things quickly 🥳

Merchant "mood"

PS2 symbols for the Merchant class make mention of a m_friendship field, along with a Merchant::mood func & MOOD enum (with values for bad / normal / good).

Seems the m_friendship value is used to determine which MOOD the merchant is in, the mood is then used to pick a "ratio" from m_off_ratio_bad / m_off_ratio_normal / m_off_ratio_good, which gets stored inside m_reduction_ratio, which then gets used by Merchant::sellPrice to adjust the price.

m_friendship increases inside Merchant::buyup (presumably when buying items), but seems to get reduced inside Merchant::study (maybe the Buy XXX for YYY? screen) - study also seems to be the func that picks the ratio & updates m_reduction_ratio too.

However I couldn't see any info online about merchant sell prices ever being adjusted (besides upgraded weapons having price increased), seems everywhere pretty much just has a table of static item prices.

Maybe something is broken with this friendship system making the adjustment from m_reduction_ratio have no effect, or the m_off_ratio_XXX fields are maybe all set to zero for all the items.

E: ah, BIO4 EXE has noted this feature was present and actually functional in an earlier trial build: https://www.youtube.com/watch?v=hgOjF95DYeg&t=750s
The build shown there seems to feature a very early merchant menu which displays an "ASK FOR DISCOUNT" option when purchasing - I've never seen any option like that in the final menus though unfortunately, so not sure how possible it'd be to reactivate in the final game...
(wasn't able to contact them about this since my youtube comments keep disappearing, too bad)

Item ID oddities

RE4VR helpfully includes an enum associating all the item IDs with actual names, there's many entries inside there that don't seem usable though (due to piece_info entries being missing in the EXE for them they can't be displayed in inventory), not known if there's anything more to them besides the enum names.

See https://github.com/nipkownix/re4_tweaks/blob/15472c5dbb2810ce319b77c0d9f7e95d52a90ef0/dllmain/GameFlags.cpp#L905 for a cleaned-up enum list, ones marked "Wep"/"Item"/"Ammo" are available to add to inventory, some treasures are also listed there (which would also be able to be added), but then there are weird entries like Ruger_SA Mauser_ST New_Weapon_SC Ada_New_Weapon, which don't seem to be usable atm.

There's also two separate Wep: Punisher items which can be added to inventory fine, one marked FN70 and the other Item_40, not sure what kind of difference there is with them. (E: seems game code actually forces one of these to switch over to the other ID instead, only code of that type in the game, weird)

Item ID name changes

The RE4VR item ID names might be interesting for some since they appear to be internal names taken from the games source code, and so don't always match the names that actually get shown in game - this maybe reveals items that were renamed at some point, or even replaced entirely.

I don't have any list comparing internal with in-game yet, but you can check out the internal enum in re4_tweaks code here, and the friendly names we show in the item adder (which we've tried to make match with the names shown in-game) here.

Some examples, Piece_Of_Slate became Stone Tablet, Golden_Gem,Silver_Gem & Cupric_Gem became Lion Ornament, Goat Ornament & Serpent Ornament, Ore_White & Ore_Black became Velvet Blue & Spinel...
The commit from @nipkownix renaming these items shows even more: nipkownix/re4_tweaks@6951f96
(note that the commit doesn't show all items that were renamed this way though, some items were renamed already in other commits, hopefully can make a proper comparison between internal<->in-game eventually)

Em06

GC debug build includes a single file related to Em06, Bio4.em06.sym, listing the function names inside the (sadly not included) em06.rel file.

The names seem to be formatted a lot differently to how other EmXX functions are named, with different capitalization & names like Em06_dm_ck, likely indicating this code is from earlier in development (or maybe is using REmake conventions):
image
Two functions of note are Em06BendBody and em06AlphaControl, implying this enemy could bend itself somehow, and maybe had some sort of transparency or invisibility effect to it.

UHD does also include an Em06.udas file, similar to Em09 below the TPL is empty though - however, it looks like UHD does have code that links the Em06.udas up with 00000006.pack ImagePack, which contains such textures:
image

Looks like that could be the hunter enemy from REmake: https://oyster.ignimgs.com/wordpress/stg.ign.com/2012/08/2-Hunter.jpg?width=1280&fit=bounds&height=720&quality=20&dpr=0.05

Em09

AI code exists inside UHD for an unused Em09 enemy, though sadly with nothing calling into the prologEm09 function for it, making the code go completely unused.

The functions available for it can maybe give some ideas about it:
image

Just like Em06 there is also an Em09.udas file shipped with UHD edition, again with an empty TPL, but unfortunately UHD doesn't seem to link this up to any ImagePack file, however assuming the filename is based on Em ID, there does seem to be a 00000009.pack file, which contains these textures:
image

Maybe the Tyrant enemy that's also from REmake? https://www.evilresource.com/images/data/full/remake/tyrant.png?2a027f3f

... so the only thing stopping this Em09 Tyrant AI from being activated might just be a missing ImagePack link & call to Em09's prolog setup? Does anyone dare look further? 😄

Misc

Small miscellaneous things that seem to go unused:

  • em3cPartsBombSet: has a param that allows choosing different part number & delay time, a ton of different values are defined, but param is only ever set to 0?
  • CameraQuasiFPS::move contains a switch statement between 4 different modes that can change how the camera works, only 2 of these are actually used though (mode 0 and mode 2), the rest go unused.
@emoose
Copy link
Owner Author

emoose commented Nov 30, 2022

E: clarifying some things I've seen mentioned about the unused RE4 Tyrant:

  • The method here replaces Em2d (Novistador) with the Em09 (Tyrant) AI code & data, none of the Novistador AI is used, all gets replaced to call the unused Em09/cEm09 code instead (the improved method linked below can even register Em09 as it's own separate Em, without replacing any existing one 🐱)
  • There's no real reason for choosing Em2d specifically, was just a convenient Em to replace (if I'd thought more about it first and picked a better one maybe wouldn't have needed the cEmWrap::ckFindPL patch...)
  • Don't think UHD was the first version with these leftovers, I just know that's a version that includes both the AI code + data for it.
    IIRC the GC debug build might have included the code but without data for it, UHD is pretty special since it also included a bunch of unused room data too (mentioned above), so maybe the Em09 data was just another thing accidentally included.
    UHD is pretty near to a direct port of the X360 HD edition though, so maybe the unused rooms/Em09 data originated there.

Had a play around changing some things with CE:

bio4_22-11-30_15-25-21-511-2.webm

To get that working using Cheat Engine:

  • load game to main menu
  • change em2d AI code prolog pointer to use em09 prolog func instead: bio4.exe+7A548C -> 004099BC (4 bytes, hex)
  • change em2d udas filename to use em09 udas: bio4.exe+714F3C -> em/em09.das (string)
  • change imagepack link for em2d to use 09 imagepack: bio4.exe+53C9C7+6 -> 09 (4 bytes, hex)
  • break cEmWrap::ckFindPL func that the stage calls (would try checking if this is em2d and call a vtable func on it if so, cEm09 doesn't have the vtable func setup though, so make it check for random em number instead): bio4.exe+4D934F+1 -> 8E (byte, hex)
  • area jump into R205

Addrs are for 1.1.0 with relocations disabled

(E: a method of adding it properly instead of replacing an existing Em class is at #22 (comment), now to start trying to fix the broken AI actions...)

@nipkownix
Copy link

Wait, em09 is a Tyrant?! No way! This is incredible!
@albertre4HD you gotta see this!

Would be amazing if we could add an option in re4_tweaks to randomly replace enemies with Tyrants or something like that.

@emoose
Copy link
Owner Author

emoose commented Nov 30, 2022

Seems along with what's in that vid it also has a death anim too after enough hits, some reason handgun shots make a blood splatter effect but doesn't make it have any pain anim like the knife hit did in the video, weird. (does seem to have some wep ID checks in the damage code...)

Editing the code to use R1_Anger does let it start running toward you + swiping though, there's a bunch of places that need to be edited for that to work, but think it might be able to use R1_Anger without edits if some flag is set.
At around 0x426DD3 it's checking player distance along with that flag, if the checks pass it sets R1_Anger (0x401), otherwise it uses R1_Walk (0x101) - R1_Anger itself also checks the same flag at 0x427181, goes back to R1_Walk if it's not set, or to R1_Dash_S if it is.

Not sure what's meant to set up that flag, wasn't able to find anything to set it in-game by attacking or anything, maybe that's something that's meant to be set by the room code? (haven't played REmake so not sure how it works there 😅)
(E: oh em09RouteCk does set that flag if RouteCkToPos returns true - guess that's whether it's able to find a route to the player, not sure why it would have returned false there...)

Would be great if this could be setup to work as its own Em instead of needing to replace existing one, then could probably just change the Em ID inside the ESL/EM_LIST stuff to swap it with any enemy we like, will need to try looking more into how that Em loading stuff works...

E: seems once it gets into the R1_Walk state it's stuck there unless the player damages it, which can be seen in the vid too, attacking it puts it back into R1_Wait, which then checks if player is close enough to attack & uses R1_Harai / R1_Turn90_Harai if so.

Walk only has code to go back to Wait if player HP is 0, otherwise it just keeps walking, strange, maybe something was removed in there.

@Mister-Curious
Copy link

Would be great if this could be setup to work as its own Em instead of needing to replace existing one, then could probably just change the Em ID inside the ESL/EM_LIST stuff to swap it with any enemy we like, will need to try looking more into how that Em loading stuff works...

Great finds! Please let me know if you would like me to make any models with working TPL files for your experiments. I am eager to see if this can all be used, as I have been using these enemies for my mod, but had to replace certain enemies for them (using Verdugo for the Tyrant, and Novistadors for the Seekers).

@albertre4HD
Copy link

Ha! So it can be used after all! I found the textures but I thought it wasn't used
em06 texture pack is a Hunter huhuhu
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants