Revert some formatting changes in interaction.c and mario_update_punch_sequence

This commit is contained in:
Arceveti
2021-11-18 14:25:38 -08:00
parent 222930f745
commit 033395d1cb
3 changed files with 97 additions and 45 deletions

View File

@@ -362,13 +362,11 @@ void mario_retrieve_cap(void) {
u32 able_to_grab_object(struct MarioState *m, UNUSED struct Object *obj) {
u32 action = m->action;
if ((action == ACT_DIVE_SLIDE)
|| (action == ACT_DIVE)) {
if (action == ACT_DIVE_SLIDE || action == ACT_DIVE) {
if (!(obj->oInteractionSubtype & INT_SUBTYPE_GRABS_MARIO)) {
return TRUE;
}
} else if ((action == ACT_PUNCHING)
|| (action == ACT_MOVE_PUNCHING)) {
} else if (action == ACT_PUNCHING || action == ACT_MOVE_PUNCHING) {
if (m->actionArg < 2) {
return TRUE;
}
@@ -412,7 +410,7 @@ u32 mario_check_object_grab(struct MarioState *m) {
m->usedObj = m->interactObj;
if (!(m->action & ACT_FLAG_AIR)) {
set_mario_action(m, ((m->action & ACT_FLAG_DIVING) ? ACT_DIVE_PICKING_UP : ACT_PICKING_UP), 0);
set_mario_action(m, (m->action & ACT_FLAG_DIVING) ? ACT_DIVE_PICKING_UP : ACT_PICKING_UP, 0);
}
result = TRUE;
@@ -586,14 +584,14 @@ u32 determine_knockback_action(struct MarioState *m, UNUSED s32 arg) {
void push_mario_out_of_object(struct MarioState *m, struct Object *obj, f32 padding) {
f32 minDistance = (obj->hitboxRadius + m->marioObj->hitboxRadius + padding);
f32 offsetX = (m->pos[0] - obj->oPosX);
f32 offsetZ = (m->pos[2] - obj->oPosZ);
f32 distanceSquared = (sqr(offsetX) + sqr(offsetZ));
f32 offsetX = m->pos[0] - obj->oPosX;
f32 offsetZ = m->pos[2] - obj->oPosZ;
f32 distanceSquared = sqr(offsetX) + sqr(offsetZ);
if (distanceSquared < sqr(minDistance)) {
struct Surface *floor;
s16 pushAngle = ((distanceSquared == 0.0f) ? m->faceAngle[1] : atan2s(offsetZ, offsetX));
f32 newMarioX = (obj->oPosX + (minDistance * sins(pushAngle)));
f32 newMarioZ = (obj->oPosZ + (minDistance * coss(pushAngle)));
f32 newMarioX = obj->oPosX + minDistance * sins(pushAngle);
f32 newMarioZ = obj->oPosZ + minDistance * coss(pushAngle);
f32_find_wall_collision(&newMarioX, &m->pos[1], &newMarioZ, 60.0f, 50.0f);
f32 floorHeight = find_floor(newMarioX, m->pos[1], newMarioZ, &floor);
if (floor != NULL) {
@@ -681,17 +679,17 @@ u32 take_damage_and_knock_back(struct MarioState *m, struct Object *obj) {
}
void reset_mario_pitch(struct MarioState *m) {
if ((m->action == ACT_WATER_JUMP)
|| (m->action == ACT_SHOT_FROM_CANNON)
|| (m->action == ACT_FLYING)) {
if (m->action == ACT_WATER_JUMP
|| m->action == ACT_SHOT_FROM_CANNON
|| m->action == ACT_FLYING) {
set_camera_mode(m->area->camera, m->area->camera->defMode, 1);
m->faceAngle[0] = 0;
}
}
u32 interact_coin(struct MarioState *m, UNUSED u32 interactType, struct Object *obj) {
m->numCoins += obj->oDamageOrCoinValue;
m->healCounter += 4 * obj->oDamageOrCoinValue;
m->numCoins += obj->oDamageOrCoinValue;
m->healCounter += 4 * obj->oDamageOrCoinValue;
#ifdef BREATH_METER
m->breathCounter += 4 * obj->oDamageOrCoinValue;
#endif
@@ -715,7 +713,7 @@ u32 interact_water_ring(struct MarioState *m, UNUSED u32 interactType, struct Ob
#ifdef BREATH_METER
m->breathCounter += 4 * obj->oDamageOrCoinValue;
#else
m->healCounter += 4 * obj->oDamageOrCoinValue;
m->healCounter += 4 * obj->oDamageOrCoinValue;
#endif
obj->oInteractStatus = INT_STATUS_INTERACTED;
return FALSE;
@@ -726,7 +724,7 @@ u32 interact_star_or_key(struct MarioState *m, UNUSED u32 interactType, struct O
#ifdef NON_STOP_STARS
u32 noExit = TRUE;
#else
u32 noExit = (obj->oInteractionSubtype & INT_SUBTYPE_NO_EXIT ) != 0;
u32 noExit = (obj->oInteractionSubtype & INT_SUBTYPE_NO_EXIT) != 0;
#endif
u32 grandStar = (obj->oInteractionSubtype & INT_SUBTYPE_GRAND_STAR) != 0;
@@ -754,9 +752,13 @@ u32 interact_star_or_key(struct MarioState *m, UNUSED u32 interactType, struct O
} else {
starGrabAction = ACT_STAR_DANCE_NO_EXIT;
}
if (m->action & (ACT_FLAG_SWIMMING | ACT_FLAG_METAL_WATER)) starGrabAction = ACT_STAR_DANCE_WATER;
if (m->action & (ACT_FLAG_SWIMMING | ACT_FLAG_METAL_WATER)) {
starGrabAction = ACT_STAR_DANCE_WATER;
}
if (m->action & ACT_FLAG_AIR) {
starGrabAction = ((m->pos[1] < (m->floorHeight + 1024.0f)) ? ACT_FALL_AFTER_STAR_GRAB : ACT_STAR_DANCE_WATER);
starGrabAction = ((m->pos[1] < m->floorHeight + 1024.0f) ? ACT_FALL_AFTER_STAR_GRAB : ACT_STAR_DANCE_WATER);
}
spawn_object(obj, MODEL_NONE, bhvStarKeyCollectionPuffSpawner);
@@ -767,7 +769,7 @@ u32 interact_star_or_key(struct MarioState *m, UNUSED u32 interactType, struct O
#ifdef GLOBAL_STAR_IDS
u32 starIndex = GET_BPARAM1(obj->oBehParams);
#else
u32 starIndex = (GET_BPARAM1(obj->oBehParams) & 0x1F);
u32 starIndex = GET_BPARAM1(obj->oBehParams) & 0x1F;
#endif
save_file_collect_star_or_key(m->numCoins, starIndex);
@@ -898,8 +900,7 @@ u32 interact_warp_door(struct MarioState *m, UNUSED u32 interactType, struct Obj
}
#endif
if ((m->action == ACT_WALKING)
|| (m->action == ACT_DECELERATING)) {
if (m->action == ACT_WALKING || m->action == ACT_DECELERATING) {
u32 actionArg = (should_push_or_pull_door(m, obj) + WARP_FLAG_DOOR_IS_WARP);
if (doorAction == 0) {

View File

@@ -67,7 +67,6 @@ enum InteractSubtypes {
INT_SUBTYPE_NPC = /* 0x00004000 */ (1 << 14),
// INTERACT_CLAM_OR_BUBBA
INT_SUBTYPE_EATS_MARIO = /* 0x00002000 */ (1 << 13),
};
enum AttackType {
@@ -124,19 +123,19 @@ enum Interactions {
INT_ATTACK_NOT_WEAK_FROM_ABOVE = (INT_GROUND_POUND_OR_TWIRL | INT_PUNCH | INT_KICK | INT_TRIP | INT_HIT_FROM_BELOW),
};
s32 mario_obj_angle_to_object(struct MarioState *m, struct Object *obj);
s32 mario_obj_angle_to_object(struct MarioState *m, struct Object *obj);
void mario_stop_riding_object(struct MarioState *m);
void mario_grab_used_object(struct MarioState *m);
void mario_drop_held_object(struct MarioState *m);
void mario_throw_held_object(struct MarioState *m);
void mario_stop_riding_and_holding(struct MarioState *m);
u32 does_mario_have_normal_cap_on_head(struct MarioState *m);
u32 does_mario_have_normal_cap_on_head(struct MarioState *m);
void mario_blow_off_cap(struct MarioState *m, f32 capSpeed);
u32 mario_lose_cap_to_enemy(u32 enemyType);
u32 mario_lose_cap_to_enemy(u32 enemyType);
void mario_retrieve_cap(void);
struct Object *mario_get_collided_object(struct MarioState *m, u32 interactType);
u32 mario_check_object_grab(struct MarioState *m);
u32 get_door_save_file_flag(struct Object *door);
u32 mario_check_object_grab(struct MarioState *m);
u32 get_door_save_file_flag(struct Object *door);
void mario_process_interactions(struct MarioState *m);
void mario_handle_special_floors(struct MarioState *m);

View File

@@ -29,9 +29,11 @@ s32 mario_update_punch_sequence(struct MarioState *m) {
s32 animFrame;
if (m->action & ACT_FLAG_MOVING) {
endAction = ACT_WALKING, crouchEndAction = ACT_CROUCH_SLIDE;
endAction = ACT_WALKING;
crouchEndAction = ACT_CROUCH_SLIDE;
} else {
endAction = ACT_IDLE, crouchEndAction = ACT_CROUCHING;
endAction = ACT_IDLE;
crouchEndAction = ACT_CROUCHING;
}
switch (m->actionArg) {
@@ -41,46 +43,94 @@ s32 mario_update_punch_sequence(struct MarioState *m) {
case ACT_ARG_PUNCH_SEQUENCE_FIRST_PUNCH:
set_mario_animation(m, MARIO_ANIM_FIRST_PUNCH);
m->actionArg = (is_anim_past_end(m) ? ACT_ARG_PUNCH_SEQUENCE_FIRST_PUNCH_FAST : ACT_ARG_PUNCH_SEQUENCE_FIRST_PUNCH);
if (m->marioObj->header.gfx.animInfo.animFrame >= 2) {
if (mario_check_object_grab(m)) return TRUE;
if (mario_check_object_grab(m)) {
return TRUE;
}
m->flags |= MARIO_PUNCHING;
}
if (m->actionArg == ACT_ARG_PUNCH_SEQUENCE_FIRST_PUNCH_FAST) m->marioBodyState->punchState = (PUNCH_STATE_TYPE_FIRST_PUNCH | 0x4);
if (m->actionArg == ACT_ARG_PUNCH_SEQUENCE_FIRST_PUNCH_FAST) {
m->marioBodyState->punchState = (PUNCH_STATE_TYPE_FIRST_PUNCH | 0x4);
}
break;
case ACT_ARG_PUNCH_SEQUENCE_FIRST_PUNCH_FAST:
set_mario_animation(m, MARIO_ANIM_FIRST_PUNCH_FAST);
if (m->marioObj->header.gfx.animInfo.animFrame <= 0) m->flags |= MARIO_PUNCHING;
if (m->input & INPUT_B_PRESSED) m->actionArg = ACT_ARG_PUNCH_SEQUENCE_WAH;
if (is_anim_at_end(m)) set_mario_action(m, endAction, 0);
if (m->marioObj->header.gfx.animInfo.animFrame <= 0) {
m->flags |= MARIO_PUNCHING;
}
if (m->input & INPUT_B_PRESSED) {
m->actionArg = ACT_ARG_PUNCH_SEQUENCE_WAH;
}
if (is_anim_at_end(m)) {
set_mario_action(m, endAction, 0);
}
break;
case ACT_ARG_PUNCH_SEQUENCE_WAH:
play_sound(SOUND_MARIO_PUNCH_WAH, m->marioObj->header.gfx.cameraToObject);
// fallthrough
case ACT_ARG_PUNCH_SEQUENCE_SECOND_PUNCH:
set_mario_animation(m, MARIO_ANIM_SECOND_PUNCH);
m->actionArg = (is_anim_past_end(m) ? ACT_ARG_PUNCH_SEQUENCE_SECOND_PUNCH_FAST : ACT_ARG_PUNCH_SEQUENCE_SECOND_PUNCH);
if (m->marioObj->header.gfx.animInfo.animFrame > 0) m->flags |= MARIO_PUNCHING;
if (m->actionArg == ACT_ARG_PUNCH_SEQUENCE_SECOND_PUNCH_FAST) m->marioBodyState->punchState = (PUNCH_STATE_TYPE_SECOND_PUNCH | 0x4);
if (m->marioObj->header.gfx.animInfo.animFrame > 0) {
m->flags |= MARIO_PUNCHING;
}
if (m->actionArg == ACT_ARG_PUNCH_SEQUENCE_SECOND_PUNCH_FAST) {
m->marioBodyState->punchState = (PUNCH_STATE_TYPE_SECOND_PUNCH | 0x4);
}
break;
case ACT_ARG_PUNCH_SEQUENCE_SECOND_PUNCH_FAST:
set_mario_animation(m, MARIO_ANIM_SECOND_PUNCH_FAST);
if (m->marioObj->header.gfx.animInfo.animFrame <= 0) m->flags |= MARIO_PUNCHING;
if (m->input & INPUT_B_PRESSED) m->actionArg = ACT_ARG_PUNCH_SEQUENCE_GROUND_KICK;
if (is_anim_at_end(m)) set_mario_action(m, endAction, 0);
if (m->marioObj->header.gfx.animInfo.animFrame <= 0) {
m->flags |= MARIO_PUNCHING;
}
if (m->input & INPUT_B_PRESSED) {
m->actionArg = ACT_ARG_PUNCH_SEQUENCE_GROUND_KICK;
}
if (is_anim_at_end(m)) {
set_mario_action(m, endAction, 0);
}
break;
case ACT_ARG_PUNCH_SEQUENCE_GROUND_KICK:
play_mario_action_sound(m, SOUND_MARIO_PUNCH_HOO, 1);
animFrame = set_mario_animation(m, MARIO_ANIM_GROUND_KICK);
if (animFrame == 0) m->marioBodyState->punchState = (PUNCH_STATE_TYPE_KICK | 0x6);
if (animFrame >= 0 && animFrame < 8) m->flags |= MARIO_KICKING;
if (is_anim_at_end(m)) set_mario_action(m, endAction, 0);
if (animFrame == 0) {
m->marioBodyState->punchState = (PUNCH_STATE_TYPE_KICK | 0x6);
}
if (animFrame >= 0 && animFrame < 8) {
m->flags |= MARIO_KICKING;
}
if (is_anim_at_end(m)) {
set_mario_action(m, endAction, 0);
}
break;
case ACT_ARG_PUNCH_SEQUENCE_BREAKDANCE:
play_mario_action_sound(m, SOUND_MARIO_PUNCH_HOO, 1);
set_mario_animation(m, MARIO_ANIM_BREAKDANCE);
animFrame = m->marioObj->header.gfx.animInfo.animFrame;
if (animFrame >= 2 && animFrame < 8) m->flags |= MARIO_TRIPPING;
if (is_anim_at_end(m)) set_mario_action(m, crouchEndAction, 0);
if (animFrame >= 2 && animFrame < 8) {
m->flags |= MARIO_TRIPPING;
}
if (is_anim_at_end(m)) {
set_mario_action(m, crouchEndAction, 0);
}
break;
}
@@ -162,6 +212,7 @@ s32 act_dive_picking_up(struct MarioState *m) {
if (m->input & INPUT_OFF_FLOOR) {
return drop_and_set_mario_action(m, ACT_FREEFALL, 0);
}
if (m->input & INPUT_ABOVE_SLIDE) {
return drop_and_set_mario_action(m, ACT_BEGIN_SLIDING, 0);
}
@@ -172,6 +223,7 @@ s32 act_dive_picking_up(struct MarioState *m) {
if (m->input & INPUT_OFF_FLOOR) {
return set_mario_action(m, ACT_FREEFALL, 0);
}
if (m->input & INPUT_ABOVE_SLIDE) {
return set_mario_action(m, ACT_BEGIN_SLIDING, 0);
}