Skip to content

Commit fca03b6

Browse files
committed
Added some simulator messages and started cMission class (still incomplete)
1 parent 8c105bc commit fca03b6

File tree

7 files changed

+313
-10
lines changed

7 files changed

+313
-10
lines changed

Spore ModAPI/Spore/App/StandardMessage.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ namespace App
4141
float _float;
4242
double _double;
4343
Object* object;
44+
void* ptr;
4445
};
4546

4647
StandardMessage();

Spore ModAPI/Spore/Simulator/SimulatorMessages.h

Lines changed: 115 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121

2222
#include <Spore\Object.h>
2323
#include <Spore\ResourceKey.h>
24+
#include <Spore\App\StandardMessage.h>
25+
#include <Spore\Simulator\cMission.h>
2426

2527
namespace Simulator
2628
{
@@ -29,7 +31,28 @@ namespace Simulator
2931
/// Simulator::EnterEditorMessage; Enters the correct editor modifying the specified creation.
3032
kMsgEnterEditor = 0x53850BAE,
3133

32-
kMsgSwitchGameMode = 0x0212D3E7
34+
kMsgSwitchGameMode = 0x0212D3E7,
35+
36+
/// Simulator::GameNounStatusChangedMessage
37+
kMsgGameNounStatusChanged = 0x1A0219E,
38+
39+
/// Simulator::MissionUpdateMessage; every update of a mission, only if the mission is ongoing
40+
kMsgMissionUpdate = 0x38CF2FD,
41+
42+
/// Simulator::CombatantKilledMessage; called when a combatant is killed
43+
kMsgCombatantKilled = 0x1622184,
44+
45+
/// Simulator::PlayerEmpireAlliedMessage; called when the player empire makes a new alliance
46+
kMsgPlayerEmpireAllied = 0x4445D43,
47+
48+
/// Simulator::PlayerEmpireLostAllianceMessage; called when the player empire loses an alliance
49+
kMsgPlayerEmpireLostAlliance = 0x4445D44,
50+
51+
/// Called when a spaceship uses an sculpting or coloring tool and it hits the planet. No parameters.
52+
kMsgSculptOrColorToolHit = 0xF46092DB,
53+
54+
/// Simulator::ToolOnHitMessage; called when a space tool hits a target
55+
kMsgToolOnHit = 0x56690BB,
3356
};
3457

3558
class IMessageParameters
@@ -40,6 +63,7 @@ namespace Simulator
4063
virtual int Release() = 0;
4164
};
4265

66+
//TODO
4367
class EnterModeMessage
4468
{
4569
/* 08h */ uint32_t mModeID;
@@ -67,4 +91,94 @@ namespace Simulator
6791
/* 10h */ ResourceKey mCreationName;
6892
/* 1Ch */ int field_1C;
6993
};
94+
95+
/// Called every update of a mission, only if the mission is ongoing
96+
class MissionUpdateMessage : App::StandardMessage
97+
{
98+
public:
99+
static const uint32_t ID = kMsgMissionUpdate;
100+
101+
/// Returns the mission that updated.
102+
inline cMission* GetMission() {
103+
return (cMission*)params[0].object;
104+
}
105+
};
106+
107+
/// Called when a cCombatant is killed.
108+
class CombatantKilledMessage : App::StandardMessage
109+
{
110+
public:
111+
static const uint32_t ID = kMsgCombatantKilled;
112+
113+
/// Returns the combatant that was killed
114+
inline cCombatant* GetCombatant() {
115+
return (cCombatant*)params[0].ptr;
116+
}
117+
118+
/// Returns the combatant that attacked, might be null.
119+
inline cCombatant* GetAttacker() {
120+
return (cCombatant*)params[1].ptr;
121+
}
122+
};
123+
124+
/// Called when the player empire makes a new alliance
125+
class PlayerEmpireAlliedMessage : App::StandardMessage
126+
{
127+
public:
128+
static const uint32_t ID = kMsgPlayerEmpireAllied;
129+
130+
/// Returns the empire with whom the player made an alliance
131+
inline cEmpire* GetAlliedEmpire() {
132+
return (cEmpire*)params[0].ptr;
133+
}
134+
135+
/// Returns the player empire that just made the alliance
136+
inline cEmpire* GetPlayerEmpire() {
137+
return (cEmpire*)params[1].ptr;
138+
}
139+
};
140+
141+
/// Called when the player empire loses an alliance
142+
class PlayerEmpireLostAllianceMessage : App::StandardMessage
143+
{
144+
public:
145+
static const uint32_t ID = kMsgPlayerEmpireLostAlliance;
146+
147+
/// Returns the empire with whom the player had the an alliance
148+
inline cEmpire* GetAlliedEmpire() {
149+
return (cEmpire*)params[0].ptr;
150+
}
151+
152+
/// Returns the player empire that just lost the alliance
153+
inline cEmpire* GetPlayerEmpire() {
154+
return (cEmpire*)params[1].ptr;
155+
}
156+
};
157+
158+
/// Called when a space tool hits a target. Called by cToolStrategy::OnHit
159+
class ToolOnHitMessage : App::StandardMessage
160+
{
161+
public:
162+
static const uint32_t ID = kMsgToolOnHit;
163+
164+
/// Returns the key that identifies the tool, as returned by cSpaceToolData::GetItemID()
165+
inline const ResourceKey& GetAlliedEmpire() {
166+
return *(ResourceKey*)params[0].ptr;
167+
}
168+
};
169+
170+
class GameNounStatusChangedMessage : App::StandardMessage
171+
{
172+
public:
173+
static const uint32_t ID = kMsgGameNounStatusChanged;
174+
175+
inline int GetStatus() {
176+
return params[0].int32;
177+
}
178+
179+
/// Returns the noun, can be null
180+
inline cGameData* GetNoun() {
181+
return (cGameData*)params[1].ptr;
182+
}
183+
};
70184
}

Spore ModAPI/Spore/Simulator/cCombatant.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ namespace Simulator
8080
/// Returns the weapon tool used by this combatant. This is only available for vehicles.
8181
/* 14h */ virtual cSpaceToolData* GetWeapon();
8282

83-
/* 18h */ virtual int func18h(float, int, int, int, int); // used to substract health?
83+
/* 18h */ virtual int func18h(float damage, uint32_t attackerPoliticalID, int, const Vector3&, cCombatant* pAttacker); // used to substract health?
8484

8585
/* 1Ch */ virtual void AddHostileUnit(cCombatant* combatant);
8686
/* 20h */ virtual Math::Vector3 func20h();
@@ -127,15 +127,15 @@ namespace Simulator
127127
/* 08h */ bool field_8; // if true, it's ignored when checking mouse position
128128
/* 09h */ bool field_9;
129129
/* 0Ch */ map<int, int> field_0C;
130-
/* 28h */ intrusive_ptr<cCombatant> field_28;
130+
/* 28h */ cCombatantPtr mpLastAttacker;
131131
/* 2Ch */ float mMaxHealthPoints; // 10.0
132132
/* 30h */ intrusive_ptr<Object> field_30;
133-
/* 34h */ int field_34;
133+
/* 34h */ int field_34; // if dead, 2
134134
/* 38h */ float mHealthPoints; // 10.0
135-
/* 3Ch */ int mLastAttacker; // -1
135+
/* 3Ch */ uint32_t mLastAttacker; // -1
136136
/* 40h */ float mArmorProbability; // 0.5
137-
/* 44h */ intrusive_ptr<cCombatant> field_44;
138-
/* 48h */ intrusive_ptr<cCombatant> mpTarget;
137+
/* 44h */ cCombatantPtr field_44;
138+
/* 48h */ cCombatantPtr mpTarget;
139139
/* 4Ch */ Vector3 field_4C;
140140
/* 58h */ vector<Vector3> mAimPoints;
141141
/* 6Ch */ bool field_6C; // true, needsToLoadAimPoints?

Spore ModAPI/Spore/Simulator/cEmpire.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,8 @@ namespace Simulator
108108
/* C4h */ ResourceKey mCaptainKey;
109109
/* D0h */ int mEmpireMoney;
110110
/* D4h */ char mTravelDistance; // 3
111-
/* D8h */ int field_D8; // -1
111+
//TODO sub_C31000 GetEmpireTier ?
112+
/* D8h */ int field_D8; // -1 //TODO empire size? Related with combat tuning, check loc_C31039
112113
/* DCh */ float field_DC;
113114
/* E0h */ float field_E0;
114115
/* E4h */ float field_E4;

Spore ModAPI/Spore/Simulator/cGonzagoSimulator.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ namespace Simulator
3535

3636
/* 10h */ virtual void Update(int deltaTime, int);
3737
/* 14h */ virtual char16_t* GetName(int);
38-
/* 18h */ virtual void Load(int);
38+
/* 18h */ virtual void Load();
3939

4040
protected:
4141
/* 0Ch */ bool field_0C;
Lines changed: 187 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,187 @@
1+
#pragma once
2+
3+
#include <Spore\Simulator\cGameData.h>
4+
#include <Spore\Simulator\cCommEvent.h>
5+
#include <Spore\Simulator\cSpeciesProfile.h>
6+
#include <Spore\Simulator\cPlanet.h>
7+
#include <Spore\Simulator\cEmpire.h>
8+
#include <Spore\App\IMessageListener.h>
9+
#include <Spore\MathUtils.h>
10+
#include <Spore\LocalizedString.h>
11+
12+
#define cMissionPtr eastl::intrusive_ptr<Simulator::cMission>
13+
14+
namespace Simulator
15+
{
16+
enum MissionFlags
17+
{
18+
kMissionFlagIsEvent = 1,
19+
kMissionFlagHideStarName = 2,
20+
kMissionFlagHidePlanetName = 4,
21+
kMissionFlagIsTutorial = 8,
22+
kMissionFlagCannotAbort = 0x10,
23+
kMissionFlagTimerStartsOnFirstEntry = 0x20,
24+
kMissionFlagIsAdventure = 0x80,
25+
};
26+
27+
enum class MissionState
28+
{
29+
/// When the mission hasn't been accepted yet, and player is in the initial conversation
30+
Unaccepted = 0,
31+
/// The mission has been finished (not necessarily completed). After this, the mission is destroyed.
32+
Finished = 1,
33+
/// The player just accepted the mission, but it hasn't started yet.
34+
/// It immediately transitions to MissionState::Active
35+
Accepted = 2,
36+
/// The mission is currently active. While the mission is in this state, it receives calls to Update()
37+
Active = 3,
38+
/// The player has successfully completed the mission. It immediately transitions to MissionState::Finished,
39+
/// or to MissionState::StepCompleted if this is a sub-mission of a bigger mission.
40+
Completed = 5,
41+
/// The player has failed the mission. It immediately transitions to MissionState::Finished
42+
Failed = 6,
43+
/// The mission has been aborted. It immediately transitions to MissionState::Finished
44+
Aborted = 7,
45+
/// The mission has been aborted. It immediately transitions to MissionState::Finished
46+
Rejected = 8,
47+
/// When this mission is only a step of a bigger mission, and the step gets completed
48+
StepCompleted = 9
49+
};
50+
51+
class cMission
52+
: public cGameData
53+
, public App::IMessageListener
54+
{
55+
public:
56+
static const uint32_t TYPE = 0x2AA5ADA;
57+
58+
//TODO GetOwnerEmpire, GetTargetEmpire C44930
59+
//TODO SetState
60+
61+
/* 60h */ virtual int GetState();
62+
/* 64h */ virtual bool func64h(); // field_38.IsRunning()
63+
/* 68h */ virtual bool func68h(); // field_58.IsRunning()
64+
/* 6Ch */ virtual void func6Ch(); //TODO start?
65+
/* 70h */ virtual void func70h(); // field_58.Start()
66+
/* 74h */ virtual uint32_t GetCardWindowControlID(); // returns a window controlID
67+
/* 78h */ virtual void Initialize(); // related with parsing prop, called when mission is created
68+
/// Only called when state is 3, called every frame.
69+
/* 7Ch */ virtual MissionState Update(int deltaTime);
70+
/// Loads prop file
71+
/* 80h */ virtual void Load();
72+
/* 84h */ virtual void func84h();
73+
74+
/// Called when the player accepts the mission.
75+
/* 88h */ virtual void OnMissionAccept();
76+
77+
/// Called when the mission is rejected.
78+
/* 8Ch */ virtual void OnMissionReject();
79+
80+
/// Called when the mission is aborted.
81+
/* 90h */ virtual void OnMissionAbort();
82+
83+
/// Called when the mission is completed.
84+
/* 94h */ virtual void OnMissionCompleted();
85+
86+
/// Called when the mission is failed.
87+
/* 98h */ virtual void OnMissionFailed();
88+
89+
/// Causes this mission to fail.
90+
/* 9Ch */ virtual void FailMission();
91+
92+
/// Returns a description for this mission, usually the `description` property in the prop list.
93+
/// @param dst The string where the description will be stored
94+
/* A0h */ virtual string16* GetDescription(string16* dst);
95+
96+
/// Returns the ID of a `.cnv` conversation file used for the mission.
97+
/// If the mission has a parent, it will return the conversation of the parent.
98+
/* A4h */ virtual uint32_t GetConversationID();
99+
100+
/// Returns how much time the mission can last, in milliseconds. 0 if there is no time limit.
101+
/* A8h */ virtual int GetDuration();
102+
103+
/// For missions with a time limit, returns how much time is left (duration - elapsedTime). Otherwise, returns 0.
104+
/* ACh */ virtual int GetRemainingTime();
105+
106+
/* B0h */ virtual cSpeciesProfile* GetTargetAnimalSpecies();
107+
108+
/* E4h */ virtual uint32_t GetStarMapEffectGroup();
109+
/* E8h */ virtual uint32_t GetStarMapEffect();
110+
/// Returns how much money it costs to travel from the source planet to the target planet and back.
111+
/* ECh */ virtual int GetTravelCost();
112+
/// Returns how much distance to travel from the source planet to the target planet and back.
113+
/* F0h */ virtual float GetTravelDistance();
114+
/// Returns true if the given planet is the target planet of the mission, or false otherwise.
115+
/* F4h */ virtual bool IsTargetPlanet(cPlanetRecord* pPlanetRecord);
116+
/* F8h */ virtual bool funcF8h(); // returns false
117+
/* FCh */ virtual bool funcFCh(); // returns false
118+
/* 100h */ virtual bool func100h(); // returns false
119+
/* 104h */ virtual bool func104h();
120+
/* 108h */ virtual int func108h();
121+
/* 10Ch */ virtual uint32_t func10Ch();
122+
/* 110h */ virtual uint32_t func110h(int, int);
123+
/* 114h */ virtual void func114h(); // nothing
124+
125+
/// Called by the space token translator, used to replace special tokens in localized texts.
126+
/// For example, it is used to provide the target planet name, target species, etc
127+
/// @param tokenID id of the token (the token is a text, this is the FNV hash)
128+
/// @param dst Where the token text must be written.
129+
/// @returns True if the token was processed, false otherwise.
130+
/* 118h */ virtual bool TranslateToken(uint32_t tokenID, string16& dst);
131+
/// By default, `event_log_return_for_rewards`
132+
/* 11Ch */ virtual uint32_t GetCompletedEventLogID();
133+
/* 120h */ virtual bool func120h(); // returns false
134+
/* 124h */ virtual void func120h(int); // nothing
135+
/* 128h */ virtual bool func128h();
136+
137+
public:
138+
/* 38h */ cGonzagoTimer field_38;
139+
/* 58h */ cGonzagoTimer field_58;
140+
/* 78h */ uint32_t mMissionID;
141+
/* 7Ch */ unsigned int mElapsedTimeMS;
142+
/* 80h */ int mDuration;
143+
/* 84h */ int mState;
144+
/* 88h */ bool mSystemsShutdown;
145+
/* 8Ch */ uint32_t mOwnerEmpireID; // -1
146+
/// Owner empire. Use GetOwnerEmpire
147+
/* 90h */ cEmpirePtr mpOwnerEmpire;
148+
/* 94h */ uint32_t mTargetEmpireID; // -1
149+
/// Owner empire. Use GetTargetEmpire
150+
/* 98h */ cEmpirePtr mpTargetEmpire;
151+
/* 9Ch */ cPlanetPtr mpSourcePlanet;
152+
/* A0h */ float mRewardMoney;
153+
/* A4h */ ResourceKey mRewardToolID;
154+
/* B0h */ LocalizedString field_B0;
155+
/* C4h */ int mStarClue; // -1 //TODO cStarClue
156+
/* C8h */ int field_C4;
157+
/* CCh */ vector<int> field_CC;
158+
/* E0h */ vector<ObjectPtr> field_E0;
159+
/* F4h */ int mPlanetClue; //TODO cPlanetClue
160+
/* F8h */ int field_F8;
161+
/* FCh */ int field_FC;
162+
/* 100h */ uint32_t mStarMapIconEffectID;
163+
/* 104h */ int field_104;
164+
/* 108h */ vector<int> field_108;
165+
/* 11Ch */ vector<ResourceKey> mUnlockToolIDList;
166+
/* 130h */ int mFlags;
167+
/* 134h */ vector<int> field_134;
168+
/* 148h */ uint32_t mProgressEventID; // -1
169+
/* 14Ch */ string16 mTitle;
170+
/* 15Ch */ string16 field_15C;
171+
/* 16Ch */ cSpeciesProfile* mTargetAnimalSpecies;
172+
/* 170h */ ResourceKey mTargetAnimalSpeciesKey;
173+
/* 17Ch */ cMissionPtr mpParentMission;
174+
/* 180h */ PropertyListPtr mpPropList;
175+
/* 184h */ int mAcceptCost;
176+
/* 188h */ int mToolCost;
177+
/* 18Ch */ bool field_18C;
178+
/* 190h */ int mGiveOnAcceptMoney;
179+
/* 194h */ vector<ResourceKey> mGiveOnAcceptToolIDs;
180+
/* 1A8h */ vector<ResourceKey> mGiveOnAcceptAnimalIDs;
181+
/* 1BCh */ vector<ResourceKey> mGiveOnAcceptPlantIDs;
182+
/* 1D0h */ vector<int> field_1D0;
183+
/* 1E4h */ cCommEventPtr mpGalaxyCommEvent;
184+
/* 1E8h */ cPlanetPtr mpTargetPlanet;
185+
};
186+
ASSERT_SIZE(cMission, 0x1F0);
187+
}

Spore ModAPI/Spore/Simulator/cSpeciesProfile.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ namespace Simulator
3434

3535
//PLACEHOLDER 6D4h vector<intrusive_ptr<cCreatureAbility>>
3636

37-
/* 504h */ ResourceKey field_504;
37+
/* 504h */ ResourceKey field_504; //TODO this is the main key?
3838
/* 510h */ ResourceKey field_510;
3939
/* 51Ch */ string16 field_51C;
4040
/* 52Ch */ string16 field_52C;

0 commit comments

Comments
 (0)