Enemies drop player when picked up

This commit is contained in:
MysterD 2020-10-14 23:52:07 -07:00
parent cb09e24eeb
commit b05fee2fd9
3 changed files with 14 additions and 2 deletions

View File

@ -6,6 +6,7 @@ void common_anchor_mario_behavior(f32 sp28, f32 sp2C, s32 sp30) {
struct MarioState* marioState = &gMarioStates[i];
struct Object* player = gMarioStates[i].marioObj;
if (marioState->heldByObj != o->parentObj && marioState->heldByObj != o) { continue; }
if (marioState->action != ACT_GRABBED) { continue; }
switch (o->parentObj->oChuckyaUnk88) {
case 0:
break;

View File

@ -682,7 +682,18 @@ s32 act_grabbed(struct MarioState *m) {
// check if they should still be grabbed
if (m->playerIndex == 0) {
if (m->heldByObj == NULL || !(m->heldByObj->oInteractStatus | INT_STATUS_GRABBED_MARIO)) {
// check if the object holding me is being held
u8 heldObjIsHeld = FALSE;
if (m->heldByObj != NULL) {
for (int i = 0; i < MAX_PLAYERS; i++) {
if (!is_player_active(&gMarioStates[i])) { continue; }
if (gMarioStates[i].heldObj == m->heldByObj) { heldObjIsHeld = TRUE; }
}
}
// error state, get out of grab
if (heldObjIsHeld || m->heldByObj == NULL || !(m->heldByObj->oInteractStatus | INT_STATUS_GRABBED_MARIO)) {
m->heldByObj = NULL;
return set_mario_action(m, (m->forwardVel >= 0.0f) ? ACT_THROWN_FORWARD : ACT_THROWN_BACKWARD, FALSE);
}
}

View File

@ -259,7 +259,7 @@ void network_receive_player(struct Packet* p) {
// find and set their held object
m->heldObj = (heldSyncID != 0) ? gSyncObjects[heldSyncID].o : NULL;
if (m->heldObj != NULL) {
if (np->globalIndex < gNetworkPlayerLocal->globalIndex) {
if (gMarioStates[0].heldObj == m->heldObj && np->globalIndex < gNetworkPlayerLocal->globalIndex) {
// drop the object if a higher priority player is holding our object
mario_drop_held_object(&gMarioStates[0]);
force_idle_state(&gMarioStates[0]);