Guide for Creating a New SSGM Plugin
Last Update: 24/03/2024 17:44:14
Author: TT
Loading...
# Creating a New SSGM Plugin
- Open scripts_vc2012.sln in Visual Studio 2012
- Ensure the drop down at the top (the one that says "Solution Configurations" when you mouse-over it) is set to "Release SSGM" and not to "Debug", "Debug SSGM"
or "Release".
- Select "build solution" to build the entire solution and verify that it all compiles without errors.
- Go to file-add-new project. Select "empty project",type in a name for your new plugin and press OK.
- Close Visual Studio
- Open scripts_vc2012.sln in notepad. Find the entry for your new project, it should look something like this:
```
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "test", "test\test.vcxproj", "{5D7F434F-E16C-4BA8-963B-4936727CF12F}"
EndProject
```
- Copy these lines in between the Project and EndProject lines
```
ProjectSection(ProjectDependencies) = postProject
{2FEF1C76-9E4A-4921-B2D3-E536DA918810} = {2FEF1C76-9E4A-4921-B2D3-E536DA918810}
{9B549C98-0BF4-4092-AE2A-AD7F780F8405} = {9B549C98-0BF4-4092-AE2A-AD7F780F8405}
EndProjectSection
```
- Copy the second number in brackets from the line referencing your project (so {5D7F434F-E16C-4BA8-963B-4936727CF12F} in our example) and search for it in the
file. You should find 8 lines similar to this:
```
{5D7F434F-E16C-4BA8-963B-4936727CF12F}.Debug SSGM|Win32.ActiveCfg = Debug|Win32
{5D7F434F-E16C-4BA8-963B-4936727CF12F}.Debug SSGM|Win32.Build.0 = Debug|Win32
{5D7F434F-E16C-4BA8-963B-4936727CF12F}.Debug|Win32.ActiveCfg = Debug|Win32
{5D7F434F-E16C-4BA8-963B-4936727CF12F}.Debug|Win32.Build.0 = Debug|Win32
{5D7F434F-E16C-4BA8-963B-4936727CF12F}.Release SSGM|Win32.ActiveCfg = Release|Win32
{5D7F434F-E16C-4BA8-963B-4936727CF12F}.Release SSGM|Win32.Build.0 = Release|Win32
{5D7F434F-E16C-4BA8-963B-4936727CF12F}.Release|Win32.ActiveCfg = Release|Win32
{5D7F434F-E16C-4BA8-963B-4936727CF12F}.Release|Win32.Build.0 = Release|Win32
```
- Change the bits after the equals sign so they say Debug SSGM|Win32 and Release SSGM|Win32, so it looks like this:
```
{5D7F434F-E16C-4BA8-963B-4936727CF12F}.Debug SSGM|Win32.ActiveCfg = Debug SSGM|Win32
{5D7F434F-E16C-4BA8-963B-4936727CF12F}.Debug SSGM|Win32.Build.0 = Debug SSGM|Win32
{5D7F434F-E16C-4BA8-963B-4936727CF12F}.Debug|Win32.ActiveCfg = Debug SSGM|Win32
{5D7F434F-E16C-4BA8-963B-4936727CF12F}.Debug|Win32.Build.0 = Debug SSGM|Win32
{5D7F434F-E16C-4BA8-963B-4936727CF12F}.Release SSGM|Win32.ActiveCfg = Release SSGM|Win32
{5D7F434F-E16C-4BA8-963B-4936727CF12F}.Release SSGM|Win32.Build.0 = Release SSGM|Win32
{5D7F434F-E16C-4BA8-963B-4936727CF12F}.Release|Win32.ActiveCfg = Release SSGM|Win32
{5D7F434F-E16C-4BA8-963B-4936727CF12F}.Release|Win32.Build.0 = Release SSGM|Win32
```
- Close scripts_vc2012.sln
- Go to the folder containing your new project (so test in my case)
- Delete the .vcxproj.filters and .vcxproj.user files
- Rename the .vcxproj file to temp.vcxproj
- Copy the contents of the example-plugin folder to the folder containing your new project
- Delete the example-plugin.vcxproj.user file
- Rename example-plugin.vcxproj, example-plugin.vcxproj.filters, exampleplugin.cpp and exampleplugin.h to the name of your new plugin (so e.g. test.vcxproj in
my case)
- Open temp.vcxproj and your new vcxproj file (so test.vcxproj) in notepad.
- Look for the ProjectGuid line in temp.vcxproj, like this:
```
<ProjectGuid>{5D7F434F-E16C-4BA8-963B-4936727CF12F}</ProjectGuid>
```
- Copy that to the new vcxproj file (so you are replacing this line)
```
<ProjectGuid>{F92D70BB-3091-41A9-801C-884E239C1263}</ProjectGuid>
```
- Close temp.vcxproj and delete it
- In the new vcxproj file, search for ExamplePlugin and change it to the name of your new plugin (test in my case). Take note of the capitalization.
- Close the new vcxproj file and open the vcxproj.filters file and change ExamplePlugin to the new name. Close the file.
- Open general.h and change EXAMPLEPLUGIN to the name of your new plugin then close it.
- Open the .cpp file for your new plugin and change ExamplePlugin to a suitable name for your new plugin, so Test in my case. Make sure you change the
#include line. Close the file.
- Open the .h file for your new plugin and change ExamplePlugin also.
- Now re-open scripts_vc2012.sln and hit "build solution". Your new plugin should compile.
- You are now ready to go ahead and start adding code to the file.
## Notes
- All source files must have #include "general.h" at the top of the file before the other #include lines
- You should no longer use std::* in scripts 4.0. Instead of std::string, use StringClass or WideStringClass. Instead of std::vector, use DynamicVectorClass.
- You no longer need to include source files from scripts (such as engine_xxx.cpp) into your plugin. SSGM 4.0 plugins will link directly to scripts.dll and
pull all the related code from there.
- SSGM logging is done via SSGMGameLog::Log_Message (which replaces FDSMessage) and SSGMGameLog::Log_Gamelog (which replaces WriteGamelog)
- INI settings are read from ssgm.ini via INIClass. Read gmmain.cpp and engine_io.h to see how it works. Also read the source code of plugins like CTF and
crates to see how plugins should be storing their configuration settings.
- Old SSGM plugins will not work with SSGM 4.0 and will need to be ported across
- If you are making any calls to Renegade or patching in any code (e.g. via hooks.dll or via _asm blocks) contact Jonathan Wilson over at Tiberian Technologies
to find out what the new version of the same hook, ASM block or engine function should be.
- Above all, read the source code and header files to understand stuff. A good way to find out how things have changed is to take the thing you are looking for
(such as BaseGameObjList) and search for it in one of the engine_xxx cpp files from the old scripts code. Then take the function that uses it and find the
same function in the new scripts code. Comparing the two functions will show you how the thing you want to use has been changed in 4.0.