Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions Spore ModAPI/SourceCode/DLL/AddressesSimulator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ namespace Addresses(Simulator)
DefineAddress(sCreatureGameUnlockCategoriesCount, SelectAddress(0x1587278, 0x1583298));

DefineAddress(CreateUFO, SelectAddress(0x102BB50, 0x102AC60));
DefineAddress(SpawnUFO, SelectAddress(0x102BBB0, 0x102ACC0));

DefineAddress(SpawnNpcTribe, SelectAddress(0xC92860, 0xC932F0));
DefineAddress(sTribeFishHotSpots_ptr, SelectAddress(0x157EB90 ,0x157ABB0));
Expand Down Expand Up @@ -369,6 +370,8 @@ namespace Simulator
DefineAddress(UpdateAndGetColor, SelectAddress(0xC325F0, 0xC32E30));
DefineAddress(AddStarOwnership, SelectAddress(0xC33AB0, 0xC34300));
DefineAddress(RequireHomePlanet, SelectAddress(0xC30F90, 0xC31890));
DefineAddress(Destroy, SelectAddress(0xC33C30, 0xC34480));
DefineAddress(GetWeaponryLevel, SelectAddress(0xC31000, 0xC31900));
}

namespace Addresses(cEnergyRepairToolStrategy)
Expand Down Expand Up @@ -548,6 +551,8 @@ namespace Simulator
DefineAddress(ApplyRelationship, SelectAddress(0xD054E0, 0xD06280));
DefineAddress(RelationshipExists, SelectAddress(0xD010C0, 0xD01B90));
DefineAddress(GetRelationshipEventValue, SelectAddress(0xD010F0, 0xD01BC0));
DefineAddress(CalculateRelationship, SelectAddress(0xCFFF60, 0xD00950));
DefineAddress(CalculateRelationshipAbsolute, SelectAddress(0xD04CC0, 0xD05A60));
}

namespace Addresses(cGameBehaviorManager)
Expand Down Expand Up @@ -634,6 +639,9 @@ namespace Simulator
DefineAddress(GenerateSolSystem, SelectAddress(0xBB1A00, 0xBB2BF0));
DefineAddress(RequirePlanetsForStar, SelectAddress(0xBB3AA0, 0xBB4C90));
DefineAddress(GeneratePlanetsForStar, SelectAddress(0xBB30B0, 0xBB42A0));
DefineAddress(GetDefaultTerrainThemeFlora, SelectAddress(0xBABFF0, 0xBAD210));
DefineAddress(PickPlantSpecies, SelectAddress(0xBAB7A0, 0xBAC9C0));
DefineAddress(PickAnimalSpecies, SelectAddress(0xBABC40, 0xBACE60));
}

namespace Addresses(cSpaceTradeRouteManager)
Expand Down Expand Up @@ -1181,6 +1189,7 @@ namespace Simulator
DefineAddress(SetRareAsFound, SelectAddress(0x1040820, 0x103FBB0));
DefineAddress(GenerateNPCStore, SelectAddress(0x103F560, 0x103E8F0));
DefineAddress(CreateTradingObject, SelectAddress(0x103B470, 0x103A490));
DefineAddress(BuildSpiceCommodities, SelectAddress(0x0103D650, 0x0103C950));
}

namespace Addresses(cScenarioEditModeDisplayStrategy) {
Expand Down
4 changes: 4 additions & 0 deletions Spore ModAPI/SourceCode/Simulator/RelationshipManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ namespace Simulator

auto_METHOD(cRelationshipManager, float, GetRelationshipEventValue, Args(uint32_t id1, uint32_t id2, uint32_t eventId), Args(id1, id2, eventId));

auto_METHOD(cRelationshipManager, float, CalculateRelationship, Args(uint32_t id1, uint32_t id2, bool useCachedValue), Args(id1, id2, useCachedValue));

auto_METHOD(cRelationshipManager, float, CalculateRelationshipAbsolute, Args(uint32_t id1, uint32_t id2, bool useCachedValue), Args(id1, id2, useCachedValue));

bool cRelationshipManager::IsAtWar(uint32_t politicalID1, uint32_t politicalID2) {
return CALL(GetAddress(cRelationshipManager, IsAtWar2), bool, Args(cRelationshipManager*, uint32_t, uint32_t), Args(this, politicalID1, politicalID2));
}
Expand Down
2 changes: 2 additions & 0 deletions Spore ModAPI/SourceCode/Simulator/SimulatorSpaceGame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,5 +62,7 @@ namespace Simulator
auto_METHOD_VOID(cSpaceTrading, CreateTradingObject,
Args(cSpaceInventoryItemPtr& dst, const ResourceKey& itemID, int itemCount, float itemCost),
Args(dst, itemID, itemCount, itemCost));

auto_METHOD_VOID_(cSpaceTrading, BuildSpiceCommodities);
}
#endif
12 changes: 12 additions & 0 deletions Spore ModAPI/SourceCode/Simulator/StarManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,18 @@ namespace Simulator
Args(cStarRecord* pStarRecord, StarRequestFilter* pFilter, bool arg),
Args(pStarRecord, pFilter, arg));

auto_METHOD_VOID(cStarManager, GetDefaultTerrainThemeFlora,
Args(const ResourceKey& planetTerrainKey, eastl::vector<ResourceKey>& plantSpecies),
Args(planetTerrainKey, plantSpecies));

auto_METHOD_VOID(cStarManager, PickPlantSpecies,
Args(const eastl::vector<ResourceKey>& speciesIDs, int tScore, int numFullRows, int numFullColumns, bool fillAllSlots, eastl::vector<ResourceKey>& selections),
Args(speciesIDs, tScore, numFullRows, numFullColumns, fillAllSlots, selections));

auto_METHOD_VOID(cStarManager, PickAnimalSpecies,
Args(const eastl::vector<ResourceKey>& speciesIDs, int tScore, int numFullRows, int numHerbivoreSlots, int numCarnivoreSlots, eastl::vector<ResourceKey>& selections),
Args(speciesIDs, tScore, numFullRows, numHerbivoreSlots, numCarnivoreSlots, selections));

auto_STATIC_METHOD(cStarManager, bool, StarGenerationMessageHandler,
Args(uint32_t messageId, Swarm::Components::DistributeEffectMessageData* pDistributeData, StarType starType),
Args(messageId, pDistributeData, starType));
Expand Down
4 changes: 4 additions & 0 deletions Spore ModAPI/SourceCode/Simulator/cEmpire.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ namespace Simulator

auto_METHOD_(cEmpire, cPlanetRecord*, RequireHomePlanet);

auto_METHOD_VOID_(cEmpire, Destroy);

auto_METHOD_(cEmpire, int, GetWeaponryLevel);

cStarRecord* cEmpire::GetHomeStarRecord() {
if (mHomeStar.internalValue != -1) {
return StarManager.GetStarRecord(mHomeStar);
Expand Down
4 changes: 4 additions & 0 deletions Spore ModAPI/SourceCode/Simulator/cGameDataUFO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,9 @@ namespace Simulator
auto_METHOD_VOID(cGameDataUFO, Initialize, Args(UfoType type, cEmpire* empire), Args(type, empire));

auto_STATIC_METHOD(Simulator, cGameDataUFO*, CreateUFO, Args(UfoType type, cEmpire* empire), Args(type, empire));

auto_STATIC_METHOD(Simulator, cGameDataUFO*, SpawnUFO,
Args(UfoType type, const uint32_t& politicalID, const ResourceKey& modelKey),
Args(type, politicalID, modelKey));
}
#endif
6 changes: 6 additions & 0 deletions Spore ModAPI/Spore/Simulator/SubSystem/SpaceTrading.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,11 @@ namespace Simulator
/// @param itemCost Cost of the object
void CreateTradingObject(cSpaceInventoryItemPtr& dst, const ResourceKey& itemID, int itemCount, float itemCost);

/// Populates `mSpices` with the resource keys of every `.prop` file in the `GroupIDs::SpaceTrading_` group
/// whose `spaceTradingType` is set to `spice`.
/// Has no effect if `mSpices` is not empty.
void BuildSpiceCommodities();

public:
struct RareGroup {
/* 00h */ uint32_t mGroupID;
Expand Down Expand Up @@ -134,5 +139,6 @@ namespace Simulator
DeclareAddress(SetRareAsFound); // 0x1040820 0x103FBB0
DeclareAddress(GenerateNPCStore); // 0x103F560 0x103E8F0
DeclareAddress(CreateTradingObject); // 0x103B470 0x103A490
DeclareAddress(BuildSpiceCommodities); // 0x0103D650 0x0103C950
}
}
39 changes: 39 additions & 0 deletions Spore ModAPI/Spore/Simulator/SubSystem/StarManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,42 @@ namespace Simulator
/// @param useMaxPlanets If true, spawn the maximum amount of planets.
void GeneratePlanetsForStar(cStarRecord* pStarRecord, StarRequestFilter* pFilter, bool useMaxPlanets);

/// Gets the complete flora ecosystem associated with `planetTerrainKey`, or an arbitrary one if the terrain key doesn't have one.
/// @param planetTerrainKey
/// @param[out] plantSpecies Output vector with the flora for the terrain key: 3 big flora, 3 medium flora, and 3 small flora.
void GetDefaultTerrainThemeFlora(const ResourceKey& planetTerrainKey, eastl::vector<ResourceKey>& plantSpecies);

/// Picks the flora to use for a planet's food web from `speciesIDs`, according to the given parameters, and returns the result in `selections`.
/// @param speciesIDs Vector of 9 flora (3 big, 3 medium, 3 small) obtained from GetDefaultTerrainThemeFlora, from which `selections` is populated.
/// @param tScore Terrascore of the planet the flora is being chosen for, caps the number of flora placed into `selections`.
/// @param numFullRows Number between 0 and `tScore`, for each full row, one flora of each size (big, medium, small) is added to `selections`.
/// @param numFullColumns Number between 0 and 3, number of flora filling the uppermost row of the food web.
/// @param fillAllSlots If true, all 9 flora from `speciesIDs` are placed into `selections`, ignoring the other parameters.
/// @param[out] selections Output vector with the flora that were picked.
void PickPlantSpecies(
const eastl::vector<ResourceKey>& speciesIDs,
int tScore,
int numFullRows,
int numFullColumns,
bool fillAllSlots,
eastl::vector<ResourceKey>& selections);

/// Picks the animal species to use for a planet's food web from `speciesIDs`, according to the given parameters, and returns the result in `selections`.
/// @param speciesIDs Vector of 9 animals (6 herbivores, 3 carnivores) obtained from a previous call to PickAnimalSpecies,
/// from which `selections` is populated, if empty, the species are sourced elsewhere.
/// @param tScore Terrascore of the planet the species are being chosen for, caps the number of species placed into `selections`.
/// @param numFullRows Number between 0 and `tScore`, for each full row, 2 herbivores and 1 carnivore are added to `selections`.
/// @param numHerbivoreSlots Number between 0 and 2, number of herbivores filling the uppermost row of the food web.
/// @param numCarnivoreSlots Number between 0 and 1, number of carnivores filling the uppermost row of the food web.
/// @param[out] selections Output vector with the species that were picked.
void PickAnimalSpecies(
const eastl::vector<ResourceKey>& speciesIDs,
int tScore,
int numFullRows,
int numHerbivoreSlots,
int numCarnivoreSlots,
eastl::vector<ResourceKey>& selections);

/// Method used by the galaxy generation effect to create the cStarRecord instances. This method is the handler of the corresponding
/// `kMsgGalaxyGenerate...` messages, such as SimulatorMessages::kMsgGalaxyGenerateBlackHole. The method generates
/// one cStarRecord for every entry in the `pDistributeData` object.
Expand Down Expand Up @@ -347,6 +383,9 @@ namespace Simulator
DeclareAddress(GenerateSolSystem); // 0xBB1A00, 0xBB2BF0
DeclareAddress(RequirePlanetsForStar); // 0xBB3AA0 0xBB4C90
DeclareAddress(GeneratePlanetsForStar); // 0xBB30B0 0xBB42A0
DeclareAddress(GetDefaultTerrainThemeFlora); //0xBABFF0 0xBAD210
DeclareAddress(PickPlantSpecies); // 0xBAB7A0, 0xBAC9C0
DeclareAddress(PickAnimalSpecies); // 0xBABC40 0xBACE60
}

namespace Addresses(cSpaceTradeRouteManager)
Expand Down
19 changes: 19 additions & 0 deletions Spore ModAPI/Spore/Simulator/SubSystem/cRelationshipManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,23 @@ namespace Simulator
if (it != mRelationships.end()) { return &(it->second); } { return nullptr; }
}


/// Calculates the relationship value between two political entities, which is the sum of all the relationship events between the entities.
/// The value is capped between 10.0f and -10.0f.
/// @param politicalID1
/// @param politicalID2
/// @param useCachedValue If true, uses a cached value instead of performing the sum.
/// @returns The relationship value between the two political entities, capped between 10.0f and -10.0f.
float CalculateRelationship(uint32_t politicalID1, uint32_t politicalID2, bool useCachedValue);

/// Calculates the relationship value between two political entities, that being the sum of all the relationship events between the entities.
/// Unlike CalculateRelationship(), the value is not capped.
/// @param politicalID1
/// @param politicalID2
/// @param useCachedValue If true, uses a cached value instead of performing the sum.
/// @returns The relationship value between the two political entities.
float CalculateRelationshipAbsolute(uint32_t politicalID1, uint32_t politicalID2, bool useCachedValue);

public:
/* 10h */ float field_10;
/* 14h */ float field_14;
Expand Down Expand Up @@ -205,5 +222,7 @@ namespace Simulator
DeclareAddress(ApplyRelationship);
DeclareAddress(RelationshipExists);
DeclareAddress(GetRelationshipEventValue);
DeclareAddress(CalculateRelationship); // 0xCFFF60 0xD00950
DeclareAddress(CalculateRelationshipAbsolute); // 0xD04CC0 0xD05A60
}
}
17 changes: 15 additions & 2 deletions Spore ModAPI/Spore/Simulator/cEmpire.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,18 @@ namespace Simulator
/// Makes this empire the owner of the given star. It will emit a kMsgStarOwnershipChanged message.
void AddStarOwnership(cStarRecord* star);

/// Called when the empire loses its last system.
void Destroy();

/// Returns the empire's weaponry level, which determines the 'level' of the empire.
/// If `mWeaponry` is greater or equal than 0, that cached value is returned directly.
/// Otherwise, the level is calculated from the empire's number of star systems, using the
/// thresholds defined in `spaceshipWeaponEmpireSize` (SpaceCombat.prop), the result is then
/// cached in `mWeaponry` before being returned.
/// The Grox empire always has a weaponry level of 5.
/// @returns The empire's weaponry level.
int GetWeaponryLevel();

/// Captures a star system for a specific empire. This can only be used when the star belongs to another empire.
/// For any kind of star, use cEmpire::AddStarOwnership
/// @param pStarRecord The star system to capture.
Expand All @@ -104,8 +116,7 @@ namespace Simulator
/* C4h */ ResourceKey mCaptainKey;
/* D0h */ int mEmpireMoney;
/* D4h */ char mTravelDistance; // 3
//TODO sub_C31000 GetEmpireTier ?
/* D8h */ int field_D8; // -1 //TODO empire size? Related with combat tuning, check loc_C31039
/* D8h */ int mWeaponry; // -1
/* DCh */ float field_DC;
/* E0h */ float field_E0;
/* E4h */ float field_E4;
Expand Down Expand Up @@ -142,6 +153,8 @@ namespace Simulator
DeclareAddress(UpdateAndGetColor); // 0xC325F0 0xC32E30
DeclareAddress(AddStarOwnership); // 0xC33AB0 0xC34300
DeclareAddress(RequireHomePlanet); // 0xC30F90 0xC31890
DeclareAddress(Destroy); // 0xC33C30 0xC34480
DeclareAddress(GetWeaponryLevel); // 0xC31000 0xC31900
}

}
Expand Down
9 changes: 9 additions & 0 deletions Spore ModAPI/Spore/Simulator/cGameDataUFO.h
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,14 @@ namespace Simulator
DeclareAddress(Initialize); // 0xC3D8D0 0xC3E210
}

/// Spawns a new UFO instance of the given type and assigns it to the empire with the given politicalID.
/// It will have full AI, show up on the minimap, and have the color of the corresponding empire.
/// @param type
/// @param politicalID
/// @param modelKey Resource key of a UFO model, the spawned UFO will use this model.
/// @returns
cGameDataUFO* SpawnUFO(UfoType type, const uint32_t& politicalID, const ResourceKey& modelKey);

/// Creates a new UFO instance of the given type and assigned to the specified empire.
/// It will call cGameDataUFO::Initialize(), which sets up the necessary tools and AI.
/// @param type
Expand All @@ -144,4 +152,5 @@ namespace Simulator
namespace Addresses(Simulator)
{
DeclareAddress(CreateUFO); // 0x102BB50 0x102AC60
DeclareAddress(SpawnUFO); // 0x102BBB0 0x102ACC0
}
Loading