øA slickproductions.org /forum/index.php?PHPSESSID=5f0fck550j2m4m2fpbtkj2vkm1&action=printpage;topic=1993.0 e:/My Web Sites/Slick Productions - FFIV Message Board/slickproductions.org/forum/index41b2-2.html slickproductions.org /forum/index.php?PHPSESSID=5f0fck550j2m4m2fpbtkj2vkm1&topic=1993.0 e:/My Web Sites/Slick Productions - FFIV Message Board/slickproductions.org/forum/index41b2-2.html.z x 0,g^ ÿÿÿÿ ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÈ P, —* OK text/html ISO-8859-1 gzip 0|Ö —* ÿÿÿÿÿÿÿÿ Tue, 10 Mar 2020 06:13:26 GMT 0ó° °® 0® P® €§² ð® .,g^ ÿÿÿÿÿÿÿÿ«q —*
Print Page - Final Fantasy IV: Side Project (Random AI Routine complete!)
Board of Slick
Library of the Ancients => Final Fantasy IV Research & Development => Topic started by: Grimoire LD on December 30, 2014, 07:58:04 PM
Title: Final Fantasy IV: Side Project (Random AI Routine complete!)
Post by: Grimoire LD on December 30, 2014, 07:58:04 PM
With Combat Boost in a pretty stable state I thought I should talk about a side-project of sorts, as Chillyfeez has pointed out one of the glaring issues with FFIV is the lack of any randomized AI, the closest the game ever gets to randomization in AI is Blaster/Slap/Gaze which can do a variety of randomized status effects. Where FFIV shines was its use of counter-attacks and scripts depending on the enemy's state, but those are so rarely used in normal battle anyhow except for the Charm Script. (except for Counter-Scripts which will be left alone for the most part)
My thought is to use several formulas which aren't necessary (Protect and Shell come immediately to mind) and use them to Jump to a lot of empty space where I could set up four random spells/commands for an enemy to use.
What will probably be done is that each family of monster will get the same AI Choices (just as in the normal game each family of monster has similar AI)
In FFIV there are 65 Normal Enemy Families even that is a fairly tall order, but I think there will be enough space to make this work (One of those four choice will probably be Fight that all monsters could use anyhow so really only 3)
There are three unused spells in FFIV, Two blank skills right underneath W. Meteo and DullSong (is meant to be used by Scarmiglione as a counter, but the Index is never given to him) that should be enough to tie the random AI to.
In addition this patch would use Chillyfeez's Shadow Party Hack, Enemy Level Up, and User Options and will use Vivify93's Project II as a base.
This project will also include my various fixes.
Since this is using the Shadow Party Hack I will try to set up events for switching characters in the Tower of Prayer late in the game, exchanging Kain for Yang, Edge for Cid OR Edward, Rosa for Porom, and Rydia for Palom.
I should have enough event slots for this.
That's about the gist of it, I might throw in another hammer and harp or two for Cid and Edward. I will note now that I will not bother to mess with the end-game events, though for fairly obvious reasons. This patch is just a proof of concept, really.
So in total...
Randomized AI Enemy Level Up Bug Fixes Party Rejoining
Title: Re: Final Fantasy IV: Side Project
Post by: chillyfeez on December 30, 2014, 08:57:05 PM
Fun. Inspired idea for random AI. Does this mean you're taking a break from Combat Boost?
Title: Re: Final Fantasy IV: Side Project
Post by: Grimoire LD on December 30, 2014, 09:06:21 PM
Not so much a break, an "intermission" I suppose you could say since I'm just about at the Underworld. I don't anticipate this project taking any longer than a couple of weeks since the most complicated part will be testing the event npc's and the like and the most laborious part will be writing the customized AI choices. Everything else is pretty much already done.
Title: Re: Final Fantasy IV: Side Project
Post by: TheBigT2000 on December 30, 2014, 09:48:59 PM
I have sort of a better idea, have all of the party members except for Cecil all be in the Lunar Whale walking around, and if you talking to say, Rosa, she would ask: "Mind if I tag along?" And you can say Yes or No, saying yes, she would stay in the party, but if you say no, it would take her out of the party. Then say, Yang asks to join the party and if you say yes, he'd join the party. I'm thinking of doing this for my hack.
Title: Re: Final Fantasy IV: Side Project
Post by: LordGarmonde on December 30, 2014, 09:54:53 PM
:hmm: FF6/FF7 Style - Interesting
I wouldn't necessarily say better though; I could imagine trouble when it came to the end when playing the cutscene where everyone wishes for you. That would have to be extensively modified to include loading the Lunar Whale.
Title: Re: Final Fantasy IV: Side Project
Post by: TheBigT2000 on December 30, 2014, 09:57:35 PM
That's another thing I was thinking of: Removing that scene entirely. Seems to be the most effective think to do.
Title: Re: Final Fantasy IV: Side Project
Post by: Grimoire LD on December 30, 2014, 10:27:33 PM
I have sort of a better idea, have all of the party members except for Cecil all be in the Lunar Whale walking around, and if you talking to say, Rosa, she would ask: "Mind if I tag along?" And you can say Yes or No, saying yes, she would stay in the party, but if you say no, it would take her out of the party. Then say, Yang asks to join the party and if you say yes, he'd join the party. I'm thinking of doing this for my hack.
While it looks good on the surface it doesn't take what happens when you already have five characters into account.
Say in your plan that I have a full party and I forget to remove someone, then when I choose someone else to join the party, the game won't add them to my party because my party is already full, in reality though that's not a big deal.
For the problem of character copies you could utilize event flags to change the character's event into just "Remove character? Yes/No" when they're already in the party but there is no default check the game performs to see if there is a full party.
You know... there just might be something to this, I'll have to set up a test for this to see if that will work. Thanks for the idea!
This plan will require 18 event scripts, 9 for...
Kain Rydia Edward Rosa Yang Palom Porom Cid Edge
And 9 for their flag check of "already in party."
As for optional events that no one should miss...
1.Ouch! from fire 2.Cecil's Maid 3. Item Selection: Soft (On the Twins) 4. Giott: Open the Door! (Not used) 5. Terrible bombardments... (not necessary) 6. WA! (Pretty sure... not used?) 7. We also might have been hypnotized (not used, bank2 message) 8. Calling Fat Chocobo with Carrot (Final will have the Cache command) 9. Resting for free in Fabul "Let's sleep in the King's Bed!" 10. Reading the Magazine 11. Obtaining the Magazine 12. Obtaining Grimoire1 13. Obtaining Grimoire2 14. Obtaining Grimoire3 15. Kaipo Dancer 16. Fabul Dancer 17. Agart Dancer 18. Dwarf Castle Dancer
That covers 18 non essential and hardly noticeable events. I just need to be careful to give all of the dying soldiers the "..." event then in Damcyan.
Title: Re: Final Fantasy IV: Side Project
Post by: chillyfeez on December 30, 2014, 11:14:54 PM
Can't the Damcyan Soldiers just use bank 2 messages? I never understood why they had their own events.
Title: Re: Final Fantasy IV: Side Project
Post by: Grimoire LD on December 30, 2014, 11:25:13 PM
Can't the Damcyan Soldiers just use bank 2 messages? I never understood why they had their own events.
I think it was supposed to be a way of saving Bank 2 space (so they wouldn't have to use "..." several times in the maps) but it does kill an event spot, yes. So I have everything all figured out for the party composition in any event due to BigT2000's suggestion.
3/7 Kain (Down) 1.Ouch! from fire - Kain Joining 2.Cecil's Maid - Kain Leaving (Flag 90)
5/7 Rydia 3. Item Selection: Soft (On the Twins) 4. Giott: Open the Door! (Not used)
9/7 Edward 5. Terrible bombardments... (not necessary) 6. WA! (Pretty sure... not used?)
11/7 Rosa 7. We also might have been hypnotized (not used, bank2 message) 8. Calling Fat Chocobo with Carrot (Final will have the Cache command)
12/8 Yang (Left) 9. Resting for free in Fabul "Let's sleep in the King's Bed!" 10. Reading the Magazine
12/9 Palom 11. Obtaining the Magazine 12. Obtaining Grimoire1
Another problem I thought of was "What happens if you switch to that party member while the Party Member is standing right there?" Well, while it's not so clean, I was thinking of forcing Paladin Cecil's sprite to be the one displayed when you go to talk to them, so yes there will be that weirdness when you see a copy of a party member, but since it switches to Paladin Cecil's sprite when you go to speak with them it shouldn't look too strange.
Title: Re: Final Fantasy IV: Side Project
Post by: TheBigT2000 on December 30, 2014, 11:58:10 PM
Glad I could help by giving you the idea! ^_^
Also, I'm serious about doing something like this in my hack. XD
Title: Re: Final Fantasy IV: Side Project
Post by: chillyfeez on December 31, 2014, 12:02:20 AM
Another problem I thought of was "What happens if you switch to that party member while the Party Member is standing right there?" Well, while it's not so clean, I was thinking of forcing Paladin Cecil's sprite to be the one displayed when you go to talk to them, so yes there will be that weirdness when you see a copy of a party member, but since it switches to Paladin Cecil's sprite when you go to speak with them it shouldn't look too strange.
Hmm... That is a weird logistical issue. You could make the character disappear (and deactivate) when they join the party, then maybe the fat chocobo in the whale (since he won't be storing items) could offer the option to clear out the roster, which would remove all characters, and activate all of their NPCs. Though the invisible ones would stay invisible until you exit and reenter the screen... Unless you put Fatty in his own separate room... Or... Anybody got any other ideas?
Title: Re: Final Fantasy IV: Side Project
Post by: TheBigT2000 on December 31, 2014, 12:04:55 AM
I say it wouldn't be THAT huge of a problem.
Title: Re: Final Fantasy IV: Side Project
Post by: Grimoire LD on December 31, 2014, 12:10:56 AM
Another problem I thought of was "What happens if you switch to that party member while the Party Member is standing right there?" Well, while it's not so clean, I was thinking of forcing Paladin Cecil's sprite to be the one displayed when you go to talk to them, so yes there will be that weirdness when you see a copy of a party member, but since it switches to Paladin Cecil's sprite when you go to speak with them it shouldn't look too strange.
Hmm... That is a weird logistical issue. You could make the character disappear (and deactivate) when they join the party, then maybe the fat chocobo in the whale (since he won't be storing items) could offer the option to clear out the roster, which would remove all characters, and activate all of their NPCs. Though the invisible ones would stay invisible until you exit and reenter the screen... Unless you put Fatty in his own separate room... Or... Anybody got any other ideas?
I didn't think about it like that... that would work, I do already have events set up for the "Add Character" and "Remove Character" if I had thought about it setting them to deactivate and clearing the Roster (and reload the map in the process of the evennt) would make that much easier, I... only needed 9 events then, hah.
Great idea by the way Chillyfeez! This will look the cleanest.
In other news I now have the room setup and it looks pretty nice.
Title: Re: Final Fantasy IV: Side Project
Post by: TheBigT2000 on December 31, 2014, 12:14:19 AM
It looks awesome! Nice layout!
Title: Re: Final Fantasy IV: Side Project
Post by: Grimoire LD on December 31, 2014, 12:27:44 AM
Ah, one small problem with the Fat Chocobo... it seems maps are forced to use only 12 NPC's the Lunar Whale uses 2 by default (well 6 before deleting the Fat Chocobo) and with 9 characters that leaves only one, for one normal NPC for the party clear. So I guess that normal NPC will be... let's go with Namingway, he follows you everywhere else, why not to the Moon?
Title: Re: Final Fantasy IV: Side Project
Post by: chillyfeez on December 31, 2014, 12:33:28 AM
Um... Does reloading the map in the roster clearing event cause weirdness when trying to exit the whale?
Title: Re: Final Fantasy IV: Side Project
Post by: Grimoire LD on December 31, 2014, 12:36:24 AM
Um... Does reloading the map in the roster clearing event cause weirdness when trying to exit the whale?
...I didn't think of that either. It likely will in reality. I'll have to try it out.
:edit: Yes, yes it does put me back at the warp... alright. Leaving the ship to refresh the roster seems the best way to go about it then (because of map reloading and "go to last map" tiles, bah.)
Title: Re: Final Fantasy IV: Side Project
Post by: TheBigT2000 on December 31, 2014, 12:48:55 AM
Could we see like a video showcasing how it's coming along or something? :3
Title: Re: Final Fantasy IV: Side Project
Post by: Grimoire LD on December 31, 2014, 12:50:34 AM
Could we see like a video showcasing how it's coming along or something? :3
I've never made a video on this computer, I wonder if it's even capable of video in all honesty. It's pretty late at the moment, but I do want to try to get at least the character's text down before calling it a night.
Title: Re: Final Fantasy IV: Side Project
Post by: TheBigT2000 on December 31, 2014, 12:52:19 AM
Okay, that's fair enough. XD
Title: Re: Final Fantasy IV: Side Project
Post by: avalanche on December 31, 2014, 08:58:08 AM
I _heart_ this idea.
I pondered about this at one point and was immediately discouraged by the amount of event scripts that would be messed up by someone in or not in your party. But if you are doing it only later in the game, when the whale is available, maybe that isn't so bad.
Title: Re: Final Fantasy IV: Side Project
Post by: LordGarmonde on December 31, 2014, 09:15:46 AM
I don't know how practical/friendly this would be - but I have an idea: What about putting someone on the ship (say Namingway) who serves the purpose to remove everyone from your party then you can go around adding people:
So...Talk to Namingway - Change Party Members (Yes/No?) If Yes - Remove Everyone But Cecil Then talk to each person to add them back. Otherwise your party is just left alone This I think could work for any point in the game provided code to determine who should be walking around the ship - not sure how to do that at the moment :hmm: I would think though, you could save at least some events with this approach if used only at the end of the game. Thoughts?
Title: Re: Final Fantasy IV: Side Project
Post by: Grimoire LD on December 31, 2014, 09:25:33 AM
I pondered about this at one point and was immediately discouraged by the amount of event scripts that would be messed up by someone in or not in your party. But if you are doing it only later in the game, when the whale is available, maybe that isn't so bad.
That is how FFIV:A (and the PSP Complete Collection) handled the matter and I think it works and makes sense, we're not aware of the fate of some of the characters until the Giant of Babil sequence anyhow.
What cannot be done in a sensical manner is set up a display for each party formation, (9x4=36 Party Formations) so I probably will not mess with the ending scenes at all other than removing the Tower of Prayer segment.
I don't know how practical/friendly this would be - but I have an idea: What about putting someone on the ship (say Namingway) who serves the purpose to remove everyone from your party then you can go around adding people:
So...Talk to Namingway - Change Party Members (Yes/No?) If Yes - Remove Everyone But Cecil Then talk to each person to add them back. Otherwise your party is just left alone This I think could work for any point in the game provided code to determine who should be walking around the ship - not sure how to do that at the moment :hmm: I would think though, you could save at least some events with this approach if used only at the end of the game. Thoughts?
Basically so, that's how the other versions have handled it and I think it works well, if not a little bit too limited, but that is the way the original plot went. What you suggested was the original plan when I ditched the Fat Chocobo for Namingway.
Namingway will ask "Would you like to clear the roster?" (Yes) reactivate all NPC's/clear party (No) no change to party.
Title: Re: Final Fantasy IV: Side Project
Post by: avalanche on December 31, 2014, 09:51:12 AM
I think it might be 9*8*7*6 = 3024 formations? But yeah still too many :)
It's a great idea. It would be sweet if earlier there were some options. But you're right, it seems like the story doesn't lend itself to it since everybody is pulled from the party rather harshly and they aren't available, either presumed dead or working for the bad guy.
Title: Re: Final Fantasy IV: Side Project
Post by: Grimoire LD on December 31, 2014, 10:25:09 AM
I think it might be 9*8*7*6 = 3024 formations? But yeah still too many :)
It's a great idea. It would be sweet if earlier there were some options. But you're right, it seems like the story doesn't lend itself to it since everybody is pulled from the party rather harshly and they aren't available, either presumed dead or working for the bad guy.
The only exception might be Cid at the Giant of Babil because it honestly seems as if he was intended to join the party, (his data is even saved to a shadow slot when he leaves) it would be the One Time in the game where Cid could realistically be there and deal that x4 damage to machines that his Hammers are capable of, but for whatever reason they decided not to go for it. Probably logistics again.
The Twins are stone for the vast majority of the game.
Edward would be an easy possibility at the Magnes Cave (4 Party Members +1 Edward, it could have worked, his harps aren't Metallic noticeably) and have him leave the party again after he finishes his assignment.
Yang could have joined as well as early as waking him up, but again, five party members already.
Granted a new sidequest to find the fabled "Super-Soft" to cure the Twins ahead of time Might be interesting... but is outside the scope of this particular project.
Title: Re: Final Fantasy IV: Side Project
Post by: Grimoire LD on December 31, 2014, 11:02:35 AM
Well, I've hit a bit of a problem... when I go to remove any character from the party, the game crashes. I haven't been able to pinpoint why this is...
Would you mind if I sent you the ROM Chillyfeez? Since it seems to deal something with the Shadow Party Mod, maybe you might be able to make better sense of what went wrong, I would look it up, but there's no clear documentation on what you added, I am wondering if there's another code conflict somewhere?
I need to be headed to work soon so I will send you the ROM, but if you'd rather not deal with this, it's completely understandable.
Title: Re: Final Fantasy IV: Side Project
Post by: chillyfeez on December 31, 2014, 01:30:26 PM
Probably another patch conflict. I'll likely be able to fix it, but not today. But I'm off 1/1 and 1/2.
Title: Re: Final Fantasy IV: Side Project
Post by: Grimoire LD on December 31, 2014, 06:01:11 PM
Probably another patch conflict. I'll likely be able to fix it, but not today. But I'm off 1/1 and 1/2.
Sounds good, just a note when I repatch the Shadow Mod onto the ROM the game works fine, removes party members and everything, Except in battle, battle starts and then the screen goes black within the first few seconds. Maybe something that might help you pinpoint the problem. In the meantime I can work on Combat Boost.
Title: Re: Final Fantasy IV: Side Project
Post by: chillyfeez on December 31, 2014, 06:19:45 PM
Good to know. It'll be something with either defer or atb then.
Title: Re: Final Fantasy IV: Side Project
Post by: chillyfeez on January 02, 2015, 03:57:22 PM
It's all set, Grimoire. It was a veritable nightmare, but I fixed it. Check your RHDN messages for the link.
Title: Re: Final Fantasy IV: Side Project
Post by: Grimoire LD on January 02, 2015, 06:49:16 PM
Thanks Chillyfeez! Well that's everything done with the Shadow Party, and I've increased the levels of enemies as suggested to assure they don't get too powerful, too quickly (though there is still the worry that the decrease in stats may make them too weak, but we'll see). Now it's time for me to do my part and get the randomized enemy AI up and running.
Title: Re: Final Fantasy IV: Side Project
Post by: Grimoire LD on January 02, 2015, 07:34:51 PM
So I hit my first roadblock... what I did with my Dragon Speech hack is force it to look only at the first enemy's typing. This obviously wouldn't work in randomized AI and there is no easy way to discern what monsters are Type0,1, or 2 within the stats, so after pondering the question for a while I think I'll have to do something a little different. I think I'll have to tie randomized AI to (unused) magical evasion and put it in a byte where it's not doing anything. While it sacrifices (dummied)magical evasion, I'm not too worried, since magical evasion can get rather crazy in default FFIV and in some respects its little wonder they axed it in the manner they did. This should give me full control of which enemy's will have what AI.
Title: Re: Final Fantasy IV: Side Project
Post by: chillyfeez on January 02, 2015, 07:58:12 PM
Is this something that's only looking at enemies' unused stat bytes? Because ATB uses at least one (maybe more?) unused stat byte of each player character.
Title: Re: Final Fantasy IV: Side Project
Post by: Grimoire LD on January 02, 2015, 08:10:35 PM
Is this something that's only looking at enemies' unused stat bytes? Because ATB uses at least one (maybe more?) unused stat byte of each player character.
Indeed it uses only enemy bytes, I'll give an example of what I mean...
Imp will use Random AI set 01, so his Magic Evasion in the editor will be set to 01.
Using the info. I've recorded down on my Evasion fix...
$03/90E9 9D 22 20 STA $2022,x[$7E:22A2] A:0001 X:0280 Y:0083 P:envMxdIzC - Store Magic Defense Multiplier into Monster's stats $03/90EC AD 1D 29 LDA $291D [$7E:291D] A:0001 X:0280 Y:0083 P:envMxdIzC - Load Magical Evasion $03/90EF 9D 24 20 STA $2024,x[$7E:22A4] A:0028 X:0280 Y:0083 P:envMxdIzC - Load Magical Evasion into Monster's stats (where Magical Defense Base will be) $03/90F2 AD 1E 29 LDA $291E [$7E:291E] A:0028 X:0280 Y:0083 P:envMxdIzC - Load Magical Defense Base $03/90F5 9D 24 20 STA $2024,x[$7E:22A4] A:0009 X:0280 Y:0083 P:envMxdIzC - Store Magical Defense Base over Magical Evasion
I just change...
$03/90EF 9D 24 20 STA $2024,x[$7E:22A4] A:0028 X:0280 Y:0083 P:envMxdIzC - Load Magical Evasion into Monster's stats (where Magical Defense Base will be)
To 9D3420 which will store Magical Evasion into Monster's Right Hand Quantity which is never looked at by the game and use that as an easy reference point for all monsters to find the AI Pattern they should be using when the routine calls for it.
:edit: Oh, I see. You're using that byte as well, thankfully you still have that old piece of code hanging there in the jump. So I can still change it without worrying, phew I was worried there for a second.
Title: Re: Final Fantasy IV: Side Project
Post by: chillyfeez on January 02, 2015, 08:44:01 PM
Oh, yeah, I forgot that level-up uses some unused monster bytes... But just as place holders for the calculations, I think.
Title: Re: Final Fantasy IV: Side Project
Post by: Grimoire LD on January 02, 2015, 09:42:14 PM
I will have to think carefully on how I want to tackle this, I have the record and the jump in data, but I tried to set up an AI pattern and came to the realization that there really is not enough room for the 64 monster types, and even if there was it would be the most inefficient means of coding ever conceived at least in a basic set up, so what I need to do is create a set of bytes that are in ROM Data for the 64 (possibly more if I have room in ROM) Randomized AI Setups.
The plan is this...
1. Look in ROM for 800 free consecutive bytes. (320 in hex) 2. Write the AI abilities into these bytes starting from Imp AI and onwards.
3. Write the routine consisting of...
Create Random Number between 0-3 - store it in Monster's Left-Handed quantity - Look at Magic Evasion - x4 it, store it in X, Add the random number in left handed quantity to X. Load ROM Address where the AI is stored +X(to get to the correct AI) - A BEQ for 00 to allow for basic Fight command. Maybe something special for Ally Targeting commands, and that should do it.
This is much more efficient than my original plan, now I just need to find those 320 Bytes and I'll be golden.
Title: Re: Final Fantasy IV: Side Project
Post by: chillyfeez on January 02, 2015, 10:05:36 PM
The empty spaces around the summon images should be more than enough if you can't find it anywhere else.
Title: Re: Final Fantasy IV: Side Project
Post by: Grimoire LD on January 02, 2015, 10:17:04 PM
The empty spaces around the summon images should be more than enough if you can't find it anywhere else.
Thanks for the suggestion Chillyfeez, I think though that I might have just found a gigantic amount right underneath the Title Screen's graphics. Starting from 438C0 to 44000, that's more than enough, and then some. At first I thought it may have been the blackness around the title screen, but it does not appear to be.
In LoRom this is at... 08B8C0
This should really get me started then.
Title: Re: Final Fantasy IV: Side Project
Post by: Grimoire LD on January 03, 2015, 12:06:30 AM
And I've hit another snag that I wasn't anticipating. Enemy using Commands is Nothing like characters using command. For giving a character randomized command is an absurdly simple process, here it is the opposite thereof. Enemies don't follow the same rules and may use a different matter all together to draw their next attack from, if such is the case I will need to strike at the core of the basic AI system instead of trying to treat them as semi-PC's and thinking that they can use Spells from Commands.
Title: Re: Final Fantasy IV: Side Project
Post by: chillyfeez on January 03, 2015, 01:03:27 AM
Hmm... Yeah.
You might have to set a breakpoint to where the AI scripts are loaded into RAM... It's gonna require some custom coding.
Maybe what you can do is take one of those unused/disused AI commands you guys were talking about recently and write a new routine for it... You could essentially copy one of the "cast a spell" routines, except preempt that with the RNG that determines which spell, if that makes any sense at all...
Or just work it into one of the "cast a spell" routines... For instance, I don't know what spell BF is or who uses it, but let's pretend for the sake of demonstration it can be done without. You would tell the AI reading code (during a JSL) that after it loads the battle command into A, if A=BF, then jump to the specialized RNG code (otherwise proceed as normal).
Sorry if that sounds like babble... Let me know if you need me to clarify, unless you've already figured something else out.
Title: Re: Final Fantasy IV: Side Project
Post by: Grimoire LD on January 03, 2015, 06:53:47 AM
BF is the graphic for Zeromus' Full Heal attack, that's it. So while not unused, it is rather strange that they created a slot for it when i think they could have just used the initial Zeromus Elixir attack and add a graphic to it. But I know of a spell that is completely unused (aside from the two below W. Meteo) and that is DullSong, it's meant to be used in a counter script by Milon-Z but was never given to him for some reason (Rubicante also has an unused counter script) DullSong also has the added benefit of suppressing its name so no chance of "RandomAI" showing up for the player to see. That was my first attempt, but then I saw that monsters use commands differently and by the time they use a spell they don't seem to have the capacity to change what the spell will be, at least not in the same way PC's do. So that plan was out. The second plan was to use Cid's "Crash" command and tie random skills into that and though I have the code working perfectly (if they were PC's) it doesn't work the same for enemies.
So my plan is to trace back in enemy AI until I find what puts the default spell into the Spell Action byte and manipulate it from its source with a jump to custom code that checks to see if the spell is DullSong (now called RandomAI) and if so to move forward in my custom code. I'll hopefully be able to figure this out when I get home from work today.
:edit: And accomplished! I can easily branch it into the code which looks at the AI routine, look for the specific spell (in this case DullSong) and move off of my custom code from there, this actually might be Much cleaner than I originally anticipated! Expect some updates when I get home later tonight!
Title: Re: Final Fantasy IV: Side Project
Post by: chillyfeez on January 03, 2015, 08:27:14 AM
Oh, good. I was just looking into this and about to post some findings/ideas, but it looks like you're all set. Looking forward to what you come up with.
Title: Re: Final Fantasy IV: Side Project
Post by: Grimoire LD on January 03, 2015, 06:00:35 PM
I expected this to take at least 80 to 100 bytes, boy was I wrong! The basic set-up has been implemented and works to perfection! It is such a simple method that I utilized, but first the important notes...
(the current hex will lead directly into my code and I'll explain their function lateR)
$03/B557AE C1 35LDX $35C1 [$7E:35C1]A:0007X:0006Y:FFFFP:envMxdizc - Load AI Pointer into A. $03/B55A7B TDCA:0007X:0780Y:FFFFP:envMxdizc - Clear A $03/B55BA8 TAYA:0000X:0780Y:FFFFP:envMxdiZc - Transfer A to Y. $03/B55CBD 5F 40LDA $405F,x[$7E:47DF]A:0000X:0780Y:0000P:envMxdiZc - Load AI Command into A. $03/B55FC9 FFCMP #$FFA:0076X:0780Y:0000P:envMxdizc - Is it End? $03/B561D0 07BNE $07 [$B56A]A:0076X:0780Y:0000P:envMxdizc - If not, branch. ----------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------- $03/B56A20 F0 FEJSR $FEF0 [$03:FEF0]A:0076X:0780Y:0000P:envMxdizc - Jump to custom subroutine. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~` $03/FEF0BD 5F 40LDA $405F,x[$7E:47DF]A:0076X:0780Y:0000P:envMxdizc - Load AI Command into A (used as a looping point at times) $03/FEF3C9 76CMP #$76A:0076X:0780Y:0000P:envMxdizc - Is it Random AI? $03/FEF5D0 1CBNE $1C [$FF13]A:0076X:0780Y:0000P:envMxdiZC - If not, branch to end. ---------------------------------------------------------------------------------------------- $03/FEF7DA PHXA:0076X:0780Y:0000P:envMxdiZC - Push X (to retrieve at end of custom routine) $03/FEF8A2 00 00LDX #$0000A:0076X:0780Y:0000P:envMxdiZC - Load 0000 into X. $03/FEFBA9 03LDA #$03A:0076X:0000Y:0000P:envMxdiZC - Load 03 into A. $03/FEFD20 79 83JSR $8379 [$03:8379]A:0003X:0000Y:0000P:envMxdizC - Produce a random number between 00-03. $03/FF00A6 A6LDX $A6 [$00:00A6]A:0001X:0000Y:0000P:envMxdizc - Load Unit Identifier into X. $03/FF029D 26 20STA $2026,x[$7E:2426]A:0001X:0400Y:0000P:envMxdizc - Store Random Number in Left-Hand Quantity (unused by enemies) $03/FF05BD 24 20LDA $2024,x[$7E:2424]A:0001X:0400Y:0000P:envMxdizc - Load Enemy's AI Pattern number (Magical Evasion) from Right-Hand quantity $03/FF080A ASL AA:0001X:0400Y:0000P:envMxdizc - x2 A $03/FF090A ASL AA:0002X:0400Y:0000P:envMxdizc - x2 A (Four bytes comprise the random AI for each monster and this x4 gets you accurately to the Random AI for that number. $03/FF0A7D 26 20ADC $2026,x[$7E:2426]A:0004X:0400Y:0000P:envMxdizc - Add the random value onto A. $03/FF0DAA TAXA:0005X:0400Y:0000P:envMxdizc - Transfer A to X $03/FF0EBF BC B8 08LDA $08B8BC,x[$08:B8C1]A:0005X:0005Y:0000P:envMxdizc - Load A from Random AI Pointers - AI 1 - Option 2. $03/FF12FA PLXA:0002X:0005Y:0000P:envMxdizc - Pull X (to bring X to its proper reading from the start of the custom routine) $03/FF1360 RTSA:0002X:0780Y:0000P:envMxdizc - Return to normal AI Procedure.
And that took a grand total of 23 bytes to accomplish.
(Note: Imps are not likely getting Wall, the rest seems fair enough)
I have to give the AI some real credit, by cracking into it at such an early juncture nothing from RandomAI's default spell setting has been loaded and so everything is loaded from this random choice of four options, so the AI won't do anything stupid like casting Cure on your party or using Slow on itself and it is completely non-intrusive. It has purposely been placed over an unused move and changing what moves you want the AI to randomly use is a simple matter of taking their Magic Evasion x4 and going from there so hackers that may normally be scared away by my more complicated hacks should find this one remarkably easy to work with.
So all of the hacking is now complete! Now it's just a matter of figuring out what randomized AI I want for 100 enemies.
Title: Re: Final Fantasy IV: Side Project (Random AI Routine complete!)
Post by: Grimoire LD on January 03, 2015, 07:53:36 PM
At least it looked like it worked to perfection in principle, but Chillyfeez your Level Up Mod also messes with Magical Evasion, which is 1/3 the basis of this hack (hence enemies use the wrong Random AI set). Is there anyway to disable the function that seems to alter Magical Evasion?
Title: Re: Final Fantasy IV: Side Project (Random AI Routine complete!)
Post by: chillyfeez on January 03, 2015, 08:38:37 PM
Yeah. That should be doable. Let's see... Did I post the disasembly for that mod...?
:edit: I did, but... Which stat are you talking about specifically? It looks like, in the commented disassembly, I talked about adjusting magic defense base and magic defense multiplier, but not magic defense percentage (which is what I thought you were talking about).
Title: Re: Final Fantasy IV: Side Project (Random AI Routine complete!)
Post by: Grimoire LD on January 03, 2015, 08:59:42 PM
Yeah. That should be doable. Let's see... Did I post the disasembly for that mod...?
:edit: I did, but... Which stat are you talking about specifically? It looks like, in the commented disassembly, I talked about adjusting magic defense base and magic defense multiplier, but not magic defense percentage (which is what I thought you were talking about).
Hmm... that is what I'm talking about. The percentage is what is being used, let me check something then...
Yes, I'm not sure why it happens, but the SwordRat's AI is supposed to be Magic Evasion 8% but that's only if its Level 6 against a Level 10 Party, at Level 7 its Magic Evasion goes down to 06 and askews the entire process.
:edit: ...Oh. I see the problem now. I feel a bit stupid, like Really stupid for not noticing this. I accidentally tied Magic Evasion base to 24 which is Magic Defense all around! instead of 34, and I tied Magic Defense to Right Hand Quantity, yikes!
Title: Re: Final Fantasy IV: Side Project (Random AI Routine complete!)
Post by: chillyfeez on January 03, 2015, 09:33:44 PM
So... I don't need to fix anything?
Title: Re: Final Fantasy IV: Side Project (Random AI Routine complete!)
Post by: Grimoire LD on January 03, 2015, 09:41:45 PM
No, no everything's working fine now. I'm still surprised at myself that I misread My Own Notes!!! And wrote Magical Defense into the AI Setup and the Magical Evasion as Magical Defense, how positively careless of me.
Title: Re: Final Fantasy IV: Side Project (Random AI Routine complete!)
Post by: LordGarmonde on January 03, 2015, 11:03:55 PM
No, no everything's working fine now. I'm still surprised at myself that I misread My Own Notes!!! And wrote Magical Defense into the AI Setup and the Magical Evasion as Magical Defense, how positively careless of me.
We all do that sometimes - especially me :wink: -- or should that be :blush:
Either way, I just wanted to say: Holy **** this is quite the hack! I was trying to sit down and finally learn Assembly but this looks like so much fun... :happy: -- Assembly is hard... :sad:
Title: Re: Final Fantasy IV: Side Project (Random AI Routine complete!)
Post by: Grimoire LD on January 03, 2015, 11:21:05 PM
No, no everything's working fine now. I'm still surprised at myself that I misread My Own Notes!!! And wrote Magical Defense into the AI Setup and the Magical Evasion as Magical Defense, how positively careless of me.
We all do that sometimes - especially me :wink: -- or should that be :blush:
Either way, I just wanted to say: Holy **** this is quite the hack! I was trying to sit down and finally learn Assembly but this looks like so much fun... :happy: -- Assembly is hard... :sad:
Thanks! It is actually very simple, much simpler than I anticipated and if I really wanted to I could add AI patterns for every monster by going into the ROM data, to go beyond 99 instead of using FF4kster to get by the 99% limit on Magical Evasion. It was just a matter where to plug the hack in. As it stands though this hack is probably one of the most nonintrusive I've ever made and after this is released I wouldn't mind creating a separate patch for this hack alone.
I'm not mathematically inclined, but I'm good at record keeping (as observed with my topic) and I use that constant memorization in place of mathematical skills in this case, but you are mathematically inclined, so SNES ASM should come pretty easily to someone that excels in logic.
ASM is a lot of fun though, it really makes you stop saying "Man I wish I could do That with FFIV..." and can make you say: "I'm Going to do That with FFIV!" Hence, Combat Boost on my side and Threat from Within (along with many other impressive hacks) from Chillyfeez's side. So it is well worth the time to pick up.
Title: Re: Final Fantasy IV: Side Project (Random AI Routine complete!)
Post by: chillyfeez on January 04, 2015, 12:30:40 AM
Yeah, LordGarmonde, you would probably pick up ASM pretty quickly, I'd think.
The thing is, SNES really is limited to so very few actual operations - all of my hacks put together probably only use about 17 different ops - acting on various registers and/or pieces of RAM.
The thing to remember is this: observable change happens when ROM affects RAM in a different way. So... 1) decide on something you want the game to do differently 2) figure out how RAM needs to be different than normal in order to make this happen (often the hardest part - I've spent days at a time on this step) 3) change the code that normally affects that portion of RAM so that it does what you want instead.
I know, I know I make it sound so simple, ya? That really is all there is to it, though. It helps to have an idea for a hack in mind. Start with something relatively small. And bookmark this page: http://wiki.superfamicom.org/snes/show/65816+Reference It's an alphabetical list of all 255 SNES opcodes (and "42," which apparently does nothing - fitting for an ultimate answer to which there is no question, but I digress), plus a bit of a tutorial on how to use them (but the list is the part you'll come back to over and over again).
I also learned quite a bit about ASM in action just by studying Grimoire's command disassembly.
Title: Re: Final Fantasy IV: Side Project (Random AI Routine complete!)
Post by: LordGarmonde on January 04, 2015, 01:34:30 AM
Thanks! It is actually very simple, much simpler than I anticipated and if I really wanted to I could add AI patterns for every monster by going into the ROM data, to go beyond 99 instead of using FF4kster to get by the 99% limit on Magical Evasion. It was just a matter where to plug the hack in. As it stands though this hack is probably one of the most nonintrusive I've ever made and after this is released I wouldn't mind creating a separate patch for this hack alone.
Agreed - I'd like to see that as well, but of course it's hard to play it safe with places to inject custom code without conflicts. I'm constantly amazed at everything you guys got not only to work but to work together!
I'm not mathematically inclined, but I'm good at record keeping (as observed with my topic) and I use that constant memorization in place of mathematical skills in this case, but you are mathematically inclined, so SNES ASM should come pretty easily to someone that excels in logic.
Thanks guys! :blush: I will say it's kind of a double-edged sword. Sometimes I'm a little too logical and having bashed out so many calculations in C over the years really spoiled me. I have to remember now that to multiply two numbers I need to transfer them to the appropriate registers (in the proper order) and then wait. I compare it to sticking two things in a microwave and waiting for the ding! :tongue:
ASM is a lot of fun though, it really makes you stop saying "Man I wish I could do That with FFIV..." and can make you say: "I'm Going to do That with FFIV!" Hence, Combat Boost on my side and Threat from Within (along with many other impressive hacks) from Chillyfeez's side. So it is well worth the time to pick up.
Yep - When someone asks me what makes this so much fun I just say: 1/2 the fun is figuring out how this game works -- 1/2 the fun fixing it and dreaming up new stuff, and then working it in -- and 1/2 the fun is playing around with all the other stuff that other people come up with that you'd never have thought of... that's why it's so much fun!
The thing is, SNES really is limited to so very few actual operations - all of my hacks put together probably only use about 17 different ops - acting on various registers and/or pieces of RAM.
The thing to remember is this: observable change happens when ROM affects RAM in a different way. So... 1) decide on something you want the game to do differently 2) figure out how RAM needs to be different than normal in order to make this happen (often the hardest part - I've spent days at a time on this step) 3) change the code that normally affects that portion of RAM so that it does what you want instead.
I know, I know I make it sound so simple, ya? That really is all there is to it, though. It helps to have an idea for a hack in mind. Start with something relatively small. And bookmark this page: http://wiki.superfamicom.org/snes/show/65816+Reference It's an alphabetical list of all 255 SNES opcodes (and "42," which apparently does nothing - fitting for an ultimate answer to which there is no question, but I digress), plus a bit of a tutorial on how to use them (but the list is the part you'll come back to over and over again).
Yeah - Backwards-ass RAM logic will get ya every time - and me at least twice :wink: I've also been surfing around looking for various resources - and I hadn't settled on an opcode list - l have now: bookmarked, chillyfeez approved
I also learned quite a bit about ASM in action just by studying Grimoire's command disassembly.
That's half of what makes me so eager to finally try and learn - that analysis is Amazing with a capital 'A' -- the other half, of course, is what can be done with it: so many great hacks! :childish:
Title: Re: Final Fantasy IV: Side Project (Random AI Routine complete!)
Post by: Spooniest on January 04, 2015, 05:14:35 AM
Uh, this concerns your Party Changing hack...
How do you handle the final scene? Do we just fade from Zeromus back to Cecil and start the Bridge Theme? Because that seems like a rather sharp edit to the story. Cecil doesn't die because of reasons? And the victory fanfare comes out of nowhere?
What did you do?
Title: Re: Final Fantasy IV: Side Project (Random AI Routine complete!)
Post by: chillyfeez on January 04, 2015, 07:31:42 AM
How do you handle the final scene? Do we just fade from Zeromus back to Cecil and start the Bridge Theme? Because that seems like a rather sharp edit to the story. Cecil doesn't die because of reasons? And the victory fanfare comes out of nowhere?
What did you do?
This is a concern I see a lot when people theorize about a hack like this. I don't see it as much of an issue to figure out. The battle sequence (in which the non present characters appear to heal the heroes) can easily be edited, to, say, only show the deceased characters. It's probably also entirely possible to alter which characters appear, though I haven't seen research on this yet (I'm sure we can figure that out if we put our minds to it). As for the "map view" portion of the ending events: simple alterations would suffice - make the rest of the party not appear at all is an easy solution. For more complicated fixes, I've had success hacking in variable NPCs, so that can be done, too, using event flags (of which there are over 100 unused) that are set differently based on which characters are in the party.
Title: Re: Final Fantasy IV: Side Project (Random AI Routine complete!)
Post by: avalanche on January 04, 2015, 11:46:36 AM
Thanks guys! :blush: I will say it's kind of a double-edged sword. Sometimes I'm a little too logical and having bashed out so many calculations in C over the years really spoiled me. I have to remember now that to multiply two numbers I need to transfer them to the appropriate registers (in the proper order) and then wait. I compare it to sticking two things in a microwave and waiting for the ding! :tongue:
If you've programmed in C, I think you're in great shape to learn assembly. In C you are really thinking about how array buffers work and pointer arithmetic and such, all very good foundations to go deeper into the figurative rabbit hole that is assembly. People who have only worked with C++ or Python (even though python is the best thing ever imo) might have a harder time thinking about registers and memory.
Bonus if you often use a ton of global variables in C, often a bad idea in programming, since that's all this game does. The hardest part about deciphering this assembly is not what the instructions are doing but what all the memory references are for without the variable names.
Just a heads up about that site is that while I was writing a disassembler for analyzing this game I noticed some errors on that wiki page. One that comes to mind is rather important I think: the description for the SBC instructions says "Subtracts operand from the Accumulator; subtracts an additional 1 if carry is set" which is backwards. It subtracts an extra 1 if the carry is CLEAR.
Just curious, does anyone know why they didn't use the stack for temporary variables?
Title: Re: Final Fantasy IV: Side Project (Random AI Routine complete!)
Post by: chillyfeez on January 04, 2015, 02:29:46 PM
Just curious, does anyone know why they didn't use the stack for temporary variables?
... Isn't that the primary purpose of pushing and pulling the registers and the accumulator?
Quote
the description for the SBC instructions says "Subtracts operand from the Accumulator; subtracts an additional 1 if carry is set" which is backwards. It subtracts an extra 1 if the carry is CLEAR.
Never noticed it said that. The opcode list is really what I was recommending there. In my experience, that part's accurate.
Title: Re: Final Fantasy IV: Side Project (Random AI Routine complete!)
Post by: avalanche on January 04, 2015, 06:08:36 PM
Just curious, does anyone know why they didn't use the stack for temporary variables?
... Isn't that the primary purpose of pushing and pulling the registers and the accumulator?
Absolutely, with PHA, PLA. But they only do that to save them momentarily, and all the other temporary storage is from some other memory. They use a lot of temporary global variables. Though granted it's hard to tell which of the global uses are truly temporaries. I was more referring to instructions with stack-relative addressing, like "AND $#04,S", so you wouldn't need the global memory, and would probably make our deciphering easier since we know a stack-relative address like that is certainly a local variable which is only used inside that very routine, rather than wondering how many other routines might modify it before we can tell what it might be. Same thing with memory used for parameters. There is limited stack space though, so that could be part of it. I also wonder if those instructions were not actually available on the SNES, but that's just speculation.
Title: Re: Final Fantasy IV: Side Project (Random AI Routine complete!)
Post by: chillyfeez on January 04, 2015, 06:43:48 PM
Well, it looks like the stack pointer can index parameters of an operation, but I don't really understand the practical use of that... But I don't have any programming experience, really, so that may just be my lack of experience.
Title: Re: Final Fantasy IV: Side Project (Random AI Routine complete!)
Post by: LordGarmonde on January 05, 2015, 05:08:00 PM
Well, it looks like the stack pointer can index parameters of an operation, but I don't really understand the practical use of that... But I don't have any programming experience, really, so that may just be my lack of experience.
:blits: I've got plenty of "experience" - but as I'm going along I'm realizing that most of the work I ended up doing on my own was in C++...back in the C days I had help ... bottom line I haven't worked in the stack either...other than on paper :wink:
Title: Re: Final Fantasy IV: Side Project (Random AI Routine complete!)
Post by: Grimoire LD on January 05, 2015, 09:22:18 PM
How do you handle the final scene? Do we just fade from Zeromus back to Cecil and start the Bridge Theme? Because that seems like a rather sharp edit to the story. Cecil doesn't die because of reasons? And the victory fanfare comes out of nowhere?
What did you do?
This is a concern I see a lot when people theorize about a hack like this. I don't see it as much of an issue to figure out. The battle sequence (in which the non present characters appear to heal the heroes) can easily be edited, to, say, only show the deceased characters. It's probably also entirely possible to alter which characters appear, though I haven't seen research on this yet (I'm sure we can figure that out if we put our minds to it). As for the "map view" portion of the ending events: simple alterations would suffice - make the rest of the party not appear at all is an easy solution. For more complicated fixes, I've had success hacking in variable NPCs, so that can be done, too, using event flags (of which there are over 100 unused) that are set differently based on which characters are in the party.
That's basically the answer I was looking for, thank you for the comment Spooniest but this patch is not meant to be a story patch by any means other than adding characters back, for your specific scenario since you can't have Golbez or FuSoYa in your party at this point even their little blurb would be enough to heal everyone back to full HP. It's more of an experiment really and so far the experiment is going well with some hiccups that I'll address.
It seems as if the Level-Up Patch is still affecting bosses and making the Mist Dragon into a fair joke, with nearly 4-6 turns for the party for every turn of the Mist Dragon the Mist Dragon goes down without even transforming.
There's no change I've made to my knowledge that could be causing that, do you have any thoughts on why that might be Chillyfeez?
:edit: I can show you what I mean a little...
The Relative Speed of the unaltered Mist Dragon is supposed to be 0A.
The Relative Speed of the LevelUp Mod Mist Dragon (though bosses shouldn't be effected?) is 19 which is 2 1/2x slower than the Mist Dragon is normally, and they are using the same Speed Index, 5.
Title: Re: Final Fantasy IV: Side Project (Random AI Routine complete!)
Post by: chillyfeez on January 05, 2015, 11:18:24 PM
No. Sorry, some stats affect all monsters, speed is among them. I can't recall specifically why I chose to do it that way, but I think part of it was to help level the playing field for monsters against major grinding... Which might have been silly. The good news is that I did keep accurate notes about that patch, so reworking it is entirely possible if it's making things difficult. But as with other monsters, you can also try adjusting down the starting level in FF4kster if he's coming out too slow.
Title: Re: Final Fantasy IV: Side Project (Random AI Routine complete!)
Post by: Grimoire LD on January 05, 2015, 11:33:30 PM
No. Sorry, some stats affect all monsters, speed is among them. I can't recall specifically why I chose to do it that way, but I think part of it was to help level the playing field for monsters against major grinding... Which might have been silly. The good news is that I did keep accurate notes about that patch, so reworking it is entirely possible if it's making things difficult. But as with other monsters, you can also try adjusting down the starting level in FF4kster if he's coming out too slow.
Indeed the clear reasoning why Speed would be affected is fully obvious, but I had thought that Bosses weren't supposed to be affected by the modding process? Was that a misunderstanding on my part?
Title: Re: Final Fantasy IV: Side Project (Random AI Routine complete!)
Post by: chillyfeez on January 06, 2015, 10:32:14 AM
No. Sorry, some stats affect all monsters, speed is among them. I can't recall specifically why I chose to do it that way, but I think part of it was to help level the playing field for monsters against major grinding... Which might have been silly. The good news is that I did keep accurate notes about that patch, so reworking it is entirely possible if it's making things difficult. But as with other monsters, you can also try adjusting down the starting level in FF4kster if he's coming out too slow.
Indeed the clear reasoning why Speed would be affected is fully obvious, but I had thought that Bosses weren't supposed to be affected by the modding process? Was that a misunderstanding on my part?
Well, yes. I left bosses largely unaffected so that they wouldn't be too easy or too hard during normal gameplay (read: not a speed-run and not overgrinding), but I also didn't want a situation where you go through a gauntlet of super powered regular foes only to fight a boss who dies in one round. I'm not quite sure how I decided which stats would increase for bosses, though. It looks like speed and defense (base and multiplier, physical and magical) are affected regardless of whether the enemy is a boss, according to what I posted here: http://slickproductions.org/forum/index.php?topic=1940.msg20858#msg20858 But the code also skips the stats it does by way of several branch Ops, so this can be adjusted easily, simply by changing some branch parameters.
Title: Re: Final Fantasy IV: Side Project (Random AI Routine complete!)
Post by: Grimoire LD on January 06, 2015, 11:13:19 AM
Ah, I see now. I should have read that better the first time around. Yes, that is probably the crux of the issue then. Maybe I want to decrease levels rather than increase them all-around now that I think about it, especially with a project like this since the ShadowMod splits experience into 13 by end-game as I recall correctly? This would better balance monsters; I flew to Agart and fought monsters around there at one point and the FlameDog surprisingly had 1 or so speed, 40-some HP, minimum attack, it was surprising but I see its purpose.
It's to balance it against a party's current level and that does leave open the possibility of throwing any variety of foes with very little worry that they would be too weak or too strong at a given point. Another idea for me would be to increase speed all around to assure that if it is being divided it's not made into nothing.
Title: Re: Final Fantasy IV: Side Project (Random AI Routine complete!)
Post by: chillyfeez on January 06, 2015, 03:35:33 PM
Haha funny you should mention increasing speed. In TfW, there is one monster (a tree type) that I wanted to be slow, but strong (you know, cuz it's a tree). Problem was, I didn't put a lower limit into this code, so whereas the tree started with something like 2 speed, when it was leveled down, its speed actually increased to something astronomically high. So that is definitely something to watch out for...
Title: Re: Final Fantasy IV: Side Project (Random AI Routine complete!)
Post by: Grimoire LD on January 06, 2015, 10:53:52 PM
Haha funny you should mention increasing speed. In TfW, there is one monster (a tree type) that I wanted to be slow, but strong (you know, cuz it's a tree). Problem was, I didn't put a lower limit into this code, so whereas the tree started with something like 2 speed, when it was leveled down, its speed actually increased to something astronomically high. So that is definitely something to watch out for...
Haha, yeah. I could see something like that causing problems, good thing you caught it though. On my side everything has been moving smoothly I have all of the Random AI set up until most of Mt. Hobbs.
For bosses I was thinking of generally leaving them alone, except I was considering replacing all of the Fiend's "Fight" commands with Random AI to mimic their counterparts from FFI so Milon for the first phase could use...
Sleep-Slow-Hold-Lit2 and Milon Z would use Fire2-Haste-Ice2,-Sleep Gas...
Now I can even set this so that the mode that the Fiends are currently in for the other three switch the Random AI by switching their Magic Evasion during battle, since it is used a grand total of twice in the game and never to any truly noticeable effect. (a new post incoming on my main topic by the way of the means to modify the AI commands that change stats. With free space and the right Jumps you can do a lot of things here.)
I think I also have a solution for the Exp. problem (at least at first, since you can only get a maximum of 65,500 Exp per battle) is to x13 all of the possible Exp. from foes and at the start of the game add and remove all party members to assure they are developing in the Shadow Party; this solves two problems, a need to massively balance the party for when someone drastically lower joins the group and make sure battles are still relevant, by default battles become less and less important due to the diminishing returns from battle.
Title: Re: Final Fantasy IV: Side Project (Random AI Routine complete!)
Post by: chillyfeez on January 07, 2015, 12:08:47 AM
That's a clever idea about experience, but you should try multiplying by 9 or 13/5 or 9/5, not 13.
The reason (again) is to curtail grinding abuse.
Let's use the hypothetical example of a battle that yields 100 exp...
In the original game, this would get divided by as much as 5 (depending upon the amount of living active party members), then the result would be distributed to all living members and the entire shadow. An enterprising grinder could, though, kill off four party members. Then the one living character and the entire shadow gets 100 each.
Now, let's look at what would happen in the shadow hack... With all members alive or in the shadow (that is, nobody dead or not yet activated), each character would be awarded 7 or 8 exp (100/13). Well, you wouldn't want to multiply by 13, because then everyone gets 100, and if there are four dead party members, then everyone gets 144.
If you multiply by 9 (900), then a full party gets 69 and 100 with four dead bodies.
9/5 (180) yields 13 and 20 respectively
13/5 (260) yields 20 and 28.
Or you could try some other "improper" fraction... 9/2 (450) yields 34-50 13/2 (650) yields 50-72
It depends on what you want the upper and lower limits to be, I guess, but you don't want your balancing attempt to give the player an unfair advantage.
Title: Re: Final Fantasy IV: Side Project (Random AI Routine complete!)
Post by: Grimoire LD on January 07, 2015, 06:39:24 AM
You present a persuasive argument. In all reality it's probably best to make the default Exp. a little lower, nothing too extreme (as it is by default) but enough to make battles feel like they are worth fighting. I may touch up the drops or drop rates, nothing insane like Combat Boost's drop tables though, that was several weeks of proper planning to make that work as intended, just little things here and there to make battle feel worth fighting. So x9 actually feels the most appropriate.
Title: Re: Final Fantasy IV: Side Project (Random AI Routine complete!)
Post by: Grimoire LD on January 07, 2015, 11:54:21 PM
I think I've noticed a slight oversight with your LevelUp Mod, Chillyfeez. I tried this plan and was met with some bizarre results, despite all characters being added and removed the mod still thinks that there's a Level 25 and Level 50 in the party and that's because removing a character only removes the very first byte' all of their other data is still kept intact. Your mod looks to see if a Level is present to determine whether to include them in APL, this seems a bit risky as it throws off the intended APL.
I see the danger on changing that 2002 as it is also used to store the Level if there is one present. Do you have any suggestions on this regard? I can foresee this causing several problems down the line.
Title: Re: Final Fantasy IV: Side Project (Random AI Routine complete!)
Post by: chillyfeez on January 08, 2015, 12:24:15 AM
Oooh, yeah.
That certainly is a problem. I'll probably have to rework the routine a bit to fix it. Now that you mention it, there's probably nothing in there that tells it to ignore dead party members either, which I think I would want to do.
Gimme a little time on this one, I'm not positive I'll have the time to fix it before I go away for the weekend, but it's high on the priority list - especially since this is an issue that would manifest in TfW, too.
Title: Re: Final Fantasy IV: Side Project (Random AI Routine complete!)
Post by: chillyfeez on January 11, 2015, 08:37:13 PM
Hey, Grimoire. So when I find the time over the next week, I'll be working on a fix for the level-up patch APL problem. While I'm doing that would be as good a time as ever to change which boss stats are affected... Any thoughts about that, since you were talking about it recently?
Title: Re: Final Fantasy IV: Side Project (Random AI Routine complete!)
Post by: Grimoire LD on January 13, 2015, 11:44:39 AM
Hmm, I'm wondering if the decreases/increases in Speed are far too drastic all around. HP and all of that seem reasonable, but speed is probably the most important stat a monster has, my thought is possibly to increase/decrease that by 25% rather than 50% when stats are adjusted.
As for bosses though, I do like the idea that they should balance, but I think they should Balance Up, I don't think they should be effected if their level is higher and the party runs into them. But if a higher level APL is to run into them their stats should be adjusted up as if they were a normal foe.
I like the idea of normal foes of having higher-lower adjusted stats though as it means that there can be a Much greater variety of foes unbound by levels and the like.
Title: Re: Final Fantasy IV: Side Project (Random AI Routine complete!)
Post by: chillyfeez on January 13, 2015, 03:25:59 PM
So: 1) reduce the degree to which speed is affected, and 2) have bosses adjust up but not down.
I like those ideas a lot. I think I'll even make those changes in my own hack. Thanks!
The rewrite will be pretty significant, but not particularly difficult - the relative level calculation will remain the same (except for the part about skipping empty slots), only the stats affected will have to change. So it'll take a while to fix, but should be worth it in the end.
:edit: Do you think this mod could benefit from a level-appropriate exp adjustment while I'm at it? It would have to be entirely separate coding from the stat adjustment, because stats are populated at the beginning of battle and exp is figured at the end. I can store the adjustment ratio in some unused stat record bytes, though - monsters have plenty of them. The purpose of something like that would be so that people don't exploit the mod against, say, Flamedogs around Eblan (probably many possibilities in the Underworld, too).
Title: Re: Final Fantasy IV: Side Project (Random AI Routine complete!)
Post by: Grimoire LD on January 13, 2015, 05:41:52 PM
So: 1) reduce the degree to which speed is affected, and 2) have bosses adjust up but not down.
I like those ideas a lot. I think I'll even make those changes in my own hack. Thanks!
The rewrite will be pretty significant, but not particularly difficult - the relative level calculation will remain the same (except for the part about skipping empty slots), only the stats affected will have to change. So it'll take a while to fix, but should be worth it in the end.
:edit: Do you think this mod could benefit from a level-appropriate exp adjustment while I'm at it? It would have to be entirely separate coding from the stat adjustment, because stats are populated at the beginning of battle and exp is figured at the end. I can store the adjustment ratio in some unused stat record bytes, though - monsters have plenty of them. The purpose of something like that would be so that people don't exploit the mod against, say, Flamedogs around Eblan (probably many possibilities in the Underworld, too).
I'm glad you like the idea! When it comes to FFIV I like to think I have a pretty good head for balancing the game out, but I do tend to skew towards the more challenging side; I am glad to hear this mod being revamped.
Oh yes. The Exp is a major issue with the mod as it stands. I noticed that though the FlameDog had only 48 HP at Level 1 they still yielded 1000's of Exp. I am glad that you reminded me of that. Without it, it's a hurdle to properly balance enemies in areas they originally weren't.
Title: Re: Final Fantasy IV: Side Project (Random AI Routine complete!)
Post by: chillyfeez on January 15, 2015, 12:00:20 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...
Title: Re: Final Fantasy IV: Side Project (Random AI Routine complete!)
Post by: Grimoire LD 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?
Title: Re: Final Fantasy IV: Side Project (Random AI Routine complete!)
Post by: chillyfeez 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:
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).
Title: Re: Final Fantasy IV: Side Project (Random AI Routine complete!)
Post by: Grimoire LD 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
Title: Re: Final Fantasy IV: Side Project (Random AI Routine complete!)
Post by: chillyfeez 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.
Title: Re: Final Fantasy IV: Side Project (Random AI Routine complete!)
Post by: Grimoire LD 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.
Title: Re: Final Fantasy IV: Side Project (Random AI Routine complete!)
Post by: Grimoire LD 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.
$01/9A81BD 00 00LDA $0000,x[$70:0000]A:0000X:0000Y:0000P:envmxdIZc - Load A from... 700000? (Maybe something dealing with save data temp storing?) $01/9A8429 3F 00AND #$003FA:8748X:0000Y:0000P:eNvmxdIzc - Get rid of variables. $01/9A87C9 01 00CMP #$0001A:0008X:0000Y:0000P:envmxdIzc - Is it the Dark Knight? $01/9A8AF0 0DBEQ $0D [$9A99]A:0008X:0000Y:0000P:envmxdIzC - If so, branch to end. ------------------------------------------------------------------------------------------------------------- $01/9A8CC9 0B 00CMP #$000BA:0008X:0000Y:0000P:envmxdIzC - Is it Paladin Cecil? $01/9A8FF0 08BEQ $08 [$9A99]A:0008X:0000Y:0000P:eNvmxdIzc - If so, branch to end. ---------------------------------------------------------------------------------------------------------------- $01/9A918A TXAA:0008X:0000Y:0000P:eNvmxdIzc - Transfer X to A $01/9A9218 CLCA:0000X:0000Y:0000P:envmxdIZc - Clear Carry Flag $01/9A9369 40 00ADC #$0040A:0000X:0000Y:0000P:envmxdIZc - Add 0040 (look at the next character) $01/9A96AA TAXA:0040X:0000Y:0000P:envmxdIzc - Transfer A to X. $01/9A9780 E8BRA $E8 [$9A81]A:0040X:0040Y:0000P: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.
Title: Re: Final Fantasy IV: Side Project (Random AI Routine complete!)
Post by: Grimoire LD 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!
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.