Un-hardcoded vanilla trajectories

This commit is contained in:
MysterD 2022-04-08 21:01:17 -07:00
parent 72584d5552
commit ef63435bc1
20 changed files with 346 additions and 71 deletions

View File

@ -2,7 +2,7 @@ import os
usf_types = ['u8', 'u16', 'u32', 'u64', 's8', 's16', 's32', 's64', 'f32']
vec3_types = ['Vec3s', 'Vec3f']
typedef_pointers = ['BehaviorScript', 'ObjectAnimPointer', 'Collision', 'LevelScript']
typedef_pointers = ['BehaviorScript', 'ObjectAnimPointer', 'Collision', 'LevelScript', 'Trajectory']
exclude_structs = [
'SPTask',

View File

@ -41,6 +41,39 @@
--- @field public terrainType integer
--- @field public warpNodes ObjectWarpNode
--- @class BehaviorTrajectories
--- @field public BowlingBallBob2Trajectory Pointer_Trajectory
--- @field public BowlingBallBobTrajectory Pointer_Trajectory
--- @field public BowlingBallTtmTrajectory Pointer_Trajectory
--- @field public KoopaBobTrajectory Pointer_Trajectory
--- @field public KoopaThiTrajectory Pointer_Trajectory
--- @field public Mips10Trajectory Pointer_Trajectory
--- @field public Mips2Trajectory Pointer_Trajectory
--- @field public Mips3Trajectory Pointer_Trajectory
--- @field public Mips4Trajectory Pointer_Trajectory
--- @field public Mips5Trajectory Pointer_Trajectory
--- @field public Mips6Trajectory Pointer_Trajectory
--- @field public Mips7Trajectory Pointer_Trajectory
--- @field public Mips8Trajectory Pointer_Trajectory
--- @field public Mips9Trajectory Pointer_Trajectory
--- @field public MipsTrajectory Pointer_Trajectory
--- @field public PlatformBitfsTrajectory Pointer_Trajectory
--- @field public PlatformCcmTrajectory Pointer_Trajectory
--- @field public PlatformHmcTrajectory Pointer_Trajectory
--- @field public PlatformLll2Trajectory Pointer_Trajectory
--- @field public PlatformLllTrajectory Pointer_Trajectory
--- @field public PlatformRr2Trajectory Pointer_Trajectory
--- @field public PlatformRr3Trajectory Pointer_Trajectory
--- @field public PlatformRr4Trajectory Pointer_Trajectory
--- @field public PlatformRrTrajectory Pointer_Trajectory
--- @field public RacingPenguinTrajectory Pointer_Trajectory
--- @field public SnowmanHeadTrajectory Pointer_Trajectory
--- @field public Unagi2Trajectory Pointer_Trajectory
--- @field public UnagiTrajectory Pointer_Trajectory
--- @class BehaviorValues
--- @field public trajectories BehaviorTrajectories
--- @class BullyCollisionData
--- @field public conversionRatio number
--- @field public posX number
@ -1565,6 +1598,7 @@
--- @field public z integer
--- @class Pointer_integer
--- @class Pointer_Trajectory
--- @class Pointer_ObjectAnimPointer
--- @class Pointer_Collision
--- @class Pointer_BehaviorScript

View File

@ -59,7 +59,14 @@ The `gGlobalObjectCollisionData` table contains references to object collision d
<br />
## [gLevelValues](#gLevelValues)
`gLevelValues`'s fields are listed in [LevelValue](structs.md#LevelValue).
`gLevelValues`'s fields are listed in [LevelValues](structs.md#LevelValues).
[:arrow_up_small:](#)
<br />
## [gBehaviorValues](#gBehaviorValues)
`gBehaviorValues`'s fields are listed in [BehaviorValues](structs.md#BehaviorValues).
[:arrow_up_small:](#)

View File

@ -4,6 +4,8 @@
- [AnimInfo](#AnimInfo)
- [Animation](#Animation)
- [Area](#Area)
- [BehaviorTrajectories](#BehaviorTrajectories)
- [BehaviorValues](#BehaviorValues)
- [BullyCollisionData](#BullyCollisionData)
- [Camera](#Camera)
- [CameraFOVStatus](#CameraFOVStatus)
@ -129,6 +131,53 @@
<br />
## [BehaviorTrajectories](#BehaviorTrajectories)
| 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 |
[:arrow_up_small:](#)
<br />
## [BehaviorValues](#BehaviorValues)
| Field | Type | Access |
| ----- | ---- | ------ |
| trajectories | [BehaviorTrajectories](structs.md#BehaviorTrajectories) | read-only |
[:arrow_up_small:](#)
<br />
## [BullyCollisionData](#BullyCollisionData)
| Field | Type | Access |

View File

@ -1,5 +1,5 @@
// 0x07078EF8 - 0x07078F2C
static const Trajectory inside_castle_seg7_trajectory_mips_0[] = {
const Trajectory inside_castle_seg7_trajectory_mips_0[] = {
TRAJECTORY_POS(0, /*pos*/ -1831, -1177, -1178),
TRAJECTORY_POS(1, /*pos*/ -1810, -1177, 284),
TRAJECTORY_POS(2, /*pos*/ -2210, -1192, 715),
@ -10,7 +10,7 @@ static const Trajectory inside_castle_seg7_trajectory_mips_0[] = {
};
// 0x07078F2C - 0x07078F68
static const Trajectory inside_castle_seg7_trajectory_mips_1[] = {
const Trajectory inside_castle_seg7_trajectory_mips_1[] = {
TRAJECTORY_POS(0, /*pos*/ -3674, -1379, -962),
TRAJECTORY_POS(1, /*pos*/ -3813, -1279, -41),
TRAJECTORY_POS(2, /*pos*/ -3628, -1279, 755),
@ -22,14 +22,14 @@ static const Trajectory inside_castle_seg7_trajectory_mips_1[] = {
};
// 0x07078F68 - 0x07078F7C
static const Trajectory inside_castle_seg7_trajectory_mips_2[] = {
const Trajectory inside_castle_seg7_trajectory_mips_2[] = {
TRAJECTORY_POS(0, /*pos*/ -1463, -1210, -2231),
TRAJECTORY_POS(1, /*pos*/ -1515, -1279, -3094),
TRAJECTORY_END(),
};
// 0x07078F7C - 0x07078FA8
static const Trajectory inside_castle_seg7_trajectory_mips_3[] = {
const Trajectory inside_castle_seg7_trajectory_mips_3[] = {
TRAJECTORY_POS(0, /*pos*/ -2019, -1279, -3077),
TRAJECTORY_POS(1, /*pos*/ -2559, -1279, -3043),
TRAJECTORY_POS(2, /*pos*/ -2957, -1279, -2747),
@ -39,7 +39,7 @@ static const Trajectory inside_castle_seg7_trajectory_mips_3[] = {
};
// 0x07078FA8 - 0x07078FD4
static const Trajectory inside_castle_seg7_trajectory_mips_4[] = {
const Trajectory inside_castle_seg7_trajectory_mips_4[] = {
TRAJECTORY_POS(0, /*pos*/ -3005, -1197, -1874),
TRAJECTORY_POS(1, /*pos*/ -2967, -1279, -2582),
TRAJECTORY_POS(2, /*pos*/ -2559, -1279, -3043),
@ -49,14 +49,14 @@ static const Trajectory inside_castle_seg7_trajectory_mips_4[] = {
};
// 0x07078FD4 - 0x07078FE8
static const Trajectory inside_castle_seg7_trajectory_mips_5[] = {
const Trajectory inside_castle_seg7_trajectory_mips_5[] = {
TRAJECTORY_POS(0, /*pos*/ -1387, -1254, -2541),
TRAJECTORY_POS(1, /*pos*/ -1541, -1177, -1446),
TRAJECTORY_END(),
};
// 0x07078FE8 - 0x07079004
static const Trajectory inside_castle_seg7_trajectory_mips_6[] = {
const Trajectory inside_castle_seg7_trajectory_mips_6[] = {
TRAJECTORY_POS(0, /*pos*/ -894, -1223, -1421),
TRAJECTORY_POS(1, /*pos*/ -306, -1279, -1601),
TRAJECTORY_POS(2, /*pos*/ -192, -1279, -2196),
@ -64,7 +64,7 @@ static const Trajectory inside_castle_seg7_trajectory_mips_6[] = {
};
// 0x07079004 - 0x07079020
static const Trajectory inside_castle_seg7_trajectory_mips_7[] = {
const Trajectory inside_castle_seg7_trajectory_mips_7[] = {
TRAJECTORY_POS(0, /*pos*/ -187, -1279, -1662),
TRAJECTORY_POS(1, /*pos*/ -805, -1238, -1406),
TRAJECTORY_POS(2, /*pos*/ -1549, -1177, -1446),
@ -72,7 +72,7 @@ static const Trajectory inside_castle_seg7_trajectory_mips_7[] = {
};
// 0x07079020 - 0x07079044
static const Trajectory inside_castle_seg7_trajectory_mips_8[] = {
const Trajectory inside_castle_seg7_trajectory_mips_8[] = {
TRAJECTORY_POS(0, /*pos*/ -1092, -1279, -3188),
TRAJECTORY_POS(1, /*pos*/ -593, -1279, -3175),
TRAJECTORY_POS(2, /*pos*/ -200, -1279, -2940),
@ -81,19 +81,10 @@ static const Trajectory inside_castle_seg7_trajectory_mips_8[] = {
};
// 0x07079044 - 0x07079068
static const Trajectory inside_castle_seg7_trajectory_mips_9[] = {
const Trajectory inside_castle_seg7_trajectory_mips_9[] = {
TRAJECTORY_POS(0, /*pos*/ -214, -1279, -2432),
TRAJECTORY_POS(1, /*pos*/ -160, -1283, -2900),
TRAJECTORY_POS(2, /*pos*/ -640, -1283, -3220),
TRAJECTORY_POS(3, /*pos*/ -1469, -1279, -3108),
TRAJECTORY_END(),
};
// 0x07079068 - 0x07079090
const Trajectory *const inside_castle_seg7_trajectory_mips[] = {
inside_castle_seg7_trajectory_mips_0, inside_castle_seg7_trajectory_mips_1,
inside_castle_seg7_trajectory_mips_2, inside_castle_seg7_trajectory_mips_3,
inside_castle_seg7_trajectory_mips_4, inside_castle_seg7_trajectory_mips_5,
inside_castle_seg7_trajectory_mips_6, inside_castle_seg7_trajectory_mips_7,
inside_castle_seg7_trajectory_mips_8, inside_castle_seg7_trajectory_mips_9,
};

View File

@ -147,9 +147,18 @@ extern const u8 inside_castle_seg7_area_3_rooms[];
extern const Collision inside_castle_seg7_collision_floor_trap[];
extern const Collision inside_castle_seg7_collision_star_door[];
extern const Collision inside_castle_seg7_collision_water_level_pillar[];
extern const Trajectory *const inside_castle_seg7_trajectory_mips[];
extern const struct MovtexQuadCollection inside_castle_movtex_green_room_water[];
extern const struct MovtexQuadCollection inside_castle_movtex_moat_water[];
extern const Trajectory inside_castle_seg7_trajectory_mips_0[];
extern const Trajectory inside_castle_seg7_trajectory_mips_1[];
extern const Trajectory inside_castle_seg7_trajectory_mips_2[];
extern const Trajectory inside_castle_seg7_trajectory_mips_3[];
extern const Trajectory inside_castle_seg7_trajectory_mips_4[];
extern const Trajectory inside_castle_seg7_trajectory_mips_5[];
extern const Trajectory inside_castle_seg7_trajectory_mips_6[];
extern const Trajectory inside_castle_seg7_trajectory_mips_7[];
extern const Trajectory inside_castle_seg7_trajectory_mips_8[];
extern const Trajectory inside_castle_seg7_trajectory_mips_9[];
// script
extern const LevelScript level_castle_inside_entry[];

View File

@ -55,15 +55,15 @@ void bowling_ball_set_hitbox(void) {
void bowling_ball_set_waypoints(void) {
switch (o->oBehParams2ndByte) {
case BBALL_BP_STYPE_BOB_UPPER:
o->oPathedStartWaypoint = segmented_to_virtual(bob_seg7_metal_ball_path0);
o->oPathedStartWaypoint = segmented_to_virtual(gBehaviorValues.trajectories.BowlingBallBobTrajectory);
break;
case BBALL_BP_STYPE_TTM:
o->oPathedStartWaypoint = segmented_to_virtual(ttm_seg7_trajectory_070170A0);
o->oPathedStartWaypoint = segmented_to_virtual(gBehaviorValues.trajectories.BowlingBallTtmTrajectory);
break;
case BBALL_BP_STYPE_BOB_LOWER:
o->oPathedStartWaypoint = segmented_to_virtual(bob_seg7_metal_ball_path1);
o->oPathedStartWaypoint = segmented_to_virtual(gBehaviorValues.trajectories.BowlingBallBob2Trajectory);
break;
case BBALL_BP_STYPE_THI_LARGE:

View File

@ -53,16 +53,14 @@ static u8 sKoopaShelledAttackHandlers[] = {
struct KoopaTheQuickProperties {
s16 initText;
s16 winText;
void const *path;
Vec3s starPos;
};
/**
* Properties for the BoB race and the THI race.
*/
static struct KoopaTheQuickProperties sKoopaTheQuickProperties[] = {
{ DIALOG_005, DIALOG_007, bob_seg7_trajectory_koopa, { 3030, 4500, -4600 } },
{ DIALOG_009, DIALOG_031, thi_seg7_trajectory_koopa, { 7100, -1300, -6000 } }
{ DIALOG_005, DIALOG_007 },
{ DIALOG_009, DIALOG_031 }
};
static u32 koopaPathedStartWaypoint = 0;
@ -70,14 +68,18 @@ static u32 koopaPathedPrevWaypoint = 0;
static u32 koopaShotFromCannon = 0;
static void bhv_koopa_the_quick_on_received_post(UNUSED u8 fromLocalIndex) {
void* path = segmented_to_virtual(sKoopaTheQuickProperties[o->oKoopaTheQuickRaceIndex].path);
void* path = (o->oKoopaTheQuickRaceIndex == 0)
? (void*) gBehaviorValues.trajectories.KoopaBobTrajectory
: (void*) gBehaviorValues.trajectories.KoopaThiTrajectory;
o->oPathedStartWaypoint = (struct Waypoint*)path + koopaPathedStartWaypoint;
o->oPathedPrevWaypoint = (struct Waypoint*)path + koopaPathedPrevWaypoint;
gMarioShotFromCannon = koopaShotFromCannon;
}
static void bhv_koopa_the_quick_on_sent_pre(void) {
void* path = segmented_to_virtual(sKoopaTheQuickProperties[o->oKoopaTheQuickRaceIndex].path);
void* path = (o->oKoopaTheQuickRaceIndex == 0)
? (void*) gBehaviorValues.trajectories.KoopaBobTrajectory
: (void*) gBehaviorValues.trajectories.KoopaThiTrajectory;
koopaPathedStartWaypoint = ((void*)o->oPathedStartWaypoint - path) / sizeof(struct Waypoint*);
koopaPathedPrevWaypoint = ((void*)o->oPathedPrevWaypoint - path) / sizeof(struct Waypoint*);
koopaShotFromCannon = gMarioShotFromCannon;
@ -638,8 +640,9 @@ static void koopa_the_quick_act_show_init_text(void) {
o->oForwardVel = 0.0f;
o->parentObj = cur_obj_nearest_object_with_behavior(bhvKoopaRaceEndpoint);
o->oPathedStartWaypoint = o->oPathedPrevWaypoint =
segmented_to_virtual(sKoopaTheQuickProperties[o->oKoopaTheQuickRaceIndex].path);
o->oPathedStartWaypoint = o->oPathedPrevWaypoint = (o->oKoopaTheQuickRaceIndex == 0)
? (struct Waypoint*) gBehaviorValues.trajectories.KoopaBobTrajectory
: (struct Waypoint*) gBehaviorValues.trajectories.KoopaThiTrajectory;
o->oKoopaTurningAwayFromWall = FALSE;
o->oFlags |= OBJ_FLAG_ACTIVE_FROM_AFAR;

View File

@ -2,6 +2,19 @@
* Behavior for MIPS (everyone's favorite yellow rabbit).
*/
static const Trajectory** sMipsPaths[] = {
&gBehaviorValues.trajectories.MipsTrajectory,
&gBehaviorValues.trajectories.Mips2Trajectory,
&gBehaviorValues.trajectories.Mips3Trajectory,
&gBehaviorValues.trajectories.Mips4Trajectory,
&gBehaviorValues.trajectories.Mips5Trajectory,
&gBehaviorValues.trajectories.Mips6Trajectory,
&gBehaviorValues.trajectories.Mips7Trajectory,
&gBehaviorValues.trajectories.Mips8Trajectory,
&gBehaviorValues.trajectories.Mips9Trajectory,
&gBehaviorValues.trajectories.Mips10Trajectory,
};
static u32 mipsPrevHeldState = 0;
static void bhv_mips_on_received_pre(UNUSED u8 fromLocalIndex) {
@ -77,16 +90,13 @@ s16 bhv_mips_find_furthest_waypoint_to_mario(void) {
s16 furthestWaypointIndex = -1;
f32 furthestWaypointDistance = -10000.0f;
f32 distanceToMario;
struct Waypoint **pathBase;
struct Waypoint *waypoint;
pathBase = segmented_to_virtual(&inside_castle_seg7_trajectory_mips);
struct Object* player = nearest_player_to_object(o);
// For each waypoint in MIPS path...
for (i = 0; i < 10; i++) {
waypoint = segmented_to_virtual(pathBase[i]);
waypoint = segmented_to_virtual(*sMipsPaths[i]);
x = waypoint->pos[0];
y = waypoint->pos[1];
z = waypoint->pos[2];
@ -136,12 +146,12 @@ void bhv_mips_act_wait_for_nearby_mario(void) {
void bhv_mips_act_follow_path(void) {
s16 collisionFlags = 0;
s32 followStatus = 0;
struct Waypoint **pathBase;
struct Waypoint ***pathBase;
struct Waypoint *waypoint;
// Retrieve current waypoint.
pathBase = segmented_to_virtual(&inside_castle_seg7_trajectory_mips);
waypoint = segmented_to_virtual(*(pathBase + o->oMipsStartWaypointIndex));
pathBase = segmented_to_virtual(sMipsPaths);
waypoint = segmented_to_virtual(*(*pathBase + o->oMipsStartWaypointIndex));
// Set start waypoint and follow the path from there.
o->oPathedStartWaypoint = waypoint;

View File

@ -18,10 +18,16 @@ static void const *sPlatformOnTrackCollisionModels[] = {
/**
* Paths for the different instances of these platforms.
*/
static void const *sPlatformOnTrackPaths[] = {
rr_seg7_trajectory_0702EC3C, rr_seg7_trajectory_0702ECC0, ccm_seg7_trajectory_0701669C,
bitfs_seg7_trajectory_070159AC, hmc_seg7_trajectory_0702B86C, lll_seg7_trajectory_0702856C,
lll_seg7_trajectory_07028660, rr_seg7_trajectory_0702ED9C, rr_seg7_trajectory_0702EEE0,
static const Trajectory** sPlatformOnTrackPaths[] = {
&gBehaviorValues.trajectories.PlatformRrTrajectory,
&gBehaviorValues.trajectories.PlatformRr2Trajectory,
&gBehaviorValues.trajectories.PlatformCcmTrajectory,
&gBehaviorValues.trajectories.PlatformBitfsTrajectory,
&gBehaviorValues.trajectories.PlatformHmcTrajectory,
&gBehaviorValues.trajectories.PlatformLllTrajectory,
&gBehaviorValues.trajectories.PlatformLll2Trajectory,
&gBehaviorValues.trajectories.PlatformRr3Trajectory,
&gBehaviorValues.trajectories.PlatformRr4Trajectory,
};
/**
@ -90,7 +96,7 @@ void bhv_platform_on_track_init(void) {
o->collisionData =
segmented_to_virtual(sPlatformOnTrackCollisionModels[o->oPlatformOnTrackType]);
o->oPlatformOnTrackStartWaypoint = segmented_to_virtual(sPlatformOnTrackPaths[pathIndex]);
o->oPlatformOnTrackStartWaypoint = segmented_to_virtual(*sPlatformOnTrackPaths[pathIndex]);
o->oPlatformOnTrackIsNotHMC = pathIndex - 4;

View File

@ -13,13 +13,13 @@ static u32 penguinPathedStartWaypoint = 0;
static u32 penguinPathedPrevWaypoint = 0;
static void bhv_racing_penguin_the_quick_on_received_post(UNUSED u8 fromLocalIndex) {
void* path = segmented_to_virtual(ccm_seg7_trajectory_penguin_race);
void* path = segmented_to_virtual(gBehaviorValues.trajectories.RacingPenguinTrajectory);
o->oPathedStartWaypoint = (struct Waypoint*)path + penguinPathedStartWaypoint;
o->oPathedPrevWaypoint = (struct Waypoint*)path + penguinPathedPrevWaypoint;
}
static void bhv_racing_penguin_the_quick_on_sent_pre(void) {
void* path = segmented_to_virtual(ccm_seg7_trajectory_penguin_race);
void* path = segmented_to_virtual(gBehaviorValues.trajectories.RacingPenguinTrajectory);
penguinPathedStartWaypoint = ((void*)o->oPathedStartWaypoint - path) / sizeof(struct Waypoint*);
penguinPathedPrevWaypoint = ((void*)o->oPathedPrevWaypoint - path) / sizeof(struct Waypoint*);
}
@ -105,7 +105,7 @@ static void racing_penguin_act_show_init_text(void) {
child->parentObj = o;
o->oPathedStartWaypoint = o->oPathedPrevWaypoint =
segmented_to_virtual(ccm_seg7_trajectory_penguin_race);
segmented_to_virtual(gBehaviorValues.trajectories.RacingPenguinTrajectory);
o->oPathedPrevWaypointFlags = 0;
o->oAction = RACING_PENGUIN_ACT_PREPARE_FOR_RACE;
@ -141,7 +141,7 @@ static void racing_penguin_act_race(void) {
child = cur_obj_nearest_object_with_behavior(bhvPenguinRaceShortcutCheck);
child->parentObj = o;
o->oPathedStartWaypoint = o->oPathedPrevWaypoint = segmented_to_virtual(ccm_seg7_trajectory_penguin_race);
o->oPathedStartWaypoint = o->oPathedPrevWaypoint = segmented_to_virtual(gBehaviorValues.trajectories.RacingPenguinTrajectory);
o->oPathedPrevWaypointFlags = 0;
}

View File

@ -62,7 +62,7 @@ void snowmans_bottom_act_1(void) {
s32 sp20 = 0;
UNUSED s16 sp1E;
o->oPathedStartWaypoint = segmented_to_virtual(&ccm_seg7_trajectory_snowman);
o->oPathedStartWaypoint = segmented_to_virtual(gBehaviorValues.trajectories.SnowmanHeadTrajectory);
sp26 = object_step_without_floor_orient();
sp20 = cur_obj_follow_path(sp20);
o->oSnowmansBottomUnkF8 = o->oPathedTargetYaw;

View File

@ -14,14 +14,14 @@ struct ObjectHitbox sUnagiHitbox = {
void bhv_unagi_init(void) {
if (o->oBehParams2ndByte != 1) {
o->oPathedStartWaypoint = segmented_to_virtual(jrb_seg7_trajectory_unagi_1);
o->oPathedStartWaypoint = segmented_to_virtual(gBehaviorValues.trajectories.UnagiTrajectory);
if (o->oBehParams2ndByte == 0) {
o->oFaceAnglePitch = -7600;
} else {
o->oAction = 1;
}
} else {
o->oPathedStartWaypoint = segmented_to_virtual(jrb_seg7_trajectory_unagi_2);
o->oPathedStartWaypoint = segmented_to_virtual(gBehaviorValues.trajectories.Unagi2Trajectory);
o->oAction = 3;
o->oAnimState = 1;

View File

@ -1,5 +1,42 @@
#include "hardcoded.h"
#include "levels/bbh/header.h"
#include "levels/bitdw/header.h"
#include "levels/bitfs/header.h"
#include "levels/bits/header.h"
#include "levels/bob/header.h"
#include "levels/bowser_1/header.h"
#include "levels/bowser_2/header.h"
#include "levels/bowser_2/header.h"
#include "levels/bowser_3/header.h"
#include "levels/bowser_3/header.h"
#include "levels/castle_courtyard/header.h"
#include "levels/castle_grounds/header.h"
#include "levels/castle_inside/header.h"
#include "levels/ccm/header.h"
#include "levels/cotmc/header.h"
#include "levels/ddd/header.h"
#include "levels/hmc/header.h"
#include "levels/jrb/header.h"
#include "levels/lll/header.h"
#include "levels/pss/header.h"
#include "levels/rr/header.h"
#include "levels/sa/header.h"
#include "levels/sl/header.h"
#include "levels/ssl/header.h"
#include "levels/thi/header.h"
#include "levels/totwc/header.h"
#include "levels/ttc/header.h"
#include "levels/ttm/header.h"
#include "levels/vcutm/header.h"
#include "levels/wdw/header.h"
#include "levels/wf/header.h"
#include "levels/wmotr/header.h"
////////////
// Levels //
////////////
struct LevelValues gLevelValues = {
.entryLevel = LEVEL_CASTLE_GROUNDS,
.starPositions = {
@ -35,3 +72,40 @@ struct LevelValues gLevelValues = {
.JetstreamRingStarPos = { 3400.0f, -3200.0f, -500.0f },
},
};
///////////////
// Behaviors //
///////////////
struct BehaviorValues gBehaviorValues = {
.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,
},
};

View File

@ -2,6 +2,10 @@
#include "types.h"
#include "level_table.h"
////////////
// Levels //
////////////
struct StarPositions {
Vec3f KoopaBobStarPos;
Vec3f KoopaThiStarPos;
@ -38,4 +42,45 @@ struct LevelValues {
extern struct LevelValues gLevelValues;
///////////////
// Behaviors //
///////////////
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;
};
struct BehaviorValues {
struct BehaviorTrajectories trajectories;
};
extern struct BehaviorValues gBehaviorValues;
#endif

View File

@ -75,9 +75,6 @@ s16 sPrevCheckMarioRoom = 0;
*/
s8 sYoshiDead = FALSE;
extern void *ccm_seg7_trajectory_snowman;
extern void *inside_castle_seg7_trajectory_mips;
/**
* Resets yoshi as spawned/despawned upon new file select.
* Possibly a function with stubbed code.

View File

@ -361,22 +361,23 @@ static int smlua__get_field(lua_State* L) {
u8* p = ((u8*)(intptr_t)pointer) + data->valueOffset;
switch (data->valueType) {
case LVT_BOOL: lua_pushboolean(L, *(u8* )p); break;
case LVT_U8: lua_pushinteger(L, *(u8* )p); break;
case LVT_U16: lua_pushinteger(L, *(u16*)p); break;
case LVT_U32: lua_pushinteger(L, *(u32*)p); break;
case LVT_S8: lua_pushinteger(L, *(s8* )p); break;
case LVT_S16: lua_pushinteger(L, *(s16*)p); break;
case LVT_S32: lua_pushinteger(L, *(s32*)p); break;
case LVT_F32: lua_pushnumber( L, *(f32*)p); break;
case LVT_COBJECT: smlua_push_object(L, data->lot, p); break;
case LVT_COBJECT_P: smlua_push_object(L, data->lot, *(u8**)p); break;
case LVT_STRING: lua_pushstring(L, (char*)p); break;
case LVT_STRING_P: lua_pushstring(L, *(char**)p); break;
case LVT_BEHAVIORSCRIPT: lua_pushinteger(L, *(s32*)p); break;
case LVT_OBJECTANIMPOINTER: lua_pushinteger(L, *(s32*)p); break;
case LVT_COLLISION: lua_pushinteger(L, *(s32*)p); break;
case LVT_LEVELSCRIPT: lua_pushinteger(L, *(s32*)p); break;
case LVT_BOOL: lua_pushboolean(L, *(u8* )p); break;
case LVT_U8: lua_pushinteger(L, *(u8* )p); break;
case LVT_U16: lua_pushinteger(L, *(u16*)p); break;
case LVT_U32: lua_pushinteger(L, *(u32*)p); break;
case LVT_S8: lua_pushinteger(L, *(s8* )p); break;
case LVT_S16: lua_pushinteger(L, *(s16*)p); break;
case LVT_S32: lua_pushinteger(L, *(s32*)p); break;
case LVT_F32: lua_pushnumber( L, *(f32*)p); break;
case LVT_COBJECT: smlua_push_object(L, data->lot, p); break;
case LVT_COBJECT_P: smlua_push_object(L, data->lot, *(u8**)p); break;
case LVT_STRING: lua_pushstring(L, (char*)p); break;
case LVT_STRING_P: lua_pushstring(L, *(char**)p); break;
case LVT_BEHAVIORSCRIPT: lua_pushinteger(L, *(s32*)p); break;
case LVT_OBJECTANIMPOINTER: lua_pushinteger(L, *(s32*)p); break;
case LVT_COLLISION: lua_pushinteger(L, *(s32*)p); break;
case LVT_LEVELSCRIPT: lua_pushinteger(L, *(s32*)p); break;
case LVT_TRAJECTORY: lua_pushinteger(L, *(s16*)p); break;
// pointers
case LVT_U8_P:
@ -390,6 +391,7 @@ static int smlua__get_field(lua_State* L) {
case LVT_OBJECTANIMPOINTER_P:
case LVT_COLLISION_P:
case LVT_LEVELSCRIPT_P:
case LVT_TRAJECTORY_P:
smlua_push_pointer(L, data->valueType, *(u8**)p);
break;
@ -571,6 +573,11 @@ void smlua_cobject_init_globals(void) {
lua_setglobal(L, "gLevelValues");
}
{
smlua_push_object(L, LOT_BEHAVIORVALUES, &gBehaviorValues);
lua_setglobal(L, "gBehaviorValues");
}
}
void smlua_cobject_init_per_file_globals(char* path) {

View File

@ -29,6 +29,8 @@ enum LuaValueType {
LVT_COLLISION_P,
LVT_LEVELSCRIPT,
LVT_LEVELSCRIPT_P,
LVT_TRAJECTORY,
LVT_TRAJECTORY_P,
LVT_LUAFUNCTION,
LVT_POINTER,
LVT_MAX,

View File

@ -72,6 +72,43 @@ static struct LuaObjectField sAreaFields[LUA_AREA_FIELD_COUNT] = {
// { "whirlpools", LOT_???, offsetof(struct Area, whirlpools), false, LOT_??? }, <--- UNIMPLEMENTED
};
#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 },
};
#define LUA_BEHAVIOR_VALUES_FIELD_COUNT 1
static struct LuaObjectField sBehaviorValuesFields[LUA_BEHAVIOR_VALUES_FIELD_COUNT] = {
{ "trajectories", LVT_COBJECT, offsetof(struct BehaviorValues, trajectories), true, LOT_BEHAVIORTRAJECTORIES },
};
#define LUA_BULLY_COLLISION_DATA_FIELD_COUNT 6
static struct LuaObjectField sBullyCollisionDataFields[LUA_BULLY_COLLISION_DATA_FIELD_COUNT] = {
{ "conversionRatio", LVT_F32, offsetof(struct BullyCollisionData, conversionRatio), false, LOT_NONE },
@ -1735,6 +1772,8 @@ struct LuaObjectTable sLuaObjectAutogenTable[LOT_AUTOGEN_MAX - LOT_AUTOGEN_MIN]
{ LOT_ANIMINFO, sAnimInfoFields, LUA_ANIM_INFO_FIELD_COUNT },
{ LOT_ANIMATION, sAnimationFields, LUA_ANIMATION_FIELD_COUNT },
{ LOT_AREA, sAreaFields, LUA_AREA_FIELD_COUNT },
{ LOT_BEHAVIORTRAJECTORIES, sBehaviorTrajectoriesFields, LUA_BEHAVIOR_TRAJECTORIES_FIELD_COUNT },
{ LOT_BEHAVIORVALUES, sBehaviorValuesFields, LUA_BEHAVIOR_VALUES_FIELD_COUNT },
{ LOT_BULLYCOLLISIONDATA, sBullyCollisionDataFields, LUA_BULLY_COLLISION_DATA_FIELD_COUNT },
{ LOT_CAMERA, sCameraFields, LUA_CAMERA_FIELD_COUNT },
{ LOT_CAMERAFOVSTATUS, sCameraFOVStatusFields, LUA_CAMERA_FOVSTATUS_FIELD_COUNT },

View File

@ -8,6 +8,8 @@ enum LuaObjectAutogenType {
LOT_ANIMINFO,
LOT_ANIMATION,
LOT_AREA,
LOT_BEHAVIORTRAJECTORIES,
LOT_BEHAVIORVALUES,
LOT_BULLYCOLLISIONDATA,
LOT_CAMERA,
LOT_CAMERAFOVSTATUS,