Isle
Loading...
Searching...
No Matches
jetskirace.cpp
Go to the documentation of this file.
1#include "jetskirace.h"
2
3#include "dunebuggy.h"
4#include "isle.h"
5#include "jetrace_actions.h"
6#include "jetski_actions.h"
7#include "jukebox_actions.h"
11#include "legomain.h"
12#include "legopathstruct.h"
13#include "legoracers.h"
14#include "legoracespecial.h"
15#include "legoutils.h"
16#include "misc.h"
19#include "mxmisc.h"
20#include "mxstillpresenter.h"
21#include "mxtransitionmanager.h"
22#include "mxvariabletable.h"
23#include "scripts.h"
24
25// Defined in legopathstruct.cpp
27
28// Defined in jetski.cpp
29extern const char* g_varJSFRNTY5;
30extern const char* g_varJSWNSHY5;
31
32// Defined in legopathactor.cpp
33extern const char* g_strHIT_WALL_SOUND;
34
36
37// GLOBAL: LEGO1 0x100f0c78
38MxS32 JetskiRace::g_unk0x100f0c78 = 2;
39
40// FUNCTION: LEGO1 0x100162c0
41// FUNCTION: BETA10 0x100c7e6f
42MxResult JetskiRace::Create(MxDSAction& p_dsAction)
43{
44 MxResult result = LegoRace::Create(p_dsAction);
45
48 LegoGameState* gameState = GameState();
49 RaceState* jetskiRaceState = (RaceState*) gameState->GetState("JetskiRaceState");
50
51 if (!jetskiRaceState) {
52 jetskiRaceState = (RaceState*) gameState->CreateState("JetskiRaceState");
53 }
54
55 m_raceState = jetskiRaceState;
56
57 if (!jetskiRaceState) {
58 return FAILURE;
59 }
60
61 m_raceState->m_unk0x28 = 1;
62 m_unk0x130.SetLeft(397);
63 m_unk0x130.SetTop(317);
64 m_unk0x130.SetRight(543);
65 m_unk0x130.SetBottom(333);
67
68 MxS32 streamId =
70 InvokeAction(Extra::e_start, m_atomId, streamId, NULL);
72
74
75 return result;
76}
77
78// FUNCTION: LEGO1 0x100163b0
79// FUNCTION: BETA10 0x100c7f10
81{
82 assert(m_hideAnim);
85
86 MxDSAction action;
90
92
93 m_unk0x128 = (MxStillPresenter*) Find("MxPresenter", "JetskiLocator2");
95 m_unk0x12c = (MxStillPresenter*) Find("MxPresenter", "JetskiLocator3");
97
99
100 VariableTable()->SetVariable("DISTANCE", "0.036");
101
103}
104
105// FUNCTION: LEGO1 0x10016520
107{
108 MxLong result = 0;
109
110 if ((p_param.GetAction()) && (p_param.GetAction()->GetObjectId() == JetraceScript::c_AirHorn_PlayWav)) {
111 m_maps[0]->Mute(FALSE);
112 m_maps[1]->Mute(FALSE);
113 m_maps[2]->Mute(FALSE);
114
116 result = 1;
117 }
118
119 return result;
120}
121
122// FUNCTION: LEGO1 0x100165a0
124{
125 MxLong result = 0;
126
127 if (((LegoControlManagerNotificationParam*) &p_param)->m_unk0x28 == 1) {
128 switch (((LegoControlManagerNotificationParam*) &p_param)->m_clickedObjectId) {
136 break;
143 result = 1;
145 break;
146 default:
147 break;
148 }
149 }
150
151 return result;
152}
153
154// FUNCTION: LEGO1 0x100166a0
155// FUNCTION: BETA10 0x100c8085
157{
158 MxLong result = 0;
159 MxEntity* sender = (MxEntity*) p_param.GetSender();
160
161 if (p_param.GetTrigger() == 68) {
162 MxS32 paramData = p_param.GetData();
163
164 switch (sender->GetEntityId()) {
165 case 10:
166 if (paramData <= m_unk0x104 || paramData >= m_unk0x104 + 5) {
167 break;
168 }
169
170 m_unk0x104 = paramData;
171 LegoChar buffer[20];
172 sprintf(buffer, "%g", 0.032 + 0.936 * (m_unk0xf8 * 20.0 + m_unk0x104) / (g_unk0x100f0c78 * 20.0));
173 VariableTable()->SetVariable("DISTANCE", buffer);
174
175 if (m_unk0x104 == 0x14) {
176 m_unk0x104 = 0;
177 m_unk0xf8++;
178
179 if (g_unk0x100f0c78 == m_unk0xf8) {
180 MxS32 position;
181
183 position = 3;
184 }
185 else if (m_unk0xfc < m_unk0xf8 || m_unk0x100 < m_unk0xf8) {
186 position = 2;
187 }
188 else {
189 position = 1;
190 }
191
196
197 RaceState::Entry* raceStateEntry = m_raceState->GetState(GameState()->GetActorId());
198 raceStateEntry->m_unk0x02 = position;
199
200 if (raceStateEntry->m_score < (MxS16) position) {
201 raceStateEntry->m_score = position;
202 }
203
205
207 }
208
209 result = 1;
210 }
211 else if (m_unk0x104 == 0xf) {
212 m_hideAnim->FUN_1006db40(m_unk0xf8 * 200 + 100);
213 result = 1;
214 }
215
216 break;
217 case 11:
218 if (paramData <= m_unk0x108 || paramData >= m_unk0x108 + 5) {
219 break;
220 }
221
222 FUN_10016930(11, paramData);
223 m_unk0x108 = paramData;
224
225 if (m_unk0x108 == 0x14) {
226 m_unk0x108 = 0;
227 m_unk0xfc++;
228
229 if (g_unk0x100f0c78 == m_unk0xfc) {
230 ((LegoPathActor*) p_param.GetSender())->SetMaxLinearVel(0.1);
231 }
232 }
233
234 break;
235 case 12:
236 if (paramData <= m_unk0x10c || paramData >= m_unk0x10c + 5) {
237 break;
238 }
239
240 FUN_10016930(12, paramData);
241
242 m_unk0x10c = paramData;
243
244 if (m_unk0x10c == 0x14) {
245 m_unk0x10c = 0;
246 m_unk0x100++;
247
248 if (g_unk0x100f0c78 == m_unk0x100) {
249 ((LegoPathActor*) p_param.GetSender())->SetMaxLinearVel(0.1);
250 }
251 }
252
253 break;
254 }
255 }
256
257 return result;
258}
259
260// FUNCTION: LEGO1 0x10016930
261void JetskiRace::FUN_10016930(MxS32 p_param1, MxS16 p_param2)
262{
263 MxS32 local4;
264 MxStillPresenter* presenter;
265 MxS32 x, y;
266
267 if (p_param1 == 11) {
268 presenter = m_unk0x128;
269 local4 = m_unk0xfc;
270 }
271 else if (p_param1 == 12) {
272 presenter = m_unk0x12c;
273 local4 = m_unk0x100;
274 }
275
276 if (presenter) {
277 x = m_unk0x130.GetLeft() + 0.5 +
278 (m_unk0x130.GetRight() - m_unk0x130.GetLeft() + 1) * (local4 * 20.0 + p_param2) / (g_unk0x100f0c78 * 20.0);
279 y = m_unk0x130.GetTop() + 0.5 +
280 (m_unk0x130.GetBottom() - m_unk0x130.GetTop() + 1) * (local4 * 20.0 + p_param2) / (g_unk0x100f0c78 * 20.0);
281
282 presenter->SetPosition(x, y);
283 }
284}
285
286// FUNCTION: LEGO1 0x10016a10
288{
290 DeleteObjects(&m_atomId, 500, 999);
296 return TRUE;
297}
MxU32 m_unk0x018
[AI] Internal gameplay state variable; see Get/SetUnknown18 for usage. [AI]
Definition: isle.h:92
static MxS32 GetColorOffset(const char *p_variable)
[AI] Determines the color offset index for the dune buggy dashboard based on a variable.
Definition: dunebuggy.cpp:161
[AI] LEGO Island's "Jetski" racing game logic and presenter class, derived from LegoRace.
Definition: jetskirace.h:13
MxLong HandleClick(LegoEventNotificationParam &) override
[AI] Handles click/interaction events on JetskiRace-specific controls or UI.
Definition: jetskirace.cpp:123
void ReadyWorld() override
[AI] Prepares the game world objects and scene for Jetski racing gameplay.
Definition: jetskirace.cpp:80
MxLong HandlePathStruct(LegoPathStructNotificationParam &) override
[AI] Handles path struct notifications during path/race progression.
Definition: jetskirace.cpp:156
MxLong HandleEndAction(MxEndActionNotificationParam &) override
[AI] Handles notifications when scripted actions end.
Definition: jetskirace.cpp:106
void FUN_10016930(MxS32 p_param1, MxS16 p_param2)
[AI] Updates auxiliary race progress presenters for opponents or other racers.
Definition: jetskirace.cpp:261
MxBool Escape() override
[AI] Handles escape/exit-from-minigame actions for JetskiRace.
Definition: jetskirace.cpp:287
void Mute(MxBool p_muted)
[AI] Mutes or unmutes the actor's current sound.
Definition: legoactor.cpp:144
void FUN_10061010(MxBool p_und)
[AI] Cancels all camera/transition animations and resets camera after completion.
void Resume()
[AI] Resumes animation manager from suspension, restoring all previously suspended state.
[AI] Notification parameter for the LegoControlManager, used to propagate information about control e...
Notification parameter class for LEGO event notifications such as mouse events and modifier keys.
Comprehensive persistent game state manager: handles save/load, player selection, area switching,...
Definition: legogamestate.h:78
Area m_currentArea
Area/world the player is presently in. [AI].
LegoState * CreateState(const char *p_stateName)
Creates an instance of given state, registers it, and returns pointer.
void StopArea(Area p_area)
Calls cleanup logic for the specified area (removes actors, VMs, closes handles, etc....
LegoState * GetState(const char *p_stateName)
Find an existing state (LegoState-derived) object by its registered script/class name.
@ e_infomain
Information Center, main screen. [AI].
Definition: legogamestate.h:96
@ e_jetraceExterior
Jetski race transition? [AI].
@ e_jetrace
Jetski race area, "interior"/main. [AI].
@ e_jetrace2
Jetski race (exterior). [AI].
@ e_undefined
Undefined or unset area. [AI].
Definition: legogamestate.h:93
void FUN_1006db40(LegoTime p_time)
[AI] Traverses the animation node hierarchy starting at the root and synchronizes visibility flags fo...
static void InitSoundIndices()
[AI] Initializes static indices for jetski-specific sound arrays to randomized starting positions.
Definition: legoracers.cpp:570
@ c_clearScreen
[AI] When set, clears the display surface. [AI]
Definition: legomain.h:49
@ c_disable3d
[AI] When set, disables 3D rendering. [AI]
Definition: legomain.h:48
@ c_disableInput
[AI] When set, disables input processing. [AI]
Definition: legomain.h:47
[AI] An actor that moves along a predefined path, supporting boundary transitions,...
Definition: legopathactor.h:32
[AI] Specialized notification parameter used for path structure related events in LEGO Island.
MxS16 GetData()
[AI] Retrieves the supplemental data associated with the notification.
MxU8 GetTrigger()
[AI] Returns the trigger type associated with this notification.
static void FUN_10012de0()
[AI] Resets static sound state variables for the car (last sound time, stopped flag,...
Definition: legoracers.cpp:204
MxStillPresenter * m_unk0x128
[AI] Unknown, likely for presenting stills during race transitions or cutscenes.
Definition: legorace.h:274
MxResult Create(MxDSAction &p_dsAction) override
[AI] Creates and initializes LegoRace world/logic for a DS action.
Definition: legorace.cpp:40
MxS32 m_unk0x104
[AI] Unknown (race-specific state/control variable).
Definition: legorace.h:267
MxS32 m_unk0x10c
[AI] Unknown (race-specific state/control variable).
Definition: legorace.h:269
RaceState * m_raceState
[AI] Stores persistent race state/results for the race world instance.
Definition: legorace.h:277
MxS32 m_unk0xfc
[AI] Unknown (race-specific state/control variable).
Definition: legorace.h:265
LegoGameState::Area m_destLocation
[AI] Destination location (area to switch to after race/transition).
Definition: legorace.h:271
MxRect32 m_unk0x130
[AI] Unknown 32-bit rectangle, possible HUD/viewport region.
Definition: legorace.h:276
LegoRaceMap * m_maps[3]
[AI] Map objects used by this race (main, alternate, or lap variants).
Definition: legorace.h:270
Act1State * m_act1State
[AI] Pointer to Act1State (first act/sequence logic).
Definition: legorace.h:273
MxStillPresenter * m_unk0x12c
[AI] Unknown, likely for presenting stills during race transitions or cutscenes.
Definition: legorace.h:275
MxS32 m_unk0x100
[AI] Unknown (race-specific state/control variable).
Definition: legorace.h:266
MxS32 m_unk0x108
[AI] Unknown (race-specific state/control variable).
Definition: legorace.h:268
MxS32 m_unk0xf8
[AI] Unknown (race-specific state/control variable).
Definition: legorace.h:264
virtual void ReadyWorld()
Called when the world is ready to be used—typically for custom scene setup after startup.
Definition: legoworld.cpp:874
LegoHideAnimPresenter * m_hideAnim
Animation presenter for ROI hide (vanish, fade, etc.) sequences.
Definition: legoworld.h:378
MxCore * Find(const char *p_class, const char *p_name)
Finds an object of a given class and name in the world.
Definition: legoworld.cpp:573
MxDSAction * GetAction()
[AI] Direct access to the underlying action.
MxResult PlayMusic(MxDSAction &p_action, undefined4 p_speed, MxPresenter::TickleState p_tickleState)
[AI] Initiates playback of a new background music action with specified speed and target tickle state...
[AI] Represents an action deserialized from SI chunks, holding key animation or script parameters suc...
Definition: mxdsaction.h:17
virtual void SetAtomId(MxAtomId p_atomId)
[AI] Sets the atom id for this object instance, used for indexing or lookup.
Definition: mxdsobject.h:118
void SetObjectId(MxU32 p_objectId)
[AI] Sets the object id (for serialization or lookup).
Definition: mxdsobject.h:147
MxU32 GetObjectId()
[AI] Returns the object id numeric value.
Definition: mxdsobject.h:130
[AI] Notification parameter marking the end of an action, specialization of MxActionNotificationParam...
MxEntity is a base class for game entities which are uniquely identified by an integer ID and an Atom...
Definition: mxentity.h:22
MxS32 GetEntityId()
Returns the current entity ID.
Definition: mxentity.h:93
MxAtomId m_atomId
The AtomId associated with this entity, used for resource and script identification.
Definition: mxentity.h:124
MxCore * GetSender() const
[AI] Retrieves the sender pointer associated with this notification.
@ e_repeating
[AI] Presentation is repeating (e.g., looping media).
Definition: mxpresenter.h:28
T GetTop() const
[AI] Get the top edge.
Definition: mxgeometry.h:231
T GetRight() const
[AI] Get the right edge.
Definition: mxgeometry.h:241
T GetLeft() const
[AI] Get the left edge.
Definition: mxgeometry.h:221
T GetBottom() const
[AI] Get the bottom edge.
Definition: mxgeometry.h:251
[AI] Presenter for single still image/bitmap media sources in the game.
virtual void SetPosition(MxS32 p_x, MxS32 p_y)
[AI] Sets the pixel-based position of the presented image.
MxResult StartTransition(TransitionType p_animationType, MxS32 p_speed, MxBool p_doCopy, MxBool p_playMusicInAnim)
[AI] Begins a new transition animation of type p_animationType at the specified speed,...
@ e_mosaic
[AI] Complex mosaic block-out effect.
void SetVariable(const char *p_key, const char *p_value)
Sets a variable by key and value, replacing or updating if it exists.
[AI] Maintains persistent information about race progress, results, and high scores for up to five ra...
Definition: legorace.h:28
undefined4 m_unk0x28
[AI] Unknown extra field, always initialized to zero.
Definition: legorace.h:138
Entry * GetState(MxU8 p_id)
[AI] Fetches a race state entry matching the given entry ID, or NULL if not found in the array.
Definition: legorace.cpp:151
#define TRUE
Definition: d3drmdef.h:28
#define FALSE
Definition: d3drmdef.h:27
#define DECOMP_SIZE_ASSERT(T, S)
Definition: decomp.h:19
const char * g_varJSWNSHY5
Definition: jetski.cpp:30
const char * g_varJSFRNTY5
Definition: jetski.cpp:25
const char * g_strHIT_WALL_SOUND
[AI] Variable table name for the wall hit sound [AI]
MxBool g_unk0x100f119c
const char * g_strHIT_WALL_SOUND
[AI] Variable table name for the wall hit sound [AI]
const char * g_raceState
[AI] Global variable storing the name of the race state variable (used for checking or setting state ...
const char * g_racing
[AI] Global variable storing the name of the racing state (used to check if the race is currently ong...
#define NULL
[AI] Null pointer value (C/C++ semantics).
Definition: legotypes.h:26
char LegoChar
[AI] Alias for char, for use in character/byte data and string handling.
Definition: legotypes.h:83
#define FAILURE
[AI] Used to indicate a failed operation in result codes.
Definition: legotypes.h:34
void InvokeAction(Extra::ActionType p_actionId, const MxAtomId &p_pAtom, MxS32 p_streamId, LegoEntity *p_sender)
[AI] Dispatches and triggers a game action on the given script or object.
Definition: legoutils.cpp:271
LegoGameState * GameState()
[AI] Accessor for the game's central game state controller. [AI]
Definition: misc.cpp:61
LegoAnimationManager * AnimationManager()
[AI] Accessor for the animation manager, which controls Lego character/world animation state....
Definition: misc.cpp:69
void DeleteObjects(MxAtomId *p_id, MxS32 p_first, MxS32 p_last)
[AI] Batch deletes objects, given by atom id, and within the entity id range [p_first,...
Definition: misc.cpp:237
MxTransitionManager * TransitionManager()
[AI] Accessor for the MxTransitionManager, handling level transitions, fades, and world changes....
Definition: misc.cpp:208
MxBackgroundAudioManager * BackgroundAudioManager()
[AI] Accessor for the background audio manager. Used for background music and ambient sounds....
Definition: misc.cpp:37
void FUN_10015820(MxBool p_disable, MxU16 p_flags)
[AI] Utility for enabling or disabling functionality in LegoOmni based on certain flags.
Definition: misc.cpp:143
MxVariableTable * VariableTable()
[AI] Returns the variable table used for script variables and global key/value state.
Definition: mxmisc.cpp:73
MxU8 MxBool
[AI]
Definition: mxtypes.h:124
MxLong MxResult
[AI]
Definition: mxtypes.h:106
int MxLong
[AI]
Definition: mxtypes.h:83
signed short MxS16
[AI]
Definition: mxtypes.h:26
signed int MxS32
[AI]
Definition: mxtypes.h:38
@ c_JetskiArms_Ctl
[AI] HUD control/entity for player's jetski arms or hands display.
@ c_JetskiDashboard
[AI] Parent dashboard control, aggregates dashboard bitmaps/controls.
@ c_AirHorn_PlayWav
[AI] Action to play airhorn WAV file (JetRace SFX).
@ c_JetskiInfo_Ctl
[AI] HUD control/entity for player's jetski info screen.
@ c_JetskiRace_Music
[AI] Music for the Jetski race event.
[AI] Contains global script AtomId pointers and utility functions for managing script AtomIds in LEGO...
MxAtomId * g_jukeboxScript
[AI] Script AtomId for the Jukebox entity/event script.
Definition: scripts.cpp:70
MxAtomId * g_jetraceScript
[AI] Script AtomId for jet racing-related scripts.
Definition: scripts.cpp:25
@ e_start
[AI] Start an activity or playback [AI]
Definition: extra.h:30
[AI] Entry for an individual race event/state, holding its identifier, unknown field,...
Definition: legorace.h:35
MxS16 m_unk0x02
[AI] Unknown field (usage unclear).
Definition: legorace.h:85
MxS16 m_score
[AI] High score for this race/entry.
Definition: legorace.h:86