Jump to content

The next Step


dreadylein

Recommended Posts

Second, unfortunately, there's special bytecodes for constant 0 and 1 in UnrealScript. You're looking for 0x25 for 0, 0x26 for 1. So you'd need to search for 0x26.

 

The reason this is a problem is because if you want to change it to 2, you're going to need to change it from 26 to 2C 02, because any constant other than 0 or 1 has to be preceeded by 2C (or a different code, for different types). And as we just learned a few minutes ago, you can't change the lengths of functions. Changing 26 to 2C 02 would add one byte to the function's length, causing the altered script to be rejected.

 

Good info... When you change the length of a function, when does it fail? When the game launches? Is it a catastrophic failure, or is it something more subtle?

 

That information comes from Solver, in the last page of the analysing the game scripts thread. I think it was a crash when the game launched, but Solver didn't say exactly.

Link to comment
Share on other sites

  • Replies 98
  • Created
  • Last Reply

Top Posters In This Topic

And, what do you mean, changing it from 1 to 4? You mean, in the decompiled source that UE Explorer shows?

In XCOMGAME.upk(decompressed) in my Hexeditor, searching for the blocks Base_Num_Rockets.const is made of(7D 10 00 00 32 55 00 00 00 00 00 00 7D 10 00 00 02 00 00 00 31 00). On the right it shows a "1" in the ansi. It corresponds with "31" in Hex on the left. When I changed it to "4" the Hex changed to "34", but even after saving and batching it in, it didn´t work in my savegame(already had those characters, took them to a mission-> they only had 1 and 2 rockets each(the second with that perk)).

 

EDIT:

@dreadylein:

Yeah... I read that... I was still hoping it´d work or I just made a mistake somewhere. :tongue:

Edited by Caiman
Link to comment
Share on other sites

Ahh, yeah, the fact that there was a 1 in the ASCII was a coincidence. Any constant values would be stored as integer values (as in, two's complement binary-encoded integer values) or, in the case of 0s and 1s, as the special 0 and 1 bytecode. In your case, you'd be looking for a 26 in the hex somewhere.

 

Like I said, though, changing a 0 or 1 to any other value is currently impossible, because it requires expanding the size of the file by one extra byte (the "IntConst" byte). We need to figure out how to update the file lengths in the UPK before we can do anything like that.

Link to comment
Share on other sites

We need to figure out how to update the file lengths in the UPK before we can do anything like that.

I'm trying out using explorer suite, which is mostly used to modify executibles, but I think it could work for manually editing the file sizes.

 

(edit) I changed the file to a larger byte size, but it didn't do anything. Maybe I didn't do what it needed, hell I think I just messed up game

Edited by Tayot84
Link to comment
Share on other sites

7) Near the middle you'll see E0 3F... that's the float 1.75 in little endian (backwards ;) ) format.

8 ) Using the same online calculator, I calculate the float 0.25 as hex, which gives: 0x3e800000

9) So, if I change the E0 3F to 80 3E, I'll change 1.75 to 0.25

10) I make the changes to the uncompressed .upk, save, rename the original file and it's .compressed_save, run XSHAPE, and then I was done.

 

* I basically repeated the above for hunkering down, which was unpacked as class: XGAction_HunkerDown

 

I must say, I'm having fun with my shortened delay on overwatch and hunkering down. :D Hope that helps someone else.

 

^^^ I'd like to see more tutorials like this on here ;)

 

Im kinda hung up on this part. Not sure whats wrong :( And its upsetting cuz i thought i was following it pretty easily!

I uncompressed the upk, then i unpacked it.

Found the overwatch area, used hexeditor to change the values.Clicked save on hexeditor.

Then I used the repacker to pack the folders back up into an uncompressed upk.

Renamed the Xcomgame.upk and its uncompressed_size file (in the cookedpc folder)

then i put the newly created uncompressed file in there.

Extracted the Xshape files into the base directory XCOM Enemy Unknown\ ( or should they be in the folder that HAS my xcomgame.exe)

I double click xhape.bat.... It says Xcom SHA Patcher for Excutable - No changes needed to be made. Press anykey.

Then if i right click the bat and open as Adminstrator it says, Unable to access jarfile Xshape.jar press any key to continue.

 

And when I try to load up the game, it crashes before it begins :(

So im not sure what im doing wrong and its very frustrating!

Edited by miked79
Link to comment
Share on other sites

Instead of repacking you can just copy the whole original overwatch area, open the xcomgame.exe in your hex editor and search for that copied overwatch hex data. Then you can change the value right in the exe, without the need to repack anything(i got it to work like that). ;)
Link to comment
Share on other sites

Instead of repacking you can just copy the whole original overwatch area, open the xcomgame.exe in your hex editor and search for that copied overwatch hex data. Then you can change the value right in the exe, without the need to repack anything(i got it to work like that). ;)

 

Ooo i might have to give that a try later! Now doing that, do you still have to use the Xshape files? Cuz i think those are where my problem is.

Link to comment
Share on other sites

I double click xhape.bat.... It says Xcom SHA Patcher for Excutable - No changes needed to be made. Press anykey.

 

^^ You messed up somewhere. XSHAPE should have reported that 1 hash file was updated. The only explanation is that one or more of the files you thought you modified actually weren't.

 

Even if you just switched to using the uncompressed upk file, the hash would still need to be updated.

 

I would check if xcomgame.upk.uncompressed_size was actually renamed. XSHAPE will skip files that have a valid <filename>.upk.uncompressed_size.

 

 

Also, download and use the new version of XSHAPE (v.11b), and then you could edit the batch to use the -v switch like so:

 

@echo off

java -jar XSHAPE.jar -v 26444500

pause

 

 

And then copy and paste the results here. Might give us a clue.

 

...do you still have to use the Xshape files? Cuz i think those are where my problem is.

 

No matter what, you'll have to use XSHAPE. Otherwise, the game will crash.

 

Personally, I don't actually use the repacking method at all.. but it's easier to explain as if I had, so I sometimes explain it that way. This time I didn't. I don't think that's the problem, however.

Edited by Daemonjax
Link to comment
Share on other sites

Ok... New mod... I'd like equal chances for an xcom soldier to be male or female.

 

Currently, the code is set up to have 33% female soldiers.

 

I know this has been done before by kanet32, but this will be the tutorialized version. :D

 

1) Uncompress XComGame.upk

2) Open it in UE Explorer

3) Go fishing... find the class: XGCharacterGenerator

4) Click on it, then open up the functions list

5) Click on CreateTSoldier

6) Notice the line:

 

kSoldier.kAppearance.iGender = ((Rand(3) == 0) ? 2 : 1);

 

What this code means is that it rolls a 3 sided die, which results in a random integer number between 0 and 2.

If it's a 0, then kSoldier.kAppearance.iGender = 2;

Otherwise, kSoldier.kAppearance.iGender = 1;

 

If you'd like to read more about the ? conditional operator: http://www.cafeaulait.org/course/week2/43.html

 

kSoldier.kAppearance.iGender = 2 about 33% of the time, so we want that to be 50%. To do that we need to make the line look like this:

 

kSoldier.kAppearance.iGender = ((Rand(2) == 0) ? 2 : 1);

 

7) So, we need to realize that we're just changing that 3 into a 2, so that we have Rand(2). Simple, right?

8 ) Instead of looking for a 3, we're going to look for the bytecode of the Rand() function instead. Since there's more than one call to Rand() in the function, we need to make sure we know where the one we're interested in appears in the file.

9) Copy and paste the contents of the decompiled version of the CreateTSoldier function from UE Explorer into a plaintext file.

10) Search the file for the string: Rand

11) We see it comes up 4 times, in the file, and it's the first instance that we're interested in.

12) Go to http://dl.dropbox.com/u/32777109/Games/XCOM%202012/output.txt

13) Hit F3, and search that page for the string: Rand

14) Note that the bytecode for it is A7

15) Start up your favorite hexeditor, and open up the CreateTSoldier.Function file in the \unpacked\XComGame\XGCharacterGenerator\ folder.

16) Search for the hex code A7, and note that there are 4 instances of it in the file. This is exactly what we hoped expected to see. Again, we're interested in the first instance.

 

Offset(h) 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F

00000170  00 00 45 9A A7 2C 03 16 25 16 02 00 2C 02 01 00  ..Eš§,..%...,...

 

17) Notice that the next two bytes are: 2C 03

 

The 03 looks interesting. But what does 2C mean? Well, searching http://dl.dropbox.com/u/32777109/Games/XCOM%202012/output.txt again for 2C gets us:

 

MirrorVectorByNormal

 

Hmm, that's unhelpful.... but, wait, there's another after that...

 

IntConstByte

 

Bingo! So, that bytecode says the next byte is to be treated as an integer. Nice... we Know (with a capital K) we're in the right place now.

 

18) You could change the 03 to an 02 in this file and just repack. Or you could close UE Explorer, and make the change directely in the uncompressed upk, and skip the repack. Your choice.

19) Reopen the modified upk file in UE Explorer to verify that the change you intended actually happened:

 

kSoldier.kAppearance.iGender = ((Rand(2) == 0) ? 2 : 1);

 

20) Rename the original file and it's .compressed_save, open the modified uncompressed upk to the \XComGame\CookedPCConsole\ folder, then run XSHAPE.

 

That's it! You're done!

 

SOOOO SIMPLE RIGHT??!! ;)

Edited by Daemonjax
Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.

×
×
  • Create New...