øAslickproductions.org/forum/index.php?PHPSESSID=5f0fck550j2m4m2fpbtkj2vkm1&topic=1993.msg22519e:/My Web Sites/Slick Productions - FFIV Message Board/slickproductions.org/forum/index407a.htmlslickproductions.org/forum/index.php?PHPSESSID=5f0fck550j2m4m2fpbtkj2vkm1&topic=1993.75e:/My Web Sites/Slick Productions - FFIV Message Board/slickproductions.org/forum/index407a.html.zxb-g^ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÈÐT OKtext/htmlISO-8859-1gzip0|ÖT ÿÿÿÿÿÿÿÿTue, 10 Mar 2020 06:18:33 GMT0ó°° ®0®P®€§²ð®a-g^ÿÿÿÿÿÿÿÿ›,T  Final Fantasy IV: Side Project (Random AI Routine complete!)

Author Topic: Final Fantasy IV: Side Project (Random AI Routine complete!)  (Read 10579 times)

Grimoire LD

  • FF4 Hacker
  • *
  • Posts: 1,684
    • View Profile
Re: Final Fantasy IV: Side Project (Random AI Routine complete!)
« Reply #75 on: January 15, 2015, 12:09:23 PM »
I'm making some progress on the new level adjustment code today. Hopefully I can finish it soon.
The way it will work is this:
All normal monster stats will adjust the same as before, except for Agility. Agility will adjust by half the difference it was adjusting before.
So, if a Monster normally had an agility score of 0x10, and the adjustment ratio would normally adjust it up to 0x20, then it will instead adjust to 0x18.
Likewise, if a Monster had an agility score of 0x10 and the ratio would adjust it down to 0x08, then it will adjust down to 0x0C instead.
So the agility changes will be half as drastic as all other stat changes.

As for Bosses...
If the boss monster's starting level is higher than the adjusted APL, then there will be no effect on the Monster's stats at all (boss monsters will not weaken under any circumstances).
If the boss monster's starting level is lower than the adjusted APL, then all stats will adjust as though the Boss was a normal monster (Weaker bosses will get significantly harder the higher your party's level).

I still have to debug the APL calculations before this is complete, but he new coding jumps to a subroutine to calculate APL, so making changes is easy to do without disturbing the rest of the code.


As for Exp adjustment...
I haven't begun that portion yet, but if I recall correctly, what the game does is look at the monster types and quantities and simply perform some calculations based on those figures to determine the total experience award.
This presents a bit of an issue with adjustments, since a different adjustment cannot be made for each individual monster.
SO, my plan is to save each monster's adjustment ratio in the unused stat bytes 2012,x and 2013,x (base wisdom and willpower). At the end of the battle, an average adjustment ratio will be calculated, and the total experience award will be multiplied by this number.
This will make things kinda weird if you fight a battle against, say, an Imp and an EvilMask (I know, this generally will never happen, but you get my point), because the adjustment average will be close to nothing.
For most normal battles, though, this will work nicely, I think...

Looks like things are moving smoothly! I am still a little confused about your adjustment Ratio and plan and how an Imp and EvilMask would be next to nothing. An Imp's ratio at a Level 60 or so should give roughly 1200 Exp. per Imp? Or something like that? Whereas with an early EvilMask fought at level... say 10. it would decrease from 50000 Exp to... (50000 /10 =) 5000 Exp. Also will this plan allow for breaking of the 65535 limit on default Exp. assignments?

chillyfeez

  • FF4 Hacker
  • *
  • Posts: 1,285
  • Gender: Male
  • Go ahead, ask me about Angel Feathers!
    • View Profile
Re: Final Fantasy IV: Side Project (Random AI Routine complete!)
« Reply #76 on: January 15, 2015, 04:34:19 PM »

Looks like things are moving smoothly! I am still a little confused about your adjustment Ratio and plan and how an Imp and EvilMask would be next to nothing. An Imp's ratio at a Level 60 or so should give roughly 1200 Exp. per Imp? Or something like that? Whereas with an early EvilMask fought at level... say 10. it would decrease from 50000 Exp to... (50000 /10 =) 5000 Exp.
... Yeah, I'm not really sure what I was thinking there. I guess I was thinking that the average of, say 1/2 and 3/2 is 1, so if your adjusted APL is exactly between the base level of two enemies, their ratios will cancel each other out for EXP award, but I can't seem to actually make that happen with my calculator, so never mind.

Quote
Also will this plan allow for breaking of the 65535 limit on default Exp. assignments?
I don't know yet. I have to look at exactly how the exp award routine works. I have to figure that each monster can only have that as its base max, but the "total exp award" pool must be three bytes, because 7 monsters with 0xFFFF each would be 0x06FFF9. The questions I'd have to answer would be:
1) can I multiply numbers that are more than two bytes? (I don't think so, but three byte products are ok)
2) does the game add each monster's exp individually, or does it multiply then add? (FFFF+FFFF+FFFF vs. 3*FFFF - it matters in this particular situation)

At any rate, I haven't even started that portion yet, but the new stat adjustment routine seems to be working great!
I'll refrain from making a patch until the whole shebang is done, but here's some code disassembly:
Code: [Select]
main routine:
$01/DE60 9D 24 20    STA $2024,x[$7E:22A4]
$01/DE63 5A          PHY                 
$01/DE64 DA          PHX                 
$01/DE65 FE 00 20    INC $2000,x[$7E:2280]
$01/DE68 C2 20       REP #$20             
$01/DE6A A9 80 02    LDA #$0280           
$01/DE6D 8D 90 22    STA $2290  [$7E:2290]
$01/DE70 7B          TDC                 
$01/DE71 E2 20       SEP #$20             
$01/DE73 22 20 E0 01 JSL $01E020[$01:E020]
$01/DE77 C2 20       REP #$20             
$01/DE79 0A          ASL A               
$01/DE7A 0A          ASL A               
$01/DE7B 0A          ASL A               
$01/DE7C 0A          ASL A               
$01/DE7D 0A          ASL A               
$01/DE7E 0A          ASL A               
$01/DE7F 0A          ASL A               
$01/DE80 0A          ASL A               
$01/DE81 7A          PLY                 
$01/DE82 BE 02 20    LDX $2002,y[$7E:2085]
$01/DE85 20 00 E1    JSR $E100  [$01:E100]
$01/DE88 99 12 20    STA $2012,y[$7E:2095]
$01/DE8B C9 00 01    CMP #$0100           
$01/DE8E B0 11       BCS $11    [$DEA1]   
$01/DE90 7B          TDC                 
$01/DE91 E2 20       SEP #$20             
$01/DE93 B9 70 20    LDA $2070,y[$7E:20F3]
$01/DE96 10 07       BPL $07    [$DE9F]   
$01/DE98 4C B8 DF    JMP $DFB8  [$01:DFB8]
$01/DE9B EA          NOP                 
$01/DE9C EA          NOP                 
$01/DE9D EA          NOP                 
$01/DE9E EA          NOP                 
$01/DE9F C2 20       REP #$20             
$01/DEA1 B9 12 20    LDA $2012,y[$7E:2095]
$01/DEA4 BE 02 20    LDX $2002,y[$7E:2085]
$01/DEA7 86 E8       STX $E8    [$00:00E8]
$01/DEA9 48          PHA                 
$01/DEAA 20 70 E1    JSR $E170  [$01:E170]
$01/DEAD E2 20       SEP #$20             
$01/DEAF 99 02 20    STA $2002,y[$7E:2085]
$01/DEB2 EA          NOP                 
$01/DEB3 EA          NOP                 
$01/DEB4 EA          NOP                 
$01/DEB5 18          CLC                 
$01/DEB6 69 0A       ADC #$0A             
$01/DEB8 99 2F 20    STA $202F,y[$7E:20B2]
$01/DEBB C2 20       REP #$20             
$01/DEBD B9 1B 20    LDA $201B,y[$7E:209E]
$01/DEC0 29 FF 00    AND #$00FF           
$01/DEC3 85 E8       STA $E8    [$00:00E8]
$01/DEC5 68          PLA                 
$01/DEC6 48          PHA                 
$01/DEC7 20 70 E1    JSR $E170  [$01:E170]
$01/DECA C9 0E 00    CMP #$000E           
$01/DECD 90 03       BCC $03    [$DED2]   
$01/DECF A9 0D 00    LDA #$000D           
$01/DED2 E2 20       SEP #$20             
$01/DED4 99 1B 20    STA $201B,y[$7E:209E]
$01/DED7 C2 20       REP #$20             
$01/DED9 B9 1D 20    LDA $201D,y[$7E:20A0]
$01/DEDC 29 FF 00    AND #$00FF           
$01/DEDF 85 E8       STA $E8    [$00:00E8]
$01/DEE1 68          PLA                 
$01/DEE2 48          PHA                 
$01/DEE3 20 70 E1    JSR $E170  [$01:E170]
$01/DEE6 C9 AF 00    CMP #$00AF           
$01/DEE9 90 03       BCC $03    [$DEEE]   
$01/DEEB A9 AE 00    LDA #$00AE           
$01/DEEE E2 20       SEP #$20             
$01/DEF0 99 1D 20    STA $201D,y[$7E:20A0]
$01/DEF3 C2 20       REP #$20             
$01/DEF5 B9 28 20    LDA $2028,y[$7E:20AB]
$01/DEF8 29 FF 00    AND #$00FF           
$01/DEFB 85 E8       STA $E8    [$00:00E8]
$01/DEFD 68          PLA                 
$01/DEFE 48          PHA                 
$01/DEFF EA          NOP                 
$01/DF00 20 70 E1    JSR $E170  [$01:E170]
$01/DF03 C9 00 01    CMP #$0100           
$01/DF06 90 03       BCC $03    [$DF0B]   
$01/DF08 A9 FF 00    LDA #$00FF           
$01/DF0B E2 20       SEP #$20             
$01/DF0D 99 28 20    STA $2028,y[$7E:20AB]
$01/DF10 C2 20       REP #$20             
$01/DF12 B9 2A 20    LDA $202A,y[$7E:20AD]
$01/DF15 29 FF 00    AND #$00FF           
$01/DF18 85 E8       STA $E8    [$00:00E8]
$01/DF1A 68          PLA                 
$01/DF1B 48          PHA                 
$01/DF1C 20 70 E1    JSR $E170  [$01:E170]
$01/DF1F C9 00 01    CMP #$0100           
$01/DF22 90 03       BCC $03    [$DF27]   
$01/DF24 A9 FF 00    LDA #$00FF           
$01/DF27 E2 20       SEP #$20             
$01/DF29 99 2A 20    STA $202A,y[$7E:20AD]
$01/DF2C C2 20       REP #$20             
$01/DF2E B9 22 20    LDA $2022,y[$7E:20A5]
$01/DF31 29 FF 00    AND #$00FF           
$01/DF34 85 E8       STA $E8    [$00:00E8]
$01/DF36 68          PLA                 
$01/DF37 48          PHA                 
$01/DF38 20 70 E1    JSR $E170  [$01:E170]
$01/DF3B C9 00 01    CMP #$0100           
$01/DF3E 90 03       BCC $03    [$DF43]   
$01/DF40 A9 FF 00    LDA #$00FF           
$01/DF43 E2 20       SEP #$20             
$01/DF45 99 22 20    STA $2022,y[$7E:20A5]
$01/DF48 C2 20       REP #$20             
$01/DF4A B9 24 20    LDA $2024,y[$7E:20A7]
$01/DF4D 29 FF 00    AND #$00FF           
$01/DF50 85 E8       STA $E8    [$00:00E8]
$01/DF52 68          PLA                 
$01/DF53 48          PHA                 
$01/DF54 20 70 E1    JSR $E170  [$01:E170]
$01/DF57 C9 00 01    CMP #$0100           
$01/DF5A 90 03       BCC $03    [$DF5F]   
$01/DF5C A9 FF 00    LDA #$00FF           
$01/DF5F E2 20       SEP #$20             
$01/DF61 99 24 20    STA $2024,y[$7E:20A7]
$01/DF64 BB          TYX                 
$01/DF65 C2 20       REP #$20             
$01/DF67 9E 09 20    STZ $2009,x[$7E:2289]
$01/DF6A B9 07 20    LDA $2007,y[$7E:208A]
$01/DF6D AA          TAX                 
$01/DF6E 29 FF 00    AND #$00FF           
$01/DF71 85 E8       STA $E8    [$00:00E8]
$01/DF73 68          PLA                 
$01/DF74 48          PHA                 
$01/DF75 20 70 E1    JSR $E170  [$01:E170]
$01/DF78 99 07 20    STA $2007,y[$7E:208A]
$01/DF7B 8A          TXA                 
$01/DF7C 29 00 FF    AND #$FF00           
$01/DF7F EB          XBA                 
$01/DF80 85 E8       STA $E8    [$00:00E8]
$01/DF82 68          PLA                 
$01/DF83 48          PHA                 
$01/DF84 20 70 E1    JSR $E170  [$01:E170]
$01/DF87 18          CLC                 
$01/DF88 79 08 20    ADC $2008,y[$7E:208B]
$01/DF8B C9 00 01    CMP #$0100           
$01/DF8E 90 03       BCC $03    [$DF93]   
$01/DF90 A9 FF 00    LDA #$00FF           
$01/DF93 99 08 20    STA $2008,y[$7E:208B]
$01/DF96 B9 07 20    LDA $2007,y[$7E:208A]
$01/DF99 99 09 20    STA $2009,y[$7E:208C]
$01/DF9C B9 15 20    LDA $2015,y[$7E:2098]
$01/DF9F 29 FF 00    AND #$00FF           
$01/DFA2 85 E8       STA $E8    [$00:00E8]
$01/DFA4 68          PLA                 
$01/DFA5 20 70 E1    JSR $E170  [$01:E170]
$01/DFA8 C9 00 01    CMP #$0100           
$01/DFAB 90 03       BCC $03    [$DFB0]   
$01/DFAD A9 FF 00    LDA #$00FF           
$01/DFB0 E2 20       SEP #$20             
$01/DFB2 20 90 E0    JSR $E090  [$01:E090]
$01/DFB5 99 15 20    STA $2015,y[$7E:2098]
$01/DFB8 BB          TYX                 
$01/DFB9 7A          PLY                 
$01/DFBA FE 00 20    INC $2000,x[$7E:2280]
$01/DFBD AD A5 28    LDA $28A5  [$7E:28A5]
$01/DFC0 5C FB 90 03 JMP $0390FB[$03:90FB]

Code: [Select]
Determine Adjusted APL Routine:
$01/E020 C2 20       REP #$20             
$01/E022 7B          TDC                 
$01/E023 AA          TAX                 
$01/E024 A8          TAY                 
$01/E025 85 A9       STA $A9    [$00:00A9]
$01/E027 E2 20       SEP #$20             
$01/E029 B9 00 20    LDA $2000,y[$7E:2083]
$01/E02C F0 0B       BEQ $0B    [$E039]   
$01/E02E B9 02 20    LDA $2002,y[$7E:2085]
$01/E031 C2 20       REP #$20             
$01/E033 18          CLC                 
$01/E034 65 A9       ADC $A9    [$00:00A9]
$01/E036 85 A9       STA $A9    [$00:00A9]
$01/E038 E8          INX                 
$01/E039 C2 20       REP #$20             
$01/E03B 98          TYA                 
$01/E03C 18          CLC                 
$01/E03D 69 80 00    ADC #$0080           
$01/E040 A8          TAY                 
$01/E041 7B          TDC                 
$01/E042 CC 90 22    CPY $2290  [$7E:2290]
$01/E045 90 E0       BCC $E0    [$E027]   
$01/E047 A5 A9       LDA $A9    [$00:00A9]
$01/E049 20 00 E1    JSR $E100  [$01:E100]
$01/E04C A2 03 00    LDX #$0003           
$01/E04F 20 00 E1    JSR $E100  [$01:E100]
$01/E052 0A          ASL A               
$01/E053 E2 20       SEP #$20             
$01/E055 6B          RTL                 

Code: [Select]
Speed Adjusting Routine:
$01/E090 D9 15 20    CMP $2015,y[$7E:2098]
$01/E093 F0 2D       BEQ $2D    [$E0C2]   
$01/E095 90 0B       BCC $0B    [$E0A2]   
$01/E097 38          SEC                 
$01/E098 F9 15 20    SBC $2015,y[$7E:2098]
$01/E09B 4A          LSR A               
$01/E09C 18          CLC                 
$01/E09D 79 15 20    ADC $2015,y[$7E:2098]
$01/E0A0 80 20       BRA $20    [$E0C2]   
$01/E0A2 C2 20       REP #$20             
$01/E0A4 EB          XBA                 
$01/E0A5 E2 20       SEP #$20             
$01/E0A7 B9 15 20    LDA $2015,y[$7E:2098]
$01/E0AA C2 20       REP #$20             
$01/E0AC EB          XBA                 
$01/E0AD E2 20       SEP #$20             
$01/E0AF 99 15 20    STA $2015,y[$7E:2098]
$01/E0B2 A9 00       LDA #$00             
$01/E0B4 C2 20       REP #$20             
$01/E0B6 EB          XBA                 
$01/E0B7 E2 20       SEP #$20             
$01/E0B9 38          SEC                 
$01/E0BA F9 15 20    SBC $2015,y[$7E:2098]
$01/E0BD 4A          LSR A               
$01/E0BE 18          CLC                 
$01/E0BF 79 15 20    ADC $2015,y[$7E:2098]
$01/E0C2 60          RTS   

Sorry, there's no commentary for now.
I'll repost with explanations at some point; but at least since I posted it I won't lose where I put it (like I did half the shadow party hack).

Grimoire LD

  • FF4 Hacker
  • *
  • Posts: 1,684
    • View Profile
Re: Final Fantasy IV: Side Project (Random AI Routine complete!)
« Reply #77 on: January 15, 2015, 05:18:41 PM »
Yes, posted indeed, which is one of the reasons I post even some of my more insignificant matters because I just Know I'll lose them if I don't record them somewhere.

The code itself looks pretty solid. Looks like the APL first checks if there's a character in that slot proper. Though what is this 01E170 address that you're JSRing too fairly often in the Stat Routines

chillyfeez

  • FF4 Hacker
  • *
  • Posts: 1,285
  • Gender: Male
  • Go ahead, ask me about Angel Feathers!
    • View Profile
Re: Final Fantasy IV: Side Project (Random AI Routine complete!)
« Reply #78 on: January 15, 2015, 06:30:45 PM »
Oh, that's the multiplication subroutine from the original Monster Level-Up patch. And 1/E100 is division.

Grimoire LD

  • FF4 Hacker
  • *
  • Posts: 1,684
    • View Profile
Re: Final Fantasy IV: Side Project (Random AI Routine complete!)
« Reply #79 on: January 15, 2015, 07:14:41 PM »
Ah. Sounds good to me then. I'm impressed you managed this all in Bank 1, I'm a bit lost in hacking when I can't use the easy 03 Bank shortcuts.

Grimoire LD

  • FF4 Hacker
  • *
  • Posts: 1,684
    • View Profile
Re: Final Fantasy IV: Side Project (Random AI Routine complete!)
« Reply #80 on: February 19, 2015, 11:40:31 AM »
Since I have a day off (Impossible!!!) I'm about up to Cagnazzo in playing through Side Project, and I noticed something odd, but expected now that I think on it. Once the Paladin event happens the game looks ?somewhere? for Paladin Cecil's HP to display on the save menu. It is a minor issue at most, but it's still an unknown. My instincts tell me that it's probably an event flag which switches what Actor is looked at for that, but I cannot say for certain.

I'll take a look and see if I can find an answer.

...And it did not deal with an event flag shockingly enough. I'm not sure what activates this then...

Ah! Found it, just did a search for C90B in Bank 01 and found it almost immediately... it deals nothing with Event Flags, as said. The game first looks to see if Actor 01, the Dark Knight is present and if not looks for Actor 0B, Paladin Cecil.
Code: [Select]
$01/9A81 BD 00 00 LDA $0000,x[$70:0000] A:0000 X:0000 Y:0000 P:envmxdIZc - Load A from... 700000? (Maybe something dealing with save data temp storing?)
$01/9A84 29 3F 00 AND #$003F A:8748 X:0000 Y:0000 P:eNvmxdIzc - Get rid of variables.
$01/9A87 C9 01 00 CMP #$0001 A:0008 X:0000 Y:0000 P:envmxdIzc - Is it the Dark Knight?
$01/9A8A F0 0D BEQ $0D    [$9A99] A:0008 X:0000 Y:0000 P:envmxdIzC - If so, branch to end.
-------------------------------------------------------------------------------------------------------------
$01/9A8C C9 0B 00 CMP #$000B A:0008 X:0000 Y:0000 P:envmxdIzC - Is it Paladin Cecil?
$01/9A8F F0 08 BEQ $08    [$9A99] A:0008 X:0000 Y:0000 P:eNvmxdIzc - If so, branch to end.
----------------------------------------------------------------------------------------------------------------
$01/9A91 8A TXA A:0008 X:0000 Y:0000 P:eNvmxdIzc - Transfer X to A
$01/9A92 18 CLC A:0000 X:0000 Y:0000 P:envmxdIZc - Clear Carry Flag
$01/9A93 69 40 00 ADC #$0040 A:0000 X:0000 Y:0000 P:envmxdIZc - Add 0040 (look at the next character)
$01/9A96 AA TAX A:0040 X:0000 Y:0000 P:envmxdIzc - Transfer A to X.
$01/9A97 80 E8 BRA $E8    [$9A81] A:0040 X:0040 Y:0000 P:envmxdIzc -Loop back. (I don't know how it breaks out of this, technically speaking it seems like it should be an infinite loop? Maybe eventually the system will always find a 0001 or 000B to draw from in a sequence of 40 bytes?)

Changing 0B to Paladin Cecil's new ID of 0A will solve the problem I was facing. You may also want to make note of this as well for your Shadow Party Mod all-in-all Chillyfeez since you've changed Paladin Cecil's ID and changing it with FF4kster is not plausible.

Grimoire LD

  • FF4 Hacker
  • *
  • Posts: 1,684
    • View Profile
Re: Final Fantasy IV: Side Project (Random AI Routine complete!)
« Reply #81 on: February 21, 2015, 11:09:33 AM »
All normal monster's random AI routines are complete, with 13 spaces left for the remaining bosses!


(Mist D.)
(OctoMamm)
(MomBomb)
(Dark Elf)
(Valvalis)
(Calbrena)
(Golbez)
(Lugaborg)
(Rubicante)
(Bahamut)
(Wyvern)
(Pale Dim)
(Zeromus)

Then the AI Routine of this project will be all but finished. As for playthrough I am currently right past Cagnazzo and because of all that opens up I completed all normal Random AI routines for normal enemies before continuing on. This will let me test accordingly until I reach the Dark Elf/Dragon where I will have to choose his four random attacks to use.

All in all things are moving along smoothly, not as fast as I would like, but that's what I can accomplish with 45 Hour work weeks, 13 hours a day at times, with school on the side.