Requirements
- Ikarus script package: Thread @ World of Gothic
- LeGo script package: Thread @ World of Gothic
- Spine script package: Download @ GitHub
Introduction
Spine allows to use new script features as long as the modification gets started via Spine. If the modification uses Spine features and is started without Spine the features will be ignored. The exception are achievements. They are also usable without Spine.
Integrate Spine in scripts
To integrate Spine in existing scripts is pretty easy. After you downloaded the script package, unzip the archive to the scripts folder (_work/data/Scripts/Content) in your modding installation of Gothic. Afterwards you just have to open the Gothic.src and enter the following line:
Spine\Spine.src
It’s important that this line is below Ikarus, LeGo and AI\AI_Intern\AI_Constants.d.
When you compile the scripts again now Spine will be compiled with your code.
Modules
Spine provides several different modules like LeGo that can be activated separately. On the one hand this causes less overhead. On the other hand it guarantees future features not being initialized automatically without a script update.
The following shall explain the different available modules.
Username
The username module is very small and just provides the possibility to receive the username of the currently logged in Spine user. It can be useful for modifications that want to personalize the player. This can be the case for multiplayer or highscores.
Achievements
The achievement module provides an easy way to add achievements to your modification. You just need to configure some values and call Spine_UnlockAchievment at the correct place in your code. More informations about achievements can be found in Tutorial 2 – Achievements.
Scores
With the score module you can create highscores and rankings. It provides different methods to set a score and to query informations about the scores. This includes both the own score as well as scores and usernames of other ranks in the highscore. Also the own rank can be queried. More informations about scores can be found in Tutorial 3 – Scores.
Multiplayer
With the multiplayer module you can realize different types of multiplayer modifications. You can connect with other players and exchange messages with them. It’s not built for fast real-time transmissions, but e.g. turn based multiplayer like in our Chess modification are absolutely no problem. More informations about multiplayer can be found in Tutorial 5 – Multiplayer.
Overall Saves
With the overall save module you can save and read data across all saves. This can be useful if you want e.g. achievements like “Complete the game with all guilds” or “Defeat x enemies”. More informations can be found in Tutorial 4 – Overall Saves.
Initialization
To initialize Spine just one more line is necessary.
Spine_Init(SPINE_MODULE_GETCURRENTUSERNAME);
This line must be placed in the function INIT_GLOBAL in the Startup.d. It’s important that this happens AFTER the initialization of LeGo. A complete INIT_GLOBAL function could look like the following:
func void INIT_GLOBAL()
{
// wird fuer jede Welt aufgerufen (vor INIT_<LevelName>)
Game_InitGerman();
LeGo_Init(LeGo_All);
Spine_Init(SPINE_MODULE_GETCURRENTUSERNAME);
};
If you want to enable multiple Spine modules you can just combine them with the bit operator ‘|’. So with the line
Spine_Init(SPINE_MODULE_GETCURRENTUSERNAME | SPINE_MODULE_ACHIEVEMENTS);
you can enable both the username and the achievements module.
After the initialization is completed you can e.g. print the name of the logged in player in a loop using
Print(ConcatStrings("Username: ", Spine_GetCurrentUsername()));
Testing Spine functionality
If you execute this code now you will notice, that only Username: is printed on the screen. That’s because the Spine functions will only work when starting the modification via Spine. As long as the modification isn’t part of the Spine database – which unreleased modifications at least in the beginning of development are – it can’t be started via Spine in the usual way. But for this you can use the developer mode. The developer mode simulates a mod already being part of the database. It can be enabled in the settings in the developer tab or in the menu bar. Shortcut Ctrl + D also enables and disables the developer mode. As an advanced feature for those working on multiple projects at a time, you can set up a mod folder for the shortcuts Ctrl + 0-9 to switch directly in developer mode to this project. You can find this setting also in the developer tab in the settings.
When the developer mode is enabled all mods installed via Spine are hidden and only manually installed ones or the own local modifications are displayed. Starting the mod now enables all Spine functionality in a test environment. You can also directly compile the scripts in Spine and run zSpy to debug.
So when you start the example now the output of the username will work properly.