From 30ca5bf0189b282be60e54100f63345b74c54327 Mon Sep 17 00:00:00 2001 From: MysterD Date: Fri, 27 Oct 2023 01:03:20 -0700 Subject: [PATCH] Eyerok can now get attacked by remote players --- autogen/lua_definitions/structs.lua | 1 + docs/lua/structs.md | 1 + include/types.h | 1 + src/game/behaviors/eyerok.inc.c | 1 + src/game/interaction.c | 10 ++++++---- src/game/spawn_object.c | 1 + src/pc/lua/smlua_cobject_autogen.c | 3 ++- 7 files changed, 13 insertions(+), 5 deletions(-) diff --git a/autogen/lua_definitions/structs.lua b/autogen/lua_definitions/structs.lua index 59caa8ff..960c61df 100644 --- a/autogen/lua_definitions/structs.lua +++ b/autogen/lua_definitions/structs.lua @@ -869,6 +869,7 @@ --- @class Object --- @field public activeFlags integer +--- @field public allowRemoteInteractions integer --- @field public areaTimer integer --- @field public areaTimerDuration integer --- @field public areaTimerType AreaTimerType diff --git a/docs/lua/structs.md b/docs/lua/structs.md index 243f10aa..ffa41da0 100644 --- a/docs/lua/structs.md +++ b/docs/lua/structs.md @@ -1250,6 +1250,7 @@ | Field | Type | Access | | ----- | ---- | ------ | | activeFlags | `integer` | | +| allowRemoteInteractions | `integer` | | | areaTimer | `integer` | | | areaTimerDuration | `integer` | | | areaTimerType | [enum AreaTimerType](constants.md#enum-AreaTimerType) | | diff --git a/include/types.h b/include/types.h index 1c301a13..9a567b97 100644 --- a/include/types.h +++ b/include/types.h @@ -243,6 +243,7 @@ struct Object /*?????*/ struct Object* usingObj; /*?????*/ u8 hookRender; /*?????*/ u8 setHome; + /*?????*/ u8 allowRemoteInteractions; /*?????*/ u8 ctx; }; diff --git a/src/game/behaviors/eyerok.inc.c b/src/game/behaviors/eyerok.inc.c index 3fc52a5f..d42787de 100644 --- a/src/game/behaviors/eyerok.inc.c +++ b/src/game/behaviors/eyerok.inc.c @@ -622,6 +622,7 @@ static void eyerok_hand_act_double_pound(void) { void bhv_eyerok_hand_loop(void) { if (!o->parentObj) { return; } + o->allowRemoteInteractions = TRUE; if (o->oAction == EYEROK_HAND_ACT_DEAD) { eyerok_hand_act_die_event(); return; diff --git a/src/game/interaction.c b/src/game/interaction.c index 0f7c5af9..9a70c06b 100644 --- a/src/game/interaction.c +++ b/src/game/interaction.c @@ -2307,12 +2307,14 @@ void mario_process_interactions(struct MarioState *m) { s32 i; for (i = 0; i < 32; i++) { u32 interactType = sInteractionHandlers[i].interactType; - if (m->playerIndex != 0 && interactType != (u32)INTERACT_PLAYER && interactType != (u32)INTERACT_POLE) { - // skip interactions for remote - continue; - } if (m->collidedObjInteractTypes & interactType) { struct Object *object = mario_get_collided_object(m, interactType); + bool allowRemoteInteractions = object && object->allowRemoteInteractions; + + if (m->playerIndex != 0 && interactType != (u32)INTERACT_PLAYER && interactType != (u32)INTERACT_POLE && !allowRemoteInteractions) { + // skip interactions for remote + continue; + } m->collidedObjInteractTypes &= ~interactType; diff --git a/src/game/spawn_object.c b/src/game/spawn_object.c index bb4a1e49..b0daf2a8 100644 --- a/src/game/spawn_object.c +++ b/src/game/spawn_object.c @@ -333,6 +333,7 @@ struct Object *allocate_object(struct ObjectNode *objList) { obj->areaTimerDuration = 0; obj->areaTimerRunOnceCallback = NULL; obj->setHome = FALSE; + obj->allowRemoteInteractions = FALSE; obj->usingObj = NULL; diff --git a/src/pc/lua/smlua_cobject_autogen.c b/src/pc/lua/smlua_cobject_autogen.c index a2e2be6e..af05c6b4 100644 --- a/src/pc/lua/smlua_cobject_autogen.c +++ b/src/pc/lua/smlua_cobject_autogen.c @@ -993,9 +993,10 @@ static struct LuaObjectField sNetworkPlayerFields[LUA_NETWORK_PLAYER_FIELD_COUNT { "type", LVT_U8, offsetof(struct NetworkPlayer, type), true, LOT_NONE }, }; -#define LUA_OBJECT_FIELD_COUNT 757 +#define LUA_OBJECT_FIELD_COUNT 758 static struct LuaObjectField sObjectFields[LUA_OBJECT_FIELD_COUNT] = { { "activeFlags", LVT_S16, offsetof(struct Object, activeFlags), false, LOT_NONE }, + { "allowRemoteInteractions", LVT_U8, offsetof(struct Object, allowRemoteInteractions), false, LOT_NONE }, { "areaTimer", LVT_U32, offsetof(struct Object, areaTimer), false, LOT_NONE }, { "areaTimerDuration", LVT_U32, offsetof(struct Object, areaTimerDuration), false, LOT_NONE }, // { "areaTimerRunOnceCallback)(void)", LVT_???, offsetof(struct Object, areaTimerRunOnceCallback)(void)), false, LOT_??? }, <--- UNIMPLEMENTED