From fa10ff629f358165be8cc99a2ed1e8a8a1783393 Mon Sep 17 00:00:00 2001 From: toaster Date: Thu, 15 Jun 2023 19:39:55 +0100 Subject: [PATCH] servant-hand.c --- src/k_kart.c | 98 +---------------------------------- src/k_kart.h | 1 - src/k_objects.h | 3 ++ src/objects/CMakeLists.txt | 1 + src/objects/servant-hand.c | 103 +++++++++++++++++++++++++++++++++++++ 5 files changed, 108 insertions(+), 98 deletions(-) create mode 100644 src/objects/servant-hand.c diff --git a/src/k_kart.c b/src/k_kart.c index 8ff8e25c3..bb05f7adc 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -8282,7 +8282,7 @@ void K_KartPlayerThink(player_t *player, ticcmd_t *cmd) { K_KartEbrakeVisuals(player); - K_KartServantHandVisuals(player); + Obj_ServantHandHandling(player); } if (K_GetKartButtons(player) & BT_BRAKE && @@ -10170,102 +10170,6 @@ void K_KartEbrakeVisuals(player_t *p) } } -void K_KartServantHandVisuals(player_t *player) -{ - if (player->pflags & PF_WRONGWAY) - { - if (player->handtimer < TICRATE) - { - player->handtimer++; - if (player->hand == NULL && player->handtimer == TICRATE) - { - mobj_t *hand = P_SpawnMobj( - player->mo->x, - player->mo->y, - player->mo->z + player->mo->height + 30*mapobjectscale, - MT_SERVANTHAND - ); - - if (hand) - { - K_FlipFromObject(hand, player->mo); - hand->old_z = hand->z; - - P_SetTarget(&hand->target, player->mo); - P_SetTarget(&player->hand, hand); - - hand->fuse = 8; - } - } - } - - if (player->hand) - { - player->hand->destscale = mapobjectscale; - } - } - else if (player->handtimer != 0) - { - player->handtimer--; - } - - if (player->hand) - { - const fixed_t handpokespeed = 4; - const fixed_t looping = handpokespeed - abs((player->hand->threshold % (handpokespeed*2)) - handpokespeed); - fixed_t xoffs = 0, yoffs = 0; - - player->hand->color = player->skincolor; - player->hand->angle = player->besthanddirection; - - if (player->hand->fuse != 0) - { - ; - } - else if (looping != 0) - { - xoffs = FixedMul(2 * looping * mapobjectscale, FINECOSINE(player->hand->angle >> ANGLETOFINESHIFT)), - yoffs = FixedMul(2 * looping * mapobjectscale, FINESINE(player->hand->angle >> ANGLETOFINESHIFT)), - - player->hand->threshold++; - } - else if (player->handtimer == 0) - { - player->hand->fuse = 8; - } - else - { - player->hand->threshold++; - } - - if (player->hand->fuse != 0) - { - if ((player->hand->fuse > 4) ^ (player->handtimer < TICRATE/2)) - { - player->hand->spritexscale = FRACUNIT/3; - player->hand->spriteyscale = 3*FRACUNIT; - } - else - { - player->hand->spritexscale = 2*FRACUNIT; - player->hand->spriteyscale = FRACUNIT/2; - } - } - - P_MoveOrigin(player->hand, - player->mo->x + xoffs, - player->mo->y + yoffs, - player->mo->z + player->mo->height + 30*mapobjectscale - ); - K_FlipFromObject(player->hand, player->mo); - - player->hand->sprzoff = player->mo->sprzoff; - - player->hand->renderflags &= ~RF_DONTDRAW; - player->hand->renderflags |= (RF_DONTDRAW & ~K_GetPlayerDontDrawFlag(player)); - } -} - static void K_KartSpindashDust(mobj_t *parent) { fixed_t rad = FixedDiv(FixedHypot(parent->radius, parent->radius), parent->scale); diff --git a/src/k_kart.h b/src/k_kart.h index 379d8c3ea..af7d142d2 100644 --- a/src/k_kart.h +++ b/src/k_kart.h @@ -196,7 +196,6 @@ UINT8 K_GetInvincibilityItemFrame(void); UINT8 K_GetOrbinautItemFrame(UINT8 count); boolean K_IsSPBInGame(void); void K_KartEbrakeVisuals(player_t *p); -void K_KartServantHandVisuals(player_t *player); void K_HandleDirectionalInfluence(player_t *player); fixed_t K_DefaultPlayerRadius(player_t *player); diff --git a/src/k_objects.h b/src/k_objects.h index 5deb7749f..3ea63b8ce 100644 --- a/src/k_objects.h +++ b/src/k_objects.h @@ -137,6 +137,9 @@ void Obj_RandomItemSpawn(mobj_t *mobj); void Obj_GachaBomReboundThink(mobj_t *mobj); void Obj_SpawnGachaBomRebound(mobj_t *source, mobj_t *target); +/* Servant Hand */ +void Obj_ServantHandHandling(player_t *player); + #ifdef __cplusplus } // extern "C" #endif diff --git a/src/objects/CMakeLists.txt b/src/objects/CMakeLists.txt index 0c6fd74e9..6ec83ac0c 100644 --- a/src/objects/CMakeLists.txt +++ b/src/objects/CMakeLists.txt @@ -20,4 +20,5 @@ target_sources(SRB2SDL2 PRIVATE instawhip.c block.c gachabom-rebound.cpp + servant-hand.c ) diff --git a/src/objects/servant-hand.c b/src/objects/servant-hand.c new file mode 100644 index 000000000..3a94ab69a --- /dev/null +++ b/src/objects/servant-hand.c @@ -0,0 +1,103 @@ +#include "../doomdef.h" +#include "../p_local.h" +#include "../p_mobj.h" +#include "../d_player.h" +#include "../k_kart.h" +#include "../k_objects.h" +#include "../v_video.h" + +void Obj_ServantHandHandling(player_t *player) +{ + if (player->pflags & PF_WRONGWAY) + { + if (player->handtimer < TICRATE) + { + player->handtimer++; + if (player->hand == NULL && player->handtimer == TICRATE) + { + mobj_t *hand = P_SpawnMobj( + player->mo->x, + player->mo->y, + player->mo->z + player->mo->height + 30*mapobjectscale, + MT_SERVANTHAND + ); + + if (hand) + { + K_FlipFromObject(hand, player->mo); + hand->old_z = hand->z; + + P_SetTarget(&hand->target, player->mo); + P_SetTarget(&player->hand, hand); + + hand->fuse = 8; + } + } + } + + if (player->hand) + { + player->hand->destscale = mapobjectscale; + } + } + else if (player->handtimer != 0) + { + player->handtimer--; + } + + if (player->hand) + { + const fixed_t handpokespeed = 4; + const fixed_t looping = handpokespeed - abs((player->hand->threshold % (handpokespeed*2)) - handpokespeed); + fixed_t xoffs = 0, yoffs = 0; + + player->hand->color = player->skincolor; + player->hand->angle = player->besthanddirection; + + if (player->hand->fuse != 0) + { + ; + } + else if (looping != 0) + { + xoffs = FixedMul(2 * looping * mapobjectscale, FINECOSINE(player->hand->angle >> ANGLETOFINESHIFT)), + yoffs = FixedMul(2 * looping * mapobjectscale, FINESINE(player->hand->angle >> ANGLETOFINESHIFT)), + + player->hand->threshold++; + } + else if (player->handtimer == 0) + { + player->hand->fuse = 8; + } + else + { + player->hand->threshold++; + } + + if (player->hand->fuse != 0) + { + if ((player->hand->fuse > 4) ^ (player->handtimer < TICRATE/2)) + { + player->hand->spritexscale = FRACUNIT/3; + player->hand->spriteyscale = 3*FRACUNIT; + } + else + { + player->hand->spritexscale = 2*FRACUNIT; + player->hand->spriteyscale = FRACUNIT/2; + } + } + + P_MoveOrigin(player->hand, + player->mo->x + xoffs, + player->mo->y + yoffs, + player->mo->z + player->mo->height + 30*mapobjectscale + ); + K_FlipFromObject(player->hand, player->mo); + + player->hand->sprzoff = player->mo->sprzoff; + + player->hand->renderflags &= ~RF_DONTDRAW; + player->hand->renderflags |= (RF_DONTDRAW & ~K_GetPlayerDontDrawFlag(player)); + } +}