Isle
Loading...
Searching...
No Matches
jetski.cpp
Go to the documentation of this file.
1#include "jetski.h"
2
3#include "dunebuggy.h"
4#include "isle.h"
5#include "isle_actions.h"
6#include "jukebox_actions.h"
9#include "legonavcontroller.h"
10#include "legoutils.h"
11#include "legovariables.h"
12#include "legoworld.h"
13#include "misc.h"
14#include "mxmisc.h"
15#include "mxtransitionmanager.h"
16#include "mxvariabletable.h"
17#include "scripts.h"
18
20
21// These two have been changed between BETA10 and LEGO1
22// GLOBAL: LEGO1 0x100f7ab8
23// STRING: LEGO1 0x100f3ce0
24// GLOBAL: BETA10 0x101e0be4
25const char* g_varJSFRNTY5 = "c_jsfrnty5";
26
27// GLOBAL: LEGO1 0x100f7abc
28// STRING: LEGO1 0x100f3ca4
29// GLOBAL: BETA10 0x101e0be0
30const char* g_varJSWNSHY5 = "c_jswnshy5";
31
32// FUNCTION: LEGO1 0x1007e3b0
34{
35 m_maxLinearVel = 25.0;
36 m_unk0x150 = 2.0;
37 m_unk0x148 = 1;
38}
39
40// FUNCTION: LEGO1 0x1007e630
42{
43 MxResult result = IslePathActor::Create(p_dsAction);
45
46 if (m_world) {
47 m_world->Add(this);
48 }
49
51 return result;
52}
53
54// FUNCTION: LEGO1 0x1007e680
55void Jetski::Animate(float p_time)
56{
58
59 char buf[200];
60 float speed = abs(m_worldSpeed);
61 float maxLinearVel = NavController()->GetMaxLinearVel();
62
63 sprintf(buf, "%g", speed / maxLinearVel);
65}
66
67// FUNCTION: LEGO1 0x1007e6f0
69{
73 RemoveFromWorld();
77}
78
79// FUNCTION: LEGO1 0x1007e750
80// FUNCTION: BETA10 0x10037621
82{
83#ifndef BETA10
84 if (!FUN_1003ef60()) {
85 return 1;
86 }
87
89
90 ((Isle*) CurrentWorld())->SetDestLocation(LegoGameState::Area::e_jetski);
92
93 if (GameState()->GetActorId() != UserActor()->GetActorId()) {
95 }
96#endif
97
98 // Selects the windshield from `IsleScript::c_JetskiDashboard11_Bitmap` (=41)
99 // to `IsleScript::c_JetskiDashboard66_Bitmap` based on the user's color selection
101 m_jetskiDashboardStreamId = 10 * (colorOffset + 3);
103 m_jetskiDashboardStreamId += colorOffset;
104
105 InvokeAction(Extra::ActionType::e_start, *g_isleScript, m_jetskiDashboardStreamId, NULL);
107
108#ifdef BETA10
109 if (UserActor()->GetActorId() != GameState()->GetActorId()) {
110 ((IslePathActor*) UserActor())->Exit();
111 }
112 Enter();
113 ControlManager()->Register(this);
114 PlayCamAnim(this, FALSE, 0x44, TRUE);
115#else
117
120 Enter();
121 ControlManager()->Register(this);
122#endif
123
124 return 1;
125}
126
127// FUNCTION: LEGO1 0x1007e880
128void Jetski::RemoveFromWorld()
129{
130 RemoveFromCurrentWorld(*g_isleScript, m_jetskiDashboardStreamId);
135}
136
137// FUNCTION: LEGO1 0x1007e8e0
139{
140 if (p_param.m_unk0x28 == 1 && CurrentWorld()->IsA("Isle")) {
141 switch (p_param.m_clickedObjectId) {
143 Exit();
147 return 1;
149 ((Isle*) CurrentWorld())->SetDestLocation(LegoGameState::e_infomain);
151 Exit();
152 return 1;
153 }
154 }
155
156 return 0;
157}
158
159// FUNCTION: LEGO1 0x1007e990
161{
163
164 Act1State* act1state = (Act1State*) GameState()->GetState("Act1State");
165 if (!act1state->m_unk0x018) {
166 if (act1state->m_unk0x022) {
167 PlayCamAnim(this, FALSE, 68, TRUE);
168 }
169 else {
170 act1state->m_unk0x022 = TRUE;
171
172 LegoPathActor* user = UserActor();
173 if (user != NULL) {
174 MxMatrix mat(user->GetROI()->GetLocal2World());
175 mat.TranslateBy(mat[2][0] * 2.5, mat[2][1] + 0.6, mat[2][2] * 2.5);
176
179 &mat,
180 TRUE,
182 NULL,
183 FALSE,
184 TRUE,
185 TRUE,
186 TRUE
187 );
188 }
189 }
190 }
191}
[AI] Holds state and transient gameplay data for the first act on Lego Island.
Definition: isle.h:29
MxBool m_unk0x022
[AI] Temporary state variable; persists through serialization, often used for logic gating....
Definition: isle.h:110
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
Derived path actor type for handling player transitions and activities on LEGO Island.
Definition: islepathactor.h:23
@ c_spawnBit1
[AI] Bit flag to trigger additional camera/animation sequence during spawn. [AI]
Definition: islepathactor.h:30
@ c_playMusic
[AI] Bit flag to trigger background music playback on spawn. [AI]
Definition: islepathactor.h:31
@ c_spawnBit3
[AI] Unused/reserved extra spawn bit in flag set. [AI]
Definition: islepathactor.h:32
MxResult Create(MxDSAction &p_dsAction) override
[AI] Initialize this actor from a DSAction.
virtual void SpawnPlayer(LegoGameState::Area p_area, MxBool p_enter, MxU8 p_flags)
[AI] Spawns the player in a specific area/location, potentially triggering music and animation.
virtual void Exit()
[AI] Called when the actor is deactivated or moved out of player control, restoring previous actor if...
LegoWorld * m_world
[AI] Pointer to the current world instance actor is existing in. [AI]
virtual void Enter()
[AI] Called when the actor is made active in a new area or context, setting navigation and visibility...
[AI] Represents the main overworld (LEGO Island) in the game, acting as the central hub and state mac...
Definition: isle.h:179
[AI] Represents the jetski vehicle placed in the 3D world of LEGO Island.
Definition: jetski.h:19
MxLong HandleControl(LegoControlManagerNotificationParam &) override
[AI] Handles control notifications from the LegoControlManager (e.g., UI element actions,...
Definition: jetski.cpp:138
void ActivateSceneActions()
[AI] Activates scene-specific scripted actions, such as music or camera animations,...
Definition: jetski.cpp:160
MxResult Create(MxDSAction &p_dsAction) override
[AI] Creates and initializes the Jetski by adding it to the current world, initializing variables,...
Definition: jetski.cpp:41
MxBool IsA(const char *p_name) const override
[AI] Checks if this object is of type "Jetski" or a parent class by name.
Definition: jetski.h:35
MxLong HandleClick() override
[AI] Handles when the player clicks or interacts with the jetski.
Definition: jetski.cpp:81
void Exit() override
[AI] Handles jetski exit logic for the player, including hand-off to other actors,...
Definition: jetski.cpp:68
void Animate(float p_time) override
[AI] Updates jetski state for the current animation frame, including world speed, dashboard,...
Definition: jetski.cpp:55
virtual MxU8 GetActorId()
[AI] Gets this actor's numeric ID, corresponding to a known enumeration/actor.
Definition: legoactor.h:77
MxResult FUN_10060dc0(MxU32 p_objectId, MxMatrix *p_matrix, MxBool p_param3, MxU8 p_param4, LegoROI *p_roi, MxBool p_param6, MxBool p_param7, MxBool p_param8, MxBool p_param9)
[AI] Helper for starting a specific animation, including world matrix and camera settings.
@ e_unk0
[AI] Unknown/unspecified play mode
MxResult FUN_10064670(Vector3 *p_position)
[AI] Activates special triggered animation in response to player position near given point.
void FUN_1005f6d0(MxBool p_unk0x400)
[AI] Enables or disables extras (extra actors).
[AI] Notification parameter for the LegoControlManager, used to propagate information about control e...
MxS32 m_clickedObjectId
[AI] Object ID of the clicked control/presenter (or -1 if not set). [AI]
MxS16 m_unk0x28
[AI] Undetermined; settable via SetUnknown0x28. [AI]
void Register(MxCore *p_listener)
[AI] Adds a listener to be notified of control events.
void Unregister(MxCore *p_listener)
[AI] Removes a listener so it no longer receives control events.
LegoROI * GetROI()
[AI] Gets the ROI (Realtime Object Instance) associated with this entity. [AI]
Definition: legoentity.h:161
MxFloat m_worldSpeed
[AI] World-relative speed (can affect animation/movement logic). [AI]
Definition: legoentity.h:212
Area m_currentArea
Area/world the player is presently in. [AI].
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_unk66
Used for some spawn locations. [AI].
@ e_jetraceExterior
Jetski race transition? [AI].
@ e_unk45
Unknown [AI].
@ e_jetski
Jetski (vehicle, spawn). [AI].
MxFloat GetMaxLinearVel()
[AI] Returns the current maximum linear velocity (units per sec).
[AI] An actor that moves along a predefined path, supporting boundary transitions,...
Definition: legopathactor.h:32
virtual void Animate(float p_time)
[AI] Per-frame animation update.
virtual void Add(MxCore *p_object)
Adds an object (entity, presenter, ROI, etc.) to the appropriate world-managed list or set.
Definition: legoworld.cpp:418
virtual void TranslateBy(const float &p_x, const float &p_y, const float &p_z)
Applies translation by amounts along X, Y, Z axes.
[AI] Represents an action deserialized from SI chunks, holding key animation or script parameters suc...
Definition: mxdsaction.h:17
void SetObjectId(MxU32 p_objectId)
[AI] Sets the object id (for serialization or lookup).
Definition: mxdsobject.h:147
[AI] Represents a 4x4 transformation matrix, specialized for the LEGO Island engine and derived from ...
Definition: mxmatrix.h:16
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.
const Matrix4 & GetLocal2World() const
Accessor for the current local-to-world transformation matrix.
#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
#define NULL
[AI] Null pointer value (C/C++ semantics).
Definition: legotypes.h:26
void EnableAnimations(MxBool p_enable)
[AI] Enables or disables animation playback globally.
Definition: legoutils.cpp:554
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
MxBool RemoveFromCurrentWorld(const MxAtomId &p_atomId, MxS32 p_id)
[AI] Removes an entity or presenter with specified AtomId and ID from the current world; triggers End...
Definition: legoutils.cpp:495
MxBool FUN_1003ef60()
[AI] Determines if the current actor can exit their area, based on state/zone/vehicle.
Definition: legoutils.cpp:572
void PlayCamAnim(LegoPathActor *p_actor, MxBool p_unused, MxU32 p_location, MxBool p_bool)
[AI] Initiates a camera animation for a specific path actor, or falls back to default animation trigg...
Definition: legoutils.cpp:459
MxAtomId * g_isleScript
[AI] Node used in hierarchical scene graphs and animation trees. [AI]
Definition: scripts.cpp:32
const char * g_varJETSPEED
[AI] Global variable key for the jet vehicle's speed.
const char * g_varJETFUEL
[AI] Global variable key for the jet vehicle's fuel amount.
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
MxTransitionManager * TransitionManager()
[AI] Accessor for the MxTransitionManager, handling level transitions, fades, and world changes....
Definition: misc.cpp:208
MxDSAction & GetCurrentAction()
[AI] Accessor for the currently running MxDSAction (e.g.
Definition: misc.cpp:195
LegoControlManager * ControlManager()
[AI] Accessor for the control manager through the input manager; manages higher-level user/game contr...
Definition: misc.cpp:53
LegoWorld * CurrentWorld()
[AI] Accessor for the currently active LegoWorld instance. [AI]
Definition: misc.cpp:93
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
LegoNavController * NavController()
[AI] Accessor for the navigation controller, managing player/camera navigation. [AI]
Definition: misc.cpp:77
void PlayMusic(JukeboxScript::Script p_objectId)
[AI] Starts music playback by scripting the background audio manager to play the music piece referenc...
Definition: misc.cpp:216
LegoPathActor * UserActor()
[AI] Accessor for the user (player-controllable) LegoPathActor. [AI]
Definition: misc.cpp:85
void SetIsWorldActive(MxBool p_isWorldActive)
[AI] Toggles whether the world should be considered active (enables/disables camera/user control etc)...
Definition: misc.cpp:228
MxVariableTable * VariableTable()
[AI] Returns the variable table used for script variables and global key/value state.
Definition: mxmisc.cpp:73
MxLong MxResult
[AI]
Definition: mxtypes.h:106
int MxLong
[AI]
Definition: mxtypes.h:83
signed int MxS32
[AI]
Definition: mxtypes.h:38
@ c_JetskiSpeedMeter
Definition: isle_actions.h:58
@ c_JetskiFuelMeter
Definition: isle_actions.h:59
@ c_sjs007in_RunAnim
Definition: isle_actions.h:875
@ 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...
@ e_start
[AI] Start an activity or playback [AI]
Definition: extra.h:30