Skip to content

Commit

Permalink
- Add Simulator::cTribeInputStrategy, with methods ChooseInputActionI…
Browse files Browse the repository at this point in the history
…D(), DoToolActionForAllSelected(), DoActionForAllSelected(), DoActionGeneric(), SetHoverObjectCursorAndRollover()

- Add enums Simulator::TribeInputAction and Simulator::CitizenAction
- Add cCreatureCitizen::DoAction()
- Add BundleManager::RemoveBundles()
- Add UI::SimulatorRollover::ShowRollover() (previous method has been renamed to ShowRolloverInternal())
- Rename GameViewManager::func30h() to GetHoveredObject()
  • Loading branch information
emd4600 committed Oct 10, 2024
1 parent 56de4b1 commit 38745a9
Show file tree
Hide file tree
Showing 16 changed files with 228 additions and 9 deletions.
11 changes: 11 additions & 0 deletions Spore ModAPI/SourceCode/DLL/AddressesSimulator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@
#include <Spore\Simulator\cTribe.h>
#include <Spore\Simulator\cTribeTool.h>
#include <Spore\Simulator\cTribeToolData.h>
#include <Spore\Simulator\cTribeInputStrategy.h>
#include <Spore\Simulator\SubSystem\cRelationshipManager.h>
#include <Spore\Simulator\SubSystem\GameBehaviorManager.h>
#include <Spore\Simulator\SubSystem\GameInputManager.h>
Expand Down Expand Up @@ -217,6 +218,7 @@ namespace Simulator

namespace Addresses(cCreatureCitizen) {
DefineAddress(Update, SelectAddress(0xC24210, 0xC24A30));
DefineAddress(DoAction, SelectAddress(0xC26EF0, 0xC27710));
}

namespace Addresses(cCreatureBase)
Expand Down Expand Up @@ -1145,6 +1147,15 @@ namespace Simulator
DefineAddress(Get, SelectAddress(0xB3D210, 0xB3D3B0));
DefineAddress(CreateBundles, SelectAddress(0xAC7810, 0xAC79F0));
}

namespace Addresses(cTribeInputStrategy) {
DefineAddress(DoToolActionForAllSelected, SelectAddress(0xCCFFE0, 0xCD09B0));
DefineAddress(DoActionForAllSelected, SelectAddress(0xCCFF70, 0xCD0940));
DefineAddress(ChooseInputActionID, SelectAddress(0xCCE870, 0xCCF130));
DefineAddress(DoActionGeneric, SelectAddress(0xCD0250, 0xCD0250));
DefineAddress(SetHoverObjectCursorAndRollover, SelectAddress(0xCCF800, 0xCD00C0));
DefineAddress(sIsInEditor_ptr, SelectAddress(0x168AD70, 0x1686AF0));
}
}

#ifdef SDK_TO_GHIDRA
Expand Down
3 changes: 2 additions & 1 deletion Spore ModAPI/SourceCode/DLL/AddressesUI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ namespace UI
namespace Addresses(SimulatorRollover)
{
DefineAddress(GetRolloverIdForObject, SelectAddress(0xB67960, 0xB67D70));
DefineAddress(ShowRollover, SelectAddress(0xB68790, 0xB68BA0));
DefineAddress(ShowRollover, SelectAddress(0xB69680, 0xB69A90));
DefineAddress(ShowRolloverInternal, SelectAddress(0xB68790, 0xB68BA0));
}
}
#endif
4 changes: 4 additions & 0 deletions Spore ModAPI/SourceCode/Simulator/cCreatureAnimal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
****************************************************************************/
#include <Spore\Simulator\cCreatureAnimal.h>
#include <Spore\Simulator\cCreatureCitizen.h>

namespace Simulator
{
Expand Down Expand Up @@ -94,5 +95,8 @@ namespace Simulator

auto_METHOD_VOID(cCreatureBase, ConsumeEnergy,
Args(float energyConsumed), Args(energyConsumed));


auto_METHOD_VOID(cCreatureCitizen, DoAction, Args(int actionId, cGameData* actionObject, App::Property* prop), Args(actionId, actionObject, prop));
}
#endif
20 changes: 20 additions & 0 deletions Spore ModAPI/SourceCode/Simulator/cTribe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <Spore\Simulator\cTribe.h>
#include <Spore\Simulator\cTribeTool.h>
#include <Spore\Simulator\cTribeToolData.h>
#include <Spore\Simulator\cTribeInputStrategy.h>

namespace Simulator
{
Expand Down Expand Up @@ -48,5 +49,24 @@ namespace Simulator

auto_STATIC_METHOD_VOID_(Simulator, DisposeTribeToolsData);


auto_METHOD(cTribeInputStrategy, int, ChooseInputActionID,
Args(cGameData* object, int unk), Args(object, unk));

auto_METHOD(cTribeInputStrategy, bool, DoToolActionForAllSelected,
Args(cTribeTool* tribeTool), Args(tribeTool));

auto_METHOD_VOID(cTribeInputStrategy, DoActionForAllSelected,
Args(int citizenActionId, cGameData* actionObject, int unk),
Args(citizenActionId, actionObject, unk));

auto_METHOD_VOID(cTribeInputStrategy, DoActionGeneric, Args(cGameData* actionObject), Args(actionObject));

auto_METHOD_VOID_(cTribeInputStrategy, SetHoverObjectCursorAndRollover);

bool cTribeInputStrategy::IsInEditor() {
return *(bool*)(GetAddress(cTribeInputStrategy, sIsInEditor_ptr));
}

}
#endif
7 changes: 5 additions & 2 deletions Spore ModAPI/SourceCode/UI/UI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,10 @@ namespace UI
auto_STATIC_METHOD(SimulatorRollover, SimulatorRolloverID, GetRolloverIdForObject,
Args(Simulator::cGameData* object), Args(object));

auto_STATIC_METHOD(SimulatorRollover, SimulatorRollover*, ShowRollover,
Args(SimulatorRolloverID rolloverId), Args(rolloverId));
auto_STATIC_METHOD_VOID(SimulatorRollover, ShowRollover,
Args(Simulator::cGameData* object), Args(object));

auto_STATIC_METHOD(SimulatorRollover, SimulatorRollover*, ShowRolloverInternal,
Args(Simulator::cGameData* object, SimulatorRolloverID rolloverId, float unk), Args(object, rolloverId, unk));
}
#endif
2 changes: 2 additions & 0 deletions Spore ModAPI/Spore ModAPI.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,8 @@
<ClInclude Include="Spore\App\IDGenerator.h" />
<ClInclude Include="Spore\App\JobManager.h" />
<ClInclude Include="Spore\App\Thumbnail_cImportExport.h" />
<ClInclude Include="Spore\Simulator\cBaseSimulatorInputStrategy.h" />
<ClInclude Include="Spore\Simulator\cTribeInputStrategy.h" />
<ClInclude Include="Spore\Simulator\cTribeToolData.h" />
<ClInclude Include="Spore\Simulator\SubSystem\BundleManager.h" />
<ClInclude Include="Spore\Simulator\SubSystem\CinematicManager.h" />
Expand Down
6 changes: 6 additions & 0 deletions Spore ModAPI/Spore ModAPI.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -2214,6 +2214,12 @@
<ClInclude Include="Spore\Simulator\SubSystem\BundleManager.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Spore\Simulator\cTribeInputStrategy.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Spore\Simulator\cBaseSimulatorInputStrategy.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="SourceCode\Allocator.cpp">
Expand Down
44 changes: 44 additions & 0 deletions Spore ModAPI/Spore/Simulator/SimulatorEnums.h
Original file line number Diff line number Diff line change
Expand Up @@ -722,4 +722,48 @@ namespace Simulator
kTribeBundleTypeMeat = 2,
kTribeBundleTypeFish = 3,
};

enum TribeInputAction
{
//TODO there are more

kTribeInputActionToolAttack1 = 19,
kTribeInputActionToolAttack2 = 20,
kTribeInputActionToolAttack3 = 21,
kTribeInputActionToolSocial1 = 22,
kTribeInputActionToolSocial2 = 23,
kTribeInputActionToolSocial3 = 24,
kTribeInputActionToolHeal = 25,
kTribeInputActionToolFirepit = 26,
};

enum CitizenAction
{
//TODO there are more
kCitizenActionEat = 0,
kCitizenActionFish = 1,
kCitizenActionGather = 2,
kCitizenActionGrabTool = 3,

kCitizenActionHeal = 5,

kCitizenActionAttack = 7,
kCitizenActionRaid1 = 8,
kCitizenActionGift1 = 9,
kCitizenActionHunt = 10,
kCitizenActionMate = 11,
kCitizenActionParty = 12,
kCitizenActionCollectEgg = 13,
kCitizenActionBundle = 14,

kCitizenActionRaid2 = 15,

kCitizenActionFeedWild = 20,
kCitizenActionGift2 = 21,

kCitizenActionRepair = 24,
kCitizenActionTame = 25,
kCitizenActionRecruit = 26,
kCitizenActionGatherMeat = 27,
};
}
9 changes: 9 additions & 0 deletions Spore ModAPI/Spore/Simulator/SubSystem/BundleManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@ namespace Simulator
/// @returns The last bundle created
cGameBundle* CreateBundles(float amount, cGameBundleContainer* container, int bundleType);

/// Removes a certain quantity from a bundle container. This will remove as many bundles as necessary,
/// and change the value of the last remaining bundle. If the amount is small enough, no bundle may be deleted.
/// @param amount
/// @param container
/// @param bundle If not null, removes only that specific bundle
/// @returns The actual amount that has been removed.
float RemoveBundles(float amount, cGameBundleContainer* container, cGameBundle* bundle = nullptr);

public:
/* 1Ch */ void* mpGroundContainer; //TODO cGameBundleGroundContainerPtr
};
Expand All @@ -30,5 +38,6 @@ namespace Simulator
namespace Addresses(cBundleManager) {
DeclareAddress(Get); // 0xB3D210 0xB3D3B0
DeclareAddress(CreateBundles); // 0xAC7810 0xAC79F0
DeclareAddress(RemoveBundles); // 0xAC7A70 TODO
}
}
6 changes: 5 additions & 1 deletion Spore ModAPI/Spore/Simulator/SubSystem/CinematicManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,11 @@ namespace Simulator
void PlayCinematic(const char* cinematicName, int arg0, int arg1, int arg2, int arg3, int arg4);

public:
/* 20h */ char padding_20[0x3c8 - 0x20];
/* 20h */ int field_20;
/* 24h */ int field_24;
/* 28h */ int field_28;
/* 2Ch */ int field_2C;
/* 30h */ char padding_30[0x3c8 - 0x30];
};
ASSERT_SIZE(cCinematicManager, 0x3C8);

Expand Down
4 changes: 2 additions & 2 deletions Spore ModAPI/Spore/Simulator/SubSystem/GameViewManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ namespace Simulator
/* 24h */ virtual void func24h_();
/* 28h */ virtual void func28h_();
/* 2Ch */ virtual void func2Ch_();
/* 30h */ virtual void func30h_(long nEllapsedMilliseconds);
/* 30h */ virtual cGameData* GetHoveredObject();
/* 34h */ virtual int func34h_(); // get cRotationRing?
/* 38h */ virtual Vector3 func38h_(int, struct Vector3);
/* 3Ch */ virtual Vector3 func3Ch_(int);
Expand Down Expand Up @@ -132,7 +132,7 @@ namespace Simulator
/* 24h */ eastl::intrusive_list<IGameDataView> mViews;
/* 2Ch */ eastl::fixed_vector<ModelPtr, 16> mGrassTrampModels;
/* 84h */ uint32_t mGameModeID; // -1
/* 88h */ cGameDataPtr field_88;
/* 88h */ cGameDataPtr mHoveredObject;
/* 8Ch */ eastl::hash_map<int, int> field_8C;
/* ACh */ eastl::vector<int> field_AC;
/* C0h */ bool field_C0;
Expand Down
22 changes: 22 additions & 0 deletions Spore ModAPI/Spore/Simulator/cBaseSimulatorInputStrategy.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#pragma once

#include <Spore\Internal.h>
#include <EASTL\map.h>

namespace Simulator
{
class cBaseSimulatorInputStrategy
{
public:
/* 00h */ virtual ~cBaseSimulatorInputStrategy();
/* 04h */ virtual void Initialize();
/* 08h */ virtual void func08h(int, int);
/* 0Ch */ virtual void func0Ch();
/* 10h */ virtual void func10h();

public:
/* 04h */ eastl::map<int, int> field_4;
/* 20h */ eastl::map<int, int> field_20;
};
ASSERT_SIZE(cBaseSimulatorInputStrategy, 0x3C);
}
9 changes: 9 additions & 0 deletions Spore ModAPI/Spore/Simulator/cCreatureCitizen.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@ namespace Simulator
using Object::Release;
using Object::Cast;

/// Programs this creature behavior tree data (i.e. its AI) to do a certain action from Simulator::CitizenAction.
/// The action is defined by an ID and an object to act on, for instance,
/// Simulator::kCitizenActionGrabTool and the cTribeTool object.
/// @param actionId
/// @param actionObject
/// @param property [Optional]
void DoAction(int actionId, cGameData* actionObject, App::Property* property = nullptr);

public:
/* FC0h */ int field_FC0; // 3
/* FC4h */ uint32_t mFavoredGrasperlikeAppendage; // -1
Expand All @@ -44,5 +52,6 @@ namespace Simulator

namespace Addresses(cCreatureCitizen) {
DeclareAddress(Update); // 0xC24210 0xC24A30
DeclareAddress(DoAction); // 0xC26EF0 0xC27710
}
}
2 changes: 1 addition & 1 deletion Spore ModAPI/Spore/Simulator/cSpatialObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ namespace Simulator
/* 4Ch */ virtual void SetIsOnView(bool bValue);
/* 50h */ virtual bool IsSelected();
/* 54h */ virtual void SetIsSelected(bool bValue);
/* 58h */ virtual bool cSpatialObject_func58h(); // does nothing by default
/* 58h */ virtual bool IsPlayerOwned(); // does nothing by default

/// Returns the local Y axis of this spatial object
/// @returns
Expand Down
79 changes: 79 additions & 0 deletions Spore ModAPI/Spore/Simulator/cTribeInputStrategy.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
#pragma once

#include <Spore\Simulator\cBaseSimulatorInputStrategy.h>
#include <Spore\Simulator\cGameData.h>
#include <Spore\Simulator\cTribeTool.h>
#include <Spore\App\IMessageListener.h>
#include <Spore\Clock.h>

namespace Simulator
{
class cTribeInputStrategy
/* 00h */ : public cBaseSimulatorInputStrategy
/* 3Ch */ , public App::IUnmanagedMessageListener
{
public:
/// Returns the input action ID (from Simulator::TribeInputAction) that the selected actors (e.g. tribe members) should do next.
/// This is called when hovering or clicking over objects such as tribal tools.
/// @param object
/// @param unk
/// @returns An action ID from TribeInputAction enum
int ChooseInputActionID(cGameData* object, int unk);

/// Makes selected tribe members act on a tribe tool. This might be repairing it if it's hurt,
/// grabbing the tool, or dancing around the fire pit.
/// @param tribeTool
bool DoToolActionForAllSelected(cTribeTool* tribeTool);

/// Makes selected tribe members do an action on an object.
/// This will call cCreatureCitizen::DoAction(), and may play a sound.
/// @param citizenActionId Action ID, from Simulator::CitizenAction
/// @param actionObject
/// @param unk
void DoActionForAllSelected(int citizenActionId, cGameData* actionObject, int unk = 0);

/// Called when the player inputs an action, this will do the appropriate action for
/// the selected tribe members and the given object (which will be the hovered object by the mouse).
/// The method calls ChooseInputActionID(), then chooses how to translate that into CitizenActions
/// that the tribe members will do.
/// @param actionObject
void DoActionGeneric(cGameData* actionObject);

/// Sets the current cursor, and maybe shows a rollover, depending on the current object
/// pointed at by the mouse cursor. The object will be cGameViewManager::GetHoveredObject()
/// The method will do nothing is IsInEditor() returns true.
void SetHoverObjectCursorAndRollover();

/// Returns true if the player has gone to the creature outfitter editor, false otherwise.
static bool IsInEditor();

public:
/* 40h */ int field_40;
/* 44h */ int field_44;
/* 48h */ int field_48;
/* 4Ch */ int field_4C;
/* 50h */ int field_50;
/* 54h */ int field_54;
/* 58h */ float field_58; // 225.0
/* 5Ch */ int field_5C;
/* 60h */ eastl::map<int, int> field_60;
/* 7Ch */ eastl::map<int, int> field_7C;
/* 98h */ int field_98;
/* 9Ch */ int field_9C;
/* A0h */ int field_A0;
/* A8h */ Clock field_A8;
/* C0h */ int field_C0;
/* C4h */ bool field_C4;
/* C8h */ int field_C8;
};
ASSERT_SIZE(cTribeInputStrategy, 0xD0);

namespace Addresses(cTribeInputStrategy) {
DeclareAddress(DoToolActionForAllSelected); // 0xCCFFE0 0xCD09B0
DeclareAddress(DoActionForAllSelected); // 0xCCFF70 0xCD0940
DeclareAddress(ChooseInputActionID); // 0xCCE870 0xCCF130
DeclareAddress(DoActionGeneric); // 0xCD0250 0xCD0250
DeclareAddress(SetHoverObjectCursorAndRollover); // 0xCCF800 0xCD00C0
DeclareAddress(sIsInEditor_ptr); // 0x168AD70 0x1686AF0
}
}
9 changes: 7 additions & 2 deletions Spore ModAPI/Spore/UI/SimulatorRollovers.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,11 @@ namespace UI
/// @returns
static SimulatorRolloverID GetRolloverIdForObject(Simulator::cGameData* object);

static SimulatorRollover* ShowRollover(SimulatorRolloverID rolloverId);
/// If possible, displays a rollover over the specificed Simulator object.
///
static void ShowRollover(Simulator::cGameData* object);

static SimulatorRollover* ShowRolloverInternal(Simulator::cGameData* object, SimulatorRolloverID rolloverId, float = -1.0f);

public:
/* 04h */ cGameDataPtr mpObject;
Expand Down Expand Up @@ -113,6 +117,7 @@ namespace UI
namespace Addresses(SimulatorRollover)
{
DeclareAddress(GetRolloverIdForObject); // 0xB67960 0xB67D70
DeclareAddress(ShowRollover); // 0xB68790 0xB68BA0
DeclareAddress(ShowRollover); // 0xB69680 0xB69A90
DeclareAddress(ShowRolloverInternal); // 0xB68790 0xB68BA0
}
}

0 comments on commit 38745a9

Please sign in to comment.