From 3bc0b13e2079e9ee02b449d0c8b8899dee1bcbac Mon Sep 17 00:00:00 2001 From: Isaac0-dev <62234577+Isaac0-dev@users.noreply.github.com> Date: Sun, 19 Feb 2023 14:45:13 +1000 Subject: [PATCH] ACTIVE_FLAG_DORMANT (#281) --- autogen/lua_definitions/constants.lua | 3 +++ autogen/lua_definitions/structs.lua | 2 +- docs/lua/constants.md | 1 + docs/lua/structs.md | 2 +- include/object_constants.h | 1 + src/engine/behavior_script.c | 8 ++++++++ src/pc/lua/smlua_cobject_autogen.c | 6 +++--- src/pc/lua/smlua_constants_autogen.c | 1 + 8 files changed, 19 insertions(+), 5 deletions(-) diff --git a/autogen/lua_definitions/constants.lua b/autogen/lua_definitions/constants.lua index 99a90f860..68bb10ad2 100644 --- a/autogen/lua_definitions/constants.lua +++ b/autogen/lua_definitions/constants.lua @@ -4739,6 +4739,9 @@ ACTIVE_FLAG_DEACTIVATED = 0 --- @type integer ACTIVE_FLAG_DITHERED_ALPHA = (1 << 7) +--- @type integer +ACTIVE_FLAG_DORMANT = (1 << 11) + --- @type integer ACTIVE_FLAG_FAR_AWAY = (1 << 1) diff --git a/autogen/lua_definitions/structs.lua b/autogen/lua_definitions/structs.lua index 8ebf8bd39..d5c29f91e 100644 --- a/autogen/lua_definitions/structs.lua +++ b/autogen/lua_definitions/structs.lua @@ -658,6 +658,7 @@ --- @field public vanishCapSequence integer --- @field public wingCapDuration integer --- @field public wingCapDurationTotwc integer +--- @field public wingCapLookUpReq integer --- @field public wingCapSequence integer --- @class LinearTransitionPoint @@ -759,7 +760,6 @@ --- @field public unkC4 number --- @field public usedObj Object --- @field public vel Vec3f ---- @field public visibleToEnemies integer --- @field public wall Surface --- @field public wallKickTimer integer --- @field public wallNormal Vec3f diff --git a/docs/lua/constants.md b/docs/lua/constants.md index 7a4a16853..8d1e0121b 100644 --- a/docs/lua/constants.md +++ b/docs/lua/constants.md @@ -1697,6 +1697,7 @@ - ACTIVE_FLAG_ACTIVE - ACTIVE_FLAG_DEACTIVATED - ACTIVE_FLAG_DITHERED_ALPHA +- ACTIVE_FLAG_DORMANT - ACTIVE_FLAG_FAR_AWAY - ACTIVE_FLAG_INITIATED_TIME_STOP - ACTIVE_FLAG_IN_DIFFERENT_ROOM diff --git a/docs/lua/structs.md b/docs/lua/structs.md index f8b1ac37e..d52a4c5e0 100644 --- a/docs/lua/structs.md +++ b/docs/lua/structs.md @@ -956,6 +956,7 @@ | vanishCapSequence | `integer` | | | wingCapDuration | `integer` | | | wingCapDurationTotwc | `integer` | | +| wingCapLookUpReq | `integer` | | | wingCapSequence | `integer` | | [:arrow_up_small:](#) @@ -1085,7 +1086,6 @@ | unkC4 | `number` | | | usedObj | [Object](structs.md#Object) | | | vel | [Vec3f](structs.md#Vec3f) | read-only | -| visibleToEnemies | `integer` | | | wall | [Surface](structs.md#Surface) | | | wallKickTimer | `integer` | | | wallNormal | [Vec3f](structs.md#Vec3f) | read-only | diff --git a/include/object_constants.h b/include/object_constants.h index 71d186f13..e0b33e8bf 100644 --- a/include/object_constants.h +++ b/include/object_constants.h @@ -17,6 +17,7 @@ #define ACTIVE_FLAG_UNK8 (1 << 8) // 0x0100 #define ACTIVE_FLAG_UNK9 (1 << 9) // 0x0200 #define ACTIVE_FLAG_UNK10 (1 << 10) // 0x0400 +#define ACTIVE_FLAG_DORMANT (1 << 11) // 0x0800 /* respawnInfoType */ diff --git a/src/engine/behavior_script.c b/src/engine/behavior_script.c index dff439acd..a7649a321 100644 --- a/src/engine/behavior_script.c +++ b/src/engine/behavior_script.c @@ -20,6 +20,7 @@ #include "pc/lua/smlua_hooks.h" #include "pc/lua/smlua_utils.h" #include "game/rng_position.h" +#include "game/interaction.h" // Macros for retrieving arguments from behavior scripts. #define BHV_CMD_GET_1ST_U8(index) (u8)((gCurBhvCommand[index] >> 24) & 0xFF) // unused @@ -1260,6 +1261,13 @@ static BhvCommandProc BehaviorCmdTable[] = { // Execute the behavior script of the current object, process the object flags, and other miscellaneous code for updating objects. void cur_obj_update(void) { + // Don't update if dormant + if (gCurrentObject->activeFlags & ACTIVE_FLAG_DORMANT) { + gCurrentObject->header.gfx.node.flags &= ~GRAPH_RENDER_ACTIVE; + gCurrentObject->oInteractStatus = INT_STATUS_INTERACTED; + return; + } + // handle network area timer if (gCurrentObject->areaTimerType != AREA_TIMER_TYPE_NONE) { // make sure the area is valid diff --git a/src/pc/lua/smlua_cobject_autogen.c b/src/pc/lua/smlua_cobject_autogen.c index 84e3124b9..dd4c43b0c 100644 --- a/src/pc/lua/smlua_cobject_autogen.c +++ b/src/pc/lua/smlua_cobject_autogen.c @@ -733,7 +733,7 @@ static struct LuaObjectField sLakituStateFields[LUA_LAKITU_STATE_FIELD_COUNT] = { "yaw", LVT_S16, offsetof(struct LakituState, yaw), false, LOT_NONE }, }; -#define LUA_LEVEL_VALUES_FIELD_COUNT 26 +#define LUA_LEVEL_VALUES_FIELD_COUNT 27 static struct LuaObjectField sLevelValuesFields[LUA_LEVEL_VALUES_FIELD_COUNT] = { { "cellHeightLimit", LVT_S16, offsetof(struct LevelValues, cellHeightLimit), false, LOT_NONE }, { "coinsRequiredForCoinStar", LVT_S16, offsetof(struct LevelValues, coinsRequiredForCoinStar), false, LOT_NONE }, @@ -760,6 +760,7 @@ static struct LuaObjectField sLevelValuesFields[LUA_LEVEL_VALUES_FIELD_COUNT] = { "vanishCapSequence", LVT_U8, offsetof(struct LevelValues, vanishCapSequence), false, LOT_NONE }, { "wingCapDuration", LVT_U16, offsetof(struct LevelValues, wingCapDuration), false, LOT_NONE }, { "wingCapDurationTotwc", LVT_U16, offsetof(struct LevelValues, wingCapDurationTotwc), false, LOT_NONE }, + { "wingCapLookUpReq", LVT_U8, offsetof(struct LevelValues, wingCapLookUpReq), false, LOT_NONE }, { "wingCapSequence", LVT_U8, offsetof(struct LevelValues, wingCapSequence), false, LOT_NONE }, }; @@ -799,7 +800,7 @@ static struct LuaObjectField sMarioBodyStateFields[LUA_MARIO_BODY_STATE_FIELD_CO { "wingFlutter", LVT_S8, offsetof(struct MarioBodyState, wingFlutter), false, LOT_NONE }, }; -#define LUA_MARIO_STATE_FIELD_COUNT 77 +#define LUA_MARIO_STATE_FIELD_COUNT 76 static struct LuaObjectField sMarioStateFields[LUA_MARIO_STATE_FIELD_COUNT] = { { "action", LVT_U32, offsetof(struct MarioState, action), false, LOT_NONE }, { "actionArg", LVT_U32, offsetof(struct MarioState, actionArg), false, LOT_NONE }, @@ -872,7 +873,6 @@ static struct LuaObjectField sMarioStateFields[LUA_MARIO_STATE_FIELD_COUNT] = { { "unkC4", LVT_F32, offsetof(struct MarioState, unkC4), false, LOT_NONE }, { "usedObj", LVT_COBJECT_P, offsetof(struct MarioState, usedObj), false, LOT_OBJECT }, { "vel", LVT_COBJECT, offsetof(struct MarioState, vel), true, LOT_VEC3F }, - { "visibleToEnemies", LVT_U8, offsetof(struct MarioState, visibleToEnemies), false, LOT_NONE }, { "wall", LVT_COBJECT_P, offsetof(struct MarioState, wall), false, LOT_SURFACE }, { "wallKickTimer", LVT_U8, offsetof(struct MarioState, wallKickTimer), false, LOT_NONE }, { "wallNormal", LVT_COBJECT, offsetof(struct MarioState, wallNormal), true, LOT_VEC3F }, diff --git a/src/pc/lua/smlua_constants_autogen.c b/src/pc/lua/smlua_constants_autogen.c index 17fe16cca..494fd6902 100644 --- a/src/pc/lua/smlua_constants_autogen.c +++ b/src/pc/lua/smlua_constants_autogen.c @@ -1768,6 +1768,7 @@ char gSmluaConstants[] = "" "ACTIVE_FLAG_UNK8 = (1 << 8)\n" "ACTIVE_FLAG_UNK9 = (1 << 9)\n" "ACTIVE_FLAG_UNK10 = (1 << 10)\n" +"ACTIVE_FLAG_DORMANT = (1 << 11)\n" "RESPAWN_INFO_TYPE_NULL = 0\n" "RESPAWN_INFO_TYPE_32 = 1\n" "RESPAWN_INFO_TYPE_16 = 2\n"