Difference between revisions of "FF7/Battle/Battle Scenes/Battle AI Addresses"
my_wiki>NFITC1 (Not complete. I'll come back to this later and make links to it.) |
my_wiki>NFITC1 (→Actor Specific: Still not competely done...) |
||
Line 106: | Line 106: | ||
==Actor Specific== | ==Actor Specific== | ||
− | These values are reflections of a given actor's status. They include some obvious things like Statuses, Level, HP, MP, etc and a few abstract things like Animation IDs for reactions. Every actor has their own copy of these values that reflects their instance. These values are accessed by masking the address with a specific actor(s) in the script. | + | These values are reflections of a given actor's status. They include some obvious things like Statuses, Level, HP, MP, etc and a few abstract things like Animation IDs for reactions. Every actor has their own copy of these values that reflects their instance. These values are accessed by masking the address with a specific actor(s) in the script. Using the mask will let the script interpreter know which set of physical addresses to use. |
{| border="1" cellspacing="1" cellpadding="3" style="border: 1px solid black; border-collapse: collapse;" | {| border="1" cellspacing="1" cellpadding="3" style="border: 1px solid black; border-collapse: collapse;" | ||
Line 230: | Line 230: | ||
|} | |} | ||
<br/> | <br/> | ||
− | <p> | + | <p>Thanks to unchecked memory leaks<sup>1</sup>, any actor can directly access another actor's script values. The following table is to be read across to show what address should be used to access another actor's values starting at 4000. For example, Actor 2 can use 4D00 to access Actor6's values. Also, Actor 8 can use 2540 to access Actor 1's values. |
− | NOTES:<br/> | + | {| border="1" cellspacing="1" cellpadding="3" style="border: 1px solid black; border-collapse: collapse;" |
− | 1 - | + | ! style="background:rgb(204,204,204)" | Actors<sup>2</sup> |
+ | ! style="background:rgb(204,204,204)" | Actor 0 | ||
+ | ! style="background:rgb(204,204,204)" | Actor 1 | ||
+ | ! style="background:rgb(204,204,204)" | Actor 2 | ||
+ | ! style="background:rgb(204,204,204)" | Actor 3 | ||
+ | ! style="background:rgb(204,204,204)" | Actor 4 | ||
+ | ! style="background:rgb(204,204,204)" | Actor 5 | ||
+ | ! style="background:rgb(204,204,204)" | Actor 6 | ||
+ | ! style="background:rgb(204,204,204)" | Actor 7 | ||
+ | ! style="background:rgb(204,204,204)" | Actor 8 | ||
+ | ! style="background:rgb(204,204,204)" | Actor 9 | ||
+ | ! style="background:rgb(204,204,204)" | RAVs<sup>3</sup> | ||
+ | |- | ||
+ | ! style="background:rgb(204,204,204)" | Actor 0 | ||
+ | | * | ||
+ | | 4340 | ||
+ | | 4680 | ||
+ | | 49C0 | ||
+ | | 4D00 | ||
+ | | 5040 | ||
+ | | 5380 | ||
+ | | 56C0 | ||
+ | | 5A00 | ||
+ | | 5D40 | ||
+ | | 6080 | ||
+ | |- | ||
+ | ! style="background:rgb(204,204,204)" | Actor 1 | ||
+ | | 2220 | ||
+ | | * | ||
+ | | 4340 | ||
+ | | 4680 | ||
+ | | 49C0 | ||
+ | | 4D00 | ||
+ | | 5040 | ||
+ | | 5380 | ||
+ | | 56C0 | ||
+ | | 5A00 | ||
+ | | 5D40 | ||
+ | |- | ||
+ | ! style="background:rgb(204,204,204)" | Actor 2 | ||
+ | | 2220 | ||
+ | | 2540 | ||
+ | | * | ||
+ | | 4340 | ||
+ | | 4680 | ||
+ | | 49C0 | ||
+ | | 4D00 | ||
+ | | 5040 | ||
+ | | 5380 | ||
+ | | 56C0 | ||
+ | | 5A00 | ||
+ | |- | ||
+ | ! style="background:rgb(204,204,204)" | Actor 3 | ||
+ | | 2220 | ||
+ | | 2540 | ||
+ | | 2880 | ||
+ | | * | ||
+ | | 4340 | ||
+ | | 4680 | ||
+ | | 49C0 | ||
+ | | 4D00 | ||
+ | | 5040 | ||
+ | | 5380 | ||
+ | | 56C0 | ||
+ | |- | ||
+ | ! style="background:rgb(204,204,204)" | Actor 4 | ||
+ | | 2220 | ||
+ | | 2540 | ||
+ | | 2880 | ||
+ | | 2BC0 | ||
+ | | * | ||
+ | | 4340 | ||
+ | | 4680 | ||
+ | | 49C0 | ||
+ | | 4D00 | ||
+ | | 5040 | ||
+ | | 5380 | ||
+ | |- | ||
+ | ! style="background:rgb(204,204,204)" | Actor 5 | ||
+ | | 2220 | ||
+ | | 2540 | ||
+ | | 2880 | ||
+ | | 2BC0 | ||
+ | | 2F00 | ||
+ | | * | ||
+ | | 4340 | ||
+ | | 4680 | ||
+ | | 49C0 | ||
+ | | 4D00 | ||
+ | | 5040 | ||
+ | |- | ||
+ | ! style="background:rgb(204,204,204)" | Actor 6 | ||
+ | | 2220 | ||
+ | | 2540 | ||
+ | | 2880 | ||
+ | | 2BC0 | ||
+ | | 2F00 | ||
+ | | 3240 | ||
+ | | * | ||
+ | | 4340 | ||
+ | | 4680 | ||
+ | | 49C0 | ||
+ | | 4D00 | ||
+ | |- | ||
+ | ! style="background:rgb(204,204,204)" | Actor 7 | ||
+ | | 2220 | ||
+ | | 2540 | ||
+ | | 2880 | ||
+ | | 2BC0 | ||
+ | | 2F00 | ||
+ | | 3240 | ||
+ | | 3580 | ||
+ | | * | ||
+ | | 4340 | ||
+ | | 4680 | ||
+ | | 49C0 | ||
+ | |- | ||
+ | ! style="background:rgb(204,204,204)" | Actor 8 | ||
+ | | 2220 | ||
+ | | 2540 | ||
+ | | 2880 | ||
+ | | 2BC0 | ||
+ | | 2F00 | ||
+ | | 3240 | ||
+ | | 3580 | ||
+ | | 38C0 | ||
+ | | * | ||
+ | | 4340 | ||
+ | | 4680 | ||
+ | |- | ||
+ | ! style="background:rgb(204,204,204)" | Actor 9 | ||
+ | | 2220 | ||
+ | | 2540 | ||
+ | | 2880 | ||
+ | | 2BC0 | ||
+ | | 2F00 | ||
+ | | 3240 | ||
+ | | 3580 | ||
+ | | 38C0 | ||
+ | | 3C00 | ||
+ | | * | ||
+ | | 4340 | ||
+ | |} | ||
+ | This is mostly unhelpful as formations can vary greatly and actors can still indirectly access each other's values based on controllable conditions. There are lots of examples of indirect access, the memory leak trick is just interesting. | ||
+ | </p> | ||
+ | <br/> | ||
+ | <p>NOTES:<br/> | ||
+ | 1 - Address values are only checked by the minimum value and stored accordingly. The structure in memory stores the Global Variables first, the Actor Variables second, and the Random Access Variables last. Technically, a value of 0xFFFF could be used as an address, but that would result in a memory leak producing erratic results.<br/> | ||
+ | 2 - Actors 0-2 are player controlled characters, Actors 4-9 are enemies. Actor 3 is a omnipresent battle actor that holds formation AI, if it exists. It does nothing on its own and is only used in a few boss battles.<br/> | ||
+ | 3 - This will access the Random Access Variables starting at 0x0000. This is stupid as it requires more work to get to them. Don't do it this way!<br/> | ||
+ | </p> |
Revision as of 21:26, 14 June 2012
In this page, an "actor" is defined as an entity instance in a battle (scene). The "current actor" is an actor that is executing a script or performing an action. An "active actor" is one that can perform actions. An "action" is defined as an event with a visual representation in battle (eg. an attack or a position change).
Most of the complexities of AI scripts use different memory addresses to make decisions based on the actor performing an action or the target of an action. There are three categories of address each spanning a separate useable1 address ranges.
Range | Usage |
---|---|
0x0000 - 0x1FFF | Random Access Variables. No initial value or significance to battle. |
0x2000 - 0x21DF | Globally accessible values. Values are the same for all actors. |
0x4000 - 0x433F | Actor specific values. Contains information such as HP, MP, Level, stats, etc. One for each Actor, 10 in all. |
Each address references a specific bit of memory rather than a byte which means individual bits can be manipulated without using BIT-wise operations in script. Every 8 address values is the beginning of a byte (ie. 0x0000, 0x0008, etc.). The code used to access an address determines whether a bit, byte, word, or dword is being read/written.
Addresses must be accessed directly. There is no pointer support to these values accessible in AI scripts.
Random Access Variables
These values are used between scripts and not automatically set/cleared at any time during battle. If an address is set to a specific value in one script, it will retain that value when the next script begins. They can all be treated as having no initial value.
Global Values
Generally these contain information about the battle itself. These values are the same when any actor accesses them, although they do change to reflect the battle's events.
Address | Value |
---|---|
0x2000 | Command Index of last action performed |
0x2008 | Action Index of last action performed |
0x2010 | Memory 1/2 Bank access value |
0x2018 | DUMMY. Used in one script in a test enemy. |
0x2020 | Battle Formation (side, pincer, pre-emptive, etc.) |
0x2038 | Limit Level. Only used by Vincent during transformation. |
0x2050 | Active Actor List. A bit mask of all active (scripts enabled) actors. |
0x2060 | Single bit indicating which actor owns the script that is currently executing. Changes as scripts are triggered. |
0x2070 | Bit mask of actors indicating targets of the current action. Should be set prior to any action. |
0x2080 | Bit mask of actors indicating actors the current actor considers as allies. Changes as scripts are triggered. |
0x2090 | Bit mask of active actors indicating actors the current actor considers as allies. Changes as scripts are triggered. |
0x20A0 | Bit mask of actors indicating actors the current actor considers as enemies. Changes as scripts are triggered. |
0x20B0 | Bit mask of active actors indicating actors the current actor considers as enemies. Changes as scripts are triggered. |
0x20C0 | Bit mask of active player's characters |
0x20E0 | Bit mask of all active and inactive actors present in the battle. |
0x2110 | Set of flags indicating battle rewards (functions unknown). |
0x2120 | Elements of last performed action. |
0x2140 | Formation Index of the current battle. |
0x2150 | Index of last performed action. |
0x2160 | Some sort of flags (unknown effect). |
0x2170 | Special Attack Flags. |
0x2180 | Unknown |
0x21A0 | Something to do with String display (not sure what). |
0x21C0 | Party's Gil |
Actor Specific
These values are reflections of a given actor's status. They include some obvious things like Statuses, Level, HP, MP, etc and a few abstract things like Animation IDs for reactions. Every actor has their own copy of these values that reflects their instance. These values are accessed by masking the address with a specific actor(s) in the script. Using the mask will let the script interpreter know which set of physical addresses to use.
Address | Value |
---|---|
0x4000 | Bitmask of current Statuses |
0x4020 | Set of flags relating to situation (defending, backrow, etc.). |
0x4040 | Unknown |
0x4048 | Level |
0x4058 | Greatest Elemental Damage modifier (No damage, half, normal, etc.) |
0x4060 | Unknown |
0x4068 | Physical Attack Power |
0x4070 | Magic Attack Power |
0x4078 | Physical Evade |
0x4080 | Idle Animation ID |
0x4088 | Damaged Animation ID |
0x4090 | Back Damage Multiplier |
0x4098 | Model Size (default is 16) |
0x40A0 | Dexterity |
0x40A8 | Luck |
0x40B0 | Unknown |
0x40B8 | Set to equal 0x4060 under unknown condition |
0x40C0 | Target(s) of last action performed by actor |
0x40D0 | Previous Attacker |
0x40E0 | Previous Physical Attacker |
0x40F0 | Previous Magical Attacker |
0x4100 | Physical Defense Rating |
0x4110 | Magical Defense Rating |
0x4120 | Index of actor |
0x4130 | Absorbed Elements |
0x4140 | Current MP |
0x4150 | Max MP |
0x4160 | Current HP |
0x4180 | Max HP |
0x4220 | Initial Statuses |
0x4268 | Magic Evade |
0x4270 | Row |
0x4278 | Unknown |
0x4280 | Gil stolen (Enemies only) |
0x4290 | Item stolen (Enemies only) |
0x42A0 | Unknown |
0x42B0 | AP actor is worth |
0x42C0 | Gil actor is worth |
0x42E0 | EXP actor is worth |
Thanks to unchecked memory leaks1, any actor can directly access another actor's script values. The following table is to be read across to show what address should be used to access another actor's values starting at 4000. For example, Actor 2 can use 4D00 to access Actor6's values. Also, Actor 8 can use 2540 to access Actor 1's values.
Actors2 | Actor 0 | Actor 1 | Actor 2 | Actor 3 | Actor 4 | Actor 5 | Actor 6 | Actor 7 | Actor 8 | Actor 9 | RAVs3 |
---|---|---|---|---|---|---|---|---|---|---|---|
Actor 0 | * | 4340 | 4680 | 49C0 | 4D00 | 5040 | 5380 | 56C0 | 5A00 | 5D40 | 6080 |
Actor 1 | 2220 | * | 4340 | 4680 | 49C0 | 4D00 | 5040 | 5380 | 56C0 | 5A00 | 5D40 |
Actor 2 | 2220 | 2540 | * | 4340 | 4680 | 49C0 | 4D00 | 5040 | 5380 | 56C0 | 5A00 |
Actor 3 | 2220 | 2540 | 2880 | * | 4340 | 4680 | 49C0 | 4D00 | 5040 | 5380 | 56C0 |
Actor 4 | 2220 | 2540 | 2880 | 2BC0 | * | 4340 | 4680 | 49C0 | 4D00 | 5040 | 5380 |
Actor 5 | 2220 | 2540 | 2880 | 2BC0 | 2F00 | * | 4340 | 4680 | 49C0 | 4D00 | 5040 |
Actor 6 | 2220 | 2540 | 2880 | 2BC0 | 2F00 | 3240 | * | 4340 | 4680 | 49C0 | 4D00 |
Actor 7 | 2220 | 2540 | 2880 | 2BC0 | 2F00 | 3240 | 3580 | * | 4340 | 4680 | 49C0 |
Actor 8 | 2220 | 2540 | 2880 | 2BC0 | 2F00 | 3240 | 3580 | 38C0 | * | 4340 | 4680 |
Actor 9 | 2220 | 2540 | 2880 | 2BC0 | 2F00 | 3240 | 3580 | 38C0 | 3C00 | * | 4340 |
This is mostly unhelpful as formations can vary greatly and actors can still indirectly access each other's values based on controllable conditions. There are lots of examples of indirect access, the memory leak trick is just interesting.
NOTES:
1 - Address values are only checked by the minimum value and stored accordingly. The structure in memory stores the Global Variables first, the Actor Variables second, and the Random Access Variables last. Technically, a value of 0xFFFF could be used as an address, but that would result in a memory leak producing erratic results.
2 - Actors 0-2 are player controlled characters, Actors 4-9 are enemies. Actor 3 is a omnipresent battle actor that holds formation AI, if it exists. It does nothing on its own and is only used in a few boss battles.
3 - This will access the Random Access Variables starting at 0x0000. This is stupid as it requires more work to get to them. Don't do it this way!