Author Topic: FF7: Enemy AI checks party's elemental affinities  (Read 4222 times)

Karifean

  • *
  • Posts: 65
    • View Profile
Okay, I'm stumped on this one. I'm trying to make an enemy not use his elemental attack if 2 party members absorb it. I just can't figure out how you can check to see if a party member absorbs an element.

Any ideas?

Bosola

  • Fire hazard!
  • *
  • Posts: 1752
    • View Profile
    • My YouTube Channel
Re: FF7: Enemy AI checks party's elemental affinities
« Reply #1 on: 2013-08-11 21:38:07 »
I don't have WallMarket available right now, but you should be able to figure this out by looking at Sephiroth's Main AI script. I can't remember exactly what the element defence check actually looks at, though.

Karifean

  • *
  • Posts: 65
    • View Profile
Re: FF7: Enemy AI checks party's elemental affinities
« Reply #2 on: 2013-08-11 21:57:53 »
Unfortunately, I don't have WallMarket available right now either, but I've been told his AI first chooses targets with the "GreatestElementalDamage" address, but then just throws that plan out the window and directly chooses its actions depending on the Formation ID. They also said that sometimes if they used Sephiroth outside of the flashback, he used spells the enemies absorbed. So it doesn't seem like Sephiroth's AI holds the answer, sadly.

Bosola

  • Fire hazard!
  • *
  • Posts: 1752
    • View Profile
    • My YouTube Channel
Re: FF7: Enemy AI checks party's elemental affinities
« Reply #3 on: 2013-08-11 23:04:01 »
I think you misunderstand; I'm not telling you to copy-paste Sephiroth's AI script. I'm suggesting you should look at how it functions (it *does* work - the script just overwrites the target data later) and see if you can have another go at figuring it out yourself.

IIRC opcode 96 is the one that does the work - for any particular 'scan' it writes a defence modifier value into a member variable for each enemy you pass into it with a formation mask. You'd need to read the WallMarket opcode reference for more details, but I'm sure you get the gist of it.
« Last Edit: 2013-08-11 23:43:39 by Bosola »

Sega Chief

  • *
  • Posts: 4086
  • These guys is sick
    • View Profile
Re: FF7: Enemy AI checks party's elemental affinities
« Reply #4 on: 2013-08-11 23:21:36 »
Hi Karifean,

I can copy-paste the AI data here (that Twitch chat thing didn't seem like a good place for it).

This is Sephiroth's Main AI. His pre-battle is to activate the main script and turn on Physical/Magical/Status immunities.
I'm not 100% on how this script works, so there's a good chance I've read it wrong. I think they might have started with
the greatest elemental damage thing but maybe ran into a problem with Harrier (which is immune to Quake and
which is slightly stronger than Fire/Ice/Bolt 3). It seems easier to just have him use certain spells against certain
formations (ones with Harrier in it) with random ones being used against the others.

I think it might be that it'll use a random spell by default but for Harrier groups it'll avoid using Quake. I think that's
the way it's been set up.

Code: [Select]
LocalVar:0000 <- 2
TargetMask <-  (TargetMask.GreatestElementalDamage >= 5)
If (TargetMask)
{
Debug.Print: "RESIST EARTH MONSTER" ; 0
LocalVar:0040 <- 1
}
TargetMask <-  (ActiveMask.FormationNumber == 25)
If ( ( (TargetMask And  (TargetMask.Status:Death == 1) )  And  (Random MOD 3 == 0) ) )
{
LocalVar:0020 <- 8

}

ElseIf ( (BitCount(AllOpponentMask) == 1) )
{
TargetMask <- RandomBit(AllOpponentMask)
If ( (TargetMask.BattleRow >= 16) )
{
LocalVar:0020 <- 29

}

Else
{
LocalVar:0000 <- 1
}

}

Else
{
TargetMask <- AllOpponentMask
If (Random MOD 3 + LocalVar:0040 == 0)
{
LocalVar:0020 <- 38
LocalVar:0040 <- 1

}

ElseIf (Random MOD 3 + LocalVar:0040 == 1)
{
LocalVar:0020 <- 32

}

Else
{
LocalVar:0020 <- 35

}

Else
{
POP(Random MOD 3 + LocalVar:0040)
}
Action(LocalVar:0020, LocalVar:0000)
SCRIPT END
« Last Edit: 2013-08-11 23:32:22 by Covarr the Proud Fanboy »

Karifean

  • *
  • Posts: 65
    • View Profile
Re: FF7: Enemy AI checks party's elemental affinities
« Reply #5 on: 2013-08-11 23:49:22 »
Ah, the page for opcode 96 in WallMarketHelp really helped a lot. That also explains the GreatestElementalDamage address. I hope it also works on characters. I'll try.

So Sephiroth just checks for Earth and picks other elemental spells by other conditions. But this should be enough knowledge to work out the AI I wanted. Thanks to both of you!

Bosola

  • Fire hazard!
  • *
  • Posts: 1752
    • View Profile
    • My YouTube Channel
Re: FF7: Enemy AI checks party's elemental affinities
« Reply #6 on: 2013-08-11 23:50:54 »
@SegaChief - That script alone won't do the job. All it does is see if any enemies have an elemental defence of five or above for Earth, and if so, push that data into the targetmask. If the targetmask is not empty, the script outputs a message to the debug console (not visible to the player). The next part of the script immediately overwrites the targetmask for different logic (specifically pushing the identfier of Young Cloud for testing if he's KOed - "LocalVar:0020 <- 8" is passing the spell ID of Life2).

@Karifean - no problem. Come back if you have any further problems writing the logic.

Karifean

  • *
  • Posts: 65
    • View Profile
Re: FF7: Enemy AI checks party's elemental affinities
« Reply #7 on: 2013-08-12 00:11:00 »
Just tested this on a test enemy. It was supposed to write "YES" if one of the characters nullifies or absorbs water, otherwise "NO". It worked exactly as it should. Awesome!

This is the code I used:

Code: [Select]
0x000 02 20A0
0x003 60 40
0x005 96
0x006 02 2070
0x009 01 4058
0x00C 80
0x00D 60 05
0x00F 42
0x010 70 001B
0x013 93 YES
0x018 72 001F
0x01B 93 NO

Edit: Now this is strange. I could swear it worked before, but now, FF7 crashes every time I start the battle against the enemy with the above script.

Edit2: Never mind, I just failed.
« Last Edit: 2013-08-15 00:50:05 by Karifean »