Author Topic: Grimoire LD's Notes, Patches, and Hacks (Dark Knight/Paladin Swap In Battle!)  (Read 78631 times)

chillyfeez

  • FF4 Hacker
  • *
  • Posts: 1,285
  • Gender: Male
  • Go ahead, ask me about Angel Feathers!
    • View Profile
Re: Grimoire LD's Notes, Methods, and Hacks (All Spells & Commands Disassembly)
« Reply #105 on: October 09, 2013, 04:03:43 PM »
Nice! I only count eleven bytes, btw (even better).
When you say Peep was 94 bytes... is that hex or base 10?

Also... Has there been previous significant speculation that "crash" was originally planned to be a now-abandoned "airship" command?
The big problem with this would be the AV - are you thinking of just stealing the animation from, say, Fire3 (easy enough, but not particularly interesting)? I guess it's possible to use the actual airship's sprites for something, but I'm certainly not adequately skilled to write new animation for such a project.

I've actually been cooking up an idea for a custom Mime command. 84 bytes may well be enough to do it.

Grimoire LD

  • FF4 Hacker
  • *
  • Posts: 1,684
    • View Profile
Re: Grimoire LD's Notes, Methods, and Hacks (All Spells & Commands Disassembly)
« Reply #106 on: October 09, 2013, 04:26:07 PM »
Did I really miscount?

Haha! I can discern coding but can't count to 11.

The discussion on Crash is somewhere on the boards, but I can't recall off the top of my head. But yes it's in just decimal, not hex.

I don't expect the command was anything flashier than a spell effect, in all honesty, if they even got that far with it. The idea that it is called "Airship" comes from the Japanese FFIV, where it is called... well Airship. It may have been intended to be used whenever Cid rejoined the group for the Giant of Bab-il section.

A Mime command, eh? That does sound intriguing. 84 bytes could possibly be enough. We know the game must store that data somewhere because the Avenger Sword works like an uncontrollable FFV Mime in many respects.

Also here's a little something to make Pray use one of two spells. Just replace this...

$03/E859   20 A6 85   JSR $85A6  [$03:85A6]   A:00EA   X:00CE   Y:0000   P:envMxdizC - Jump to Subroutine (??)
$03/E85C   A9 10   LDA #$10   A:0003   X:00CE   Y:0000   P:envMxdizC - Load 10 into A (D) (Failed Prayer)
$03/E85E   8D CA 34   STA $34CA  [$7E:34CA]   A:0010   X:00CE   Y:0000   P:envMxdizC - Store A in Battle Message Data.
$03/E861   80 08   BRA $08    [$E86B]   A:0010   X:00CE   Y:0000   P:envMxdizC - Branch Always to 03E86B

With This...


$03/E855   C9 80   CMP #$80   A:00DA   X:0049   Y:0000   P:eNvMxdizC
$03/E857   90 0A   BCC $0A    [$E863]   A:00DA   X:0049   Y:0000   P:envMxdizC
$03/E859   A9 0F   LDA #$0F   A:00DA   X:0049   Y:0000   P:envMxdizC
$03/E85B   8D D2 26   STA $26D2  [$7E:26D2]   A:000F   X:0049   Y:0000   P:envMxdizC
$03/E85E   20 3E CD   JSR $CD3E  [$03:CD3E]   A:000F   X:0049   Y:0000   P:envMxdizC


A very simple process, indeed.

Deathlike2

  • Moderator
  • *
  • Posts: 3,538
  • I'm looking at you, bitch!
    • View Profile
Re: Grimoire LD's Notes, Methods, and Hacks (All Spells Disassembly)
« Reply #107 on: October 09, 2013, 10:53:07 PM »
That said, I'm not sure how the Slumber Blade worked previously... it is the only Weapon Spell Effect that did not seem 100%, but clearly the Ignore Accuracy byte was enabled normally. I think the team must not have been aware of this byte, as the Weapon Spells clearly were not meant to be 100% seeing as they have Accuracy that are in all different amounts.


AFAIK, the Slumber Sword's spell worked through Agility, through my testing.

I could be wrong, but that's how I remember it to be.

Also, am I reading this correctly?

Twin's #s are listed as such:
1/4 (64/256) chance to Comet, 1/256 chance to fail, and 195/256 chance for Burst (mini-Flare).

Now, if I could only get numbers for Double Meteor in the GBA port.
« Last Edit: October 09, 2013, 11:16:57 PM by Deathlike2 »
Working on the next Yet To Be Named FF4 "Hardtype" Hack Download Latest: v1.48

Video Demos: #1 #2 #3

Grimoire LD

  • FF4 Hacker
  • *
  • Posts: 1,684
    • View Profile
Re: Grimoire LD's Notes, Methods, and Hacks (All Spells & Commands Disassembly)
« Reply #108 on: October 10, 2013, 12:06:47 AM »
Hmm, Agility would have been an ideal use for Weapon Magic... but I could find no reference, maybe I wasn't looking in the right place, and I would find it strange that the Slumber Blade would be the odd weapon out.

Indeed, that's exactly how Twin works, which is why it is a very simple matter to include a third spell at a reasonable chance of occurrence rather than just "failed." which barely any player will ever see.

I thought Double Meteor was a near guarantee in FFIV:A when you had the Twin Stars? I guess I'm recalling incorrectly then. Possibly it just takes Comet's probability, and uses Comet's original slot (quite a simple "Is Character equipped with Twin Stars...  Will Comet Occur? Then BEQ to Double Meteor" Then again, I can't recall Double Meteor too well in FFIV:A.

Deathlike2

  • Moderator
  • *
  • Posts: 3,538
  • I'm looking at you, bitch!
    • View Profile
Re: Grimoire LD's Notes, Methods, and Hacks (All Spells & Commands Disassembly)
« Reply #109 on: October 10, 2013, 11:51:58 AM »
I thought Double Meteor was a near guarantee in FFIV:A when you had the Twin Stars? I guess I'm recalling incorrectly then. Possibly it just takes Comet's probability, and uses Comet's original slot (quite a simple "Is Character equipped with Twin Stars...  Will Comet Occur? Then BEQ to Double Meteor" Then again, I can't recall Double Meteor too well in FFIV:A.

Double Meteor is almost guaranteed, but it's closer to 50-66, or even 75%. However, Comet and Burst still occur at a far lower rate and the chance to fail (1/256) is probably still there.
Working on the next Yet To Be Named FF4 "Hardtype" Hack Download Latest: v1.48

Video Demos: #1 #2 #3

Grimoire LD

  • FF4 Hacker
  • *
  • Posts: 1,684
    • View Profile
Re: Grimoire LD's Notes, Methods, and Hacks (All Spells & Commands Disassembly)
« Reply #110 on: October 10, 2013, 07:25:04 PM »
Hmm, that actually implies that there's a separate check before Comet/Mini-Flare that checks for Twin Stars, then goes to Double Meteor, runs it through an RNG, and moves on if it fails, to the normal choices.

Because this idea has been brewing in my mind for quite some time I decided to make Salve a versatile command. Meaning that it will no longer Require any One item, but will be able to read from all usable items. There is code that reads from the Start of Battle Items to the End of Battle Items, meaning that whichever applicable item you have first in your inventory will be the item that is used... This can be anything (except maybe the Drain and Osmose Spell Items) and it should work perfectly fine. If targeting is your issue you can set the targeting of Salve to F0 so you can freely target all enemies or allies. If your concerned about the already unused Elemental Items you can make the ones that hit all foes hit only one enemy for significant damage if you don't use multi-targeting (Balance isn't so much my concern in this regard, but to one more balance-oriented may want to change DD to Cure 3 at D0. And if someone still want it to be Purely for allies and to use only the Potions, you can use CE to D1 as the checks to make.

All that was removed was a set of instructions that didn't seem to do anything and in my testing I never saw a problem with these.

If you have any thoughts or suggestions on how to improve this, please let me know. I plan on touching up the majority of the commands in time to make them more useful or give them a varied purpose.

Failed Attempt - Used Item above DD
Code: [Select]
$03/E2E4 BD 1B 32 LDA $321B,x[$7E:321B] A:0000 X:0000 Y:0000 P:envMxdiZc - Load A from 7E321B+x (Start of Items)
$03/E2E7 C9 B0 CMP #$B0 A:0007 X:0000 Y:0000 P:envMxdizc - Is it a Battle Item or above? (It's not in this run around)
$03/E2E9 B0 14 BCS $14    [$E2FF] A:0007 X:0000 Y:0000 P:envMxdizc - If so, branch to 03E2FF.
-----------------------------------------------------------------------------------------------------------------------------------------------
$03/E2EB C8 INY A:0007 X:0000 Y:0000 P:envMxdizc +1 to Y
$03/E2EC E8 INX A:0007 X:0000 Y:0001 P:envMxdizc +1 to X
$03/E2ED E8 INX A:0007 X:0001 Y:0001 P:envMxdizc +1 to X
$03/E2EE E8 INX A:0007 X:0002 Y:0001 P:envMxdizc +1 to X
$03/E2EF E8 INX A:0007 X:0003 Y:0001 P:envMxdizc +1 to X
$03/E2F0 E0 C0 00 CPX #$00C0 A:0007 X:0004 Y:0001 P:envMxdizc - Has it checked all items?
$03/E2F3 D0 EF BNE $EF    [$E2E4] A:0007 X:0004 Y:0001 P:eNvMxdizc - If not loop back to 03E2E4.

###################################################################
$03/E2E4 BD 1B 32 LDA $321B,x[$7E:321F] A:0007 X:0004 Y:0001 P:eNvMxdizc - Load Item Slot 2 into A.
$03/E2E7 C9 B0 CMP #$B0 A:00E9 X:0004 Y:0001 P:eNvMxdizc - Is it a Battle Item or above?
$03/E2E9 B0 14 BCS $14    [$E2FF] A:00E9 X:0004 Y:0001 P:envMxdizC - If so, branch to 03E2FF.
----------------------------------------------------------------------------------------------------

----------------------------------------------------------------------------------------------
$03/E2FF 85 FE STA $FE    [$00:00FE] A:00E9 X:0004 Y:0001 P:envMxdizC - Store Item Slot in FE.
$03/E301 C9 DD CMP #$DD A:00E9 X:0004 Y:0001 P:envMxdizC - Is it above the Final Battle Item?
$03/E303 B0 36 BCS $36    [$E33B] A:00E9 X:0004 Y:0001 P:envMxdizC - If so, branch to 03E33B
----------------------------------------------------------------------------------------------------------------------
$03/E33B CD A5 FE CMP $FEA5  [$7E:FEA5] A:00E9 X:0004 Y:0001 P:envMxdizC - Non applicable, only used for closing out of routine from hereon...
$03/E33E 8D C5 33 STA $33C5  [$7E:33C5] A:00E9 X:0004 Y:0001 P:eNvMxdizC
$03/E341 A9 0A LDA #$0A A:00E9 X:0004 Y:0001 P:eNvMxdizC
$03/E343 8D C8 34 STA $34C8  [$7E:34C8] A:000A X:0004 Y:0001 P:envMxdizC
$03/E346 A9 10 LDA #$10 A:000A X:0004 Y:0001 P:envMxdizC
$03/E348 8D C7 34 STA $34C7  [$7E:34C7] A:0010 X:0004 Y:0001 P:envMxdizC
$03/E34B 60 RTS A:0010 X:0004 Y:0001 P:envMxdizC - Return
#######################################################################

Successful Attempt - Couerl Whisker (Fatal)

Code: [Select]
$03/E2E4 BD 1B 32 LDA $321B,x[$7E:321F] A:0007 X:0004 Y:0001 P:eNvMxdizc - Load A from Item Slot +X
$03/E2E7 C9 B0 CMP #$B0 A:00C9 X:0004 Y:0001 P:eNvMxdizc - Is it a Battle Item?
$03/E2E9 B0 14 BCS $14    [$E2FF] A:00C9 X:0004 Y:0001 P:envMxdizC - If so, branch to 03E2FF.
-------------------------------------------------

------------------------------------------
$03/E2FF 85 FE STA $FE    [$00:00FE] A:00C9 X:0004 Y:0001 P:envMxdizC - Store A in FE
$03/E301 C9 DD CMP #$DD A:00C9 X:0004 Y:0001 P:envMxdizC - Is it Above the Final Battle Item?
$03/E303 B0 36 BCS $36    [$E33B] A:00C9 X:0004 Y:0001 P:eNvMxdizc - If so branch to 03E33B
$03/E305 EA NOP A:00C9 X:0004 Y:0001 P:eNvMxdizc - Null
$03/E306 EA NOP A:00C9 X:0004 Y:0001 P:eNvMxdizc - Null
$03/E307 BD 1C 32 LDA $321C,x[$7E:3220] A:00C9 X:0004 Y:0001 P:eNvMxdizc - Load Item Quantity into A
$03/E30A C9 01 CMP #$01 A:000A X:0004 Y:0001 P:envMxdizc - Is it 01 or below?
$03/E30C 90 E7 BCC $E7    [$E2F5] A:000A X:0004 Y:0001 P:envMxdizC - If so branch to 03E2F5.
$03/E30E 38 SEC A:000A X:0004 Y:0001 P:envMxdizC - Set Carry Flag.
$03/E30F BD 1C 32 LDA $321C,x[$7E:3220] A:000A X:0004 Y:0001 P:envMxdizC - Load Item Quantity into A.
$03/E312 E9 01 SBC #$01 A:000A X:0004 Y:0001 P:envMxdizC - -1 to A
$03/E314 9D 1C 32 STA $321C,x[$7E:3220] A:0009 X:0004 Y:0001 P:envMxdizC - Store A in Item Quantity
$03/E317 D0 0B BNE $0B    [$E324] A:0009 X:0004 Y:0001 P:envMxdizC - Branch if not 00 to 03E324.
------------------------------------------------------------------

-----------------------------------------------------------------
$03/E324 98 TYA A:0009 X:0004 Y:0001 P:envMxdizC - Transfer Y to A.
$03/E325 85 01 STA $01    [$00:0001] A:0001 X:0004 Y:0001 P:envMxdizC - Store 01 into A.
$03/E327 A9 06 LDA #$06 A:0001 X:0004 Y:0001 P:envMxdizC - Load 06 into A
$03/E329 20 85 80 JSR $8085  [$03:8085] A:0006 X:0004 Y:0001 P:envMxdizC - Jump to Subroutine (A lot of jumping, a lot of things that don't make much sense to me)
$03/E32C A9 F8 LDA #$F8 A:0000 X:7510 Y:0018 P:envMxdiZc - Load A from F8 (Targeting matters)
$03/E32E 8D D4 26 STA $26D4  [$7E:26D4] A:00F8 X:7510 Y:0018 P:eNvMxdizc - Store A in 7E26D4 (Targeting)
$03/E331 A5 FE LDA $FE    [$00:00FE] A:00F8 X:7510 Y:0018 P:eNvMxdizc - Load Item placed in FE. (Fatal)
$03/E333 8D D2 26 STA $26D2  [$7E:26D2] A:00C9 X:7510 Y:0018 P:eNvMxdizc - Store Fatal in Next Action to Take.
$03/E336 EE 2A 35 INC $352A  [$7E:352A] A:00C9 X:7510 Y:0018 P:eNvMxdizc - +1 to 7E352A.
$03/E339 20 3E CD JSR $CD3E  [$03:CD3E] A:00C9 X:7510 Y:0018 P:envMxdizc - Jump to Subroutine (Magic Call)
$03/E33C A5 FE LDA $FE    [$00:00FE] A:00F0 X:0680 Y:001A P:eNvMxdizC - Load Item from FE's Graphic.
$03/E33E 8D C5 33 STA $33C5  [$7E:33C5] A:00C9 X:0680 Y:001A P:eNvMxdizC - Store A in 7E33C5 (Graphics)
$03/E341 A9 0A LDA #$0A A:00C9 X:0680 Y:001A P:eNvMxdizC - Load Message (Salve)
$03/E343 8D C8 34 STA $34C8  [$7E:34C8] A:000A X:0680 Y:001A P:envMxdizC - Store A in Battle Message Small
$03/E346 A9 10 LDA #$10 A:000A X:0680 Y:001A P:envMxdizC - Load 10 into A.
$03/E348 8D C7 34 STA $34C7  [$7E:34C7] A:0010 X:0680 Y:001A P:envMxdizC - Store A in 7E34C7.
$03/E34B 60 RTS A:0010 X:0680 Y:001A P:envMxdizC - Return

Process in Pictures...

Salve on All Foes


Salve Failing


Salve Failed Because of the Item in the second slot having too high of a value.


Now the Items are Switched!



Salve is Successfully Cast!



Grimoire LD

  • FF4 Hacker
  • *
  • Posts: 1,684
    • View Profile
Re: Grimoire LD's Notes, Methods, and Hacks (All Spells & Commands Disassembly)
« Reply #111 on: October 10, 2013, 10:37:12 PM »
Ideally, I guess the player would want the spell to occur in addition to the attack damage. I mean, if I just want to cast the spell, I'll just use the weapon as an item. But I sincerely doubt that the game is capable of doing that - there is no other instance of a single character attack that generates multiple damage calls.
You could (I think):
  • Store zero in 00A2-00A3 (end damage result location)
  • Check for weapon spell
  • If none, jump down to regular attack routine
  • RNG
  • Check if random number is within range
  • If not, jump to regular attack routine
  • Load weapon spell
  • Jump to spell subroutine (which will return here when finished)
  • Regular attack routine
  • Add attack result to 00A2-00A3

In theory, I think this would cast the spell (if luck deems it so), then attack, and combine the resultant damage. Setting A2-A3 to zero first would ensure that if no spell is cast, only the attack's damage would be applied (instead of, say, being added to residual values from whatever the last attack was).

This game is surprisingly versatile! Even moreso than I thought!

I just tested a very simple process...

$03/E153   A9 1C   LDA #$1C   A:0003   X:0028   Y:0000   P:envMxdizc - Load Spell into A.
$03/E155   8D D2 26   STA $26D2  [$7E:26D2]   A:001C   X:0028   Y:0000   P:envMxdizc - Store A in Next Action.
$03/E158   9C C4 33   STZ $33C4  [$7E:33C4]   A:001C   X:0028   Y:0000   P:envMxdizc - Store Zero in 7E33C4.
$03/E15B   20 3E CD   JSR $CD3E  [$03:CD3E]   A:001C   X:0028   Y:0000   P:envMxdizc - Jump to Magic Call.
$03/E15E   A9 C0   LDA #$C0   A:0020   X:0680   Y:001A   P:envMxdizC - Load Attack Graphic into A
$03/E160   8D C4 33   STA $33C4  [$7E:33C4]   A:00C0   X:0680   Y:001A   P:eNvMxdizC - Store A in Audio/Visual Code.
$03/E163   4C 99 C4   JMP $C499  [$03:C499]   A:00C0   X:0680   Y:001A   P:eNvMxdizC - Jump to Fight Routine.


Remarkably this is All You Need to have the game use Magic, then attack and to my vast surprise, while it shows only one damage, it is Accumulated Damage from the command. So say you're doing 200 Damage with an attack. Say you add Lit-3 onto that damage with a Low Wisdom character and you'll see that shoot up to roughly 1500-1700 damage. This is in addition. The game will show the normal attack animation, then the magic graphic, making it look seamless and may I say, beautiful.

Add a few conditions to that (maybe intelligently look for the magic by looking at the Weapon itself) and we have Exactly that, (the above was just a proof of concept). For as sometimes poorly coded as FFIV sometimes seems to be, there are times when it shines and this is definitely one of those times. It looks like making a separate Fight command for Mages or a revamped Fight Command is close on the horizon!

chillyfeez

  • FF4 Hacker
  • *
  • Posts: 1,285
  • Gender: Male
  • Go ahead, ask me about Angel Feathers!
    • View Profile
Re: Grimoire LD's Notes, Methods, and Hacks (Magic Activating with Fight!)
« Reply #112 on: October 11, 2013, 12:19:44 AM »
Wow, good stuff. Nice going, Grimoire!

Deathlike2

  • Moderator
  • *
  • Posts: 3,538
  • I'm looking at you, bitch!
    • View Profile
Re: Grimoire LD's Notes, Methods, and Hacks (All Spells & Commands Disassembly)
« Reply #113 on: October 11, 2013, 01:14:09 AM »
Remarkably this is All You Need to have the game use Magic, then attack and to my vast surprise, while it shows only one damage, it is Accumulated Damage from the command. So say you're doing 200 Damage with an attack. Say you add Lit-3 onto that damage with a Low Wisdom character and you'll see that shoot up to roughly 1500-1700 damage. This is in addition. The game will show the normal attack animation, then the magic graphic, making it look seamless and may I say, beautiful.

Add a few conditions to that (maybe intelligently look for the magic by looking at the Weapon itself) and we have Exactly that, (the above was just a proof of concept). For as sometimes poorly coded as FFIV sometimes seems to be, there are times when it shines and this is definitely one of those times. It looks like making a separate Fight command for Mages or a revamped Fight Command is close on the horizon!

That is what FF4A already does to specific weapons, like the Lightbringer, Abel's Lance, and Fiery Hammer.
Working on the next Yet To Be Named FF4 "Hardtype" Hack Download Latest: v1.48

Video Demos: #1 #2 #3

Grimoire LD

  • FF4 Hacker
  • *
  • Posts: 1,684
    • View Profile
Re: Grimoire LD's Notes, Methods, and Hacks (Magic Activating with Fight!)
« Reply #114 on: October 11, 2013, 07:51:24 AM »
Thanks Chillyfeez!

Indeed DeathLike2. I thought they must have added a fair amount of code to make that possible, but it doesn't appear to be the case whatsoever. All I did was take Peep's formula and cannibalized it to create something very different, but still something quite simple. Do FFIV:A have the means to change the magic cast from those specific weapons? (I mean, has it been found?) because if not, it may be a CMP added to the Fight routine to check to see if those work and then go into the Magic Routine to accomplish the specific spells.

I can see a new class idea come out of this though, "MKnight" "Can use the latent power of weaponry with the Fight Command".  Or something to that accord. Sort of like what I pictured Baigan being in a couple of ways.

So Salve is down, that has been made more versatile. A separate Fight command can be made, so that takes care of Fight, I wonder what I should try to modify next... Maybe work on Cid's FFIV:DS "Elemental Weapon" command?

chillyfeez

  • FF4 Hacker
  • *
  • Posts: 1,285
  • Gender: Male
  • Go ahead, ask me about Angel Feathers!
    • View Profile
Re: Grimoire LD's Notes, Methods, and Hacks (Magic Activating with Fight!)
« Reply #115 on: October 11, 2013, 08:39:14 AM »
Question: when using your code, does the spell cost MP?
If not, how does it know not to (since it's using the magic routine)? And is it possible to make it cost MP? This would take a bit of the cheap out of a theorhetical MKnight's special command...

chillyfeez

  • FF4 Hacker
  • *
  • Posts: 1,285
  • Gender: Male
  • Go ahead, ask me about Angel Feathers!
    • View Profile
Re: Grimoire LD's Notes, Methods, and Hacks (Magic Activating with Fight!)
« Reply #116 on: October 11, 2013, 11:53:26 AM »
Also, what would happen, in theory, if the character was using a bow and arrow, and both had a spell assignment?
Would the game only use the spell of the weapon in the dominant hand, or would both spells be cast?

Deathlike2

  • Moderator
  • *
  • Posts: 3,538
  • I'm looking at you, bitch!
    • View Profile
Re: Grimoire LD's Notes, Methods, and Hacks (Magic Activating with Fight!)
« Reply #117 on: October 11, 2013, 02:29:31 PM »
Indeed DeathLike2. I thought they must have added a fair amount of code to make that possible, but it doesn't appear to be the case whatsoever. All I did was take Peep's formula and cannibalized it to create something very different, but still something quite simple. Do FFIV:A have the means to change the magic cast from those specific weapons? (I mean, has it been found?) because if not, it may be a CMP added to the Fight routine to check to see if those work and then go into the Magic Routine to accomplish the specific spells.

I don't know, but just from testing, I believe it's just another branch of code that determines from the RNG whether or not to execute (with probabilities) with Abel's Lance being a special case using Kain's level to determine success.

It would be nice to know how often it works for the other two weapons. I'm sure you could change the spell used if you wanted to (using the associated attributes of Wisdom/Intelligence and Will Power/Spirit depending on the spell).

Question: when using your code, does the spell cost MP?
If not, how does it know not to (since it's using the magic routine)? And is it possible to make it cost MP? This would take a bit of the cheap out of a theorhetical MKnight's special command...

Chances are, the spell command (White/Black/Summon/Ninjutsu) is doing the MP deduction, so LD's design skips that step unless that is manually added into the Fight or new command code.
Working on the next Yet To Be Named FF4 "Hardtype" Hack Download Latest: v1.48

Video Demos: #1 #2 #3

Grimoire LD

  • FF4 Hacker
  • *
  • Posts: 1,684
    • View Profile
Re: Grimoire LD's Notes, Methods, and Hacks (Magic Activating with Fight!)
« Reply #118 on: October 11, 2013, 04:15:22 PM »
Question: when using your code, does the spell cost MP?
If not, how does it know not to (since it's using the magic routine)? And is it possible to make it cost MP? This would take a bit of the cheap out of a theorhetical MKnight's special command...

DeathLike2 had the right idea with his response, but I did find the actual byte which says whether to use MP and that was in Recall's routine...

"So to have Recall not take any MP it is as simple as changing this...


$03/EABC   EE 5D 35   INC $355D  [$7E:355D]   A:0019   X:000F   Y:0003   P:envMxdizc - +1 to 7E355D.

To this...

$03/EABC   9C 5D 35   STZ $355D  [$7E:355D]   A:0020   X:0009   Y:0003   P:envMxdizc - Store Zero in 7E355D."

Adding that +1 to 7E355D signals to the game to use that spell's MP to cast it.

As for checking to see if you have enough MP to use said spell, that too is in Recall...

"
$03/EA9B   AD 8B 26   LDA $268B  [$7E:268B]   A:0000   X:000F   Y:0003   P:envMxdiZC - Load Caster's MP Byte 1.
$03/EA9E   85 A9   STA $A9    [$00:00A9]   A:00E7   X:000F   Y:0003   P:eNvMxdizC - Store A in A9.
$03/EAA0   AD 8C 26   LDA $268C  [$7E:268C]   A:00E7   X:000F   Y:0003   P:eNvMxdizC - Load Caster's MP Byte 2.
$03/EAA3   F0 04   BEQ $04    [$EAA9]   A:0003   X:000F   Y:0003   P:envMxdizC - Branch if not 00 to 03EAA9.
-------------------------------------------------------------------------------------------------------------------------------------------------
$03/EAA5   A9 FF   LDA #$FF   A:0003   X:000F   Y:0003   P:envMxdizC - Load FF into A. (Assumes you have enough MP to cast spell)
$03/EAA7   85 A9   STA $A9    [$00:00A9]   A:00FF   X:000F   Y:0003   P:eNvMxdizC - Store A in A9.
-----------------------------------------------------------------------------------------------------------------------------------------------
$03/EAA9   AD A1 28   LDA $28A1  [$7E:28A1]   A:00FF   X:000F   Y:0003   P:eNvMxdizC - Load A from Spell's MP Cost.
$03/EAAC   29 7F   AND #$7F   A:0007   X:000F   Y:0003   P:envMxdizC - Get rid of negative bits.
$03/EAAE   C5 A9   CMP $A9    [$00:00A9]   A:0007   X:000F   Y:0003   P:envMxdizC - Is it the same as what is in A9?
$03/EAB0   F0 06   BEQ $06    [$EAB8]   A:0007   X:000F   Y:0003   P:envMxdizc - Branch if Equal to 03EAB8.
$03/EAB2   90 04   BCC $04    [$EAB8]   A:0007   X:000F   Y:0003   P:envMxdizc - Branch  if More to 03EAB8.
-------------------------------------------------------------------------------------------------------------------------------------------------
$03/EAB4   68    PLA   A:0005   X:0009   Y:0003   P:envMxdizC - Pull A.
$03/EAB5   4C C2 EA   JMP $EAC2  [$03:EAC2]   A:0020   X:0009   Y:0003   P:envMxdizC - Jump to Routine (Return)
-------------------------------------------------------------------------------------------------------------------------------------------------
$03/EAB8   68    PLA   A:0007   X:000F   Y:0003   P:envMxdizc - Pull A from Stack (retrieving the spell to be cast)
$03/EAB9   8D D2 26   STA $26D2  [$7E:26D2]   A:0019   X:000F   Y:0003   P:envMxdizc - Store A in Caster's Action to be Taken.
$03/EABC   EE 5D 35   INC $355D  [$7E:355D]   A:0019   X:000F   Y:0003   P:envMxdizc - +1 to 7E355D.
$03/EABF   20 46 CC   JSR $CC46  [$03:CC46]   A:0019   X:000F   Y:0003   P:envMxdizc - Jump to Subroutine (Magic Call - Full)
$03/EAC2   60    RTS   A:00E0   X:0680   Y:001A   P:eNvMxdizC - Return
"
Granted that uses up a fair amount of bytes. What would be easier is a way to make the command unusable at 00 MP. Which is a very easy thing to set up whether inside the command or outside of it.

Now spells that are drawn from weapons are purely on a weapon by weapon basis.

There is an unknown (and possibly unused) byte in weapons that I think could be replaced and used for this as a secondary "Spell Check" so to speak. So that it can't be cast by just using the weapon.  Now the way I would set this up is to check the character's equipment (7E2780+), look in the Right Hand, then if inapplicable look in the Left Hand, meaning that only one instance of a spell would occur as the game would branch to the next part of the routine. But let me see if the game is capable of recognizing two magic commands in  a single routine for theories sake...

The game does not take kindly to casting two spells in one action, it seems. Either that or I'm missing something, which is completely possible. I might need to look back at the Summon section of data to see how that works since that is technically two spells, even if one is just the Summoning Preparation.




chillyfeez

  • FF4 Hacker
  • *
  • Posts: 1,285
  • Gender: Male
  • Go ahead, ask me about Angel Feathers!
    • View Profile
Re: Grimoire LD's Notes, Methods, and Hacks (Magic Activating with Fight!)
« Reply #119 on: October 11, 2013, 04:42:16 PM »
When you cast a spell, the game checks if it is in the summon range, if so then it changes the value in the sub-action byte to the appropriate actual spell. It's a pretty straightforward process, but probably not very useful for what you're trying to do.