# Welcome

## Where Am I?

This is the **documentation** section of [ShrineFox.com](https://shrinefox.com). If you're not sure how to begin modding Persona games, or you need step-by-step instructions on specific tasks, you're in the right place.

{% hint style="success" %}
Last updated: 8/20/25

* Added latest information to the "Getting Started" page for [Persona 5 Royal (PC) Mod Support](/getting-started/persona-5-royal-pc-mod-support).
  {% endhint %}

## Prerequisites

The directions featured here assume that you have the following:

* A PC running a modern Windows OS (8 or higher).
* Hardware capable of running modern PC games or running emulation software.\
  **OR**\
  A game console capable of being modified with custom firmware.

## Supported Games/Platforms

* **🎩Persona 5**
  * Original ([PS3](/getting-started/persona-5-ps3-mod-support), [PS4](/getting-started/persona-5-royal-ps4-mod-support))
  * Royal ([PS4](/getting-started/persona-5-royal-ps4-mod-support), [Switch](/getting-started/persona-5-royal-switch-mod-support), [PC](/getting-started/persona-5-royal-pc-mod-support))
* 📺 **Persona 4**
  * Original ([PS2](/getting-started/persona-4-ps2-mod-support))
  * Golden ([PSVita](/getting-started/persona-4-golden-psvita-mod-support), [PC](/getting-started/persona-4-golden-pc-mod-support))
* **🌘 Persona 3**
  * FES ([PS2](/getting-started/persona-3-fes-ps2-mod-support))
  * Portable ([PSP](/getting-started/persona-3-portable-psp-mod-support))

## Supported Procedures

* Adding Mod Support
* Writing [Custom Scripts](/flowscript/intro-to-scripting)

## Future Plans

{% hint style="danger" %}
Much of this documentation is already partially present, but still under heavy construction. It still lacks the following information:

* [**Messagescript**](/flowscript/messagescript)**:** (Message Variables)
* [**Flowscript**](/flowscript/flowscript)**:** (Arrays, Enums, Loops, Conditionals, Functions, Importing Files, Menus, Library Functions, Examples)
* [**Mod Support**](/getting-started/persona-5-ps3-mod-support)**:** (SMT3, P4G, CFB, new PC/Switch ports of P3P/P4G)

See also: [personamodding.com](https://personamodding.com) (also under construction)
{% endhint %}


# Persona 5 Royal (PC) Mod Support

How to load modded files in P5R on PC - Updated 8/20/25

## Background

{% hint style="success" %}
The Switch/PC ports of **Persona 5 Royal** have become the most commonly modded version of P5, due to having the latest content, plus the convenience of running natively on PC. You will likely see less support for modding prior versions.
{% endhint %}

Persona 5 Royal is a [re-release of Persona 5, originally launched on PS3](/getting-started/persona-5-ps3-mod-support) and [PS4](/getting-started/persona-5-royal-ps4-mod-support) in 2019 (2020 in the west). Just like its predecessor, it's a JRPG with life-sim and dungeon crawling elements that involves summoning and fusing a party of Personas.

It features many quality of life improvements and a longer campaign, and has recently been ported to PC and Switch.

## Dumping Files (Optional)

<figure><img src="/files/7hxodULmAgvhOhEA11i5" alt=""><figcaption><p>In the CPK folder, .CPK files (CRIWare archives) are used to store the game's assets.</p></figcaption></figure>

In order to create your own mods, you'll want a copy of the game's unpacked files to work with. If you'll only be installing mods created by other users, you don't need to worry about this.

1. Find the game's directory. In your Steam library, you can right click P5R and choose `Manage` > `Browse Local Files`. (e.x. `C:\Games\Steam\steamapps\common\P5R`)
2. Download [`CriFsLib.GUI.zip`](https://github.com/Sewer56/CriFsV2Lib/releases) and extract it somewhere on your PC.
   1. The first time you run the program, you may be required to install a .NET framework. Do so as prompted.
3. Open `BASE.CPK` and right click anywhere in the window to Extract All.
   1. If you don't have the space on your PC, you can use "Extract Selected" instead.
   2. In this case, you can narrow down the list by searching for a term at the top of the window.
   3. Hold Ctrl to select multiple files, or hold Shift to select a range of files in a row.
4. Do the same with the `EN.CPK` (or whichever language you use).

{% hint style="info" %}
You can think of `BASE.CPK` and `EN.CPK` like zip folders that contain the game's many files. They are very compressed, so once unpacked, the contents become much larger. The unpacked files end up being about 62 GB in total, so make sure you have enough space free on your hard drive.
{% endhint %}

## Setting Up Reloaded II Mods

Thanks to Sewer56 and Lipsum (zarroboogs), Persona 5 Royal on PC now has support for loading modded files via Reloaded II mods, bypassing the need to repack `BASE.CPK` and use `EN.CPK` for mods.

{% hint style="success" %}
Thanks to Persona Essentials, this also allows you to merge many different formats using various "File Emulation Frameworks," such as [AWB](https://sewer56.dev/FileEmulationFramework/emulators/awb.html), [SPD](https://sewer56.dev/FileEmulationFramework/emulators/spd.html), [PAK](https://sewer56.dev/FileEmulationFramework/emulators/pak.html), and even [BF](https://sewer56.dev/FileEmulationFramework/emulators/bf.html) and [BMD](https://sewer56.dev/FileEmulationFramework/emulators/bmd.html). However, unlike Aemulus Package Manager (used for the old version of P5), this merging isn't handled automatically. Mods must format files in a specific way to be picked up by the file emulator. See [here for usage instructions](https://sewer56.dev/FileEmulationFramework/emulators/pak.html).
{% endhint %}

Once you follow these steps, you'll also be able to skip the opening logos and run the game even when the window is unfocused. You can also toggle each of these features in the mod's settings.&#x20;

1. Download [Reloaded-II](https://github.com/Reloaded-Project/Reloaded-II/releases) and extract `Releases.zip`.&#x20;
2. Run `ReloadedII.exe`. You may need to first install a few .NET runtimes as prompted.
3. Once ReloadedII is open, click the (+) button on the left of Reloaded-II. Navigate to where P5R is installed and add P5R.exe.
4. Once P5R is added, go to the mod browser (the first icon in the top left of Reloaded-II) and download any mod. Persona Essentials will install automatically.

## Creating Mods

Please refer to [this series of blog posts](https://shrinefox.com/blog/2025/08/17/p5r-modding-guide-2025-2-creating-new-mods/) for details on making your own P5R mods. The first entry focuses on getting set up in Reloaded-II and testing it with simple file swaps. Other installments of the guide cover the usage of various File Emulation Frameworks, as well as sound conversion, model importing, and more.

{% hint style="info" %}
At the time of writing, the tutorial series isn't fully completed. You can check its completion status [here](https://trello.com/c/mBH60At7/118-p5r-modding-tutorial-series).
{% endhint %}

## Porting Existing Mods

While a lot of things are the same between the PS4 version of P5R and the new ports, there are some major differences you need to take into account.

* The contents of most `.PAC` files are now loosely distributed.
* File paths are in uppercase now, but the game will still load lowercase files/folders.
* `.GNF` textures (used for Thieves Den images, bustups, and field textures) are now `.DDS`.
  * Texture `.BIN` files no longer use headerless `.DDS`.
* The audio format is still `.ADX`, but `.ACB`/`.AWB`/`.USM` [encryption keys](https://drive.google.com/file/d/1zHiVWwpjYipK-vrvUOAtCa9zplpel8km/view?usp=sharing) have changed.
* There are [additional flowscript functions](https://github.com/tge-was-taken/Atlus-Script-Tools/pull/48).

There are also dozens of other, tinier differences too specific to list here.


# Persona 5 Royal (Switch) Mod Support

How to load modded files in P5R (Switch CFW, RyujiNX, Yuzu) - Updated 10/29/22

## Background

{% hint style="success" %}
The Switch/PC ports of **Persona 5 Royal** have very recently released in October 2022. You may notice a community effort to shift focus to these versions, especially considering the restrictive complexity of PS4 modding.\
It only stands to reason that this would be the most popular edition of Persona 5 to mod, so expect very little community support for prior editions going forward.
{% endhint %}

Persona 5 Royal is a [re-release of Persona 5, originally launched on PS3](/getting-started/persona-5-ps3-mod-support) and [PS4](/getting-started/persona-5-royal-ps4-mod-support) in 2019 (2020 in the west). Just like its predecessor, it's a JRPG with life-sim and dungeon crawling elements that involves summoning and fusing a party of Personas.

It features many quality of life improvements and a longer campaign, and has just recently been ported to PC and Switch in 2022.

## Supported Platforms

Click one of the below links to read how to set up mod loading on your target platform.

{% content-ref url="/pages/4D1F66I8zEfj5DqqbZ1N" %}
[P5R Mods on Switch Console (CFW)](/getting-started/persona-5-royal-switch-mod-support/p5r-mods-on-switch-console-cfw)
{% endcontent-ref %}

{% content-ref url="/pages/FkKVqOjTRVtNxxuwBTYx" %}
[P5R Switch Mods on PC Emulator (Yuzu/RyujiNX)](/getting-started/persona-5-royal-switch-mod-support/p5r-switch-mods-on-pc-emulator-yuzu-ryujinx)
{% endcontent-ref %}

Once you have followed the relevant instructions, continue on below.

## Merging Downloaded Mods

To use community-made mods, or to eventually create your own, you'll need a mod manager called Aemulus. This allows you to merge multiple mods together for simultaneous use.

{% hint style="info" %}
Aemulus was made to "deep merge" modded files wherever possible by comparing them to the originals extracted from the game, greatly increasing compatibility between mods.
{% endhint %}

1. Download the latest release of [Aemulus Package Manager](https://github.com/TekkaGB/AemulusModManager/releases). Extract it somewhere on your PC using [7-zip](https://www.7-zip.org/).&#x20;
2. Choose `Persona 5 Royal (Switch)` in the games dropdown.
3. Click the `Settings` button.
4. Click on `Extract Original Files` in order to improve mod merging. \
   Click on Extract Original Files in order to improve mod merging. You'll have to select the folder containing your `ALL_USEU.CPK` and `PATCH1.CPK` files. This can take a very long time due to the very efficient compression (35GB of files crammed into 15GB) so please be patient! This only has to be done once.
5. You can switch to the `GameBanana` tab to download community-submitted mods directly from the website. \
   You could also drop manually downloaded archives in the Packages folder and refresh Aemulus to load them. Just be aware that mods not made/updated specifically for use with the Switch version will probably not work.
6. Enable the mods you want to use via the checkboxes, and re-order their priority as desired.&#x20;
7. Click the Build button to output a new `PATCH1.CPK` that you can transfer to the following location, depending on your target platform:
   1. Switch: `sdmc:/atmosphere/contents/01005CA01580E000/romfs/CPK/PATCH1.CPK`
   2. Yuzu: `yuzu/load/01005CA01580E000/ModName/romfs/CPK/PATCH1.CPK`
   3. RyujiNX: `Ryujinx/mods/contents/01005CA01580E000/romfs/CPK/PATCH1.CPK`

## Enabling 60FPS

{% hint style="info" %}
At this time, the 60 FPS cheat only seems to work on actual Switch hardware due to how emulators handles the heap. See the next section for a method that works on all platforms.
{% endhint %}

Use the following cheat by DeathChaos to run the game at 60FPS. So far, there doesn't seem to be any game-breaking bugs or major drawbacks. Performance is mostly the same.

1. Download [`P5R_60_FPS_SWITCH.7z`](https://drive.google.com/file/d/1mpuXmib4aNy3gCJY3qeArFRROFmG-5J3/view?usp=sharing) and extract with [7-zip](https://www.7-zip.org/).
2. Place the `cheats` folder in the `sdmc:/atmosphere/contents/01005CA01580E000/` folder.

## Using Loose Files (Experimental)

Using Raytwo's [**p5rcbt**](https://github.com/Raytwo/p5rcbt) skyline plugin, you have the option to load modified files directly, *without* packing them into a `.CPK`. It also has 60 FPS patch built in-- which works for both consoles and emulators. Plus, it even features a way to log files as they're loaded.

1. Extract the contents of [release.zip](https://github.com/Raytwo/p5rcbt/releases) to your SD card.
2. Place modded files in either `sdmc:/p5r/` or `sdmc:/atmosphere/contents/01005CA01580E000/romfs/CPK/BIND`
3. Start the game and enjoy!

{% hint style="warning" %}
Aemulus has not been updated yet to support unpacked files at this time. However, most mods for the PC version should be directly compatible (provided you place the files in the right location!)\
\
The `/p5r/` and `/BIND/` folders are treated as the root. You do not need to place the files in a folder named after the `.CPK`.
{% endhint %}

## Porting Existing Mods

While a lot of things are the same between the PS4 version of P5R and the new ports, there are some major differences you need to take into account.

* The contents of `.PAC` files are now loosely distributed.
* File paths are in uppercase now, but the game will still load lowercase files/folders.
* `.GNF` textures (used for Thieves Den images, bustups, and field textures) are now `.DDS`.
  * Texture `.BIN` files no longer use headerless `.DDS`.
* The audio format is changed to `.HCA` (Switch only), and `.ACB`/`.AWB`/`.USM` [encryption keys](https://drive.google.com/file/d/1zHiVWwpjYipK-vrvUOAtCa9zplpel8km/view?usp=sharing) have changed.
* There are [additional flowscript functions](https://github.com/tge-was-taken/Atlus-Script-Tools/pull/48).

There are also dozens of other, tinier differences too specific to list here.


# P5R Mods on Switch Console (CFW)

P5R Mods on Switch console using Atmosphere

## Using Custom Firmware

{% hint style="success" %}
Although it is technically possible for Nintendo to detect Custom Firmware usage via online telemetry, there is no precedent for banwaves related to simply using CFW. You would need to pirate games, install homebrew launchers as homescreen apps, or cheat in online games in order to get your console/account banned.
{% endhint %}

In order to load modified files on console, we need to be running a custom firmware. \
All that's needed is:

1. A [**compatible Nintendo Switch**](https://ismyswitchpatched.com/) **console.**\
   Not all Switch units are compatible with current methods of booting CFW, due to the hardware exploit being patched. Most units sold before the release of Splatoon 2 are exploitable.
2. Files from the [**latest Atmosphere release .zip**](https://github.com/Atmosphere-NX/Atmosphere/releases) on your Switch's SD card.\
   Make sure to only update your console if there's a compatible Atmosphere release for the latest firmware, or you will lose the ability to load mods for the time being.
3. A **safe way to send the payload**, such as [a jig](https://www.ebay.com/sch/i.html?_nkw=switch+jig).\
   In order to perform the exploit, the Switch must be booted into RCM mode.\
   This special mode allows you to send a "payload" over USB-C, which we can use to launch CFW. \
   To access this mode, Pin 4 on the right-hand side joycon rail must be shorted out while the console is fully turned off, and **Power + Volume Up** is pressed.

{% hint style="warning" %}
The joycon rail pins are difficult to see, and shorting out the wrong pins will result in permanently damaging your console, so it's best to use a 3D-printed mold that slides into the joycon slot securely. It is **not recommended** to use a paper clip or tinfoil, or other such methods.
{% endhint %}

You will know that you have entered RCM mode when the Nintendo logo doesn't show up when you tap the Power button. If you connect the console to your PC via a USB-C, it should make a noise indicating a device was plugged in.

### Launching CFW via RCM

The first time you plug your console in while in RCM mode, it won't be recognized properly, so the correct drivers won't be loaded.&#x20;

1. Download and run [Zadig](https://zadig.akeo.ie/).
2. Select the device listed as "APX." \
   If you don't see it in the dropdown, click "Options" at the top and check "List All Devices."
3. Change the box on the right to **libusbK** and click "Install Driver."

Now that the driver is installed, you can follow these next steps each time you want to play the game with mods. CFW will remain applied until the next time the console reboots or shuts down.

1. Download and run [TegraRcmGUI](https://github.com/eliboa/TegraRcmGUI/releases).
2. Select the [`fusee.bin` file](https://github.com/Atmosphere-NX/Atmosphere/releases) downloaded from the latest Atmosphere release.
3. Send the payload. The program should show if it was successful, and you'll see the Atmosphere logo light up on the Switch.

### Transferring Files

Atmosphere CFW includes built-in LayeredFS support, meaning files in the SD card's `/atmosphere/contents/01005CA01580E000/romfs/CPK` folder get loaded automatically while the game is running, instead of the original files.

{% hint style="info" %}
Removing the SD card will require you to reboot the Switch, and therefore repeat the steps to enter RCM mode and send the payload over USB. To avoid doing that, keep your Switch in sleep mode rather than powering it off. If you want to change the files on your SD card, you can do it wirelessly via FTP homebrew.
{% endhint %}

To set up FTP...

1. Download [`ftpd.nro`](https://github.com/mtheall/ftpd/releases/download/v3.1.0/ftpd.nro) and place it in the /switch/ folder of your SD card.
2. On PC, install a [program such as Filezilla](https://filezilla-project.org/download.php?type=client).&#x20;
3. Connect your Switch to the same network as your PC.&#x20;
4. Launch the FTP-D homebrew via the Album icon on the home menu.
5. Simply enter the IP and port shown onscreen in your client and connect to begin transferring files.

### Dumping Files

In order to create your own mods, or merge existing mods using a Mod Manager, you'll want a copy of the game's files. The files are about 15 GB in total, so make sure you have enough space free on your SD card.

1. Download [`nxdumptool.nro`](https://github.com/DarkMatterCore/nxdumptool/releases/download/v1.1.15/nxdumptool.nro) and place it in the `/switch/` folder of your SD card.
2. Launch the NXDumpTool homebrew via the Album icon on the home menu.
3. Select P5R and dump RomFS content to SD card. This can take quite some time.
4. Once the files are dumped, copy them to PC.
5. If the `ALL_USEU.CPK` file was split up due to the SD Card being formatted as FAT32...

   1. Download and run [HxD](https://mh-nexus.de/en/downloads.php?product=HxD20).
   2. Go to `Tools` > `File Tools` > `Concatenate`
   3. Select each of the files in the `ALL_USEU.CPK` folder and make sure they're listed in order
   4. Save the `ALL_USEU.CPK` file somewhere on your PC.

   This also applies to the `.NSP` if you're dumping the game for emulation.

## Installing Mods

See the following section for mod installation directions.

{% content-ref url="/pages/2RGKMoyGv2G4Wqd4fe34" %}
[Persona 5 Royal (Switch) Mod Support](/getting-started/persona-5-royal-switch-mod-support)
{% endcontent-ref %}


# P5R Switch Mods on PC Emulator (Yuzu/RyujiNX)

P5R Switch Mods on PC using RyujiNX or Yuzu

## Getting Required Files

In order to run the game on a PC emulator, you will need the following files:

* prod.keys
* title.keys
* an NSP/XCI dump of the game
* a [Nintendo Switch firmware](https://darthsternie.net/switch-firmwares/)

Due to copyright and the potential for piracy, these cannot be provided directly, but you can either search online or dump them yourself from your Switch console.

### Dumping Keys

See [Launching CFW via RCM ](/getting-started/persona-5-royal-switch-mod-support/p5r-mods-on-switch-console-cfw#launching-cfw-via-rcm)for how to access RCM mode and launch a payload.

* Use [TegraRCMGUI](https://github.com/eliboa/TegraRcmGUI/releases) to launch the [lockpick homebrew](https://github.com/dezem/Lockpick_RCM/releases) and dump your keys.

### Dumping the NSP/XCI

See [Launching CFW via RCM ](/getting-started/persona-5-royal-switch-mod-support/p5r-mods-on-switch-console-cfw#launching-cfw-via-rcm)for how to boot into CFW and launch homebrew.

1. Download [`nxdumptool.nro`](https://github.com/DarkMatterCore/nxdumptool/releases/download/v1.1.15/nxdumptool.nro) and place it in the `/switch/` folder of your SD card.
2. Launch the NXDumpTool homebrew via the Album icon on the home menu.
3. Select P5R and dump as an `.NSP` file to SD card. \
   This can take quite some time. Make sure you have an extra 15 GB of space available on the SD.
4. If the `.NSP` file was split up due to the SD Card being formatted as FAT32...
   1. Download and run [HxD](https://mh-nexus.de/en/downloads.php?product=HxD20).
   2. Go to `Tools` > `File Tools` > `Concatenate`
   3. Select each of the files in the NSP folder and make sure they're listed in order.
   4. Save the `.NSP` file somewhere on your PC.

## Setting up your Emulator

1. Download [RyujiNX ](https://ryujinx.org/download)or [Yuzu](https://yuzu-emu.org/downloads/), and extract with [7-zip](https://www.7-zip.org/).
2. Follow the [Setup & Configuration Guide](https://github.com/Ryujinx/Ryujinx/wiki/Ryujinx-Setup-&-Configuration-Guide) for RyujiNX,\
   or the [Quickstart Guide](https://yuzu-emu.org/help/quickstart/) and [FAQ](https://yuzu-emu.org/wiki/faq/#how-do-i-use-mods-or-cheats) for Yuzu, which cover...
   1. How to add your keys to the emulator
   2. How to install the firmware
   3. How to load the game + any updates
   4. How to add mods to the game

## Extracting Files

In order to create your own mods, or merge existing mods using a Mod Manager, you'll want a copy of the game's files. The files are about 15 GB in total, so make sure you have enough space free.

1. Go to `Options` > `Settings` > `General` and add the directory containing your P5R `.NSP` or `.XCI` to the Game Directories list.
2. Right click the game in the list and choose `Extract Data` > `RomFS`.
3. Please be patient as this can take a very long time!

## Installing Mods

See the following section for mod installation directions.

{% content-ref url="/pages/2RGKMoyGv2G4Wqd4fe34" %}
[Persona 5 Royal (Switch) Mod Support](/getting-started/persona-5-royal-switch-mod-support)
{% endcontent-ref %}


# Manually Installing Switch Mods

Creating a CPK without using a Mod Manager - Updated 10/24/22

{% hint style="info" %}
This is an outdated method of installing mods, written before [Aemulus Package Manager](https://github.com/TekkaGB/AemulusModManager) was updated to support P5R Switch. These instructions are still included for those who rely on the original workflow.
{% endhint %}

Follow the steps on the [Persona 5 Royal (Switch) Mod Support page](/getting-started/persona-5-royal-switch-mod-support) to obtain the `ALL_USEU.CPK` and `PATCH1.CPK` files.

The game considers the root of each `.CPK` to be the same folder. `PATCH1.CPK` has higher load priority, since it's meant to override anything that needs to be updated. We can extract and then rebuild `PATCH1.CPK` with our modded files inside.

1. Download [`CriPakGUI-P5R.7z`](https://drive.google.com/file/d/1X9TPpQffaiqH-bFCedxO5gOqt1uw0U3a/view?usp=sharing) and extract with [7-zip](https://www.7-zip.org/).
2. Open `ALL_USEU.CPK` and click the **Extract Files** button to unpack the files to a folder.\
   The program may appear to freeze, this is normal. Please be patient as this can take a very long time.&#x20;
3. Do the same with the `PATCH1.CPK`.

{% hint style="warning" %}
You can think of `ALL_USEU.CPK` and `PATCH1.CPK` like zip folders. They are compressed, so once unpacked, the contents become much larger. The unpacked files end up being about 35 GB in total, so make sure you have enough space free on your hard drive.
{% endhint %}

1. Download and extract [`CpkMaker.zip`](https://drive.google.com/file/d/19RAhHnro19plJK53wAE02R5kFOfRA8Xq/view?usp=sharing) to the directory containing your unpacked `.CPK` folders.
2. Drag the `PATCH1.CPK_unpacked` folder onto `CPK.bat` to build a new `PATCH1.CPK` containing your modded files.
3. Transfer the new `PATCH1.CPK` to the directory matching your target platform.\
   Switch: `sdmc:/atmosphere/contents/01005CA01580E000/romfs/CPK`\
   RyujiNX: `/Ryujinx/mods/contents/01005CA01580E000/romfs/CPK`\
   Yuzu: `/yuzu/load/01005CA01580E000/ModName/romfs/CPK`

Be sure to match the directory structure of the extracted `.CPK`.\
On Switch, there's one extra thing to consider: the root of the `BASE.CPK` contains two folders, `BASE` and `EN`. But you can actually substitute either one with a folder called `PATCH1` and the files will still be loaded. For instance, if you're editing a file in the `ALL_USEU.CPK_unpacked/EN/INIT/` folder, copy it to your `PATCH1.CPK_unpacked/PATCH1/INIT` folder.

{% hint style="success" %}
Replacement files/folders can be uppercase or lowercase, it doesn't matter since the game loads them either way! Just make sure the `.CPK` filename is all uppercase.
{% endhint %}


# Persona 5 Royal (PS4) Mod Support

How to load modded files in P5(R) (PS4 HEN)

## Background

{% hint style="warning" %}
**Persona 5 Royal** has recently been ported to PC & Switch in 2022. You may notice a community effort to shift focus to that version, especially considering PS4 modding relies on not updating your console to the latest firmware, effectively locking you out of PSN and the latest games. It only stands to reason that this would be the least popular edition of Persona 5 to mod, so expect very little community support.
{% endhint %}

Persona 5 Royal is a [re-release of Persona 5, originally launched on PS3](/getting-started/persona-5-ps3-mod-support) and PS4 in 2019 (2020 in the west). Just like its predecessor, it's a JRPG with life-sim and dungeon crawling elements that involves summoning and fusing a party of Personas.&#x20;

It features many quality of life improvements and a longer campaign, and has just recently been ported to PC and [Switch](/getting-started/persona-5-royal-switch-mod-support) in 2022.

## HEN on PS4 Console

{% hint style="danger" %}
There is currently no decent way to emulate Persona 5 Royal on PC. [Spine](https://wololo.net/tag/Spine/), a PS4 compatibility layer for Linux, is in the works but the game isn't currently considered "playable."
{% endhint %}

We need to perform a one-time modification to the game itself in order to load modded files from an external mod.cpk archive.

The **only way** to play modified Playstation 4 titles on console is to **create and install a Fakesigned .PKG File** (known as a "FPKG") of Persona 5 Royal [obtained from the internet](https://lmgtfy.app/?q=dlpsgame+persona+5+royal), along with a **modded Update FPKG**-- more on that later.

The ability to install .PKG files is locked away in the System Settings's Debug menu, which is only accessible on developer units.

To get around this, you can temporarily escalate user permissions on certain firmwares. This is accomplished via a combination of kernel exploit and webkit exploit released by talented hackers.

{% hint style="danger" %}
Unfortunately, you **cannot update** to the latest firmware without losing your access to modded games. \
Also, the FPKG must be generated from the exact .PKG the base game was installed from, meaning even if you have a legit copy of the game installed you must uninstall it and use an illegitimate one. This poses a potential **console or account ban risk** if you ever go online with the console in the future.
{% endhint %}

### Exploitable Firmwares

* 5.05
* 6.72
* 7.02, 7.50 - 7.55
* 9.00 (with [USB dongle](https://wololo.net/2021/12/14/ps4-how-to-run-the-ps4-9-00-jailbreak-full-guide-with-goldhen-payload/))

Navigate to <https://cthugha.exploit.menu/> on your PS4's browser and choose your firmware.&#x20;

Then, choose GoldHEN.

Follow the instructions onscreen and if you're lucky a system message will appear letting you know HEN is running. If the payload fails, restart the console. You may have to hold the power button down for a few seconds if the console freezes.

## Adding Mod Support

The following steps only need to be completed once. Afterwards, each time you launch the game you can enjoy your patches and modded files.

{% hint style="warning" %}
Keep in mind: After doing this, the game will only be launchable while HEN is active.\
Each time the console reboots you will have to go to the PS4 browser and repeat the above steps to exploit the firmware again.
{% endhint %}

### Installing the Base Game FPKG

1. Put the .PKG of the [full base Persona 5 Royal game](https://lmgtfy.app/?q=dlpsgame+persona+5+royal) on a USB drive.
2. Insert the drive and go to System Settings > Debug > Game > Install PKG.
3. Select the .PKG file and install. It will overwrite the existing P5R copy already installed on the system.

### Installing the Patched Update FPKG

1. On PC, go to ShrineFox.com's [Get Started Page](https://shrinefox.com/getstarted?platform=PS4\&game=P5R\&region=USA).
2. Choose the region matching your installed Base Game FPKG.
3. Enable any desired optional patches.
4. Download the Update FPKG, or just the EBOOT.BIN if you want to [manually create your own FPKG](https://shrinefox.com/guides/2021/12/28/manually-patching-ps4-persona-games/).

Install it the same way as the Base Game FPKG and launch the game.

If all the steps above were done correctly, the game should open like normal with no errors, but the opening logos should be skipped immediately.

## Installing Mods

To use community-made mods, or to eventually create your own, you'll need a mod manager.

1. Download the [latest release](https://github.com/TekkaGB/AemulusModManager/releases) of Aemulus Package Manager.
2. Extract it somewhere on your PC [using 7-zip](https://www.7-zip.org/).
3. Choose **Persona 5 Royal** in the games dropdown, and click the Settings button.
4. Click on **Extract Original Files** in order to improve mod merging.

You can switch to the **GameBanana tab** to download community-submitted mods directly from the website. Enable them with the checkboxes and re-order their priority as desired.

{% hint style="danger" %}
Missing info:

* Including 1.0.2 Update Files in mod.cpk to prevent crashes
  {% endhint %}

Fill out the settings in Aemulus and click **Build** to generate the mod.cpk wherever you pointed the output to.&#x20;

Now you're ready to transfer it to PS4:

1. Start a FTP connection between PS4 and PC via the same webpage where you enable GoldHEN.
2. Transfer the mod.cpk to /data/p5r and create the folder if it doesn't already exist.
3. Repeat the above steps every time you build a new mod.cpk with Aemulus to update your mods on PS4!

## Extracting Files

If you are looking to create your own mods for this game, you will want a full dump of all the game's original, unedited files.

{% hint style="info" %}
Persona 5 Royal utilizes CriWare's .CPK archive format to store its individual files. You can think of it somewhat like a .zip file that contains the directory structure, but offers compression.
{% endhint %}

{% hint style="danger" %}
Missing info:

* Extracting files from Base Game FPKG
* Dumping files from PS4 via payload
  {% endhint %}

Use [CriPakGUI](https://github.com/CaptainSwag101/CriPakTools/releases) to open and extract the contents of each .CPK file to a folder.

{% hint style="success" %}
For simplicity, you can extract them all to the same folder (or merge folders later) if you'd like. It's not important which .CPK the files came from, because they all share the same directory structure when loaded by the game.
{% endhint %}

## Creating Mods

To begin exploring the files and learning how to edit them, see the [Persona 5 Royal](https://amicitia.miraheze.org/wiki/Persona_5_Royal) on the [Amicitia Wiki](https://shrinefox.com/wiki). Once you have an idea for a mod, open **Aemulus Package Manager** and click on the **New** button. Fill out the form and it will create a mod folder for you.

Inside the mod folder, **match the structure** of the extracted .CPK contents. For instance, if you're editing a file in the /init/ folder, copy the unedited one from your .CPK dump to your mod folder and place it in a /init/ folder.

## Troubleshooting

{% hint style="danger" %}
Missing Info:

* Errors launching game
* Success rate on certain firmwares
  {% endhint %}


# Persona 5 (PS3) Mod Support

How to load modded files in P5 (PS3 CFW & RPCS3)

## Background

{% hint style="info" %}
**Persona 5 (PS3)** has been around the longest out of all editions of P5. It therefore has the largest modding community, largest selection of mod & tool compatibility, and largest support base. However, with the recent release of **Persona 5 Royal** on PC & Switch, you may notice a community effort to shift focus to that version.
{% endhint %}

Persona 5 is a 2016 turn-based JRPG released by Atlus on PS3 and [PS4](/getting-started/persona-5-royal-ps4-mod-support). It features dungeon crawling and life-sim elements. Combat is mainly based on summoning and fusing a party of Personas with different elemental affinities.

The re-release, [Persona 5 Royal, launched on PS4](/getting-started/persona-5-royal-ps4-mod-support) a few years later, featuring many quality of life improvements and a longer campaign. It has just recently been ported to PC and [Switch](/getting-started/persona-5-royal-switch-mod-support) in 2022.

## Custom Firmware PS3 Console

{% hint style="danger" %}
This section is missing the following info:

* How to install CFW on the latest possible PS3 firmware
* How to install FTP Homebrew
* How to replace EBOOT.BIN and mod.cpk
  {% endhint %}

## RPCS3 Emulator

You can run this version of the game on PC using the **RPCS3 emulator**.

### Setting Up RPCS3

1. Download the [latest release](https://rpcs3.net/download) for your platform.
2. Extract anywhere on your PC using [7-zip](https://www.7-zip.org/).
3. Download any [PS3 firmware PS3UPDAT.PUP](https://darthsternie.net/ps3-firmwares/) file and install in RPCS3.
4. Download the .PKG file ([USA](https://zeus.dl.playstation.net/cdn/UP2611/NPUB31848_00/UP2611-NPUB31848_00-HDDBOOTPERSONA05_bg_1_c122979e59ce5776a3ce4418c242e51a5e7a81bc.pkg)/[EUR](https://zeus.dl.playstation.net/cdn/EP4062/NPEB02436_00/EP4062-NPEB02436_00-GPERSONA5X000001_bg_1_8b007b705f5c8aec892213cfa95629ee53453926.pkg)) and install the game in RPCS3.\
   OR\
   Obtain a .ISO file (dump your blu-ray disc with Custom Firmware PS3 or blu-ray drive).
5. If using a .PKG file, place a .RAP license in /dev\_hdd0/home/000000XX/exdata/\
   This license must match the region of .PKG you downloaded or dumped!
6. Launch the game to make sure it works!

For detailed instructions, see RPCS3 Wiki's [Help: Dumping Playstation 3 Games](https://wiki.rpcs3.net/index.php?title=Help:Dumping_PlayStation_3_games) page.

### Patching the Game

In order to load modded files, you need to patch the executable of the game to look for them in a custom mod.cpk archive. Fortunately, RPCS3 makes this fairly easy to do.

1. Go to ShrineFox.com's [Getting Started Page](https://shrinefox.com/getstarted?platform=PS3\&game=P5\&region=USA).
2. Follow the directions and enter the correct PPU Hash.
3. Enable any optional patches you'd like.
4. Download the patch.yml file and move it to RPCS3/patches.
5. In RPCS3, go to Manage > Game Patches and select No when prompted to download patches.
6. Enable the patches you'd like to use (including Mod Support) for your installed region/game version.
7. Run the game to check if patches work!

{% hint style="success" %}
An easy way to check if patches are working is to enable the **File Access Log** patch and launch the game. There's a tab named TTY near the bottom of the main RPCS3 window where you select a game. Click on it and you should see a list of files being printed as they are accessed while the game is running.
{% endhint %}

## Installing Mods

To use community-made mods, or to eventually create your own, you'll need a mod manager.

1. Download the [latest release](https://github.com/TekkaGB/AemulusModManager/releases) of **Aemulus Package Manager**.
2. Extract it somewhere on your PC [using 7-zip](https://www.7-zip.org/).
3. Choose **Persona 5** in the games dropdown, and click the Settings button.
4. Click on **Extract Original Files** in order to improve mod merging.

You can switch to the **GameBanana tab** to download community-submitted mods directly from the website. Enable them with the checkboxes and re-order their priority as desired.

Fill out the settings in Aemulus to point to the game's installed directory, or wherever you want the mod.cpk to be generated.&#x20;

Click **Build** and test it out in-game!\
Transfer the mod.cpk to the game's USRDIR folder on PS3 using FTP if you aren't using RPCS3.

## Extracting Files

If you are looking to create your own mods for this game, you will want a full dump of all the game's original, unedited files.

{% hint style="info" %}
Persona 5 utilizes CriWare's .CPK archive format to store its individual files. You can think of it somewhat like a .zip file that contains the directory structure, but offers compression.
{% endhint %}

On RPCS3, once the game is installed, you can right click it and choose "Open Install Folder" to view the files. In the "USRDIR" folder, there are several large files such as data.cpk and ps3.cpk.

On PS3, you can use FTP to navigate to dev\_hdd0\game\NPEB02436\USRDIR to view the same files. It may be more convenient to download a copy of the .PKG file ([USA](https://zeus.dl.playstation.net/cdn/UP2611/NPUB31848_00/UP2611-NPUB31848_00-HDDBOOTPERSONA05_bg_1_c122979e59ce5776a3ce4418c242e51a5e7a81bc.pkg)/[EUR](https://zeus.dl.playstation.net/cdn/EP4062/NPEB02436_00/EP4062-NPEB02436_00-GPERSONA5X000001_bg_1_8b007b705f5c8aec892213cfa95629ee53453926.pkg)) and extract using PKGView\.exe than to dump and transfer these files to PC.

Use [CriPakGUI](https://shrinefox.com/browse?post=cripakgui) to open and extract the contents of each .CPK file to a folder.

{% hint style="success" %}
For simplicity, you can extract them all to the same folder (or merge folders later) if you'd like. It's not important which .CPK the files came from, because they all share the same directory structure when loaded by the game.
{% endhint %}

## Creating Mods

To begin exploring the files and learning how to edit them, see the [Persona 5 page](https://amicitia.miraheze.org/wiki/Persona_5) on the [Amicitia Wiki](https://shrinefox.com/wiki). Once you have an idea for a mod, open **Aemulus Package Manager** and click on the **New** button. Fill out the form and it will create a mod folder for you.

Inside the mod folder, **match the structure** of the extracted .CPK contents. For instance, if you're editing a file in the /init/ folder, copy the unedited one from your .CPK dump to your mod folder and place it in a /init/ folder.


# Persona 4 Golden (PC) Mod Support

How to load modded files in P4G PC

## Background

{% hint style="info" %}
The internals of **Persona 4 Golden** on PC are largely the same as on its original release platform, the PSVita. Due to this, many mods are cross-compatible with a little tweaking. However, with the upcoming release of **Persona 4 Golden** on PC & Switch, you may notice a community effort to shift focus to that version.
{% endhint %}

Persona 4 Golden is a 2012 re-release of [the 2008 turn-based JRPG](/getting-started/persona-4-ps2-mod-support) released by Atlus on PS2. The game features dungeon crawling and life-sim elements. Combat is mainly based on summoning and fusing a party of Personas with different elemental affinities.

This re-release features many quality of life improvements and a longer campaign. It has recently been ported to PC and a Switch port will release in January 2023.

## Steam Version

### Mod Support Setup & Installing Mods

Please [see here](https://p4g.cep.one/) for a full guide on **setting up mod support** and **installing mods** for Persona 4 Golden on PC.

## Extracting Files

If you are looking to create your own mods for this game, you will want a full dump of all the game's original, unedited files.

{% hint style="info" %}
Persona 4 Golden on PC utilizes PreApp Partners' .CPK/.PAC archive format for storing files, which **aren't the same** as the .CPK/.PAC typically found in other Persona titles. Still, you can think of it somewhat like a .zip file that contains the directory structure, while offering compression.
{% endhint %}

On Steam, right click the game in your Library and choose Manage > Open Install Folder to view the files. There should be several large .PAC files and some .CPK files.

Download and unzip [TGE's preappfile program](https://github.com/tge-was-taken/preappfile/releases). Drag each of the .PAC or .CPK files onto the .EXE to automatically extract the contents to a folder.

{% hint style="success" %}
For simplicity, you can extract them all to the same folder (or merge folders later) if you'd like. It's not important which .CPK the files came from, because they all share the same directory structure when loaded by the game.
{% endhint %}

## Creating Mods

To begin exploring the files and learning how to edit them, see the [Persona 4 Golden page](https://amicitia.miraheze.org/wiki/Persona_4_Golden) on the [Amicitia Wiki](https://shrinefox.com/wiki). Once you have an idea for a mod, open **Aemulus Package Manager** and click on the **New** button. Fill out the form and it will create a mod folder for you.

Inside the mod folder, **match the structure** of the extracted .CPK/.PAC contents. For instance, if you're editing a file in the /init/ folder, copy the unedited one from your dump to your mod folder and place it in a /init/ folder.


# Persona 4 Golden (PSVita) Mod Support

How to load modded files in P4G (Vita CFW & Vita3K)

## Background

{% hint style="info" %}
**Persona 4 Golden** on PC is largely the same as on its original release platform, the PSVita. Due to this, many mods are cross-compatible with a little tweaking. However, with the upcoming release of **Persona 4 Golden** on PC & Switch, you may notice a community effort to shift focus to that version.
{% endhint %}

Persona 4 Golden is a 2012 re-release of the 2008 turn-based JRPG released by Atlus on PS2. The game features dungeon crawling and life-sim elements. Combat is mainly based on summoning and fusing a party of Personas with different elemental affinities.

This re-release features many quality of life improvements and a longer campaign.  It has recently been ported to PC and a Switch port will release in January 2023.

## Custom Firmware PSVita Console

You can run mods natively on the PSVita using a custom firmware known as h-encore. It is perfectly safe to do so and there's little to no risk of a ban or any irreversible damage to your console.

### Setting up the console for mods

To install custom firmware on your PSVita console, please follow the comprehensive step-by-step guide at [vita.hacks.guide](https://vita.hacks.guide/get-started.html). It will walk you through the entire process.

Once you have Vitashell installed on your PSVita, open it and press Select to start a FTP connection. As long as the Vita and your PC are connected to the same network, you can transfer files using a [program such as Filezilla](https://filezilla-project.org/download.php?type=client). Simply enter the IP and port shown onscreen in your client and connect.

1. Download [AutoPlugin2.vpk](https://github.com/ONElua/AutoPlugin2/releases) and transfer it to your Vita.
2. Install the `.VPK` with Vitashell and launch the newly created bubble on your home screen.
3. Use AutoPlugin2 to install the plugins [0syscall6](https://github.com/SKGleba/0syscall6/releases), [nonpdrm](https://sites.google.com/site/theleecherman/) (v1.4 by lman), and [rePatch](https://github.com/dots-tb/rePatch-reDux0/releases) (v3.0). Remove ref00d if you already have it installed.

### Patching the Game

In order to load modded files, you need to patch the executable of the game to look for them in a custom mod.cpk archive.

1. Go to ShrineFox.com's [Getting Started Page](https://shrinefox.com/getstarted?platform=PSV\&game=P4G\&region=USA).
2. Enable any optional patches you'd like.
3. Download the eboot.bin.
4. Use Vitashell to transfer it to `ux0:/rePatch/PCSE00120` (substitute the title ID for your game's region, create the folders if they don't already exist) on your Vita. Create the path if it doesn't already exist.
5. Run the game to check if patches work!

{% hint style="success" %}
An easy way to check if patches are working is to see if the intro logos get skipped when you start the game. With patches, you should immediately be greeted by the title screen.
{% endhint %}

## Vita3K Emulator

You can run this version of the game on PC using the **Vita3K emulator**.

### Setting Up RPCS3

1. Download the [latest release](https://vita3k.org/#download) for your platform.
2. Extract the .zip anywhere on your PC.
3. Download any [PSVita Firmware](https://www.playstation.com/en-us/support/hardware/psvita/system-software/) file and install in Vita3K.
4. Obtain a .VPK, .PKG, or decrypted archive of the game to run with Vita3K\
   OR\
   Dump your own from your CFW PSVita console.
5. Launch the game to make sure it works!

For detailed instructions on dumping your own game, see [Vita3K's Quickstart Guide](https://vita3k.org/quickstart.html).

### Patching the Game

In order to load modded files, you need to patch the executable of the game to look for them in a custom mod.cpk archive.

1. Go to ShrineFox.com's [Getting Started Page](https://shrinefox.com/getstarted?platform=PSV\&game=P4G\&region=USA).
2. Enable any optional patches you'd like.
3. Download the eboot.bin.
4. During Vita3K setup, it should have let you pick a folder to install the PSVita filesystem to.\
   By default, it's `%appdata%`. Navigate to the `ux0\app\PCSE00120` folder and replace the `eboot.bin` with the patched one you downloaded.
5. Run the game to check if patches work!

{% hint style="success" %}
An easy way to check if patches are working is to see if the intro logos get skipped when you start the game. With patches, you should immediately be greeted by the title screen.
{% endhint %}

## Installing Mods

To use community-made mods, or to eventually create your own, you'll need a mod manager.

1. Download the [latest release](https://github.com/tge-was-taken/Mod-Compendium/releases) of the Mod Compendium.
2. Extract it somewhere on your PC [using 7-zip](https://www.7-zip.org/).
3. Choose **Persona 4 Golden** in the games dropdown, and click the **Settings** button.
4. The **output path** should be where your mod.cpk file to be generated.

{% hint style="danger" %}
**Important**

Most of the mods available for P4G are made specifically for the PC version and are only compatible with Aemulus. As such, they must be **manually ported to the PSVita version** if they aren't already available in Mod Compendium format.
{% endhint %}

You can explore community-submitted mods and download them from [ShrineFox.com/Browse](https://shrinefox.com/browse?game=P4\&type=Mod). Extract the .zip to the Mod Compendium's Mods folder and refresh to enable/disable them. Change their order as needed with the up and down arrows on the side.

Click **Build** and test it out in-game! \
Transfer the **mod.cpk** to the game's **rePatch folder** on PSVita using FTP if you aren't using Vita3K.

## Extracting Files

If you are looking to create your own mods for this game, you will want a full dump of all the game's original, unedited files.

{% hint style="info" %}
Persona 5 utilizes CriWare's .CPK archive format to store its individual files. You can think of it somewhat like a .zip file that contains the directory structure, but offers compression.
{% endhint %}

On RPCS3, once the game is installed, you can right click it and choose "Open Install Folder" to view the files. In the "USRDIR" folder, there are several large files such as data.cpk and ps3.cpk.

On PS3, you can use FTP to navigate to dev\_hdd0\game\NPEB02436\USRDIR to view the same files. It may be more convenient to download a copy of the .PKG file ([USA](https://zeus.dl.playstation.net/cdn/UP2611/NPUB31848_00/UP2611-NPUB31848_00-HDDBOOTPERSONA05_bg_1_c122979e59ce5776a3ce4418c242e51a5e7a81bc.pkg)/[EUR](https://zeus.dl.playstation.net/cdn/EP4062/NPEB02436_00/EP4062-NPEB02436_00-GPERSONA5X000001_bg_1_8b007b705f5c8aec892213cfa95629ee53453926.pkg)) and extract using PKGView\.exe than to dump and transfer these files to PC.

Use [CriPakGUI](https://shrinefox.com/browse?post=cripakgui) to open and extract the contents of each .CPK file to a folder.

{% hint style="success" %}
For simplicity, you can extract them all to the same folder (or merge folders later) if you'd like. It's not important which .CPK the files came from, because they all share the same directory structure when loaded by the game.
{% endhint %}

## Creating Mods

To begin exploring the files and learning how to edit them, see the [Persona 4 Golden](https://amicitia.miraheze.org/wiki/Persona_4_Golden) page on the [Amicitia Wiki](https://shrinefox.com/wiki). Once you have an idea for a mod, open the **Mod Compendium** and click on the **New** button. Fill out the form and it will create a mod folder for you.

Inside the mod folder, **match the structure** of the extracted .CPK contents. For instance, if you're editing a file in the /init/ folder, copy the unedited one from your .CPK dump to your mod folder and place it in a /init/ folder.

## Porting Mods

{% hint style="danger" %}
Missing info:

* Recreating .PACs that contain changed files between PC/Vita
* Accounting for the different texture resolution
* Accounting for the different sound format
* Porting Aemulus mods to the Mod Compendium
  {% endhint %}


# Persona 4 (PS2) Mod Support

How to load modded files in P4 (PS2, PCSX2 & PS4)

## Background

{% hint style="info" %}
The original version of **Persona 4** has been around as long as the modding scene, so there is a decent amount of mods available. However, with the recent PC release and upcoming port of **Persona 4 Golden** on Switch, you may notice a community effort to shift focus to that version. Many mods are **not** directly compatible due to substantial differences between P4 and P4G.
{% endhint %}

Persona 4 is a 2008 turn-based JRPG released by Atlus on PS2. The game features dungeon crawling and life-sim elements. Combat is mainly based on summoning and fusing a party of Personas with different elemental affinities.

There is a [2012 re-release](/getting-started/persona-4-golden-psvita-mod-support) featuring many quality of life improvements and a longer campaign. It has recently been ported to [PC](/getting-started/persona-4-golden-pc-mod-support) and a Switch port will release in January 2023.

## Modded PS2 Console

{% hint style="danger" %}
Missing info:

* How to mod a PS2 console
* How to launch modded .ISOs
  {% endhint %}

## Custom Firmware PS3 Console

{% hint style="danger" %}
Missing info:

* How to mod a PS3 console
* How to launch modded PS2 .ISOs
  {% endhint %}

## HEN on PS4 Console

If you have a moddable PS4, it's possible to create and install custom PS2 titles, including modded games. Please note that this requires use of the paid software UltraISO. You're also welcome to try equivalent, free .ISO creation tools to see if they work.

{% hint style="warning" %}
These games will only be usable while in "HEN" mode, which you will lose access to if you update the system firmware. Also, due to these titles being illegitimate, there is always a possible account/console ban risk.
{% endhint %}

1. Obtain an .ISO of the game. For detailed instructions on dumping your own game as an .ISO, see [this wiki page](https://emulation.gametechwiki.com/index.php/Ripping_games#Sony_PlayStation_1/2).
2. Follow the [Persona 5 Royal (PS4) Mod Support](/getting-started/persona-5-royal-ps4-mod-support) page up until the "Adding Mod Support" section to get HEN running on your moddable PS4.
3. Download the latest release of the [Mod Compendium](https://github.com/tge-was-taken/Mod-Compendium/releases).
4. Extract it somewhere on your PC [using 7-zip](https://www.7-zip.org/).
5. Choose Persona 4 in the games dropdown, and click the Settings button.
6. Provide the path to your ISO and the output path.
7. Download any mods you want from [ShrineFox.com/Browse](https://shrinefox.com/browse?game=P4\&type=Mod). Extract them to the Mod Compendium's "Mods" folder.
8. In the Mod Compendium, click the checkboxes next to each mod to enable them, and sort their priority with the up/down arrows on the right.
9. Click Build and a new set of .CVM files and a new executable will be output.
10. Manually replace these files by dragging them in the ISO and saving as a new ISO using UltraISO Premium (paid software).
11. Create a .PKG from your new .ISO using [PS4 PS2 Classics GUI](https://github.com/xXxTheDarkprogramerxXx/PS3Tools/releases/tag/PS4-PS2-Classics-Release\(AppVoyer\)).
12. Install the .PKG using the same steps found at the end of the [Persona 5 Royal (PS4) Mod Support](/getting-started/persona-5-royal-ps4-mod-support) page.
13. Run the game to ensure that it works!

## PCSX2 Emulator

You can run this version of the game on PC using the **PCSX2 emulator**.

### Setting Up PCSX2

1. Download the [latest release](https://pcsx2.net/downloads/) for your platform.
2. Extract the .zip anywhere on your PC using [7-zip](https://www.7-zip.org/).
3. Download any [PS2 Firmware](https://www.mediafire.com/file/edp636rbtb77hk7/PS2_BIOS.zip) and install in PCSX2 during setup.
4. Obtain a .ISO of the game.
5. Launch the game to make sure it works!

For detailed instructions on dumping your own game as an .ISO, see [this wiki page](https://emulation.gametechwiki.com/index.php/Ripping_games#Sony_PlayStation_1/2).

### Patching the Game

In order to load modded files, you need to patch the executable of the game to look for them in an external directory. This patch is known as HostFS.

1. Go to ShrineFox.com's [Getting Started Page](https://shrinefox.com/GetStarted?platform=PS2\&game=P4\&region=USA).
2. Follow the instructions on the page to enter the game's CRC hash.
3. Enable any optional patches you'd like.
4. Download the .pnach file.
5. Close PCSX2. Place the .pnach in the folder called "**cheats**" next to PCSX2.exe.
6. Open the **PCSX2\_vm.ini** file in the PCSX2 folder with your text editor. \
   Change the line hostFS=disabled to **hostFS=enabled** then save and exit.
7. Make sure to check **on** the option **File > Enable Cheats** in PCSX2.
8. Open the game's .ISO with [7-zip](https://www.7-zip.org/). Extract the executable file, which should look like "SLUS\_217.82". Add the .ELF extension to it, which should give it the name "SLUS\_217.82.ELF."
9. Run the .ELF in PCSX2 to check if it works!

{% hint style="success" %}
An easy way to check if patches are working is to include the **Debug Log** patch and check if files are logged to the PCSX2 console as the game loads them. To view the console, go to **Misc > Show Console.**
{% endhint %}

## Installing Mods

To use community-made mods, or to eventually create your own, you'll need a mod manager.

1. Download the latest release of the [Mod Compendium](https://github.com/tge-was-taken/Mod-Compendium/releases).
2. Extract it somewhere on your PC [using 7-zip](https://www.7-zip.org/).
3. Choose Persona 4 in the games dropdown, and click the Settings button.
4. Provide the path to your ISO and the output path.\
   The output path should be where your extracted .ELF file is for PCSX2.\
   Also check the "HostFS mode" box if you're using PCSX2.

You can explore community-submitted mods and download them from [ShrineFox.com/Browse](https://shrinefox.com/browse?game=P4\&type=Mod). Extract the .zip to the Mod Compendium's Mods folder and refresh to enable/disable them. Change their order as needed with the up and down arrows on the side.

Press **Build** and it should merge and output the contents of the mods to your output directory!

{% hint style="warning" %}
**Note:** If you're not using PCSX2/HostFS mode, files will be output as new .CVM and a new executable. You must manually replace these files by dragging them in the ISO and saving as a new ISO using UltraISO Premium (paid software).
{% endhint %}

## Extracting Files

If you are looking to create your own mods for this game, you will want a full dump of all the game's original, unedited files.

{% hint style="info" %}
Persona 4 utilizes CriWare's .CVM archive format to store its individual files. You can think of it somewhat like a .zip file that contains the directory structure, but offers compression.
{% endhint %}

Open the game's .ISO with [7-zip](https://www.7-zip.org/). Click on each .CVM file and extract its contents to a file named after the CVM (i.e. DATA, BTL, BGM, ENV).

## Creating Mods

To begin exploring the files and learning how to edit them, see the [Persona 4 page](https://amicitia.miraheze.org/wiki/Persona_4) on the [Amicitia Wiki](https://shrinefox.com/wiki). Once you have an idea for a mod, open the **Mod Compendium** and click on the **New** button. Fill out the form and it will create a mod folder for you.

Inside the mod folder, **match the structure** of the extracted .CVM contents. For instance, if you're editing a file in the DATA.CVM's /INIT/ folder, copy the unedited one from your .CVM dump to your mod folder and place it in a DATA/INIT/ folder.


# Persona 3 Portable (PSP) Mod Support

How to load modded files in P3P (PSP, PPSSPP, Vita CFW, PS4 HEN)

## Background

{% hint style="warning" %}
**Persona 3 Portable** has an upcoming port to PC & Switch in January 2023. You may notice a community effort to shift focus to that version around that time. It only stands to reason that this will become the less popular edition of Persona 3 to mod once that happens, so expect very little community support.
{% endhint %}

Persona 3 Portable is a 2009 re-release of the [2006 turn-based JRPG released by Atlus on PS2](/getting-started/persona-3-fes-ps2-mod-support). The game features dungeon crawling and life-sim elements. Combat is mainly based on summoning and fusing a party of Personas with different elemental affinities.

This re-release features many quality of life improvements (although with the removal of anime cutscenes and 3d fields/events) and a new female protagonist. A new port to PC Switch will release in January 2023.

## Custom Firmware PSP Console

You can run mods natively on the PSP using a custom firmware. It is perfectly safe to do so and there's little to no risk of a ban or any irreversible damage to your console.

### Setting up the console for mods

To install custom firmware on your PSVita console, please follow the comprehensive step-by-step guide at [wololo.net](https://wololo.net/cfw4dummies/). It will walk you through the entire process.

## Custom Firmware PSVita Console

You can run mods natively on the PSVita using a custom firmware known as h-encore. It is perfectly safe to do so and there's little to no risk of a ban or any irreversible damage to your console.

### Setting up the console for mods

To install custom firmware on your PSVita console, please follow the comprehensive step-by-step guide at [vita.hacks.guide](https://vita.hacks.guide/get-started.html). It will walk you through the entire process.

Once you have Vitashell installed on your PSVita, [follow the guide on setting up Adrenaline](https://vita.hacks.guide/adrenaline.html), which opens up the built-in PSP mode to all the advantages of a CFW PSP console.

Once Adrenaline is installed, also obtain a .ISO or .UMD of Persona 3 Portable. For detailed instructions on dumping your own game, see [PPSSPP's FAQs page](https://www.ppsspp.org/faq.html).

Open VitaShell on the Vita and press Select to start an FTP connection. As long as the Vita and your PC are connected to the same network, you can transfer files using a [program such as Filezilla](https://filezilla-project.org/download.php?type=client). Simply enter the IP and port shown onscreen in your client and connect.

Move the game to ux0:pspemu/ISO (create the directory if it doesn't already exist).&#x20;

Now go into Adrenaline and launch the game to make sure it works!

## HEN on PS4 Console

If you have a moddable PS4, it's possible to create and install custom PSP titles, including modded games.

{% hint style="warning" %}
These games will only be usable while in "HEN" mode, which you will lose access to if you update the system firmware. Also, due to these titles being illegitimate, there is always a possible account/console ban risk.
{% endhint %}

1. Obtain an .ISO/.UMD of the game. For detailed instructions on dumping your own game as an .ISO, see [PPSSPP's FAQs page](https://www.ppsspp.org/faq.html).
2. Follow the [Persona 5 Royal (PS4) Mod Support](/getting-started/persona-5-royal-ps4-mod-support) page up until the "Adding Mod Support" section to get HEN running on your moddable PS4.
3. Extract the EBOOT.BIN from the game after opening it with [7-zip](https://www.7-zip.org/).
4. Patch `EBOOT.BIN` with the provided [xdelta](https://github.com/jmacd/xdelta-gpl) patches:

   ```
   xdelta -vfn merge -m intro.xdelta mod.xdelta tmp.xdelta
   xdelta -vfn -d -s EBOOT.BIN tmp.xdelta PATCHED_EBOOT.BIN
   ```
5. Download any mods you want in Aemulus, sort their priority and click Build to output a mod.cpk file.
6. Open the game with [UMDGen](https://shrinefox.com/browse?post=umdgen) and replace the EBOOT.BIN with the patched one. Add the mod.cpk file alongside the umd0.cpk and umd1.cpk files. Save as a new .ISO.
7. Create a .PKG from your new .ISO using [PS4 PSP Classics GUI](https://github.com/xXxTheDarkprogramerxXx/PS3Tools/releases/tag/PS4-PSP-Classics-GUI-\(AppVoyer\)).
8. Install the .PKG using the same steps found at the end of the [Persona 5 Royal (PS4) Mod Support](/getting-started/persona-5-royal-ps4-mod-support) page.
9. Run the game to ensure that it works!

## PPSSPP Emulator

You can run this version of the game on PC using the **PPSSPP emulator**.

### Setting Up PPSSPP

1. Download the [latest release](https://www.ppsspp.org/downloads.html) for your platform.
2. Extract the .zip anywhere on your PC.
3. Obtain a .ISO or .UMD, of the game to run with Vita3K\
   OR\
   Dump your own from your CFW PSP console.
4. Launch the game to make sure it works!

For detailed instructions on dumping your own game, see [PPSSPP's FAQs page](https://www.ppsspp.org/faq.html).

## Patching the Game

In order to load modded files, you need to patch the executable of the game to look for them in a custom mod.cpk archive (or loose files in a "bind" folder).

1. Download [a zip of the p3p-patches repo](https://github.com/zarroboogs/p3p-patches/archive/refs/heads/master.zip).
2. Extract the zip somewhere on your PC.
3. Copy the ULUS10512.ini file from the zip to `memstick\PSP\Cheats`. Create the folder if it doesn't exist yet.
4. If you're emulating the game on PPSSPP...
   1. go to `Settings > System > Enable Cheats` and make sure it's checked, since by default it won't be.
   2. Start the game and press `ESC`, then click on the `Cheats` menu.
5. If you're using a PSP, or Adrenaline on the PSVita...
   1. Install [CWCheat](https://www.cfwaifu.com/cwcheat-adrenaline/) and add the contents of `ULUS10512.ini` to `ms0:/seplugins/cwcheat/cheat.db`.
   2. Make sure to add `CHEAT ENABLE = 1` to `ms0:/seplugins/cwcheat/cwcheat.ini` so that patches may be applied on boot.
   3. Enable the patches you'd like to use via the cheats menu.
6. Run the game to check if patches work!

{% hint style="success" %}
An easy way to check if patches are working is to see if the intro logos get skipped when you start the game. With patches, you should immediately be greeted by the title screen.
{% endhint %}

{% hint style="warning" %}
If the CWCheat method doesn't work for you, you can unpack the game and directly patch `EBOOT.BIN` with the provided [xdelta](https://github.com/jmacd/xdelta-gpl) patches:

```
xdelta -vfn merge -m intro.xdelta mod.xdelta tmp.xdelta
xdelta -vfn -d -s EBOOT.BIN tmp.xdelta PATCHED_EBOOT.BIN
```

Overwrite the original `EBOOT.BIN` with the patched file, then repack and boot the game.
{% endhint %}

## Installing Mods

To use community-made mods, or to eventually create your own, you'll need a mod manager.

1. Download the [latest release](https://github.com/TekkaGB/AemulusModManager/releases) of Aemulus Package Manager.
2. Extract it somewhere on your PC [using 7-zip](https://www.7-zip.org/).
3. Choose **Persona 3 Portable** in the games dropdown, and click the Settings button.
4. Click on **Extract Original Files** in order to improve mod merging.

You can switch to the **GameBanana tab** to download community-submitted mods directly from the website. Enable them with the checkboxes and re-order their priority as desired.

Fill out the settings in Aemulus to point to the directory you want your mod.cpk (or loose "bind" files) to be generated.&#x20;

Click **Build** and test it out in-game!

## Extracting Files

If you are looking to create your own mods for this game, you will want a full dump of all the game's original, unedited files.

{% hint style="info" %}
Persona 3 Portable utilizes CriWare's .CPK archive format to store its individual files. You can think of it somewhat like a .zip file that contains the directory structure, but offers compression.
{% endhint %}

Open the game's .ISO/.UMD with [7-zip](https://www.7-zip.org/) and extract the following files from it:

* [umd0.cpk](https://amicitia.miraheze.org/wiki/Persona_3_Portable/umd0.cpk) (Most game data)
* [umd1.cpk](https://amicitia.miraheze.org/w/index.php?title=Persona_3_Portable/umd1.cpk\&action=edit\&redlink=1) (Event voice files)

Use [CriPakGUI](https://shrinefox.com/browse?post=cripakgui) to open and extract the contents of each .CPK file to a folder.

{% hint style="success" %}
For simplicity, you can extract them all to the same folder (or merge folders later) if you'd like. It's not important which .CPK the files came from, because they all share the same directory structure when loaded by the game.
{% endhint %}

## Creating Mods

To begin exploring the files and learning how to edit them, see the [Persona 3 Portable page](https://amicitia.miraheze.org/wiki/Persona_3_Portable) on the [Amicitia Wiki](https://shrinefox.com/wiki). Once you have an idea for a mod, open **Aemulus Package Manager** and click on the **New** button. Fill out the form and it will create a mod folder for you.

Inside the mod folder, **match the structure** of the extracted .CPK contents. For instance, if you're editing a file in the /init/ folder, copy the unedited one from your .CPK dump to your mod folder and place it in a /init/ folder.


# Persona 3 FES (PS2) Mod Support

How to load modded files in P3FES (PS2, PCSX2 & PS4)

## Background

{% hint style="info" %}
The original version of **Persona 3 FES** has been around as long as the modding scene, so there is a decent amount of mods available. However, with the upcoming port of **Persona 3 Portable** on PC/Switch, you may notice a community effort to shift focus to that version. Many mods are **not** directly compatible due to substantial differences between P3FES and P3P.
{% endhint %}

Persona 3 FES is a 2006 turn-based JRPG released by Atlus on PS2. The game features dungeon crawling and life-sim elements. Combat is mainly based on summoning and fusing a party of Personas with different elemental affinities.

There is [a 2009 re-release](/getting-started/persona-3-portable-psp-mod-support) featuring many quality of life improvements (although with the removal of anime cutscenes and 3d fields/events) and a new female protagonist. A new port to PC Switch will release in January 2023.

## Modded PS2 Console

{% hint style="danger" %}
Missing info:

* How to mod a PS2 console
* How to launch modded .ISOs
  {% endhint %}

## Custom Firmware PS3 Console

{% hint style="danger" %}
Missing info:

* How to mod a PS3 console
* How to launch modded PS2 .ISOs
  {% endhint %}

## HEN on PS4 Console

If you have a moddable PS4, it's possible to create and install custom PS2 titles, including modded games. Please note that this requires use of the paid software UltraISO. You're also welcome to try equivalent, free .ISO creation tools to see if they work.

{% hint style="warning" %}
These games will only be usable while in "HEN" mode, which you will lose access to if you update the system firmware. Also, due to these titles being illegitimate, there is always a possible account/console ban risk.
{% endhint %}

1. Obtain an .ISO of the game. For detailed instructions on dumping your own game as an .ISO, see [this wiki page](https://emulation.gametechwiki.com/index.php/Ripping_games#Sony_PlayStation_1/2).
2. Follow the [Persona 5 Royal (PS4) Mod Support](/getting-started/persona-5-royal-ps4-mod-support) page up until the "Adding Mod Support" section to get HEN running on your moddable PS4.
3. Download the latest release of the [Mod Compendium](https://github.com/tge-was-taken/Mod-Compendium/releases).
4. Extract it somewhere on your PC [using 7-zip](https://www.7-zip.org/).
5. Choose **Persona 3 FES** in the games dropdown, and click the Settings button.
6. Provide the path to your ISO and the output path.
7. Download any mods you want from [ShrineFox.com/Browse](https://shrinefox.com/browse?game=P4\&type=Mod). Extract them to the Mod Compendium's "Mods" folder.
8. In the Mod Compendium, click the checkboxes next to each mod to enable them, and sort their priority with the up/down arrows on the right.
9. Click Build and a new set of .CVM files and a new executable will be output.
10. Manually replace these files by dragging them in the ISO and saving as a new ISO using UltraISO Premium (paid software).
11. Create a .PKG from your new .ISO using [PS4 PS2 Classics GUI](https://github.com/xXxTheDarkprogramerxXx/PS3Tools/releases/tag/PS4-PS2-Classics-Release\(AppVoyer\)).
12. Install the .PKG using the same steps found at the end of the [Persona 5 Royal (PS4) Mod Support](/getting-started/persona-5-royal-ps4-mod-support) page.
13. Run the game to ensure that it works!

## PCSX2 Emulator

{% hint style="warning" %}
Consider reading [this more up-to-date guide](https://gamebanana.com/tuts/15959) on getting set up with mods on PC or Steam Deck.
{% endhint %}

You can run this version of the game on PC using the **PCSX2 emulator**.

### Setting Up PCSX2

1. Download the [latest release](https://pcsx2.net/downloads/) for your platform.
2. Extract the .zip anywhere on your PC using [7-zip](https://www.7-zip.org/).
3. Download any [PS2 Firmware](https://www.mediafire.com/file/edp636rbtb77hk7/PS2_BIOS.zip) and install in PCSX2 during setup.
4. Obtain a .ISO of the game.
5. Launch the game to make sure it works!

For detailed instructions on dumping your own game as an .ISO, see [this wiki page](https://emulation.gametechwiki.com/index.php/Ripping_games#Sony_PlayStation_1/2).

### Patching the Game

In order to load modded files, you need to patch the executable of the game to look for them in an external directory. This patch is known as HostFS.

1. Go to ShrineFox.com's [Getting Started Page](https://shrinefox.com/GetStarted?platform=PS2\&game=P3FES\&region=USA).
2. Follow the instructions on the page to enter the game's CRC hash.
3. Enable any optional patches you'd like.
4. Download the .pnach file.
5. Close PCSX2. Place the .pnach in the folder called "**cheats**" next to PCSX2.exe.
6. Open the **PCSX2\_vm.ini** file in the PCSX2 folder with your text editor. \
   Change the line hostFS=disabled to **hostFS=enabled** then save and exit.
7. Make sure to check **on** the option **File > Enable Cheats** in PCSX2.
8. Open the game's .ISO with [7-zip](https://www.7-zip.org/). Extract the executable file, which should look like "SLUS\_216.21". Add the .ELF extension to it, which should give it the name "SLUS\_216.21.ELF."
9. Run the .ELF in PCSX2 to check if it works!

{% hint style="success" %}
An easy way to check if patches are working is to include the **Debug Log** patch and check if files are logged to the PCSX2 console as the game loads them. To view the console, go to **Misc > Show Console.**
{% endhint %}

## Installing Mods

To use community-made mods, or to eventually create your own, you'll need a mod manager.

1. Download the [latest release](https://github.com/TekkaGB/AemulusModManager/releases) of Aemulus Package Manager.
2. Extract it somewhere on your PC [using 7-zip](https://www.7-zip.org/).
3. Choose **Persona 3 FES** in the games dropdown, and click the Settings button.\
   The output path should be where your extracted .ELF file is for PCSX2.
4. Click on **Extract Original Files** in order to improve mod merging.

You can switch to the **GameBanana tab** to download community-submitted mods directly from the website. Enable them with the checkboxes and re-order their priority as desired.

Fill out the settings in Aemulus to point to the directory containing your extracted .ELF. \
Click **Build** and test it out in-game!

{% hint style="warning" %}
**Note:** If you're not using PCSX2/HostFS mode, you must use the merged output files from Aemulus in a new Mod Compendium mod. When built with the Mod Compendium, files will be output as new .CVM and a new executable. You must manually replace these files by dragging them in the ISO and saving as a new ISO using UltraISO Premium (paid software).
{% endhint %}

## Extracting Files

If you are looking to create your own mods for this game, you will want a full dump of all the game's original, unedited files.

{% hint style="info" %}
Persona 4 utilizes CriWare's .CVM archive format to store its individual files. You can think of it somewhat like a .zip file that contains the directory structure, but offers compression.
{% endhint %}

Open the game's .ISO with [7-zip](https://www.7-zip.org/). Click on each .CVM file and extract its contents to a file named after the CVM (i.e. DATA, BTL, BGM).

## Creating Mods

To begin exploring the files and learning how to edit them, see the [Persona 3 FES page](https://amicitia.miraheze.org/wiki/Persona_3) on the [Amicitia Wiki](https://shrinefox.com/wiki). Once you have an idea for a mod, open the **Aemulus Package Manager** and click on the **New** button. Fill out the form and it will create a mod folder for you.

Inside the mod folder, **match the structure** of the extracted .CVM contents. For instance, if you're editing a file in the DATA.CVM's /INIT/ folder, copy the unedited one from your .CVM dump to your mod folder and place it in a DATA/INIT/ folder.


# Intro to Scripting

What the hey is all this?

Persona games feature their own built-in scripting engine. With a basic understanding of coding, you can build completely custom experiences into your mod. This is a chance for your creativity to shine as you work with the limited (yet robust) tools that the game provides us.

You do NOT have to have any prior knowledge of programming to follow this tutorial. However, I do recommend watching at least [the first 3 videos from Harvard's CS50 playlist](https://www.youtube.com/watch?v=IDDmrzzB14M\&list=PLhQjrBD2T380F_inVRXMIHCqLaNUd7bN4). A lot of the same concepts apply here, and these videos lay them all out for you in an easy-to-digest fashion.

{% embed url="<https://www.youtube.com/live/IDDmrzzB14M?feature=share>" %}
Harvard's CS50 YouTube playlist gets you familiar with thinking like a programmer and using code to solve real life problems.
{% endembed %}

## So, what is Scripting?

Scripting is the act of writing a scrip&#x74;**.**

* **Scripts** are a text files containing *human-readable* code. \
  These instructions are meant to be interpreted by another program, rather than your computer's processor.

<figure><img src="/files/gh7ANgmHELKzt2EbZWdo" alt=""><figcaption><p>An example of the kind of scripts you will see and be able to create in Persona 5.</p></figcaption></figure>

A program for interpreting scripts is called a compiler.

* **Compiling** is the act of converting human-readable code to machine language.
* A **Binary** is what we call the output, usually a single game file.

<figure><img src="/files/pPtCxP7CcxwjQt0tWOab" alt=""><figcaption><p>An example of a script being converted into a binary file using a compiler.</p></figcaption></figure>

Atlus games use scripts to perform various logical procedures.&#x20;

* Giving the player items, skills, or money
* Showing message windows or choosing options in a menu
* Playing sound effects or loading fields/events/battles
* *etc. etc. etc. ...*

<figure><img src="/files/6pUqNFUmberdMkJKnbOp" alt=""><figcaption><p>The compiled binary is unreadable to humans, but the game can understand it perfectly.</p></figcaption></figure>

I bet you can already picture how this opens tons of doors for modding. \
Scripts found in the game have **already been compiled**. \
Normally, we wouldn't be able to do much with these files, since **they only exist as binaries**.<br>

But thanks to clever reverse engineering, we have TGE's [**AtlusScriptCompiler**](/flowscript/atlusscriptcompiler).\
This program can:

* [**Decompile**](/flowscript/atlusscriptcompiler/run-via-commandline/decompile)`.BF`t&#x6F;**`.FLOW`**`and .BMD`t&#x6F;**`.MSG`**
* [**Compile**](/flowscript/atlusscriptcompiler/run-via-commandline/compile)`.FLOW`t&#x6F;**`.BF`**`and .MSG`t&#x6F;**`.BMD`**

## What is Flowscript?

To answer that, let's go over these proprietary Atlus binary formats.

* **BF** (`binary flow`)\
  The compiled form of Atlus's scripts.
* **BMD** (`binary message data`)\
  Another binary format often found embedded within`.BF` files. \
  These contain text and markup.

### .FLOW and .MSG

[AtlusScriptCompiler](/flowscript/atlusscriptcompiler) supports two unique script formats.

* [**Flowscript**](/flowscript/flowscript) (`.FLOW`) \
  A human-readable scripting language designed by TG&#x45;**.** \
  It mimics the original script format `.BF` files were created from.
* [**Messagescript**](/flowscript/messagescript) (`.MSG`) \
  TGE's answer to `.BMD`as a script format.\
  It contains text with markup that can be linked to a `.FLOW` script.

Altogether, this makes it possible to edit and create `.BF` and `.BMD` files.

### What does .FLOW look like?

[Flowscript](/flowscript/flowscript) (`.FLOW`) looks similar to **C**, so anyone familiar with object-oriented programming should feel right at home.

{% hint style="success" %}
Don't be intimidated! This guide is geared toward ***complete beginners***.\
By the end, you should be able to easily create your own scripts-- even if you've never programmed before.
{% endhint %}

The following is an example of a simple menu in Persona 5. See if you can surmise what's happening! The comments are there to help you make sense of things.

```csharp
// Import the MessageScript into the script
import( "TestScript2.msg" );

// Main Script Procedure
void Main()
{
	// Display dialog window (by message name)
	MSG_WND_DSP(); 
	// Display dialog (by message name)
	MSG( HelloDialog, 0 );
	// Display selection menu (by message index)
	int selection = SEL( 1 );
	// Close dialog window
	MSG_WND_CLS();
	
	// Do whatever you selected
	switch ( selection )
	{
		case 0:
			// Get Player Resource Handle
			int playerResHandle = FLD_PC_GET_RESHND( 0 );		
			// Change Player Model Size
			FLD_MODEL_SET_SCALE( playerResHandle, 2f );
			break;
		case 1:
			// Go to Field 000_002
			CALL_FIELD( 0, 2, 0, 0 );
			break;
		default:
			break;
	}
}

...
```

### What does .MSG look like?

[Messagescript](/flowscript/messagescript) is even more straightforward.\
See below for an idea of how dialog and selections are labelled and formatted.

> // Index 0\
> \[dlg BossRushModeDialog \[TGE]]\
> \[f 2 1]Select a boss fight.\[f 1 1]\[e]

> // Index 1\
> \[sel SelectBoss0]\
> \[f 2 1]D00\_SCENARIO\_BATTLE\_01\[e]\
> \[f 2 1]D01\_01\_SCENARIO\_BATTLE\_01\[e]\
> \[f 2 1]D01\_01\_MORUGANA\_BATTLE\[e]\
> \[f 2 1]D01\_02\_SCENARIO\_BATTLE\_01\[e]\
> \[f 2 1]Previous\[e]\
> \[f 2 1]Next\[e]

## Getting Started

To make full use of this guide, you will need...

* A PC running Windows
* Extracted [files](/flowscript/intro-to-scripting/resources#shrinefox-com-files) from the game you're modding
* An open mind :)

Read on for how to get started with the program.


# Resources

Links for helpful tools while you're learning

## ShrineFox.com TextSearch

One of several web applications on ShrineFox.com is [TextSearch](https://shrinefox.com/apps/textsearch).\
This helps locate files containing specific text.

Choose a game and enter the text you're searching for.\
It will show you a sample of the surrounding text, the path to the file it was found in, and some tips on accessing that file if additional programs are necessary.

## ShrineFox.com Files

The [Files](https://shrinefox.com/apps/files) area of the site allows you to download specific pre-dumped files.\
This way, you don't have to extract them yourself.

This can be an easy way to grab scripts to work with once you've located them with TextSearch.


# AtlusScriptCompiler

About TGE's script (de)compiler program

## Downloading the Program

1. Click [this link](https://ci.appveyor.com/project/TGEnigma/atlusscripttools/build/artifacts) and download the `.zip`.
2. When the `.zip` has downloaded, right click it and choose `Extract All`.
3. Move the files to a safe location on your PC.

## Using the Program

There are two ways to use the program. \
The second option is far easier, but it's good to be familiar with both ways.

{% content-ref url="/pages/-MgwjKLZDN-Xpl\_z3QXp" %}
[Run via Commandline](/flowscript/atlusscriptcompiler/run-via-commandline)
{% endcontent-ref %}

{% content-ref url="/pages/-Mgwk7Vz9xhMzV3rmXc9" %}
[Run via GUI](/flowscript/atlusscriptcompiler/run-via-gui)
{% endcontent-ref %}


# Run via Commandline

Using the Compiler with Windows Command Prompt

This method is the traditional way to use the compiler.

{% hint style="success" %}
For an even easier time, see how to [**Run via GUI**](/flowscript/atlusscriptcompiler/run-via-gui) (graphical user interface).\
If using that method, you can safely skip this page and the upcoming [**Compile**](/flowscript/atlusscriptcompiler/run-via-commandline/compile) and [**Decompile**](/flowscript/atlusscriptcompiler/run-via-commandline/decompile) sections.
{% endhint %}

## Usage

### Command Prompt

If you tried to run [**AtlusScriptCompiler**](/flowscript/atlusscriptcompiler) like a typical `.EXE`, the program would appear to quickly open and close without doing anything. That's because *commandline* programs must be run from the Windows Command Promp&#x74;**,** which we will shortened as "CMD" from here on out.

1. Press `Windows Key + R` and type `cmd`.
2. Press Enter.
3. Drag `AtlusScriptCompiler.exe` onto the CMD window,\
   OR\
   Type the full path to the program in the CMD. Wrap it in quotes in case any folder names contain spaces.
4. Press `Enter`.

Your CMD window should look like this:

```
Microsoft Windows [Version 10.0.22000.120]
(c) Microsoft Corporation. All rights reserved.

C:\Users\Username>"C:\Path\To\AtlusScriptCompiler.exe"
```

At this point, the program should just spit out a list of **arguments** to use.

### Arguments

**Arguments** are the commands that *commandline* programs take as user input. \
You can type them after path to the program you're executing to tell it what to do.&#x20;

For instance, to [Decompile](/flowscript/atlusscriptcompiler/run-via-commandline/decompile) a Persona 5 `.BF` script, you'd type:

```
C:\Users\Username>"C:\Path\To\AtlusScriptCompiler.exe" "C:\Path\To\input.bf" -Decompile -Library P5 -Encoding P5 -Out "C:\Path\To\output.flow"
```

{% hint style="success" %}
By now, you know that AtlusScriptCompiler can [compile](/flowscript/atlusscriptcompiler/run-via-commandline/compile) `.FLOW` and `.MSG` files, and [decompile](/flowscript/atlusscriptcompiler/run-via-commandline/decompile) `.BF` and `.BMD` files. You're also acquainted with how to start the program. \
\
If not, start from [**Intro to Scripting**](/).
{% endhint %}

To learn what each argument means, and which to use in different scenarios, keep reading.

{% content-ref url="/pages/-MgwkH0bTnsDEeeLeijr" %}
[Decompile](/flowscript/atlusscriptcompiler/run-via-commandline/decompile)
{% endcontent-ref %}


# Decompile

Convert BF and BMD into flowscripts and messagescripts

As previously mentioned, [**AtlusScriptCompiler**](/flowscript/atlusscriptcompiler) can [**decompile**](/flowscript/atlusscriptcompiler/run-via-commandline/decompile) `.BF` and `.BMD` into `.FLOW` and `.MSG` respectively. This allows us to view scripts in plain text and edit to our liking.

## 1. Specifying the Input File <a href="#id-1-specifying-the-input-file" id="id-1-specifying-the-input-file"></a>

First, you must tell the program what file we're working with. \
For [decompiling](/flowscript/atlusscriptcompiler/run-via-commandline/decompile), this must be a `.BF` or `.BMD` file.

```
C:\Users\Username>"C:\Path\To\AtlusScriptCompiler.exe" "C:\Path\To\input.bmd"
```

{% hint style="info" %}
You can simply **drag** `AtlusScriptCompiler.exe` and then `input.bmd` onto the [command prompt window](/flowscript/atlusscriptcompiler/run-via-commandline). \
This will automatically wrap each paths in quotes, which keeps arguments separate in case your paths contain spaces.‌
{% endhint %}

## 2. Specify that you are Decompiling

Now, let's tell the program what to do with that file. \
Add `-Decompile`, separated by a space.

```
C:\Users\Username>"C:\Path\To\AtlusScriptCompiler.exe" "C:\Path\To\input.bmd" -Decompile
```

## 2. Specifying the Library <a href="#id-2-specifying-the-library" id="id-2-specifying-the-library"></a>

A **Flowscript Library** instructs the compiler on function names and parameters.\
In order to work with the input file, you have to tell the compiler which Library to use with `-Library`.

```
C:\Users\Username>"C:\Path\To\AtlusScriptCompiler.exe" "C:\Path\To\input.bmd" -Decompile -Library P5
```

### Included Libraries <a href="#included-libraries" id="included-libraries"></a>

|         Library Name | Usage                 |
| -------------------: | --------------------- |
| **DigitalDevilSaga** | `-Library`**`DDS`**   |
|         **Nocturne** | `-Library`**`SMT3`**  |
|         **Persona3** | `-Library`**`P3`**    |
|      **Persona3FES** | `-Library`**`P3FES`** |
| **Persona3Portable** | `-Library`**`P3P`**   |
|         **Persona4** | `-Library`**`P4`**    |
|   **Persona4Golden** | `-Library`**`P4G`**   |
|         **Persona5** | `-Library`**`P5`**    |
|    **Persona5Royal** | `-Library`**`P5R`**   |
|        **PersonaQ2** | `-Library`**`PQ2`**   |

{% hint style="warning" %}
**Not all games** have libraries available. Knowledge of reverse engineering game executables is required to generate a library, as you'll have to find the offsets of function signatures yourself. A sample script for dumping that data from P3/P4 (PS2) can be seen [here](https://github.com/TGEnigma/Atlus-Script-Tools/blob/master/Scripts/ScriptInterpreterCOMMTableToJson_P3P4.py).‌‌
{% endhint %}

## 3. Specifying Encoding <a href="#id-4-specifying-encoding" id="id-4-specifying-encoding"></a>

‌An **Encoding** can be specified using `-Encoding`. \
It lets the compiler know what set of characters to use.

```
C:\Users\Username>"C:\Path\To\AtlusScriptCompiler.exe" "C:\Path\To\input.bmd" =Decompile -Library P5 -Encoding P5
```

### Encodings <a href="#encodings" id="encodings"></a>

|                                                                    Game Name | Usage                       |
| ---------------------------------------------------------------------------: | --------------------------- |
|                                                                **Persona 5** | `-Encoding`**`P5`**         |
|                                                                **Persona 4** | `-Encoding`**`P4`**         |
|                                                          **Persona 3 (FES)** | `-Encoding`**`P3`**         |
| <p><strong>PersonaQ(2)</strong><br>or any game using <br>Shift-JIS/CP932</p> | `-Encoding`**`SJ`**&#x200C; |

## 5. Specifying the Output File <a href="#id-5-specifying-the-output-file" id="id-5-specifying-the-output-file"></a>

‌Finally, you can name the **Output File** using `-Out`.

```
C:\Users\Username>"C:\Path\To\AtlusScriptCompiler.exe" "C:\Path\To\input.bmd" -Decompile -Library P5 -Encoding P5 -Out "C:\Path\To\output.msg"
```

If `-Out` is **not specified,** it will default to the input filename and folder, but with the output filetype appended. In this case, that would be `C:\Path\To\input.bmd.msg`.‌

## Conclusion

At this point, you can press **`Enter`**&#x74;o begin decompiling.

To learn how to put a new or edited script back in the game, keep reading.

{% content-ref url="/pages/-MgwkPJ6OaJ28zEt6nIL" %}
[Compile](/flowscript/atlusscriptcompiler/run-via-commandline/compile)
{% endcontent-ref %}


# Compile

Convert BF and BMD into flowscripts and messagescripts

As previously mentioned, [**AtlusScriptCompiler**](/flowscript/atlusscriptcompiler) can [**compile**](/flowscript/atlusscriptcompiler/run-via-commandline/compile) `.FLOW` and `.MSG` into `.BF` and `.BMD` respectively. Read the previous sections for more information.

## 1. Specifying the Input File

First, you must tell the program what file we're working with. \
For [compiling](/flowscript/atlusscriptcompiler/run-via-commandline/compile), this must be a `.FLOW` or `.MSG` file.

```
C:\Users\Username>"C:\Path\To\AtlusScriptCompiler.exe" "C:\Path\To\field.bf.flow"
```

{% hint style="info" %}
You can simply **drag** `AtlusScriptCompiler.exe` and then `field.bf.flow` **onto the command prompt window**. \
This will automatically wrap each paths in quotes, which keeps arguments separate in case your paths contain spaces.
{% endhint %}

## 2. Specify that you are Compiling

Now, let's tell the program what to do with that file. \
Add `-Compile`, separated by a space.

```
C:\Users\Username>"C:\Path\To\AtlusScriptCompiler.exe" "C:\Path\To\field.bf.flow" -Compile
```

## 2. Specifying the Library

A **Flowscript Library** instructs the compiler on function names and parameters.\
In order to work with the input file, you have to tell the compiler which Library to use with `-Library`.

```
C:\Users\Username>"C:\Path\To\AtlusScriptCompiler.exe" "C:\Path\To\field.bf.flow" -Compile -Library P5
```

### Included Libraries

|         Library Name | Usage                 |
| -------------------: | --------------------- |
| **DigitalDevilSaga** | `-Library`**`DDS`**   |
|         **Nocturne** | `-Library`**`SMT3`**  |
|         **Persona3** | `-Library`**`P3`**    |
|      **Persona3FES** | `-Library`**`P3FES`** |
| **Persona3Portable** | `-Library`**`P3P`**   |
|         **Persona4** | `-Library`**`P4`**    |
|   **Persona4Golden** | `-Library`**`P4G`**   |
|         **Persona5** | `-Library`**`P5`**    |
|    **Persona5Royal** | `-Library`**`P5R`**   |
|        **PersonaQ2** | `-Library`**`PQ2`**   |

{% hint style="warning" %}
&#x20;**Not all games** have libraries available. Knowledge of reverse engineering game executables is required to generate a library, as you'll have to find the offsets of function signatures yourself. A sample script for P3/P4 (PS2) can be seen [here](https://github.com/TGEnigma/Atlus-Script-Tools/blob/master/Scripts/ScriptInterpreterCOMMTableToJson_P3P4.py).
{% endhint %}

## 3. Specifying Output Format

You should also choose an **Output Type** with `-OutFormat`. \
This determine the version and endianness of the generated `BF` or `BMD`.

```
C:\Users\Username>"C:\Path\To\AtlusScriptCompiler.exe" "C:\Path\To\field.bf.flow" -Compile -Library P5 -OutFormat V3BE
```

### Output Types

|                                                              Output Type | Usage                  |
| -----------------------------------------------------------------------: | ---------------------- |
|                                 <p> Persona 5<br><strong>BF</strong></p> | `-OutFormat`**`V3BE`** |
|                           <p>Persona 5 (PS3)<br><strong>BMD</strong></p> | `-OutFormat`**`V1BE`** |
| <p>Persona 5 (PS4) &<br>Persona 3/4 (PS2)<br><strong>BF/BMD</strong></p> | `-OutFormat`**`V1`**   |

## 4. Specifying Encoding

An **Encoding** can be specified using `-Encoding`.\
It lets the compiler know what set of characters to use.

```
C:\Users\Username>"C:\Path\To\AtlusScriptCompiler.exe" "C:\Path\To\field.bf.flow" -Compile -Library P5 -OutFormat V3BE -Encoding P5
```

### Encodings

|                                                                     Game Name | Usage               |
| ----------------------------------------------------------------------------: | ------------------- |
|                                                                 **Persona 5** | `-Encoding`**`P5`** |
|                                                                 **Persona 4** | `-Encoding`**`P4`** |
|                                                           **Persona 3 (FES)** | `-Encoding`**`P3`** |
| <p><strong>PersonaQ(2)</strong> <br>or any game using <br>Shift-JIS/CP932</p> | `-Encoding`**`SJ`** |

## 5. Specifying the Output File

Finally, you can name the **Output File** using `-Out`.

```
C:\Users\Username>"C:\Path\To\AtlusScriptCompiler.exe" "C:\Path\To\field.bf.flow" -Compile -Library P5 -OutFormat V3BE -Encoding P5 -Out "C:\Path\To\field.bf"
```

{% hint style="info" %}
If `-Out` is **not specified,** it will default to the input filename and folder, but with the output filetype appended. In this case, that would be `C:\Path\To\field.bf.flow.bf`.
{% endhint %}

At this point, you can press **`Enter`**&#x74;o begin compiling. \
But, there are a few optional commands which might be useful to you.

## 6. Hooking

**Hooking** can be handy when you're compiling a `.FLOW` and only want to replace specific [**procedures**](/flowscript/flowscript/procedures) in an [**imported**](/flowscript/flowscript/importing) `.BF`.

{% hint style="info" %}
**AtlusScriptCompiler is not perfect**, so it doesn't hurt to be proactive.\
With hooks, we can avoid potential compiler issues when recompiling an entire `.BF` script.
{% endhint %}

Enable Hooking by adding the`-Hook` argument.

When [compiling](/flowscript/atlusscriptcompiler/run-via-commandline/compile) your `.FLOW` into `.BF`, this redirects existing [procedures](/flowscript/flowscript/procedures) in an [imported](/flowscript/flowscript/importing) `.BF` file to replacement [procedures](/flowscript/flowscript/procedures) with a matching names that end in **`_hook_()`**.&#x20;

{% hint style="success" %}
The original [procedure](/flowscript/flowscript/procedures) still exists and can be called by name in your `.FLOW` script,  since the original data is not overwritten when hooking a function.\
References to the original [procedure](/flowscript/flowscript/procedures) in the original `.BF` are simply redirected to your replacement.
{% endhint %}

```
C:\Users\Username>"C:\Path\To\AtlusScriptCompiler.exe" "C:\Path\To\field.bf.flow" -Compile -Library P5 -OutFormat V3BE -Encoding P5 -Out "C:\Path\To\field.bf" -Hook
```

### Setup

1. [**Decompile**](/flowscript/atlusscriptcompiler/run-via-commandline/decompile) the `.BF` that you're referencing in the `.FLOW` you're compiling.
2. **Open** the `.FLOW` and copy the procedure you want to edit.
3. **Paste** it into your `.FLOW` that references the `.BF`, and add **`_hook`** to the procedure name.
4. **Edit** the procedure however you'd like.
5. [Import](/flowscript/flowscript/importing) the original `.BF` file.
6. **Compile** your new `.FLOW`with the`-Hook` argument.

## Conclusion

Now that you know how to (de)compile with [AtlusScriptCompiler](/flowscript/atlusscriptcompiler), you're ready to read, edit, and create scripts. If you haven't already, read on to see how to use the [**GUI**](/flowscript/atlusscriptcompiler/run-via-gui) to make (de)compiling even easier:

{% content-ref url="/pages/-Mgwk7Vz9xhMzV3rmXc9" %}
[Run via GUI](/flowscript/atlusscriptcompiler/run-via-gui)
{% endcontent-ref %}


# Batch Dump .FLOW/.MSG

Locally searchable decompiled script dumps

TGE's [Atlus-Script-Tools](https://github.com/TGEnigma/Atlus-Script-Tools) repository comes with other [**commandline**](/flowscript/atlusscriptcompiler/run-via-commandline) programs aside from just [**AtlusScriptCompiler**](/flowscript/atlusscriptcompiler). **AtlusFlowScriptExtractor** and **AtlusMessageScriptExtractor**, as their names imply, batch [**decompile**](/flowscript/atlusscriptcompiler/run-via-commandline/decompile) all `.FLOW` and `.MSG` data from `.BF` and `.BMD` in a directory (and subdirectories), even ones contained in archives like `.PAC`.

You'll end up with `.TXT` files containing all of the dumped data. While the [**ShrineFox.com Text Search**](/flowscript/intro-to-scripting/resources#shrinefox-com-textsearch) provides these advantages, it's also nice to have a local dump on your computer to search and use as a reference.

## Using AtlusFlowScriptExtractor

Enter the path to AtlusFlowScriptExtractor.exe in the Windows Command Prompt.

```
Microsoft Windows [Version 10.0.22000.120]
(c) Microsoft Corporation. All rights reserved.

C:\Users\Username>"C:\Path\To\AtlusFlowScriptExtractor.exe"
```

Then, enter the path to the directory you want to scan. Ideally, this should be a folder containing the extracted contents of your `data.cpk` and `ps3.cpk`. You can use [CriPakGUI](https://shrinefox.com/browse?post=cripakgui) to extract these if you haven't already.

```
C:\Users\Username>"C:\Path\To\AtlusFlowScriptExtractor.exe" "D:\Games\Persona\Backups\Persona 5"
```

From here, there's optional arguments we can add for different results.

|       Argument | Info                                                                                                                                                      |
| -------------: | --------------------------------------------------------------------------------------------------------------------------------------------------------- |
|     **`-enc`** | <p>Determines which text encoding is used. <br>If no enc directive is provided, non-ASCII <br>code points will be output as hex values</p>                |
|    **`-func`** | <p>Enables the output of function codes.<br>Disabled by default</p>                                                                                       |
|    **`-scan`** | <p>Enables bruteforce scanning for message <br>script data if file type is not detected <br>(CAN BE VERY SLOW)</p>                                        |
| **`-noalign`** | <p>Disables 4 byte alignment for scanning. <br>Not recommend unless you're sure the file <br>contains text that doesn't get detected <br>(ULTRA SLOW)</p> |
| **`-exclude`** | <p>Excludes specified file extensions from<br>brute force scanning.</p>                                                                                   |
| **`-include`** | <p>Includes specified file extensions in<br>brute force scanning.</p>                                                                                     |
|     **`-dec`** | <p>Uses decompiler output instead</p><p>of the regular output.</p>                                                                                        |

Here's the options I went with, since I wanted to output with decompiler formatting, since I'm working with flowscripts and it'd make a handy 1:1 reference. I also skip large files that for sure don't contain script data (`.GMD, .GAP, .GFS, .GSC, .USM, .EPL, .ENV`...)

```
C:\Users\Username>"C:\Path\To\AtlusFlowScriptExtractor.exe" "D:\Games\Persona\Backups\Persona 5" -dec -scan -exclude usm gmd gap gfs epl env spr spd plg adx gsc acb awb dds bed bcd evt bfl 000 001 dat cmr bmd
```

This process can take quite some time, so sit back and relax until you have a complete `AtlusFlowScriptExtractorOutput.txt` file.

## Using AtlusMessageScriptExtractor

Pretty much the same as above.

```
C:\Users\Username>"C:\Path\To\AtlusMessageScriptExtractor.exe" "D:\Games\Persona\Backups\Persona 5" -dec -enc p5 -scan -exclude usm gmd gap gfs epl env spr spd plg adx acb awb dds bed bcd evt bfl 000 001 dat cmr
```

This process can take quite some time, so sit back and relax until you have a complete `MessageScriptDump.txt` file.


# Run via GUI

Using the Compiler with AtlusScriptCompilerGUI

**AtlusScriptCompilerGUI** is a Graphical User Interface (GUI) made by ShrineFox for ease of use when (de)compiling.

1. Download the GUI from [**this link**](https://github.com/ShrineFox/AtlusScriptCompiler-GUI/releases) (under where it says `Assets`).
2. When the `.zip` has finished downloading, right click and choose `Extract All`.
3. Move the files to the location of your `AtlusScriptCompiler.exe`.
4. Double-click `AtlusScriptCompilerGUI.exe` to run it.
5. If `AtlusScriptCompiler.exe` is found, the form will open.
6. Choose the game you'll be working with from the dropdown.

![AtlusScriptCompilerGUI Appearance (Dark Mode)](/files/-Mgx-NcP5WQlhHVuYW4K)

## Usage

To **(de)compile**, drag and drop files onto the corresponding buttons of the form.\
With the checkboxes, you can toggle...

* [**Hooking**](/flowscript/atlusscriptcompiler/run-via-commandline/compile#6-hooking). It doesn't hurt to leave this on by default.
* **Displaying the log**. This is useful for diagnosing errors.
* **Disassembling**. Off by default, useful for reverse engineers when a script fails to (de)compile.
* **Overwriting**. When on, the output will look something like `script.bf` rather than `script.bf.flow.bf` therefore overwriting any file with that name that may already exist.
* **SumBits** is enabled by default when decompiling. This simplifies mathematical expressions automatically.

## Conclusion

By now, you know all the basics of using [**AtlusScriptCompiler**](/flowscript/atlusscriptcompiler).\
You're ready to get familiar with [**Messagescript**](/flowscript/messagescript)!

{% content-ref url="/pages/-Mgwkhx3XPwBlP6X93-v" %}
[Messagescript](/flowscript/messagescript)
{% endcontent-ref %}


# Flowscript

About TGE's human-readable .BF approximation

{% hint style="info" %}
**Did you know?** The name "Flowscript" comes from the *magic string* (first 4 bytes) of a`.BF` file, which spells out "FLW0".
{% endhint %}

**Flowscript** (`.FLOW`) is the human-readable script you get by [**Decompiling**](/flowscript/atlusscriptcompiler/run-via-commandline/decompile) a `.BF` file using [**AtlusScriptCompiler**](/flowscript/atlusscriptcompiler).\
Designed by TGE, it features syntax similar to **C**, which many users experienced with object-oriented programming should find familiar.

{% hint style="success" %}
Again-- This guide is geared toward ***complete beginners***.\
By the end, you should be able to easily create your own scripts, even if you've never programmed before.
{% endhint %}

## Usage

You can create a `.FLOW` file from scratch by renaming a new text file.

{% hint style="info" %}
You may need to [make Windows display known file extensions](https://www.howtogeek.com/205086/beginner-how-to-make-windows-show-file-extensions/) in order to change the `.TXT` extension to`.FLOW`.
{% endhint %}

You can also [Decompile](/flowscript/atlusscriptcompiler/run-via-commandline/decompile) an existing `.BF` script to `.FLOW`, or vice versa by [**Compiling**](/flowscript/atlusscriptcompiler/run-via-commandline/compile).

Read on to learn more about what comprises a Flowscript.


# Procedures

void Main();

A **Procedure** is defined as a set of coded instructions that tell a computer how to perform certain calculations. A bulk of scripting takes place within these so-called *procedures*.

## Usage

### Main()

Every [**Flowscript**](/flowscript/flowscript) has at least one *procedure*, usually called `Main()`, which is used as the **entry point**. \
When the script is executed (or run) by the game, it will follow the path starting from the first line of code in `Main()`.

```csharp
void Main() // Procedure declaration
{
    2 + 2; // Statement, would equal 4 once compiled and run
}
```

Every line of code is referred to as a **statement**. \
A statement ends with a semicolon to tell the compiler that the logical expression is complete. \
Think of it like saying "OVER" when speaking into a walkie-talkie.

Notice the `void` keyword, which indicates the **data type** that the procedure **returns**.

{% hint style="info" %}
**A void doesn't return anything**, it just runs whatever code is contained in it, and then continues from whatever line it was called on. \
When the end of `Main()` is reached, the entire script has finished executing.
{% endhint %}

### Return Types

A *procedure* can **return** a value once calculations have finished if it isn't a `void`. \
The returned value is then used in calculation wherever the procedure was called, as if it was a [**variable**](/flowscript/flowscript/variables-and-procedures).&#x20;

```csharp
void Main() // Procedure declaration
{
    2 + GetNumber(); // Statement, would equal 5 once compiled and run
}

int GetNumber() //Procedure declaration
{
    return 3; // Return statement
}
```

These are the **Data Types** a *procedure* can return:

| Name        | Description                                                                          | Example Value       |
| ----------- | ------------------------------------------------------------------------------------ | ------------------- |
| `void`      | Default procedure type. Does not return anything.                                    |                     |
| **`int`**   | Integer. A whole number **between**  **-2147483648** and  **2147483647.**            | 24                  |
| **`float`** | Floating-point. A decimal between **1.175494351 E - 38** and **3.402823466 E + 38**. | 24.01**f**          |
| **`bool`**  | Boolean. A **true** or **false** value. Can also be represented by 1 or 0.           | <p>true</p><p>1</p> |

### **Parameters**

A **parameter** is an argument that a *procedure* requires in order to do its calculations.\
This is just like in algebra, where you would need to know the value of **x** first in order to find **y** in `x + y = 30`.

These could be the same data types as above. For example:

```csharp
void Main() // Procedure declaration
{
    GetNumber( 2, 15 ); // Statement, would equal 17 once compiled and run
}

int GetNumber( int inputNumber, int anotherNumber ) // Procedure declaration with parameters
{
    return inputNumber + anotherNumber; // Return statement
}
```

## Conclusion

***Procedures***, **return types** and **parameters** are major concepts that we will continue to build on in the upcoming section. Don't worry if you find this overwhelming. The more [Flowscript](/flowscript/flowscript) you read and edit, the more natural this will be to work with.

Keep reading to learn about another major concept-- [**variables**](/flowscript/flowscript/variables-and-procedures)!

{% content-ref url="/pages/-Mh8goN7P3ZK6nNy1G5k" %}
[Variables](/flowscript/flowscript/variables-and-procedures)
{% endcontent-ref %}


# Variables

int number = 1;

**Variables** are named objects of a specified data type that we can assign a value to.

## Usage

### Declaring Variables

**Declaring** (or **defining**) a *variable* means giving it a name. \
You can declare a *variable* this way:

```csharp
var variableName;
```

### **Initializing Variables**

**Initializing** a *variable* means giving it an initial value.\
We can do just that with the `=` sign:

```csharp
var variableName = 25;
```

### Data Types

Each variable has a **Data Type** (also known as a **primitive**), such as...

| Name        | Description                                                                          | Example Value                                    |
| ----------- | ------------------------------------------------------------------------------------ | ------------------------------------------------ |
| `var`       | Default data type. The compiler will assume the most likely data type.               | <p>5</p><p>20.3<strong>f</strong></p><p>true</p> |
| **`int`**   | Integer. A whole number **between**  **-2147483648** and  **2147483647.**            | 24                                               |
| **`float`** | Floating-point. A decimal between **1.175494351 E - 38** and **3.402823466 E + 38**. | 24.01**f**                                       |
| **`bool`**  | Boolean. A **true** or **false** value. Can also be represented by 1 or 0.           | <p>true</p><p>1</p>                              |

You can initialize a *variable* with a specific data type if you want:

```csharp
int variableName = 25;
float variableName2 = 25.01;
```

In most cases, the compiler will assume a number is an `int`. \
You can put an **`f`** after any number to show that it's a `float`, even without a decimal point:

```csharp
// This will be assumed to be an int
var variableName = 25;
// This will be assumed to be a float
var variableName2 = 25f;
```

## Conclusion

Now you know how to save whole numbers, decimals, and true/false values and refer to them by name. This will be very useful for re-using values in mathematic expressions and [**procedures**](/flowscript/flowscript/procedures).

With that in mind, you're ready to learn about a major component of [procedures](/flowscript/flowscript/procedures) and *variables*.

{% content-ref url="/pages/-MhWua76OOvIT7f52pcA" %}
[Scope](/flowscript/flowscript/scope)
{% endcontent-ref %}


# Scope

global var number = 24;

A **Scope** is an area of a program where an object is recognized.\
Procedures have their own *scope*. To the rest of the script, any [**variables**](/flowscript/flowscript/variables-and-procedures) [declared](/flowscript/flowscript/variables-and-procedures#declaring-variables) inside a [**procedure**](/flowscript/flowscript/procedures) do not exist.

For instance, if you declare a variable in [**`Main()`**](/flowscript/flowscript/procedures#main), you will not be able to use it from any other [procedure](/flowscript/flowscript/procedures). Also, unless you assign the value to a variable of greater *scope*, when the [procedure](/flowscript/flowscript/procedures) ends, the value will be discarded.

```csharp
// variableName only exists within Main() since it's local
void Main() {
    var variableName = 25;
    // no other procedure will be able to recognize 'variableName'
    AnotherProcedure();
}

void AnotherProcedure(int variableTest ) {
    // This would cause an ERROR.
    var test = variableName;
}
```

However, [variables](/flowscript/flowscript/variables-and-procedures) can be given different *scopes*.

## Variable Scopes

| Name         | Description                                                                                    |
| ------------ | ---------------------------------------------------------------------------------------------- |
| `local`      | Default *scope* for [variables](/flowscript/flowscript/variables-and-procedures).              |
| **`global`** | Persists across all scripts while the game is running.                                         |
| **`static`** | Value persists per [procedure](/flowscript/flowscript/procedures) while the script is running. |
| **`const`**  | Must be initialized with a value. Cannot be changed afterward.                                 |

### Local

In the example above, the value of `variableName` cannot be accessed by `OtherProcedure()` since it only exists to [`Main()`](/flowscript/flowscript/procedures#main), where it was defined.

However, you can **still pass it by reference** to use it for math or [initializing a variable](/flowscript/flowscript/variables-and-procedures#initializing-variables) in another[ procedure](/flowscript/flowscript/procedures).

```csharp
// variableName only exists within Main() since it's local
void Main() {
    var variableName = 25;
    // but since AnotherProcedure() takes an int... 
    AnotherProcedure( variableName );
}

// ... we can make a copy of its value with a different name
void AnotherProcedure(int variableTest ) {
    // This would create a new local variable equal to 25
    var test = variableTest;
}
```

### Global

`global` [variables](/flowscript/flowscript/variables-and-procedures) are persist even after a script is done executing. \
They stay in memory while the game is running, but **aren't saved to your save file**.&#x20;

A practical use case would be keeping track of the last entered number after closing and re-opening a menu.

```csharp
// globalTest exists for as long as the game is running, even after Main()
global int globalTest = 50;

void Main() {
    globalTest = globalTest + 30;
    AnotherProcedure();
}

void AnotherProcedure() {
    // This would create a new local variable equal to 80
    var test = globalTest;
}
```

### Static

`static` [variables](/flowscript/flowscript/variables-and-procedures) can be declared but not initialized outside of a [procedure](/flowscript/flowscript/procedures). \
These keep their value between executions while the game is running, but **aren't saved to your save file**.&#x20;

```csharp
static int staticNumber;

void Main() {
    // the first static int will be 10 higher every time the script is run
    staticNumber = staticNumber + 10;
}
```

### Const

`const` [variables](/flowscript/flowscript/variables-and-procedures) are constant, so **their value cannot be changed** after they're initialized.\
This can be useful for referring to values you know in advance by a convenient name.

```csharp
const int constantNumber = 99;

void Main() {
    constantNumber = 0;
    // test would still equal 99
    var test = constantNumber;
}
```

### Out Variables

Aside from [passing by reference](/flowscript/flowscript/scope#local) or using `global`, `static` or `const`, you can also use **out variables** to pass values between [procedures](/flowscript/flowscript/procedures), even `void`. It would look like this:

```csharp
void Main() {
    OutTest( out x, out y );
    var x + y; // result equaling 35
}

void OutTest( out int x, out int y )
{
    x = 5;
    y = 30;
}
```

As you can see, the [variables](/flowscript/flowscript/variables-and-procedures) were already [declared](/flowscript/flowscript/variables-and-procedures#declaring-variables) in the parameters of `OutTest()` using the **`out` keyword**. \
After being initialized with a value, the `x` and `y` variables are then passed to `Main()`, once again using the **`out` keyword**.

{% hint style="info" %}
If this seems confusing, don't worry about it for now. You will not have to do this very often.
{% endhint %}

## Conclusion

Now you should have a grasp on how data is stored and handled by scripts. You're ready to learn more advanced usages of these techniques, such as [**Arrays**](/flowscript/flowscript/arrays) and [**Loops**](/flowscript/flowscript/loops-and-conditionals).

{% content-ref url="/pages/-MhX1ZRKxa6CqNP4VF7P" %}
[Arrays](/flowscript/flowscript/arrays)
{% endcontent-ref %}


# Arrays

int array2\[] = { 1, 2, 3, 4, 5 };

{% hint style="danger" %}
The **Arrays** section of this guide is still incomplete. Pending additional information on the following:

* **Defining Arrays**
* **Initializing Arrays**
* **Getting and Setting Array Values**
  {% endhint %}


# Enums

Enumerables

{% hint style="danger" %}
The **Enums** section of this guide is still incomplete. Pending additional information on the following:

* **What is an Enum**
* **How to Define Enums**
* **Using Enums (user input example)**
  {% endhint %}


# Loops

for ( int i = 0; i < 22; i = i + 1 ) { ... };

{% hint style="danger" %}
The **Loops** section of this guide is still incomplete. Pending additional information on the following:

* **For Loops**
* **While Loops**
  {% endhint %}


# Conditionals

if ( 1 != value ) { ... };

{% hint style="danger" %}
The **Conditionals** section of this guide is still incomplete. Pending additional information on the following:

* **If/Else**
* **! (not)**
* **|| (or)**
* **&& (and)**
* **Switch cases**
  {% endhint %}


# Functions

{% hint style="danger" %}
The **Functions** section of this guide is still incomplete. Pending additional information on the following:

* **Functions are hardcoded procedures in the game's executable (ALL\_CAPS)**
* **Common, Field, AI etc.**
  {% endhint %}


# Importing Files

How to include other scripts in your script

At the beginning of a [**Flowscript**](/flowscript/flowscript), you can **import** a `.BF`, `.FLOW` `.BMD` or `.MSG` file.

## Usage

* Chaining together multiple `.FLOW` scripts is a great way to keep your code clean and organized.<br>
* You can call [**procedures**](/flowscript/flowscript/procedures) by name from pre-compiled `.BF` files and other `.FLOW` files, and [messages](/flowscript/messagescript#messages) by name (or index) from pre-compiled `.BMD` files.

### Importing Uncompiled Scripts

Suppose the file we are creating is named **Experiment.flow**, and we want to use a [procedure](/flowscript/flowscript/procedures) from another [flowscript](/flowscript/flowscript) (**Test.flow**).

Suppose we have the following files...

#### **Experiment.flow**

(our new `.FLOW`)

```c
// Import another Flowscript into the script
import( "Test.flow" );

void Main() {
	// Call procedure from the imported FlowScript
	ShowWindow();
}
```

#### **Test.flow**

(The `.FLOW` we're *importing*)

```csharp
import( "Test.msg" );

void ShowWindow() {
	int messageNumber = 2;
	MSG_WND_DSP();
	MSG( messageNumber, 0 );
	MSG_WND_CLS();
}

```

#### **Test.msg**&#x20;

**(**&#x54;he `.MSG` imported by the `.FLOW` we're *importing*)

> \[dlg FirstMessage]\
> \[s]Message 1.\[e]
>
> \[msg SecondMessage]\
> \[s]Nessage 2.\[e]
>
> \[dlg ThirdMessage]\
> \[s]Message 3.\[e]

#### **Results**

If run in-game, the [message](/flowscript/messagescript#messages) in **Test.bf**'s embedded `.BMD` "*Message 3.*" would be shown in a message window.

{% hint style="info" %}
This is because the integer i&#x6E;**`ShowWindow()`**&#x69;s initialized with a value of 2, and then used as the first **parameter** (required input) in th&#x65;**`MSG()`**&#x66;unction. \
[Message](/flowscript/messagescript#messages) indexes start at `0`, so it'd actually show the 3rd [message](/flowscript/messagescript#messages).
{% endhint %}

### Importing Compiled Scripts

{% hint style="danger" %}
The **Importing** section of this guide is still incomplete. Pending additional information on the following:

* **Importing Compiled Scripts**
  * With .BF and .BMD you can reference procedures, variables and messages by name, but variable names and comments are lost. You can still decompile these to see the message names/indexes and procedure names in order to reference them.
    {% endhint %}

## Conclusion

Now that you understand pretty much every element of a [flowscript](/flowscript/flowscript), we can move on to getting user input with [**menus**](/flowscript/flowscript/menus), which is a great place to begin making your own scripts.

{% content-ref url="/pages/-Mh8hEH8cLJUnqDfRZU-" %}
[Menus](/flowscript/flowscript/menus)
{% endcontent-ref %}


# Menus

Working with menus in flowscript

{% hint style="danger" %}
The **Menus** section of this guide is still incomplete. Pending additional information on the following:

* **Selection Masks**
* **Pages**
* **Selection Box Descriptions**
* **Selection Box Help Text (P5)**
  {% endhint %}


# Messagescript

About TGE's human-readable .BMD approximation

## Where Am I?

This is the **documentation** section of [ShrineFox.com](https://shrinefox.com). If you're not sure how to begin modding Persona games, you're in the right place. While you can find blog post style step-by-step tutorials in the [guides section](https://shrinefox.com/guides), you can think of these docs as a more generalized handbook.

You're meant to be able to jump around as you search for information, kind of like a wiki page. Complete beginners are encouraged to read each section from beginning to end.

{% hint style="info" %}
This is still under heavy construction. As such, it hasn't been linked on the site yet.\
The documentation still lacks the following information:

**Flowscript**

* [**Messagescript**](/flowscript/messagescript) Message Variables
*

{% endhint %}

<br>

{% content-ref url="/pages/-MgwjBgEd2UvFDUFHjdM" %}
[AtlusScriptCompiler](/flowscript/atlusscriptcompiler)
{% endcontent-ref %}


# Markup

How to style the text in messages.

You can change the appearance of text in a `.MSG` by inserting the following **commands** in brackets into your message.

## Commands

* `[clr`` `**`x`**`]` **Text color**. Affects all text after the tag until the end of the line (\[e]).
  * **x** is a number between 0 and 30.
* `[n]` **Linebreak**. Put this between some text to make it show up on a new line ingame.
* `[w]` **Wait**. Makes the game await user input before moving on to the next line.
* `[vp`` `**`w x y z`**` ``0 0]` **Voice Pack**. Makes the game play a voice clip.
  * **w** = eventIdMajor
  * **x** = eventIdMinor
  * **y** = eventIdSub
  * **z** = cueId
* `[bup 0`` `**`x y z`**` ``0]` **Bustup**. Shows a character's talking sprite during dialog.
  * **x** = characterId
  * **y** = expressionId
  * **z** = customeId
  * **Lip flap** will animate if this command is followed by `[f 4 10 -1 0 0]`.

### Colors

| Index | Color              | Hex Value  |
| ----- | ------------------ | ---------- |
| 0     | White              | `#FFFFFF`  |
| 1     | Light Blue         | `#72C5FF`  |
| 2     | Light Red          | `#FF423F`  |
| 3     | Light Yellow       | `#FFFF76`  |
| 4     | Light Green        | `#69FF65`  |
| 5     | Dark Brown         | `#50321E`  |
| 6     | Dark Orange        | `#DC6E00`  |
| 7     | White              | `#FFFFFF`  |
| 8     | Dark Brown         | `#50321E`  |
| 9     | Red                | `#FF1800`  |
| 10    | Dark Red           | `#BA0000`  |
| 11    | Blue               | `#1200FFF` |
| 12    | Dark Blue          | `#1F00BA`  |
| 13    | Green              | `#0AC000`  |
| 14    | Dark Green         | `#078600`  |
| 15    | Purple             | `#9D00EF`  |
| 16    | Dark Purple        | `#78008E`  |
| 17    | Dark Yellow        | `#BF9D02`  |
| 18    | Pink               | `#FF0391`  |
| 19    | Dark Pink          | `#FF00FC`  |
| 20    | Darker Pink        | `#DB0054`  |
| 21    | Light Teal         | `#00AEFF`  |
| 22    | Dark Brown         | `#90401A`  |
| 23    | Light Black        | `#161616`  |
| 24    | Dark Gray          | `#404040`  |
| 25    | Gray               | `#656565`  |
| 26    | Dark Yellow        | `#E6B625`  |
| 27    | White              | `#FFFFFFF` |
| 28    | Dark Teal          | `#99BBD3`  |
| 29    | Really Light Brown | `#E4D4C7`  |


# Message Variables

How to display certain data within a message.

{% hint style="danger" %}
The **Message Variables** section of this guide is still incomplete. Pending additional information on the following:

* **Defining Message Variables**
* **Using Message Variables**
  {% endhint %}


# Library Functions


# Persona 5

Functions found in all versions of Persona 5.

These functions are automatically included when using the P5 library of AtlusScriptCompiler.\
They are also found in P5R & P5EX libraries.

[See here](https://github.com/tge-was-taken/Atlus-Script-Tools/blob/539e25eec0eed909ca1e04b931157360cf8acd1b/Source/AtlusScriptCompiler/Resources/Include/p5.flow) for a list of all functions and their arguments.\
Here are some of the most common commands, in order of usefulness.

## **Message Boxes**

{% hint style="info" %}
These functions are a simple way to display information to the player. Try it out!
{% endhint %}

### void MSG\_WND\_DSP();

This function comes before a message box function. It lets the game know to open the message before a message is loaded.

### void MSG\_WND\_CLS();

This function comes after a message box function. It lets the game know to close the message box after messages are loaded.

### void MSG(int msgID, int unused);

The `MSG()` function shows a basic message box onscreen. \
This is usually used for characters having a verbal conversation.\
\
The first argument is the index of the message in the .msg file.\
The second argument is always `0` and serves no purpose.\
You can use the name of the message in place of the index, and AtlusScriptCompiler will automatically interpret it.

```c
// Imports messages from a nearby .msg file
import("messages.msg");

// Example of a basic text box
MSG_WND_DSP();
MSG(firstMessage, 0); // same as MSG(0,0);
MSG(secondMessage, 0); // Same as MSG(1,0);
MSG(thirdMessage, 0); // Same as MSG(2,0);
MSG_WND_CLS();
```

### void MSG\_MIND(int msgID, int unused);

The `MSG_MIND()` function shows a thought bubble containing some text onscreen.\
This is usually used for the protagonist's inner thoughts.\
\
This works exactly the same as `MSG()`.

```c
// Example of a thought bubble message
MSG_WND_DSP();
MSG_MIND(firstMessage, 0);
MSG_MIND(secondMessage, 0);
MSG_WND_CLS();
```

### void MSG\_SYSTEM(int msgID);

The `MSG_SYSTEM()` function shows a square grey box containing some text onscreen.\
This is usually used for game-related messages, such as tutorials or settings confirmation.\
\
This works exactly the same as `MSG()` and `MSG_MIND()` but lacks the unused argument.

```c
// Example of a system message
MSG_WND_DSP();
MSG_SYSTEM(firstMessage);
MSG_WND_CLS();
```

## Menus

{% hint style="info" %}
These functions allow you to get some input from the player.
{% endhint %}

### int SEL(int msgID);

The `SEL()` function takes a message index as an argument, just like `MSG()`. \
The message must be of type `[sel]` and not `[msg]/[dlg]`.\
It returns an integer-- the index of the option the user selected.

If used after a message box function, and before `MSG_WND_CLS()`, the message will stay onscreen in the background of the menu, providing context to the player.

The type of message box used will determine the appearance. For instance, `MSG()` (or no messagebox) will display the protagonist's portrait on the side of the screen. Meanwhile, `MSG_MIND()` will display the options as thought bubbles in the middle of the screen, and for `MSG_SYSTEM()`, the options will appear in grey boxes next to the system message.

<pre class="language-c"><code class="lang-c">import("messages.msg");
import("menus.msg");

// Example of a basic menu
MSG_WND_DSP();
MSG(firstMessage, 0); // Shows dialog first
<strong>int selection = SEL(firstMenu); // Opens menu and records player's answer
</strong>MSG_WND_CLS();

// Use the selection variable to do different things
if (selection == 0)
{
    // do stuff if player selected first option
    MSG_WND_DSP();
    MSG_SYSTEM(optionOneMessage);
    MSG_WND_CLS();
}
else if (selection == 1)
{
    // do stuff if player selected second option
    MSG_WND_DSP();
    MSG_SYSTEM(optionTwoMessage);
    MSG_WND_CLS();
}
// etc ...
</code></pre>

### int SEL\_GENERIC(int msgTitleID, int msgOptionsID);

This function has several variants that work the same with minor differences.\
It is used to display a large menu with a scrollbar that covers most of the screen, so it's not ideal to pair it with a `MSG()` or similar function. It's best to use when you have a lot of options.

The first argument is the message index to use for the title, which is a small white box with black text that appears at the top of the menu. Use something short that describes the purpose of the menu. This message must be of type `[dlg]/[msg]`.

The second argument, like other selection functions, is the index of the `[sel]` type message where each line is a menu option.

```c
// Example of a generic menu
MSG_WND_DSP();
int selection = SEL_GENERIC(firstMenuTitle, firstMenu);
MSG_WND_CLS();

if (selection == -1)
{
    // do stuff if player cancelled selection
}
else if (selection == 0)
{
    // do stuff if first option selected
}
// etc.
```

Note that the user is able to press the cancel button on their gamepad to select nothing, resulting in the function returning `-1`. You can prevent this behavior if it is unwanted by using a similar function, listed below.

#### Variants

<table><thead><tr><th width="279">Function Name</th><th>Description</th></tr></thead><tbody><tr><td>SEL_GENERIC_NOT_HELP</td><td>Generic menu but without description text for each menu option.</td></tr><tr><td>SEL_GENERIC_NOT_CANCEL</td><td>Generic menu but without the ability to press the cancel button to exit the menu without selecting anything.</td></tr><tr><td>SEL_GENERIC_EX</td><td>??? takes an extra two integer arguments?</td></tr></tbody></table>

#### Menu Option Descriptions

Unless using `SEL_GENERIC_NOT_HELP()`, a cool feature of these functions is to display some extra text onscreen that describes the highlighted menu item. Each description is its own msg entry of type \[dlg]/\[msg].

However, it is a bit tricky to set this up properly. It seems that these msg entries must immediately follow the \[sel] with the options that it's describing. The description entries must come in the same order as the options.

Not only that, but each menu option must end with a msg function with arguments denoting the index of the option and the message index of the description. See below for an example.

Finally, it seems that message description names must start with GENERIC\_HELP\_, but anything after that doesn't matter. It's recommended to name these after the message index to prevent your own confusion.

```c
[sel Options_ModMenu]
Phone/Auto-Recover[ref 0 1][e]
Player[ref 1 2][e]
Teleport[ref 2 3][e]
Call...[ref 3 4][e]
Calendar[ref 4 5][e]
Camera[ref 5 6][e]
Flags[ref 6 7][e]
Spawn[ref 7 8][e]
About[ref 8 9][e]
Royal[ref 9 10][e]

[dlg GENERIC_HELP_1]
View your IM messages[n]or auto heal the party,
[n]just like the [clr 18]IM button[clr 0]
[n]normally does.[e]

[dlg GENERIC_HELP_2]
Change social stats, items,
[n]Personas, Skills, model,
[n]animations, money or name.[e]

...
```

In this example, `GENERIC_HELP_1` is the description for the option `Phone/Auto-Recover`.\
`GENERIC_HELP_1` is at message index `1`, since it is the second msg entry in the file (indices start counting at `0`).\
Therefore, the numbers in `[ref 0 1]` refer to `Phone/Auto-Recover` being the 0th option of the menu (the first), and `GENERIC_HELP_1` being at index `1` (the second message entry).\
You can see how for the next option, these numbers increase by 1, and so on forth.

{% hint style="warning" %}
If this seems redundant, that's because it is! Unfortunately, if any of these conventions aren't followed, the menu will not display a description in-game and you'll be left with a blank white box where one should be. It's frustrating, but this is the best we can do.
{% endhint %}

## Calling Functions

{% hint style="info" %}
Functions that "call" certain elements of the game are very useful! Use [the Amicitia wiki](https://amicitia.miraheze.org/wiki/Persona_5#Recommended_Pages) to find out what ID numbers correspond to what you're trying to call.
{% endhint %}

### void CALL\_BATTLE(int battleIndex);

The `CALL_BATTLE()` function does exactly what you'd imagine-- start a battle using its index as the argument. You can find a battle's index in the game's `ENCOUNT.TBL` file (found in `battle/table.pac`).

{% hint style="success" %}
Use [`p5_tbl.bt` or `p5r_tbl.bt`](https://github.com/tge-was-taken/010-Editor-Templates/tree/master/templates) as a template in [010 Editor](https://www.sweetscape.com/010editor/) to easily navigate and/or change the data in ENCOUNT.TBL!
{% endhint %}

You may also want to immediately follow this function with another function, `WAIT_BATTLE()`, which takes no args and helps prevent softlocks. When the battle is over, you will return to the field the function was called from.

```c
// starts encounter 25 and waits for battle to end before continuing
CALL_BATTLE(25);
WAIT_BATTLE();
```

#### Variants

| Function Name                                               | Description                                                                                                                           |
| ----------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------- |
| CALL\_EVENTBATTLE(int eventID, int subID, int encounterID); | Calls a battle attached to an event. Plays the event first.                                                                           |
| FLD\_START\_BOSS(int bossID);                               | Starts a boss/midboss battle. Argument is the number of the procedure in boss.bf that starts the battle. May alter story progression. |

### void CALL\_FIELD(int majorID, int minorID, int entrance, int unknown);

The `CALL_FIELD()` func can be used to warp to another area in the game. This can be a town, dungeon, safe room, or even special places like the Velvet Room or title screen. Mementos and non-existant fields crash, so use caution.

Entrance refers to which spawn point to start the player's position at. These are usually set in the field's .FBN file. Use `0` if you're not sure. The unknown value is usually set to `0` as well.

```c
// Warp to the Velvet Room
CALL_FIELD(10,3,0,0);
```

#### Variants

| Function Name                                         | Description                                                                                        |
| ----------------------------------------------------- | -------------------------------------------------------------------------------------------------- |
| CALL\_AT\_DUNGEON(int area, int floor, int entrance); | Warps to a certain floor of a certain Mementos area.                                               |
| FLD\_MY\_PALACE\_ENTER();                             | Royal only. Enters the Theives Den. Only seems to work on saves where the Theives Den is unlocked. |

### void CALL\_EVENT(int eventMajor, int eventMinor);

`CALL_EVENT()` is a function for starting a story event scene (the kind where you can fast-forward and view the conversation log). Returns to the field the function was called from after the event is over.

There's a variant called `CALL_KF_EVENT()` that takes an extra 2 arguments (usually `0`?). This one is for field events where you often have a party member NPC following you around, for instance.

<pre class="language-c"><code class="lang-c"><strong>// Start the event where Ryuji takes you to the weapons shop
</strong><strong>CALL_KF_EVENT( 701, 101, 0, 820);
</strong><strong>// Start the event before the Morgana chase scene in Mementos
</strong>CALL_EVENT( 334, 1 );
</code></pre>

### Miscellaneous Calling Functions

The following are very self-explanatory.

| Function Name                                                                          | Description                                                                                                                                               |
| -------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------- |
| CALL\_PUBLIC\_SHOP(int shopID);                                                        | Opens up a shop window.                                                                                                                                   |
| CALL\_CHAT\_ARRIVAL(int chatID);                                                       | Starts a certain cellphone chat conversation.                                                                                                             |
| CALL\_CALENDAR();                                                                      | Starts the calendar sequence leading to the next day.                                                                                                     |
| BGM(int [waveID](https://amicitia.miraheze.org/wiki/Persona_5/ps3.cpk/sound/bgm.awb)); | Change BGM to a certain track from `bgm.awb`                                                                                                              |
| CALL\_BATTING\_CENTER();                                                               | Starts the batting minigame.                                                                                                                              |
| CALL\_FISHING\_POND();                                                                 | Starts the fishing minigame.                                                                                                                              |
| CALL\_TITLE();                                                                         | Go to the title screen.                                                                                                                                   |
| CALL\_STAFF\_ROLL();                                                                   | Starts playing the credits.                                                                                                                               |
| CALL\_WEAPON\_SHOP();                                                                  | Opens weapon shop menu.                                                                                                                                   |
| CALL\_ITEM\_SHOP();                                                                    | Opens the medicine shop menu.                                                                                                                             |
| CALL\_COMBINE\_SHOP();                                                                 | Opens the Velvet Room fusion menu.                                                                                                                        |
| <p>CALL\_NAME\_ENTRY();<br>CALL\_PHANTOM\_NAME\_ENTRY();</p>                           | <p>Opens the player/team naming menus.<br>Use <code>INIT\_IME\_DRIVER();</code> before and <code>END\_IME\_DRIVER();</code> after to prevent crashes.</p> |

## Stats

There's a function that can add points to a player's social stats.

`ADD_PC_ALL_PARAM(knowledge, charm, proficiency, guts, kindness);`

Each argument listed above is an integer. It takes hundreds of points to max out a given stat, so usually a small number is awarded at a time. If `0` is used, no points will be awarded for that type.

Follow the command with `DISP_PC_PARAM_METER();` to bring up the visual that shows the points being added and the stat levelling up.

## Money

You can add or subtract yen from the player by using the following functions.

```c
// Take 540 yen from the player
int yen = -540;
CHANGE_GLOBAL_MONEY(yen, 0);

// Add 154,000 yen and show it being added
yen = 154000;
GET_MONEY_WINDOW(yen, 0);
CALL_GLOBAL_MONEY_PANEL();
CHANGE_GLOBAL_MONEY(yen, 0);
DEL_GLOBAL_MONEY_PANEL();
```

## Personas

{% hint style="danger" %}
Unfortunately, there are no (known) ways to remove a specific Persona, check which Persona is equipped, change the equipped Persona, or change a party member's Persona using flowscript.
{% endhint %}

| Function Name                                                 | Description                                                                                                       |
| ------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------- |
| ADD\_PERSONA\_STOCK(int personaID);                           | Adds a specific Persona to your current set.                                                                      |
| CLEAR\_PERSONA\_STOCK();                                      | Removes all Personas from your current set.                                                                       |
| PERSONA\_EVOLUTION(int partyMember, int personaID);           | Evolves a party member's Persona to tier 2.                                                                       |
| SET\_PERSONA\_LV(int partyMember, int stockIndex, int level); | Sets a party member's Persona (or the protag's Persona at a specific slot) to a level from 1 to 99.               |
| CHK\_PERSONA\_EXIST(int lowerRange, int upperRange);          | Returns 1 if a Persona is found in the player's stock, returns 0 if not. I think it takes a range of Persona IDs? |

## Skills

Use the function `PERSONA_SKILL_ADD(int partyMember, int personaID, int skillID);` to give a desired skill to a character's Persona.\
Conversely, use `REMOVE_PERSONA_SKILL` for the opposite effect.

There's also `SKILL_ADD(int partyMember, int skillID);` which will do the same thing without providing a persona ID. In the case of the protagonist, it'll add the skill to the currently equipped Persona.

```c
// Give Joker's equipped Persona the skill Agi
SKILL_ADD(1, 10);
// Show the skill being added
FADEIN(0, 10);
FADE_SYNC();
FLD_REQ_FLASHBACK(152, 51);
FLD_END_FLASHBACK();
```

## Items

Giving the player items can seem a little complicated, but follow the table below and it should help.

| Type ID | Item Type      |
| ------- | -------------- |
| 0x0     | Melee Weapons  |
| 0x1000  | Armor          |
| 0x2000  | Accessories    |
| 0x3000  | Consumables    |
| 0x4000  | Key Items      |
| 0x5000  | Materials      |
| 0x6000  | Skill Cards    |
| 0x7000  | Outfits        |
| 0x8000  | Ranged Weapons |

```c
// Receive 4 of the key item "Morgana's Scarf"
ItemGet(0x4000, 72, 4);
// Show the item type, name and amount being received
GET_ITEMS_WINDOW(0);

// You can borrow this procedure to easily add items
void ItemGet(int type, int itemId, int amount)
{
    GET_ITEM_BUF_RESET();
    GET_ITEM_BUF_SET(type + itemId, amount);
    SET_ITEM_NUM(type + itemId, GET_ITEM_NUM(type + itemId) + amount);
}
```


# Persona 5 EX

Functions exclusive to DeathChaos's P5EX mod.

This library includes all the functions already found in [Persona 5](/flowscript/library-functions/persona-5).\
However, you must be using the [P5EX library downloaded from here](https://github.com/DeathChaos25/p5_library_ex) with AtlusScriptCompiler to compile scripts that use the following functions. This will also make your mod require P5EX as a dependency, since the vanilla game won't recognize these functions and will probably crash.

* void SET\_HUMAN\_LV( int lv ) -- Restored Game function, sets Joker's level to the specified level, range 1 -> 99
* void SET\_PERSONA\_LV( int PlayerID, int targetLv, int unused ) -- Restored Game function, can only be used to raise party member levels, not lower, only updates unit stats and level, not skills (note: does not work on Joker)
* EX\_PRINTF( variable args ) -- printf implementation in flowscript
* int GET\_EQUIPPED\_PERSONA( int playerID ) -- Returns the currently equipped persona ID of the specified player character, range 1 to 10
* int GET\_ENCOUNTER\_ID( void ) -- Returns the encounter ID of the current encounter the function is used on.
* void PERSONA\_EVOLUTION2( int playerID, int personaID ) -- Enhanced game function, now allows setting a target Persona to evolve to.
* void AI\_ACT\_PERSONA\_SKILL( int personaID, int battleSkillID ) -- sets target persona for enemy AI to use on certain encounters ( requires additional custom patches ) .
* int GET\_SEQ\_ID( void ) -- returns the current sequence ID the game is runnning on
* int GET\_LEARNABLE\_SKILL( int PartyMember, int SkillSlotID, int targetLv ) -- returns the skill ID on the given slot from a party member's PERSONA tbl entry, will return a skill ID if the skill is higher than the party member's current level but lower/same level as the target level (note: Joker excluded for obvious reasons)
* int GET\_PLAYER\_LV ( int PartyMember ) -- returns a party member's current level
* void SET\_TACTICS\_STATE ( int PartyMember, int TacticsState ) -- sets a party member's tactics state (Joker included) to the target value
* void AI\_SET\_ENID\_TARGETABLE\_STATE( int enemyID, bool targetableState ) -- use from encounter script, toggles enemy's ability to be targetted by players
* void AI\_SET\_TARGETABLE\_STATE( bool targetableState ) -- use inside enemy BF script, toggles enemy's own ability to be targetted by players
* void AI\_ACT\_SUMMON\_UNITS( int EnemyID, int EnemyID, int EnemyID, int EnemyID, int customBED\_subID ) -- use inside enemy BF script, summons target amount of enemies, use id 0 to not summon an enemy on selected slot, use 0 to use normal summon visual effect (note: exceeding 5 total enemies in a battle will crash the game!)

Notes:

* GET\_LEARNABLE\_SKILL gets the learnset from the actual persona tbl section of party member personas, meaning this is NOT checking the learnset stored in the save, meaning its mod compatible, if you have a custom learnset it'll just work, this also means they can learn skills if you updated the skillset in the tbl but used an existing save that has old learnset


# Persona 5 Royal


# Persona 4


# Persona 4 Golden


# Persona 3


# Persona 3 FES


# Persona 3 Portable


# SMT III: Nocturne


# Digital Devil Saga


