Jump to content

UPK Utils


wghost81

Recommended Posts

Because the new code is longer than original one. You need to resize the function properly to fit the bigger code inside.

 

"It wrecks everything" isn't much helpful in locating the source of a problem. :wink: You need to post an entire mod file for me (or someone else) to be able to see what's wrong with it.

Link to comment
Share on other sites

  • 3 months later...
  • Replies 235
  • Created
  • Last Reply

Top Posters In This Topic

Hi, I'm trying to get use your program, PatcherGUI or UPK Utils to solve an issue I've run into while hex editing.

 

 

0F 35 03 FB FF FF B1 F9 FF FF 00 00 35 BC F8 FF FF A5 F9 FF FF 00 01 19 01 39 2C 00 00 09 00 60 53 00 00 00 01 60 53 00 00 19 19 1B 6B 03 00 00 00 00 00 00 16 09 00 AE 31 00 00 00 01 AE 31 00 00 0D 00 96 FB FF FF 00 1B 9F 12 00 00 00 00 00 00 24 00 28 16

m_kSoldier.m_kSoldier.kAppearance.iVoice = BARRACKS().m_kCharGen.GetNextMaleVoice(0, false)

 

 

This line has "GetNextMaleVoice" in the XcomStrategyGame.UPK, but the alternative "GetNextFemaleVoice" is not in the same UPK file so I can't do a simple hex swap to get it to change. I noticed "GetNextFemaleVoice" is used in XcomGame.UPK and I was wondering if there's a way I can export that line and apply it here.

*****EDIT**** I'm not sure what the terminology for this would be*

 

Also, I'm having issues figuring out how to use UPK Utils. I can't get these programs to do anything, it's like a puzzle to me at the moment. I've never had to use programs like these so I don't understand some of the directions in the read me file. They come off as extremely vague.

 

Like.... where do I type in this command? Command Prompt? ExtractNameLists.exe XComStrategyGame.upk > XComStrategyGame.txt

 

Do I have to create the txt file beforehand, and if so where do I put it?

 

I tried just dragging XComStrategyGame.UPK to the ExtractNameList.exe and it seemed to do something. The command prompt window came up and then it disappeared after flying through with some data.

 

I appreciate the help.

Edited by Kaldreth88
Link to comment
Share on other sites

Thaaaaaaaaaaaaaaaaaaaaaaaaaaank YOU !!!

(yes you, there, I point myindex at you !!!)

 

but !!! Still need some help...

 

I tried some things... (Oki, I admit I am a sloooooooooooooooooooooooooow modder, or I take a loooooooooooooooooooooooooong time to make tests... Depends on the PoV :p)

 

UPK_FILE=XComStrategyGame.upk
OBJECT=XGShip_Dropship.GetCapacity:AUTO
[FIND_HEX]
A5 00 B9 4B 00 00
[MODDED_HEX]
A1 00 B9 4B 00 00 2C 04

 

 

It made it "less worse" than my initial trials, but, hummm...

 

 

 

function int GetCapacity()
{
local int iCapacity;

iCapacity = m_iCapacity;
// End:0x43
if(BARRACKS().HasOTSUpgrade(1))
{
iCapacity += 4;
}
// End:0xA2
@NULL = @NULL != iCapacity == if(m_bExtendSquadForHQAssault)
{
iCapacity = HQASSAULT_REINFORCEMENT_CAPACITY;
}
Clamp(iCapacity, 8, 12);
// End:0xBB
if(m_bReinforcementsForHQAssault)
{
}
iCapacity = 14;
// End:0x320
if((HANGAR().m_kSkyranger != none) && HANGAR().m_kSkyranger.m_kMission != none)
{
// End:0x258
if(ENGINEERING().IsFoundryTechResearched(37))
{
// End:0x19E
if(HANGAR().m_kSkyranger.m_kMission.m_iMissionType == 8)
{
}
iCapacity += 2;
// End:0x1FB
if(HANGAR().m_kSkyranger.m_kMission.m_iMissionType == 13)
{
}
iCapacity += 2;
// End:0x258
if(HANGAR().m_kSkyranger.m_kMission.m_iMissionType == 10)
{
}
}
iCapacity += 4;
// End:0x2B4
if(HANGAR().m_kSkyranger.m_kMission.m_iMissionType == 5)
{
}
iCapacity = 4;
// End:0x320
if(HANGAR().m_kSkyranger.m_kMission.m_iMissionType != 7)
{
// End:0x320
if(iCapacity > 12)
{
}
}
}
iCapacity = 12;
}

 

 

 

 

 

 

 

 

Link to comment
Share on other sites

Kaldreth88, UPK Utils are Windows (Linux/Mac) command line tools. You can use PowerShell or cmd under Windows to work with these. Please, consult your Windows manual on how to work with command line tools.

 

PatchUPK is the main tool to patch upk files. It accepts txt files, parses them and performs necessary modifications. You can use it directly via command line or you can use PatcherGUI which basically is a GUI wrapper around PatchUPK.

 

PatchUPK has it's own readme which explains how keys and sections work. Also, there is a main UPKUtils readme which explains how to use different utilities.

 

If you explain what exactly you are trying to do, I can guide you through it.

 

LeMagos, I can't understand the question. What seems to be the problem here?

Edited by wghost81
Link to comment
Share on other sites

Note I suck at proof reading... I forgot half my post...

 

Note 2: I am BAD with forum formatting...

 

Note 3: the iCapacity += 4 is only there because I randomly hit the 4 key, It could have been iCapacity += 3, iCapacity += 2, iCapacity += 1, etc.

 

I have

 

 

function int GetCapacity()
{
local int iCapacity;

iCapacity = m_iCapacity;
// End:0x43
if(BARRACKS().HasOTSUpgrade(1))
{
iCapacity += 4;
}
// End:0xA2
@NULL = @NULL != iCapacity == if(m_bExtendSquadForHQAssault)
{
iCapacity = HQASSAULT_REINFORCEMENT_CAPACITY;
}
Clamp(iCapacity, 8, 12);
// End:0xBB
if(m_bReinforcementsForHQAssault)
{
}
iCapacity = 14;
// End:0x320

No trace of HasOTSUpgrade(2)...

 

When

 

I try to have:

function int GetCapacity()
{
local int iCapacity;

iCapacity = m_iCapacity;
// End:0x43 Loop:False
if(BARRACKS().HasOTSUpgrade(1))
{
iCapacity += 4;
}
// End:0x73 Loop:False
if(BARRACKS().HasOTSUpgrade(2))
{
++ iCapacity;
}
// End:0x8c Loop:False
if(m_bExtendSquadForHQAssault)
{
iCapacity = 6;
}
// End:0xa6 Loop:False
if(m_bReinforcementsForHQAssault)
{
iCapacity += 8;
}
// End:0x30b Loop:False

Link to comment
Share on other sites

wghost81 , I've been making simple hex changes to the XComStrategygame.UPK file and I've come across a bit of code I can't change correctly. More specifically the function he function CreateEasterEggCharacter under the XGCustomizeUi branch.

 

 

(37E/222) [0F 35 03 FB FF FF B1 F9 FF FF 00 00 35 BC F8 FF FF A5 F9 FF FF 00 01 19 01 39 2C 00 00 09 00 60 53 00 00 00 01 60 53 00 00 19 19 1B 6B 03 00 00 00 00 00 00 16 09 00 AE 31 00 00 00 01 AE 31 00 00 0D 00 96 FB FF FF 00 1B 9F 12 00 00 00 00 00 00 24 00 28 16]

 

L(125/85) -> SM(68/40) -> SM(49/29) -> C(30/18) -> IV(9/5) -> IV(9/5) -> C(56/44) -> C(31/23) -> VF(10/10) -> EFP(1/1) -> IV(9/5) -> VF(13/13) -> BC(2/2) -> F(1/1) -> EFP(1/1)
m_kSoldier.m_kSoldier.kAppearance.iVoice = BARRACKS().m_kCharGen.GetNextMaleVoice(0, false)

 

 

I just want to designate a female voice to the character ( I almost don't care if it's random, or a specific voice). I changed everything else to make this a female character already. "GetNextFemaleVoice" doesn't seem to be in the XComStrategygame.UPK at all so I haven't been able to figure out what hex change to make.

 

 

Here's what I've changed so far, and it's pretty messy but I just wanted to play around with the options and make sure I could change things around. The above line has kept me banging my head against a wall for 3 days now. Thanks!

 

 

 

 

(0D4/084) [0F 35 F0 F8 FF FF A5 F9 FF FF 00 01 19 01 39 2C 00 00 09 00 60 53 00 00 00 01 60 53 00 00 10 25 01 3F 2C 00 00]
m_kSoldier.m_kSoldier.strNickName = SuperSoldierNickNames[0]

(111/0A9) [0F 35 0A FB FF FF B1 F9 FF FF 00 00 35 BC F8 FF FF A5 F9 FF FF 00 01 19 01 39 2C 00 00 09 00 60 53 00 00 00 01 60 53 00 00 2C 02]
m_kSoldier.m_kSoldier.kAppearance.iGender = 2

(158/0D4) [0F 35 05 FB FF FF B1 F9 FF FF 00 00 35 BC F8 FF FF A5 F9 FF FF 00 01 19 01 39 2C 00 00 09 00 60 53 00 00 00 01 60 53 00 00 25]
m_kSoldier.m_kSoldier.kAppearance.iRace = 0

(19E/0FE) [0F 35 07 FB FF FF B1 F9 FF FF 00 00 35 BC F8 FF FF A5 F9 FF FF 00 01 19 01 39 2C 00 00 09 00 60 53 00 00 00 01 60 53 00 00 2C 2B]
m_kSoldier.m_kSoldier.kAppearance.iHead = 43

(1E5/129) [0F 35 08 FB FF FF B1 F9 FF FF 00 00 35 BC F8 FF FF A5 F9 FF FF 00 01 19 01 39 2C 00 00 09 00 60 53 00 00 00 01 60 53 00 00 2C 0B]
m_kSoldier.m_kSoldier.kAppearance.iHaircut = 11

(22C/154) [0B]
N(1/1)

(22D/155) [0F 35 0C FB FF FF B1 F9 FF FF 00 00 35 BC F8 FF FF A5 F9 FF FF 00 01 19 01 39 2C 00 00 09 00 60 53 00 00 00 01 60 53 00 00 1D FF FF FF FF]
m_kSoldier.m_kSoldier.kAppearance.iFacialHair = -1

(277/183) [0F 35 04 FB FF FF B1 F9 FF FF 00 00 35 BC F8 FF FF A5 F9 FF FF 00 01 19 01 39 2C 00 00 09 00 60 53 00 00 00 01 60 53 00 00 2C 05]
m_kSoldier.m_kSoldier.kAppearance.iSkinColor = 5

(2BE/1AE) [0F 35 CC FA FF FF A5 F9 FF FF 00 01 19 01 39 2C 00 00 09 00 60 53 00 00 00 01 60 53 00 00 25]
m_kSoldier.m_kSoldier.iCountry = 0

(2F1/1CD) [0F 35 0B FB FF FF B1 F9 FF FF 00 00 35 BC F8 FF FF A5 F9 FF FF 00 01 19 01 39 2C 00 00 09 00 60 53 00 00 00 01 60 53 00 00 25]
m_kSoldier.m_kSoldier.kAppearance.iFlag = 0

(337/1F7) [0F 35 06 FB FF FF B1 F9 FF FF 00 00 35 BC F8 FF FF A5 F9 FF FF 00 01 19 01 39 2C 00 00 09 00 60 53 00 00 00 01 60 53 00 00 2C 08]
m_kSoldier.m_kSoldier.kAppearance.iLanguage = 8

(37E/222) [0F 35 03 FB FF FF B1 F9 FF FF 00 00 35 BC F8 FF FF A5 F9 FF FF 00 01 19 01 39 2C 00 00 09 00 60 53 00 00 00 01 60 53 00 00 19 19 1B 6B 03 00 00 00 00 00 00 16 09 00 AE 31 00 00 00 01 AE 31 00 00 0D 00 96 FB FF FF 00 1B 9F 12 00 00 00 00 00 00 24 00 28 16]
m_kSoldier.m_kSoldier.kAppearance.iVoice = BARRACKS().m_kCharGen.GetNextMaleVoice(0, false)

(3FB/277) [19 01 39 2C 00 00 0B 00 00 00 00 00 00 1B BB 06 00 00 00 00 00 00 4A 16]
m_kSoldier.ClearPerks()

(41B/28F) [0F 35 C7 FA FF FF A5 F9 FF FF 00 01 19 01 39 2C 00 00 09 00 60 53 00 00 00 01 60 53 00 00 2C 01]
m_kSoldier.m_kSoldier.iRank = 1

(44F/2AF) [19 01 39 2C 00 00 0C 00 00 00 00 00 00 1B 1A 2B 00 00 00 00 00 00 24 01 16]
m_kSoldier.SetSoldierClass(1)

(470/2C8) [19 01 39 2C 00 00 0C 00 00 00 00 00 00 1B F2 13 00 00 00 00 00 00 2C 00 16]
m_kSoldier.GivePerk(0)

(491/2E1) [19 01 39 2C 00 00 0C 00 00 00 00 00 00 1B F2 13 00 00 00 00 00 00 2C 00 16]
m_kSoldier.GivePerk(0)

(4B2/2FA) [19 01 39 2C 00 00 0C 00 00 00 00 00 00 1B F2 13 00 00 00 00 00 00 2C 00 16]
m_kSoldier.GivePerk(0)

(4D3/313) [19 01 39 2C 00 00 0C 00 00 00 00 00 00 1B F2 13 00 00 00 00 00 00 2C 00 16]
m_kSoldier.GivePerk(0)

(4F4/32C) [19 01 39 2C 00 00 0C 00 00 00 00 00 00 1B F2 13 00 00 00 00 00 00 2C 00 16]
m_kSoldier.GivePerk(0)

(515/345) [19 01 39 2C 00 00 0C 00 00 00 00 00 00 1B F2 13 00 00 00 00 00 00 2C 00 16]
m_kSoldier.GivePerk(0)

(536/35E) [19 01 39 2C 00 00 0C 00 00 00 00 00 00 1B F2 13 00 00 00 00 00 00 2C 00 16]
m_kSoldier.GivePerk(0)

(557/377) [14 2D 35 2A FF FF FF AF F9 FF FF 00 01 19 01 39 2C 00 00 09 00 61 53 00 00 00 01 61 53 00 00 28]
m_kSoldier.m_kChar.bHasPsiGift = false

(58B/397) [14 19 01 39 2C 00 00 0A 00 55 53 00 00 00 2D 01 55 53 00 00 28]
m_kSoldier.m_bPsiTested = false

(5AC/3AC) [0F 35 C9 FA FF FF A5 F9 FF FF 00 01 19 01 39 2C 00 00 09 00 60 53 00 00 00 01 60 53 00 00 2C 00]
m_kSoldier.m_kSoldier.iPsiRank = 0

(5E0/3CC) [19 01 39 2C 00 00 0C 00 00 00 00 00 00 1B F2 13 00 00 00 00 00 00 2C 00 16]
m_kSoldier.GivePerk(0)

(601/3E5) [19 01 39 2C 00 00 0C 00 00 00 00 00 00 1B F2 13 00 00 00 00 00 00 2C 00 16]
m_kSoldier.GivePerk(0)

(622/3FE) [19 01 39 2C 00 00 0C 00 00 00 00 00 00 1B F2 13 00 00 00 00 00 00 2C 00 16]
m_kSoldier.GivePerk(0)

(643/417) [19 01 39 2C 00 00 0C 00 00 00 00 00 00 1B F2 13 00 00 00 00 00 00 2C 00 16]
m_kSoldier.GivePerk(0)

(664/430) [0F 1A 25 35 FF FA FF FF AF F9 FF FF 00 01 19 01 39 2C 00 00 09 00 61 53 00 00 00 01 61 53 00 00 2C 05]
m_kSoldier.m_kChar.aStats[0] = 5

(69A/452) [0F 1A 2C 07 35 FF FA FF FF AF F9 FF FF 00 01 19 01 39 2C 00 00 09 00 61 53 00 00 00 01 61 53 00 00 2C 37]
m_kSoldier.m_kChar.aStats[7] = 55

(6D1/475) [0F 1A 26 35 FF FA FF FF AF F9 FF FF 00 01 19 01 39 2C 00 00 09 00 61 53 00 00 00 01 61 53 00 00 2C 4B]
m_kSoldier.m_kChar.aStats[1] = 75

(707/497) [0F 1A 2C 0D 35 FF FA FF FF AF F9 FF FF 00 01 19 01 39 2C 00 00 09 00 61 53 00 00 00 01 61 53 00 00 25]
m_kSoldier.m_kChar.aStats[13] = 0

(73D/4B9) [19 1B 01 2F 00 00 00 00 00 00 16 13 00 00 00 00 00 00 1B 6C 29 00 00 00 00 00 00 01 39 2C 00 00 16]
STORAGE().ReleaseLoadout(m_kSoldier)

(766/4DA) [19 1B 01 2F 00 00 00 00 00 00 16 0E 00 00 00 00 00 00 1B BE 00 00 00 00 00 00 00 2C 3B 4A 4A 16]
STORAGE().AddItem(59)

(78A/4FA) [19 1B 01 2F 00 00 00 00 00 00 16 0E 00 00 00 00 00 00 1B BE 00 00 00 00 00 00 00 2C D5 4A 4A 16]
STORAGE().AddItem(213)

(7AE/51A) [19 1B 01 2F 00 00 00 00 00 00 16 0E 00 00 00 00 00 00 1B BE 00 00 00 00 00 00 00 2C 02 4A 4A 16]
STORAGE().AddItem(2)

(7D2/53A) [0F 35 E3 FA FF FF A8 F9 FF FF 00 01 00 EE 2C 00 00 2C 3B]
kLoadout.iArmor = 59

(7F1/54D) [0F 35 DF FA FF FF A8 F9 FF FF 00 01 00 EE 2C 00 00 2C 02]
kLoadout.iPistol = 2

(810/560) [19 1B CB 2F 00 00 00 00 00 00 16 16 00 D7 FA FF FF 00 1C E0 FB FF FF 00 EE 2C 00 00 25 2C D5 16]
TACTICAL().TInventoryLargeItemsSetItem(kLoadout, 0, 213)

(83C/580) [19 1B F5 1A 00 00 00 00 00 00 16 1C 00 A8 38 00 00 00 1B 53 01 00 00 00 00 00 00 01 39 2C 00 00 00 EE 2C 00 00 16]
LOCKERS().ApplySoldierLoadout(m_kSoldier, kLoadout)

 

 

 

 

Link to comment
Share on other sites

Kaldreth88, so you're trying to mod one of the easter egg characters to be a female. There is indeed no GetNextFemaleVoice defined inside XComStrategyGame, so you'll have to do without it.

 

I suggest generating a soldier with m_kSoldier = BARRACKS().CreateSoldier(...) and then changing all the values to whatever you want.

 

LeMagos, @NULL tokens in your first decompiled code indicate that there is some error in the script. Both vanilla and LW versions have HasOTSUpgrade(2) calls:

vanilla:

 

 

 

function int GetCapacity()
{
    local int iCapacity;

    iCapacity = m_iCapacity;
    // End:0x52
    if(BARRACKS().HasOTSUpgrade(1) || m_bExtendSquadForHQAssault)
    {
        ++ iCapacity;
    }
    // End:0x91
    if(BARRACKS().HasOTSUpgrade(2) || m_bExtendSquadForHQAssault)
    {
        ++ iCapacity;
    }
    // End:0xB2
    if(m_bReinforcementsForHQAssault)
    {
        iCapacity += HQASSAULT_REINFORCEMENT_CAPACITY;
    }
    return iCapacity;
    //return ReturnValue;    
}

 

LW

 

 

function int GetCapacity()
{
    local int iCapacity;

    iCapacity = m_iCapacity;
    // End:0x43
    if(BARRACKS().HasOTSUpgrade(1))
    {
        ++ iCapacity;
    }
    // End:0x73
    if(BARRACKS().HasOTSUpgrade(2))
    {
        ++ iCapacity;
    }
    // End:0xA2
    if(m_bExtendSquadForHQAssault)
    {
        iCapacity = HQASSAULT_REINFORCEMENT_CAPACITY;
        Clamp(iCapacity, 8, 12);
    }
    // End:0xBB
    if(m_bReinforcementsForHQAssault)
    {
        iCapacity = 14;
    }
    // End:0x320
    if((HANGAR().m_kSkyranger != none) && HANGAR().m_kSkyranger.m_kMission != none)
    {
        // End:0x258
        if(ENGINEERING().IsFoundryTechResearched(37))
        {
            // End:0x19E
            if(HANGAR().m_kSkyranger.m_kMission.m_iMissionType == 8)
            {
                iCapacity += 2;
            }
            // End:0x1FB
            if(HANGAR().m_kSkyranger.m_kMission.m_iMissionType == 13)
            {
                iCapacity += 2;
            }
            // End:0x258
            if(HANGAR().m_kSkyranger.m_kMission.m_iMissionType == 10)
            {
                iCapacity += 4;
            }
        }
        // End:0x2B4
        if(HANGAR().m_kSkyranger.m_kMission.m_iMissionType == 5)
        {
            iCapacity = 4;
        }
        // End:0x320
        if(HANGAR().m_kSkyranger.m_kMission.m_iMissionType != 7)
        {
            // End:0x320
            if(iCapacity > 12)
            {
                iCapacity = 12;
            }
        }
    }
    return iCapacity;    
}

 

 

Anyway, if you're trying to add some new code inside a function, you need to rewrite it partially or completely. In this case you need a complete rewrite, because of all the jump offsets. You need to code all the lines either in hex code or in pseudo-code (I suggest using pseudo-code with Patcher) and use AUTO modifier with object key:

OBJECT=Object.Name:AUTO
[REPLACEMENT_CODE]
//the whole script in pseudo-code
Here is an exampe of pseudo-code:

// iCapacity = m_iCapacity;
0F 00 <.iCapacity> 01 <@m_iCapacity>
But I still can't understand what exactly are you trying to do. Can you explain the main idea? Edited by wghost81
Link to comment
Share on other sites

I still can't understand what exactly are you trying to do. Can you explain the main idea?

 

My goal is double:

1. expose both squad size upgrades to moddability... (I am stoopid: one day I am happy with standard LW values, the other I could want the first give 2 men the second 3)

2.Understand how it works (i am STOOPIDLY stoopid: To have it is good, to make it is icing on the cake...)

 

 

in the end 1 means I have the code for making the function start as:

 

function int GetCapacity()

{

local int iCapacity;

 

iCapacity = m_iCapacity;

// End:0x43 Loop:False

if(BARRACKS().HasOTSUpgrade(1))

{

iCapacity += value1;

}

// End:0x73 Loop:False

if(BARRACKS().HasOTSUpgrade(2))

{

iCapacity += value2;

}

// End:0x8c Loop:False

etc.

 

 

 

Where value1 and value2 I can choose before the campaign, run the mod, enjoy, get bored, rinse & repeat... (See ??? Stoopidly stoopid of stoopidbürg...)

 

 

2. would be take my neuron 1, hit it on the head to wake it up, take my neuron 2, etc. & read & try & read & try what will & what won't work...(maybe harder than what I thought at first, but I'LL BE BACK !!!)

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.

×
×
  • Create New...