eterniti / xv2patcher

A dll that patches Xenoverse 2 to improve modding functionalities
12 stars 5 forks source link

Possible Fix for cast character's not resetting size when using skills that change BCS Body ID #7

Open Dee-Ayy opened 6 months ago

Dee-Ayy commented 6 months ago

So there's a bug when using skills on cast characters that change their BCS Body ID such as Become Giant.

Manually activating and cancelling the transformation will work as expected, but being forced to detransform (losing stamina, getting hit with Fu's Remote Serious Bomb) or using the reset option in Training/Photo Mode with not correctly reset the character to default size leaving them still in the changed size.

I narrowed down this bug to the code that starts at DBXV2.exe+D4230. Specifically:

mov esi,[rcx+000000C4]
...
cmp esi,-01
jng DBXV2.exe+D4382

mov esi,[rcx+000000C4] is loading the character default Body ID into ESI (set on match load). later cmp esi,-01 compare the value to -1 then jumps ahead if it's not greater than that effective skipping the reset code.

My fix for this was to simple change jng DBXV2.exe+D4382 to instead be

jg DBXV2.exe+D424E
xor esi,esi

the first line simply jumps ahead to the opcode right after jng DBXV2.exe+D4382 which continues the function as intended (effetely no difference whatsoever for CaCs) and the second line clears the ESI making it 0 if it's not already at least 0, then continuing the code as if 0 was always the intended Body ID.

So in all, this fix makes all cast characters load 0 as their Default Body ID which will allow them to properly revert their size when forced to detransform.

eterniti commented 1 month ago

For the moment, this patch won't be applied, as it has been found to have side effects with "pseudocacs" (x2m generated by cac2x2m and Cycit). (Not only when using the giant skill, but also since the beginning of the battle)

Because these characters also have several bodies like cacs, by forcing the load of body 0, they're forced to load their smallest body, changing their stature (unless they were already using body 0).

I'll have the location into account for a future more complex patch where I locate the default body. (the default body for these psuedocacs is actually saved in pre-baked.xml )

So the idea would be to hook the function, and change the field C4 (body) before the function call, to either the body in pre-baked.xml (if exists) or 0 if it doesn't. Then at function return, restore C4 to original value.

eterniti commented 1 month ago

Ok, I have applied the idea that I wrote in earlier post. It should work fine. I'll keep this open just in case some other unknown side effect appears in testing.

Dee-Ayy commented 1 month ago

Oh nice, I wasn't thinking about how X2M character would work when doing this. Thanks again for looking into this!