Saved player index in held objects

This commit is contained in:
MysterD 2020-08-01 19:03:26 -07:00
parent fa2470327f
commit 01e02affad
4 changed files with 4 additions and 4 deletions

View File

@ -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;

View File

@ -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;

View File

@ -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);
}
}

View File

@ -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;