This discussion is meant to provide advice for modders willing to
1) add crossplatform support to a new mod, to ensure it will work on as many platforms as possible (e.g. BG:EE, Tutu, BGT, etc.)
2) add EE support to an old mod created before the EEs release
This is a very large topic, so instead of trying to write a gigantic post all at once, I think it it will be best to write short posts, each dealing with a different aspect of the process.If you have any questions, requests, comments and any other kind of feedback on this tutorial, please use this thread
Tips from other modders are also welcome, so feel free to contribute your own at any time.Credits@CamDawg
, for his tutorial on Converting existing mods to the EE engine@Wisp
, for implementing HANDLE_CHARSETS
in WeiDU and for other encoding-related sample code (Edwin Romance
is basically a tutorial disguised as a mod). @Isaya
, for pointing out here
some inaccuracies in my second post.Getting started
First, I recommend reading this discussion
. It is a bit outdated, but still very useful to understand the main differences between the enhanced engine and the original one.
Also it is always a good idea to take a look at the code in existing crossplatform mods, especially well coded ones like BG1 NPC Project.
Let's start with something simple, i.e.Handling differences in item descriptions
This is also covered by CamDawg in the discussion linked above, but to further exemplify let's see how this is handled in BG1 NPC Project:
the item descriptions for Tutu and BGT, and other strings common to all the engines, including BG:EE, are stored in the file BG1NPC.tra (actually is bg1npc_tmp.tra, but for simplicity sake let's call it BG1NPC.tra)
the item descriptions for BG:EE (without usability info and with a slightly different style), and other strings that are different in BG:EE, are stored in the file BGEE_ITEMDESC.tra
As explained by CamDawg, only the strings that are different are present in both tra files. For example, some strings like
@78 = ~Great Shield - White Oak~
are present only in BG1NPC.tra, as they are exactly the same on all engines, while some strings like the item descriptions @79 and @80 are present in both tra files to account for engine-dependent differences.
In other words, BG1NPC.tra
the strings and BGEE_ITEMDESC.tra
contains only the ones that are different in BG:EE
Te mod loads BG1NPC.tra first on any engine and, if the engine is BG:EE, it will subsequently load BGEE_ITEMDESC.tra. Therefore, if the engine is BG:EE, strings that are missing in BGEE_ITEMDESC.tra, like @78, will stay the same as Tutu/BGT, but strings like @79 and @80 will be replaced by the EE versions.
To do that, we simply have to use the following code in the tp2 file:
ACTION_IF GAME_IS ~bgee~ THEN BEGIN
LOAD_TRA ~BG1NPC/TRA/%LANGUAGE%/BGEE_ITEMDESC.tra~ /* Item descriptions for BGEE, i.e. without usability info */
Of course we still need to account for differences in the encoding as EEs use utf8 and vanilla/Tutu/BGT other language-dependent encodings, but I will explain how to deal with this another time