Changing and Replacing Combat Functions via Special Effects - 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 and Replacing Combat Functions via Special Effects (/thread-3149.html) |
Changing and Replacing Combat Functions via Special Effects - ReturnerScum - 02-24-2016 Hi hackers. This thread is going to be for mapping out the combat function and explaining how to change and replace combat formulas via special effects, making abilities and items much more dynamic with the game. So far I've made a rocking formula successfully but I do have 3 questions for anyone who might be familiar with storing values, special effects, and the combat function. I have searched about these, btw. Q1: Storing Values. I'm working on some new formulas and when I look at the original game formulas, it seems to store values in a low range of addresses. I'm looking to use 2-3 byte calculations for changing and replacing damage functions. Is there any range in particular I would need to store this extra data? There are at least two spots where damage is stored, for example -- $F0 and $11B0. I'm guessing the low address values are due to development planning rather than system mechanics---anyone know about that? Q2: Special Effects Special effects are called in a lot of different places--it looks like there's two tables and only one of them works for my spell sfx. Has anyone found any surprising problems with editing special effects in general? They're called in reflect and launcher too, IIRC. Q3: Combat Functions It seems like the combat --> damage --> result function never ends. Any caveats and wisdom would be much appreciated before I wreck my hack for good. I'm surprised at how little it seems the modify damage routine is referenced, but I'm worried there are so many references upstream I'm not seeing, that changing damage is too risky when added via special effects into $11B0 and $F0. Thanks all. Whether we have any wisdom on this or not, I'll be sure to make it enlightening for us. RS RE: Changing and Replacing Combat Functions via Special Effects - ReturnerScum - 02-27-2016 I've got two new special effects for us that work and one that doesn't work but seems very close to doing so. FIRST REPLACEMENT - New Special Effect $14 - Mpwr^2/8 Added to damage Code: C2/3DF5: 8C 38 --> 90 67 Special ($14h) [20] now points to 6790 Notice that I use XBA and JSR $4781 to multiply the $11A0 Mpwr together. I then tried using $11A0 and $11A6....and it didn't work to create Mpwr*Vigor. I have the same situation for the next formula below---I get a bit more daring by using the Y index to Lvl^2, but I have a suspicion that other data near those values (3B18) don't work when called by special effects. The XBA and JSR technique was stolen from the Flare Star code, which I'll discuss in detail for my third, huge, formula: SECOND REPLACEMENT - $03 - Lvl*Lvl Added to Damage Code: C2/3DD3: 43 3D ($03) --> B0 67 (jump to $67B0 as new special effect $03, 4th in weapon sfx menu in FF3usME, But first let's talk about how insanely great this is. Would you rather have a sword that breaks, like ogre nix, or a sword that adds damage based on your Mpwr? The limits of interesting combat are quickly destroyed with the prismatic expansion of damage formulas. Do you really like having exploder in your Lore list? But how much can we change? I've recently read a lot of the Programming the 65816 document and have, of course, made some formulas that are much more sophisticated than a squared hero statistic. This one isn't super sophisticated but it doesn't just do damage = your HP or dmg+HP, it does [(HP/64+1)+(MP/16+1)]^2 and replaces the damage from normal formulas: Code: HP+MP Damage Formula And this time, for some reason, the formula doesn't work. This code loads HP and MP data, reduces them to a # which will not exceed 1 byte, then goes into 8-bit mode to do the XBA JSR trick again. The XBA trick swaps the high byte and low byte of the accumulator, with one of them (the high byte, I believe) referred to as "B" when in 8bit-mode, because there is no 2nd byte in 8bit-mod, but the space (and thus, the hex values there) is still there, it just isn't touched. When you swap the low byte and high byte, you can multiply or divide the value by 256, or you can use the JSR $4781 multiplication subroutine to multiply the two bytes together, with the result in 16bit A. The formula of this type is much more powerful because it multiplies 2 byte values like HP and MP together, although it's not perfectly ideal because I believe there is a lot of rounding down that occurs. So why do the first two formulas work and this one doesn't? The same HP value is called by Valiant Knife, so that should be fine---but when I change the hero stats to be $11A0 (Mpwr) instead, the formula works brilliantly. Does anyone know the values that can or can't be loaded during combat? Below is the quick list of values I've found throughout C2: Quote: Speed (hero) - $11A4 I should also mention that in this code, Y seems to be the attacker and X the target, but it seems extremely difficult to track the source of what's in the X or Y registers. (Note: On the site the code text looks jilted but when editing it the code and comments are perfectly straight) (To use these formulas by the way, FF3usME has the special effect box on the right when looking at a spell, and the special effect drop-down menu for weapons. The first formula here is effect $14 in the spell menu, the 2nd is the "0x3" special effect for weapons, replacing the "Kill with X" effect.) RE: Changing and Replacing Combat Functions via Special Effects - Synchysi - 02-27-2016 One thing you can do to troubleshoot your custom functions is to run them through the SNES9x debugger. http://geigercount.net/crypt/ Just set a breakpoint at the address in question, then you can go through it line-by-line to check which values are getting loaded, and if they are what you expect. RE: Changing and Replacing Combat Functions via Special Effects - ReturnerScum - 02-27-2016 Thanks I'll try and figure out how to use that. This thread isn't just about debugging my formulas by the way---it's to find ways that actually work, so if anyone else has successfully changed things up in a similar way, please feel free to join in. Alright that debug tool worked like a charm once I figured out how to use it. You have to add a breakpoint then check the "Execute" and "read"function and type in your 6 digit hex address. When the address is called or used then it stops and you have to push the "step into" button to go step-by-step through the code that is executing and compare what should happen. Then you can use the same program to change the hex code of the ROM on the fly and reload. What the debugging tool also means, is that you can track the entire combat function using the same technique. There's probably some button that can just write the code to a file but that wasn't explained by the self-titled "l337" pre-pubescent boy who was explaining this to me on Youtube. Also I've found a nice explanation of the special effects combat function when foolishly trying to remove a patch by Assassin, the capture weapon fix "Recapture the Glory": Quote:Also, the game only has a few basic damage formulae: one used by physical spells (and by The problem with my formula was that my storage bytes were in the middle of the code and being interpreted as ASM instructions, derailing the train from there. Now the damage is off for a reason I haven't figured out yet. It should be doing around 4801 dmg with 2063 HP and 651 MP, but ends up around 1100. RE: Changing and Replacing Combat Functions via Special Effects - ReturnerScum - 03-06-2016 Here is my mapping of the two SFX tables when cross-checking the C2Code and FF3usME: Edit: Since all my text ends up jilted, a document is attached with this (even though it also doesn't look straight in the google drive preview). Code: C2/3DCD: 8C 38 Nothing C2/42E1: 8A 3E RE: Changing and Replacing Combat Functions via Special Effects - HatZen08 - 07-30-2018 Quote:I'm working on some new formulas and when I look at the original game formulas, it seems to store values in a low range of addresses. I'm looking to use 2-3 byte calculations for changing and replacing damage functions. Is there any range in particular I would need to store this extra data? There are at least two spots where damage is stored, for example -- $F0 and $11B0. I'm guessing the low address values are due to development planning rather than system mechanics---anyone know about that? $11B0 (low) and $11B1 (high) are the two-byte damage value. $F0 generally is used as a temporary buffer or variable to calculate damage. For special effects, to setup $11B0 AND $11B1 are the correct way to setup a custom formula damage. Quote:Special effects are called in a lot of different places--it looks like there's two tables and only one of them works for my spell sfx. Has anyone found any surprising problems with editing special effects in general? They're called in reflect and launcher too, IIRC. Some special effects have hard coded features and are manually setup in code instead of a weapon or spell data. Examples are sketch, control, steal, etc. If they are modified, whatever code that setups them must be nullified as well to avoid undesired surprises. Quote:It seems like the combat --> damage --> result function never ends. Any caveats and wisdom would be much appreciated before I wreck my hack for good. I'm surprised at how little it seems the modify damage routine is referenced, but I'm worried there are so many references upstream I'm not seeing, that changing damage is too risky when added via special effects into $11B0 and $F0. The special effects that changes damage only overwrites the calculated default damage setup in $11B0 and $11B1. If the special effects don't change damage, the default damage is left as it was calculated. Quote:I should also mention that in this code, Y seems to be the attacker and X the target, but it seems extremely difficult to track the source of what's in the X or Y registers. I believe X or Y are the fighters index. 0, 2, 4 and 6 are the party side and above it are the opposition (monsters). As example, $3BF4,0 should be the actual hp of the first party member. $3BF4,2 should be the actual hp of the second party member, etc. The data stored in similar two bytes structures are always two bytes to accommodate all fighter indexes, party and opposition alike. About the wrong text display in the posts, probably you used tabs instead of white space characters. The tab characters will try to setup the column text in a different position in the forum instead of the position of your text editor. You can try to check if your text editor has the option to automatically convert tab spaces in white spaces. |