Changing Damage formulas - Printable Version +- FF6 Hacking (https://www.ff6hacking.com/forums) +-- Forum: Discussion Forums (https://www.ff6hacking.com/forums/forum-5.html) +--- Forum: Magitek Research Facility (https://www.ff6hacking.com/forums/forum-9.html) +--- Thread: Changing Damage formulas (/thread-2736.html) |
Changing Damage formulas - Odal - 11-10-2014 So I've done a bunch of digging over the past few days trying to figure out a change which I thought would be relatively simple, and I've gotten a lot closer but still feel so far. I simply want to change damage calculation algorithms. Magic and Physical. I've found the C2 disassembly (http://assassin17.home.comcast.net/~assassin17/code2i.txt) and located the stuff in windhex, but I'm unsure how to modify what the actual algorithm is. So say, for example, the magic calculation divides by 32 and I want to change it to something else, let's say 64 for the sake of ease. How would I actually change this line of code to do that? I've searched everywhere and nothing seems to explain how to actually change this. I've found where it does this, but I have no idea how to modify the function the way I want to: Code: C2/2B90: 20 D1 0D JSR $0DD1 (Divide 24-bit Damage by 32. [note the I have found stuff around C2/2B69 where it tells what stat it's pulling and I've figured out how to tell it to pull a different stat, but unfortunately that still leaves me with these ridiculous equations where one stat skyrockets above the other in terms of effectiveness. As for more in-depth formula changing, the meat of the formula seems to be here: Code: C2/2B86: 20 81 47 JSR $4781 (Multiplication Function: Ugh, this is hurting my brain. I apologize if this is really basic stuff. There doesn't seem to be much dumbed-down detail on this anywhere and it's been really hard to wrap my brain around what little I have managed to understand so far. RE: Changing Damage formulas - Synchysi - 11-11-2014 (11-10-2014, 10:03 PM)Odal Wrote: So say, for example, the magic calculation divides by 32 and I want to change it to something else, let's say 64 for the sake of ease. How would I actually change this line of code to do that? I've searched everywhere and nothing seems to explain how to actually change this. I've found where it does this, but I have no idea how to modify the function the way I want to: If you look at C2/0DD1, the commentary will tell you what's going on. This multiplication is actually part of a larger function, but if entered at C2/0DD1, it's a bit more generalized arithmetic: Code: (if entered at C2/0DD1, does a more general division of a 32-bit value What it doesn't tell you is what the base value being modified is, but you can discern that by looking at the function (it's the values stored in $E8 - $EA, typically, so a 24-bit value). So the commentary says it's dividing that by 2^(A+1). If you look back at the caller, you can see an LDA #$04 instruction at C2/2B8C. So using that, we can figure out what the divisor is: 2^(4+1) = 2^5 = 32 To change the divisor to 64, you'd just need to change that LDA instruction to LDA #$05. (11-10-2014, 10:03 PM)Odal Wrote: As for more in-depth formula changing, the meat of the formula seems to be here: Same thing, take a look at the commentary for the function being called. At C2/4781: Code: Multiplication Function Calling the operands the "low bit" and "high bit" is misleading; more accurately, it should be "low byte" and "high byte." These simply refers to each 8-bit portion of a 16-bit A. For example, if A contains 13BD (5053 in decimal), then this function will multiply 13 * BD. And at C2/47B7: Code: Multiplication Function 2 This one is easier to understand, and a bit more versatile. As you can tell, it will give you three different results for three different sets of arithmetic. One result will be stored in 16-bit A. One result will be stored in 24-bit $E8 (that is, $E8 - $EA) The last result will be stored in 16-bit $EC ($EC - $ED) (11-10-2014, 10:03 PM)Odal Wrote: And now that I look at it, I don't see where Spell power * 4 (first part of the formula) is calculated at all. This one's a bit less obvious than calling a multiplication function. Code: C2/2B71: AD A6 11 LDA $11A6 (Spell Power) The key is in the ASL instructions. These shift all bits in the operand left by one bit, which effectively doubles it. This instruction has more uses than just a quick (operand * 2), but that's all it's used for in this case. It starts by loading the caster's spell power into A, then doubling that (A * 2), then doubling THAT (A * 4). Of note, the LSR instruction has a similar usage in that it shifts all bits in the operand to the right by one bit, effectively halving it. ASL = Arithmetic Shift Left LSR = Logical Shift Right (11-10-2014, 10:03 PM)Odal Wrote: Ugh, this is hurting my brain. I apologize if this is really basic stuff. There doesn't seem to be much dumbed-down detail on this anywhere and it's been really hard to wrap my brain around what little I have managed to understand so far. This is about familiarity with ASM more than anything else. How basic it is depends on how comfortable the hacker is with the language. I implemented a fully custom physical damage formula in my hack, so I was hanging around these damn formulas for way too long. RE: Changing Damage formulas - Odal - 11-15-2014 Thank you very much for your help. So, I spent a lot of time pondering and decided I still doubt I know how to do anything complex. Here is what I have come up with in case you or anyone else is curious and I still have to test it. I always find that in any hack, I have to itemize and value Magic Power to Vigor at a 1:2 ratio. That is, it takes roughly 2 vigor to be a similar raise in damage to 1 Magic power. I realized I may have been thinking too big when I wanted to change everything altogether. Then I had a thought: Why not just divide Magic Power by 2? (Side question here: does the game only truncate the final result? I assume it does. If not, my concern would be that an odd numbered magic power would be exactly the same as the even number preceding it.) Well, as I understand it, I need to use the same amount of space. I'm not sure how true this is, but I don't know how I'd go about using less or more space than what is already being used. So what I came up with is this: Spoiler (Click to View) Now the only issue I have is level scaling. In Physical damage, the level is squared in its calculation and it's not squared in the Magic damage formula. I came up with a similar kind of solution for levels. Spoiler (Click to View) Is there some way I can just remove the squaring aspect altogether though? I see where it looks kind of separated from the main calculations. Spoiler (Click to View) Edit - It seems my original idea broke the game. I was going to make room for AD A6 11 (calling battle power instead of E5 E8, "get attacker level again") by deleting an ASL again. One thing it did was make the enemies deal a LOT more damage, but when I finally did get a chance to attack, the game crashed Tried calling battle power instead of level earlier on, but alas this just makes the "get attacker level again" pull battle power instead of level. So as far as I can tell, there's no way to separate the two easily. On the good side, deleting an ASL and inputting an LSR for the magic calculation has seemed to work out smoothly. Edit 2 - All my attempts to cut level stat in half in the physical damage formula using LSR ended in failure. Basically numbers are all wrong coming from enemies and character attacks result in game reset. Tried one LSR (in place of a monster battle power *4 ASL) inserted several different spots around where it annotates a reference to character level stat being called, but no good. Tried some more with magic to see if that was a fluke, but the LSR in that seems to be working right. Not sure why it works in one and not the other. Hmm. |