tbkiah Posted October 22, 2012 Share Posted October 22, 2012 (edited) 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 October 22, 2012 by tbkiah Link to comment Share on other sites More sharing options...
Daemonjax Posted October 22, 2012 Share Posted October 22, 2012 (edited) 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 October 22, 2012 by Daemonjax Link to comment Share on other sites More sharing options...
Lethargus Posted October 22, 2012 Share Posted October 22, 2012 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 More sharing options...
Daemonjax Posted October 22, 2012 Share Posted October 22, 2012 (edited) 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 October 22, 2012 by Daemonjax Link to comment Share on other sites More sharing options...
tbkiah Posted October 22, 2012 Share Posted October 22, 2012 Funny, i modded my tacticalgamenativecore or whatever and f***ed up the const part, and went from 216 to 96, and my game still runs. In other words, those are completely useless... which we thought all along, but confirm that. Link to comment Share on other sites More sharing options...
Daemonjax Posted October 22, 2012 Share Posted October 22, 2012 (edited) 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 October 22, 2012 by Daemonjax Link to comment Share on other sites More sharing options...
Lethargus Posted October 22, 2012 Share Posted October 22, 2012 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 More sharing options...
Daemonjax Posted October 22, 2012 Share Posted October 22, 2012 Sounds interesting. I'll check it out. Link to comment Share on other sites More sharing options...
tbkiah Posted October 23, 2012 Share Posted October 23, 2012 I for one have no idea where some of the constant values are being used... Link to comment Share on other sites More sharing options...
Lethargus Posted October 24, 2012 Share Posted October 24, 2012 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 linebResult = 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 1614 is the equals for a bool2D is variable type of bool00 means local variable5D 00 00 00 is the index for the name of the bResult variable and will be the destination97 is > test and 9C is binary and, note they're next to each other in bytecode1A means we're interested in an array element00 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 kVis45 00 00 00 is the struct (or class) XGUnitVisibilityInformation which kVis was passed in as00 00 is.... the type of struct? I have no idea, but it's part of the struct info00 62 00 00 00 is the local instance of the variable kVisInfo00 5E 00 00 00 is the local instance of iMask16 is the marker for end of a function op, think of it like parentheses so it belongs to the binary and25 is the special byte for 016 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 More sharing options...
Recommended Posts