diff --git a/include/types.h b/include/types.h index c46bdf01b..3d2e18f0d 100644 --- a/include/types.h +++ b/include/types.h @@ -214,7 +214,7 @@ struct Object /*0x204*/ f32 hurtboxHeight; /*0x208*/ f32 hitboxDownOffset; /*0x20C*/ const BehaviorScript *behavior; - /*0x210*/ u32 unused2; + /*0x210*/ u32 heldByPlayerIndex; /*0x214*/ struct Object *platform; /*0x218*/ void *collisionData; /*0x21C*/ Mat4 transform; diff --git a/src/game/behaviors/bobomb.inc.c b/src/game/behaviors/bobomb.inc.c index 64d36aad7..a0fde4d2c 100644 --- a/src/game/behaviors/bobomb.inc.c +++ b/src/game/behaviors/bobomb.inc.c @@ -179,8 +179,7 @@ void bobomb_free_loop(void) { void bobomb_held_loop(void) { o->header.gfx.node.flags |= GRAPH_RENDER_INVISIBLE; cur_obj_init_animation(1); - // LUIGI TODO: we need to be able to get the player that is actually holding it. - struct Object* player = nearest_player_to_object(o); + struct Object* player = gMarioStates[o->heldByPlayerIndex].marioObj; cur_obj_set_pos_relative(player, 0, 60.0f, 100.0); o->oBobombFuseLit = 1; diff --git a/src/game/interaction.c b/src/game/interaction.c index 8d8d10f84..b5448a1ea 100644 --- a/src/game/interaction.c +++ b/src/game/interaction.c @@ -288,6 +288,7 @@ void mario_grab_used_object(struct MarioState *m) { if (m->usedObj == NULL || m->usedObj->oHeldState == HELD_HELD) { return; } if (m->heldObj == NULL) { m->heldObj = m->usedObj; + m->heldObj->heldByPlayerIndex = (m == &gMarioStates[0]) ? 0 : 1; obj_set_held_state(m->heldObj, bhvCarrySomething3); } } diff --git a/src/game/spawn_object.c b/src/game/spawn_object.c index ee77f564b..6337486fc 100644 --- a/src/game/spawn_object.c +++ b/src/game/spawn_object.c @@ -260,7 +260,7 @@ struct Object *allocate_object(struct ObjectNode *objList) { obj->hurtboxRadius = 0.0f; obj->hurtboxHeight = 0.0f; obj->hitboxDownOffset = 0.0f; - obj->unused2 = 0; + obj->heldByPlayerIndex = 0; obj->platform = NULL; obj->collisionData = NULL;