Users browsing this thread: 1 Guest(s)
Monsters are invincible/Algorithm question???

#1
Posts: 14
Threads: 2
Thanks Received: 0
Thanks Given: 0
Joined: Oct 2017
Reputation: 0
Status
None
Hey guys. I'm having this weird issue where any monsters in slot 5 or 6 (according to FF3usME) are invincible. This was particularly troublesome on any battle with 5+ enemies or battles where you can't retreat.

So far I've just made small edits to monster stats, and have used the 24-bit monster HP patch (which seems to be working for me now).

I first encountered the issue at the Imperial Outpost where Cyan goes berzerk and attacks the Grunts. In this fight are 2 Grunts and a Cadet. I was able to kill Cadet and the bottom Grunt. But the Grunt on top is seemingly invincible. I also encounter this issue in the Figaro Cave in the battle with 3 bleary and 2 hornets, and most recently in the Piranha/Rizopas fights. After removing the Piranhas in slot 5 I noticed Rizopas was also invincible, leading me to believe slot 6 is an issue as well.


Is there something I can do with Hex editing to fix this? I'm not sure where to go from here.
  Find
Quote  

#2
Posts: 2,549
Threads: 98
Thanks Received: 147
Thanks Given: 158
Joined: Aug 2009
Reputation: 52
Status
Nattak\'d
Ah yes, I do remember this bug with the patch... I wrote about it here http://slickproductions.org/forum/index....ic=1659.15 (last post) but never got any reply about it. It'll be much harder to fix without a supplied document showing the code, I'm sure. Sad It is a real shame and I'm surprised this issue was never spoken of as it's so serious, maybe not many people in the community ever used and/or tested it, I guess.


We are born, live, die and then do the same thing over again.
Quote  

#3
Posts: 14
Threads: 2
Thanks Received: 0
Thanks Given: 0
Joined: Oct 2017
Reputation: 0
Status
None
Hmm. I wouldn't actually need 24-bit Monster HP if I could cut all characters' damage dealt in half. I can just adjust the monsters' HP accordingly.

I found where the algorithms were for character's attack and magic damage are. I've been meddling with the magic attack algorithm, trying to get it to halve the final output.


So from something like: (Spell Power x 4) + (Mag.Pwr x Spell Power x Level) / 32
To something like: (Spell Power x 2) + (Mag.Pwr x Spell Power x Level) / 64

Which seemed to give the desired results when I ran them through a spreadsheet using different stats, etc. I took the following:
00022D70 7B AD A6 11 C2 20 90 02 0A 0A 8D B0 11 E2 20 AD
00022D80 AE 11 EB AD A6 11 20 81 47 20 B7 47 A9 04 C2 20

And tried changing to either of these:
00022D70 7B AD A6 11 C2 20 90 02 0A 00 8D B0 11 E2 20 AD
00022D80 AE 11 EB AD A6 11 20 81 47 20 B7 47 A9 05 C2 20

Set the second ASL command to 00 and changed the LDA from 05 to 04 under the theory that it would change the divide function from 32 to 64. As of typing this I realize that by setting that byte to 00, all I did was change it from an ASL command to a software break? Or is that just considered empty space?

Or...
00022D70 7B AD A6 11 C2 20 90 02 0A 8D B0 11 E2 20 AD AE
00022D80 11 EB AD A6 11 20 81 47 20 B7 47 A9 05 00 C2 20
Tried removing the above mentioned ASL command and shifting the bytes over 1. Then foolishly tried, what I assume was an LDA command in 8-bit mode trying to use 3 bytes.

Both of these things just caused my game to crash as soon as I attempted to use fire beam on a fresh game. I'm not sure what I'm missing here as I've only been learning this stuff for a couple days now. I'm not sure what needs to be done here to get extra bytes needed to alter the algorithm in the way I want. I would appreciate ANY insight on this!

PS: I apoligise in advanced as well for not knowing how to add code blocks to my posts...
  Find
Quote  

#4
Posts: 208
Threads: 3
Thanks Received: 0
Thanks Given: 8
Joined: May 2013
Reputation: 0
Status
None
Try changing OA to EA at C2/2D79 (headered location) so that it skip that line.
  Find
Quote  

#5
Posts: 281
Threads: 18
Thanks Received: 13
Thanks Given: 8
Joined: Mar 2014
Reputation: 8
Status
None
You have the right idea, but as you said, $00 is the BRK (break) instruction, so it's not surprising that your game crashes. What you want is the NOP (no operation) instruction, which is the $EA opcode.
Replace the ASL at C2/2B79 with NOP and the (Spell Power * 4) portion will be (Spell Power * 2 instead).

You have the right idea about the division part as well, but I'm confused by what you wrote, as the vanilla code is already set to loop the division function 5 times (divide by 32) by the LDA #$04 at C2/2B8C. If you set it to loop 6 times you'll get DIV 64, ie. change that LDA #$04 to LDA #$05.

Explanation: the function call at C2/2B90 calls a function at C2/0DD1 that divides a 32-bit number $E8 by 2^A+1. It does this by bit shifting/rotating the bytes and then looping A times.

The operand length of an instruction is determined by the register length flag. That is, if A is 8-bit, you can't supply an LDA with a 16-bit operand; only the first byte will be interpreted as an operand. The second byte you supply will then be interpreted as an operator. In your case, you put $00 there so it's another BRK instruction.

EDIT: The offsets in this post are all unheadered, by the way. It appears your ROM has a header so you'll have to add $200 to them.

By the way, I think B-Run included a fixed version of the 24-bit monster HP patch in his monster AI upgrade patch, which can be found in this forum.
  Find
Quote  

#6
Posts: 14
Threads: 2
Thanks Received: 0
Thanks Given: 0
Joined: Oct 2017
Reputation: 0
Status
None
(10-25-2017, 10:38 AM)seibaby Wrote: By the way, I think B-Run included a fixed version of the 24-bit monster HP patch in his monster AI upgrade patch, which can be found in this forum.

That bug I mentioned appears to still be there unfortunately Sad

Thank you for the other information though! I managed to get spell damage to be halved. Though I think monsters follow this same code, possibly an altered version of it. I know they have a different algorithm for physical attacks but I can't see where their version of magical attacks are or how to change that.

Quote:You have the right idea about the division part as well, but I'm confused by what you wrote, as the vanilla code is already set to loop the division function 5 times (divide by 32) by the LDA #$04 at C2/2B8C. If you set it to loop 6 times you'll get DIV 64, ie. change that LDA #$04 to LDA #$05.

Perhaps my wording could have been better, but yeah, I assumed the original LDA $04 code was for looping 5 times. I needed it to loop 6 times. Thank you for clarifying that I could use $05 though Smile

Anyways. You guys have been a huge help. I'm going to see about changing some stuff around with the algorithms.
  Find
Quote  

#7
Posts: 281
Threads: 18
Thanks Received: 13
Thanks Given: 8
Joined: Mar 2014
Reputation: 8
Status
None
Monsters and player characters use the same damage calculation for magical attacks, handled at C2/2B69. You can check the physical damage calculation at C2/2B9D to see how it handles calculating damage differently for monsters and PCs.

The X register usually holds the attacker ID, a number from $00 to $14, for each of the ten possible entities in battle. For PCs it is $00, $02, $04, or $06, so CPX #$08 and BCC is often used to differentiate between characters and monsters. For targets, the Y register is used instead.
  Find
Quote  

#8
Posts: 208
Threads: 3
Thanks Received: 0
Thanks Given: 8
Joined: May 2013
Reputation: 0
Status
None
In the Algorithms FAQ it says that monsters use a slightly different formula for magic (it's basically a 50% increased damage).

Here it is:

For magical attacks made by monsters:
Damage = Spell Power * 4 + (Level * (Magic Power * 3/2) * Spell Power / 32)

Tho I don't see anything related to that in C2 docs, is that information erroneous?
  Find
Quote  

#9
Posts: 200
Threads: 1
Thanks Received: 10
Thanks Given: 0
Joined: Oct 2015
Reputation: 18
Status
None
no, it's done earlier.  see C2/2D30.
Quote  

#10
Posts: 208
Threads: 3
Thanks Received: 0
Thanks Given: 8
Joined: May 2013
Reputation: 0
Status
None
Oh there it is, thanks!
  Find
Quote  



Forum Jump:

Users browsing this thread: 1 Guest(s)


Theme by Madsiur2017Custom Graphics by JamesWhite