Made trajectories overridable from Lua

This commit is contained in:
MysterD 2022-04-08 23:01:41 -07:00
parent ef63435bc1
commit defb7dc830
23 changed files with 229 additions and 134 deletions

View File

@ -227,7 +227,7 @@ def get_struct_field_info(struct, field):
lvt = translate_type_to_lvt(ftype)
lot = translate_type_to_lot(ftype)
fimmutable = str(lvt == 'LVT_COBJECT' or 'const ' in ftype).lower()
if lvt.startswith('LVT_') and lvt.endswith('_P') and 'OBJECT' not in lvt and 'COLLISION' not in lvt:
if lvt.startswith('LVT_') and lvt.endswith('_P') and 'OBJECT' not in lvt and 'COLLISION' not in lvt and 'TRAJECTORY' not in lvt:
fimmutable = 'true'
if sid in override_field_immutable:

View File

@ -7141,6 +7141,12 @@ function get_temp_object_hitbox()
-- ...
end
--- @param name string
--- @return Pointer_Trajectory
function get_trajectory(name)
-- ...
end
--- @param objList ObjectList
--- @return Object
function obj_get_first(objList)
@ -7441,3 +7447,4 @@ end
--- @class Pointer_BehaviorScript
--- @class Pointer_number
--- @class Pointer_Collision
--- @class Pointer_Trajectory

View File

@ -31,6 +31,9 @@ gPlayerSyncTable = {}
--- @type LevelValues
gLevelValues = {}
--- @type BehaviorValues
gBehaviorValues = {}
-----------
-- hooks --
-----------

View File

@ -72,6 +72,9 @@
--- @field public UnagiTrajectory Pointer_Trajectory
--- @class BehaviorValues
--- @field public KoopaBobAgility number
--- @field public KoopaCatchupAgility number
--- @field public KoopaThiAgility number
--- @field public trajectories BehaviorTrajectories
--- @class BullyCollisionData

View File

@ -40,6 +40,7 @@ Collision* dynos_collision_get(const char* collisionName);
void dynos_add_level(s32 modIndex, const char *modPath, const char* levelName);
const char* dynos_level_get_token(u32 index);
struct MovtexQuadCollection *dynos_level_get_movtexqc(s32 index);
Trajectory* dynos_level_get_trajectory(const char* name);
void dynos_level_load_background(void *ptr);
#endif

View File

@ -761,6 +761,7 @@ void DynOS_Lvl_Activate(s32 modIndex, const SysPath &aPackFolder, const char *aL
DataNode<TexData> *DynOS_Lvl_GetTexture(void *aPtr);
const char* DynOS_Lvl_GetToken(u32 index);
DataNode<MovtexQC> *DynOS_Lvl_GetMovtexQuadCollection(s32 index);
Trajectory* DynOS_Lvl_GetTrajectory(const char* aName);
void DynOS_Lvl_LoadBackground(void *aPtr);
void *DynOS_Lvl_Override(void *aCmd);

View File

@ -2044,7 +2044,7 @@ static bool DynOS_Lvl_GeneratePack_Internal(const SysPath &aPackFolder, Array<Pa
PrintNoNewLine("%s.lvl: Model identifier: %X - Processing... ", _LvlRootName.begin(), _GfxData->mModelIdentifier);
DynOS_Lvl_Parse(_GfxData, _LvlRoot, true);
// Force all of the movtexs and collisions into the compiled lvl
// Force all of the movtexs, collisions, and trajectories into the compiled lvl
for (auto &_Node : _GfxData->mMovtexs) {
if (_Node->mModelIdentifier != _GfxData->mModelIdentifier) { continue; }
DynOS_Movtex_Parse(_GfxData, _Node, false);
@ -2057,6 +2057,10 @@ static bool DynOS_Lvl_GeneratePack_Internal(const SysPath &aPackFolder, Array<Pa
if (_Node->mModelIdentifier != _GfxData->mModelIdentifier) { continue; }
DynOS_Col_Parse(_GfxData, _Node, false);
}
for (auto &_Node : _GfxData->mTrajectories) {
if (_Node->mModelIdentifier != _GfxData->mModelIdentifier) { continue; }
DynOS_Trajectory_Parse(_GfxData, _Node, false);
}
// Write if no error
if (_GfxData->mErrorCount == 0) {

View File

@ -119,6 +119,10 @@ struct MovtexQuadCollection *dynos_level_get_movtexqc(s32 index) {
return node->mData;
}
Trajectory* dynos_level_get_trajectory(const char* name) {
return DynOS_Lvl_GetTrajectory(name);
}
void dynos_level_load_background(void *ptr) {
DynOS_Lvl_LoadBackground(ptr);
}

View File

@ -831,12 +831,17 @@ static void DynOS_Level_ParseScript(const void *aScript, s32 (*aPreprocessFuncti
s16 *DynOS_Level_GetWarp(s32 aLevel, s32 aArea, u8 aWarpId) {
DynOS_Level_Init();
s16 *bestWarp = NULL;
for (const auto &_Warp : sDynosLevelWarps[aLevel]) {
if (_Warp.mArea == aArea && _Warp.mId == aWarpId) {
return (s16 *) &_Warp;
if (_Warp.mArea == aArea) {
if (_Warp.mId == aWarpId) {
return (s16 *) &_Warp;
} else {
bestWarp = (s16 *) &_Warp;
}
}
}
return NULL;
return bestWarp;
}
s16 *DynOS_Level_GetWarpEntry(s32 aLevel, s32 aArea) {

View File

@ -4,8 +4,14 @@ extern "C" {
#include "game/skybox.h"
}
struct OverrideLevelScript {
const void* originalScript;
const void* newScript;
GfxData* gfxData;
};
static Array<Pair<const char*, GfxData*>> sDynosCustomLevelScripts;
static Array<Pair<const void*, const void*>> sDynosOverrideLevelScripts;
static Array<struct OverrideLevelScript> sDynosOverrideLevelScripts;
Array<Pair<const char*, GfxData*>> &DynOS_Lvl_GetArray() {
return sDynosCustomLevelScripts;
@ -45,7 +51,7 @@ void DynOS_Lvl_Activate(s32 modIndex, const SysPath &aPackFolder, const char *aL
}
DynOS_Level_Override((void*)originalScript, newScriptNode->mData);
sDynosOverrideLevelScripts.Add({ originalScript, newScriptNode->mData});
sDynosOverrideLevelScripts.Add({ originalScript, newScriptNode->mData, _Node});
}
DataNode<TexData> *DynOS_Lvl_GetTexture(void *aPtr) {
@ -105,6 +111,17 @@ DataNode<MovtexQC> *DynOS_Lvl_GetMovtexQuadCollection(s32 index) {
return mMovtexQCs[index];
}
Trajectory* DynOS_Lvl_GetTrajectory(const char* aName) {
for (auto& script : sDynosCustomLevelScripts) {
for (auto& trajectoryNode : script.second->mTrajectories) {
if (trajectoryNode->mName == aName) {
return trajectoryNode->mData;
}
}
}
return NULL;
}
void DynOS_Lvl_LoadBackground(void *aPtr) {
// ensure this texture list exists
GfxData* foundGfxData = NULL;
@ -139,13 +156,11 @@ double_break:
}
void *DynOS_Lvl_Override(void *aCmd) {
for (auto& overridePair : sDynosOverrideLevelScripts) {
if (aCmd == overridePair.first || aCmd == overridePair.second) {
aCmd = (void*)overridePair.second;
for (auto& customPair : sDynosCustomLevelScripts) {
gLevelScriptModIndex = customPair.second->mModIndex;
gLevelScriptActive = (LevelScript*)aCmd;
}
for (auto& overrideStruct : sDynosOverrideLevelScripts) {
if (aCmd == overrideStruct.originalScript || aCmd == overrideStruct.newScript) {
aCmd = (void*)overrideStruct.newScript;
gLevelScriptModIndex = overrideStruct.gfxData->mModIndex;
gLevelScriptActive = (LevelScript*)aCmd;
}
}
return aCmd;

View File

@ -1335,6 +1335,7 @@
- smlua_obj_utils.h
- [get_temp_object_hitbox](#get_temp_object_hitbox)
- [get_trajectory](#get_trajectory)
- [obj_get_first](#obj_get_first)
- [obj_get_first_with_behavior_id](#obj_get_first_with_behavior_id)
- [obj_get_first_with_behavior_id_and_field_f32](#obj_get_first_with_behavior_id_and_field_f32)
@ -24957,6 +24958,26 @@ The `reliable` field will ensure that the packet arrives, but should be used spa
<br />
## [get_trajectory](#get_trajectory)
### Lua Example
`local PointerValue = get_trajectory(name)`
### Parameters
| Field | Type |
| ----- | ---- |
| name | `string` |
### Returns
- `Pointer` <`Trajectory`>
### C Prototype
`Trajectory* get_trajectory(const char* name);`
[:arrow_up_small:](#)
<br />
## [obj_get_first](#obj_get_first)
### Lua Example

View File

@ -135,34 +135,34 @@
| Field | Type | Access |
| ----- | ---- | ------ |
| BowlingBallBob2Trajectory | `Pointer` <`Trajectory`> | read-only |
| BowlingBallBobTrajectory | `Pointer` <`Trajectory`> | read-only |
| BowlingBallTtmTrajectory | `Pointer` <`Trajectory`> | read-only |
| KoopaBobTrajectory | `Pointer` <`Trajectory`> | read-only |
| KoopaThiTrajectory | `Pointer` <`Trajectory`> | read-only |
| Mips10Trajectory | `Pointer` <`Trajectory`> | read-only |
| Mips2Trajectory | `Pointer` <`Trajectory`> | read-only |
| Mips3Trajectory | `Pointer` <`Trajectory`> | read-only |
| Mips4Trajectory | `Pointer` <`Trajectory`> | read-only |
| Mips5Trajectory | `Pointer` <`Trajectory`> | read-only |
| Mips6Trajectory | `Pointer` <`Trajectory`> | read-only |
| Mips7Trajectory | `Pointer` <`Trajectory`> | read-only |
| Mips8Trajectory | `Pointer` <`Trajectory`> | read-only |
| Mips9Trajectory | `Pointer` <`Trajectory`> | read-only |
| MipsTrajectory | `Pointer` <`Trajectory`> | read-only |
| PlatformBitfsTrajectory | `Pointer` <`Trajectory`> | read-only |
| PlatformCcmTrajectory | `Pointer` <`Trajectory`> | read-only |
| PlatformHmcTrajectory | `Pointer` <`Trajectory`> | read-only |
| PlatformLll2Trajectory | `Pointer` <`Trajectory`> | read-only |
| PlatformLllTrajectory | `Pointer` <`Trajectory`> | read-only |
| PlatformRr2Trajectory | `Pointer` <`Trajectory`> | read-only |
| PlatformRr3Trajectory | `Pointer` <`Trajectory`> | read-only |
| PlatformRr4Trajectory | `Pointer` <`Trajectory`> | read-only |
| PlatformRrTrajectory | `Pointer` <`Trajectory`> | read-only |
| RacingPenguinTrajectory | `Pointer` <`Trajectory`> | read-only |
| SnowmanHeadTrajectory | `Pointer` <`Trajectory`> | read-only |
| Unagi2Trajectory | `Pointer` <`Trajectory`> | read-only |
| UnagiTrajectory | `Pointer` <`Trajectory`> | read-only |
| BowlingBallBob2Trajectory | `Pointer` <`Trajectory`> | |
| BowlingBallBobTrajectory | `Pointer` <`Trajectory`> | |
| BowlingBallTtmTrajectory | `Pointer` <`Trajectory`> | |
| KoopaBobTrajectory | `Pointer` <`Trajectory`> | |
| KoopaThiTrajectory | `Pointer` <`Trajectory`> | |
| Mips10Trajectory | `Pointer` <`Trajectory`> | |
| Mips2Trajectory | `Pointer` <`Trajectory`> | |
| Mips3Trajectory | `Pointer` <`Trajectory`> | |
| Mips4Trajectory | `Pointer` <`Trajectory`> | |
| Mips5Trajectory | `Pointer` <`Trajectory`> | |
| Mips6Trajectory | `Pointer` <`Trajectory`> | |
| Mips7Trajectory | `Pointer` <`Trajectory`> | |
| Mips8Trajectory | `Pointer` <`Trajectory`> | |
| Mips9Trajectory | `Pointer` <`Trajectory`> | |
| MipsTrajectory | `Pointer` <`Trajectory`> | |
| PlatformBitfsTrajectory | `Pointer` <`Trajectory`> | |
| PlatformCcmTrajectory | `Pointer` <`Trajectory`> | |
| PlatformHmcTrajectory | `Pointer` <`Trajectory`> | |
| PlatformLll2Trajectory | `Pointer` <`Trajectory`> | |
| PlatformLllTrajectory | `Pointer` <`Trajectory`> | |
| PlatformRr2Trajectory | `Pointer` <`Trajectory`> | |
| PlatformRr3Trajectory | `Pointer` <`Trajectory`> | |
| PlatformRr4Trajectory | `Pointer` <`Trajectory`> | |
| PlatformRrTrajectory | `Pointer` <`Trajectory`> | |
| RacingPenguinTrajectory | `Pointer` <`Trajectory`> | |
| SnowmanHeadTrajectory | `Pointer` <`Trajectory`> | |
| Unagi2Trajectory | `Pointer` <`Trajectory`> | |
| UnagiTrajectory | `Pointer` <`Trajectory`> | |
[:arrow_up_small:](#)
@ -172,6 +172,9 @@
| Field | Type | Access |
| ----- | ---- | ------ |
| KoopaBobAgility | `number` | |
| KoopaCatchupAgility | `number` | |
| KoopaThiAgility | `number` | |
| trajectories | [BehaviorTrajectories](structs.md#BehaviorTrajectories) | read-only |
[:arrow_up_small:](#)

View File

@ -740,11 +740,11 @@ static void koopa_the_quick_act_race(void) {
&& (o->oPathedPrevWaypointFlags & WAYPOINT_MASK_00FF) < 28) {
// Move faster if mario has already finished the race or
// cheated by shooting from cannon
o->oKoopaAgility = 8.0f;
o->oKoopaAgility = gBehaviorValues.KoopaCatchupAgility;
} else if (o->oKoopaTheQuickRaceIndex != KOOPA_THE_QUICK_BOB_INDEX) {
o->oKoopaAgility = 6.0f;
o->oKoopaAgility = gBehaviorValues.KoopaThiAgility;
} else {
o->oKoopaAgility = 4.0f;
o->oKoopaAgility = gBehaviorValues.KoopaBobAgility;
}
obj_forward_vel_approach(o->oKoopaAgility * 6.0f * downhillSteepness,

View File

@ -2,7 +2,7 @@
* Behavior for MIPS (everyone's favorite yellow rabbit).
*/
static const Trajectory** sMipsPaths[] = {
static Trajectory** sMipsPaths[] = {
&gBehaviorValues.trajectories.MipsTrajectory,
&gBehaviorValues.trajectories.Mips2Trajectory,
&gBehaviorValues.trajectories.Mips3Trajectory,

View File

@ -18,7 +18,7 @@ static void const *sPlatformOnTrackCollisionModels[] = {
/**
* Paths for the different instances of these platforms.
*/
static const Trajectory** sPlatformOnTrackPaths[] = {
static Trajectory** sPlatformOnTrackPaths[] = {
&gBehaviorValues.trajectories.PlatformRrTrajectory,
&gBehaviorValues.trajectories.PlatformRr2Trajectory,
&gBehaviorValues.trajectories.PlatformCcmTrajectory,

View File

@ -78,34 +78,37 @@ struct LevelValues gLevelValues = {
///////////////
struct BehaviorValues gBehaviorValues = {
.KoopaBobAgility = 4.0f,
.KoopaThiAgility = 6.0f,
.KoopaCatchupAgility = 8.0f,
.trajectories = {
.KoopaBobTrajectory = bob_seg7_trajectory_koopa,
.KoopaThiTrajectory = thi_seg7_trajectory_koopa,
.UnagiTrajectory = jrb_seg7_trajectory_unagi_1,
.Unagi2Trajectory = jrb_seg7_trajectory_unagi_2,
.SnowmanHeadTrajectory = ccm_seg7_trajectory_snowman,
.RacingPenguinTrajectory = ccm_seg7_trajectory_penguin_race,
.BowlingBallBobTrajectory = bob_seg7_metal_ball_path0,
.BowlingBallBob2Trajectory = bob_seg7_metal_ball_path1,
.BowlingBallTtmTrajectory = ttm_seg7_trajectory_070170A0,
.MipsTrajectory = inside_castle_seg7_trajectory_mips_0,
.Mips2Trajectory = inside_castle_seg7_trajectory_mips_1,
.Mips3Trajectory = inside_castle_seg7_trajectory_mips_2,
.Mips4Trajectory = inside_castle_seg7_trajectory_mips_3,
.Mips5Trajectory = inside_castle_seg7_trajectory_mips_4,
.Mips6Trajectory = inside_castle_seg7_trajectory_mips_5,
.Mips7Trajectory = inside_castle_seg7_trajectory_mips_6,
.Mips8Trajectory = inside_castle_seg7_trajectory_mips_7,
.Mips9Trajectory = inside_castle_seg7_trajectory_mips_8,
.Mips10Trajectory = inside_castle_seg7_trajectory_mips_9,
.PlatformRrTrajectory = rr_seg7_trajectory_0702EC3C,
.PlatformRr2Trajectory = rr_seg7_trajectory_0702ECC0,
.PlatformRr3Trajectory = rr_seg7_trajectory_0702ED9C,
.PlatformRr4Trajectory = rr_seg7_trajectory_0702EEE0,
.PlatformCcmTrajectory = ccm_seg7_trajectory_0701669C,
.PlatformBitfsTrajectory = bitfs_seg7_trajectory_070159AC,
.PlatformHmcTrajectory = hmc_seg7_trajectory_0702B86C,
.PlatformLllTrajectory = lll_seg7_trajectory_0702856C,
.PlatformLll2Trajectory = lll_seg7_trajectory_07028660,
.KoopaBobTrajectory = (Trajectory*) bob_seg7_trajectory_koopa,
.KoopaThiTrajectory = (Trajectory*) thi_seg7_trajectory_koopa,
.UnagiTrajectory = (Trajectory*) jrb_seg7_trajectory_unagi_1,
.Unagi2Trajectory = (Trajectory*) jrb_seg7_trajectory_unagi_2,
.SnowmanHeadTrajectory = (Trajectory*) ccm_seg7_trajectory_snowman,
.RacingPenguinTrajectory = (Trajectory*) ccm_seg7_trajectory_penguin_race,
.BowlingBallBobTrajectory = (Trajectory*) bob_seg7_metal_ball_path0,
.BowlingBallBob2Trajectory = (Trajectory*) bob_seg7_metal_ball_path1,
.BowlingBallTtmTrajectory = (Trajectory*) ttm_seg7_trajectory_070170A0,
.MipsTrajectory = (Trajectory*) inside_castle_seg7_trajectory_mips_0,
.Mips2Trajectory = (Trajectory*) inside_castle_seg7_trajectory_mips_1,
.Mips3Trajectory = (Trajectory*) inside_castle_seg7_trajectory_mips_2,
.Mips4Trajectory = (Trajectory*) inside_castle_seg7_trajectory_mips_3,
.Mips5Trajectory = (Trajectory*) inside_castle_seg7_trajectory_mips_4,
.Mips6Trajectory = (Trajectory*) inside_castle_seg7_trajectory_mips_5,
.Mips7Trajectory = (Trajectory*) inside_castle_seg7_trajectory_mips_6,
.Mips8Trajectory = (Trajectory*) inside_castle_seg7_trajectory_mips_7,
.Mips9Trajectory = (Trajectory*) inside_castle_seg7_trajectory_mips_8,
.Mips10Trajectory = (Trajectory*) inside_castle_seg7_trajectory_mips_9,
.PlatformRrTrajectory = (Trajectory*) rr_seg7_trajectory_0702EC3C,
.PlatformRr2Trajectory = (Trajectory*) rr_seg7_trajectory_0702ECC0,
.PlatformRr3Trajectory = (Trajectory*) rr_seg7_trajectory_0702ED9C,
.PlatformRr4Trajectory = (Trajectory*) rr_seg7_trajectory_0702EEE0,
.PlatformCcmTrajectory = (Trajectory*) ccm_seg7_trajectory_0701669C,
.PlatformBitfsTrajectory = (Trajectory*) bitfs_seg7_trajectory_070159AC,
.PlatformHmcTrajectory = (Trajectory*) hmc_seg7_trajectory_0702B86C,
.PlatformLllTrajectory = (Trajectory*) lll_seg7_trajectory_0702856C,
.PlatformLll2Trajectory = (Trajectory*) lll_seg7_trajectory_07028660,
},
};

View File

@ -47,37 +47,40 @@ extern struct LevelValues gLevelValues;
///////////////
struct BehaviorTrajectories {
const Trajectory* KoopaBobTrajectory;
const Trajectory* KoopaThiTrajectory;
const Trajectory* UnagiTrajectory;
const Trajectory* Unagi2Trajectory;
const Trajectory* SnowmanHeadTrajectory;
const Trajectory* RacingPenguinTrajectory;
const Trajectory* BowlingBallBobTrajectory;
const Trajectory* BowlingBallBob2Trajectory;
const Trajectory* BowlingBallTtmTrajectory;
const Trajectory* MipsTrajectory;
const Trajectory* Mips2Trajectory;
const Trajectory* Mips3Trajectory;
const Trajectory* Mips4Trajectory;
const Trajectory* Mips5Trajectory;
const Trajectory* Mips6Trajectory;
const Trajectory* Mips7Trajectory;
const Trajectory* Mips8Trajectory;
const Trajectory* Mips9Trajectory;
const Trajectory* Mips10Trajectory;
const Trajectory* PlatformRrTrajectory;
const Trajectory* PlatformRr2Trajectory;
const Trajectory* PlatformRr3Trajectory;
const Trajectory* PlatformRr4Trajectory;
const Trajectory* PlatformCcmTrajectory;
const Trajectory* PlatformBitfsTrajectory;
const Trajectory* PlatformHmcTrajectory;
const Trajectory* PlatformLllTrajectory;
const Trajectory* PlatformLll2Trajectory;
Trajectory* KoopaBobTrajectory;
Trajectory* KoopaThiTrajectory;
Trajectory* UnagiTrajectory;
Trajectory* Unagi2Trajectory;
Trajectory* SnowmanHeadTrajectory;
Trajectory* RacingPenguinTrajectory;
Trajectory* BowlingBallBobTrajectory;
Trajectory* BowlingBallBob2Trajectory;
Trajectory* BowlingBallTtmTrajectory;
Trajectory* MipsTrajectory;
Trajectory* Mips2Trajectory;
Trajectory* Mips3Trajectory;
Trajectory* Mips4Trajectory;
Trajectory* Mips5Trajectory;
Trajectory* Mips6Trajectory;
Trajectory* Mips7Trajectory;
Trajectory* Mips8Trajectory;
Trajectory* Mips9Trajectory;
Trajectory* Mips10Trajectory;
Trajectory* PlatformRrTrajectory;
Trajectory* PlatformRr2Trajectory;
Trajectory* PlatformRr3Trajectory;
Trajectory* PlatformRr4Trajectory;
Trajectory* PlatformCcmTrajectory;
Trajectory* PlatformBitfsTrajectory;
Trajectory* PlatformHmcTrajectory;
Trajectory* PlatformLllTrajectory;
Trajectory* PlatformLll2Trajectory;
};
struct BehaviorValues {
f32 KoopaBobAgility;
f32 KoopaThiAgility;
f32 KoopaCatchupAgility;
struct BehaviorTrajectories trajectories;
};

View File

@ -46,7 +46,7 @@ static void debug_warp_level1() {
}
static void debug_warp_level2() {
dynos_warp_to_level(LEVEL_WDW, 1, 1);
dynos_warp_to_level(LEVEL_WDW, 2, 1);
}
static void debug_grand_star(void) {

View File

@ -482,6 +482,7 @@ static int smlua__set_field(lua_State* L) {
case LVT_BEHAVIORSCRIPT_P:
case LVT_OBJECTANIMPOINTER_P:
case LVT_COLLISION_P:
case LVT_TRAJECTORY_P:
valuePointer = smlua_to_cpointer(L, 4, data->valueType);
if (gSmLuaConvertSuccess) {
*(u8**)p = valuePointer;

View File

@ -74,39 +74,42 @@ static struct LuaObjectField sAreaFields[LUA_AREA_FIELD_COUNT] = {
#define LUA_BEHAVIOR_TRAJECTORIES_FIELD_COUNT 28
static struct LuaObjectField sBehaviorTrajectoriesFields[LUA_BEHAVIOR_TRAJECTORIES_FIELD_COUNT] = {
{ "BowlingBallBob2Trajectory", LVT_TRAJECTORY_P, offsetof(struct BehaviorTrajectories, BowlingBallBob2Trajectory), true, LOT_POINTER },
{ "BowlingBallBobTrajectory", LVT_TRAJECTORY_P, offsetof(struct BehaviorTrajectories, BowlingBallBobTrajectory), true, LOT_POINTER },
{ "BowlingBallTtmTrajectory", LVT_TRAJECTORY_P, offsetof(struct BehaviorTrajectories, BowlingBallTtmTrajectory), true, LOT_POINTER },
{ "KoopaBobTrajectory", LVT_TRAJECTORY_P, offsetof(struct BehaviorTrajectories, KoopaBobTrajectory), true, LOT_POINTER },
{ "KoopaThiTrajectory", LVT_TRAJECTORY_P, offsetof(struct BehaviorTrajectories, KoopaThiTrajectory), true, LOT_POINTER },
{ "Mips10Trajectory", LVT_TRAJECTORY_P, offsetof(struct BehaviorTrajectories, Mips10Trajectory), true, LOT_POINTER },
{ "Mips2Trajectory", LVT_TRAJECTORY_P, offsetof(struct BehaviorTrajectories, Mips2Trajectory), true, LOT_POINTER },
{ "Mips3Trajectory", LVT_TRAJECTORY_P, offsetof(struct BehaviorTrajectories, Mips3Trajectory), true, LOT_POINTER },
{ "Mips4Trajectory", LVT_TRAJECTORY_P, offsetof(struct BehaviorTrajectories, Mips4Trajectory), true, LOT_POINTER },
{ "Mips5Trajectory", LVT_TRAJECTORY_P, offsetof(struct BehaviorTrajectories, Mips5Trajectory), true, LOT_POINTER },
{ "Mips6Trajectory", LVT_TRAJECTORY_P, offsetof(struct BehaviorTrajectories, Mips6Trajectory), true, LOT_POINTER },
{ "Mips7Trajectory", LVT_TRAJECTORY_P, offsetof(struct BehaviorTrajectories, Mips7Trajectory), true, LOT_POINTER },
{ "Mips8Trajectory", LVT_TRAJECTORY_P, offsetof(struct BehaviorTrajectories, Mips8Trajectory), true, LOT_POINTER },
{ "Mips9Trajectory", LVT_TRAJECTORY_P, offsetof(struct BehaviorTrajectories, Mips9Trajectory), true, LOT_POINTER },
{ "MipsTrajectory", LVT_TRAJECTORY_P, offsetof(struct BehaviorTrajectories, MipsTrajectory), true, LOT_POINTER },
{ "PlatformBitfsTrajectory", LVT_TRAJECTORY_P, offsetof(struct BehaviorTrajectories, PlatformBitfsTrajectory), true, LOT_POINTER },
{ "PlatformCcmTrajectory", LVT_TRAJECTORY_P, offsetof(struct BehaviorTrajectories, PlatformCcmTrajectory), true, LOT_POINTER },
{ "PlatformHmcTrajectory", LVT_TRAJECTORY_P, offsetof(struct BehaviorTrajectories, PlatformHmcTrajectory), true, LOT_POINTER },
{ "PlatformLll2Trajectory", LVT_TRAJECTORY_P, offsetof(struct BehaviorTrajectories, PlatformLll2Trajectory), true, LOT_POINTER },
{ "PlatformLllTrajectory", LVT_TRAJECTORY_P, offsetof(struct BehaviorTrajectories, PlatformLllTrajectory), true, LOT_POINTER },
{ "PlatformRr2Trajectory", LVT_TRAJECTORY_P, offsetof(struct BehaviorTrajectories, PlatformRr2Trajectory), true, LOT_POINTER },
{ "PlatformRr3Trajectory", LVT_TRAJECTORY_P, offsetof(struct BehaviorTrajectories, PlatformRr3Trajectory), true, LOT_POINTER },
{ "PlatformRr4Trajectory", LVT_TRAJECTORY_P, offsetof(struct BehaviorTrajectories, PlatformRr4Trajectory), true, LOT_POINTER },
{ "PlatformRrTrajectory", LVT_TRAJECTORY_P, offsetof(struct BehaviorTrajectories, PlatformRrTrajectory), true, LOT_POINTER },
{ "RacingPenguinTrajectory", LVT_TRAJECTORY_P, offsetof(struct BehaviorTrajectories, RacingPenguinTrajectory), true, LOT_POINTER },
{ "SnowmanHeadTrajectory", LVT_TRAJECTORY_P, offsetof(struct BehaviorTrajectories, SnowmanHeadTrajectory), true, LOT_POINTER },
{ "Unagi2Trajectory", LVT_TRAJECTORY_P, offsetof(struct BehaviorTrajectories, Unagi2Trajectory), true, LOT_POINTER },
{ "UnagiTrajectory", LVT_TRAJECTORY_P, offsetof(struct BehaviorTrajectories, UnagiTrajectory), true, LOT_POINTER },
{ "BowlingBallBob2Trajectory", LVT_TRAJECTORY_P, offsetof(struct BehaviorTrajectories, BowlingBallBob2Trajectory), false, LOT_POINTER },
{ "BowlingBallBobTrajectory", LVT_TRAJECTORY_P, offsetof(struct BehaviorTrajectories, BowlingBallBobTrajectory), false, LOT_POINTER },
{ "BowlingBallTtmTrajectory", LVT_TRAJECTORY_P, offsetof(struct BehaviorTrajectories, BowlingBallTtmTrajectory), false, LOT_POINTER },
{ "KoopaBobTrajectory", LVT_TRAJECTORY_P, offsetof(struct BehaviorTrajectories, KoopaBobTrajectory), false, LOT_POINTER },
{ "KoopaThiTrajectory", LVT_TRAJECTORY_P, offsetof(struct BehaviorTrajectories, KoopaThiTrajectory), false, LOT_POINTER },
{ "Mips10Trajectory", LVT_TRAJECTORY_P, offsetof(struct BehaviorTrajectories, Mips10Trajectory), false, LOT_POINTER },
{ "Mips2Trajectory", LVT_TRAJECTORY_P, offsetof(struct BehaviorTrajectories, Mips2Trajectory), false, LOT_POINTER },
{ "Mips3Trajectory", LVT_TRAJECTORY_P, offsetof(struct BehaviorTrajectories, Mips3Trajectory), false, LOT_POINTER },
{ "Mips4Trajectory", LVT_TRAJECTORY_P, offsetof(struct BehaviorTrajectories, Mips4Trajectory), false, LOT_POINTER },
{ "Mips5Trajectory", LVT_TRAJECTORY_P, offsetof(struct BehaviorTrajectories, Mips5Trajectory), false, LOT_POINTER },
{ "Mips6Trajectory", LVT_TRAJECTORY_P, offsetof(struct BehaviorTrajectories, Mips6Trajectory), false, LOT_POINTER },
{ "Mips7Trajectory", LVT_TRAJECTORY_P, offsetof(struct BehaviorTrajectories, Mips7Trajectory), false, LOT_POINTER },
{ "Mips8Trajectory", LVT_TRAJECTORY_P, offsetof(struct BehaviorTrajectories, Mips8Trajectory), false, LOT_POINTER },
{ "Mips9Trajectory", LVT_TRAJECTORY_P, offsetof(struct BehaviorTrajectories, Mips9Trajectory), false, LOT_POINTER },
{ "MipsTrajectory", LVT_TRAJECTORY_P, offsetof(struct BehaviorTrajectories, MipsTrajectory), false, LOT_POINTER },
{ "PlatformBitfsTrajectory", LVT_TRAJECTORY_P, offsetof(struct BehaviorTrajectories, PlatformBitfsTrajectory), false, LOT_POINTER },
{ "PlatformCcmTrajectory", LVT_TRAJECTORY_P, offsetof(struct BehaviorTrajectories, PlatformCcmTrajectory), false, LOT_POINTER },
{ "PlatformHmcTrajectory", LVT_TRAJECTORY_P, offsetof(struct BehaviorTrajectories, PlatformHmcTrajectory), false, LOT_POINTER },
{ "PlatformLll2Trajectory", LVT_TRAJECTORY_P, offsetof(struct BehaviorTrajectories, PlatformLll2Trajectory), false, LOT_POINTER },
{ "PlatformLllTrajectory", LVT_TRAJECTORY_P, offsetof(struct BehaviorTrajectories, PlatformLllTrajectory), false, LOT_POINTER },
{ "PlatformRr2Trajectory", LVT_TRAJECTORY_P, offsetof(struct BehaviorTrajectories, PlatformRr2Trajectory), false, LOT_POINTER },
{ "PlatformRr3Trajectory", LVT_TRAJECTORY_P, offsetof(struct BehaviorTrajectories, PlatformRr3Trajectory), false, LOT_POINTER },
{ "PlatformRr4Trajectory", LVT_TRAJECTORY_P, offsetof(struct BehaviorTrajectories, PlatformRr4Trajectory), false, LOT_POINTER },
{ "PlatformRrTrajectory", LVT_TRAJECTORY_P, offsetof(struct BehaviorTrajectories, PlatformRrTrajectory), false, LOT_POINTER },
{ "RacingPenguinTrajectory", LVT_TRAJECTORY_P, offsetof(struct BehaviorTrajectories, RacingPenguinTrajectory), false, LOT_POINTER },
{ "SnowmanHeadTrajectory", LVT_TRAJECTORY_P, offsetof(struct BehaviorTrajectories, SnowmanHeadTrajectory), false, LOT_POINTER },
{ "Unagi2Trajectory", LVT_TRAJECTORY_P, offsetof(struct BehaviorTrajectories, Unagi2Trajectory), false, LOT_POINTER },
{ "UnagiTrajectory", LVT_TRAJECTORY_P, offsetof(struct BehaviorTrajectories, UnagiTrajectory), false, LOT_POINTER },
};
#define LUA_BEHAVIOR_VALUES_FIELD_COUNT 1
#define LUA_BEHAVIOR_VALUES_FIELD_COUNT 4
static struct LuaObjectField sBehaviorValuesFields[LUA_BEHAVIOR_VALUES_FIELD_COUNT] = {
{ "trajectories", LVT_COBJECT, offsetof(struct BehaviorValues, trajectories), true, LOT_BEHAVIORTRAJECTORIES },
{ "KoopaBobAgility", LVT_F32, offsetof(struct BehaviorValues, KoopaBobAgility), false, LOT_NONE },
{ "KoopaCatchupAgility", LVT_F32, offsetof(struct BehaviorValues, KoopaCatchupAgility), false, LOT_NONE },
{ "KoopaThiAgility", LVT_F32, offsetof(struct BehaviorValues, KoopaThiAgility), false, LOT_NONE },
{ "trajectories", LVT_COBJECT, offsetof(struct BehaviorValues, trajectories), true, LOT_BEHAVIORTRAJECTORIES },
};
#define LUA_BULLY_COLLISION_DATA_FIELD_COUNT 6

View File

@ -14840,6 +14840,17 @@ int smlua_func_get_temp_object_hitbox(UNUSED lua_State* L) {
return 1;
}
int smlua_func_get_trajectory(lua_State* L) {
if(!smlua_functions_valid_param_count(L, 1)) { return 0; }
const char* name = smlua_to_string(L, 1);
if (!gSmLuaConvertSuccess) { return 0; }
smlua_push_pointer(L, LVT_TRAJECTORY_P, (void*)get_trajectory(name));
return 1;
}
int smlua_func_obj_get_first(lua_State* L) {
if(!smlua_functions_valid_param_count(L, 1)) { return 0; }
@ -16810,6 +16821,7 @@ void smlua_bind_functions_autogen(void) {
// smlua_obj_utils.h
smlua_bind_function(L, "get_temp_object_hitbox", smlua_func_get_temp_object_hitbox);
smlua_bind_function(L, "get_trajectory", smlua_func_get_trajectory);
smlua_bind_function(L, "obj_get_first", smlua_func_obj_get_first);
smlua_bind_function(L, "obj_get_first_with_behavior_id", smlua_func_obj_get_first_with_behavior_id);
smlua_bind_function(L, "obj_get_first_with_behavior_id_and_field_f32", smlua_func_obj_get_first_with_behavior_id_and_field_f32);

View File

@ -97,6 +97,10 @@ void obj_set_model_extended(struct Object *o, enum ModelExtendedId modelId) {
o->header.gfx.sharedChild = gLoadedGraphNodes[smlua_model_util_load(modelId)];
}
Trajectory* get_trajectory(const char* name) {
return dynos_level_get_trajectory(name);
}
//
// Helpers to iterate through the object table
//

View File

@ -12,6 +12,8 @@ s32 obj_has_behavior_id(struct Object *o, enum BehaviorId behaviorId);
s32 obj_has_model_extended(struct Object *o, enum ModelExtendedId modelId);
void obj_set_model_extended(struct Object *o, enum ModelExtendedId modelId);
Trajectory* get_trajectory(const char* name);
//
// Helpers to iterate through the object table
//