Author Topic: Help needed on AI Editing (FFVII)  (Read 18721 times)

nfitc1

  • *
  • Posts: 3011
  • I just don't know what went wrong.
    • View Profile
    • WM/PrC Blog
Re: Help needed on AI Editing (FFVII)
« Reply #25 on: 2009-08-10 11:43:21 »
This would all be better in Post-Attack, it fires more often and would catch Dual and Poison-induced critical damage sooner.

secondadvent

  • *
  • Posts: 287
    • View Profile
Re: Help needed on AI Editing (FFVII)
« Reply #26 on: 2009-08-10 12:45:42 »
@xelane: yeah, post attack is sort of a general counter for any attack made, not just on the user, so if something has to be activated fast, this is where it should go. it still will not likely always activate right away for dual drain/poison cases (unless they count as an attack :P), but it can be faster than general, as nfitc1 said. now i do not know if any of the unknown sections are actually usable, but if they actually do something, then i would not be surprised if one of them acted every time a unit of time passed, which could be how doom/dual drain acts, and could be useful to make something activate a countdown timer of sorts outside of the main AI of an enemy, especially since you'd be able to make the enemy attack/react even if it isn't it's turn yet :P.

now i am not entirely sure if there is a section that is like that, if there is you'd have to be careful what you put into it, or you could be making the game work too hard since it has to do the calculations a massive amount of times, but it would have it's advantages, like with setting a status at a certain time, that has to be done asap. i could think of a few ways to use a section like that ^_^ *hopes that there is one like that, or a way to do it  :roll:*.

@nfitc1: now sort of off topic, how exactly does your jump pointer update work, do you have to point it to a specific point and it auto updates as you add more before that spot (like if you point to offset 0x021 and add stuff there to kick down the original jump to 0x027, it will make the jump stick to the original spot, regardless of how far down it moves)? that does sound pretty good, but what about when starting from a fresh section, all that is there would be whatever you add, and if you were to point at a location right as you start to build an if, the only place you could really jump would be the end statement, and so no matter what you add, it will still point there, and if you had wanted to point at something before the end, but after the if's data, you would still have to manually edit that. also, if you were to add something (like something after an if's data for example), and some jump is already pointing to that specific data, and you had to add something before that to make it work right, all of the jumps would still follow the old data, you would have to manually update there as well, or overwrite the data in the same location to make them work right.

i know that those are things that are probably not easy to fix and should be left to the user to do anyway, but it IS me, and i like to be picky  :roll:. ignoring my smart @$$ comments for a second, it does sound like it will be a very nice feature, and i will be happy to take advantage of it when i get back to ffvii hacking ^_^.

@armorvil: as for the 0mp kill thingy, i had tried last night to get that to work, but it didn't go over so well. i first tried 0hp, which as i thought wouldn't kill it, so i then tried just setting the death flag, which worked at first, but after actually giving the enemy some mp, and causing it to lower to 0, it stopped killing them, or even doing anything (using an if self.mp == 0 statement, it may work with a self.mp < 1 line, but i don't see why that would be needed :/). i also tried the "normal" killing method used by other enemies to kill off the enemy at 0hp, but for some reason the enemy wouldn't even disappear like normal when that part activates, i don't know what was up... maybe i have just been away for too long :/.

anyhow, even if you use the normal killing method (setting those values to 0), if you want to have any battle spoils from the enemy, you will have to set death to 1, i noticed at least that much in my testing. maybe you will have more luck than me, use nfitc1's ai script for killing the enemies (though he is using the max hp value instead of the current hp, not sure how the game reacts to that :/), and just to be safe (if you don't get exp or whatever from it), set death status to 1 as well, maybe you will have more luck than i did :P. as far as i can tell though, the death animation will not play, the enemy "should" only disappear and make itself inactive (should, as in mine didn't but my current scene.bin is a mess anyway from testing crap :P), there is probably a way to manually activate the death animation, but i do not know how to do that, i even tried to set the idle animation to 2 which iirc is the death animation for enemies, but it just froze the game  :-(. just try niftc1's code and if needed the death flag to 1 code by titeguy and see what happens... i will have to crack open a fresh scene.bin backup sometime soon :P.

hp being locked at 0 is a fun little way to make an enemy invincible even though you are still doing damage... kinda fun to beat up on an enemy for a while while it just laughs at you, until you realize that healing it and then taking that hp away = death XD.

nfitc1

  • *
  • Posts: 3011
  • I just don't know what went wrong.
    • View Profile
    • WM/PrC Blog
Re: Help needed on AI Editing (FFVII)
« Reply #27 on: 2009-08-10 13:41:38 »
@nfitc1: now sort of off topic, how exactly does your jump pointer update work, do you have to point it to a specific point and it auto updates as you add more before that spot (like if you point to offset 0x021 and add stuff there to kick down the original jump to 0x027, it will make the jump stick to the original spot, regardless of how far down it moves)? that does sound pretty good, but what about when starting from a fresh section, all that is there would be whatever you add, and if you were to point at a location right as you start to build an if, the only place you could really jump would be the end statement, and so no matter what you add, it will still point there, and if you had wanted to point at something before the end, but after the if's data, you would still have to manually edit that. also, if you were to add something (like something after an if's data for example), and some jump is already pointing to that specific data, and you had to add something before that to make it work right, all of the jumps would still follow the old data, you would have to manually update there as well, or overwrite the data in the same location to make them work right.

i know that those are things that are probably not easy to fix and should be left to the user to do anyway, but it IS me, and i like to be picky  :roll:. ignoring my smart @$$ comments for a second, it does sound like it will be a very nice feature, and i will be happy to take advantage of it when i get back to ffvii hacking ^_^.

It's as user-friendly as it can possibly be. The user doesn't have to make any additional labels or points or anything. Just write the code as usual. If you tell the code to jump to an address and that address moves because you inserted code before it, the jump address will update. If you insert code after the jump, the address won't be affected. I can see two potentially destructive parts about this:

#1. You tell it to jump to an address that doesn't exist. WM/PrC won't crash, but the game will likely freak out on you. In one of the test monsters (those pyramids) there is a jump to 0x64 when the end script code is at 0x63. I don't know if this enemy can be encountered as it's a debug enemy. What will happen is......nothing. Since the address doesn't exist it won't update. You can tell it to jump to 0x5F32 (an impossible address as it virtually can't exceed 0x0FD8) then it will just remain being 5F32 until you are ready to give it a position.
#1b. If you give it an address that BECOMES usable later, it will still function like normal.
#2. You want to jump to 0x00 to start a script over then add code at the beginning. This one's more rare to happen. Indeed, I'm not even sure that you can jump backwards. I've never gotten it to work. But as you add code to the beginning, it will continue to push the 0x00 address forward. You'll have to manually change the jump address or consider changing where you're inserting code.

You want to know the mechanics behind it? Renumbering the address grid is the second-to-last step (right before writing the AI into memory to be written to the scene.bin/KERNEL.BIN). Also notice that when you add a row it adds a blank address header and displaces all the others? Well, as a testament to my genius as a programmer, right before all the addresses get renumbered I go through and find the jumps and which address they point to and make a note of which row that equates to. After it finishes making that assessment for all jumps and all row addresses are updated, it goes BACK through the jumps it found and changes the address if the address it jumps to and the address in the row header is different. Then the AI is written back to memory with the jumps updated.
Brilliant, no? ;) This function has a "big O" (not to be confused with The Big O with the retarded theme song) of log(n) so it's super fast and runs every time data is changed. It'll probably even be fast on Eligor's script! :O I only really tested it on a few things. Guard Scorpion was the biggest script I tested. On the laptop I use to develop this I saw no performance hit for doing this function.
It's LIKE having labels, but the user doesn't ever have to make one. It's amazing sometimes how the simplest things work the best.

Armorvil

  • *
  • Posts: 621
  • Working on : FFVII Total Grudge
    • View Profile
Re: Help needed on AI Editing (FFVII)
« Reply #28 on: 2009-08-10 20:09:38 »
About my 0 MP = Death problem...

NFITC1's script, at the bottom of page 1, doesn't seem to work. But Titeguy's new script in post-attack does work :

02    2060
02    4140
80
60    00
40
70    0017
12    2060
10    4000
80
60   01
90
73

The only problem is the fact that the enemy doesn't do its death animation... So, I tried to add this new line, between 60 01 and 90, near the end of the script :

93    Devil Ride's brain was crushed!  (:-P)

Because yeah, if we can't make an enemy disappear, then we can at least let a player know it's dead... ...the problem though, is the fact that this message keeps displaying as the battle goes on, over and over...  :-(
Is there a way to display the message only once, just as the enemy dies ?

Akari

  • *
  • Posts: 766
    • View Profile
Re: Help needed on AI Editing (FFVII)
« Reply #29 on: 2009-08-10 20:16:02 »
About my 0 MP = Death problem...

NFITC1's script, at the bottom of page 1, doesn't seem to work. But Titeguy's new script in post-attack does work :

02    2060
02    4140
80
60    00
40
70    0017
12    2060
10    4000
80
60   01
90
73

The only problem is the fact that the enemy doesn't do its death animation... So, I tried to add this new line, between 60 01 and 90, near the end of the script :

93    Devil Ride's brain was crushed!  (:-P)

Because yeah, if we can't make an enemy disappear, then we can at least let a player know it's dead... ...the problem though, is the fact that this message keeps displaying as the battle goes on, over and over...  :-(
Is there a way to display the message only once, just as the enemy dies ?

It you want to show enemy die - just call it's death animation scripts. You can do it by create dummy attack and assosiate it with death animation script. Example of dummy attack you can see in Guard Scorpion (when he rise and down it's tail). For enemy death animation script should be 0x01. But note that animation scripts check if HP == 0 so you need to set enemy HP equal to 0.
« Last Edit: 2009-08-10 20:17:59 by Akari »

Armorvil

  • *
  • Posts: 621
  • Working on : FFVII Total Grudge
    • View Profile
Re: Help needed on AI Editing (FFVII)
« Reply #30 on: 2009-08-10 20:55:35 »
Thanks for the info. I looked at Guard Scorpion's script, but I fear that my eyes aren't trained enough to see which lines are the ones that call a different animation. Besides, if I had to create a dummy attack for each monster susceptible to MP-Killing, it would be too time-consuming. The whole full-game hack I have in the works is trouble enough already, so I figure my line "[monster name] lived on MP..." is sufficient if the AI script can't make an enemy disappear. Now if only I knew how to make the text box display only once...
« Last Edit: 2009-08-10 20:57:35 by Armorvil »

nfitc1

  • *
  • Posts: 3011
  • I just don't know what went wrong.
    • View Profile
    • WM/PrC Blog
Re: Help needed on AI Editing (FFVII)
« Reply #31 on: 2009-08-10 21:13:51 »
Akari's not saying a line in the script calls the animation (although you could set the idle animation). He means that you should create a blank attack and use the animations/formations tab to associate its death animation (somewhere between 0-2, I'm not clear on this) with that attack. Perform that attack right before inflicting the death status and it will appear to die like normal. Then you can just perform a text display as you call the attack and inflict death.

titeguy3

  • *
  • Posts: 1283
  • A jack of all trades
    • View Profile
Re: Help needed on AI Editing (FFVII)
« Reply #32 on: 2009-08-10 21:37:56 »
@NFITC1, I've discovered through half-assed mistakes that if you jump to a point beyond a script's boundary, it'll jump to the next script. For example, with guard scorpion, I accidentally made a jump to a point out of bounds, and it used tail laser, meaning it jumped to the point in it's General Counter Script where tail laser is called. I can't prove this, since I'm not the one of the ones who decrypted scene.bin, but I'm fairly certain that's what happens...

It's bizarre that it's so difficult to kill an enemy. Isn't there a RunScript(x) function that can be used to just call a death script?

Whatever, I digress. Armorvil, ever notice how some enemies have a "(report)" attack? These are basically suicide attacks. You need to make an attack like this, once you do it once, you don't have to do it again, just use the same attack.

Let me break it down...
1. Make an attack in Proud Clod, name it "MPDeath" or something
2. set it's Attack ID to something unused...let's say...x0166.
3. Set the MP Cost to 0, set the Attack damage to "00 No Damage Calculation (Name not displayed)", Check "Ignore Stat Def" and make it cause "Death" status with 63 Chance
4. Use this code: (in the post-attack script)
Assembly:
Code: [Select]
; Die when MP reaches zero
PSHA02 SELF
PSHA02 MP
MASK
PUSH 0
EQU
JMP0 FIN
PUSH12 TARGETMASK
PSHA02 SELF
STRA
PUSH 20
PUSH 166 ; MPDeath attack
ATTK
PUSH12 SELF
PUSH12 MP
MASK
PUSH 1
STRA
FIN END

Hex:
Code: [Select]
02 2060
02 4140
80
60 00
40
70 0024
12 2070
02 2060
90
60 20
61 0166
92
12 2060
12 4140
80
60 01
90
73

This shouldn't have any problems, I've tested this method out before and works in every case.

EDIT: I noticed that this could make it go awry is if something bad happens when it tries to use this attack after it's dead...better add a line in to set it's MP to one so this only happens once...(adds line in)

If you need to have another enemy die by MP, put the code in their post-attack as well, then give them an attack with ID x0166 (or whatever you used), then right click the ORIGINAL attack, and click "Sync attack with Given ID". That'll essentially copy over the attack properties to every other with the same ID, so you don't have to put in the attack info more than once.
« Last Edit: 2009-08-10 22:00:09 by titeguy3 »

Armorvil

  • *
  • Posts: 621
  • Working on : FFVII Total Grudge
    • View Profile
Re: Help needed on AI Editing (FFVII)
« Reply #33 on: 2009-08-10 22:06:24 »
Urgh, I did exactly as you wrote Titeguy3, and I get a "Data Error - scene 35 code 32" for Devil Ride (scene10).
I don't know what I do wrong... And thanks for the right click thing ! Wow, Proud Clod has some pretty neat functionalities  8-)
« Last Edit: 2009-08-10 22:09:21 by Armorvil »

titeguy3

  • *
  • Posts: 1283
  • A jack of all trades
    • View Profile
Re: Help needed on AI Editing (FFVII)
« Reply #34 on: 2009-08-10 22:09:46 »
Oh, I may have forgotten to mention that you also have to assign the attack to him in Animations/Formations. Guess and check which animation works the best... One of them has to be the Idle one....

Armorvil

  • *
  • Posts: 621
  • Working on : FFVII Total Grudge
    • View Profile
Re: Help needed on AI Editing (FFVII)
« Reply #35 on: 2009-08-10 22:24:50 »
OK, thank you : it works now, but there's a new problem : I tested it in a battle formation of two Devil Rides, and once I MP-defeated one, the other took his turn (by attacking or whatever) and the battle ended as if I also defeated the second Devil Ride (meaning, this second one didn't use the death animation, which is normal since he wasn't MP damaged - but then why did its HP go to 0 ? I never attacked it).

Man, I would never have guessed implementing this function would be so troublesome  :-o
« Last Edit: 2009-08-10 22:31:36 by Armorvil »

Akari

  • *
  • Posts: 766
    • View Profile
Re: Help needed on AI Editing (FFVII)
« Reply #36 on: 2009-08-10 23:33:09 »
associate its death animation (somewhere between 0-2, I'm not clear on this) with that attack

Animation script 1 is the script that plays hurt animation and do check for death. If unit is dead it plays death effect set in this model.

ps: Animation script id 1 - idle.
pps: please don't confuse animation script id with animation id. Animation script can call a lot of animations as well as play effects and load new one from disk.
enemy MP animation script 3 (assosiate with mashingun attack) calls 4 different animations in model.
// mashingun
Code: [Select]
action = 3
// sequence
FC EA 02    AD07B801010A D8011000 F708 03    04    05    E5EE
// opcodes
// FC set direction for animation for target and attacker based on target and other things.
// EA show attack name
// 02 play animation 2 (jump to half enemy)
// AD[07][B801][01][0A] Attach effect to joint 07 with lenght 1B8 which starts at 01 and ends at 0x0a. Always mashingun fire.
// D8[01][1000] some effect related???
// F7[08] time before target plays hurt action. This will display damage and effect.
// 03 play animation 3 (looks like 1 frame only ???)
// 04 play animation 4 (looks like 1 frame only ???)
// 05 play animation 5 (attack and jump back)
// E5 return direction (oposite of FC)
// EE reset to idle.

titeguy3

  • *
  • Posts: 1283
  • A jack of all trades
    • View Profile
Re: Help needed on AI Editing (FFVII)
« Reply #37 on: 2009-08-10 23:59:12 »
OK, thank you : it works now, but there's a new problem : I tested it in a battle formation of two Devil Rides, and once I MP-defeated one, the other took his turn (by attacking or whatever) and the battle ended as if I also defeated the second Devil Ride (meaning, this second one didn't use the death animation, which is normal since he wasn't MP damaged - but then why did its HP go to 0 ? I never attacked it).

Man, I would never have guessed implementing this function would be so troublesome  :-o

That...I can't explain... did you update both instances of Devil Ride's AI? (scene 8 and 10)
Although I can't imagine why a single battle would want to call instances of the same monster from different scenes...

He couldn't have used up his own mp though, devil rides don't have any attacks that consume MP.

But yeah, that's AI Scripting for ya. It can be pretty chaotic...try to gather some more information. Find out why the round is ending by sensing the second devil ride and seeing if it's HP or MP is going to zero.