Jump to content

Need help using UPKUtils/PatcherGUI


Mrwatsyoname

Recommended Posts

So I finally figured out how to display 3 item slots in EW (with the help of this link: https://forums.nexusmods.com/index.php?/topic/967933-r-d-inventory-items-weapons-overhaul/page-3) and wish to upload it to the nexus through PatcherGUI, but can't seem to get PatcherGUI to make the process simpler. Here is what I have so far:

 

MOD_NAME=Additional Item Slots for EW(Amineri Edition)
AUTHOR=MrWatsyoname (kinda)
DESCRIPTION=This mod is a recreation of a Hex Edit Amineri did to allow for 3 small item slots to be displayed in EU. Unfortunately, you will have to change the default value of Small items on all armor types on your own.
Version 1.0
Compatible with EW version:
- Patch 3 (Changelist: 402256)
UPK_FILE=UICollection_Strategy_SF
OBJECT=gfxSoldierLoadout
OFFSET=0x724DD5
[MODDED_HEX]
96 09 00 04 01 08 02 07 FB FF FF FF
Can anyone tell what I did wrong?
Link to comment
Share on other sites

It's been too long since I did any patching in XCOM to help with the code, but the way you phrased your question suggests some confusion with the role of PatcherGUI.

 

PatcherGUI is a replacement (and enhanced) tool for the long discontinued "ToolBoks" tool. As such it supports "ToolBoks" patches (using the correct comment type), but also adds other mechanisms. There are several different mechanisms defined in the "PatchUPK_Readme.txt" file included in the tool archive. It does not upload or download anything to or from Nexus. You need to do that either manually or with a "mod manager".

 

Your patch code is using the"ToolBoks-style OFFSET" method, which the community has shied away from since it was discovered that every patch released tended to break mods using that technique. The "offset" is an absolute location from the beginning of the file, and patches (official and mod imposed) can move that specific target code offset location. Even at this late date, last I knew it was not considered particularly "safe" from the effects of changes. Authors shy away from having to constantly update a mod. That offset is the most likely source of your problem.

 

In general you need to either replace an exactly equal number of bytes, or you have to move some existing code (within the overall same number of bytes in that section) to make room for your extended length code. Moving code is considered an "advanced" technique.

 

The use of "Find-and-replace (FNR) style patching (UPKModder compatibility)" and "pseudo-code" is more common. It's reasonable to assume you are searching for the default vanilla values. There is an example mod in the PatcherGUI archive under the "Mods" sub-folder. Also, see some of the mods by the author of the tool (wghost81) such as "XCOM Interface and Gameplay Tweaks" for examples. If you click on her name under "uploaded by" on any of her download pages it will take you to her profile page. Click on the "User Files" tab to get a list of her uploads.

 

[Edit for typos and clarity.]

 

-Dubious-

Link to comment
Share on other sites

To rephrase what ~Dubious~ said: Your modding is so 2013 ...

 

IF you are having trouble with PatcherGUI finding your function THEN I recommend starting with:


UPK_FILE=UICollection_Strategy_SF.upk

 

OBJECT=gfxSoldierLoadout:AUTO

  • "gfxSoldierLoadout" really should be in form "class.function"; example (from EU) :
    • UPK_FILE= XComGame.upk
    • OBJECT=XGCharacter_Soldier.AddXP:AUTO

 

 

 

Personally, I prefer to use PatcherGUI's [bEFORE_CODE] ... [/bEFORE_CODE] & [AFTER_CODE] ... [AFTER_CODE] sections ?

 

The UPKUtils program HexToPseudoCode should be able to give you the entire PseudoCode for "gfxSoldierLoadout" (which I am presuming is a function and not a data-reference) to put in the "BEFORE_CODE" section.

 

UE Explorer should be able to help identify which hexadecimal values go with which script/pseudocode names.

 

Once you have the proper modded PseudoCode for the "AFTER_CODE" section - PatcherGUI should be able to do any required resizing; something that Amineri probably wasn't doing back in 2013.

 

ONLY after you have tested that PatcherGUI can install (and uninstall) the mod, and hopefully have checked to see that the mod is working as desired, will you be ready to zip (rar or whatever) your <mod_filename>.txt along with supporting documentation (i.e. readme.txt file) and upload the results (from zip / rar / etc.) to the Nexus Mods pages.

 

~JDDysart

 

EDIT:

Unless "UICollection_Strategy_SF" is a class that contains the function "gfxSoldierLoadout" in which case you need to find the UPK_FILE=<name.upk> that contains said class with said function and use:

(I checked and this is not your case - still might be worth saying for others)

OBJECT=UICollection_Strategy_SF.gfxSoldierLoadout:AUTO

[bEFORE_CODE]

.

.

.

[/bEFORE_CODE]

 

[AFTER_CODE]

.

.

.

[/AFTER_CODE]

 

~ JDDysart

Edited by JDDysart
Link to comment
Share on other sites

  • 2 weeks later...

I appreciate the help but I still can't seem to make any progress. Every time I change my installation txt. file (to get it to work) and have PatcherGUI try to use it I always get the following: "Failed to create backups!" > "Error Patching UPK!" > "Failed to copy the file ....................... '(error 0: the operation completed successfully)"

I have no idea what is causing the problem but I suspect it is because of the way I wrote the installation txt. file. One example of a mod using PatcherGUI looked like this:

MOD_NAME=My SHIV is Special
AUTHOR=Peasly Wellbott
DESCRIPTION=Opens SHIVs to customization.
Version: 1.0
Compatible with XCOM Enemy Within/Enemy Unknown versions:
- All hopefully
UPK_FILE=XComStrategyGame.upk
OBJECT=XGSoldierUI.UpdateMainMenu
[bEFORE_CODE]
<IsATank> 16 18 20 00 19
[AFTER_CODE]
<IsInPsiTesting> 16 18 20 00 19
I see that the author has included <...> here but I have no idea what purpose it serves. Also (I probably should have asked sooner) but what exactly is an OBJECT?
Link to comment
Share on other sites

 

Also (I probably should have asked sooner) but what exactly is an OBJECT?

 

In the context of UPKUtils & PatcherGUI (in extremely technical terms) an object is something that may be accessed via a 'named reference' to a "serialized" (i.e. indexed) location. If you have been using the Unreal-Engine Explorer (a.k.a. UE Explorer) to view what is in an Unreal-Package (a.k.a. UPK) file, then you may more easily understand what follows.

 

A UPK file is a container of various "objects" addressed via one of three tables: the "Names" table (contains simple 'unique' names), the "Exports" table (contains complex names, of 'objects' contained in this file), and the "Imports" table (contains complex names, of 'objects' contained in another file). Simple names are unqualified single level names, such as "IsATank" and "IsInPsiTesting". Complex names are qualified multi-level names, such as "XGStrategySoldier.IsATank" and "XGStrategySoldier.IsInPsiTraining". A top-level 'object', in Unreal-Script, is a 'Class object' defined by a "UC" (Unreal-Class) tag; which (in unexpanded form) is what you first see on the "Objects" tab in UE-Explorer; of course these 'Class Objects' may be expanded to show 'sub-objects' (with various 'U?' tags).

 

PatchUPK.exe uses the Less-Than ("<") and Greater-Than (">") symbols in place of quotes to designate 'pseudo coded references' that need to be resolved into 32-bit index values for one of the three primary tables in a UPK file. A qualified reference (i.e. name - such as "XGStrategySoldier.IsATank" or ".IsATank" - the "." in ".IsATank" does make a difference) resolves to a single 32-bit value, while an unqualified reference (i.e. name - such as "isATank") resolves to a double 32-bit value (a 32-bit index-value followed by a 32-bit "0" numeric-value). And then there are the serialized size (length) vs the memory size (length) issues, which is the main reason for using the ?_CODE sections - so that PatchUPK.exe can handle these (usually confusing) issues; which works really well when all the serial (index) values are properly pseudo-coded. An unresolvable "pseudo coded reference" will cause PatcherGUI to "Fail" when attempting to "apply" a patch.

 

The "unable to create backup" error is indicating a problem with placing a copy of the pre-modification-UPK-file (the "XComStrategyGame.upk" file in your example) in the designated backup location. Might be caused by failing to designate a valid 'backup path", see PatcherGUI's "Advanced" menu for the "Settings" (Program Settings) window - which should have valid values for three critical paths; or possibly, for whatever reason, the program is unable to write (a file of that size) to the backup location. Speaking of which, it might be considered as 'a good policy': when uninstalling a patch - do "clean up" (at least some of) this backup location.

 

I sincerely hope some part of the above is of some use to you, Good Luck!

 

~ JDDysart

Link to comment
Share on other sites

  • 2 weeks later...

I think I found the problem. I have a UICollectionblahblah.upk that contains the hex edit required to allow the soldier loadout screen to be able to show 3 small item slots and figured I could just dump the hex edit into PatcherGUI. As it turns out, however, my modified UICollection....upk was actually a decompressed upk file. This whole time I was trying to make Xcom's compressed upk file use a hex edit for a decompressed upk. I guess that means that using PatcherGUI's "Pseudo Code" function is the only way to get the results I want, but all the examples I see of pseudo code have contain hex values. For example:

UPK_FILE=XComGame.upk
OBJECT = XGTacticalGameCore.GetXPRequired
FIND_CODE = 0F 00 <.iXPRequired> 1D <%u 10000000>
MODDED_CODE = 0F 00 <.iXPRequired> 1D <%u 99999>
I presume that the hex values indicate where that specific string of code is, but 1: How do you even find that out and 2: Wouldn't those values be irrelevant because PatcherGUI injects things into a compressed upk file (while these reference a decompressed file)?
Link to comment
Share on other sites

Back to basics ...

 

First on the 3 small item slots? Are you wanting to add slots to a particular armor? or be able to see lower slots (on the load-out screen) after you have added slots to a particular armor?

 

To add slots - use PatcherGUI to enable INI loading - then change the Armor line(s) in the DefaultGameCore.ini file.

To see lower slots - when you add too many? - you will need an actual mod to do this.

 

Then on to modding basics ...

 

Have you reviewed what is available on the XCom Wiki? in particular have you seen the "Hex values XCOM Modding" article? Do you have access to the UE Explorer ("Unreal Engine" Explorer)?

 

UPK files are "Unreal Package" files ... similar to DLL files (if you have any experience with them?) ... this is a collection of what programmers refer to as "object code modules", with several of these packed into each UPK file. Similar to ZIP files - UPK file contents may be uncompressed, (partially compressed?) or fully compressed. UE Explorer won't work with FULLY COMPRESSED UPK files; but PatcherGUI (or actually PatchUPK) checks for compression state then deals with what it finds.

 

PatcherGUI, which you should know - if you have read the ReadMe.txt files that come with it, replaces the need to manually "hex edit" UPK files ... PatcherGUI does such editing for you! based on the pseudo-coded contents of a text file.

 

The general modding procedure is to use UE Explorer to find the function (or whatever) that you want to modify (and to get some ideas on what you want to modify whatever to);

... then either copy mixed code from UE Explorer or use HexToPseudoCode (from the UPKUtils toolkit) to get the before code;

... once you have the before code - you then have to "MODIFY" it (based on what you are wanting to do) to get the after code;

... finally you put the before code and after code together in a PatcherGUI text file and attempt to apply it to the UPK file of your choice.

And if the mod you are making is not for JUST your personal use, then it needs to be extensively tested before you publish it.

 

BUT PatcherGUI does have some paths that must be properly set before it will work; one of these is the "Backup path".

 

From personal experience, I know that the 0F 00 in your example is a length value, in pseudo-code you might use [@] where you want a length value, followed by "(" & ")" around what you are wanting the length of. The 1D Is an "Unreal Token" specifying that an unsigned-32-bit-integer value follows (the %u in your example, with a value of 10000000 being replaced with a value of 99999). What is actually happening in your example is that PatcherGUI is setting the RelativeOffset to where it finds that particular string of code within OBJECT=XGTacticalGameCore.GetXPRequired, then placing the modded code value at that relative offset, while updating the memory and serial sizes as needed for <iXPRequired>.

 

A good place to start learning might be to get the entire mixed code (hex & pseudo) from HexToPseudoCode of XGTacticalgameCore.GetXPRequired (from the XComGame.upk file), and place all of it in a [bEFORE_CODE] ... [/bEFORE_CODE] section. Then find the code string that is being altered and see if you can write the [AFTER_CODE] .. [/AFTER_CODE] section? Clue: for this mod you need to make sure that the before code and after code both start with same code and both stop with the same code (and the UPK_FILE= and OBJECT= lines go above the before code section). Caution: if you have the Display Soldier's XP, PsiXP & Mobility mod already installed - then the mod you are writing may conflict with it!

 

Hopefully something above helps,

 

~ JDDysart

Link to comment
Share on other sites

  • 2 weeks later...
  • Recently Browsing   0 members

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