Новички, пришло время принять реальность и смириться с судьбой. Чувствуйте себя как дома в Долине Рудников, месте, полном опасностей, преступлений и жадности. Вам предстоит оставаться здесь очень...
Готика 2: Другая история / Other Story - это глобальная модификация для игры «Готика 2: Ночь Ворона». Её цель - сделать игру более нелинейной, с большим количеством вариантов выбора и...
4 мая в 18-00 стартует шестой сезон Community лиги по одной из лучших игр в жанре arpg Grim Dawn. Сезон представляет собой глобальную модификацию игры, включающую в себя расширение мира, изменение...
Наконец-то дождались - "Baldur's Gate III" покидает ранний доступ, и в августе 2023 выходит в полноценный релиз, о чём стало известно на церемонии "The Game Awards 2022". С момента выхода игры в...
Creating a project:
Launch Visual studio, select 'Create project', or hold Ctrl + Shift + N.
In the window that opens, we find the plugin template UnionPlugin_X_Xx for Visual C ++.
Click ok and look in the browser window.
We have the interfaces of 4 versions of ZenGin and several source code files. Now we need Application.cpp.
Open the file and you can see several functions. Each will be called automatically when a game event is performed:
- Game_Entry occurs when initializing game resources and entering the main menu.
- Game_Init occurs when the game ends correctly.
- Game_Exit occurs every time the frame is redrawn during the game.
- Game_Loop happens before saving starts.
- Game_SaveBegin occurs before saving starts.
- Game_SaveEnd occurs after saving is completed.
- LoadBegin before any game loading.
- LoadEnd occurs after any loading of the game
- Game_LoadBegin_NewGame happens before loading a new game.
- Game_LoadEnd_NewGame happens after loading a new game.
- Game_LoadBegin_SaveGame happens before loading a saved game.
- Game_LoadEnd_SaveGame occurs after loading a saved game.
- Game_LoadBegin_ChangeLevel happens before loading another location.
- Game_LoadEnd_ChangeLevel occurs after loading another location.
- Game_LoadBegin_Trigger occurs before loading another location via a trigger (before calling Game_LoadBegin_ChangeLevel).
- Game_LoadEnd_Trigger occurs before loading another location via a trigger (after calling Game_LoadEnd_ChangeLevel)
- Game_Pause occurs when a game is paused.
- Game_Unpause occurs when the game resumes.
- Game_DefineExternals occurs before initializing external script functions.
Program code implementation:
These functions will be basic in writing any plugin. Therefore, within the framework of the current tutorial, I propose to check how they work.
When entering the main menu, we will output a message with the name of the current plugin, version of Union and the current engine.
We will use the Game_Init function.
C++:
// The function returns the name of the engine based on its version.
string GetEngineVersionName(TEngineVersion version) {
switch( version ) {
case Engine_G1: return "Gothic I Classic";
case Engine_G1A: return "Gothic I Addon";
case Engine_G2: return "Gothic II Classic";
case Engine_G2A: return "Gothic II Addon";
}
return "Unknown";
}
void Game_Init() {
// We get a pointer to the current
// plugin and get its name
const CPlugin* plugin = CPlugin::GetCurrentPlugin();
string pluginName = plugin->GetName();
// Get the instance version of the union
// and convert it to a text string.
TVersion unionVersion = Union.GetUnionVersion();
string unionVersionName = unionVersion.ToString();
// Get the version of the engine and its name
TEngineVersion engineVersion = Union.GetEngineVersion();
string engineVersionName = GetEngineVersionName(engineVersion);
// Show a message on the screen
Message::Info( string::Combine(
"Plugin name: %s\nUnion version: %s\nEngine version: %s",
pluginName,
unionVersionName,
engineVersionName
) );
}
Compilation and running:
In the project 'Configuration manager', set 'Release'. We collect the project and add it to the ini file. We start the game and wait for the menu to load.