Spore-ModAPI

A C++ library that allows you to create advanced mods for Spore (user interface, shaders,...)

Stars
63

Bot releases are hidden (Show)

Spore-ModAPI - ModAPI SDK v2.5.209

Published by emd4600 about 2 years ago

Added several methods related with star properties:

  • GetBinarySystemStarTypes
  • GetBinarySystemBaseRadius
  • GetSolarStarTemperature
  • GetSolarStarMass
  • GetSolarStarRadius
  • GetSolarStarRotationRate
  • GetSolarStarOrbitRadius
  • GetPlanetTemperatureType
  • IsBinaryStar
  • IsNotStarOrBinaryStar
    For those that want to add new star types, detouring these star-related methods will be necessary.

The update also adds two new methods to the StarManager related with solar system generation:

  • RequirePlanetsForStar: Call this method when you want to access the planets of a star record. Planets are not generated when the galaxy is generated, but only when their star is first accessed; this method ensures the star will have planets.
  • GeneratePlanetsForStar: Called by RequirePlanetsForStar, this method is the one that actually generates planets and adds them to a solar system cStarRecord. Detour this function if you want to change how solar systems are generated.

Finally, a new class was added, Simulator::cSpaceGfx. This class has all the effects used to display the galaxy, the "skybox" in space, etc.

Spore-ModAPI - ModAPI SDK v2.5.205

Published by emd4600 about 2 years ago

This update contains many improvements to planets and stars:

  • Added many fields to cPlanetRecord and cStarRecord.
  • Improved StarID and PlanetID
  • Added class SpaceNames used to generate random names.
  • Added class ResourceKeyGenerator used to generate unique keys for creations/planets.
  • Now it is possible to create instances of cPlanetRecord with all the fields necessary.
  • Added some methods related with galaxy generation. One of them is cStarManager::GenerateSolSystem(), which is called when generating the galaxy to create the Sol system (which contains the Earth, etc). This method can be detoured to add special stars or planets during galaxy creation. For example, this simple method adds the Jupiter moon "Io":
member_detour(GenerateSolSystem__detour, Simulator::cStarManager, void())
{
	void detoured()
	{
		using namespace Simulator;

		original_function(this);

		auto solStar = GetSol();

		// 0 is the Earth, 1 is the Moon, 2 is Mercury, 3 is Venus, 4 is Mars, 5 is asteroid belt,
		// 6 is Jupiter,...
		auto jupiter = solStar->GetPlanetRecord(6);

		cPlanetRecordPtr planet;
		cPlanetRecord::Create(PlanetID(solStar->GetID(), solStar->mPlanetCount), planet);

		planet->mName = u"Io";
		planet->mType = PlanetType::T0;
		planet->mTechLevel = TechLevel::None;
		StarManager.GenerateEllipticalOrbit(solStar, planet->mOrbit, 21.0, 23.0, jupiter);

		planet->SetGeneratedTerrainKey(planet->GenerateTerrainKey());
		// I just used a random terrain script here
		TerrainResourceManager.SaveTerrain(planet->GetGeneratedTerrainKey(), id("crystal_hex"), 0x4184A200);

		StarManager.CalculatePlanetScores(planet.get());

		solStar->mPlanetCount++;
	}
};

void AttachDetours()
{
	attach_detour(GenerateSolSystem__detour, Simulator::cStarManager, GenerateSolSystem);
}
Spore-ModAPI - ModAPI SDK v2.5.203

Published by emd4600 about 2 years ago

Several improvements to classes EditorRigblock, EditorModel, cEditorResource, EditorBaseHandle, TuningSpine. Apart from completing the structure and fields of these classes, several interesting methods have been added related to editor models. An example of what you can do:

auto resource = new Editors::cEditorResource();
Editor.GetEditorModel()->Save(resource);

// ... 
// Later:
auto model = new Editors::EditorModel();
model->Load(resource);
Editor.SetEditorModel(model);

This saves the current creation into the resource object. That creation can be later restored in the editor creating a new model, loading the resource and setting it in the Editor.

Spore-ModAPI - ModAPI SDK v2.5.199

Published by emd4600 about 2 years ago

Adventure editor! Added many classes and functions related to the adventure editor (adventures are known in Spore code as "scenarios"):

  • cScenarioData
  • cScenarioPlayMode
  • cScenarioTerraformMode
  • cScenarioEditHistory
  • cScenarioPowerup

And many improvements to other classes. You can access most of this using ScenarioMode, like ScenarioMode.GetPlayMode()->SetCurrentAct(3); (to go to the fourth act when playing an adventure).

There have also been some improvements to audio support. Now it supports separate audio tracks which can play a single sound at a time, and a function to stop the sound. For example:

auto track = Audio::CreateAudioTrack();
Audio::PlayAudio(soundID, track);

// ... later ...
Audio::StopAudio(track);
Spore-ModAPI - ModAPI SDK v2.5.197

Published by emd4600 about 2 years ago

Fixed compilation error related with cGameData.

Spore-ModAPI - ModAPI SDK v2.5.195

Published by emd4600 about 2 years ago

Spore-ModAPI - ModAPI SDK v2.5.179

Published by emd4600 about 3 years ago

Multiple features, from now on releases will be more frequent.

Spore-ModAPI - ModAPI SDK v2.5.155

Published by emd4600 almost 4 years ago

Another test release with a few bugfixes.

Spore-ModAPI - ModAPI SDK v2.5.150

Published by emd4600 about 4 years ago

Test release, cannot be used publicly yet.

Spore-ModAPI - ModAPI SDK v2.5: Visual Studio 2019

Published by emd4600 over 4 years ago

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

Spore-ModAPI - ModAPI SDK v2.4.0

Published by emd4600 over 5 years ago

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 });

Spore-ModAPI - ModAPI SDK v2.3.1

Published by emd4600 over 5 years ago

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:

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.

  1. Open Visual Studio. Go to Tools -> Extensions and Updates… . There, find the item called Spore ModAPI Templates and uninstall it.
  2. 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 called Spore 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)

VS Project Configuration