sagefantasma / MGS2-Cheat-Trainer

Just a simple Cheat Trainer C# VS Form for MGS2 on the Master Collection.
MIT License
3 stars 1 forks source link

Enable HF Blade to be used outside of only Arsenal #14

Closed sagefantasma closed 3 months ago

ANTIBigBoss commented 6 months ago

I just wanted to put a note in here about what I think the solution may be for this. I imagine the GCX is what tells the game what models/weapons/items to allow as that's how it's worked in other MGS games I've worked on. This is just a shot in the dark but seems plausible. I'll slap this in the allowing Snake disallowed weapons too since I imagine the solution will be similar for both.

EDIT: Not sure how this would work in conjunction with the trainer since we'd need to edit game files directly.

sagefantasma commented 4 months ago

After spending entirely too many hours on this, I've identified that @ANTIBigBoss is right - the HF blade's use is determined per stage. I did an ass-load of investigation and research, but I've reached my wits end with this atm. I've put all the related findings and notes in the /Resources/Documentation/gcx_investigations in case I, or anyone else, wants to try and pick this up again.

Short end of the long: whenever you load into a level where the H.F. Blade is enabled, the game's memory will load the rai_blade.sar file, which instructs the game on how to actually use the H.F. Blade. rai_blade.mar is seemingly loaded every time(at least with levels with Raiden), which is what instructs the game on the animations to use for the H.F. Blade(hence why the sword will appear on Raiden's back, and he'll go into the "sword ready" position when you equip it). From looking at the MGS2 Substance release, it appears the relevant gcx files reference .command(code("bladeply_init")). The two problems I'm currently running into here are this(and I'm too frustrated to figure out how to fix them right now): 1) The MGS2 Master Collection gcx files seem to have their resources encrypted similarly to MGS3 and MGS4 - this can be identified by cross-examining the PC Substance release gcx files with their modern Master Collection counterparts. 2) There is (seemingly) no way to recompile a GCX file either way, so actually modifying the gcx file doesn't even provide a solution. My only guess at this point is maybe there's someway to inject an instruction to MGS2 to load the rai_blade.sar file? But idk how to do that.

sagefantasma commented 3 months ago

Remember that time I said I was at my wit's end with this and was going to put this down? That was a good joke. I didn't stop, at all.

After another 3 weeks of active work on this, I am officially deigning this and #13 as, presently, out-of-scope. I'll try and organize the absolute monolith of notes I took during my investigation of the game code, but it looks like it goes even further than just being related to the gcx: essentially every level is it's own program. In order to implement either this ticket or #13 I believe one of the two options exists: 1) modify each stage's .gcx, manifest, and bp_asset to reference the desired functionality. This way, the game will automatically "load" the instructions for the "new" behaviors(blade, normally unusable weapons, etc), and would hopefully automatically take care of everything itself. Taking care of the manifest and bp_asset is straight-forward enough, but the data from those doesn't seem to get loaded for some reason, and I'm guessing it's related to something in the .gcx files instructing the .exe on what assets to load - not really clear on that as decompiling gcx files is doable, but not really readable. Even then, currently recompiling gcx files isn't possible - theoretically it could absolutely be done, but nobody has bothered and I can't be bothered to do it myself right now. Which leads to 2) monitoring what weapon the player has equipped, and essentially hot-redirecting the .exe to an injected .dll that instructs the game on how to handle the given weapon that isn't natively usable. This is very much out of my wheelhouse, and I am sure I'm over-simplifying the amount of effort it would take to accomplish this.

All of that to say, right now(unless someone smarter than me figures out a better way of doing this/actually how to do it), this is wildly out-of-scope for a cheat trainer: this isn't just enabling an existing functionality in the game, it is essentially creating an entirely NEW functionality to parts of the game that don't already have it. Definitely not what you would really expect a cheat trainer to be able to do. So that's my excuse for dropping this right now :(