Jump to content

The next Step


dreadylein

Recommended Posts

A couple files got me thinking... The XcomTacticalGameCoreNative base has properties of config entries...

 

Do you think it would be possible to add config entries for a bunch of consts?

 

Initially i thought maybe we were all just overlooking it and could just simply add some of those constant values into the ini and it would work... but it wasn't that simple.

 

Maybe i'm just being a dumb ass.

 

Did anybody get the repacker to work? mine keeps giving me a can't open pgkinfo file error..

Edited by tbkiah
Link to comment
Share on other sites

  • Replies 98
  • Created
  • Last Reply

Top Posters In This Topic

I already dared dreadylein to add all those consts in that upk as a feature to his modpatcher. ;)

 

It would take some degree of work just to get all the offsets, and I haven't seen a single one changed that had an effect ingame yet. Could be a gigantic waste of time.

 

I just repacked xcomstategygame.upk, so it does work. Number of bytes matched the original uncompressed.

 

If you used Gildor's extractor, then it won't create the package info file... but if you use upkunpack, then it does.

Edited by Daemonjax
Link to comment
Share on other sites

Correct me if i'm wrong, but currently we have no way to modify entire script lines in the X-Com function files, right?

 

Do the mod gurus (i'm looking expecially at you Daemonjax) have any ideas if it's something we will be able to do in the near / distant future?

 

This is what I pursued at first. Because UnrealScript assigns what are basically lookup references for each class to recompile using the official UDK tools it looks like you have to recompile EVERYTHING and not just pieces (please someone prove me wrong.) I extracted out the XComGame upk and it depended on Core and Engine classes not in the standard UDK. This just means Firaxis added a few things. So I extracted those out as well and got complaints about BindDLL being defined as native. It *might* just be a bug in the UE Explorer export, but more likely it's the free version of the UDK complaining about the core game code being edited (which is a feature of the fully paid license) and not having access to the edited DLLs.

 

It should be possible to change the size of the scripts in the upk, but I'm not sure anyone here knows the file format well enough yet. It's just a list of serialized objects, but that means each object itself will have a size entry and there will probably be sections within the upk itself that also have total size values. All these would need to be updated if the size of a script is changed. The good thing is nothing will have a hard coded offset into the upk, it'll deserialize and then access the offsets. Once changing the size is taken care of we'll be able to remove entire lines of code. Then it's a matter of creating a translation for variable/class/function to reference bytes to be able to add lines of code.

Link to comment
Share on other sites

I keep looking, but I'm not finding anything that looks like function length within the function script itself.

 

I believe that information is in the decompiled .class file or another file (.package, or .UPKpkginfo, etc.).

 

But my money is on the .class file.

Edited by Daemonjax
Link to comment
Share on other sites

Good info, there... let's keep the bytecode mods/info flowing. :D

 

On that note, I figured out how to entirely disable shooting while panicked through bytecode.

 

I doubt anyone would be interested in that particularly, but a lot of the code that handles panic is in the XGUnit class in XComGame.upk.

 

We can also change the maximum range at which the panicked unit checks for targets when they fire randomly. It's currently set to 256 (4 * 64) distance units.

 

I don't think either are particularly worthwhile mods, but if someone's interested in more details then let me know.

Edited by Daemonjax
Link to comment
Share on other sites

For those that use 010 Editor I've started a rough UPK Template. I have it parsing the Names, Imports, and Export tables. What we're interested in as modders is in the Export table under the Export's Content variable. The next step for me will be to figure out which are classes and parse their contents specially to list out the opcodes and what they all are.

 

Right now this isn't hugely helpful, it just lets you browse the exports table and immediately jump to the content for the name you're looking at. In the future, once I get it parsing the class contents correctly there will be 2 ways it will help. The first is to spell out the content opcode for the export if you go to it from the export list, or, a better way: If you already know the byte values for the function you want to edit (maybe from extracting) you can search for those values and it'll take you to the parsed information.

 

I'm out of town next week so working hard to try to get this to a more useable state as quickly as possible.

 

(Rename the .txt to .bt for it to work with 010 Editor. This forum doesn't let you upload .bt files, I guess it thinks it's BitTorrent?)

Link to comment
Share on other sites

I for one have no idea where some of the constant values are being used...

 

For the most part, they're not being used. I have a feeling those constants were left over from debugging or unit testing.

 

On a different note, here's the latest version of my 010 Editor template. In this one when you go to a function's content it starts to spell out what I've managed to decipher. The simpler functions it works great. The more complex functions I haven't figured out the opcodes for yet, or their dependent structures. Any help in this regard is appreciated. Note that if you hit an error trying to retrieve the name of an item (due to a misalignment or mishandled opcode) then you will forever after get errors, even on values that had returned correctly before until you rerun the template.

 

I've learned a lot putting this template together. For instance, it would be possible, but very difficult to change the size of a function. Each export has an offset and a size, so you would need to update the size field appropriately, and then shift ALL the offsets to all the other exports after the one you changed the size of. Doable, but you'd want to automate it in some way. Not to mention a lot of the internal function jumps or switches would need to be updated for the new values. Far easier to just edit existing functions slightly.

 

The order of operations for the bytecode isn't always as expected, either. This screenshot shows my template against the IsTargetVisible function:

 

 

 

The line

bResult = kVisInfo.kVis[iCurrentCoverPoint] & iMask > 0;

is interesting and the template spells it out exactly:

14 2D 00 5D 00 00 00 97 9C 1A 00 61 00 00 00 35
43 00 00 00 45 00 00 00 00 00 00 62 00 00 00 00
5E 00 00 00 16 25 16

14 is the equals for a bool

2D is variable type of bool

00 means local variable

5D 00 00 00 is the index for the name of the bResult variable and will be the destination

97 is > test and 9C is binary and, note they're next to each other in bytecode

1A means we're interested in an array element

00 61 00 00 00 is the local variable iCurrentCoverPoint (a local instance of it at least)

35 means we're working on a structure. I don't have this fully understood.

43 00 00 00 is the struct member kVis

45 00 00 00 is the struct (or class) XGUnitVisibilityInformation which kVis was passed in as

00 00 is.... the type of struct? I have no idea, but it's part of the struct info

00 62 00 00 00 is the local instance of the variable kVisInfo

00 5E 00 00 00 is the local instance of iMask

16 is the marker for end of a function op, think of it like parentheses so it belongs to the binary and

25 is the special byte for 0

16 would be the close parentheses for the greater than test.

What I found odd is how it puts the operators together, then lists the variables and uses the 16's as grouping designators. Things like this would make creating new code confusing imo, but doable.

 

Hopefully my template can help accelerate some mods. I know it's unfinished. If you know a structure I don't, please help me fill in the info.

Also, I know this isn't compatible with all upk versions, I'm just interested in making in compatible with XCom at the moment.

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.

×
×
  • Create New...