Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Npc: Implement FukuwaraiFaceParts #270

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

GRAnimated
Copy link
Collaborator

@GRAnimated GRAnimated commented Jan 14, 2025

It's the capture(s) in the picture match room in Mushroom Kingdom. The name Fukuwarai is the original game it was based on.

I looked it up and Nintendo released a Mario Fukuwarai print out that looks pretty similar to SMO's:
fu
Link to the article

Interestingly, that article was created in December of 2016, meaning that this print out predates SMO's minigame. One must have inspired the other.


This change is Reviewable

Copy link
Owner

@MonsterDruide1 MonsterDruide1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 6 of 6 files at r1, all commit messages.
Reviewable status: all files reviewed, 8 unresolved discussions (waiting on @GRAnimated)


src/Npc/FukuwaraiFaceParts.cpp line 84 at r1 (raw file):

            rotation.y += 360.0f;
        }
        mTargetAngle = y;

Maybe the compiler generated this?

Suggestion:

        if (rotation.y < 0.0f) {
            rotation.y += 360.0f;
        }
        mTargetAngle = rotation.y;

src/Npc/FukuwaraiFaceParts.cpp line 98 at r1 (raw file):

}

s32 calculateFukuwaraiPartPriority(const char* name) {

Does it still match if you do [X]Part.name here instead of hardcoding them again?


src/Npc/FukuwaraiFaceParts.cpp line 151 at r1 (raw file):

            if (al::isMsgPlayerDisregard(message) || rs::isMsgPlayerDisregardHomingAttack(message))
                return true;
        }

Wow. I'm glad they checked the nerve here.

Code quote:

        if (al::isNerve(this, &NrvFukuwaraiFaceParts.Wait)) {
            if (al::isMsgPlayerDisregard(message) || rs::isMsgPlayerDisregardHomingAttack(message))
                return false;
        } else {
            if (al::isMsgPlayerDisregard(message) || rs::isMsgPlayerDisregardHomingAttack(message))
                return true;
        }

src/Npc/FukuwaraiFaceParts.cpp line 219 at r1 (raw file):

            bodyPart = MarioNosePart;
        else
            return -5.0f;

Nice, if the game messes up, you're being punished. Great.


src/Npc/FukuwaraiFaceParts.cpp line 235 at r1 (raw file):

    }

    return bodyPart.a + bodyPart.c * calcScoreAngleRate() + (bodyPart.b * calcScoreDistRate());

This is the only information we have available on a, b and c?

Just for myself: calcScore[X]Rate() returns a value between 0-1, where 1 is "you did good".


src/Npc/FukuwaraiFaceParts.cpp line 250 at r1 (raw file):

        difference = angle - mTargetAngle;
    else
        difference = mTargetAngle - angle;

(or some variation of this)

Suggestion:

    f32 difference = sead::Mathf::abs(angle - mTargetAngle);

src/Npc/FukuwaraiFaceParts.cpp line 255 at r1 (raw file):

    if (al::isEqualString("FukuwaraiMarioNose", al::getModelName(this))) {
        f32 clampedScore = (score > 90.0f) ? 180.0f - score : score;

(same as written above)

Suggestion:

f32 clampedScore = score > 90.0f ? 180.0f - score : score;

src/Npc/FukuwaraiFaceParts.cpp line 257 at r1 (raw file):

        f32 clampedScore = (score > 90.0f) ? 180.0f - score : score;

        return 1.0f - clampedScore / 90.0f;

Ohh, right, you can place the nose upside down - that's clever!

Code quote:

        f32 clampedScore = (score > 90.0f) ? 180.0f - score : score;

        return 1.0f - clampedScore / 90.0f;

src/Npc/FukuwaraiFaceParts.cpp line 270 at r1 (raw file):

    score = sead::Mathf::clamp(score, 0.0f, 1.0f);

    return (1.0f - score) * (1.0f - score);

Suggestion:

return sead::Mathf::square(1.0f - score);

src/Npc/FukuwaraiFaceParts.cpp line 347 at r1 (raw file):

        al::addRotateAndRepeatY(this, -2.0f);
        al::holdSe(this, "Rotate_loop");
    }

Not even custom actions that are not called Jump? Lame.

Code quote:

    if (rs::isHoldHackAction(mIUsePlayerHack)) {
        al::addRotateAndRepeatY(this, 2.0f);
        al::holdSe(this, "RotateRev_loop");
    }
    if (rs::isHoldHackJump(mIUsePlayerHack)) {
        al::addRotateAndRepeatY(this, -2.0f);
        al::holdSe(this, "Rotate_loop");
    }

src/Npc/FukuwaraiFaceParts.cpp line 383 at r1 (raw file):

    if (al::isGreaterStep(this, 30))
        al::setNerve(this, &NrvFukuwaraiFaceParts.CaptureMove);

... that's not a nice way to restart the animation.


src/Npc/FukuwaraiFaceParts.h line 17 at r1 (raw file):

    f32 a;
    f32 b;
    f32 c;

Not happy with these names, we don't get information from any other file, right?

Code quote:

    f32 a;
    f32 b;
    f32 c;

src/Npc/FukuwaraiFaceParts.h line 54 at r1 (raw file):

    f32 mTargetAngle = 0.0f;
    sead::Vector3f mTargetPos = sead::Vector3f::zero;
    al::AreaObjGroup* mAreaObjGroup = nullptr;

(name taken from FukuwaraiWatcher::init)

Suggestion:

al::AreaObjGroup* mFukuwaraiArea = nullptr;

Copy link
Collaborator Author

@GRAnimated GRAnimated left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: all files reviewed, 8 unresolved discussions (waiting on @MonsterDruide1)


src/Npc/FukuwaraiFaceParts.h line 17 at r1 (raw file):

Previously, MonsterDruide1 wrote…

Not happy with these names, we don't get information from any other file, right?

We do not. I can change them to whatever you want though, like field_8 and similar maybe.


src/Npc/FukuwaraiFaceParts.h line 54 at r1 (raw file):

Previously, MonsterDruide1 wrote…

(name taken from FukuwaraiWatcher::init)

Done.


src/Npc/FukuwaraiFaceParts.cpp line 84 at r1 (raw file):

Previously, MonsterDruide1 wrote…

Maybe the compiler generated this?

You're right!


src/Npc/FukuwaraiFaceParts.cpp line 98 at r1 (raw file):

Previously, MonsterDruide1 wrote…

Does it still match if you do [X]Part.name here instead of hardcoding them again?

No, and I don't think it makes sense do do that anyway. The assembly points directly to the string instead of going through the struct like calcScore. Also, There's "FukuwaraiKuriboMarioEyeRight" and "FukuwaraiKuriboMarioEyeLeft" that don't have a struct.


src/Npc/FukuwaraiFaceParts.cpp line 235 at r1 (raw file):

Previously, MonsterDruide1 wrote…

This is the only information we have available on a, b and c?

Just for myself: calcScore[X]Rate() returns a value between 0-1, where 1 is "you did good".

Yeah, those names aren't very descriptive but I don't know enough about the function to rename them to anything useful.


src/Npc/FukuwaraiFaceParts.cpp line 250 at r1 (raw file):

Previously, MonsterDruide1 wrote…

(or some variation of this)

Any variation of std::abs or Mathf::abs causes a mismatch here. I resorted to this after trying them. However, a ternary matches. Want me to use that instead?


src/Npc/FukuwaraiFaceParts.cpp line 255 at r1 (raw file):

Previously, MonsterDruide1 wrote…

(same as written above)

Done.


src/Npc/FukuwaraiFaceParts.cpp line 270 at r1 (raw file):

    score = sead::Mathf::clamp(score, 0.0f, 1.0f);

    return (1.0f - score) * (1.0f - score);

Done.

Copy link
Owner

@MonsterDruide1 MonsterDruide1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 2 of 2 files at r2, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @GRAnimated)


src/Npc/FukuwaraiFaceParts.cpp line 98 at r1 (raw file):

Previously, GRAnimated wrote…

No, and I don't think it makes sense do do that anyway. The assembly points directly to the string instead of going through the struct like calcScore. Also, There's "FukuwaraiKuriboMarioEyeRight" and "FukuwaraiKuriboMarioEyeLeft" that don't have a struct.

Alright, I just don't like the duplicated "magic names" here - but we'll just go with that then.


src/Npc/FukuwaraiFaceParts.cpp line 250 at r1 (raw file):

Previously, GRAnimated wrote…

Any variation of std::abs or Mathf::abs causes a mismatch here. I resorted to this after trying them. However, a ternary matches. Want me to use that instead?

No, that would exceed our line length and get broken up in an ugly way - just leave it like this then.


src/Npc/FukuwaraiFaceParts.cpp line 232 at r2 (raw file):

    }

    return bodyPart.a + bodyPart.c * calcScoreAngleRate() + (bodyPart.b * calcScoreDistRate());

reordered b/distance to the front and renamed the struct fields

Suggestion:

return bodyPart.mBasePoints + bodyPart.mDistancePoints * calcScoreDistRate() + bodyPart.mAnglePoints * calcScoreAngleRate();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants