Restore vanilla angle checks for kick/pick

This commit is contained in:
MysterD 2023-04-03 15:23:10 -07:00
parent 74e0dc7c77
commit 0d21c66037

View file

@ -196,7 +196,7 @@ s16 mario_obj_angle_to_object(struct MarioState *m, struct Object *o) {
* Determines Mario's interaction with a given object depending on their proximity, * Determines Mario's interaction with a given object depending on their proximity,
* action, speed, and position. * action, speed, and position.
*/ */
u32 determine_interaction(struct MarioState *m, struct Object *o) { static u32 determine_interaction_internal(struct MarioState *m, struct Object *o, u8 isPVP) {
u32 interaction = 0; u32 interaction = 0;
u32 action = m->action; u32 action = m->action;
@ -212,17 +212,24 @@ u32 determine_interaction(struct MarioState *m, struct Object *o) {
s16 dYawToObject = mario_obj_angle_to_object(m, o) - m->faceAngle[1]; s16 dYawToObject = mario_obj_angle_to_object(m, o) - m->faceAngle[1];
if (m->flags & MARIO_PUNCHING) { if (m->flags & MARIO_PUNCHING) {
// 120 degrees total, or 60 each way
if (isPVP || (-0x2AAA <= dYawToObject && dYawToObject <= 0x2AAA)) {
interaction = INT_PUNCH; interaction = INT_PUNCH;
} }
}
if (m->flags & MARIO_KICKING) { if (m->flags & MARIO_KICKING) {
// 120 degrees total, or 60 each way
if (isPVP || (-0x2AAA <= dYawToObject && dYawToObject <= 0x2AAA)) {
interaction = INT_KICK; interaction = INT_KICK;
} }
}
if (m->flags & MARIO_TRIPPING) { if (m->flags & MARIO_TRIPPING) {
// 180 degrees total, or 90 each way // 180 degrees total, or 90 each way
if (-0x4000 <= dYawToObject && dYawToObject <= 0x4000) { if (-0x4000 <= dYawToObject && dYawToObject <= 0x4000) {
interaction = INT_TRIP; interaction = INT_TRIP;
} }
} }
} else if (action == ACT_GROUND_POUND || action == ACT_TWIRLING) { } else if (action == ACT_GROUND_POUND || action == ACT_TWIRLING) {
if (m->vel[1] < 0.0f) { if (m->vel[1] < 0.0f) {
interaction = INT_GROUND_POUND_OR_TWIRL; interaction = INT_GROUND_POUND_OR_TWIRL;
@ -262,6 +269,14 @@ u32 determine_interaction(struct MarioState *m, struct Object *o) {
return interaction; return interaction;
} }
u32 determine_interaction(struct MarioState *m, struct Object *o) {
return determine_interaction_internal(m, o, FALSE);
}
u32 determine_interaction_pvp(struct MarioState *m, struct Object *o) {
return determine_interaction_internal(m, o, TRUE);
}
/** /**
* Sets the interaction types for INT_STATUS_INTERACTED, INT_STATUS_WAS_ATTACKED * Sets the interaction types for INT_STATUS_INTERACTED, INT_STATUS_WAS_ATTACKED
*/ */
@ -1427,7 +1442,7 @@ u32 interact_player_pvp(struct MarioState* attacker, struct MarioState* victim)
} }
// see if it was an attack // see if it was an attack
u32 interaction = determine_interaction(attacker, cVictim->marioObj); u32 interaction = determine_interaction_pvp(attacker, cVictim->marioObj);
if (!(interaction & INT_ANY_ATTACK) || (interaction & INT_HIT_FROM_ABOVE) || !passes_pvp_interaction_checks(attacker, cVictim)) { if (!(interaction & INT_ANY_ATTACK) || (interaction & INT_HIT_FROM_ABOVE) || !passes_pvp_interaction_checks(attacker, cVictim)) {
return FALSE; return FALSE;
} }