Author Topic: [FFVII] Enemy AI Script questions  (Read 29965 times)

DynamixDJ

  • *
  • Posts: 240
  • 1111 1111 0111
    • View Profile
Re: [FFVII] Enemy AI Script questions
« Reply #50 on: 2019-03-22 15:27:25 »
What's going on here with the Grangalan Jr.Jr.?

Code: [Select]
MAIN:

0x000 If (Random MOD 4 == 0)
0x000 {
0x009 }
0x009 Else
0x009 {
0x00C }
0x00C Else
0x00C {
0x00F BattleAddr(&TarSelected) <- RandomBit(BattleAddr(&AllPlayers))
0x017 Perform("Silver Wheel"[01DC], EnemyAttack)
0x01D }
0x01D Else
0x01D {
0x020POP(Random MOD 4)
0x021SCRIPT END

Is this a 1/4 chance of using silver wheel or a 3/4 chance?

the Jr.Jr. has an unused Attack (Stop Eye 01DB) which has a 71% chance of casting Stop on the target. It's likely that they decided this was too OP and removed the attack from the script (imagine how hard it would be in the battle square).

It looks to me as though they have removed the Stop Eye attack from the script but didn't clean it properly. I can't tell if this is running sequentially or not. I think it should have been initially a 1/4 chance use Stop Eye and a 3/4 chance use Silver Wheel.

Terrence Ferguson has deciphered it as a 1/4 chance of using Silver Wheel, but I suspect that it's wrong, it's actually a 3/4 chance and a 1/4 chance it'll do nothing. Testing against them seems to suggest so, anyway. NF?
« Last Edit: 2019-03-22 15:29:50 by DynamixDJ »

DynamixDJ

  • *
  • Posts: 240
  • 1111 1111 0111
    • View Profile
Re: [FFVII] Enemy AI Script questions
« Reply #51 on: 2019-03-22 20:27:41 »
When does the "Custom Event" script get played? On the Mystery Ninja, we can see script which disables the mystery ninja's AI script and target-ability. Does this get played upon the Enemy's death?

Also, what does "RunScript(15)" do?
« Last Edit: 2019-03-22 21:05:51 by DynamixDJ »

JBedford128

  • *
  • Posts: 113
    • View Profile
Re: [FFVII] Enemy AI Script questions
« Reply #52 on: 2019-03-22 23:49:21 »
RunScript(15) runs the enemy's sixteenth script: What Proud Clod calls "Custom Event 8". All custom scripts are executed in this way.

DynamixDJ

  • *
  • Posts: 240
  • 1111 1111 0111
    • View Profile
Re: [FFVII] Enemy AI Script questions
« Reply #53 on: 2019-03-23 02:07:07 »
Ah OK, cool. That answers both questions :)

The wiki marks 2018 as "DUMMY. Used in one script in a test enemy." I suspect this is accessing Memory Bank 7/F (not that it does anything with it)

DynamixDJ

  • *
  • Posts: 240
  • 1111 1111 0111
    • View Profile
Re: [FFVII] Enemy AI Script questions
« Reply #54 on: 2019-03-23 15:25:00 »
I made an interesting discovery yesterday. I was making a list of all of the test formations, and the backgrounds that they appear on. I didn't include any duplicate formations, only unique ones, and take note of the test Encounters found on the Debug Background:

Code: [Select]
  DEBUG TEST AREA BACKGROUND:
.----------------------------------------------------------------------------.
|   Test Encounter #1  EXP - 1000      1st Row: 1x êúô0(äñ)                  |
|                      AP  - 100                                             |
|                      GIL - 10,000                                          |
|                                                                            |
|   Test Encounter #2  EXP - 500,000   1st Row: 2x êúô2(ñ)                   |
|                      AP  - 10,000    2nd Row: 2x êúô2(ñ)                   |
|                      GIL - 500,000   3rd Row: 1x êúô2(ñ)                   |
|                                                                            |
|   Test Encounter #4  EXP - 16        1st Row: 1x êúô7(úñA), 1x êúô8(úñB)   |
|                      AP  - 2                                               |
|                      GIL - 10                                              |
|                                                                            |
|   Test Encounter #5  EXP - 24        1st Row: 1x êúô7(úñA), 1x êúô8(úñB),  |
|                      AP  - 3                                  1x êúô9(úñC) |
|                      GIL - 15                                              |
|                                                                            |
|   Test Encounter #6  EXP - 32        1st Row: 1x êúô7(úñA), 2x êúô8(úñB),  |
|                      AP  - 4                                  1x êúô9(úñC) |
|                      GIL - 20                                              |
|                                                                            |
|   Test Encounter #7  EXP - 1000      1st Row: 1x êúô0(äñ)                  |
|      Back Attack     AP  - 100                                             |
|          Run = 2     GIL - 10,000                                          |
| Battle Won't End                                                           |
|                                                                            |
|   Test Encounter #8  EXP - 1000      1st Row: 1x êúô0(äñ)                  |
|      Side Attack     AP  - 100                                             |
|                      GIL - 10,000                                          |
|                                                                            |
|   Test Encounter #9  EXP - 2000      1st Grp: 1x êúô0(äñ)                  |
|      Pinc Attack     AP  - 200       2nd Grp: 1x êúô0(äñ)                  |
| Battle Won't End     GIL - 20,000                                          |
'----------------------------------------------------------------------------'

  FOREST BACKGROUND:
 NOTE - The first encounter could be found in the Well in Corel Prison in the
         JORG version as a 12.5% encounter chance.
.----------------------------------------------------------------------------.
|   Test Encounter #1  EXP - 4000      1st Row: 4x êúô0(äñ)                  |
|                      AP  - 400                                             |
|                      GIL - 40,000                                          |
|                                                                            |
|   Test Encounter #2  EXP - 96        1st Row: 1x êúô4(ëöù)                 |
|                      AP  - 6         2nd Row: 2x êúô4(ëöù)                 |
|                      GIL - 240                                             |
|                                                                            |
|   Test Encounter #3  EXP - 80        1st Row: 1x êúô4(ëöù), 1x êúô5(áñô),  |
|                      AP  - 5                                   1x êúô6(ñâ) |
|                      GIL - 100                                             |
|                                                                            |
|   Test Encounter #4  EXP - 6000      1st Row: 6x êúô0(äñ)                  |
|                      AP  - 600                                             |
|                      GIL - 60,000                                          |
'----------------------------------------------------------------------------'

  TRAIN GRAVEYARD BACKGROUND:
.----------------------------------------------------------------------------.
|   Test Encounter #1  EXP - 101,012   1st Row: 1x êúô0(äñ)                  |
|                      AP  - 2101      2nd Row: 1x êúô1(), 1x êúô2(ñ)        |
|                      GIL - 110,025                                         |
'----------------------------------------------------------------------------'

  DIRT WASTELAND BACKGROUND:
.----------------------------------------------------------------------------.
|   Test Encounter #1  EXP - 72        1st Row: 2x êúô4(ëöù), 1x êúô6(ñâ)    |
|      Back-Attack     AP  - 5                                               |
|          Run = 2     GIL - 165                                             |
'----------------------------------------------------------------------------'

  SNOW BACKGROUND:
.----------------------------------------------------------------------------.
|   Test Encounter #1  EXP - 40        1st Row: 1x êúô6(ñâ), 1x êúô4(ëöù)    |
|      Side-Attack     AP  - 3                                               |
|                      GIL - 85                                              |
'----------------------------------------------------------------------------'

  SEWERS BACKGROUND:
.----------------------------------------------------------------------------.
|   Test Encounter #1  EXP - 128       1st Grp: 2x êúô4(ëöù)                 |
|      Pinc Attack     AP  - 8         2nd Grp: 2x êúô4(ëöù)                 |
| Battle Won't End     GIL - 320                                             |
'----------------------------------------------------------------------------'

  COREL VALLEY BACKGROUND:
.----------------------------------------------------------------------------.
|   Test Encounter #1  EXP - 6000      1st Row: 2x êúô0(äñ) <C>              |
|  No Victory Pose     AP  - 600       2nd Row: 1x êúô0(äñ) <C>              |
| Battle Won't End     GIL - 60,000    3rd Row: 3x êúô0(äñ)                  |
|                                                                            |
|   Test Encounter #2  EXP - 72        1st Row: 2x êúô1() <C>                |
|  No Victory Pose     AP  - 6         2nd Row: 1x êúô1() <C>                |
|                      GIL - 150       3rd Row: 3x êúô1()                    |
'----------------------------------------------------------------------------'

  BLANK BACKGROUND:
.----------------------------------------------------------------------------.
|   Test Encounter #1  EXP - 100,000   1st Row: 1x êúô2(ñ)                   |
|                      AP  - 2000                                            |
|                      GIL - 100,000                                         |
'----------------------------------------------------------------------------'

  SISTER RAY BASE BACKGROUND:
.----------------------------------------------------------------------------.
|   Test Encounter #1  EXP - 100,000   1st Row: 1x êúô2(ñ)                   |
|                      AP  - 2000                                            |
|                      GIL - 100,000                                         |
'----------------------------------------------------------------------------'

  KALM FLASHBACK DRAGON BATTLE BACKGROUND:
.----------------------------------------------------------------------------.
|   Test Encounter #1  EXP - 100       1st Row: 2x Mighty Grunt              |
|     Auto Pre-Emp     AP  - 10                                              |
|                      GIL - 196                                             |
'----------------------------------------------------------------------------'

  COREL TRAIN BATTLE BACKGROUND:
.----------------------------------------------------------------------------.
|   Test Encounter #1  EXP - 100       1st Row: 2x Mighty Grunt              |
|                      AP  - 10                                              |
|                      GIL - 196                                             |
'----------------------------------------------------------------------------'

  REACTOR 5 BACKGROUND:
.----------------------------------------------------------------------------.
|   Test Encounter #1  EXP - 4320      1st Row: 3x Adamantaimai              |
|                      AP  - 600       2nd Row: 3x Adamantaimai              |
|                      GIL - 12,000                                          |
'----------------------------------------------------------------------------'

There are exactly enough formations on the Debug Background to fill out each slot on a field map! It's likely that these formations were once used on one of the blackbg maps to test encounters (the Back Attack would have filled both back-attack slots with a probable rating of 2 or 4 for each)

nfitc1

  • *
  • Posts: 3011
  • I just don't know what went wrong.
    • View Profile
    • WM/PrC Blog
Re: [FFVII] Enemy AI Script questions
« Reply #55 on: 2019-03-23 21:33:28 »
There's more debug info in the Japanese PSX edition. There is no scene.bin as that is unique to the PC edition, but the test enemies and formations were way different in the initial release. Every other edition after the first Japan release had their test enemies replaced with those pyramids.

As for 2018, this is only used in one of (all of?) the debug enemies and doesn't seem to be assigned anything.

What I'll say abou Grangalan Jr. Jr. is that PrC's AI disassembler isn't perfect. That's because the AI scripts themselves aren't perfect. Sometimes jumps will jump to jumps and other times jumps won't be reachable at all. This always throws off the disassemly. I think the Kalm wolf has some behavior like this, but it has a very simple script. Anyway, when this happens you'll have to diagnose the script by hand/sight.
TFergusson is incorrect and the script indicates a 3/4 chance of silver wheel. Take a look at the binary script:
Code: [Select]
81
60  04
34
60  00
71  000F
72  0020
72  000F
...
This is the relevant part at least. The code 71 will jump if the top two pops ARE NOT EQUAL. So the (Random Mod 4) will NOT trigger this if it is equal 0 and it will jump to 0020 at the next step. The confusing bit is the unreachable 72  000F that is located at 0x00C. This is confusing the disassembly and causing the weird output. This actually may be an artifact of the removed Stop Eye action.

JBedford128

  • *
  • Posts: 113
    • View Profile
Re: [FFVII] Enemy AI Script questions
« Reply #56 on: 2019-03-23 23:25:53 »
There is no scene.bin as that is unique to the PC edition
The PlayStation versions use a scene.bin. Same format too-- except the original Japanese releases which had some additional padding. I think the only difference between the original English PS and PC scene.bins is the AI for the Chocobo enemy.
« Last Edit: 2019-03-23 23:32:28 by JBedford128 »

nfitc1

  • *
  • Posts: 3011
  • I just don't know what went wrong.
    • View Profile
    • WM/PrC Blog
Re: [FFVII] Enemy AI Script questions
« Reply #57 on: 2019-03-24 00:01:37 »
Ahh, shoot! You’re right. I was thinking about the battle.lgp that contain the enemy model data. I’ve gotten less smart lately, apparently. :P

DynamixDJ

  • *
  • Posts: 240
  • 1111 1111 0111
    • View Profile
Re: [FFVII] Enemy AI Script questions
« Reply #58 on: 2019-03-24 19:52:21 »
Thanks for clearing that up about the Grangalan, I had a feeling it had something to do with the way the jumps were working. I've spent a little bit of time looking at the non-disassembled version and things start to make a bit more sense. Also, whenever LMSK or HMSK is used to select the target with the highest/lowest X (HP/MP/Def etc), Pr Cl displays "Bade Code" and the address of the LMSK/HMSK.

The more I learn the easier this becomes. Note to self for my mod: c+p Bagnadrana's script as a template:

Code: [Select]
0x000: PUSH (2070) Type (12)
0x003: PSHA (20A0) Type (02)
0x006: RBYT
0x007: STRA
0x008: RWRD
0x009: PUSH (04) Type (01)
0x00B: MOD
0x00C: PUSH (00) Type (01)
0x00E: JNEQ (001D)
0x011: PUSH (20) Type (01)
0x013: PUSH (0189) Type (02)
0x016: ATTK
0x017: JUMP (0048)
0x01A: JUMP (0022)
0x01D: PUSH (01) Type (01)
0x01F: JNEQ (002E)
0x022: PUSH (20) Type (01)
0x024: PUSH (01BE) Type (02)
0x027: ATTK
0x028: JUMP (0048)
0x02B: JUMP (0033)
0x02E: PUSH (02) Type (01)
0x030: JNEQ (003F)
0x033: PUSH (20) Type (01)
0x035: PUSH (01E5) Type (02)
0x038: ATTK
0x039: JUMP (0048)
0x03C: JUMP (003F)
0x03F: PUSH (20) Type (01)
0x041: PUSH (01E6) Type (02)
0x044: ATTK
0x045: JUMP (0048)
0x048: POP
0x049: END

produces an even 1/4 chance of using one of four attacks. Lovely and simple :). Only use attacks that select a single target.
« Last Edit: 2019-03-24 19:54:32 by DynamixDJ »

nfitc1

  • *
  • Posts: 3011
  • I just don't know what went wrong.
    • View Profile
    • WM/PrC Blog
Re: [FFVII] Enemy AI Script questions
« Reply #59 on: 2019-03-24 19:54:37 »
Does it actually say “bade code”? I wouldn’t put it past me back then. :P

DynamixDJ

  • *
  • Posts: 240
  • 1111 1111 0111
    • View Profile
Re: [FFVII] Enemy AI Script questions
« Reply #60 on: 2019-03-25 02:57:28 »
lol, no it doesn't, that was a runscript error in my head lol

What's going on 'ere with the 2-Faced? It seems as though the 2-Faced should have a 100% chance of countering with one of its two attacks if it is the last enemy alive, however, after testing, that's not the case:

Code: [Select]
0x000LocalVar:0000 <-  (BitCount(BattleAddr(&2060).BattleAddr(&4060)) == BattleAddr(&2050).BattleAddr(&4060))
0x014LocalVar:0000 <- LocalVar:0000 AND  NOT BattleAddr(&2060)
0x020LocalVar:0020 <-  (LocalVar:0000.BattleAddr(&4120) == 107)
0x02E If ( ( (LocalVar:0000.BattleAddr(&4000) == 1)  And  (LocalVar:0020.BattleAddr(&4000) == 0) ) )
0x02E {
0x046 If (Not  (Random MOD 2) )
0x046 {
0x04E BattleAddr(&2070) <- RandomBit(BattleAddr(&20A0))
0x056 Perform("Self-destruct"[01ED], EnemyAttack)
0x05C BattleAddr(&2060).BattleAddr(&4020) <- 0
0x066 BattleAddr(&2060).BattleAddr(&4023) <- 0
0x070 BattleAddr(&2060).BattleAddr(&4022) <- 0
0x07A BattleAddr(&2060).BattleAddr(&4024) <- 0
0x084 }
0x084 Else
0x084 {
0x087 BattleAddr(&2070) <- BattleAddr(&20A0)
0x08E Perform("Cure3"[0002], EnemyAttack)
0x093 BattleAddr(&2060).BattleAddr(&4020) <- 0
0x09D BattleAddr(&2060).BattleAddr(&4023) <- 0
0x0A7 BattleAddr(&2060).BattleAddr(&4022) <- 0
0x0B1 BattleAddr(&2060).BattleAddr(&4024) <- 0
0x0BB }
0x0BB Else
0x0BB {
0x0BE If (Random MOD 8 == 0)
0x0BE {
0x0C7 BattleAddr(&2070) <- RandomBit(BattleAddr(&20A0))
0x0CF Perform("Self-destruct"[01ED], EnemyAttack)
0x0D5 BattleAddr(&2060).BattleAddr(&4020) <- 0
0x0DF BattleAddr(&2060).BattleAddr(&4023) <- 0
0x0E9 BattleAddr(&2060).BattleAddr(&4022) <- 0
0x0F3 BattleAddr(&2060).BattleAddr(&4024) <- 0
0x0FD }
0x0FD Else
0x0FD {
0x100 }
0x100 Else
0x100 {
0x103 If (Random MOD 8 == 1)
0x103 {
0x108 BattleAddr(&2070) <- BattleAddr(&20A0)
0x10F Perform("Cure3"[0002], EnemyAttack)
0x114 BattleAddr(&2060).BattleAddr(&4020) <- 0
0x11E BattleAddr(&2060).BattleAddr(&4023) <- 0
0x128 BattleAddr(&2060).BattleAddr(&4022) <- 0
0x132 BattleAddr(&2060).BattleAddr(&4024) <- 0
0x13C }
0x13C Else
0x13C {
0x13F }
0x13F Else
0x13F {
0x142 }
0x142 Else
0x142 {
0x145 POP(Random MOD 8)
0x146SCRIPT END

I *think* the problem lies with the use of 2050, which is "Active Actors". This means that the initial script for the first check only runs if the 2-Faced is the last actor alive, which abviously can't happen becuase you'd get a game over before that.

If 2050 was changed to 2090 ("Active Enemies") would that fix the problem? I'm gonna test to find out. I've noted down 2090 as active enemies, although technically 2090 is "all actors that the current actor regards as an ally", but to make it easier in my mind I've just jotted it as active enemies (and 20B0 as Active Players).

What one earth?? Why is the vanilla steam version giving my formation IDs that are 4 out? I'm fighting the Mt. Corel Bridge enemies and the forced Cokatolis battle in Corel Prison, all the ID#s are -4. The Formation in the well was #516 1x 2-Face and 2x Bandit instead of #520 4- 2 Faced Pnicer Attack.

What's up with that? I've checked the flevel.lgp in C:\Steam Library\steamapps\common\FINAL FANTASY VII\data\field and the formation IDs are correct.

Regardless, chenging 2050 to 2090 did not work, so I've no clue what's going on here....
Ah, maybe it is correct but it's only triggering the script if it's the last *2-Faced* alive, not the last enemy. I guess I'll have to fight the Land Worm #524 to get the 4x 2-Faced #520 lol
« Last Edit: 2019-03-25 03:36:11 by DynamixDJ »

DynamixDJ

  • *
  • Posts: 240
  • 1111 1111 0111
    • View Profile
Re: [FFVII] Enemy AI Script questions
« Reply #61 on: 2019-03-25 03:59:03 »
OK I'd somehow corrupted the scene.bin, I've sorted that now, but the corrected script did not work. Changing it to 2050 to 2080 didn't work either.

How di I make it so the 2-Faced passes the check at 0x02E and has a 100% chance of countering when it is the last 2 Faced alive as intended?

edit - I've been trying for hours to get the script working properly. I've tried changing:

0x014LocalVar:OtherActors <- LocalVar:OtherActors AND  NOT BattleAddr(&2060)

to

0x014LocalVar:OtherActors <- LocalVar:OtherActors AND  NOT BattleAddr(&2060).BattleAddr(&4060)

That took me a while to work out that the MASK opcode was needed. that didn't work.

Then I tried changing

If ( ( (LocalVar:0000.BattleAddr(&4000) == 1)  And  (LocalVar:0020.BattleAddr(&4000) == 0) ) )

to

If ( ( (LocalVar:0000.BattleAddr(&4000) == 1)  And  (LocalVar:0020.BattleAddr(&4000) == 1) ) )

that didn't work. Then I tried the same thing but the 2050 to 2080. Still didn't work. Then I tried a combination of all different things, and now I give up and I'm going to bed.

I just wanna make sure I understand this correctly

0x000LocalVar:0000 <-  (BitCount(BattleAddr(&2060).BattleAddr(&4060)) == BattleAddr(&2050).BattleAddr(&4060))

First this looks at the bit of the current character ID, and changes it to the bit of all active character iDs. So if there are four enemies (in the well) then there are 7 actors, and LocalVar:0000 to this point will be 127, or [0111 1111].

Then, the LovalVar:000 AND NOT 2060 toggles the bit of the current actor, so let's say we are dealing with the 2-Faced A (bit 3), then 0x04 gets toggled so we end up with 119, or [0111 0111].

The final bit that sets LocalVar:0020 sets the bitmask of 0000 to match any other actors that have the ID of 6B (107) so LocalVar 0020 becomes 112, or [0111 0000].

As it stands, it makes no sense because the check is to see if 6 other actors are dead, and the other 2-faced enemies are still alive. It's nonsensical, assuming I'm reading correctly. The point is, how do I fix it? The things I've tried should have worked but for now I can't see straight....

Lol, so much for blasting through all of the Corel Prison enemies in one night, I didn't even get past the first enemy haha. Been staring at the 2-faced for about 6 hours lol
« Last Edit: 2019-03-25 06:11:08 by DynamixDJ »

DynamixDJ

  • *
  • Posts: 240
  • 1111 1111 0111
    • View Profile
Re: [FFVII] Enemy AI Script questions
« Reply #62 on: 2019-03-27 18:35:55 »
OK, I've been completely misreading what 4060 is. TF has cleared it up (the wiki could do with being a little clearer):

  Formation ID
    Used to determine whether multiple monsters are part of the same 'group'.
    A Formation ID is visible in battles with multiple monsters of the
    same type by looking at the 'A'/'B'/'C' after the monster's name.
    So, "Hammer Blaster A" has a Formation ID of 0, while "Hammer Blaster B"
    has a Formation ID of 1.

I think I've analysed the problem correctly. This is what I've written up on the 2-Faced:

A flaw exists with the 2-Faced's AI Script. If the other (non 2-Faced) enemies that share the same 'Group ID' as the 2-Faced have been killed (2-Faced A = Group 0; 2-Faced B = 1 etc), then the 2-Faced *should* have had a 100% chance of activating its Counter Script, with a 50/50 chance of using either Attack. As it stands, the Counter script will check for the Death Status of the other 2-Faced in the same group, which is illogical due to the fact there can only be one "2-Faced A" (or "B" or "C").
« Last Edit: 2019-03-27 20:03:57 by DynamixDJ »

DynamixDJ

  • *
  • Posts: 240
  • 1111 1111 0111
    • View Profile
Re: [FFVII] Enemy AI Script questions
« Reply #63 on: 2019-03-27 23:29:52 »
What's going on with the Harpy's general counter script? It changes the player flag of the Chocobo the lower its HP. The only way the script runs as it should is if LocalVar:0020 is set to 3, seeing as the Chocobo is is the 4th Actor (1st Enemy). This only happens when the Harpy's HP is <= 25%.

This doesn't appear to be a glitch either. It seems to be intentional. God only knows what they were trying to do there...

If you manage to kill the Harpy while its HP is above 25% then the player flag for the Chocobo is changed, and the Chocobo only exists in the 1st enemy slot, slot "3" so the default Chocobo Capturing script is *not* executed from the harpy. Instead you have to wait for the Chocobo's ATB guage to fill, at which point the Chocobo will be captured. The Chocobo may say "Wark! Wark!" as if it is about to run away (instead of displaying "Captured a Chocobo"), but the script still ends the battle and gives you the Chocobo if this happens. TF reported that the Chocobo would flee the battle in this instance, but I haven't seen that happen yet.

DynamixDJ

  • *
  • Posts: 240
  • 1111 1111 0111
    • View Profile
Re: [FFVII] Enemy AI Script questions
« Reply #64 on: 2019-04-05 01:11:33 »
I'm pretty convinced that 42B0 is not the Actor's AP value. I think it has something to do with the evade animation used.....

DynamixDJ

  • *
  • Posts: 240
  • 1111 1111 0111
    • View Profile
Re: [FFVII] Enemy AI Script questions
« Reply #65 on: 2019-04-05 04:08:54 »
What is the following doing, found on Yang's Physical and Magical counter script?

PUSH (24) Type (01)
PUSH (00) Type (01)

nfitc1

  • *
  • Posts: 3011
  • I just don't know what went wrong.
    • View Profile
    • WM/PrC Blog
Re: [FFVII] Enemy AI Script questions
« Reply #66 on: 2019-04-05 14:18:28 »
I'm pretty convinced that 42B0 is not the Actor's AP value. I think it has something to do with the evade animation used.....

Yeah, totally NOT AP. 42E0 is EXP and 42C0 is Gil so I assumed that 42B0 was AP. It looks like it's a damage reaction animation. When a player misses the enemy just restarts their idle animation. There is no special "dodge" animation on enemies.

What is the following doing, found on Yang's Physical and Magical counter script?

PUSH (24) Type (01)
PUSH (00) Type (01)

That's actually queuing an action of command index 24. I have no idea what its affects are. If a flag is set, it sets some other flags. ??? TF's FAQ doesn't have a clue what it does either. It's not a graphical thing...

If BF2E08 bit 1 is active, set 9AEA78 to 1. That just skips a few steps in the command flow. I can't tell that it actually does anything.

DynamixDJ

  • *
  • Posts: 240
  • 1111 1111 0111
    • View Profile
Re: [FFVII] Enemy AI Script questions
« Reply #67 on: 2019-04-07 04:19:30 »
Ah, I thought I was connecting some dots. The Black Bat has the action 'Dodge' [023A] which is not used via the AI script. I noticed that the Animation value was 4, so I made the assumption that the 42B0 assignment to 4 meant that it was using that animation.

A quick question regarding Added Effect: I'm fairly certain that you get a *fresh* 19% chance for each Status you have on your weapon (Hades) when you attack, as opposed to a single 19% chance to inflict every status (correct me if I'm wrong).

My question is this - if you pass the chance to inflict Stop on an enemy that already has Stop (or Paralyzed on an enemy that is Paralyzed etc), will the 'Stop Timer' reset to 0, or will it remain unaffected?

nfitc1

  • *
  • Posts: 3011
  • I just don't know what went wrong.
    • View Profile
    • WM/PrC Blog
Re: [FFVII] Enemy AI Script questions
« Reply #68 on: 2019-04-08 17:34:18 »
A quick question regarding Added Effect: I'm fairly certain that you get a *fresh* 19% chance for each Status you have on your weapon (Hades) when you attack, as opposed to a single 19% chance to inflict every status (correct me if I'm wrong).

That would make sense, except..... It looks like a few fuzzy logics are in play here. First, it would appear that multiple strikes would make multiple attempts to inflict. Second, it seems like there's a logical oddity that means you can only inflict, remove, or toggle effects, but it's not possible to do all three with vanilla data. Third, the code assumes that there is single inflict chance for all statuses. It's flat for all added-effect statuses. There's just as much chance that you can cause Death and Sleep on the same action.

My question is this - if you pass the chance to inflict Stop on an enemy that already has Stop (or Paralyzed on an enemy that is Paralyzed etc), will the 'Stop Timer' reset to 0, or will it remain unaffected?

Looks like the timer is only set when the status actually changes. I believe the logic of the battle is that infliction will miss if attempting to inflict a timed status on a target that already has that status. I just tested with Barrier and it missed an already barrier'd target.

DynamixDJ

  • *
  • Posts: 240
  • 1111 1111 0111
    • View Profile
Re: [FFVII] Enemy AI Script questions
« Reply #69 on: 2019-04-11 19:07:04 »
What happens if a target's condition changes after the actor's ATB gauge has filled, but before its turn?

Let's say that the actor will use Attack A on a rnd target without Frog. Does the script run as soon as its ATB is filled, or does it run when it is about to perform its Attack? If it selects its target as the ATB is filled, and the target that is chosen becomes inflicted with Frog after the script is run, will it still try to use the attack on the target, even though the target has now become inflicted with Frog (where the check in the script targets an enemy without Frog)?

NxK

  • *
  • Posts: 130
  • In AI I Trust
    • View Profile
    • YT
Re: [FFVII] Enemy AI Script questions
« Reply #70 on: 2019-04-11 20:40:17 »
What happens if a target's condition changes after the actor's ATB gauge has filled, but before its turn?

Let's say that the actor will use Attack A on a rnd target without Frog. Does the script run as soon as its ATB is filled, or does it run when it is about to perform its Attack? If it selects its target as the ATB is filled, and the target that is chosen becomes inflicted with Frog after the script is run, will it still try to use the attack on the target, even though the target has now become inflicted with Frog (where the check in the script targets an enemy without Frog)?

Scripts are only run when they are about to be executed, i.e. the moment they are to be run, which is generally quite a while after the respective ATB gauge has been filled up. This makes redundancy scenarios like the one you envision impossible.

Let's say you are to fight six Touch Me in a pincer attack with just Cloud and these six Touch Me had their AI altered to use Frog Song every turn if at least one character is not a Frog and Frog Jab otherwise. Now, since it's a pincer attack, all of these six Touch Me start with their ATB gauges filled at the beginning of the battle. If scripts being run as soon as ATB gauges are filled were the case, these six Touch Me should all cast Frog Song on Cloud. However, that is not what would happen. The first Touch Me to act would cast Frog Song, turning Cloud into a Frog (let's say all attacks cannot miss), the second one would use Frog Jab, removing the Frog status from Cloud, then the third Touch Me would cast Frog Song again, the fourth one Frog Jab, the fifth one Frog Song and the sixth one Frog Jab again.

DynamixDJ

  • *
  • Posts: 240
  • 1111 1111 0111
    • View Profile
Re: [FFVII] Enemy AI Script questions
« Reply #71 on: 2019-04-11 21:34:52 »
Thanks for clearing that up :) I suspected as much, I just needed to be sure

DynamixDJ

  • *
  • Posts: 240
  • 1111 1111 0111
    • View Profile
Re: [FFVII] Enemy AI Script questions
« Reply #72 on: 2019-04-14 23:14:20 »
I'm a little bit confused what this script is doing with the Jumping:

Code: [Select]
0x008: PSHA (20A0) Type (02)
0x00B: PSHA (4000) Type (00)
0x00E: MASK
0x00F: PUSH (01) Type (01)
0x011: EQU
0x012: CNTB
0x013: PUSH (01) Type (01)

0x008 If (BitCount( (BattleAddr(&20A0).BattleAddr(&4000) == 1) ) == 1)

It seems to be checking to see if exactly one player has Death, but after testing this check didn't seem to do anything; the Jumping appeared to have a 1/2 chance of using Club Sword regardless of how many players were dead (it's supposed to have a 1/4 chance of using the attack if the check passes).

TF seemed to think this check will always fail, aswell

DynamixDJ

  • *
  • Posts: 240
  • 1111 1111 0111
    • View Profile
Re: [FFVII] Enemy AI Script questions
« Reply #73 on: 2019-04-22 00:29:16 »
As for 2040. The only enemies that use it are Bottomswell, Carry Armor/Left Arm/Right Arm, Elfadunk, Roulette Cannon, SOLDIER:2nd, Turks:Rude. Roulette Cannon and SOLDIER:2nd can appear in the same formation so they might be able to shed some light as to what the intended function is.

The script with the Roulette Cannon is basically a copy and paste of part of Bottomswell's script. It makes sure that it will only use the attack if two or more players are alive; if only one player is alive, it will not use the attack, and target selected will be 2040.

It looks like it's just a coincidence that the Soldier:2nd and roulette cannon appear together and both use 2040. Until now I've been able to dismiss the var, as it doesn't seem to be doing much. With the Soldier:2nd, however, there's quite a lot going on with 2040. I kind of need to know what's going on with it before I can move on....

Just decided to have a quick look at Carry Armor. Any idea what 4300 is doing?

2090. There's another new one that I don't know what it's doing
« Last Edit: 2019-04-22 01:17:08 by DynamixDJ »

DynamixDJ

  • *
  • Posts: 240
  • 1111 1111 0111
    • View Profile
Re: [FFVII] Enemy AI Script questions
« Reply #74 on: 2019-04-22 03:13:45 »
OK, after testing it seems that 4300 is used when a playable character is imprisoned within Carry Armor's Arms, and is used to damage the imprisoned actor, amongst other things. I'll look into it more thoroughly when I actually get to Carr Armor.

For now though, I've spent quite a lot of time with Cheat Engine, and 2040 never seems to be any value other than 0. I think I was correct in my original assumption that this will reset the var to 0, as that's exactly what it seems to be doing.

-edit- The more I look at it, the more I'm sure that 2040 is used to clear the last attacker that is set as the SOLDIER:2nd's target. The same thing is used for the Elfadunk.
« Last Edit: 2019-04-22 03:29:21 by DynamixDJ »