øAslickproductions.org/forum/index.php?PHPSESSID=5f0fck550j2m4m2fpbtkj2vkm1&topic=442.msg3548e:/My Web Sites/Slick Productions - FFIV Message Board/slickproductions.org/forum/index74a3.htmlslickproductions.org/forum/index.php?PHPSESSID=5f0fck550j2m4m2fpbtkj2vkm1&topic=442.0e:/My Web Sites/Slick Productions - FFIV Message Board/slickproductions.org/forum/index74a3.html.zxTg^ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÈ…¬v6OKtext/htmlISO-8859-1gzip0|Öv6ÿÿÿÿÿÿÿÿTue, 10 Mar 2020 09:03:49 GMT0ó°° ®0®P®€§²ð®Tg^ÿÿÿÿÿÿÿÿ*v6 Spell ASM Finds

Author Topic: Spell ASM Finds  (Read 23005 times)

Phoenix

  • FF4 Hacker
  • *
  • Posts: 456
    • View Profile
    • Phoenix Hacks
Spell ASM Finds
« on: March 18, 2008, 05:36:58 PM »
I've been deconstructing the spell subroutines ASM over the last few days, and have made a few finds. I thought I'd post them here and add to it as I make more discoveries.

  • Like the Cure subroutine does a check for Cure4, I confirmed that the Life subroutine does a check for Life2, which is why it does a complete HP restore. The Life subroutine also checks for a few other monster spells (AB Recover and AC Remedy) and does a full HP restore for them, too.
  • I also confirmed that the generic spell subroutine does a check for summon spells, and if one is being casted it checks if the targets are allies (Asura skips this check). So, I was right that there is an ally safeguard for these spells. Why? I don't know, since you're not allowed to target them on allies anyway, and they're not reflectable. Anyway, to change this behavior and skip the check, change the value at 1D37D (ROM with header) from [10 AE] to [80 00]. You can then target allies with summons if you change the targeting byte within the spell. I'm not sure if this affects other spells or enemy attacks, so let me know if you notice anything strange (especially since I plan on using this in my hack).
  • The ASM for reflected spells does a check on whether party slots are viable (i.e. not empty, or have a character with swoon/stone/jump/hide/magnetized status). If I'm reading the code right, this means that magnetized characters can't have spells reflected onto them. Can anyone confirm this? I tried doing a test but I didn't have enough time to find out if it worked.



« Last Edit: March 19, 2008, 09:02:50 PM by Phoenix »

Dragonsbrethren

  • Forum Overlord
  • *
  • Posts: 1,820
    • View Profile
    • Dragonsbrethren Industries
Re: Spell ASM Finds
« Reply #1 on: March 18, 2008, 05:45:55 PM »
Nice finds. Is there anything in Life's subroutine that checks for Asura's life spell? Still wondering why that one can hit dead characters when multi targeted and the normal ones can't.

Phoenix

  • FF4 Hacker
  • *
  • Posts: 456
    • View Profile
    • Phoenix Hacks
Re: Spell ASM Finds
« Reply #2 on: March 18, 2008, 06:13:42 PM »
Yeah, that's the main reason I've been looking in the ASM data. It's all so I can make a multi-revive possible. Asura's bypass of the targeting check is not in the Life subroutine that I can tell, or within the normal spell routine. But, there's more subroutines that are called from both of those that I haven't analyzed or been able to figure out yet. I'll post as soon as I find it.

Deathlike2

  • Moderator
  • *
  • Posts: 3,538
  • I'm looking at you, bitch!
    • View Profile
Re: Spell ASM Finds
« Reply #3 on: March 18, 2008, 06:36:35 PM »
3. The ASM for reflected spells does a check on whether party slots are viable (i.e. not empty, or have a character with swoon/stone/jump/hide/magnetized status). If I'm reading the code right, this means that magnetized characters can't have spells reflected onto them. Can anyone confirm this? I tried doing a test but I didn't have enough time to find out if it worked.

Magnetized characters can have spells hurt them when reflected. Sorry.

Nice finds. Is there anything in Life's subroutine that checks for Asura's life spell? Still wondering why that one can hit dead characters when multi targeted and the normal ones can't.

Probably, but it's supposed to avoid the standard multitargeting check for targeting dead/live characters in regards to status afflications (Life is reversing Death status)
Working on the next Yet To Be Named FF4 "Hardtype" Hack Download Latest: v1.48

Video Demos: #1 #2 #3

Phoenix

  • FF4 Hacker
  • *
  • Posts: 456
    • View Profile
    • Phoenix Hacks
Re: Spell ASM Finds
« Reply #4 on: March 18, 2008, 07:19:49 PM »
Quote
Magnetized characters can have spells hurt them when reflected. Sorry.

Hmm...must have read the code wrong. I wonder what check I was looking at. I'll have to go back and analyze it again.

Quote
Probably, but it's supposed to avoid the standard multitargeting check for targeting dead/live characters in regards to status afflications (Life is reversing Death status)

Asura's spell is definitely special in that it avoids a targeting check, but it's not within the Life subroutine. I think it's in the subroutine that's called when you cast a spell/use an item, but that one is really long so I haven't been able to figure it all out yet. I've found a couple of areas where the code checks if the characters are alive, and excludes those that are dead, petrified, jumping, or hiding, so I'm guessing it bypasses one of those.

Phoenix

  • FF4 Hacker
  • *
  • Posts: 456
    • View Profile
    • Phoenix Hacks
Re: Spell ASM Finds
« Reply #5 on: March 19, 2008, 09:07:03 PM »
Some more things I've discovered:

  • I looked for a long time a while ago for how to change the black/white/call casting effects for the spells. After I couldn't find them, I thought they were probably hardcoded, which I've confirmed in the generic spell subroutine. It checks for the spell number, and performs the animation based on that. So you could expand the range of black/white/call spells, but you can't pick and choose individual ones.
  • Silence only affects spells below 5F (i.e. character spells). Enemy attacks are not affected by this status.

Again, if anyone can confirm these or show them to be false, please do.

Deathlike2

  • Moderator
  • *
  • Posts: 3,538
  • I'm looking at you, bitch!
    • View Profile
Re: Spell ASM Finds
« Reply #6 on: March 19, 2008, 10:01:58 PM »
Some more things I've discovered:

  • I looked for a long time a while ago for how to change the black/white/call casting effects for the spells. After I couldn't find them, I thought they were probably hardcoded, which I've confirmed in the generic spell subroutine. It checks for the spell number, and performs the animation based on that. So you could expand the range of black/white/call spells, but you can't pick and choose individual ones.
  • Silence only affects spells below 5F (i.e. character spells). Enemy attacks are not affected by this status.

Again, if anyone can confirm these or show them to be false, please do.

I've always thought it was simply cosmetic, but I guess that's only for weapon based spells.

I think what would be more interesting is being able to tweak what the spell uses to power itself (using Wisdom or Will Power, enemies just use their magic power as a universal stat).

Silence's behavior is not surprising, although maybe the exception is the weapon-item special spells and W-Meteo (to an extent).

Weapon/item based spells ignore Silence, so go figure.

I get the feeling some of the Item based spell were meant to be used by Kain, such as Poisona and the Dancing Knife... although Kain does have Spears that cast magic.. though it wouldn't surprise anyone.

It would be nice to know what those weapon-item based spells are powered by (Wisdom or Will... most likely Will Power)
Working on the next Yet To Be Named FF4 "Hardtype" Hack Download Latest: v1.48

Video Demos: #1 #2 #3

Phoenix

  • FF4 Hacker
  • *
  • Posts: 456
    • View Profile
    • Phoenix Hacks
Re: Spell ASM Finds
« Reply #7 on: March 19, 2008, 10:29:51 PM »
  • I found the code that specifies the spell multiplier (which we knew to be [wisdom/will] / 4 + 1). Within this block of code is a section that says if the spell has the status-spell bit set in the effect data, then this multiplier is set to 1. So far, this bit doesn't seem to have any other uses besides this.
  • Deathlike2, I think you'll be particularly interested in this. I think I found the algorithm that calculates the spell hit rate. It uses the base hit rate of the spell and the modified wisdom/will of the character (modified meaning after equipment bonuses). The modified hit rate is the spell's base hit rate + (modified wisdom/will)/2. Furthermore, if the caster is blind, this modified hit rate is cut in half. Also, it appears to do a check to see whether the caster is in the first slot (character or enemy), and gives a 25% bonus to the hit rate if so. Here's some code to make it a little more readable:

Code: [Select]
modified hit rate = (spell's base hit rate) + (modified wisdom/will)/2
divide by 2 if Blind
multiply by 5/4 if in slot 1

Let me know if I'm wrong on this and tests don't support it. That block of code was a little complicated so I might have missed something. I think the next block of code balances this against the target's magic defense %, but I'm not going to look at that part yet because it's a little too much right now.

Deathlike2

  • Moderator
  • *
  • Posts: 3,538
  • I'm looking at you, bitch!
    • View Profile
Re: Spell ASM Finds
« Reply #8 on: March 19, 2008, 10:39:24 PM »
I found the code that specifies the spell multiplier (which we knew to be [wisdom/will] / 4 + 1). Within this block of code is a section that says if the spell has the status-spell bit set in the effect data, then this multiplier is set to 1. So far, this bit doesn't seem to have any other uses besides this.

I've replied to that thread, and I believe that sounds about right.

Quote
Deathlike2, I think you'll be particularly interested in this. I think I found the algorithm that calculates the spell hit rate. It uses the base hit rate of the spell and the modified wisdom/will of the character (modified meaning after equipment bonuses). The modified hit rate is the spell's base hit rate + (modified wisdom/will)/2. Furthermore, if the caster is blind, this modified hit rate is cut in half. Also, it appears to do a check to see whether the caster is in the first slot (character or enemy), and gives a 25% bonus to the hit rate if so. Here's some code to make it a little more readable:

Code: [Select]
modified hit rate = (spell's base hit rate) + (modified wisdom/will)/2
divide by 2 if Blind
multiply by 5/4 if in slot 1

Let me know if I'm wrong on this and tests don't support it. That block of code was a little complicated so I might have missed something. I think the next block of code balances this against the target's magic defense %, but I'm not going to look at that part yet because it's a little too much right now.

I'll have to look into the slot 1 issue (does this mean the center position for the characters?). I find that a little fascinating.. I'll end up testing with Rydia+Piggy because that spell needs massive help for success. Assuming it is the center position, it implies that a 2-fighter, 3 back-row character is intended to favor spellcasters even more (more than I originally though).

If what you saying is true about hit rate being boosted by Wisdom+Will (which is more logical than my level based reasoning, but I still think I'm right on that), that would explain better the hit rate for particular spells.

Blind apparently affects more than I thought (I thought it was a hit rate reduction of 1/4, but 1/2 is truly significant). This is a relatively underrated status effect that gets very underused AFAIK.
Working on the next Yet To Be Named FF4 "Hardtype" Hack Download Latest: v1.48

Video Demos: #1 #2 #3

Phoenix

  • FF4 Hacker
  • *
  • Posts: 456
    • View Profile
    • Phoenix Hacks
Re: Spell ASM Finds
« Reply #9 on: March 19, 2008, 10:48:59 PM »
Yes, slot 1 is the middle slot. The slot bonus took me a while to figure out, simply because I couldn't believe that a bonus would be given to an individual slot. But I worked through it a few times and came out with the same result, so that seems to be what it is. I might still be wrong though, so if it doesn't pan out let me know.

Blind does seem to be underrated and underused, especially since there's no spell that characters have access to that inflicts this status (right?). It'd be nice to have a blindness-inducing spell, although frankly I don't use status spells that often. Just doesn't seem worth the time . . . but maybe that's because the FF2us version is so easy.

Deathlike2

  • Moderator
  • *
  • Posts: 3,538
  • I'm looking at you, bitch!
    • View Profile
Re: Spell ASM Finds
« Reply #10 on: March 19, 2008, 10:57:33 PM »
Yes, slot 1 is the middle slot. The slot bonus took me a while to figure out, simply because I couldn't believe that a bonus would be given to an individual slot. But I worked through it a few times and came out with the same result, so that seems to be what it is. I might still be wrong though, so if it doesn't pan out let me know.

I'm starting to think positioning has a "starting" ATB bonus of sorts.. I have some older thread documenting the order characters go in a preemptive attack.

Quote
Blind does seem to be underrated and underused, especially since there's no spell that characters have access to that inflicts this status (right?). It'd be nice to have a blindness-inducing spell, although frankly I don't use status spells that often. Just doesn't seem worth the time . . . but maybe that's because the FF2us version is so easy.

The notable monsters that inflict it are those butterfly/moth monsters and the Marlboro's (spelled Molbol in FF2US) Breath attack. I don't know of any monster that inflicts that status attack normally as part of their physical attack.

Also.. this may or may not be important. I did my testing of the magnetic status in FF4, not FF2. It may be worthwhile to check if your "magnetic" finding in FF2US correlates with FF4's spell code.
Working on the next Yet To Be Named FF4 "Hardtype" Hack Download Latest: v1.48

Video Demos: #1 #2 #3

Phoenix

  • FF4 Hacker
  • *
  • Posts: 456
    • View Profile
    • Phoenix Hacks
Re: Spell ASM Finds
« Reply #11 on: March 19, 2008, 11:10:09 PM »
I checked FF4 and it has the same code there, so I must have made a mistake. Some time I'll go back and figure out what it really is, but right now I'm still searching for Asura's code. That mysterious woman, she's so good at keeping her secrets . . .
 :angry:

Deathlike2

  • Moderator
  • *
  • Posts: 3,538
  • I'm looking at you, bitch!
    • View Profile
Re: Spell ASM Finds
« Reply #12 on: March 19, 2008, 11:15:35 PM »
I checked FF4 and it has the same code there, so I must have made a mistake. Some time I'll go back and figure out what it really is, but right now I'm still searching for Asura's code. That mysterious woman, she's so good at keeping her secrets . . .
 :angry:

She's only cute when she casts uber "Cure4" on you.  :wink:

Ok.. testing was done.. it seemed to affect Odin significantly, but not in the method you described. Yes, his hit rate is 0, but if your hit rate bonus is true, then this code was intended to reduce the hit rate of the caster.

This is done to prevent insta-death killing sprees for easy EXP. Remember that the first character to go is in the one in the middle, if all ATB were the same.

This may also explain why the Evilmask has trouble casting multi-targeted Reflect on your guys.
Working on the next Yet To Be Named FF4 "Hardtype" Hack Download Latest: v1.48

Video Demos: #1 #2 #3

Phoenix

  • FF4 Hacker
  • *
  • Posts: 456
    • View Profile
    • Phoenix Hacks
Re: Spell ASM Finds
« Reply #13 on: March 19, 2008, 11:34:28 PM »
I'm not quite sure what you mean. How does multiplying by 5/4 reduce the hit rate? Or are saying that number is wrong?

Either way, I think it's more to affect enemies than the party, although why they would include the party's slot 1 when they could just exclude it is puzzling.

Deathlike2

  • Moderator
  • *
  • Posts: 3,538
  • I'm looking at you, bitch!
    • View Profile
Re: Spell ASM Finds
« Reply #14 on: March 19, 2008, 11:36:16 PM »
I'm not quite sure what you mean. How does multiplying by 5/4 reduce the hit rate? Or are saying that number is wrong?

Either way, I think it's more to affect enemies than the party, although why they would include the party's slot 1 when they could just exclude it is puzzling.

I think it is multiplying by 4/5, not 5/4.
Working on the next Yet To Be Named FF4 "Hardtype" Hack Download Latest: v1.48

Video Demos: #1 #2 #3