Author Topic: AI Proofreading  (Read 2610 times)

Sega Chief

  • *
  • Posts: 4086
  • These guys is sick
    • View Profile
AI Proofreading
« on: 2016-02-27 08:44:44 »
Hey all, I'm approaching the end of getting NT's last major build overhaul finished but I've a very important AI to roll out to most of the enemies in the game that's going to be handling a lot of NT's stat adjustments, Arrange Mode tweaks, and the SP system. I'd like to get a few sets of eyes to have a look at this script and tell me if they spot any errors or have ideas on how to make it more efficient:

Script
Code: [Select]
12 0260
60 00
87
90
12 0280
60 01
87
90
12 02A0
60 02
87
90
13 0220
02 0260
02 4100
80
60 02
32
90
12 0260
12 4100
80
03 0220
90
13 0220
02 0260
02 4110
80
60 02
32
90
12 0260
12 4100
80
03 0220
90
13 0220
02 0280
02 4100
80
60 02
32
90
12 0280
12 4100
80
03 0220
90
13 0220
02 0280
02 4110
80
60 02
32
90
12 0280
12 4100
80
03 0220
90
13 0220
02 02A0
02 4100
80
60 02
32
90
12 02A0
12 4100
80
03 0220
90
13 0220
02 02A0
02 4110
80
60 02
32
90
12 02A0
12 4100
80
03 0220
90
02 0260
01 4048
80
60 09
45
02 0280
01 4048
80
60 09
45
50
02 02A0
01 4048
80
60 09
45
50
70 00E7
11 02C0
60 01
90
93 Level Check Debug
02 0260
01 4048
80
60 2C
44
70 00FE
12 0260
11 4048
80
60 2C
90
02 0280
01 4048
80
60 2C
44
70 0115
12 0280
11 4048
80
60 2C
90
02 02A0
01 4048
80
60 2C
44
70 012C
12 02A0
11 4048
80
60 2C
90
01 2010
60 01
40
70 0161
12 2060
11 4048
80
02 2060
01 4048
80
60 05
30
90
11 0220
60 01
90
93 Arrange Mode Debug

Disassembly
Code: [Select]
0x000LocalVar:0260 <- FlagBit(0)
0x007LocalVar:0280 <- FlagBit(1)
0x00ELocalVar:02A0 <- FlagBit(2)
0x015LocalVar:0220 <- LocalVar:0260.PhysDefense * 2
0x023LocalVar:0260.PhysDefense <- LocalVar:0220
0x02ELocalVar:0220 <- LocalVar:0260.MagDefense * 2
0x03CLocalVar:0260.PhysDefense <- LocalVar:0220
0x047LocalVar:0220 <- LocalVar:0280.PhysDefense * 2
0x055LocalVar:0280.PhysDefense <- LocalVar:0220
0x060LocalVar:0220 <- LocalVar:0280.MagDefense * 2
0x06ELocalVar:0280.PhysDefense <- LocalVar:0220
0x079LocalVar:0220 <- LocalVar:02A0.PhysDefense * 2
0x087LocalVar:02A0.PhysDefense <- LocalVar:0220
0x092LocalVar:0220 <- LocalVar:02A0.MagDefense * 2
0x0A0LocalVar:02A0.PhysDefense <- LocalVar:0220
0x0AB If ( ( ( (LocalVar:0260.Level < 9)  And  (LocalVar:0280.Level < 9) )  And  (LocalVar:02A0.Level < 9) ) )
0x0AB {
0x0CE LocalVar:02C0 <- 1
0x0D4 Display String: "Level Check Debug"
0x0E7 If ( (LocalVar:0260.Level > 44) )
0x0E7 {
0x0F4 LocalVar:0260.Level <- 44
0x0FE If ( (LocalVar:0280.Level > 44) )
0x0FE {
0x10B LocalVar:0280.Level <- 44
0x115 If ( (LocalVar:02A0.Level > 44) )
0x115 {
0x122 LocalVar:02A0.Level <- 44
0x12C If ( (GlobalAddress == 1) )
0x12C {
0x135 Self.Level <- Self.Level + 5
0x147 LocalVar:0220 <- 1
0x14D Display String: "Arrange Mode Debug"
0x161SCRIPT END

In the older build, defensive values for characters get doubled through the character AI in the kernel and the level synch is made there as well. This created a problem of limited space for innate ability AI, but it's now also made it tougher to dole out SP based on the character's level compared to the enemy level as Pre-Battle seems to be processed based on the actor bit (so chara AI, and therefore level, is always set first which buggers any Level check I want to make later on).

So my plan is to move all of this into the enemy AI where there's a lot more room (hopefully, I don't know if the scene.bin has an upper ceiling on how big it can be before problems arise). But as this means copying the AI into every single enemy, I wanted to get some second opinions on how this AI looks, if there's any problems with it I've missed, or suggestions on a more efficient way to arrange it all. It'll take a while to implement it into each enemy's pre-battle as I've got to get rid of the old one and navigate around any other scripts they have so just want to make sure I've got it right.

One thing I'd really like is a way to improve the level comparison at 0x0AB so that the game reads the enemy level and correctly compares it to the character level. I've tried it a few different ways, like loading the monster's bit, but I can't seem to get it to work; changing the compared number to match the monster's level every time will be a huge time sink so I'd appreciate it if anyone knows of a way to do this. It might be that I'm using the wrong set of codes, I was never 100% sure when to use 03, 02, or 01 for these things.

nfitc1

  • *
  • Posts: 3011
  • I just don't know what went wrong.
    • View Profile
    • WM/PrC Blog
Re: AI Proofreading
« Reply #1 on: 2016-02-27 12:41:30 »
Quote
0x015LocalVar:0220 <- LocalVar:0260.PhysDefense * 2
0x023LocalVar:0260.PhysDefense <- LocalVar:0220
0x02ELocalVar:0220 <- LocalVar:0260.MagDefense * 2
0x03CLocalVar:0260.PhysDefense <- LocalVar:0220
0x047LocalVar:0220 <- LocalVar:0280.PhysDefense * 2
0x055LocalVar:0280.PhysDefense <- LocalVar:0220
0x060LocalVar:0220 <- LocalVar:0280.MagDefense * 2
0x06ELocalVar:0280.PhysDefense <- LocalVar:0220
0x079LocalVar:0220 <- LocalVar:02A0.PhysDefense * 2
0x087LocalVar:02A0.PhysDefense <- LocalVar:0220
0x092LocalVar:0220 <- LocalVar:02A0.MagDefense * 2
0x0A0LocalVar:02A0.PhysDefense <- LocalVar:0220

I think these are mismatched.

Quote
0x12C   If ( (GlobalAddress == 1) )
0x12C   {
0x135   Self.Level <- Self.Level + 5
0x147   LocalVar:0220 <- 1
You never set the GlobalAddress so there's no telling what this value would be. What are you trying to accomplish with this statement?

Quote
So my plan is to move all of this into the enemy AI where there's a lot more room (hopefully, I don't know if the scene.bin has an upper ceiling on how big it can be before problems arise).
There's a limit of 4K for all enemies in the scene. That's pretty big, actually.

Quote
But as this means copying the AI into every single enemy
There are tricks to avoid that, actually. However they're not possible in PrC. PM me for details.

Quote
One thing I'd really like is a way to improve the level comparison at 0x0AB so that the game reads the enemy level and correctly compares it to the character level. I've tried it a few different ways, like loading the monster's bit, but I can't seem to get it to work; changing the compared number to match the monster's level every time will be a huge time sink so I'd appreciate it if anyone knows of a way to do this.
Code: [Select]
if ( Self.Level != LocalVar.2F0 )
{
   Self.Level <- LocalVar.2F0
}
I'm not really sure what the problem is. That's not an inefficient code. I'd need more details about how you want to manipulate it.

Quote
It might be that I'm using the wrong set of codes, I was never 100% sure when to use 03, 02, or 01 for these things.
The X3 is not needed. It won't hurt anything, but you almost never need it.

Sega Chief

  • *
  • Posts: 4086
  • These guys is sick
    • View Profile
Re: AI Proofreading
« Reply #2 on: 2016-02-27 13:12:39 »
Defence: Good thing you spotted that defence mistake, that would have been pretty bad if it went out.

Global: Another mistake, I forgot to add the bit at the beginning. The original looks like this:

Code: [Select]
13 0240
01 2010
90
60 00
61 026C
95
01 2010
60 01
40
70 0060
12 2060
11 4048
80
02 2060
01 4048
80
60 0F
30
90
13 0220
02 2060
02 42E0
80
60 03
32
90
12 2060
12 42E0
80
03 0220
90
13 0220
02 2060
02 42E0
80
60 02
33
90
12 2060
12 42E0
80
03 0220
90
11 0220
60 01
90

Must have just forgot to write it in when I was putting the new script together. Another good save  :-D

Level: I was meaning this bit here:

0x0AB   If ( ( ( (LocalVar:0260.Level < 9)  And  (LocalVar:0280.Level < 9) )  And  (LocalVar:02A0.Level < 9) ) )

The problem I'm hoping to avoid is that when I go to paste this script into every enemy, I'll need to manually adjust the enemy level listed in the 'If' condition every single time to account for each monster's different level. I tried to push the monster's level into a variable so that I wouldn't need to do this, but the methods I've tried don't seem to work. Is it possible to make something like this work instead:

0x0AB   If ( ( ( (LocalVar:0260.Level < Self.level)  And  (LocalVar:0280.Level < Self.Level) )  And  (LocalVar:02A0.Level < Self.Level) ) )

Something along those lines? I think I tried it this way but didn't have much luck. I'll shoot a PM over about that script copying thing.