Persona 3 AICALC info dump by Phoenix and whoever shows up to this thread

Create detailed, step by step tutorials on how to create mods!
Post Reply
User avatar
Phoenix
Posts: 45
Joined: Sat Sep 19, 2020 9:10 am
Has liked: 12 posts
Been liked: 26 posts

Howdy! I'm Phoenix, creator of the New Moon mod for Persona 3, and the intention of this thread is to get my knowledge of this game archived on the internet. Additionally, any insightful information contributed by other forum users/ modders may be present, so if you're from five years from the future and you want to understand how this game works for your own mods or for a neat speedrunning exploit:

THIS IS FOR YOU

But enough about me, let's dig in.

A readable version of the AI can be found in this commit of New Moon (before I began modding it): https://github.com/Phoenix-neat/NewMoon ... 16fa90b5f0

Persona 3 FES (FES) will be addressed the most here, as it is the one I have the most experience with, along with the occasional mention of Persona 3 Portable (P3P). The original version (P3) will be rarely, if ever, touched on as there is no reason to mod a significantly rarer version of FES with zero advantages over such.

AICALC contains the AI for both party members and bosses. These files can be accessed by locating "FLW0" in a hex editor, selecting that and the eight bytes behind it (the FES version starts with 00 00 00 00 D9 58 01 00 46 4C 57 30) and continuing the selection down to either the bottom for the second (and last) FLW0, or to the top of the second one for the first. The party AI is first and the boss AI comes after.

The party AI ranges from (DC80h) to (2:3950h), with the boss AI from (2:3960h) to (7:FFC0h) in unmodified FES.

Additionally, FES has separate AI files for The Answer and The Journey, with The Answer's variant being called "AICALC_F". The thing is, these files are completely identical, containing all bosses in both The Journey AND The Answer IN BOTH. This information is important as it can be used to either
a) easily put bosses that are exclusive to one version into the other
b) reduce file size by allowing one to delete bosses that aren't in that version while keeping them intact in the other

The file size for either file is, for whatever ungodly reason, capped by the game at around 512kb, but this is incredibly inconsistent. For instance, I've had occasions where certain file sizes would be acceptable in The Journey, but not The Answer. When in doubt, keep it below 512kb, or use Tupelov's AI patch to bypass the size limit (more on that later).

Party AI is shared by all party members and split amongst the selectable menus, with an additional menu for Orgia mode. TECHNICALLY each party member has a separate function for each tactic, but the game will just call Yukari's version for each additional party member. The menus are ordered as follows:

AI_PC_00X_00Y

"X" being the party member ID and "Y" being the menu ID.
X has the following values:
Yukari = 2, Aigis = 3, Mitsuru = 4, Junpei = 5, Akihiko = 7, Ken = 8, Shinjiro (Metis in AICALC_F) = 9, Koromaru = A

1 and 6 typically refer to The Protagonist (Makoto) and Fuuka respectively, which is likely why they are skipped.

Y has the following values:
Act Freely = 1, Knock Down = 2, Attack Fallen = 3, Full Assault = 4, Heal and Support = 5, Conserve SP = 6, Assign Target = 7, Same Target = 8, Stand By = 9, Orgia mode = A

For example, AI_PC_005_004 is AI for Junpei Full Assault.
As obvious as this may sound, Orgia mode functions only exists for Aigis and Metis, so there is no empty AI_PC_002_00A function, it doesn't exist. Metis' orgia mode function exists in AICALC for The Journey as well, but it is unused.



Each boss, and certain unique enemies (i.e. golden hands, many enemies in Monad, etc), has their own AI function. Each function is assigned to a boss in AICALC, and it is possible to modify which enemy gets what function. Each enemy gets a function (they can share functions, most enemies have a generic enemy one) that is ordered by what number function it is. I.e., the first function is function 1, the last function is function 240. If you add functions to the game, you can get it to call these functions by the number it is.

A word of advice for freeing up space is to keep unused boss functions, but to remove the data in them. This still reduces the size greatly, but it keeps the functions in order so you don't have to reorder them all again. This will be your worst nightmare. To add more functions, remember the last one in unmodded FES is 240, so your first one will be 241, your second 242, etc. The location of the table segment that controls enemy AI assignment is right before the party AI FLW0. Enemies are ordered by their ID which can be referenced with the Enemy ID table on the wiki.



That's all for now, I'm going to go to bed. In the next edition, we'll discuss more on the file size limitations, some AI quirks, and more.

Tags:
User avatar
Phoenix
Posts: 45
Joined: Sat Sep 19, 2020 9:10 am
Has liked: 12 posts
Been liked: 26 posts

Continuing on from the last post, each boss has an AI function, however some more complex fights have several. At this point you can expect spoilers

SPOILERS

from this point onward so brace yourself. Nyx in particular has a function to call all of her message lines, a function involving Moonlit Gown, 14 functions for each of her 14 phases, and a post fight "Nyx-2" function. She's incredibly impressive. Elizabeth has a main function that deals with phase changing, checking to see if you follow the rules of battle, and checking her turn count, along with additional functions for each of her personas. The ??? shadow fight in The Answer is similar to this as well, possessing a main function and offshooting into various Persona functions when necessary. Erebus has four phases but one of these is seemingly unused.

On the topic of unused content and AI quirks:
-Arcana Emperor and Empress are horribly coded, and the chance they get to have certain affinities is all over the place/ lopsided
-Arcana Hermit has a separate phase when it is charging
-Arcana Justice and Chariot each have individual functions and a combined function
-Arcana Strength has a glitch where if she notices a party member is knocked down (typically only through stumble), she will endlessly use Vile Assault from that point on in the fight. This is because they incorrectly coded the "turn off Vile Assault phase" check to be "On" instead of "Off"
-The Reaper, Chidori, and Takaya will not check if Mind Charge is already active before using it
-Chidori will not check if Tetrakarn is already active before using it
-Jin, and later the Conceited Maya fight in The Answer, target weaknesses IN ORDER instead of at random. The order is slash, strike, pierce, fire, ice, elec, wind, hama, mudo. As a result, the bosses are incredibly predictable in that if you (for instance) have Mitsuru in your party and no phys weaknesses, he will only use Fire skills the entire fight.
-Takaya has a second phase in FES that is not possible to start as the game checks for the wrong HP percent. Instead of checking for Takaya's enemy ID HP check or the self HP check, the game calls Takaya's enemy ID from his FIRST FIGHT. The second phase would have added Mahamaon and Mamudoon. This is fixed in Persona 3 Portable...
--Editors note on this one: I could have sworn he used this move years ago but I can't get him to use it anymore, so there is a chance he only uses the second phase instead of the first, but the way the code looks implies he only gets the first
-??? has an unused phase where it would seemingly summon Psyche, but it was seemingly dropped early as there isn't much left in the function
-Erebus has a (seemingly) unused phase
-Elizabeth is technically fightable in The Answer, however she will still call her old affinity values from The Journey. This is an issue as certain new bosses in The Answer overwrite these values, so she'll call affinities that make no sense
User avatar
HxCannon
Posts: 6
Joined: Mon Oct 04, 2021 9:38 am
Has liked: 3 posts
Been liked: 1 post

Thanks for sharing the info, I always wondered how the game dealt with certain battles, specifically Elizabeth's battle, but after checking P3 and P3P scripts for a while, everything makes more sense.

I was wondering a few things about the AI, since you seem very knowledgeable about it, the first one is, how do you got the code for AI scripts? They seem to be decrypted using AtlusScriptCompiler, but as far as I know they don't work with tbl files, right? Did you take the time to transcript it to C#? ...Or am I missing something? It might very well be the case since I know more about P3P and not a lot about FES. Also, checking the dumped script, it seems the ailments are already programmed by the game, right? I was hoping we could modify their behavior in the AI table, any idea if this is possible :hee_thonk: ???
Post Reply
cron

ShrineFox 2020 - 2023
Support | Progress | Labs | Privacy | Terms
This site is NOT affiliated, associated, authorized, endorsed by, or in any way officially connected with Atlus Co., Ltd, Atlus U.S.A., Inc. or Sega Games Co., Ltd, or any of its subsidiaries or its affiliates.