From d33b123e32a4ff1a6b73f62725dcf1c8f239cc9f Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Wed, 28 Aug 2024 01:01:19 -0400 Subject: [PATCH] Implement reticule gfx, fix FOFs/walls/scale --- src/info.c | 5 ++- src/info.h | 1 + src/k_kart.c | 41 ++++++++++++-------- src/k_kart.h | 2 + src/objects/ballhog.cpp | 83 +++++++++++++++++++++++++++-------------- src/p_map.c | 6 +++ src/p_mobj.c | 33 ++++++++-------- 7 files changed, 110 insertions(+), 61 deletions(-) diff --git a/src/info.c b/src/info.c index 7cd1a0dec..40cc9949f 100644 --- a/src/info.c +++ b/src/info.c @@ -370,6 +370,7 @@ char sprnames[NUMSPRITES + 1][5] = "DTRG", // Drop Target "BHOG", // Ballhog "BHBM", // Ballhog BOOM + "BHGR", // Ballhog reticule "SPBM", // Self-Propelled Bomb "TRIS", // SPB Manta Ring start "TRNQ", // SPB Manta Ring loop @@ -2458,7 +2459,7 @@ state_t states[NUMSTATES] = {SPR_BHBM, FF_FULLBRIGHT|13, 1, {NULL}, 0, 0, S_BALLHOGBOOM15}, // S_BALLHOGBOOM14 {SPR_BHBM, FF_FULLBRIGHT|14, 1, {NULL}, 0, 0, S_BALLHOGBOOM16}, // S_BALLHOGBOOM15 {SPR_BHBM, FF_FULLBRIGHT|15, 1, {NULL}, 0, 0, S_NULL}, // S_BALLHOGBOOM16 - {SPR_SPBM, FF_FULLBRIGHT|0, -1, {NULL}, 0, 0, S_NULL}, // S_BALLHOG_RETICULE + {SPR_BHGR, FF_ANIMATE|FF_FULLBRIGHT|0, 2*TICRATE, {NULL}, 5, 3, S_NULL}, // S_BALLHOG_RETICULE {SPR_SPBM, 0, 1, {NULL}, 0, 0, S_SPB2}, // S_SPB1 {SPR_SPBM, 1, 1, {NULL}, 0, 0, S_SPB3}, // S_SPB2 @@ -15231,7 +15232,7 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = 100, // mass 0, // damage sfx_None, // activesound - MF_NOTHINK|MF_NOBLOCKMAP|MF_NOCLIPTHING|MF_DONTENCOREMAP|MF_DONTPUNT, // flags + MF_NOCLIPTHING|MF_DONTENCOREMAP|MF_DONTPUNT, // flags S_NULL // raisestate }, diff --git a/src/info.h b/src/info.h index 6eff5131e..e16625725 100644 --- a/src/info.h +++ b/src/info.h @@ -909,6 +909,7 @@ typedef enum sprite SPR_DTRG, // Drop Target SPR_BHOG, // Ballhog SPR_BHBM, // Ballhog BOOM + SPR_BHGR, // Ballhog reticule SPR_SPBM, // Self-Propelled Bomb SPR_TRIS, // SPB Manta Ring start SPR_TRNQ, // SPB Manta Ring loop diff --git a/src/k_kart.c b/src/k_kart.c index 712d2db4a..31d096430 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -5472,9 +5472,25 @@ void K_SpawnLandMineExplosion(mobj_t *source, skincolornum_t color, tic_t delay) } } -fixed_t K_ItemScaleForPlayer(player_t *player) +fixed_t K_GetItemScaleConst(fixed_t scale) { - switch (player->itemscale) + if (scale >= FixedMul(GROW_PHYSICS_SCALE, mapobjectscale)) + { + return ITEMSCALE_GROW; + } + else if (scale <= FixedMul(SHRINK_PHYSICS_SCALE, mapobjectscale)) + { + return ITEMSCALE_SHRINK; + } + else + { + return ITEMSCALE_NORMAL; + } +} + +fixed_t K_ItemScaleFromConst(UINT8 item_scale_const) +{ + switch (item_scale_const) { case ITEMSCALE_GROW: return FixedMul(GROW_SCALE, mapobjectscale); @@ -5487,6 +5503,11 @@ fixed_t K_ItemScaleForPlayer(player_t *player) } } +fixed_t K_ItemScaleForPlayer(player_t *player) +{ + return K_ItemScaleFromConst(player->itemscale); +} + fixed_t K_DefaultPlayerRadius(player_t *player) { mobj_t *top = K_GetGardenTop(player); @@ -6598,7 +6619,7 @@ mobj_t *K_ThrowKartItemEx(player_t *player, boolean missile, mobjtype_t mapthing if (tossX != 0 || tossY != 0) { - fixed_t g = 5 * DEFAULT_GRAVITY / 2; // P_GetMobjGravity does not work here?? + fixed_t g = FixedMul(5 * DEFAULT_GRAVITY / 2, mapobjectscale); // P_GetMobjGravity does not work here?? if (dir > FRACUNIT) { g = FixedMul(g, dir); @@ -12766,19 +12787,7 @@ static void K_trickPanelTimingVisual(player_t *player, fixed_t momz) void K_SetItemOut(player_t *player) { player->itemflags |= IF_ITEMOUT; - - if (player->mo->scale >= FixedMul(GROW_PHYSICS_SCALE, mapobjectscale)) - { - player->itemscale = ITEMSCALE_GROW; - } - else if (player->mo->scale <= FixedMul(SHRINK_PHYSICS_SCALE, mapobjectscale)) - { - player->itemscale = ITEMSCALE_SHRINK; - } - else - { - player->itemscale = ITEMSCALE_NORMAL; - } + player->itemscale = K_GetItemScaleConst(player->mo->scale); } void K_UnsetItemOut(player_t *player) diff --git a/src/k_kart.h b/src/k_kart.h index e61767b2a..769d0da97 100644 --- a/src/k_kart.h +++ b/src/k_kart.h @@ -263,6 +263,8 @@ void K_PlayHitEmSound(mobj_t *source, mobj_t *other); void K_TryHurtSoundExchange(mobj_t *victim, mobj_t *attacker); void K_PlayPowerGloatSound(mobj_t *source); +fixed_t K_GetItemScaleConst(fixed_t scale); +fixed_t K_ItemScaleFromConst(UINT8 item_scale_const); fixed_t K_ItemScaleForPlayer(player_t *player); void K_SetItemOut(player_t *player); void K_UnsetItemOut(player_t *player); diff --git a/src/objects/ballhog.cpp b/src/objects/ballhog.cpp index e57d19273..d11a24bf3 100644 --- a/src/objects/ballhog.cpp +++ b/src/objects/ballhog.cpp @@ -59,7 +59,7 @@ static void CalculateHogAngles(UINT8 n) if (total_hogs > 1) { - const fixed_t base_radius = mobjinfo[MT_BALLHOG].radius * 3 / 2; + const fixed_t base_radius = mobjinfo[MT_BALLHOG].radius * 6; fixed_t radius = base_radius; UINT8 max_points = 6; angle_t circle_offset = 0; @@ -129,13 +129,26 @@ static boolean HogReticuleEmulate(mobj_t *mobj) return true; // mobj was removed } - //P_CheckPosition(mobj, mobj->x, mobj->y, NULL); + if (P_MobjWasRemoved(mobj) == true) + { + return true; + } } - return (P_MobjWasRemoved(mobj) == true || (x == mobj->x && y == mobj->y && z == mobj->z)); + if (P_MobjWasRemoved(mobj) == true) + { + return true; + } + + if (x == mobj->x && y == mobj->y && z == mobj->z) + { + return true; + } + + return false; } -static void HogReticuleTest(player_t *player, vector3_t *ret) +static void HogReticuleTest(player_t *player, vector3_t *ret, fixed_t final_scale) { // Emulate the movement of a tossed ballhog // until it hits something. @@ -157,21 +170,11 @@ static void HogReticuleTest(player_t *player, vector3_t *ret) // Intentionally NOT player scale, that doesn't work. proj_speed = FixedMul(proj_speed, mapobjectscale); - fixed_t finalscale = ITEMSCALE_NORMAL; - if (player->mo->scale >= FixedMul(GROW_PHYSICS_SCALE, mapobjectscale)) - { - finalscale = ITEMSCALE_GROW; - } - else if (player->mo->scale <= FixedMul(SHRINK_PHYSICS_SCALE, mapobjectscale)) - { - finalscale = ITEMSCALE_SHRINK; - } - // Shoot forward //P_MoveOrigin(mo, player->mo->x, player->mo->y, player->mo->z + (player->mo->height / 2)); // FINE! YOU WIN! I'll make an object every time I need to test this... mobj_t *mo = P_SpawnMobj(player->mo->x, player->mo->y, player->mo->z + (player->mo->height / 2), MT_BALLHOG_RETICULE_TEST); - mo->fuse = 2; // if something goes wrong, destroy this + mo->fuse = 2; // if something goes wrong, destroy it mo->angle = player->mo->angle; @@ -183,7 +186,8 @@ static void HogReticuleTest(player_t *player, vector3_t *ret) mo->flags2 |= (player->mo->flags2 & MF2_OBJECTFLIP); } - //P_SetTarget(&mo->target, player->mo); + P_SetTarget(&mo->target, player->mo); + mo->threshold = 10; mo->extravalue2 = dir; @@ -199,12 +203,12 @@ static void HogReticuleTest(player_t *player, vector3_t *ret) mo->momz = (117 * mo->momz) / 200; } - P_SetScale(mo, finalscale); - mo->destscale = finalscale; + P_SetScale(mo, final_scale); + mo->destscale = final_scale; // Contra spread shot scale up - //mo->destscale = mo->destscale << 1; - //mo->scalespeed = abs(mo->destscale - mo->scale) / (2*TICRATE); + mo->destscale = mo->destscale << 1; + mo->scalespeed = abs(mo->destscale - mo->scale) / (2*TICRATE); ret->x = mo->x; ret->y = mo->y; @@ -213,6 +217,11 @@ static void HogReticuleTest(player_t *player, vector3_t *ret) constexpr INT32 max_iteration = 256; for (INT32 i = 0; i < max_iteration; i++) { +#if 0 + mobj_t *test = P_SpawnMobj(mo->x, mo->y, mo->z, MT_THOK); + test->tics = 2; +#endif + if (HogReticuleEmulate(mo) == true) { break; @@ -238,14 +247,23 @@ void K_UpdateBallhogReticules(player_t *player, UINT8 num_hogs, boolean on_relea return; } - constexpr tic_t kBallhogReticuleTime = TICRATE / 2; - const UINT8 start_hogs = num_hogs; +#if 1 + if (start_hogs == 0) + { + return; + } +#endif + CalculateHogAngles(num_hogs); // Calculate center positon + fixed_t final_scale = K_ItemScaleFromConst(K_GetItemScaleConst(player->mo->scale)); + vector3_t center = {0, 0, 0}; - HogReticuleTest(player, ¢er); // Originally this was called for everything, but it's more optimized to only run 1 prediction. + HogReticuleTest(player, ¢er, final_scale); // Originally this was called for everything, but it's more optimized to only run 1 prediction. + + constexpr tic_t kBallhogReticuleTime = (TICRATE * 3 / 4); // Update existing reticules. mobj_t *reticule = player->ballhogreticule; @@ -259,8 +277,8 @@ void K_UpdateBallhogReticules(player_t *player, UINT8 num_hogs, boolean on_relea const UINT8 old_hogs = reticule->extravalue1; UINT8 angle_index = num_hogs - 1; - fixed_t x_offset = g_hogangles[angle_index].x; - fixed_t y_offset = g_hogangles[angle_index].y; + fixed_t x_offset = FixedMul(g_hogangles[angle_index].x, final_scale); + fixed_t y_offset = FixedMul(g_hogangles[angle_index].y, final_scale); if (on_release == true) { @@ -291,6 +309,11 @@ void K_UpdateBallhogReticules(player_t *player, UINT8 num_hogs, boolean on_relea } reticule->tics = kBallhogReticuleTime; + reticule->color = player->skincolor; + + reticule->destscale = final_scale * 2; + P_SetScale(reticule, reticule->destscale); + num_hogs--; } #if 0 @@ -334,15 +357,19 @@ void K_UpdateBallhogReticules(player_t *player, UINT8 num_hogs, boolean on_relea P_SetTarget(&new_reticule->hprev, player->mo); } - // Start in center new_reticule->extravalue1 = start_hogs; + new_reticule->tics = kBallhogReticuleTime; + new_reticule->color = player->skincolor; + + new_reticule->destscale = final_scale * 2; + P_SetScale(new_reticule, new_reticule->destscale); if (on_release == true) { UINT8 angle_index = num_hogs - 1; - fixed_t x_offset = g_hogangles[angle_index].x; - fixed_t y_offset = g_hogangles[angle_index].y; + fixed_t x_offset = FixedMul(g_hogangles[angle_index].x, final_scale); + fixed_t y_offset = FixedMul(g_hogangles[angle_index].y, final_scale); P_SetOrigin(new_reticule, center.x + x_offset, center.y + y_offset, center.z); } diff --git a/src/p_map.c b/src/p_map.c index 7f1965aee..f8be8b6f9 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -2747,6 +2747,12 @@ fixed_t P_BaseStepUp(void) fixed_t P_GetThingStepUp(mobj_t *thing, fixed_t destX, fixed_t destY) { + if (thing->type == MT_BALLHOG || thing->type == MT_BALLHOG_RETICULE_TEST) + { + // these should explode, not go up stairs + return 0; + } + const fixed_t maxstepmove = P_BaseStepUp(); fixed_t maxstep = maxstepmove; diff --git a/src/p_mobj.c b/src/p_mobj.c index 3c0a2d81f..11a650ea4 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -1697,8 +1697,9 @@ boolean P_XYMovement(mobj_t *mo) P_PushSpecialLine(result.line, mo); - if (mo->type == MT_BALLHOG_RETICULE_TEST) + if (mo->type == MT_BALLHOG || mo->type == MT_BALLHOG_RETICULE_TEST) { + P_ExplodeMissile(mo); return false; } @@ -1813,14 +1814,9 @@ boolean P_XYMovement(mobj_t *mo) xmove = ymove = 0; S_StartSound(mo, mo->info->activesound); - //{ SRB2kart - Orbinaut, Ballhog - // Ballhog dies on contact with walls - if (mo->type == MT_BALLHOG) - { - P_ExplodeMissile(mo); - } + //{ SRB2kart - Orbinaut // Bump sparks - else if (mo->type == MT_ORBINAUT || mo->type == MT_GACHABOM) + if (mo->type == MT_ORBINAUT || mo->type == MT_GACHABOM) { mobj_t *fx; fx = P_SpawnMobj(mo->x, mo->y, mo->z, MT_BUMP); @@ -2260,6 +2256,7 @@ boolean P_ZMovement(mobj_t *mo) mo->eflags &= ~MFE_APPLYPMOMZ; } mo->z += mo->momz; + onground = P_IsObjectOnGround(mo); if (mo->standingslope) @@ -2323,15 +2320,10 @@ boolean P_ZMovement(mobj_t *mo) } break; case MT_BALLHOG: - if (mo->z <= mo->floorz || mo->z + mo->height >= mo->ceilingz) - { - P_ExplodeMissile(mo); - return false; - } - break; case MT_BALLHOG_RETICULE_TEST: if (mo->z <= mo->floorz || mo->z + mo->height >= mo->ceilingz) { + P_ExplodeMissile(mo); return false; } break; @@ -2380,7 +2372,6 @@ boolean P_ZMovement(mobj_t *mo) else if (delta > 0 && dist < (delta*3)) mo->z += FixedMul(FLOATSPEED, mo->scale); } - } // clip movement @@ -10647,6 +10638,18 @@ void P_SceneryThinker(mobj_t *mobj) if (P_MobjWasRemoved(mobj)) return; } + + if (mobj->type == MT_BALLHOG_RETICULE) + { + if (mobj->tics & 1) + { + mobj->renderflags &= ~RF_DONTDRAW; + } + else + { + mobj->renderflags |= RF_DONTDRAW; + } + } } //