AI script to tell a monster to die if its MP reach 0 ?

  • Thread starter Thread starter Armorvil
  • Start date Start date
Status
Not open for further replies.
A

Armorvil

Guest
Urgh, I never really know if these kinds of topics go in Game Tweaking or General... ...Feel free to move it if I made the wrong choice.

Anyways, this topic was brought up before, but a long time ago. I tried to search for the info, but it's nowhere to be found (I think they got purged when a bunch of AI-related posts, in the Proud Clod thread, were deleted). And I lost the info I need.

Basically, I need help in coming-up with an AI code that would make an enemy die if it has no MP left. I remember that someone found a code, and it worked - even though all enemies in the formation that shared this code also died, when one of them was MP-killed. This is no problem though, I already planned to only make MP-killable, enemies that appear only one at a time in a formation (I edited my scenes' formations to that end).

I thought I saved the info on my comp, but the only code I found is this :

Code: [Select]
Code:
02  206003  41808060  004070  003512  206010  40228060  009012  206010  40208060  009012  206010  40238060  009012  206010  40248060  009073
But I tried to type this in Post-attack (with an older version of PrC, the newest versions being plagued with an Out of range exception when you try to add more than one line), and it didn't work. Once again, any help would be appreciated.
 
Last edited:
Urgh, I never really know if these kinds of topics go in Game Tweaking or General... ...Feel free to move it if I made the wrong choice.

Anyways, this topic was brought up before, but a long time ago. I tried to search for the info, but it's nowhere to be found (I think they got purged when a bunch of AI-related posts, in the Proud Clod thread, were deleted). And I lost the info I need.

Basically, I need help in coming-up with an AI code that would make an enemy die if it has no MP left. I remember that someone found a code, and it worked - even though all enemies in the formation that shared this code also died, when one of them was MP-killed. This is no problem though, I already planned to only make MP-killable, enemies that appear only one at a time in a formation (I edited my scenes' formations to that end).

I thought I saved the info on my comp, but the only code I found is this :

Code: [Select]
Code:
02  206003  41808060  004070  003512  206010  40228060  009012  206010  40208060  009012  206010  40238060  009012  206010  40248060  009073
But I tried to type this in Post-attack (with an older version of PrC, the newest versions being plagued with an Out of range exception when you try to add more than one line), and it didn't work. Once again, any help would be appreciated.
The immediate problem is that "Post-Attack" isn't "Post-Attack".

The best way to do this is to add this function to the formations' "General Counter" script. That way after any actions are performed (it may require damage calculation to trigger this) the formation's "General Counter" would loop through all appropriate enemies and kill off whomever has 0MP. That's the only way I can think to reliably do it.

You're code basically has the right idea though. It'd need to be altered to loop through the appropriate enemies (I haven't tested this, but it's theoretically sound)
Code: [Select]
Code:
12 020060 049012 030002 0200879002 030002 41208061 XXXX  <-- specific enemyID71 004F02 030003 41808060 004070 005002 030010 40228060 009002 030010 40208060 009002 030010 40238060 009002 030010 40248060 009012 020002 020060 01309002 020060 094370 000673
Translates to:

Code: [Select]
Code:
LocalVar:0200 <- 4DO{ LocalVar:0300 <- FlagBit(LocalVar:0200) If (LocalVar:0300.EnemyID == XXXX) {  If ( (LocalVar:0300.MHP == 0) )  {   LocalVar:0300.Flag:Unknown(00000004) <- 0   LocalVar:0300.Flag:Invisible <- 0   LocalVar:0300.Flag:Targetable <- 0   LocalVar:0300.Flag:MainScriptActive <- 0  } } LocalVar:0200 <- LocalVar:0200 + 1}  WHILE LocalVar:0300 <= 9SCRIPT END
That will look through certain enemies and should kill them when their MP runs out. This script is only 100 bytes in size so it would be usuable in all four scenes if needed. You can check for all three ids in the scene if you'd like, that'd only take about 24 or so additional bytes (per script) at most.
 
If you're planning to release something, throw it in Game Tweaking.  If you just have a question that you think someone else will easily have the answer to, General.

And then if it's a question where you will need to delve into the game's code and discover something new (and plan to do so) Tech-Related.
 
I just tried your code in the formations' AI, NFITC1 (pasted it in the 4 formations, to make sure), and it doesn't work : the battle goes on as usual. And I also tried to insert it in the enemy's general counter script to no avail. :( Same with the code I got, putting it in the general counter of an enemy doesn't work either  :cry:

If you're planning to release something, throw it in Game Tweaking.  If you just have a question that you think someone else will easily have the answer to, General.

And then if it's a question where you will need to delve into the game's code and discover something new (and plan to do so) Tech-Related.
OK, thanks for the clarification Obesebear.

EDIT :

Sorry, I finally found the original thread. Titeguy3 was the one who managed to find a working script ^^ Kudos to him :)

I can't believe I couldn't find the thread yesterday, and that I didn't save the right script in my HDD... ...Sorry about that, it's the second time I create a useless topic in a couple days  :-[
Anyways, thanks for trying to help, NFITC1 ;)
 
Last edited:
Basically, I need help in coming-up with an AI code that would make an enemy die if it has no MP left. I remember that someone found a code, and it worked - even though all enemies in the formation that shared this code also died, when one of them was MP-killed.
So, if you have two dragons in a fight, but want only one to be MP 'sensitive'. Off the top of my head, your options are:

* create a new, second enemy that uses the same dragon model. Give it its own AI code (verbose!)
* have the AI code only active for monsters with a particular formation ID (neater)
* make both MP sensitive, but make an MP 'death' change a BattleVar that 'deactivates' the MP-sensitivity script on the other monster (if you don't mind which one dragon dies at 0 MP, just want only *one* to be vulnerable to this per battle)


I'll give the code a proper look tonight if I get the chance, see if I can spot what's going on.
 
I just tried your code in the formations' AI, NFITC1 (pasted it in the 4 formations, to make sure), and it doesn't work : the battle goes on as usual. And I also tried to insert it in the enemy's general counter script to no avail. :( Same with the code I got, putting it in the general counter of an enemy doesn't work either  :cry:
If it doesn't work in the general counter of the formation then you should append that code to the end of the monster's main, just without the flagbit loop. Your original code would work fine for that.

EDIT: I think I can contribute two points to this conversation:

1. I doubt that will actually work. Appending to the end of the main script I mean. Scripts are all designed to be run in a single frame. With that in mind, MP only decreases AFTER the action is performed. Since actions aren't performed until after the script is completely run appending it to the end of the Main script will not work.

Sequence of events:

Enemy0's turn begins
Enemy0's Main script runs
:Stuff happens in Main script
:Enemy0 queues up "Flare" magic attack
:Enemy0's Main script terminates
If Enemy0 has enough MP, Flare will be cast; Otherwise it displays message of not enough MP.
MP is deducted accordingly.

See that the Main script terminates before MP is deducted? Since this is the case, the enemy won't die until its next turn.

2. The jumps in my code are a little off:

Code: [Select]
Code:
02   030002   41208061   XXXX  <-- specific enemyID71   004F
Should be:

Code: [Select]
Code:
02   030002   41208061   XXXX  <-- specific enemyID71   0050
Try that out again.
 
Last edited:
Not sure why general counter isn't working. Should be possible to do a blanket search for all enemies with a certain Index and MP 0, then force-death them. Counter should be on another unit.

Or, put the counter script on Cloud. 'Feed' the script enemy indeces set with a BattleVar established at the start of the battle.
 
I'm glad both of you are interested and desire to help, but I already got what I wanted ;)
My formations are arranged so there's only one MP-killable enemy at a time, so Titeguy's code is perfect  ;D
 
Status
Not open for further replies.
Back
Top