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

Added a section covering the recompilation of flowscripts in P3RE #19

Merged
merged 4 commits into from
Dec 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 75 additions & 0 deletions flowscript/p3re-pc/compilation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
---
title: Recompiling Flowscripts
layout: page
parent: P3RE Flowscript Editing
grand_parent: Flowscript
nav_order: 1
games: ['P3RE']
---

<details open markdown="block">
<summary>
Table of contents
</summary>
{: .text-delta }
1. TOC
{:toc}
</details>

## Introduction

This section covers recompiling previously decompiled flowscript files (BF_*.flow files) so you can actually test them ingame.

## Pre-requisites

The pre-requisites are the same as those in the [Decompiling Flowscripts Section]({%link flowscript/p3re-pc/decompilation.md %}).

## Recompiling FlowScripts

### Using the Unreal Atlus Script Mod

{: .warning }
>Atlus Script Library P3R support is still WIP. Compiled flowscripts might cause crashes; this might be from incorrect settings I set in compilation/transferring P3R support to BF Emu fork or the compiler itself.

This method does not compile the flowscripts but can be used to replace flowscripts ingame. This method is also superior to replacing compiled flowscript files directly via Unreal Essentials as you can use the UE Atlus Script API to add your assets via code. An example use case can be a config option where you can let users enable or disable what text changes/flowscript changes they want ingame. You also don't have to deal with any of the V4/V4BE Format related issues most of the time.

1. Create a mod with a Mod Dependency on Unreal Atlus Script.

2. In your mod's folder, create a folder named ue-atlus-script.

3. Place any replacement .flow files here. The file must have the same name as the asset it's replacing.

4. For example, BF_FldInitScript_102.uasset would be replaced by adding BF_FldInitScript_102.flow.

5. Files can be nested in folders for organization.

{: .info }
>EPISODE AIGIS: Many scripts were duplicated in the Astrea folder for the DLC. To replace Astrea scripts, place files in an astrea folder inside of ue-atlus-script.

### Using Atlus Script GUI

{: .warning }
>Flowscripts can be compiled using 2 different Outformats V4BE and V4. To figure out which one you need check what format you originally used to decompile the flowscript. You will get no errors during compilation if you use the wrong format but loading the flowscript ingame will not work.

1. Launch the app and on the top right corner click on game and then select Persona 3 Reload from the list.

2. If your Outformat is V4BE check if the Big Endian .FLOW (P3RE) option has a checkmark next to it. This option can be found under the Options tab. If your Outformat is V4 make sure it is disabled.

3. Now drag any BF_*.flow file over the "Drag a .Flow or .Msg to Compile" box.

### Using Atlus Script Tools Cli

{: .warning }
>Flowscripts can be compiled using 2 different Outformats V4BE and V4. To figure out which one you need check what format you originally used to decompile the flowscript. You will get no errors during compilation if you use the wrong format but loading the flowscript ingame will not work.

Use the following command in Command Prompt or Windows Powershell to recompile a BF_*.flow file.

V4 Outformat Command:
```
AtlusScriptCompiler -In <Path to BF_*.flow> -Compile -Library P3RE -Encoding UTF-8 -OutFormat V4
```

V4BE Outformat Command:
```
AtlusScriptCompiler -In <Path to BF_*.flow> -Compile -Library P3RE -Encoding UTF-8 -OutFormat V4BE
```
23 changes: 17 additions & 6 deletions flowscript/p3re-pc/decompilation.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ games: ['P3RE']

## Introduction

Flowscripts are responsible for handling logic during gameplay in almost all Persona games and several other Atlus entries. For example, enemy AI, setting and checking flags for displaying dialog, starting scripted battles etc. They are stored in BF_*.uasset files.
Flowscripts are responsible for handling logic during gameplay in almost all Persona games and several other Atlus entries. For example, enemy AI, setting and checking flags for displaying dialog, starting scripted battles etc. They are stored in BF_*.uasset files. This section will cover decompiling these files so you can modify them.

## Pre-requisites

Expand All @@ -31,6 +31,9 @@ There are a couple of options you can go with to decompile flowscripts but gener

4. [**Atlus Script Tools Cli**](https://github.com/tge-was-taken/Atlus-Script-Tools) is the tool you should use if you have experience working in command prompt/powershell and need to decompile BF files that you find via Fmodel.

{: .info }
>After installing Atlus Script Tools it is recommended that you add the program to your systems PATH so it can be accessed from any folder.

## Decompiling FlowScripts

### Using the Unreal Atlus Script Mod
Expand All @@ -47,24 +50,32 @@ There are a couple of options you can go with to decompile flowscripts but gener

### Using Atlus Script GUI

{: .warning }
>Flowscripts can be decompiled using 2 different Outformats V4BE and V4. To figure out which one you need to try any one of them and if you get any errors during decompilation try the other outformat.
>Be sure to note down what format you used (V4/V4BE) to decompile the file as that will be required when you try to recompile it.

1. After installing Atlus Script GUI (Must be a newer version than v3.5). Launch the app and on the top right corner click on game and then select Persona 3 Reload from the list.

2. Now drag any BF_*.uasset file over the "Drag a .BF or .BMD to decompile" box.
2. Now drag any BF_*.uasset file over the "Drag a .BF or .BMD to Decompile" box. It will now try to decompile the file using the V4 OutFormat if the Big Endian .FLOW Option isn' enabled.

3. If decompilation fails then click on Options and then on Big Endian .FLOW (P3RE). There should now be a checkmark next to it. Now the app will try to decompile the file using the V4BE OutFormat.

![]({%link assets/images/flowscript/p3re-pc/AtlusScriptGuiGameSetting.png %})

### Using Atlus Script Tools Cli
After installing Atlus Script Tools (It is recommended that you add the program to your systems PATH so it can be accessed from any folder but not required.) use the following command to decompile a BF_*.uasset file.

{: .warning }
>Flowscripts can be decompiled using 2 different Outformats V4BE and V4. To figure out which one you need to try any one of them and if you get any errors during decompilation try the other outformat.
>Flowscripts can be decompiled using 2 different Outformats V4BE and V4. To figure out which one you need to try any one of them and if you get any errors during decompilation try the other outformat.
>Be sure to note down what format you used (V4/V4BE) to decompile the file as that will be required when you try to recompile it.

Use the following command in Command Prompt or Windows Powershellto decompile a BF_*.uasset file.

V4 Outformat Command:
```
AtlusScriptCompiler <Path to BF_*.uasset> -Decompile -Library P3RE -Encoding UTF-8 -OutFormat V4
AtlusScriptCompiler -In <Path to BF_*.uasset> -InFormat FlowscriptBinary -Decompile -Library P3RE -Encoding UTF-8 -OutFormat V4
```

V4BE Outformat Command:
```
AtlusScriptCompiler <Path to BF_*.uasset> -Decompile -Library P3RE -Encoding UTF-8 -OutFormat V4BE
AtlusScriptCompiler -In <Path to BF_*.uasset> -InFormat FlowscriptBinary -Decompile -Library P3RE -Encoding UTF-8 -OutFormat V4BE
```
Loading