From 598f974fdc8843ff448f6b69a99f61db6f8e94f4 Mon Sep 17 00:00:00 2001 From: yamamama Date: Sat, 31 Jan 2026 21:56:15 -0500 Subject: [PATCH] Follower mood system * Followers get happy when you hit others, and angry when others hit you * The mood doesn't do much beyond change the horn's symbol --- src/info/states.h | 2 ++ src/k_follower.c | 61 ++++++++++++++++++++++++++++++++++++++++++++--- src/k_follower.h | 8 +++++++ 3 files changed, 68 insertions(+), 3 deletions(-) diff --git a/src/info/states.h b/src/info/states.h index f4c659848..067f91d6d 100644 --- a/src/info/states.h +++ b/src/info/states.h @@ -3626,3 +3626,5 @@ _(RECSPIN_SKID) // Horncode _(HORNCODE) +_(HORNCODE_ANGRY) +_(HORNCODE_HAPPY) diff --git a/src/k_follower.c b/src/k_follower.c index d02762a1d..529650d2d 100644 --- a/src/k_follower.c +++ b/src/k_follower.c @@ -245,6 +245,32 @@ static void K_UpdateFollowerState(mobj_t *f, statenum_t state, followerstate_t t } } +/*-------------------------------------------------- + static void K_UpdateFollowerMood(mobj_t *f, followermood_t mood, tic_t time) + + Sets a follower object's mood and time before returning to a normal mood. + + Input Arguments:- + f - The follower's mobj_t. + mood - The mood to set. + time - The mood's duration. + + Return:- + None +--------------------------------------------------*/ +static void K_UpdateFollowerMood(mobj_t *f, followermood_t mood, tic_t time) +{ + if (f == NULL || P_MobjWasRemoved(f) == true) + { + // safety net + return; + } + + + f->extravalue3 = mood; + f->cvmem = (INT32)(time); +} + /*-------------------------------------------------- void K_HandleFollower(player_t *player) @@ -567,6 +593,20 @@ void K_HandleFollower(player_t *player) // However with how the code is factored, this is just a special case of S_INVISBLE to avoid having to add other player variables. + // Mood system + // For now, all this does is change the VFX generated when you honk your horn. + if (player->follower->cvmem && (player->follower->extravalue3 != FOLLOWERMOOD_NORMAL)) + { + // Tick down the mood timer + player->follower->cvmem--; + + // Return to our normal mood + if (player->follower->cvmem == 0) + { + player->follower->extravalue3 = FOLLOWERMOOD_NORMAL; + } + } + // handle follower animations. Could probably be better... // hurt or dead if (P_PlayerInPain(player) == true || player->mo->state == &states[S_KART_SPINOUT] || player->mo->health <= 0) @@ -585,6 +625,11 @@ void K_HandleFollower(player_t *player) // if dead, follow the player's z momentum exactly so they both look like they die at the same speed. player->follower->momz = player->mo->momz; } + else + { + // Not dead; get mad on the player's behalf. + K_UpdateFollowerMood(player->follower, FOLLOWERMOOD_ANGRY, (3 * TICRATE / 2)); + } } else if (player->exiting) { @@ -603,6 +648,7 @@ void K_HandleFollower(player_t *player) else if (player->follower->movecount) { K_UpdateFollowerState(player->follower, fl.hitconfirmstate, FOLLOWERSTATE_HITCONFIRM); + K_UpdateFollowerMood(player->follower, FOLLOWERMOOD_HAPPY, (3 * TICRATE / 2)); player->follower->movecount--; } else if (player->follower->reactiontime) @@ -702,12 +748,21 @@ void K_FollowerHornTaunt(player_t *taunter, player_t *victim) MT_FOLLOWERHORN ); - // TODO (yama): Honk icons based on a follower's "emotion" - // (♪ for hitconfirm honks, 💢 for mid-damage honks) - if (P_MobjWasRemoved(honk) == true) return; // Permit lua override of horn production + // Set the horn icon based on the follower's mood. + switch (taunter->follower->extravalue3) + { + case FOLLOWERMOOD_ANGRY: + P_SetMobjState(honk, S_HORNCODE_ANGRY); + break; + case FOLLOWERMOOD_HAPPY: + P_SetMobjState(honk, S_HORNCODE_HAPPY); + default: + break; + } + P_SetTarget(&taunter->follower->hprev, honk); P_SetTarget(&honk->target, taunter->follower); diff --git a/src/k_follower.h b/src/k_follower.h index 6cb5da15a..e1f2590ec 100644 --- a/src/k_follower.h +++ b/src/k_follower.h @@ -49,6 +49,14 @@ typedef enum FOLLOWERSTATE__MAX } followerstate_t; +typedef enum +{ + FOLLOWERMOOD_NORMAL, // Default mood, produces a ++ symbol when you honk. + FOLLOWERMOOD_HAPPY, // Happy mood (recent hitconfirm, won race), produces a ♪ symbol when you honk. + FOLLOWERMOOD_ANGRY, // Angry/upset mood (taking damage, recently took damage), produces a 💢 symbol when you honk. + FOLLOWERMOOD__MAX +} followermood_t; + // // We'll define these here because they're really just a mobj that'll follow some rules behind a player //