Technical Specs for "Everyone is Bi" Mod

This document outlines the custom assembly modifications made to RF4S.exe to unlock same-sex relationships in Rune Factory 4 Special. Below is a breakdown of the modified code sections, what they do, and why they were implemented this way.

Custom Logic for Friendship Menu Icons

RF4S.exe+227380 - 0FB7 C1- movzx eax,cx
RF4S.exe+227383 - 83 F8 01 - cmp eax,01 { 1 }
RF4S.exe+227386 - 74 3A - je RF4S.exe+2273C2
RF4S.exe+227388 - 83 F8 02 - cmp eax,02 { 2 }
RF4S.exe+22738B - 74 35 - je RF4S.exe+2273C2
RF4S.exe+22738D - 83 F8 04 - cmp eax,04 { 4 }
RF4S.exe+227390 - 74 30 - je RF4S.exe+2273C2
RF4S.exe+227392 - 83 F8 05 - cmp eax,05 { 5 }
RF4S.exe+227395 - 74 2B - je RF4S.exe+2273C2
RF4S.exe+227397 - 83 F8 07 - cmp eax,07 { 7 }
RF4S.exe+22739A - 74 26 - je RF4S.exe+2273C2
RF4S.exe+22739C - 83 F8 08 - cmp eax,08 { 8 }
RF4S.exe+22739F - 74 21 - je RF4S.exe+2273C2
RF4S.exe+2273A1 - 83 F8 09 - cmp eax,09 { 9 }
RF4S.exe+2273A4 - 74 1C - je RF4S.exe+2273C2
RF4S.exe+2273A6 - 83 F8 0B - cmp eax,0B { 11 }
RF4S.exe+2273A9 - 74 17 - je RF4S.exe+2273C2
RF4S.exe+2273AB - 83 F8 0D - cmp eax,0D { 13 }
RF4S.exe+2273AE - 74 12 - je RF4S.exe+2273C2
RF4S.exe+2273B0 - 83 F8 0F - cmp eax,0F { 15 }
RF4S.exe+2273B3 - 74 0D - je RF4S.exe+2273C2
RF4S.exe+2273B5 - 83 F8 11 - cmp eax,11 { 17 }
RF4S.exe+2273B8 - 74 08 - je RF4S.exe+2273C2
RF4S.exe+2273BA - 83 F8 14 - cmp eax,14 { 20 }
RF4S.exe+2273BD - 74 03 - je RF4S.exe+2273C2
RF4S.exe+2273BF - 31 C0 - xor eax,eax
RF4S.exe+2273C1 - C3 - ret
RF4S.exe+2273C2 - B8 01000000 - mov eax,00000001 { 1 }
RF4S.exe+2273C7 - C3 - ret

This section of code originally checked the player’s gender and displayed hearts only for characters of the opposite gender. I replaced this logic with a simpler check based on character IDs to show hearts for all bachelors and bachelorettes, regardless of the player’s gender.

The original function was much larger and more complex. I NOP’d the original instructions and replaced them with this custom logic.

Custom Logic to Detect Confession Events

RF4S.exe+2273C8 - 81 3F 07000716 - cmp [rdi],16070007 { (0) }
RF4S.exe+2273CE - 75 0C - jne RF4S.exe+2273DC
RF4S.exe+2273D0 - 83 79 40 01 - cmp dword ptr [rcx+40],01 { 1 }
RF4S.exe+2273D4 - 75 06 - jne RF4S.exe+2273DC
RF4S.exe+2273D6 - C6 41 40 00 - mov byte ptr [rcx+40],00 { 0 }
RF4S.exe+2273DA - EB 12 - jmp RF4S.exe+2273EE
RF4S.exe+2273DC - 81 3F 07820007 - cmp [rdi],07008207 { (0) }
RF4S.exe+2273E2 - 75 0A - jne RF4S.exe+2273EE
RF4S.exe+2273E4 - 83 79 40 00 - cmp dword ptr [rcx+40],00 { 0 }
RF4S.exe+2273E8 - 75 04 - jne RF4S.exe+2273EE
RF4S.exe+2273EA - C6 41 40 01 - mov byte ptr [rcx+40],01 { 1 }
RF4S.exe+2273EE - 0FB6 17- movzx edx,byte ptr [rdi]
RF4S.exe+2273F1 - 8D 42 FF - lea eax,[rdx-01]
RF4S.exe+2273F4 - E9 1D6E0100 - jmp RF4S.exe+23E216

This custom function detects love confession events by checking for specific byte patterns in the data structure passed to the game’s state machine.

  • Male confession events contain the 4-byte value 16070007.
  • Female confession events contain the 4-byte value 07008207.

The mod uses these values to detect when a confession event is occurring. Based on whether the detected value contains 82 or 00, the mod flips the player’s gender flag so that the character’s gender check always receives a compatible value.

This way, the gender value flip only happens for love confession checks, which only affects whether you can confess or get friendzoned. All other game systems, like dialogues, your title in the Order Symbol, bathhouse placement, etc., still receive the value for your chosen gender. In theory, the only time you would get misgendered is in cases where gender is not checked and references are hardcoded (for example, in dialogue where they explicitly use he/she instead of the typical placeholder).

This function is placed in the space previously occupied by the friendship menu logic, right after the new friendship menu checks.

Jump Instruction to Custom Logic

RF4S.exe+23E210 - E9 B391FEFF - jmp RF4S.exe+2273C8
RF4S.exe+23E215 - 90 - nop

The game’s original instructions were moved to make space for a jump instruction, which redirects the game’s flow to the custom confession detection logic.

The two original instructions were moved to the new function’s end to preserve the original flow of the game’s logic, and after the custom function is completed, it jumps back to continue the original flow.

Code Reusability and Potential Side Effects

From my understanding, the game’s code seems to use some sort of a state machine to handle a wide variety of in-game logic and events.

In this case, it appears that a data structure is passed to the state machine, and various code paths are executed depending on the provided data. This makes the game’s code highly reusable but also introduces potential risks when modifying it.

For example, modifying the gender check logic for confession events caused unintended side effects during the Order tutorial. This happened because the same operations was reused for another system.

The way I chose to detect a love confession event was by checking the 4 bytes around the value that contains the character’s gender. However, it’s possible that other events might use the same byte pattern, leading to unexpected behavior.

While my testing hasn’t found any major issues, the potential for side effects exists. I recommend keeping an eye out for any unusual behavior and reporting any bugs found.

Summary of Key Changes

1. Friendship Menu Logic:
  • Replaced gender-based heart assignment with a simple ID check.
  • NOP’d the original function and replaced it with custom logic.
2. Confession Event Detection:
  • Detects love confessions using the byte patterns `16070007` (male) and `07008207` (female).
  • Flips the player’s gender flag to ensure compatibility during confession events.
3. Jump Instruction:
  • Added a jump to the new confession detection logic.
  • Moved the original instructions to preserve the game’s original flow.

Note: The game’s code is highly interconnected, and modifying one part can impact other systems. I’ve done my best to minimize side effects, but given the state machine structure, it’s possible that other events could be unintentionally affected by these changes. Please report any issues you find during gameplay.

Article information

Added on

Edited on

Written by

0x8f00ff

0 comments