Jump to content

Help starting with PatchUPK


amaciel81

Recommended Posts

Hi,

I'm starting with PatchUPK and I could perform a couple of changes using BEFORE_CODE/AFTER_CODE:

// AS_AddResource(class'UIUtilities'.static.GetHTMLColoredText((m_kMgr.GetResourceLabel(0) $ ":") @ m_kMgr.ConvertCashToString(iCash), ((iCash > 0) ? 6 : 3)))
[BEFORE_CODE]
1C 0E 1E 00 00 12 20 65 FE FF FF 6F 00 4D F9 FF FF 00 1B 35 12 00 00 00 00 00 00 A8 70 19 01 AA 1D 00 00 0B 00 62 09 00 00 00 1B 25 13 00 00 00 00 00 00 25 16 1F 3A 00 16 19 01 AA 1D 00 00 13 00 5F 09 00 00 00 1B 2C 07 00 00 00 00 00 00 00 C8 1D 00 00 16 16 45 97 00 C8 1D 00 00 25 16 02 00 2C 06 02 00 2C 03 4A 16 16
[/BEFORE_CODE]

// AS_AddResource(class'UIUtilities'.static.GetHTMLColoredText((m_kMgr.GetResourceLabel(0) $ "==:==") @ m_kMgr.ConvertCashToString(iCash), ((iCash > 0) ? 6 : 3)))
[AFTER_CODE]
1C 0E 1E 00 00 12 20 65 FE FF FF 6F 00 4D F9 FF FF 00 1B 35 12 00 00 00 00 00 00 A8 70 19 01 AA 1D 00 00 0B 00 62 09 00 00 00 1B 25 13 00 00 00 00 00 00 25 16 1F <%t "==:=="> 16 19 01 AA 1D 00 00 13 00 5F 09 00 00 00 1B 2C 07 00 00 00 00 00 00 00 C8 1D 00 00 16 16 45 97 00 C8 1D 00 00 25 16 02 00 2C 05 02 00 2C 03 4A 16 16
[/AFTER_CODE]

However, if I try to duplicate the [AFTER_CODE] line (so I replace the command by two), the code looks perfect in UE Explorer, but the game crashes. What I'm missing here?

 

Thanks,

Link to comment
Share on other sites

I remember having the same problem when I first started modding XCom - the code looks fine but it crashes. If you're increasing the size of the function you'll have to expand it. Your header should look something like this:

 

UPK_FILE=XComStrategyGame.upk
EXPAND_FUNCTION=XGStrategySoldier.RebuildAfterCombat:0x0700
OBJECT=XGStrategySoldier.RebuildAfterCombat:AUTO

If you code moves the locations of any jumps then they'll have to be updated as well. Which is a huge pain!

 

Personally, I'd recommend that you use the HexToPseudoCode.exe utility to decode the entire function and then change it as you like. You won't have to worry about memory sizes and jump targets as it will handle everything for you. The pseudo code it also much easier to read than plain hex. The other benefit is that you can keep making changes and re-applying the patch as you're replacing the entire function in one go - you won't have to uninstall each time.

Edited by SpazmoJones
Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...