Author Topic: Change the workings of a materia  (Read 6479 times)

Tenko Kuugen

  • Public Enemy
  • *
  • Posts: 1416
    • View Profile
    • Twitter
Change the workings of a materia
« on: 2010-09-11 07:04:59 »
In general, I want to abolish the
"Red master materia enables all summons infinite times" thing
and
"Can't sense" on boss monsters or those with too much HP
The question is, where do I even find that data? a search on "Sense" "Materia command" or similiar stuff returned nothing in the wiki and the forum search. From what I gather, back in the day ( 2001, 2004, 2006 ) people said that that stuff is in the battle engine. Now, we have wallmarket and dozens ( or close to ) of other editors, but none seem to really edit the workings of materia such as deathblow, steal, sense, and other command materia. Is that all still undiscovered info or am I just not looking hard enough? ( seeing how battle mechanics is still without page on the wiki, I guess it's still undiscovered info. makes me wonder if it ever will be discovered )

Kudistos Megistos

  • Banned
  • *
  • Posts: 3929
    • View Profile
Re: Change the workings of a materia
« Reply #1 on: 2010-09-11 10:13:13 »
The effects of commands are in the .exe, I believe, and that part of it hasn't been reverse engineered yet. The same is true of the "materia type" effects (as they are called in Wallmarket). 

nfitc1

  • *
  • Posts: 3011
  • I just don't know what went wrong.
    • View Profile
    • WM/PrC Blog
Re: Change the workings of a materia
« Reply #2 on: 2010-09-11 14:53:12 »
The effects of commands are in the .exe, I believe, and that part of it hasn't been reverse engineered yet. The same is true of the "materia type" effects (as they are called in Wallmarket).

This is indeed correct. I stumbled upon the materia type handlers a few weeks ago and they are very strictly coded to do what they do. Almost all functions in this game are coded into the executable. You could change the materia type of the master summon to make it some other materia, but it's type will always create a "master summon" effect.

For more info, check out the new Materia type page on the wiki authored by yours truely. It is a definitive (thought not technically complete) list of materia type functions. Adding is much harder than taking away. It IS possible to make a type do nothing, but not so easy to grant it new functionality.

halkun

  • Global moderator
  • *
  • Posts: 2097
  • NicoNico :)
    • View Profile
    • Q-Gears Homepage
Re: Change the workings of a materia
« Reply #3 on: 2010-09-11 16:24:19 »
keep in mind fieldscript can check your inventory, so you have have field-effect mareia with a litttle creative fieldscripting. (Read:underwater)

Bosola

  • Fire hazard!
  • *
  • Posts: 1752
    • View Profile
    • My YouTube Channel
Re: Change the workings of a materia
« Reply #4 on: 2010-09-11 16:37:45 »
In general, I want to abolish the
"Can't sense" on boss monsters or those with too much HP

My first instinct would be to use a debugger when Sensing, and watch those registers carefully for whatever the threshold value is. From there, I'd try and trace back the logic and see where in the executable the number comes from.

The other functions would be hard to work with. I wonder if anyone has ever pushed FF7.exe through something like Boomerang etc?


Tenko Kuugen

  • Public Enemy
  • *
  • Posts: 1416
    • View Profile
    • Twitter
Re: Change the workings of a materia
« Reply #5 on: 2010-09-11 22:15:33 »
In general, I want to abolish the
"Can't sense" on boss monsters or those with too much HP

My first instinct would be to use a debugger when Sensing, and watch those registers carefully for whatever the threshold value is. From there, I'd try and trace back the logic and see where in the executable the number comes from.

The other functions would be hard to work with. I wonder if anyone has ever pushed FF7.exe through something like Boomerang etc?

That sounds well past my skills.
I assumed that, in case of the red master materia, the function does dictate a number of usages ( ala if 255 = infinite ) but I guess it doesn't and it's a hardcoded "enable function" type of thing, as far as I can tell from my limited knowledge.

I did think it should be possible to 'adjust' the top value of the sense command to something so high that it's working on everything, since the game has to detect SOMEHOW which mob can be sensed or not depending on how high it's HP are. ( I have seen nothing like a check for that in Hojo nor Prod, so I'm pretty sure it's handled via a check on the MHP )

Is there any hope of that stuff ever getting reverse engineered? Tbh, I don't mind the master summon as much as how useless sense becomes in the hardcore mod ( and especially my version of it )

Bosola

  • Fire hazard!
  • *
  • Posts: 1752
    • View Profile
    • My YouTube Channel
Re: Change the workings of a materia
« Reply #6 on: 2010-09-12 02:18:57 »
It is done by checking HP. But it would be difficult to move that stat above 65,535HP (one word), because then you'd probably need to change the layout of bytes.

An easier method would be to patch the mod so that HP remained within the 10k mark. Lower the damage / HP normally worked with, then worry about the sense command.

The reverse engineering would be doable, but simple? I'm really not sure. It could be really trivial to find (a certain opcode simply pushes this and that data into a register, and checks) or more complicated.

Gemini

  • *
  • Posts: 260
  • Not learner's Guru
    • View Profile
    • Devil Hackers
Re: Change the workings of a materia
« Reply #7 on: 2010-09-12 06:42:51 »
Put a read-breakpoint on a monster HP parameter and see where it copies that for in-battle stats, then remove the original breakpoint and set another read one on the copied HP value (this should pause the game each frame). Activate Sense and see if there's an additional process accessing the HP copy value: that's 100% sure the Sense initiation code.

Tenko Kuugen

  • Public Enemy
  • *
  • Posts: 1416
    • View Profile
    • Twitter
Re: Change the workings of a materia
« Reply #8 on: 2010-09-12 10:27:49 »
It is done by checking HP. But it would be difficult to move that stat above 65,535HP (one word), because then you'd probably need to change the layout of bytes.

An easier method would be to patch the mod so that HP remained within the 10k mark. Lower the damage / HP normally worked with, then worry about the sense command.

The reverse engineering would be doable, but simple? I'm really not sure. It could be really trivial to find (a certain opcode simply pushes this and that data into a register, and checks) or more complicated.

Lowering the HP would defeat the purpose of the mod in the first place. beside that, I am aware that it's probably limited to 65,535 ( FFFF ). And changing that to a long word to allow for FFFFFFFF is.. well. I don't know how difficult that is, but likely VERY. For now I neither have the knowledge to do near any of the stuff you guys mentioned, nor the time to actually learn how to do it.

At least I tried asking.

Bosola

  • Fire hazard!
  • *
  • Posts: 1752
    • View Profile
    • My YouTube Channel
Re: Change the workings of a materia
« Reply #9 on: 2010-09-12 19:35:54 »

Lowering the HP would defeat the purpose of the mod in the first place.

But it wouldn't. Half the HP of everything, and half the damage done, and the mechanics are effectively the same. Tactics was no easier than VII just because it dabbled in the range of 100-300 damage rather than 6000-9999.

Anyway, Gemini's method would work just fine with, say, PSX's R3000 debugger. At least give it a go - you might find it less fearful than you think!
« Last Edit: 2010-09-12 19:38:57 by Bosola »

Gemini

  • *
  • Posts: 260
  • Not learner's Guru
    • View Profile
    • Devil Hackers
Re: Change the workings of a materia
« Reply #10 on: 2010-09-12 19:37:18 »
That should actually work on any machine.

nfitc1

  • *
  • Posts: 3011
  • I just don't know what went wrong.
    • View Profile
    • WM/PrC Blog
Re: Change the workings of a materia
« Reply #11 on: 2010-09-13 03:29:56 »
Put a read-breakpoint on a monster HP parameter and see where it copies that for in-battle stats, then remove the original breakpoint and set another read one on the copied HP value (this should pause the game each frame). Activate Sense and see if there's an additional process accessing the HP copy value: that's 100% sure the Sense initiation code.

Not quite. You'd eventually find that after a lot of function returns, but by the time you're reading the HP, you've already looked up a battle text index and parsed it, then started looking for the values that fill it:

1. Activate Sense
2. Read Battle Text from the KERNEL
3. Find where special characters are
4. Retrieve values for characters *
5. Display string

You'd get to the * and you'd be able to step your way out of there back to where step 2 was called at least. Figuring out where that is though.... It might be easier to figure out where the ATB is stored for each character (It's bound to be where the character battle data is which is known) then see where the menu handler is, then the command handler, and then see where command "Sense" goes when it is activated.


UPDATE :


Kernel2 text is stored in memory at 0x9A13C8
Kernel2 file offsets are stored in memory at 0x9A7FC8

All data between those addresses is allocated for text from the kernel2 file.

THEREFORE: THE TOTAL SIZE OF THE UNCOMPRESSED DATA FROM THE KERNEL2 FILE, INCLUDING TEXT POINTERS, CAN BE NO LARGER THAN 27648 (27KB) BYTES IN SIZE!!!

I say that in Billy Mays mode because there's always been some confusion about this. This will likely be written into the next WM version.
« Last Edit: 2010-09-21 19:51:17 by NFITC1 »