• Welcome to Final Fantasy Hacktics. Please login or sign up.
 
March 28, 2024, 09:04:19 pm

News:

Don't be hasty to start your own mod; all our FFT modding projects are greatly understaffed! Find out how you can help in the Recruitment section or our Discord!


Rodil's ASM hacks

Started by Rodil, December 30, 2015, 02:45:55 am

Rodil

December 30, 2015, 02:45:55 am Last Edit: February 10, 2016, 06:03:53 am by Rodil
I will be telling a lot of stories in between the hacks, so if all you want is the hacks, look for the spoiler boxes.

Hi, I'm new here as of mid December 2015.  I have very little programming experience(3 courses of 100 level c++ in college) so it takes me quite a while to figure out anything.  The first thing I did here was read... a LOT.  There is a lot of information spread around here in the forums and on the wiki.  I didn't always know what questions to ask at first so I made it a policy to read more and ask questions later.  This will be a log of my ASM hacks as well as any lessons I learned from the implementation of the hacks.

My initial goal for the work I'm doing is to decrease the range of everything.  My first obstacle in accomplishing this was the fact that ranged weapons(bows, crossbows, guns, books, instruments) have a minimum target range of 3.  So I dove into the ASM to try and figure out if I could fix this.  Without this fix my whole goal would be moot so this I dove into this before FFTP, before eventing, before doing much of anything except reading as much information as I could digest both on the forums and the wiki.

Lesson 1: If you are new to ASM/coding in general, as I am, it's going to take a LOT of time to figure out the smallest problems.  Be prepared to invest the time or just stick to other peoples awesome patches.

I loaded up a game, equipped a character with a crossbow, used the gameshark guide to pinpoint it's info and set up a break in in the r3000 debugger for psxfin, opened up a MIPS guide so I could read along with the code and the battle.bin page on the wiki and went to work.  The way I learn best is to process along with the computer, line by line with the code.  So I read a lot of code based around loading the crossbow, keeping close track of the Rslot the range was stored in and eventually came across the location(s) the program uses to draw out its maps.  Up to this point I had about 5 hours in, mostly just learning all the MIPS commands.  I then mapped out on paper at the same time as the program mapped out it's attack area and learned how the computer maps everything out, in which order it goes from one tile to the next, what flags it uses and some of the information that goes into the map.  (another 5 hours or so drawing maps and learning)  After all this I was able to find the function that is used to delete the squares for ranged and soon(another 2 or 3 hours later) I was able to pinpoint the piece of code that erased the range 1-2 for crossbows and guns.  And then, with a simple change of 1 line of code I did it,  I changed it in the debugger and it worked my minimum range for the crossbow was now 2!  A quick self teaching of basic XML and I then patched an ISO and learned my next couple lessons thanks to the kind people in the chat(the first time I asked them anything)

Lesson 2: Always make sure to patch a clean ISO.  If you are here you've probably already patched 3 or 10 ISO's with other peoples work.  I patched the only patch that it didn't work on!

The next lesson will come in a bit, so here it is:

Change minimum range of crossbows and guns to 2


battle.bin
0x112430
01000634


you can make other minranges too: 00000634 will make it 1, 03000634 will make it 3.
ps I just tested for books and it works there too, I have yet to test harps and here comes the next lesson I learned.

I was very happy with my achievement and figured I was done with reducing the minimum range for ALL things when somebody in the chat asked if it worked for bow, I assumed it did, they proved me wrong!

Lesson 3: Always test every aspect of something before assuming it works

Well, back to the drawing board.  This time it only took about 4 hours to nail the right spot as I had already done all that mapping work before.  Not much story here as it came down to similar things to the previous hack, though it was interesting to see how differently the arced range and direct range functions were written.

Change bows minumum range to 2


battle.bin
0x112934
02004229


Likewise with this one you can change it to other numbers you want: 01004229 will make it 1, 04004229 will make it 4

After finishing all of this I was fairly confident with my knowledge of the mapping of ranged weapons functions and decided to try one of the 'optional' things on my list: changing the amount of range that is increased from height on arced weapons(bows).  This one ended up being in the very same function so I was able to find it fairly quickly(a mere 1 or 2 hours).  My next problem was that there was only one line of code immediately available for the current programming of it and what I wanted to do(1 range increase per 3 height) required more than one line of code and I was not confident enough in moving code around to do this so after some time of trying to make up my mind i decided to be lazy and go with 1 range increase per 4 height.

Change range increase for height for bows to 4 height=1range


battle.bin
0x1129a4
C3100200


Again you can change values here, default is 2height=1range, 03110200 is 8height=1range, 43100200 is 1height=1range.
I don't know if there is a way to do numbers that are not exponents of 2 without adding more lines of code, but there's enough info here for a better coder to pick it up if they want, I'm satisfied with my lazy answer.

Edit: Feb 10 2016
Finally made another hack, this one was a lot bigger than my other ones in terms of the amount of code I had to manipulate.  I started out this project when somebody mentioned changing knockback to a pull, which I thought to be a fun enough idea to try.  Looking into the code it looked like a bigger project than my previous ones but still possible with my limited knowledge of code.  The main problems I ran into here was the limited amount of code space for what I wanted to do and an oddity with loading signed and unsigned values and putting them through a greater than/less than comparison.  I didn't really learn a lesson here as I still don't really understand why it worked/didn't work the way it did. :)

The hack will add the option on a knockback ability.  I use the X value as it is unused in the only vanilla knockback formula(37) so if you've added knockback to another formula which does use the X value, this hack will mess up your knockbacks.  So this will work for any ability with knockback, if you want to keep the knockback as knockback, leave the X value at 0, if you want it to be a pull instead, change it to 1(higher numbers also cause a pull)

I also got rid of the immortal flag blocking knockback to make room for this, so again if being immortal makes knockback ineffective is vital for you, this is not the hack for you.

Knockback/Pull option on knockback attacks


BATTLE_BIN
offset=0011d3ec
E0FFBD27
1C00BFAF
1800B2AF
1400B1AF
1000B0AF
1980053C
982DA58C
1980043C
942D848C
8201A290
1980013C
76004014
F9382190
21580100
4700A990
47008390
4800A690
48008290
23402301
2338C200
02000105
21200001
23200400
0200E104
2118E000
23180300
21802001
2A106400
0B004010
2188C000
05000019
00000000
10006019
00000000
1100601D
00000000
0F006019
00000000
0A00601D
00000000
0500E018
00000000
0C006019
00000000
0D00601D
00000000
0B006019
00000000
0600601D
03000434
37110608
01001026
01000434
37110608
FFFF1026
02000434
37110608
01003126
21200000
FFFF3126
21280002
8411060C
21302002


I have only tested this in psxfin, with the amount of issues I had getting it to work in that emulator, I would not be surprised if it does not work in other emulators.  Post here if it doesn't work in anything so people will know(I likely won't fix it as I don't like other emulators. :P)

Jumza

Nice job :o These are very cool hacks!
  • Modding version: PSX
Nyzer: Alma teleports out of her own possessed body.
Raijinili: Remember that you're telling a modding community that the game they love could use some fixing.

Choto

Nice job in helping yourself learn ASM. I hope the resources we provided here helped alot. If you have any questions you can always ask. We enjoy helping people who take the time to read and learn as much as they could. 

Rodil

Bump for knockback ASM update, see bottom of original post.