Skip to content

Modding Enhancements

emoose edited this page Mar 22, 2023 · 8 revisions

re4_tweaks adds some new enhancements to RE4 that can help with mod development, such as extended file formats, and new command-line parameter support.

Mod Expansion

The "Mod Expansion" extends certain file formats used by the game to include extra features, such as model scaling & enemy speed changes.

By default the expansion isn't activated, EnableModExpansion must be set to True inside the re4_tweaks INI to enable it first.

  • Mod developers can include an INI override file with their mod data, to help ensure the expansion (or any other re4_tweaks features) will be enabled on the users game, see the "INI Overrides" section below for more info.

Right now only two formats have been extended, the ESL spawn lists, and ETS model files.

ESL

ESL entries have 4 bytes at the end (from 0x1C through 0x1F) which are normally unused by the game. re4_tweaks can change these 4 bytes to act as two 2-byte/16-bit (uint16_t) integers, which control the speed & scale of the enemy respectively.

  • Speed is read as uint16_t from 0x1C - 0x1D (inclusive)
  • Scale is read as uint16_t from 0x1E - 0x1F (inclusive)

The value is treated as a percentage to change the scale by, eg. a value of 150 would set the speed/scale to 150% of normal value (or 1.5x), while 50 would make it 50% (0.5x).

For the speed/scale changes to take effect the flags value of the entry (at byte 0x0) must have 0x40 added to it, otherwise re4_tweaks will ignore any speed/scale value set there. (eg. if the value at 0x0 is already set to 0x07, you must change it to 0x47)

  • Flags are read as uint8_t at offset 0x0 (add 0x40 to any existing flag value to enable the speed/scale modifications)

This is mostly to deal with an issue of the game sometimes creating ESL entries in memory with random data inside 0x1C-0x1F, the 0x40 flag just lets re4_tweaks know that the values there are valid/intended.

ETS

ETS entries contain 12 bytes reserved for the scale of the model, but for some reason the game never makes use of them, leaving them inoperable. re4_tweaks allows those 12 bytes to be used properly, and can also optionally allow them to be split into two scalars, one for the visual model, and one for the collision model.

Unfortunately some ETS entries included with the vanilla game already have (unused) data inside those 12 bytes for some reason, which break many things if activated, so re4_tweaks will require a flag value of 0x40 to be set at offset 0x3 into the ETS entry first, in order to confirm that the scale values were updated by the modder.

(However, since most ETS mod tools don't currently support our flag, you can skip the flag check by enabling the ForceETSApplyScale INI setting inside your override INI - make sure to remove those broken vanilla ETS scale values in your mod though!)

With the flag configured (or INI setting enabled), re4_tweaks will read the scale from 0x4 - 0xF as a normal Vec3f, like other scale values in the game (3 seperate floats for x / y / z scale), and apply the scale to both visual & collision model.

In case collision scale needs to be set separately to a different value, a "short mode" can be enabled, which splits the 12 bytes into two 6-byte scalars, that work the same as the ESL scalars above (ie. as percentages)

To enable this "short mode", the byte at 0x3 into the ETS entry must have 0x80 added to it (along with the 0x40 flag to activate scaling, so 0x80 + 0x40 = flag should be 0xC0)

  • Flags are read as uint8_t at offset 0x3 (set to 0x40 to activate ETS scaling, or 0xC0 to activate "short mode")

With ETS[0x3] set to 0x40 (or ForceETSApplyScale enabled):

  • Scale is read as Vec3f (X/Y/Z floats) from offset 0x4 - 0xF (inclusive)

With ETS[0x3] set to 0xC0:

  • Visual scale is read as three uint16s (X/Y/Z), from offset 0x4 - 0x9 (inclusive)
  • Collision scale is read as three uint16s (X/Y/Z), from offset 0xA - 0xF (inclusive)

Similar to ESL the "short mode" values are treated as a percentage that's applied onto the visual/collision scale value (value of 150 would set it to 150% / 1.5x scale, value of 25 would set it to 25% / 0.25x scale, etc)

Command-line parameters

re4_tweaks also allows some new parameters/launch options to be passed to the games bio4.exe when launching it, mainly to help with development/debugging (it's not recommended to use these for general gameplay!)

In addition to the parameters listed here, all INI settings from the re4_tweaks INI file can also be overridden with parameters, for example -SkipIntroLogos 1 -FOVAdditional 20.0 would force intro logos to be skipped & FOV 20 to be applied.

When using the following parameters all intro logos/screens will be skipped, to help minimize time needed to debug things:

  • -room rXXX (or -r rXXX) Will try making the game load straight into the given room, player model position is set based on the first entry for this room inside the roomInfo/area jump data. Optionally, -pos XX YY ZZ parameters can also be passed to force the player character to a certain position, instead of using the set area jump position.

  • -difficulty XXX (or -df XXX) Sets the difficulty level before loading into the room, can be useful if you need to test a room under a specific difficulty. Valid params: -difficulty veryeasy, -difficulty easy, -difficulty medium, -difficulty pro.

  • -load XX (or -l XX) Will load the savegame from the given slot number, slot number is based on the number shown in the savegame menu, so valid slots are 1 - 20.

  • -gamedir XXX (or -g XX) Allows overriding the BIO4 path that the game would normally load data from, so eg. you could keep different versions of your BIO4 folders next to each other, and share the same Bin32 contents (bio4.exe / re4_tweaks DLL & settings / etc) between them. Can either specify a single folder name to load from a folder next to where BIO4 is located (eg. BIO4_HD), or a full folder path can be specified instead (eg. C:\Games\RE4HD\BIO4)

Model Precaching

The game only seems to partly load in models during the actual "Loading.." screen, it's not until the models become actually visible on screen that the model will finish being loaded (maybe only actually uploads the models/textures to GPU once it's on screen)

Unfortunately this can cause framerate hitches in the game if many newly-seen models become visible at the same moment, this doesn't really ever happen in the vanilla game (besides maybe 1 occurrence), but some modders have ran into this issue many times already.

To work around this re4_tweaks includes a new PrecacheModels option, which can just force the game to treat all models on the stage as being visible on-screen for just a few ticks after the level loads in (then the precaching will be disabled) - this seems to help fix the stutter problem with no known drawbacks from it.

  • To enable simply set PrecacheModels = true in the re4_tweaks INI, or add that to your INI override file inside the [FRAME RATE] section.

INI Overrides

All re4_tweaks settings can be configured in a separate mod-specific "INI override" file, allowing mod authors to override any of the users settings.

These overrides can come in useful if you're creating a mod that depends on a certain re4_tweaks feature to always be enabled (or vice-versa, where a feature has to be disabled for the mod to work properly)

In that case you can ship a Bin32\re4_tweaks\setting_overrides\MyCoolMod.ini with your mod that includes the setting values you require, preferably named after your mod itself.

  • Recommend including the full folder structure with your mod, Bin32 -> re4_tweaks -> setting_overrides, only the folders themselves & your override INI are needed.

Any settings in your override-INI will always override the users saved INI file, so please make sure to only include settings that your mod actually requires! (in other words, try to keep your override-INI trimmed down to the minimum settings needed)

In case of user troubles with your mod, the dinput8.log file can be used to verify whether your override file has been loaded in for the user, eg. you should see a line such as:

Reading settings from: "C:\Program Files (x86)\Steam\steamapps\common\Resident Evil 4\Bin32\re4_tweaks\setting_overrides\MyCoolMod.ini"

roominfo data

re4_tweaks includes improved roominfo data inside our DLL (thanks to Zatarita for creating it!) - which fixes broken data & gives the rooms more descriptive names on the debug "area jump" page (also gets used by our trainers custom "area jump" tool too)

This data would normally read by the game from the debug\roominfo.dat file, but the default roominfo.dat data included with UHD is broken and doesn't allow the tools to work properly, so instead this file is ignored & our improved data will always override it.

However if you need to modify the roominfo data for any reason, you can instead write it into debug\roominfo_new.dat, and that should allow both the tool menu & the trainer "area jump" tools to make use of the new data.

(for modding feel free to make use of our roominfo.dat as a base, instead of the broken UHD version: https://github.com/nipkownix/re4_tweaks/blob/master/dllmain/roomInfo.cpp)

Clone this wiki locally