Releases: emd4600/Spore-ModAPI
ModAPI SDK v2.5.195
Fixed compilation error
ModAPI SDK v2.5.179
Multiple features, from now on releases will be more frequent.
ModAPI SDK v2.5.155
Another test release with a few bugfixes.
ModAPI SDK v2.5.150
Test release, cannot be used publicly yet.
ModAPI SDK v2.5: Visual Studio 2019
One of the biggest updates to the SDK, this update has support for Visual Studio 2019, simplifies a lot how it's used, has fixed templates and improved documentation!
From now on updates will be more frequent, as updating is now a lot simpler and can be done from Visual Studio directly.
Installation tutorial: https://emd4600.github.io/Spore-ModAPI/_installation.html
Online documentation: https://emd4600.github.io/Spore-ModAPI
ModAPI SDK v2.4.0
Easier detouring (CppRevEng)
I've integrated my new reverse engineering library, CppRevEng
into the SDK. This makes detouring easier than ever. An example:
member_detour(RenderType_detour, App::cViewer, void(int, bool)) {
void detoured(int renderType, bool arg1)
{
if (renderType == 0xF) {
// When the game tries to use hologram, use the default render type instead
original_function(this, 0, arg1);
}
else {
original_function(this, renderType, arg1);
}
}
};
// In DllMain
PrepareDetours(hModule);
RenderType_detour::attach(GetAddress(App::cViewer, SetRenderType));
CommitDetours();
Editor requests
Now it's possible to enter an Editor from the code. You do so using the new Editors::EditorRequest
class.
More information here.
intrusive_ptr<EditorRequest> request = new EditorRequest();
request->editorID = id("CreatureEditorExtraLarge");
request->allowSporepedia = true;
request->hasSaveButton = true;
EditorRequest::Submit(request.get());
Sporepedia requests
Now it's possible to show the Sporepedia to the player, requesting them to pick a creation. This is done using the new Sporepedia::ShopperRequest
class.
More information here.
// `this` can also be whatever object that inherits from IShopperListener
Sporepedia::ShopperRequest request(this);
request.SetShopperID(id("MilitaryAirShopper"));
Simulator changes
The GetData
method now also accepts subclasses. For example, you can use GetData<cCombatant>()
to get all combatants (creatures, vehicles, buildings, etc). More information here.
There are also some new, useful methods:
PlanetModel::GetOrientation
gives you the correct orientation an object must have to lay on the surface of the planet.cCity::SpawnVehicle
spawns a vehicle next to the given city. This is the same that the buttons do in the Civilization stage.SpaceTeleportTo
instantly moves the player UFO into the given planet.
GameBehaviorManager
There's also a new class, the GameBehaviorManager
used to (presumably?) enable AI in Simulator objects. Or at least avoid crashes.
Graphics & Shaders
A new feature has been integrated into the graphics system: the shader load method. That's a method specific to every shader, that is executed just before any object that uses it is rendered. Now with the SDK you can replace it to load whatever you need in your shader, such as a custom generated texture.
This example makes the shader use a special texture, which shows what is currently being displayed on the screen.
BOOL LoadTvShader(RenderWare::Mesh<>* mesh)
{
// Apparently 0x15 is used for the main render target?
Graphics::RTT* rtt = Graphics::RenderTargetManager()->GetRTT(0x15);
if (rtt) {
Graphics::Renderer::SetTexture(0, rtt);
}
return Graphics::StandardShader::Load(mesh);
}
void ReplaceTvMaterial() {
auto material = Graphics::MaterialManager()->GetMaterial(id("TVScreen_MainColorRTT"));
if (material) {
auto shader = material->states[0]->pMaterialShader;
shader->SetLoadMethod(&LoadTvShader);
}
}
// In your initialization function
// This adds a listener to know when initialization has finished
App::MessageManager()->AddListener([](uint32_t messageID, void* data)
{
ReplaceTvMaterial();
return true;
}, { App::kMsgAppInitialized });
ModAPI SDK v2.3.1
This GitHub page hosts the develpment kit, used to create mods with the ModAPI. To use those mods, you need the ModAPI Launcher and Installers.
Pre-requisites
To use the ModAPI, you need to have installed:
- The Windows 10 SDK (you might need to use different versions if you don’t have Windows 10): https://developer.microsoft.com/en-US/windows/downloads/windows-10-sdk
- Visual Studio 2017. You can download the free version here: https://visualstudio.microsoft.com/vs/community/
Setting up the SDK
Download the Spore.ModAPI.Development.Kit.2.3.1.zip
file provided in this release. Unzip it to whatever directory you want (it will be your workspace).
Inside the folder you will find a file called Spore ModAPI Templates.vsix
. If you have installed Visual Studio correctly, you will be able to execute the file. Once the installer is open, press Install.
Finally, open Visual Studio. Go to Tools -> Code Snippets Manager… . In the dialog that opens, ensure that the Language: field is set to Visual C++. Press the button Add… and find the folder called ModAPISnippets, which is inside the ModAPI tools folder we unzipped before.
If you had already installed previous versions
For those that installed older versions of the ModAPI Development Kit, we need to take an extra step to get this working. If this is the first time you install it, you can skip this step.
- Open Visual Studio. Go to Tools -> Extensions and Updates… . There, find the item called Spore ModAPI Templates and uninstall it.
- Go to the directory
%APPDATA%\Microsoft\VisualStudio
. There you will see multiple folders, it’s recommended that you do these steps for all of them. Inside each of these folders, you go to ProjectTemplatesCache\Visual C++ Project. If you see a folder calledSpore ModAPI Template.zip
, delete it.
Now you can install the tempates as explained before.
Creating a project
Go to File -> New -> Project… . A dialog will open; under the tab Visual C++, select the template called Spore ModAPI Template. Now in the bottom part of the dialog there are two fields you must modify:
Name
: Insert the name of your mod; do not to use whitespaces.Location
: Where your mod files will be saved. Use the button Browse… to navigate to the Projects folder inside the ModAPI directory you unzipped before.
Now, there is one more thing you might need to do. Open the project configuration, ensure the Configuration box is set to All Configurations
like shown in the picture below. Now, in the General categories, there are two settings you must pay attention to.
Windows SDK Version
: Ensure this setting is set to the latest SDK version.Platform Toolset
: Ensure this setting is set to Visual Studio 2017 (not necessarily v141)