Skip to content
This repository has been archived by the owner on Jul 2, 2024. It is now read-only.

Commit

Permalink
ACTIVE_FLAG_DORMANT (#281)
Browse files Browse the repository at this point in the history
  • Loading branch information
Isaac0-dev authored Feb 19, 2023
1 parent 3f7f5da commit 3bc0b13
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 5 deletions.
3 changes: 3 additions & 0 deletions autogen/lua_definitions/constants.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion autogen/lua_definitions/structs.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions docs/lua/constants.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion docs/lua/structs.md
Original file line number Diff line number Diff line change
Expand Up @@ -956,6 +956,7 @@
| vanishCapSequence | `integer` | |
| wingCapDuration | `integer` | |
| wingCapDurationTotwc | `integer` | |
| wingCapLookUpReq | `integer` | |
| wingCapSequence | `integer` | |

[:arrow_up_small:](#)
Expand Down Expand Up @@ -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 |
Expand Down
1 change: 1 addition & 0 deletions include/object_constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
8 changes: 8 additions & 0 deletions src/engine/behavior_script.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions src/pc/lua/smlua_cobject_autogen.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
Expand All @@ -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 },
};

Expand Down Expand Up @@ -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 },
Expand Down Expand Up @@ -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 },
Expand Down
1 change: 1 addition & 0 deletions src/pc/lua/smlua_constants_autogen.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 3bc0b13

Please sign in to comment.