Jump to content


Photo

Editing APT Files


  • Please log in to reply
247 replies to this topic

#1 DeeZire

DeeZire
  • Members
  • 140 posts

Posted 20 November 2009 - 08:17 AM

I know this is years old - but I've been asked countless times how I did this in my old BFMEI mod, and I still get asked how to edit APTs. It's kinda funny to still see people resorting to hex edits, and at the same time quite sad to see not many changes made to the APTs, so I thought I'd share the years old 'secret'.

Yes, you can 'edit' the APT files to a degree with a hex editor, but in the case of the BFMEI spellbook this was my last resort. Hex edits are also very limited in their scope and can only accomplish a little as you are digging in the dark.

Explanation - I decompiled the APT file so it was in a more readable and understandable form, this way I knew what I had to edit inside it to switch the campaign spellbook with the multiplayer one. Only by decompiling it did I figure this out. My frustration was that I could never get the damn things to recompile into a form that the game would read or use, so given that I knew what needed changing I resorted to a hex edit to do it. The key thing was decompiling the APT so I could figure out what was required to be edited. Editing by hex alone is almost pointless, as you have no idea what you are looking at.

Using the same method, a lot more could be done with them, although you have to have an understanding of how they work. You see the APT files all interact with eachother. Some contain IMPORTS, these work a bit like INC files for INIs, in that they call resources or code from other APT files - for example, common buttons/images, sounds etc. Others contain EXPORTS that make their internal resources available to other APT files. The trickiest bit is that the APT files all interact with the core game code, and the restriction here is due to the naming convention of the elements inside the APT file. For example, a button called 'GoodCanpaignButton' may be named so in the game exe, which means that particular button in an APT file will only trigger a specific function in the exe. Also, that button will only work when inside a particular tree in the APT file, for example MainMenu > SinglePlayerMenu > GoodCampaignButton will be the only one able to trigger the good campaign to start.

Back when I did my BFMEI mod I was lucky enough to have a proprietary app that could decompile but it's compiler sucked and made APT files of a lower version than BFMEI supported. However, you can still decompile them into XML which makes them very readable (thus editable). I wish you could recompile into APT again but the tools cannot do this, so what you have is the ability to decompile, read and thus analyse what you can edit, where and how. Armed with this knowledge, you can apply hex edits (albeit in a limited capacity) although you would not be digging in the dark as much because you know what and where to change. This is how I accomplished the BFMEI spell book thing, I dont see how it could have been done without reading and understanding the APT first.

So, if anyone wants to follow in my footsteps and try to get more out of the APT files, you can use a newer tool from this very network at this page on C&C Guild to decompile APTs into XML.

I've recently used the same method to make a perfect port of the BFMEII spell store into RoTWK complete with more spells in multiplayer, perfect color/sounds scheme etc. I actually picked on SpellStore.APT because it is the easiest one to edit by far, on account of the fact that it has no IMPORTS or EXPORTS (it acts independently). There you have it - good luck.

Edited by Bart, 19 December 2009 - 09:22 PM.
Changed CNC3.Net link to guild


#2 m@tt

m@tt

    #######

  • Project Team
  • 4,056 posts
  • Location:England
  • Projects:The Dwarf Holds
  •  T3A Chamber Member

Posted 20 November 2009 - 09:30 AM

So... are you the DeeZire then? I thought you'd just nicked his name :p

Nice to have you around. I take it you are moving onto finishing BFME:EE like you said on your site a few months ago?

If you feel like putting this into a proper tutorial, use the main site http://www.the3rdage.net.

With regards to the APT stuff, by doing this, we would finally be able to do things like new faction icons (for the skirmish menu and 'select all heroes' button)?
Posted Image

#3 DeeZire

DeeZire
  • Members
  • 140 posts

Posted 20 November 2009 - 10:52 AM

Yes it's me :p

I finished the BFME:EE, but then I had a similar project for BFMEII that I never finished or released. Then I noticed RoTWK came around, so I have decided to just port everything I ever did for the series into RoTWK in one all-encompassing mod, which is actually a heck of a lot and I'm very pleased with how it's turning out (although theres a bit left to do). I have even merged the campaigns from them together.

For faction icons I have done that perfectly well without editing the APTs, is that one not commonly known?

If you mean new 'select all heroes button' then I think eventually yes, I looked into that one when putting Rohan back as a seperate faction, as well as looking at making a new view in the skirmish stats menu for new sides. Eventually I decided to just replace Angmar with Rohan (I wasn't happy with playing with sides from different time periods and wanted to just focus on the War Of The Ring).

I definately remember when looking at LibInGameImages and PalantirExport (I think that's where the select all heroes buttons are defined) there was a slot called 'unused' which could be made into a new select all heroes button I reckon - it seems to be the leftover from the slot which was made spare for The Fellowship in BFMEI (even though they weren't a playable side as such they had a select all heroes button which was used in the campaign). This logic still works in RoTWK, you can specify 'Fellowship' for a side in WorldBuilder and they will get their own faction icon (but no Select All Heroes button).

In short - faction icons are simple to do anyways, new select all heroes buttons and skirmish stat screen views will need APT editing - the skirmish stats menu is a complicated beast (but reads logically). I would have this available for people now if they wanted, the trouble is my edited XML to add those things worked fine but even the new tools I mentioned above do not reliably recompile it into an APT version that BFMEII supports and hex editing that lot in would be enough to drive anyone crazy.

Edited by DeeZire, 20 November 2009 - 11:01 AM.


#4 Sûlherokhh

Sûlherokhh

    Sagacious Engineer

  • Project Team
  • 3,754 posts
  • Location:Central Germany
  • Projects:S.E.E., Sage A.I., Code Advisor
  •  'Axe'er of the Gordic Knot

Posted 20 November 2009 - 04:58 PM

Glad to have you around. I'll check out the decompiler. Thanks. :p

bannerreal01mittelit3.jpg
Axed Head and A.I. Coder for S.E.E. and ... stuff

".. coding is basically boring. What's fun is finding out how things work, take them apart and then put them together in ways that were not intended nor even conceived."


#5 m@tt

m@tt

    #######

  • Project Team
  • 4,056 posts
  • Location:England
  • Projects:The Dwarf Holds
  •  T3A Chamber Member

Posted 20 November 2009 - 05:41 PM

Faction icons etc can be done in BFME 2 (there's a tutorial on the main site), but afaik there are limitations in BFME 1 (I'm in a BFME 1 mod team - The Dwarf Holds).
Posted Image

#6 Prolong

Prolong
  • Members
  • 133 posts

Posted 25 November 2009 - 02:25 PM

How can I tell the program to extract BFME II files rather than CnC3 files?

#7 Prolong

Prolong
  • Members
  • 133 posts

Posted 03 December 2009 - 08:58 PM

Hm I really can't figure this out, has anybody else figured out how to use the program. :ohmy:

#8 m@tt

m@tt

    #######

  • Project Team
  • 4,056 posts
  • Location:England
  • Projects:The Dwarf Holds
  •  T3A Chamber Member

Posted 12 December 2009 - 10:29 PM

It looks like you need CnC3 installed to be able to do this :(
Posted Image

#9 Hostile

Hostile

    Benefitting Humanity Simply by Showing Up!

  • Veterans
  • 9,551 posts
  • Location:Washington DC
  •  T3A Founder
  • Division:Revora
  • Job:Global Administrator
  • Donated
  • Association

Posted 12 December 2009 - 10:43 PM

Maybe there is a parameter setting there. He wouldn't have added it if it was incorrect. Thanks for stopping by Dee. :D

#10 Phil

Phil

    Force Majeure

  • Network Leaders
  • 7,976 posts
  • Location:Switzerland
  • Projects:Revora, C&C:Online
  •  Thought Police
  • Division:Revora
  • Job:Network Leader
  • Donated
  • Association

Posted 13 December 2009 - 02:03 AM

I don't think you need to have C&C3 installed. You can just run the program from the command line like this:
C:\path\to\cc3tools\apt2xml.exe C:\extracted\apt\files\Aptfile

All you need is the *.apt and corresponding *.const files in the same directory and it will automatically create an *.xml file at the same place. For example:
C:\Users\Phil\Modding\CNC3Modding\Tools\cc3tools\apt2xml.exe C:\Users\Phil\bfmeapt\Palantir

revorapresident.jpg
My Political Compass

Sieben Elefanten hatte Herr Dschin
Und da war dann noch der achte.
Sieben waren wild und der achte war zahm
Und der achte war's, der sie bewachte.


#11 Prolong

Prolong
  • Members
  • 133 posts

Posted 19 December 2009 - 09:12 PM

I don't think you need to have C&C3 installed. You can just run the program from the command line like this:
C:\path\to\cc3tools\apt2xml.exe C:\extracted\apt\files\Aptfile

All you need is the *.apt and corresponding *.const files in the same directory and it will automatically create an *.xml file at the same place. For example:
C:\Users\Phil\Modding\CNC3Modding\Tools\cc3tools\apt2xml.exe C:\Users\Phil\bfmeapt\Palantir

That doesn't work with aptextract.exe and there is no apt2xml.exe :/

#12 Phil

Phil

    Force Majeure

  • Network Leaders
  • 7,976 posts
  • Location:Switzerland
  • Projects:Revora, C&C:Online
  •  Thought Police
  • Division:Revora
  • Job:Network Leader
  • Donated
  • Association

Posted 19 December 2009 - 09:20 PM

Oh, now I realise I have been using a different (newer?) set of tools with the same name. You can get the other one at http://www.cncmods.net/downloads.php, it's called SDK Extras.

Edit: Seems DeeZire was using the old tools as well, so I have no idea if it will actually work well with this version. It seemed to turn the APT file into decent XML but I've never edited it myself, so I wouldn't know. With the new xml2apt you have the prospect of recompiling it into APT though so if you're very lucky, you can avoid the hex editing completely.

Edited by Dark Lord of the Sith, 19 December 2009 - 09:32 PM.

revorapresident.jpg
My Political Compass

Sieben Elefanten hatte Herr Dschin
Und da war dann noch der achte.
Sieben waren wild und der achte war zahm
Und der achte war's, der sie bewachte.


#13 Prolong

Prolong
  • Members
  • 133 posts

Posted 23 December 2009 - 12:18 AM

Ooooh going to try that thanks :p

Edit- I really can't figure out how to get it to work unfortunately. :( The syntax you gave above for commandprompt doesn't work, and I don't quite understand the guide posted here as it's slightly confusing (what would be the UI folder?).

Edited by Prolong, 23 December 2009 - 02:10 AM.


#14 Phil

Phil

    Force Majeure

  • Network Leaders
  • 7,976 posts
  • Location:Switzerland
  • Projects:Revora, C&C:Online
  •  Thought Police
  • Division:Revora
  • Job:Network Leader
  • Donated
  • Association

Posted 23 December 2009 - 11:05 PM

Keep in mind that those guides are written for C&C3, so some things might not apply to BFME2 :p The UI folder, for example, is specific to C&C3 file structure.
As for using the tools, do this:

  • Create a new folder for the APT editing, say C:\apt
  • Extract the .apt and .const file (.dat is not required as far as I can see in the source code) of the interface you want to edit into that folder, say SpellStore.apt and SpellStore.const
  • Copy apt2xml.exe, xml2apt.exe and cc3tools.dll to that folder as well
  • Navigate to that folder in the command line (cd C:\apt)
  • Run apt2xml with the name of the interface as an argument, say apt2xml.exe SpellStore
  • Do some magic to the XML file that has been created
  • Delete or rename the original .apt file
  • Run xml2apt again to "recompile", xml2apt.exe SpellStore

I have absolutely no idea if this is going to work ingame and how much sense you can make of the XML in order to edit stuff, but it's worth a try :good:

revorapresident.jpg
My Political Compass

Sieben Elefanten hatte Herr Dschin
Und da war dann noch der achte.
Sieben waren wild und der achte war zahm
Und der achte war's, der sie bewachte.


#15 Prolong

Prolong
  • Members
  • 133 posts

Posted 24 December 2009 - 05:26 AM

Keep in mind that those guides are written for C&C3, so some things might not apply to BFME2 :p The UI folder, for example, is specific to C&C3 file structure.
As for using the tools, do this:

  • Create a new folder for the APT editing, say C:\apt
  • Extract the .apt and .const file (.dat is not required as far as I can see in the source code) of the interface you want to edit into that folder, say SpellStore.apt and SpellStore.const
  • Copy apt2xml.exe, xml2apt.exe and cc3tools.dll to that folder as well
  • Navigate to that folder in the command line (cd C:\apt)
  • Run apt2xml with the name of the interface as an argument, say apt2xml.exe SpellStore
  • Do some magic to the XML file that has been created
  • Delete or rename the original .apt file
  • Run xml2apt again to "recompile", xml2apt.exe SpellStore

I have absolutely no idea if this is going to work ingame and how much sense you can make of the XML in order to edit stuff, but it's worth a try :good:

Aha I got it to work, my inexperience with simple command prompt had been my undoing and it took me a little while to figure it out even after seeing the cd command written up there. :( Thank you!

#16 Kwen

Kwen

    Vileartist

  • T3A Staff
  • 4,865 posts
  • Location:Korea I wish
  • Projects:It'sa secreeet
  •  T3A's First N00b
  • Division:BFME
  • Job:T3A Expert
  • Donated

Posted 14 July 2010 - 03:24 PM

I don't understand this part:

Run apt2xml with the name of the interface as an argument, say apt2xml.exe SpellStore

                           https://www.twitch.tv/vileartist - Yes shameless self-promotion

          ----------------------------------------------------------------------------------------------------------------------

                            "Old modders never die, they just fade away" ~ Hostile


#17 Goldtouch

Goldtouch

    title available

  • Hosted
  • 449 posts

Posted 27 July 2010 - 05:14 AM

I don't understand this part:

Run apt2xml with the name of the interface as an argument, say apt2xml.exe SpellStore



First of all open command prompt aka CMD...

Within the CMD you go too the 'c:\apt' directory with this command: "cd c:\apt" press enter

Thanks too the previous step you can now run the compiler/decompiler & tell it what to decompile/compile(to xml with the apt2xml.exe or to apt with the xml2apt.exe).
This is how you do it: "apt2xml.exe NAMEoftheAPTwithoutTheExtention" ex. "apt2xml.exe mainmenu"

---
My question is who the hell can make changes to it :thumbsdownsmiley: say I want to move the buttons of the main menu below eatchother aligned to the left side... How do you do that when you got this xml 'book' of codes

Edited by THORONGlL, 27 July 2010 - 05:17 AM.


#18 Goldtouch

Goldtouch

    title available

  • Hosted
  • 449 posts

Posted 01 August 2010 - 06:38 AM

*Bump*

I'm really curious who mastered xml here or knows someone who can help. With a bit of community we should manage to find this out right !?

I've attached (mainmenu.xml) the converted apt file twice to this topic.

Attached Files


Edited by THORONGlL, 01 August 2010 - 06:40 AM.


#19 Ridder Geel

Ridder Geel

    Master Yelloh

  • T3A Staff
  • 10,852 posts
  • Location:The Netherlands (AKA: Holland)
  • Projects:RC Mod + SEE + RTS Engine
  •  The Dangerous T3A Team Chamber Member
  • Division:BFME
  • Job:T3A Staff

Posted 01 August 2010 - 02:52 PM

I've been looking at xml stuff too... im not exactly sure how it works, i too am still trying to figure out things... :crazed:
I will let you guys know as soon as i get something decent to work :ninja:
Ridder Geel

#20 Phil

Phil

    Force Majeure

  • Network Leaders
  • 7,976 posts
  • Location:Switzerland
  • Projects:Revora, C&C:Online
  •  Thought Police
  • Division:Revora
  • Job:Network Leader
  • Donated
  • Association

Posted 01 August 2010 - 03:47 PM

Go look at the C&C3 Tools source code, that might give you a clue. Warning - it's undocumented, ugly C!

Have fun :crazed:

revorapresident.jpg
My Political Compass

Sieben Elefanten hatte Herr Dschin
Und da war dann noch der achte.
Sieben waren wild und der achte war zahm
Und der achte war's, der sie bewachte.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users