fix dynos warps castle grounds bug

This commit is contained in:
Isaac0-dev 2025-01-07 09:04:37 +10:00
parent 54d5a5a6f7
commit 547e22530c
6 changed files with 54 additions and 64 deletions

View file

@ -820,7 +820,7 @@ const void *DynOS_Level_GetScript(s32 aLevel);
s32 DynOS_Level_GetModIndex(s32 aLevel);
bool DynOS_Level_IsVanillaLevel(s32 aLevel);
Collision *DynOS_Level_GetCollision(u32 aLevel, u16 aArea);
s16 *DynOS_Level_GetWarp(s32 aLevel, s32 aArea, u8 aWarpId);
s16 *DynOS_Level_GetWarp(s32 aLevel, s32 aArea, s8 aWarpId);
s16 *DynOS_Level_GetWarpEntry(s32 aLevel, s32 aArea);
s16 *DynOS_Level_GetWarpDeath(s32 aLevel, s32 aArea);
u64 DynOS_Level_CmdGet(void *aCmd, u64 aOffset);

View file

@ -5,6 +5,7 @@ extern "C" {
#include "levels/scripts.h"
#include "pc/lua/utils/smlua_level_utils.h"
#include "game/area.h"
#include "game/level_update.h"
}
//
@ -18,6 +19,8 @@ extern const BehaviorScript *sWarpBhvSpawnTable[];
#define DYNOS_LEVEL_MOD_INDEX_VANILLA (-1)
#define DYNOS_LEVEL_MARIO_POS_WARP_ID (-1)
extern void *gDynosLevelScriptsOriginal[LEVEL_COUNT];
void DynOS_Level_ParseScript(const void *aScript, s32 (*aPreprocessFunction)(u8, void *));
@ -63,45 +66,10 @@ LvlCmd *DynOS_Level_CmdNext(LvlCmd *aCmd) {
// Init
//
static s32 DynOS_Level_PreprocessMasterScript(u8 aType, void *aCmd) {
static bool sDynosScriptExecLevelTable = false;
static s32 sDynosLevelNum = -1;
if (sDynosScriptExecLevelTable) {
switch (aType) {
// JUMP_IF
case 0x0C: {
sDynosLevelNum = (s32) DynOS_Level_CmdGet(aCmd, 0x04);
} return 0;
// EXECUTE
case 0x00: {
void *_Script = (void *) DynOS_Level_CmdGet(aCmd, 0x0C);
if (sDynosLevelNum >= 0 && sDynosLevelNum < LEVEL_COUNT && !sDynosLevelScripts[sDynosLevelNum].mLevelScript) {
sDynosLevelScripts[sDynosLevelNum].mLevelScript = _Script;
sDynosLevelScripts[sDynosLevelNum].mModIndex = DYNOS_LEVEL_MOD_INDEX_VANILLA;
gDynosLevelScriptsOriginal[sDynosLevelNum] = _Script;
}
sDynosLevelNum = -1;
} return 2;
// EXIT or SLEEP
case 0x02:
case 0x03:
return 3;
}
} else if (aType == 0x06) { // JUMP_LINK
sDynosScriptExecLevelTable = true;
return 0;
}
return 0;
}
static s32 sDynosCurrentLevelNum;
static u8 sDynosAreaIndex = 0;
inline static DynosWarp *DynOS_Level_GetWarpStruct(u8 aId) {
inline static DynosWarp *DynOS_Level_GetWarpStruct(s8 aId) {
for (s32 i = 0; i != sDynosLevelWarps[sDynosCurrentLevelNum].Count(); ++i) {
if (sDynosLevelWarps[sDynosCurrentLevelNum][i].mArea == sDynosAreaIndex &&
sDynosLevelWarps[sDynosCurrentLevelNum][i].mId == aId) {
@ -152,6 +120,20 @@ static s32 DynOS_Level_PreprocessScript(u8 aType, void *aCmd) {
}
} break;
// MARIO_POS
case 0x2B: {
DynosWarp *_Warp = DynOS_Level_GetWarpStruct(DYNOS_LEVEL_MARIO_POS_WARP_ID);
_Warp->mArea = (s16) DynOS_Level_CmdGet(aCmd, 2);
_Warp->mAngle = ((s16) DynOS_Level_CmdGet(aCmd, 4) * 0x8000) / 180 - 0x8000;
_Warp->mPosX = (s16) DynOS_Level_CmdGet(aCmd, 6);
_Warp->mPosY = (s16) DynOS_Level_CmdGet(aCmd, 8);
_Warp->mPosZ = (s16) DynOS_Level_CmdGet(aCmd, 10);
_Warp->mType = MARIO_SPAWN_IDLE - 1;
_Warp->mDestLevel = sDynosCurrentLevelNum;
_Warp->mDestArea = _Warp->mArea;
_Warp->mDestId = DYNOS_LEVEL_MARIO_POS_WARP_ID;
} break;
// SLEEP or SLEEP_BEFORE_EXIT
case 0x03:
case 0x04:
@ -399,7 +381,7 @@ void DynOS_Level_ParseScript(const void *aScript, s32 (*aPreprocessFunction)(u8,
// Level Script Utilities
//
s16 *DynOS_Level_GetWarp(s32 aLevel, s32 aArea, u8 aWarpId) {
s16 *DynOS_Level_GetWarp(s32 aLevel, s32 aArea, s8 aWarpId) {
if (aLevel >= CUSTOM_LEVEL_NUM_START) {
struct CustomLevelInfo* info = smlua_level_util_get_info(aLevel);
if (!info || !info->script) { return NULL; }
@ -435,7 +417,7 @@ s16 *DynOS_Level_GetWarpEntry(s32 aLevel, s32 aArea) {
if (sDynosLevelScripts[aLevel].mLevelScript == level_castle_inside_entry) {
return DynOS_Level_GetWarp(aLevel, aArea, (aArea == 3) ? 0x00 : 0x01);
} else if (sDynosLevelScripts[aLevel].mLevelScript == level_castle_grounds_entry) {
return DynOS_Level_GetWarp(aLevel, aArea, 0x00);
return DynOS_Level_GetWarp(aLevel, aArea, DYNOS_LEVEL_MARIO_POS_WARP_ID);
} else if (sDynosLevelScripts[aLevel].mLevelScript == level_castle_courtyard_entry) {
return DynOS_Level_GetWarp(aLevel, aArea, 0x01);
}

View file

@ -235,12 +235,12 @@ static void *DynOS_Warp_UpdateWarp(void *aCmd, bool aIsLevelInitDone) {
}
sDelayedWarpOp = WARP_OP_NONE;
switch (sDynosWarpSpawnType) {
case MARIO_SPAWN_UNKNOWN_03: play_transition(WARP_TRANSITION_FADE_FROM_STAR, 0x10, 0x00, 0x00, 0x00); break;
case MARIO_SPAWN_PIPE: play_transition(WARP_TRANSITION_FADE_FROM_STAR, 0x10, 0x00, 0x00, 0x00); break;
case MARIO_SPAWN_DOOR_WARP: play_transition(WARP_TRANSITION_FADE_FROM_CIRCLE, 0x10, 0x00, 0x00, 0x00); break;
case MARIO_SPAWN_TELEPORT: play_transition(WARP_TRANSITION_FADE_FROM_COLOR, 0x14, 0xFF, 0xFF, 0xFF); break;
case MARIO_SPAWN_SPIN_AIRBORNE: play_transition(WARP_TRANSITION_FADE_FROM_COLOR, 0x1A, 0xFF, 0xFF, 0xFF); break;
case MARIO_SPAWN_SPIN_AIRBORNE_CIRCLE: play_transition(WARP_TRANSITION_FADE_FROM_CIRCLE, 0x10, 0x00, 0x00, 0x00); break;
case MARIO_SPAWN_UNKNOWN_27: play_transition(WARP_TRANSITION_FADE_FROM_COLOR, 0x10, 0x00, 0x00, 0x00); break;
case MARIO_SPAWN_FADE_FROM_BLACK: play_transition(WARP_TRANSITION_FADE_FROM_COLOR, 0x10, 0x00, 0x00, 0x00); break;
default: play_transition(WARP_TRANSITION_FADE_FROM_STAR, 0x10, 0x00, 0x00, 0x00); break;
}
@ -387,7 +387,7 @@ static void *DynOS_Warp_UpdateExit(void *aCmd, bool aIsLevelInitDone) {
gMarioSpawnInfo->startAngle[2] = 0;
gMarioSpawnInfo->areaIndex = gCurrAreaIndex;
init_mario();
set_mario_initial_action(gMarioState, MARIO_SPAWN_UNKNOWN_02, 0);
set_mario_initial_action(gMarioState, MARIO_SPAWN_IDLE, 0);
// Init transition
if (gCurrentArea != NULL) {

View file

@ -82,8 +82,8 @@ const BehaviorScript *sWarpBhvSpawnTable[] = {
};
u8 sSpawnTypeFromWarpBhv[] = {
MARIO_SPAWN_DOOR_WARP, MARIO_SPAWN_UNKNOWN_02, MARIO_SPAWN_UNKNOWN_03, MARIO_SPAWN_UNKNOWN_03,
MARIO_SPAWN_UNKNOWN_03, MARIO_SPAWN_TELEPORT, MARIO_SPAWN_INSTANT_ACTIVE, MARIO_SPAWN_AIRBORNE,
MARIO_SPAWN_DOOR_WARP, MARIO_SPAWN_IDLE, MARIO_SPAWN_PIPE, MARIO_SPAWN_PIPE,
MARIO_SPAWN_PIPE, MARIO_SPAWN_TELEPORT, MARIO_SPAWN_INSTANT_ACTIVE, MARIO_SPAWN_AIRBORNE,
MARIO_SPAWN_HARD_AIR_KNOCKBACK, MARIO_SPAWN_SPIN_AIRBORNE_CIRCLE, MARIO_SPAWN_DEATH, MARIO_SPAWN_SPIN_AIRBORNE,
MARIO_SPAWN_FLYING, MARIO_SPAWN_SWIMMING, MARIO_SPAWN_PAINTING_STAR_COLLECT, MARIO_SPAWN_PAINTING_DEATH,
MARIO_SPAWN_AIRBORNE_STAR_COLLECT, MARIO_SPAWN_AIRBORNE_DEATH, MARIO_SPAWN_LAUNCH_STAR_COLLECT, MARIO_SPAWN_LAUNCH_DEATH,

View file

@ -355,10 +355,10 @@ void set_mario_initial_action(struct MarioState *m, u32 spawnType, u32 actionArg
case MARIO_SPAWN_DOOR_WARP:
set_mario_action(m, ACT_WARP_DOOR_SPAWN, actionArg);
break;
case MARIO_SPAWN_UNKNOWN_02:
case MARIO_SPAWN_IDLE:
set_mario_action(m, ACT_IDLE, 0);
break;
case MARIO_SPAWN_UNKNOWN_03:
case MARIO_SPAWN_PIPE:
set_mario_action(m, ACT_EMERGE_FROM_PIPE, 0);
break;
case MARIO_SPAWN_TELEPORT:
@ -475,7 +475,7 @@ void init_mario_after_warp(void) {
sDelayedWarpOp = WARP_OP_NONE;
switch (marioSpawnType) {
case MARIO_SPAWN_UNKNOWN_03:
case MARIO_SPAWN_PIPE:
play_transition(WARP_TRANSITION_FADE_FROM_STAR, 0x10, 0x00, 0x00, 0x00);
break;
case MARIO_SPAWN_DOOR_WARP:
@ -490,7 +490,7 @@ void init_mario_after_warp(void) {
case MARIO_SPAWN_SPIN_AIRBORNE_CIRCLE:
play_transition(WARP_TRANSITION_FADE_FROM_CIRCLE, 0x10, 0x00, 0x00, 0x00);
break;
case MARIO_SPAWN_UNKNOWN_27:
case MARIO_SPAWN_FADE_FROM_BLACK:
play_transition(WARP_TRANSITION_FADE_FROM_COLOR, 0x10, 0x00, 0x00, 0x00);
break;
default:

View file

@ -38,24 +38,32 @@
#define SPECIAL_WARP_TITLE -8
#define SPECIAL_WARP_LEVEL_SELECT -9
#define MARIO_SPAWN_DOOR_WARP 0x01
enum MarioSpawnType {
MARIO_SPAWN_NONE,
MARIO_SPAWN_DOOR_WARP,
MARIO_SPAWN_IDLE,
MARIO_SPAWN_PIPE,
MARIO_SPAWN_TELEPORT,
MARIO_SPAWN_INSTANT_ACTIVE = 0x10,
MARIO_SPAWN_SWIMMING,
MARIO_SPAWN_AIRBORNE,
MARIO_SPAWN_HARD_AIR_KNOCKBACK,
MARIO_SPAWN_SPIN_AIRBORNE_CIRCLE,
MARIO_SPAWN_DEATH,
MARIO_SPAWN_SPIN_AIRBORNE,
MARIO_SPAWN_FLYING,
MARIO_SPAWN_PAINTING_STAR_COLLECT = 0x20,
MARIO_SPAWN_PAINTING_DEATH,
MARIO_SPAWN_AIRBORNE_STAR_COLLECT,
MARIO_SPAWN_AIRBORNE_DEATH,
MARIO_SPAWN_LAUNCH_STAR_COLLECT,
MARIO_SPAWN_LAUNCH_DEATH,
MARIO_SPAWN_UNUSED_38,
MARIO_SPAWN_FADE_FROM_BLACK
};
#define MARIO_SPAWN_UNKNOWN_02 0x02
#define MARIO_SPAWN_UNKNOWN_03 0x03
#define MARIO_SPAWN_TELEPORT 0x04
#define MARIO_SPAWN_INSTANT_ACTIVE 0x10
#define MARIO_SPAWN_SWIMMING 0x11
#define MARIO_SPAWN_AIRBORNE 0x12
#define MARIO_SPAWN_HARD_AIR_KNOCKBACK 0x13
#define MARIO_SPAWN_SPIN_AIRBORNE_CIRCLE 0x14
#define MARIO_SPAWN_DEATH 0x15
#define MARIO_SPAWN_SPIN_AIRBORNE 0x16
#define MARIO_SPAWN_FLYING 0x17
#define MARIO_SPAWN_PAINTING_STAR_COLLECT 0x20
#define MARIO_SPAWN_PAINTING_DEATH 0x21
#define MARIO_SPAWN_AIRBORNE_STAR_COLLECT 0x22
#define MARIO_SPAWN_AIRBORNE_DEATH 0x23
#define MARIO_SPAWN_LAUNCH_STAR_COLLECT 0x24
#define MARIO_SPAWN_LAUNCH_DEATH 0x25
#define MARIO_SPAWN_UNKNOWN_27 0x27
#define WARP_NODE_F0 0xF0