Author Topic: FF4A (E) Hacking Notes and Mod  (Read 11379 times)

Kea

  • Vargas
  • *
  • Posts: 94
    • View Profile
Re: FF4A (E) Hacking Notes and Mod
« Reply #45 on: August 07, 2015, 08:12:24 PM »
For my magic weapons, I piggybacked off of the pre-existing system used for the Lunar Ruins weapons; it casts the spell normally, using the wielder's Intellect or Spirit. I hadn't realized the same thing was possible in the SNES version though on reflection I can see how you could edit the battle code so that certain weapons replace their physical attack with a spell. My version only allows for spells after the physical attack as yet.

This patch is complete through to the end of the Fabul battles, yeah. If it was just the Mt. Hobs stuff that was new it would hardly be worth releasing!

I managed to make Dwarven Bread into a Protect-casting item, which turned out to require some minor edits to these routines:

Code: [Select]
$06C1FC: Item usability routine (Field)
-Check if Item ID is 0xE6 (Dwarven Bread) - if not in dungeon, usable
-Check if Item ID 0xE5 (Emergency Exit) - if in dungeon, usable
-Because of these hardcoded checks, these two items can be considered usable regardless of what their item data says, which can crash the game if you remove their field effects and attempt to use them
-If not one of those two, calls:
   $06CE7C: finds item's entry in Item Data
        -Checks item's general data to determine if it is usable in the field

$08C562:
Applying Protect and Shell buffs:
-If at least one hit was successful:
-If spell ID =/= 0x5 (Protect), increase MDF by 3; otherwise increase DEF by 5
« Last Edit: August 07, 2015, 08:25:21 PM by Kea »

Grimoire LD

  • FF4 Hacker
  • *
  • Posts: 1,684
    • View Profile
Re: FF4A (E) Hacking Notes and Mod
« Reply #46 on: August 07, 2015, 11:20:25 PM »
For my magic weapons, I piggybacked off of the pre-existing system used for the Lunar Ruins weapons; it casts the spell normally, using the wielder's Intellect or Spirit. I hadn't realized the same thing was possible in the SNES version though on reflection I can see how you could edit the battle code so that certain weapons replace their physical attack with a spell. My version only allows for spells after the physical attack as yet.

This patch is complete through to the end of the Fabul battles, yeah. If it was just the Mt. Hobs stuff that was new it would hardly be worth releasing!

I managed to make Dwarven Bread into a Protect-casting item, which turned out to require some minor edits to these routines:

Code: [Select]
$06C1FC: Item usability routine (Field)
-Check if Item ID is 0xE6 (Dwarven Bread) - if not in dungeon, usable
-Check if Item ID 0xE5 (Emergency Exit) - if in dungeon, usable
-Because of these hardcoded checks, these two items can be considered usable regardless of what their item data says, which can crash the game if you remove their field effects and attempt to use them
-If not one of those two, calls:
   $06CE7C: finds item's entry in Item Data
        -Checks item's general data to determine if it is usable in the field

$08C562:
Applying Protect and Shell buffs:
-If at least one hit was successful:
-If spell ID =/= 0x5 (Protect), increase MDF by 3; otherwise increase DEF by 5

A good use for an item called "Dwarven Bread" considering you'd expect it to make the eater more "hardy" so to speak, a good call.

As to Magic Weapons, that's how mine works as well. It does the normal attack, then 25% of the time it will use the weapon's assigned magic, drawn from the normal magic casting routine. I would like to include some Wisdom/Will set up though. I wrote it right into Fight's routine.

Good to have confirmation on the length of the patch, now back to it!

Rosa's now Level 15, so though I didn't get the Ghoul Ring, it seems a good time to move on.

Pyro, eh? Was not expecting that! Did deal some respectable damage.

Firaga?! Ouch! Well, everyone survived, but still... ouch.

Explode thankfully did not do too much damage. Now onto the mop-up...

Phew, and dealt with. The bombs were taken care of with Sleep, an Antarctic Wind and general attacks from thereon out.

And I am out of Mt. Hobbs, onto Fabul!

Ah, the Steel Quill is more easily obtainable Gatlinger's...

A Silk Robe from Fabul, that's a new item.

Yang has reached Level 14 where he gains another Attack Multiplier which seems like a good place to stop grinding.

Interesting new formations here, The Gatlingers work well rather than a... I think a Sahagin and the two Bombs with the next squadron of soldiers was a nice touch.

Grr... TOSE... there used to be some special code that prevented Edward from Hiding during the Fabul fights... looks like TOSE never caught that or something.

Oh, the Captains stay and fight? Good to know.

Wow, a Treant?! That is actually notable. They are not easy foes for this point. Thankfully they have a crippling weakness to Fire.

And killed by the Treant because I wasn't expecting a Stop counter which just happened to hit Yang... back to the start of this then.

Wow, barely survived. Because of TOSE Edward went hiding and pretty much got Yang killed, during the Bombs and Soldiers battle. I used an item and tried to persevere through it, Cecil was down to 200 HP or so, but the battle was won. The Treant fight started and I immediately brought Edward back from Hiding where the Treant killed him, Cecil used a Bomb Fragment, then he hit Cecil and Cecil was down to 77 HP. After that I hit him one more time and he fell. I knew the next fight would not be easy, well it was 6 Domovoi but Cecil outsped them all and used the Zeus' Rage the next fight was terrifying to look at, but after an Hourglass, Hi-Potion, and Antarctic Wind, I used Dark Wave, and finished off the Captain and General in piecemeal. Cecil managed to win three battles all on his own purely through the use of items. Phew, that was intense!

And with that the first part of the game is over.

Cecil 20, Rosa 17, Yang 14, Edward 18, Rydia 19

Next will be Mysidia and Mt. Ordeals.

Kea

  • Vargas
  • *
  • Posts: 94
    • View Profile
Re: FF4A (E) Hacking Notes and Mod
« Reply #47 on: August 08, 2015, 03:40:35 PM »
I hope you liked the siege! I wanted to make the battles more closely match the story, ie being pushed back and overwhelmed by an unstoppable army. Each encounter is supposed to be tougher than the last, except for the 6x Domovois which is a breather before the last fight. About the Treant battle, it was hard to come up with an enemy that was "out of your depth" yet still beatable, and vaguely humanoid. For the next time, they're vulnerable to Confusion which makes them petrify themselves. Once I implement the fixed Agility system, I'll be able to more freely include out-of-depth monsters without having them wipe the party before you get a turn.

I think I can make Edward's Auto-Hide disable during battles that can't be run from; will have to look into it.

Bomb Fragments et al used to have 3 power; now they have 6. That might be a bit too much, so I'll reduce them to 5. Hourglasses will be getting a nerf too; originally they lasted 50/100/200 ATB units, which is an absolutely ridiculous length for something that targets all enemies (Stop only lasts 10 ATB units for comparison). Something like 5/15/50 for Hourglass/Silver Hourglass/Gold Hourglass would be good, I think.

I think I'll wait to release the next version of the mod until it's up to Cagnazzo, or maybe the Magnetic Cave + Eblan castle.

Grimoire LD

  • FF4 Hacker
  • *
  • Posts: 1,684
    • View Profile
Re: FF4A (E) Hacking Notes and Mod
« Reply #48 on: August 08, 2015, 07:06:04 PM »
I wouldn't say the power of the Battle Items need lowered, all things considered they only dealt 200 or so damage to all enemies and once you have a dedicated mage those numbers are par for the course, not to mention that's roughly how much a normal hit does and these are rarish items, it should be something the player feels could save them in a time of crisis instead of rolling their eyes at another useless battle item (see: original FFIV)

Kea

  • Vargas
  • *
  • Posts: 94
    • View Profile
Re: FF4A (E) Hacking Notes and Mod
« Reply #49 on: August 08, 2015, 10:09:20 PM »
Hm, you may be right. I suppose it's better to have them be a little too strong than the other way around, they are consumables after all. I'm still sticking to the Hourglass numbers though.

So as you've seen with the Magic Beast type, I'm rearranging the monster families in this game. Anybody who's played FF4 probably knows that monster types are very unevenly distributed (cf Mythril equipment defending against a nearly nonexistent Spirit family). Here's the specific changes being made:

Mech -> Construct
Basically this is to include Golems and any artificial enemies in this family. There will also be some new Mech-type enemies in Zot for Cid to smack around.

Reptile -> Magic Beast
Reptiles are actually fairly common throughout the game, but hardly anything actually interacts with them, and it overlaps with Ice weakness a little. Most animal-type monsters except birds, fish and insects will go into this one, making it fairly common up until the Lunar Subterrane.

Mage -> Humanoid
Again, expanding this family to include human and human-like enemies such as Arachnes, Giants and Ogres. This family becomes almost ubiquitous now, almost every dungeon past Mt. Ordeals has at least one.

Giant -> Flying
Giants, along with Flans, were a very small family, so I chose this one to cut and replace with the Flying family to free up the Wind element. Just about everything with wings is part of this family, though it becomes somewhat less common as you go on. Creatures in this family were shifted to the Humanoid or Construct families, whichever made sense.

The Spirit family will be seeing some new and some not-so-new members too. Overall there should be a greater variety of monsters running around throughout the game, and more specialized weapons designed to take them on.

Grimoire LD

  • FF4 Hacker
  • *
  • Posts: 1,684
    • View Profile
Re: FF4A (E) Hacking Notes and Mod
« Reply #50 on: August 09, 2015, 12:53:27 AM »
I love the sound of that new plan for races! Also don't worry about the Hourglasses, yes they Need nerfed. A freeze of 50 ATB is Ridiculous!! That's 5 Meteo spells! Combat Boost has only one HourGlass Item the rest... well I still haven't completely decided on what I want with the other two item slots.

In FF4A I imagine you have much more than FF monster slots, with all of the new monsters running about the Lunar Ruins?

Kea

  • Vargas
  • *
  • Posts: 94
    • View Profile
Re: FF4A (E) Hacking Notes and Mod
« Reply #51 on: August 09, 2015, 11:32:42 AM »
In FF4A I imagine you have much more than FF monster slots, with all of the new monsters running about the Lunar Ruins?

Indeed, with 286 monsters in the game, monster IDs are a halfword. Expanding the number of monsters is a little tricky; you'd have to replace the base text index used by monster names, rewrite the AI loading code (and that's another thing, the pointer table for AI routines is also used for events so it's not so easy to expand), and possibly restructure the Bestiary data if you want them to show up as regular monsters there.

Then there's monster sprite definitions; the first 286 entries correspond to the default sprites of all monsters, but the next 76 entries are used for alternate forms of monsters (eg Octomammoth losing tentacles, Odin raising his sword...). So if you wanted to add new monsters, it would be better to skip 76 monster IDs and start at monster No. 363.

Grimoire LD

  • FF4 Hacker
  • *
  • Posts: 1,684
    • View Profile
Re: FF4A (E) Hacking Notes and Mod
« Reply #52 on: August 09, 2015, 12:09:48 PM »
In FF4A I imagine you have much more than FF monster slots, with all of the new monsters running about the Lunar Ruins?

Indeed, with 286 monsters in the game, monster IDs are a halfword. Expanding the number of monsters is a little tricky; you'd have to replace the base text index used by monster names, rewrite the AI loading code (and that's another thing, the pointer table for AI routines is also used for events so it's not so easy to expand), and possibly restructure the Bestiary data if you want them to show up as regular monsters there.

Then there's monster sprite definitions; the first 286 entries correspond to the default sprites of all monsters, but the next 76 entries are used for alternate forms of monsters (eg Octomammoth losing tentacles, Odin raising his sword...). So if you wanted to add new monsters, it would be better to skip 76 monster IDs and start at monster No. 363.

Oh... oh wow that sounds needlessly complicated and how did they tie the AI routines into proper events? That just... sounds so bizarre, and they turned the "change form" monsters into full monster entries? That just seems pointless... hah. Ah well, just like FFIV then you still have all of those programmers to axe for new monsters.

Kea

  • Vargas
  • *
  • Posts: 94
    • View Profile
Re: FF4A (E) Hacking Notes and Mod
« Reply #53 on: August 09, 2015, 12:14:44 PM »
The changed forms aren't new monsters in the sense that they have their own complete data; it's just that they take up spots in the sprite table.

Here's the struct itself:
Code: [Select]
0x0C bytes per entry:
$00-01: Sprite ID; what graphics/palette to load
$02: Attack Shading:
00 - Normal (black/outlines)
01 - Entire sprite
FF - None? (character enemies)
$03: Number of sprite tiles to read horizonatally?
$04: Number of sprite tiles to read vertically?
$05: Sprite's drawn width
$06: Sprite's drawn height (bad numbers causes sprite to be cut off/broken up etc)
$05-06 are only different from 03-04 in Dr. Lugae's case, where he changes sprites at start of battle
(not that it actually makes a difference?)
$07: Unused?
$08-0B: Pointer to data in 0x0801C--- region, or 00
Used for most Lunar esper alt. forms - special tile/palette arrangement
Allows each tile to have its own palette?
If you look at the sprites for the Lunar espers and Zeromus EG, they have more colors than other monsters; that's thanks to the $08 pointer.

This is what the end of the sprite list looks like:
Code: [Select]
Soldier Monk
Super Monk
Drillmaster
Melt Bomb
Goblin (Super)
Palace Guard
Dark Kain
Bandit
Specter
Dummy (Goblin)
Dummy (Goblin)
Dummy (Goblin)
Dark Bahamut (Mega Flaring) 2
Lunar Leviathan (turned away)
Mist Dragon (mist)
Cagnazzo (hiding)
Cagnazzo (Torrents)
Barbariccia (Wind shield)
King of Eblan (sane)
Queen of Eblan (sane)
Rubicante
Odin (Sword up)
Odin (Charging)
Leviathan (forward)
Bahamut (Mega Flaring)
Demon Wall (2)
Asura (2)
Asura (3)
(Tiny snake thing?)
Titan (Quaking)
Egg (Hatching)
Chocobo 1
Chocobo 2
Shiva 1
Shiva 2
Ifrit 1
Ifrit 2
Ramuh 1
Ramuh 2
Sylph 1
Octomammoth 2
Octomammoth 3
Octomammoth 4
Octomammoth 5
Octomammoth 6
Octomammoth 7
Octomammoth 8
(Pig)
(Toad)
(Midget)
Momb Bomb (Exploding)
Mist Dragon (Summon?)
Dr. Lugae (Transformed)
Demon Wall (Front only - 1)
Demon Wall (Front only - 2)
Demon Wall (Front only - 3)
Demon Wall (Front only - 4)
Demon Wall (Front only - 5)
Demon Wall (Front only - 6)
Demon Wall (Front only - 7)
Demon Wall (Front only - 8)
Demon Wall (Front only - 9)
Demon Wall (Front only - max)
Sylph 2
Sylph 3
Lunar Bahamut (Mega Flaring)
Lunar Leviathan (backward)
Lunar Odin
Lunar Odin (charging)
Lunar Asura 2
Lunar Asura 3
Lunar Titan (Quaking)
Lunar Dragon (Mist)
Lunar Ifrit (Flaming)
Lunar Ramuh
Lunar Ramuh (Zapping)
Lunar Shiva
Ifrit (Boss2)
Shiva (Boss2)
Titan (Boss2)
Ramuh (Boss2)
Super Monk (2)
Super Monk (3)
Soldier Monk (2)
Soldier Monk (3)
Drillmaster (2)
Drillmaster (3)
Dark Bahamut

The worst part? Monsters that start in one form, move to another, then change back to their previous form use three different sprite entries: Lunar Odin uses different sprite entries for before raising his sword and after lowering it, and Dark Bahamut does the same for his Mega Flaring. It's crazy.
« Last Edit: August 09, 2015, 12:21:27 PM by Kea »

Kea

  • Vargas
  • *
  • Posts: 94
    • View Profile
Re: FF4A (E) Hacking Notes and Mod
« Reply #54 on: August 11, 2015, 10:56:03 PM »
One small thing while I work on Mt. Ordeals....

The routine at $09C304 handles charge times for all abilities, based on a byte table at $0F94E4:
Code: [Select]
$0F94E4 - One byte per command; 0x21 bytes in total
-Bottom nibble is base charge time
-Top half is bitfield:
00 - Use (ATB time)/(base charge timel), modified by Agility divisor
10 - Use base*(ATB time)
20 - Use base charge time
40 - Use spell's charge time (Magic, Summon, Ninjutsu etc)

Of all abilities, the second part of Twincast has 0x14 as its value, the only command that has bit 0x10 set. Its unique formula to determine its charge time looks like this:
Code: [Select]
Charge time = min((500 / (Agility*10),1) * 4 At the point when you first recruit Palom and Porom, Twincast will have a charge time of about 20-28 units. That's over twice the charge time of Meteor, applied to both twins! :scared: Twincast will have a not completely insane charge time (of 8 units - almost as much as Meteor) when you get the twins back at the endgame, but by then Comet and Pyro are laughably weak.

This formula is used for both twins involved, so whichever one has more Agility is the one that will cast the spell (so, Porom usually).

My mod will likely make Twincast have a fixed charge time, so you might consider using it sometime.

Kea

  • Vargas
  • *
  • Posts: 94
    • View Profile
Re: FF4A (E) Hacking Notes and Mod
« Reply #55 on: September 01, 2015, 10:18:27 PM »
It's been a while, but I'm not quite dead yet. I went on vacation and isolated myself from computers for a while, and after I finished up the Scarmiglione battles took a break from this game to avoid getting burned out.

I should have the mod up to Cagnazzo or the Dark Elf finished in a week or so.

Kea

  • Vargas
  • *
  • Posts: 94
    • View Profile
Re: FF4A (E) Hacking Notes and Mod
« Reply #56 on: November 05, 2015, 04:40:31 PM »
Well that took quite a lot longer than a week.  :blush:

But I've finally finished up to Cagnazzo, who has the most complicated AI script of any enemy so far - 352 bytes in all. I had a lot of fun designing his and Scarmiglione's fights, so I hope you have just as much fun battling them! :finger:

In engine news, I've implemented a system for equipment to run custom ASM routines at the start of battle; this allows for equipment that sets status effects like Reflect, Haste or Image, or makes the wearer Undead, and things like that. I haven't figured out how to make permanent status effects for a 'true' Reflect Ring, but it's getting there.

Regardless, here is the patch. Complete up to beating Cagnazzo and looting Baron Castle. My next task...is to play Threat From Within, because it's looking really cool from what I'm reading.

Grimoire LD

  • FF4 Hacker
  • *
  • Posts: 1,684
    • View Profile
Re: FF4A (E) Hacking Notes and Mod
« Reply #57 on: November 05, 2015, 09:08:18 PM »
Well that took quite a lot longer than a week.  :blush:

But I've finally finished up to Cagnazzo, who has the most complicated AI script of any enemy so far - 352 bytes in all. I had a lot of fun designing his and Scarmiglione's fights, so I hope you have just as much fun battling them! :finger:

In engine news, I've implemented a system for equipment to run custom ASM routines at the start of battle; this allows for equipment that sets status effects like Reflect, Haste or Image, or makes the wearer Undead, and things like that. I haven't figured out how to make permanent status effects for a 'true' Reflect Ring, but it's getting there.

Regardless, here is the patch. Complete up to beating Cagnazzo and looting Baron Castle. My next task...is to play Threat From Within, because it's looking really cool from what I'm reading.

This weekend seems pretty open for me, I'll get back to this at that time. I'm always glad to see an update!

Grimoire LD

  • FF4 Hacker
  • *
  • Posts: 1,684
    • View Profile
Re: FF4A (E) Hacking Notes and Mod
« Reply #58 on: November 06, 2015, 06:48:26 PM »
That's some impressive ASM to give equipment custom ASM routines! I doubt there's enough room in the original FFIV for something that expansive. Unless we're referring to a rather small subset (see Avenger)

Oh right, should I restart my file? Or am I safe to continue on from Fabul?

Kea

  • Vargas
  • *
  • Posts: 94
    • View Profile
Re: FF4A (E) Hacking Notes and Mod
« Reply #59 on: November 06, 2015, 07:19:45 PM »
You should be good to go from Fabul; there shouldn't be anything that breaks.

And thank you. The way the custom equipment ASM works is that after setting elemental and racial attributes from equipment, my new code runs through ever piece of equipment and checks for a (formerly unused) index byte in that item's item data, then uses that byte to index to a pointer table to ASM routines; so any item with an index byte of 1 will run he same code.