Oliver2Goetz / AIUtils

Coordinate translator for Modding Alien Isolation
1 stars 0 forks source link

Offsets can be calculated automatically by reading Commands files #1

Closed MattFiler closed 1 year ago

MattFiler commented 1 year ago

Hey Oliver, thanks for the sponsor!

Just had a quick poke at this project, it's cool - and I could see it being a useful tool while OpenCAGE's world editor is in development.

Thought it was worth pointing out that the offsets you're manually calculating to get the SCRIPT_STORYMISSION coordinates in your UI can actually be grabbed automatically by using my CathodeLib library to parse the loaded level's Commands file (check out the CommandsPAK class).

You can read down from the level's root composite to figure out the hierarchy at which each composite is instanced in the level. When doing this, keep a track of the positions at which they're instanced, as stacking these will get you your in-world position. It's kinda complicated to understand in the current OpenCAGE GUI, but think of it similar to instancing prefabs in Unity, or Blueprint Classes in Unreal.

For example, in BSP_TORRENS, to get the coordinate offsets for entities in the single instance of LEVEL_COMPOSITES\BSP_TORRENS\MISSIONS_TORRENS, you can start in the root composite (P:\CONTENT\BUILD\LEVELS\PRODUCTION\BSP_TORRENS) and see the position given to the MISSIONS_Torrens_1 entity, which instances the MISSIONS_TORRENS composite at position zero - so we know that all entities within this will have no offsets).

I had a parser that did this in an older version of my Unity level editor, but scrapped it as it was quite inefficient. I plan on re-writing everything at some point when all the formats are fully known, to speed it all up and make a nice level editor with a proper node-based UI!

Thanks again for the sponsorship, hopefully this info is useful & you can have some fun with CathodeLib!

Feel free to submit a PR if you figure any new bits out! Any help is welcome, especially as I'm quite busy with work right now so don't have as much time as I'd like to have to work on OpenCAGE :)

Oliver2Goetz commented 1 year ago

Hey @MattFiler,

thanks for your feedback onto my little project.

Despite my lacking knowledge of anything related with PAK files, Modding and coding in relation with games in general I can comprehend what you mean and looked it up in OpenCAGE. Since the level BSP_LV426_PT01 (first part of mission nine) has a position which isn't set to zero's that's what the offset would be for that level. However that would contradict what two other members of the community found out for mission 5 -> level SCI_HOSPITALUPPER. The idea was, spawning an android entity in SCI_HOSPITALUPPER, which was not successful. They later found out that offsets exist but that's not the way your explanation would work in this case (if I understood correctly). After my own research I guess they found it like this: In LEVEL_COMPOSITES\SCI_HOSPITALUPPER\MISSION_HOSPITALUPPER there's an entity of typeSCRIPT_STORYMISSION\M09GET_INTO_HOSPITAL\M09_PART02\M09_PT02` which reflects those offsets they gave me. X and Z are switched and have an offset. Using the coordinates in that entity as offsets worked out for them.

A little bit of a background story what my program is about: I talked to one of them since he has some problems with using Cheat Engine and he's experiencing crashes. My idea was to create a program in which he can see the coordinates realtime while walking around (like a normal Cheat Table would do). Calculate the coordinates with offsets if there are any and displaying them near each other in realtime as well. I am not calculating the offsets, I am using them to display the current coordinates of the player and also showing the coordinates recalculated with the offsets.

Since there are currently only two levels known with offsets I might not use CathodeLib as of right now. If there are more offsets which I yet don't know I can see it being used though. The next part would probably be figuring out which levels have offsets. My knowledge of OpenCAGE and Cathode is nearly zero. I'm currently working on my first mod (I started a week ago) and I still have a lot to learn about OpenCAGE, how Cathode works, etc. Said that it might take a while to have an understanding of the different things. Afterwards I can try and do some stuff with CathodeLib once I have a better understanding.

Anyway, thanks for your feedback and letting me know about all this!