From cf9bfcae028b7a7d20d9c6c6708d4b4ae59a613e Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Sat, 10 Sep 2022 21:44:40 -0400 Subject: [PATCH 01/26] Start on new Shrink Currently just spawns an object that goes along the waypoint path --- src/deh_tables.c | 2 + src/info.c | 27 ++++ src/info.h | 2 + src/k_kart.c | 36 +---- src/k_objects.h | 4 + src/k_waypoint.c | 1 + src/objects/Sourcefile | 1 + src/objects/shrink.c | 347 +++++++++++++++++++++++++++++++++++++++++ src/p_mobj.c | 5 + 9 files changed, 390 insertions(+), 35 deletions(-) create mode 100644 src/objects/shrink.c diff --git a/src/deh_tables.c b/src/deh_tables.c index d58550367..dd97d1825 100644 --- a/src/deh_tables.c +++ b/src/deh_tables.c @@ -5336,6 +5336,8 @@ const char *const MOBJTYPE_LIST[] = { // array length left dynamic for sanity t "MT_HYUDORO", "MT_HYUDORO_CENTER", + "MT_SHRINK_POHBEE", + "MT_SINK", // Kitchen Sink Stuff "MT_SINK_SHIELD", "MT_SINKTRAIL", diff --git a/src/info.c b/src/info.c index 72665927e..f7135472a 100644 --- a/src/info.c +++ b/src/info.c @@ -24009,6 +24009,33 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = S_NULL // raisestate }, + { // MT_SHRINK_POHBEE + -1, // doomednum + S_HYUDORO, // spawnstate + 1000, // spawnhealth + S_NULL, // seestate + sfx_None, // seesound + 8, // reactiontime + sfx_None, // attacksound + S_NULL, // painstate + 0, // painchance + sfx_None, // painsound + S_NULL, // meleestate + S_NULL, // missilestate + S_NULL, // deathstate + S_NULL, // xdeathstate + sfx_None, // deathsound + 0, // speed + 32*FRACUNIT, // radius + 24*FRACUNIT, // height + 0, // display offset + 0, // mass + 0, // damage + sfx_None, // activesound + MF_NOCLIP|MF_NOCLIPTHING|MF_NOCLIPHEIGHT|MF_NOGRAVITY|MF_DONTENCOREMAP, // flags + S_NULL // raisestate + }, + { // MT_SINK -1, // doomednum S_SINK, // spawnstate diff --git a/src/info.h b/src/info.h index ab1867973..5d96a4317 100644 --- a/src/info.h +++ b/src/info.h @@ -6362,6 +6362,8 @@ typedef enum mobj_type MT_HYUDORO, MT_HYUDORO_CENTER, + MT_SHRINK_POHBEE, + MT_SINK, // Kitchen Sink Stuff MT_SINK_SHIELD, MT_SINKTRAIL, diff --git a/src/k_kart.c b/src/k_kart.c index ab8f04da9..08d3fc1a9 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -5581,46 +5581,12 @@ void K_DoSneaker(player_t *player, INT32 type) static void K_DoShrink(player_t *user) { - INT32 i; mobj_t *mobj, *next; S_StartSound(user->mo, sfx_kc46); // Sound the BANG! user->pflags |= PF_ATTACKDOWN; - for (i = 0; i < MAXPLAYERS; i++) - { - if (!playeringame[i] || players[i].spectator || !players[i].mo) - continue; - if (&players[i] == user) - continue; - if (players[i].position < user->position) - { - //P_FlashPal(&players[i], PAL_NUKE, 10); - - // Grow should get taken away. - if (players[i].growshrinktimer > 0) - K_RemoveGrowShrink(&players[i]); - else - { - // Start shrinking! - K_DropItems(&players[i]); - players[i].growshrinktimer = -(15*TICRATE); - - if (players[i].mo && !P_MobjWasRemoved(players[i].mo)) - { - players[i].mo->scalespeed = mapobjectscale/TICRATE; - players[i].mo->destscale = FixedMul(mapobjectscale, SHRINK_SCALE); - - if (K_PlayerShrinkCheat(&players[i]) == true) - { - players[i].mo->destscale = FixedMul(players[i].mo->destscale, SHRINK_SCALE); - } - - S_StartSound(players[i].mo, sfx_kc59); - } - } - } - } + Obj_CreateShrinkPohbees(user); // kill everything in the kitem list while we're at it: for (mobj = kitemcap; mobj; mobj = next) diff --git a/src/k_objects.h b/src/k_objects.h index 45f9df78c..d0b6f6b8b 100644 --- a/src/k_objects.h +++ b/src/k_objects.h @@ -8,4 +8,8 @@ void Obj_HyudoroThink(mobj_t *actor); void Obj_HyudoroCenterThink(mobj_t *actor); void Obj_HyudoroCollide(mobj_t *special, mobj_t *toucher); +/* Shrink */ +void Obj_PohbeeThinker(mobj_t *pohbee); +void Obj_CreateShrinkPohbees(player_t *owner); + #endif/*k_objects_H*/ diff --git a/src/k_waypoint.c b/src/k_waypoint.c index a6a592a6b..0a8dfd0f0 100644 --- a/src/k_waypoint.c +++ b/src/k_waypoint.c @@ -2044,6 +2044,7 @@ boolean K_SetupWaypointList(void) // Loop through the waypointcap here so that all waypoints are added to the heap, and allow easier debugging for (waypointmobj = waypointcap; waypointmobj; waypointmobj = waypointmobj->tracer) { + waypointmobj->cusval = (INT32)numwaypoints; K_SetupWaypoint(waypointmobj); } diff --git a/src/objects/Sourcefile b/src/objects/Sourcefile index f7e4f2491..94f7dd25b 100644 --- a/src/objects/Sourcefile +++ b/src/objects/Sourcefile @@ -1 +1,2 @@ hyudoro.c +shrink.c diff --git a/src/objects/shrink.c b/src/objects/shrink.c new file mode 100644 index 000000000..b6e41111b --- /dev/null +++ b/src/objects/shrink.c @@ -0,0 +1,347 @@ +// DR. ROBOTNIK'S RING RACERS +//----------------------------------------------------------------------------- +// Copyright (C) 2022 by Sally "TehRealSalt" Cochenour +// Copyright (C) 2022 by Kart Krew +// +// This program is free software distributed under the +// terms of the GNU General Public License, version 2. +// See the 'LICENSE' file for more details. +//----------------------------------------------------------------------------- +/// \file shrink.c +/// \brief Shrink laser item code. + +#include "../doomdef.h" +#include "../doomstat.h" +#include "../info.h" +#include "../k_kart.h" +#include "../k_objects.h" +#include "../m_random.h" +#include "../p_local.h" +#include "../r_main.h" +#include "../s_sound.h" +#include "../g_game.h" +#include "../z_zone.h" +#include "../k_waypoint.h" + +#define POHBEE_HOVER (300 << FRACBITS) +#define POHBEE_SPEED (128 << FRACBITS) +#define POHBEE_TIME (15 * TICRATE) +#define POHBEE_DIST (2048 << FRACBITS) +#define POHBEE_CHAIN (16) + +#define LASER_SPEED (20 << FRACBITS) + +enum +{ + POHBEE_MODE_SPAWN, + POHBEE_MODE_ACT, + POHBEE_MODE_DESPAWN, +}; + +#define pohbee_mode(o) ((o)->cusval) + +#define pohbee_waypoint_cur(o) ((o)->extravalue1) +#define pohbee_waypoint_dest(o) ((o)->extravalue2) + +#define pohbee_owner(o) ((o)->target) +#define pohbee_laser(o) ((o)->tracer) +#define pohbee_chain(o) ((o)->hnext) + +#define laser_owner(o) ((o)->target) +#define laser_pohbee(o) ((o)->tracer) + +static void PohbeeMoveTo(mobj_t *pohbee, fixed_t destx, fixed_t desty, fixed_t destz) +{ + pohbee->momx = destx - pohbee->x; + pohbee->momy = desty - pohbee->y; + pohbee->momz = destz - pohbee->z; +} + +static fixed_t GenericDistance( + fixed_t curx, fixed_t cury, fixed_t curz, + fixed_t destx, fixed_t desty, fixed_t destz) +{ + return P_AproxDistance(P_AproxDistance(destx - curx, desty - cury), destz - curz); +} + +static fixed_t PohbeeWaypointZ(mobj_t *dest) +{ + return dest->z + (FixedMul(POHBEE_HOVER, mapobjectscale) * P_MobjFlip(dest)); +} + +static void PohbeeSpawn(mobj_t *pohbee) +{ + waypoint_t *curWaypoint = NULL; + waypoint_t *destWaypoint = NULL; + + fixed_t distLeft = INT32_MAX; + fixed_t newX = pohbee->x; + fixed_t newY = pohbee->y; + fixed_t newZ = pohbee->z; + + boolean finalize = false; + + const boolean useshortcuts = false; + const boolean huntbackwards = false; + boolean pathfindsuccess = false; + path_t pathtofinish = {0}; + size_t pathIndex = 0; + + curWaypoint = K_GetWaypointFromIndex((size_t)pohbee_waypoint_cur(pohbee)); + destWaypoint = K_GetWaypointFromIndex((size_t)pohbee_waypoint_dest(pohbee)); + + if (curWaypoint == NULL || destWaypoint == NULL) + { + // Waypoints aren't valid. + // Just transition into the next state. + pohbee_mode(pohbee) = POHBEE_MODE_ACT; + return; + } + + distLeft = FixedMul(POHBEE_SPEED, mapobjectscale); + + while (distLeft > 0) + { + fixed_t wpX = curWaypoint->mobj->x; + fixed_t wpY = curWaypoint->mobj->y; + fixed_t wpZ = PohbeeWaypointZ(curWaypoint->mobj); + + fixed_t distToNext = GenericDistance( + newX, newY, newZ, + wpX, wpY, wpZ + ); + + if (distToNext > distLeft) + { + // Only made it partially there. + newX += FixedMul(FixedDiv(wpX - newX, distToNext), distLeft); + newY += FixedMul(FixedDiv(wpY - newY, distToNext), distLeft); + newZ += FixedMul(FixedDiv(wpZ - newZ, distToNext), distLeft); + + distLeft = 0; + } + else + { + // Close enough to the next waypoint, + // move there and remove the distance. + newX = wpX; + newY = wpY; + newZ = wpZ; + + distLeft -= distToNext; + + if (curWaypoint == destWaypoint) + { + // Reached the end. + finalize = true; + break; + } + + // Create waypoint path to our destination. + // Crazy over-engineered, just to catch when + // waypoints are insanely close to each other :P + if (pathfindsuccess == false) + { + pathfindsuccess = K_PathfindToWaypoint( + curWaypoint, destWaypoint, + &pathtofinish, + useshortcuts, huntbackwards + ); + + if (pathfindsuccess == false) + { + // Path isn't valid. + // Just transition into the next state. + finalize = true; + break; + } + } + + pathIndex++; + + if (pathIndex >= pathtofinish.numnodes) + { + // Successfully reached the end of the path. + finalize = true; + break; + } + + // Now moving to the next waypoint. + curWaypoint = (waypoint_t *)pathtofinish.array[pathIndex].nodedata; + pohbee_waypoint_cur(pohbee) = (INT32)K_GetWaypointHeapIndex(curWaypoint); + } + } + + PohbeeMoveTo(pohbee, newX, newY, newZ); + + if (finalize == true) + { + pohbee_mode(pohbee) = POHBEE_MODE_ACT; + } + + if (pathfindsuccess == true) + { + Z_Free(pathtofinish.array); + } +} + +void Obj_PohbeeThinker(mobj_t *pohbee) +{ + pohbee->momx = 0; + pohbee->momy = 0; + pohbee->momz = 0; + + switch (pohbee_mode(pohbee)) + { + case POHBEE_MODE_SPAWN: + PohbeeSpawn(pohbee); + break; + + case POHBEE_MODE_ACT: + //PohbeeSpawn(pohbee); + break; + + case POHBEE_MODE_DESPAWN: + //PohbeeSpawn(pohbee); + break; + + default: + // failsafe + pohbee_mode(pohbee) = POHBEE_MODE_SPAWN; + break; + } +} + +static void CreatePohbeeForPlayer(player_t *target, player_t *owner) +{ + const UINT32 traveldist = FixedMul(POHBEE_DIST, mapobjectscale) / FRACUNIT; + + mobj_t *pohbee = NULL; + //mobj_t *laser = NULL; + + waypoint_t *startWaypoint = NULL; + waypoint_t *endWaypoint = NULL; + + I_Assert(target != NULL); + I_Assert(owner != NULL); + + if (target->mo == NULL || P_MobjWasRemoved(target->mo) == true) + { + // No object for the target. + return; + } + + // First, go backwards to find our starting point. + { + const boolean useshortcuts = false; + const boolean huntbackwards = true; + boolean pathfindsuccess = false; + path_t pathtofinish = {0}; + + pathfindsuccess = K_PathfindThruCircuit( + target->nextwaypoint, traveldist, + &pathtofinish, + useshortcuts, huntbackwards + ); + + if (pathfindsuccess == true) + { + startWaypoint = (waypoint_t *)pathtofinish.array[ pathtofinish.numnodes - 1 ].nodedata; + Z_Free(pathtofinish.array); + } + else + { + startWaypoint = target->nextwaypoint; + } + } + + // Now, go forwards to get our ending point. + { + const boolean useshortcuts = false; + const boolean huntbackwards = false; + boolean pathfindsuccess = false; + path_t pathtofinish = {0}; + + pathfindsuccess = K_PathfindThruCircuit( + target->nextwaypoint, traveldist * 2, + &pathtofinish, + useshortcuts, huntbackwards + ); + + if (pathfindsuccess == true) + { + endWaypoint = (waypoint_t *)pathtofinish.array[ pathtofinish.numnodes - 1 ].nodedata; + Z_Free(pathtofinish.array); + } + else + { + endWaypoint = target->nextwaypoint; + } + } + + // Try to repair an incomplete pair, just in case. + if (startWaypoint == NULL && endWaypoint != NULL) + { + startWaypoint = endWaypoint; + } + + if (endWaypoint == NULL && startWaypoint != NULL) + { + endWaypoint = startWaypoint; + } + + if (startWaypoint == NULL || endWaypoint == NULL) + { + // Unable to create shrink lasers + // due to invalid waypoint structure... + return; + } + + // Valid spawning conditions, + // we can start creating each individual part. + pohbee = P_SpawnMobjFromMobj(startWaypoint->mobj, 0, 0, POHBEE_HOVER, MT_SHRINK_POHBEE); + + P_SetTarget(&pohbee_owner(pohbee), owner->mo); + + pohbee_mode(pohbee) = POHBEE_MODE_SPAWN; + + pohbee_waypoint_cur(pohbee) = (INT32)K_GetWaypointHeapIndex(startWaypoint); + pohbee_waypoint_dest(pohbee) = (INT32)K_GetWaypointHeapIndex(endWaypoint); +} + +void Obj_CreateShrinkPohbees(player_t *owner) +{ + UINT8 ownerPos = 1; + UINT8 i; + + I_Assert(owner != NULL); + + ownerPos = owner->position; + + for (i = 0; i < MAXPLAYERS; i++) + { + player_t *player = NULL; + + if (playeringame[i] == false) + { + // Not valid. + continue; + } + + player = &players[i]; + + if (player->spectator == true) + { + // Not playing. + continue; + } + + if (player->position > ownerPos) + { + // Too far behind. + continue; + } + + CreatePohbeeForPlayer(player, owner); + } +} diff --git a/src/p_mobj.c b/src/p_mobj.c index 621da9d9f..f2aebb6d7 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -7841,6 +7841,11 @@ static boolean P_MobjRegularThink(mobj_t *mobj) Obj_HyudoroCenterThink(mobj); break; } + case MT_SHRINK_POHBEE: + { + Obj_PohbeeThinker(mobj); + break; + } case MT_ROCKETSNEAKER: if (!mobj->target || !mobj->target->health) { From a74506690fa9e9a1218e3a60b87007f287418c27 Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Sun, 11 Sep 2022 02:15:44 -0400 Subject: [PATCH 02/26] More shrink foundation - Keeps track of ties. If multiple Poh-Bees would go to the same waypoint, then it will combine them into a single one, with multiple lasers attached to it. - Added the laser shooters. Still purely visual. - Added despawn behavior. --- src/deh_tables.c | 1 + src/info.c | 27 ++++ src/info.h | 1 + src/objects/shrink.c | 356 ++++++++++++++++++++++++++++++++----------- 4 files changed, 295 insertions(+), 90 deletions(-) diff --git a/src/deh_tables.c b/src/deh_tables.c index dd97d1825..9e7718333 100644 --- a/src/deh_tables.c +++ b/src/deh_tables.c @@ -5337,6 +5337,7 @@ const char *const MOBJTYPE_LIST[] = { // array length left dynamic for sanity t "MT_HYUDORO_CENTER", "MT_SHRINK_POHBEE", + "MT_SHRINK_LASER", "MT_SINK", // Kitchen Sink Stuff "MT_SINK_SHIELD", diff --git a/src/info.c b/src/info.c index f7135472a..e1ea01a05 100644 --- a/src/info.c +++ b/src/info.c @@ -24036,6 +24036,33 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = S_NULL // raisestate }, + { // MT_SHRINK_LASER + -1, // doomednum + S_HYUDORO, // spawnstate + 1000, // spawnhealth + S_NULL, // seestate + sfx_None, // seesound + 8, // reactiontime + sfx_None, // attacksound + S_NULL, // painstate + 0, // painchance + sfx_None, // painsound + S_NULL, // meleestate + S_NULL, // missilestate + S_NULL, // deathstate + S_NULL, // xdeathstate + sfx_None, // deathsound + 0, // speed + 32*FRACUNIT, // radius + 24*FRACUNIT, // height + 0, // display offset + 0, // mass + 0, // damage + sfx_None, // activesound + MF_NOCLIP|MF_NOCLIPTHING|MF_NOCLIPHEIGHT|MF_NOGRAVITY|MF_DONTENCOREMAP, // flags + S_NULL // raisestate + }, + { // MT_SINK -1, // doomednum S_SINK, // spawnstate diff --git a/src/info.h b/src/info.h index 5d96a4317..668485d69 100644 --- a/src/info.h +++ b/src/info.h @@ -6363,6 +6363,7 @@ typedef enum mobj_type MT_HYUDORO_CENTER, MT_SHRINK_POHBEE, + MT_SHRINK_LASER, MT_SINK, // Kitchen Sink Stuff MT_SINK_SHIELD, diff --git a/src/objects/shrink.c b/src/objects/shrink.c index b6e41111b..bde2fdb35 100644 --- a/src/objects/shrink.c +++ b/src/objects/shrink.c @@ -23,13 +23,15 @@ #include "../z_zone.h" #include "../k_waypoint.h" -#define POHBEE_HOVER (300 << FRACBITS) +#define POHBEE_HOVER (384 << FRACBITS) #define POHBEE_SPEED (128 << FRACBITS) #define POHBEE_TIME (15 * TICRATE) -#define POHBEE_DIST (2048 << FRACBITS) -#define POHBEE_CHAIN (16) +#define POHBEE_DIST (4096 << FRACBITS) #define LASER_SPEED (20 << FRACBITS) +#define LASER_SWINGTIME (3 * TICRATE) + +#define CHAIN_SIZE (16) enum { @@ -39,16 +41,20 @@ enum }; #define pohbee_mode(o) ((o)->cusval) - +#define pohbee_timer(o) ((o)->reactiontime) #define pohbee_waypoint_cur(o) ((o)->extravalue1) #define pohbee_waypoint_dest(o) ((o)->extravalue2) #define pohbee_owner(o) ((o)->target) -#define pohbee_laser(o) ((o)->tracer) -#define pohbee_chain(o) ((o)->hnext) +#define pohbee_lasers(o) ((o)->hnext) -#define laser_owner(o) ((o)->target) -#define laser_pohbee(o) ((o)->tracer) +#define laser_offset(o) ((o)->movecount) +#define laser_swing(o) ((o)->movedir) +#define laser_numsegs(o) ((o)->extravalue1) + +#define laser_pohbee(o) ((o)->target) +#define laser_collider(o) ((o)->tracer) +#define laser_chains(o) ((o)->hprev) static void PohbeeMoveTo(mobj_t *pohbee, fixed_t destx, fixed_t desty, fixed_t destz) { @@ -173,9 +179,11 @@ static void PohbeeSpawn(mobj_t *pohbee) } PohbeeMoveTo(pohbee, newX, newY, newZ); + pohbee->angle = K_MomentumAngle(pohbee); if (finalize == true) { + // Move to next state pohbee_mode(pohbee) = POHBEE_MODE_ACT; } @@ -185,11 +193,77 @@ static void PohbeeSpawn(mobj_t *pohbee) } } +static void PohbeeAct(mobj_t *pohbee) +{ + pohbee_timer(pohbee)--; + + if (pohbee_timer(pohbee) <= 0) + { + // Move to next state + pohbee_mode(pohbee) = POHBEE_MODE_DESPAWN; + pohbee->fuse = 5*TICRATE; + } +} + +static void PohbeeDespawn(mobj_t *pohbee) +{ + pohbee->momz = 16 * pohbee->scale * P_MobjFlip(pohbee); +} + +static void DoLaserSwing(mobj_t *laser, mobj_t *pohbee) +{ + const angle_t angle = laser->angle + ANGLE_90; + const tic_t swingTimer = leveltime + laser_offset(laser); + + const angle_t swingAmt = swingTimer * (ANGLE_MAX / LASER_SWINGTIME); + const fixed_t swingCos = FINECOSINE(swingAmt >> ANGLETOFINESHIFT); + const fixed_t swing = FixedMul(laser_swing(laser), 9 * swingCos); + + const angle_t pitch = -ANGLE_90 + swing; + const fixed_t dist = laser_numsegs(laser) * CHAIN_SIZE * laser->scale; + + fixed_t offsetX = FixedMul( + dist, FixedMul( + FINECOSINE(angle >> ANGLETOFINESHIFT), + FINECOSINE(pitch >> ANGLETOFINESHIFT) + ) + ); + + fixed_t offsetY = FixedMul( + dist, FixedMul( + FINESINE(angle >> ANGLETOFINESHIFT), + FINECOSINE(pitch >> ANGLETOFINESHIFT) + ) + ); + + fixed_t offsetZ = FixedMul( + dist, FINESINE(pitch >> ANGLETOFINESHIFT) + ); + + PohbeeMoveTo(laser, pohbee->x + offsetX, pohbee->y + offsetY, pohbee->z + offsetZ); +} + +static void ShrinkLaserThinker(mobj_t *laser) +{ + mobj_t *pohbee = laser_pohbee(laser); + + if (pohbee == NULL || P_MobjWasRemoved(pohbee) == true) + { + P_RemoveMobj(laser); + return; + } + + laser->angle = pohbee->angle; + DoLaserSwing(laser, pohbee); + + //PohbeeMoveTo(laser_collider(laser), laser->x, laser->y, laser->z); +} + void Obj_PohbeeThinker(mobj_t *pohbee) { - pohbee->momx = 0; - pohbee->momy = 0; - pohbee->momz = 0; + mobj_t *laser = NULL; + + pohbee->momx = pohbee->momy = pohbee->momz = 0; switch (pohbee_mode(pohbee)) { @@ -198,11 +272,11 @@ void Obj_PohbeeThinker(mobj_t *pohbee) break; case POHBEE_MODE_ACT: - //PohbeeSpawn(pohbee); + PohbeeAct(pohbee); break; case POHBEE_MODE_DESPAWN: - //PohbeeSpawn(pohbee); + PohbeeDespawn(pohbee); break; default: @@ -210,117 +284,188 @@ void Obj_PohbeeThinker(mobj_t *pohbee) pohbee_mode(pohbee) = POHBEE_MODE_SPAWN; break; } + + laser = pohbee_lasers(pohbee); + while (laser != NULL && P_MobjWasRemoved(laser) == false) + { + ShrinkLaserThinker(laser); + laser = pohbee_lasers(laser); + } } -static void CreatePohbeeForPlayer(player_t *target, player_t *owner) +/* +void Obj_PohbeeRemoved(mobj_t *pohbee) +{ + mobj_t *chain = NULL; + + if (pohbee_laser(pohbee) != NULL) + { + P_RemoveMobj(pohbee_laser(pohbee)); + } + + chain = pohbee_chain(pohbee); + while (chain != NULL) + { + mobj_t *temp = chain; + chain = pohbee_chain(temp); + P_RemoveMobj(temp); + } +} +*/ + +static waypoint_t *GetPohbeeStart(waypoint_t *anchor) +{ + const UINT32 traveldist = FixedMul(POHBEE_DIST >> 1, mapobjectscale) / FRACUNIT; + const boolean useshortcuts = false; + const boolean huntbackwards = true; + boolean pathfindsuccess = false; + path_t pathtofinish = {0}; + waypoint_t *ret = NULL; + + pathfindsuccess = K_PathfindThruCircuit( + anchor, traveldist, + &pathtofinish, + useshortcuts, huntbackwards + ); + + if (pathfindsuccess == true) + { + ret = (waypoint_t *)pathtofinish.array[ pathtofinish.numnodes - 1 ].nodedata; + Z_Free(pathtofinish.array); + } + else + { + ret = anchor; + } + + return ret; +} + +static waypoint_t *GetPohbeeEnd(waypoint_t *anchor) { const UINT32 traveldist = FixedMul(POHBEE_DIST, mapobjectscale) / FRACUNIT; + const boolean useshortcuts = false; + const boolean huntbackwards = false; + boolean pathfindsuccess = false; + path_t pathtofinish = {0}; + waypoint_t *ret = NULL; + pathfindsuccess = K_PathfindThruCircuit( + anchor, traveldist, + &pathtofinish, + useshortcuts, huntbackwards + ); + + if (pathfindsuccess == true) + { + ret = (waypoint_t *)pathtofinish.array[ pathtofinish.numnodes - 1 ].nodedata; + Z_Free(pathtofinish.array); + } + else + { + ret = anchor; + } + + return ret; +} + +static void CreatePohbee(player_t *owner, waypoint_t *start, waypoint_t *end, UINT8 numLasers) +{ mobj_t *pohbee = NULL; - //mobj_t *laser = NULL; - waypoint_t *startWaypoint = NULL; - waypoint_t *endWaypoint = NULL; + fixed_t size = INT32_MAX; + INT32 baseSegs = INT32_MAX; + INT32 segVal = INT32_MAX; + mobj_t *prevLaser = NULL; - I_Assert(target != NULL); - I_Assert(owner != NULL); + size_t i, j; - if (target->mo == NULL || P_MobjWasRemoved(target->mo) == true) + if (owner == NULL || owner->mo == NULL || P_MobjWasRemoved(owner->mo) == true + || start == NULL || end == NULL + || numLasers == 0) { - // No object for the target. + // Invalid inputs return; } - // First, go backwards to find our starting point. + // Calculate number of chain segments added per laser. + size = end->mobj->radius / mapobjectscale; + baseSegs = 1 + (size / CHAIN_SIZE); + + if (baseSegs < MAXPLAYERS) { - const boolean useshortcuts = false; - const boolean huntbackwards = true; - boolean pathfindsuccess = false; - path_t pathtofinish = {0}; - - pathfindsuccess = K_PathfindThruCircuit( - target->nextwaypoint, traveldist, - &pathtofinish, - useshortcuts, huntbackwards - ); - - if (pathfindsuccess == true) - { - startWaypoint = (waypoint_t *)pathtofinish.array[ pathtofinish.numnodes - 1 ].nodedata; - Z_Free(pathtofinish.array); - } - else - { - startWaypoint = target->nextwaypoint; - } + baseSegs = MAXPLAYERS; } - // Now, go forwards to get our ending point. - { - const boolean useshortcuts = false; - const boolean huntbackwards = false; - boolean pathfindsuccess = false; - path_t pathtofinish = {0}; - - pathfindsuccess = K_PathfindThruCircuit( - target->nextwaypoint, traveldist * 2, - &pathtofinish, - useshortcuts, huntbackwards - ); - - if (pathfindsuccess == true) - { - endWaypoint = (waypoint_t *)pathtofinish.array[ pathtofinish.numnodes - 1 ].nodedata; - Z_Free(pathtofinish.array); - } - else - { - endWaypoint = target->nextwaypoint; - } - } - - // Try to repair an incomplete pair, just in case. - if (startWaypoint == NULL && endWaypoint != NULL) - { - startWaypoint = endWaypoint; - } - - if (endWaypoint == NULL && startWaypoint != NULL) - { - endWaypoint = startWaypoint; - } - - if (startWaypoint == NULL || endWaypoint == NULL) - { - // Unable to create shrink lasers - // due to invalid waypoint structure... - return; - } + segVal = baseSegs / numLasers; // Valid spawning conditions, // we can start creating each individual part. - pohbee = P_SpawnMobjFromMobj(startWaypoint->mobj, 0, 0, POHBEE_HOVER, MT_SHRINK_POHBEE); - + pohbee = P_SpawnMobjFromMobj(start->mobj, 0, 0, POHBEE_HOVER * 3, MT_SHRINK_POHBEE); P_SetTarget(&pohbee_owner(pohbee), owner->mo); pohbee_mode(pohbee) = POHBEE_MODE_SPAWN; + pohbee_timer(pohbee) = POHBEE_TIME; - pohbee_waypoint_cur(pohbee) = (INT32)K_GetWaypointHeapIndex(startWaypoint); - pohbee_waypoint_dest(pohbee) = (INT32)K_GetWaypointHeapIndex(endWaypoint); + pohbee_waypoint_cur(pohbee) = (INT32)K_GetWaypointHeapIndex(start); + pohbee_waypoint_dest(pohbee) = (INT32)K_GetWaypointHeapIndex(end); + + prevLaser = pohbee; + + for (i = 0; i < numLasers; i++) + { + const UINT8 numSegs = segVal * (i + 1); + + mobj_t *laser = P_SpawnMobjFromMobj(pohbee, 0, 0, 0, MT_SHRINK_LASER); + //mobj_t *collider = NULL; + //mobj_t *prevChain = NULL; + + P_SetTarget(&laser_pohbee(laser), pohbee); + P_SetTarget(&pohbee_lasers(prevLaser), laser); + + laser_numsegs(laser) = numSegs; + laser_swing(laser) = (ANGLE_45 * baseSeg) / numSegs; + laser_offset(laser) = P_RandomKey(LASER_SWINGTIME); + + /* + prevChain = laser; + for (j = 0; j < numSegs; j++) + { + mobj_t *chain = P_SpawnMobjFromMobj(laser, 0, 0, 0, MT_SHRINK_LASER); + P_SetTarget(&laser_chains(prevChain), chain); + prevChain = chain; + } + */ + (void)j; + + prevLaser = laser; + } } void Obj_CreateShrinkPohbees(player_t *owner) { UINT8 ownerPos = 1; - UINT8 i; - I_Assert(owner != NULL); + struct { + waypoint_t *start; + waypoint_t *end; + UINT8 lasers; + } pohbees[MAXPLAYERS]; + size_t numPohbees = 0; + + size_t i, j; + + if (owner == NULL || owner->mo == NULL || P_MobjWasRemoved(owner->mo) == true) + { + return; + } ownerPos = owner->position; for (i = 0; i < MAXPLAYERS; i++) { player_t *player = NULL; + waypoint_t *endWaypoint = NULL; if (playeringame[i] == false) { @@ -342,6 +487,37 @@ void Obj_CreateShrinkPohbees(player_t *owner) continue; } - CreatePohbeeForPlayer(player, owner); + if (player->nextwaypoint == NULL) + { + // No waypoint? + continue; + } + + endWaypoint = GetPohbeeEnd(player->nextwaypoint); + + for (j = 0; j < numPohbees; j++) + { + if (pohbees[j].end == endWaypoint) + { + // Increment laser count for the already existing poh-bee, + // if another one would occupy the same space. + pohbees[j].lasers++; + break; + } + } + + if (j == numPohbees) + { + // Push a new poh-bee + pohbees[j].start = GetPohbeeStart(player->nextwaypoint); + pohbees[j].end = endWaypoint; + pohbees[j].lasers = 4; + numPohbees++; + } + } + + for (i = 0; i < numPohbees; i++) + { + CreatePohbee(owner, pohbees[i].start, pohbees[i].end, pohbees[i].lasers); } } From 6aaa6082999e52c18fd937164516cee6c2bf6348 Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Sun, 11 Sep 2022 21:40:24 -0400 Subject: [PATCH 03/26] Playable Shrink --- src/deh_tables.c | 8 ++ src/info.c | 96 ++++++++++++++- src/info.h | 9 ++ src/k_kart.c | 2 +- src/k_kart.h | 1 + src/k_objects.h | 1 + src/objects/shrink.c | 272 +++++++++++++++++++++++++++++++++++-------- src/p_map.c | 46 ++++++++ 8 files changed, 379 insertions(+), 56 deletions(-) diff --git a/src/deh_tables.c b/src/deh_tables.c index 3c4e7fe1e..8b25029b6 100644 --- a/src/deh_tables.c +++ b/src/deh_tables.c @@ -3755,6 +3755,11 @@ const char *const STATE_LIST[] = { // array length left dynamic for sanity testi // Caked-Up Booty-Sheet Ghost "S_HYUDORO", + // Shrink + "S_SHRINK_GUN", + "S_SHRINK_LASER", + "S_SHRINK_PARTICLE", + // The legend "S_SINK", "S_SINK_SHIELD", @@ -5338,7 +5343,10 @@ const char *const MOBJTYPE_LIST[] = { // array length left dynamic for sanity t "MT_HYUDORO_CENTER", "MT_SHRINK_POHBEE", + "MT_SHRINK_GUN", + "MT_SHRINK_CHAIN", "MT_SHRINK_LASER", + "MT_SHRINK_PARTICLE", "MT_SINK", // Kitchen Sink Stuff "MT_SINK_SHIELD", diff --git a/src/info.c b/src/info.c index f067ee1f1..c2bd3c964 100644 --- a/src/info.c +++ b/src/info.c @@ -573,6 +573,7 @@ char sprnames[NUMSPRITES + 1][5] = "FLML", // Flame Shield speed lines "FLMF", // Flame Shield flash "HYUU", // Hyudoro + "SHRG", // Shrink gun / laser "SINK", // Kitchen Sink "SITR", // Kitchen Sink Trail "KBLN", // Battle Mode Bumper @@ -4314,6 +4315,10 @@ state_t states[NUMSTATES] = {SPR_HYUU, FF_FULLBRIGHT, -1, {NULL}, 0, 0, S_NULL}, // S_HYUDORO + {SPR_SHRG, 0, -1, {NULL}, 0, 0, S_NULL}, // S_SHRINK_GUN + {SPR_SHRG, FF_FULLBRIGHT|1, -1, {NULL}, 0, 0, S_NULL}, // S_SHRINK_LASER + {SPR_SHRG, FF_FULLBRIGHT|2, -1, {NULL}, 0, 0, S_NULL}, // S_SHRINK_PARTICLE + {SPR_SINK, 0, 1, {A_SmokeTrailer}, MT_SINKTRAIL, 0, S_SINK}, // S_SINK {SPR_SINK, 0|FF_TRANS80|FF_FULLBRIGHT, -1, {NULL}, 0, 0, S_SINK_SHIELD}, // S_SINK_SHIELD {SPR_SITR, 0, 1, {NULL}, 0, 0, S_SINKTRAIL2}, // S_SINKTRAIL1 @@ -24063,9 +24068,9 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = S_NULL // raisestate }, - { // MT_SHRINK_LASER + { // MT_SHRINK_GUN -1, // doomednum - S_HYUDORO, // spawnstate + S_SHRINK_GUN, // spawnstate 1000, // spawnhealth S_NULL, // seestate sfx_None, // seesound @@ -24080,13 +24085,94 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = S_NULL, // xdeathstate sfx_None, // deathsound 0, // speed - 32*FRACUNIT, // radius - 24*FRACUNIT, // height + 48*FRACUNIT, // radius + 120*FRACUNIT, // height 0, // display offset 0, // mass 0, // damage sfx_None, // activesound - MF_NOCLIP|MF_NOCLIPTHING|MF_NOCLIPHEIGHT|MF_NOGRAVITY|MF_DONTENCOREMAP, // flags + MF_SCENERY|MF_NOCLIPHEIGHT|MF_NOGRAVITY|MF_DONTENCOREMAP, // flags + S_NULL // raisestate + }, + + { // MT_SHRINK_CHAIN + -1, // doomednum + S_SHRINK_GUN, // spawnstate + 1000, // spawnhealth + S_NULL, // seestate + sfx_None, // seesound + 8, // reactiontime + sfx_None, // attacksound + S_NULL, // painstate + 0, // painchance + sfx_None, // painsound + S_NULL, // meleestate + S_NULL, // missilestate + S_NULL, // deathstate + S_NULL, // xdeathstate + sfx_None, // deathsound + 0, // speed + 16*FRACUNIT, // radius + 120*FRACUNIT, // height + 0, // display offset + 0, // mass + 0, // damage + sfx_None, // activesound + MF_NOTHINK|MF_NOCLIP|MF_NOCLIPTHING|MF_NOCLIPHEIGHT|MF_NOGRAVITY|MF_DONTENCOREMAP, // flags + S_NULL // raisestate + }, + + { // MT_SHRINK_LASER + -1, // doomednum + S_SHRINK_LASER, // spawnstate + 1000, // spawnhealth + S_NULL, // seestate + sfx_None, // seesound + 8, // reactiontime + sfx_None, // attacksound + S_NULL, // painstate + 0, // painchance + sfx_None, // painsound + S_NULL, // meleestate + S_NULL, // missilestate + S_NULL, // deathstate + S_NULL, // xdeathstate + sfx_None, // deathsound + 0, // speed + 16*FRACUNIT, // radius + 33*FRACUNIT, // height + 0, // display offset + 0, // mass + 0, // damage + sfx_None, // activesound + MF_SCENERY|MF_NOCLIP|MF_NOCLIPTHING|MF_NOCLIPHEIGHT|MF_NOGRAVITY|MF_DONTENCOREMAP, // flags + S_NULL // raisestate + }, + + { // MT_SHRINK_PARTICLE + -1, // doomednum + S_SHRINK_PARTICLE, // spawnstate + 1000, // spawnhealth + S_NULL, // seestate + sfx_None, // seesound + 8, // reactiontime + sfx_None, // attacksound + S_NULL, // painstate + 0, // painchance + sfx_None, // painsound + S_NULL, // meleestate + S_NULL, // missilestate + S_NULL, // deathstate + S_NULL, // xdeathstate + sfx_None, // deathsound + 0, // speed + 16*FRACUNIT, // radius + 16*FRACUNIT, // height + 0, // display offset + 0, // mass + 0, // damage + sfx_None, // activesound + MF_SCENERY|MF_NOCLIP|MF_NOCLIPTHING|MF_NOCLIPHEIGHT|MF_NOGRAVITY|MF_DONTENCOREMAP, // flags S_NULL // raisestate }, diff --git a/src/info.h b/src/info.h index 74771110e..0ff8f7f93 100644 --- a/src/info.h +++ b/src/info.h @@ -1119,6 +1119,7 @@ typedef enum sprite SPR_FLML, // Flame Shield speed lines SPR_FLMF, // Flame Shield flash SPR_HYUU, // Hyudoro + SPR_SHRG, // Shrink gun / laser SPR_SINK, // Kitchen Sink SPR_SITR, // Kitchen Sink Trail SPR_KBLN, // Battle Mode Bumper @@ -4745,6 +4746,11 @@ typedef enum state // Caked-Up Booty-Sheet Ghost S_HYUDORO, + // Shrink + S_SHRINK_GUN, + S_SHRINK_LASER, + S_SHRINK_PARTICLE, + // The legend S_SINK, S_SINK_SHIELD, @@ -6364,7 +6370,10 @@ typedef enum mobj_type MT_HYUDORO_CENTER, MT_SHRINK_POHBEE, + MT_SHRINK_GUN, + MT_SHRINK_CHAIN, MT_SHRINK_LASER, + MT_SHRINK_PARTICLE, MT_SINK, // Kitchen Sink Stuff MT_SINK_SHIELD, diff --git a/src/k_kart.c b/src/k_kart.c index b36009f68..f96f50182 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -3643,7 +3643,7 @@ void K_SpinPlayer(player_t *player, mobj_t *inflictor, mobj_t *source, INT32 typ P_SetPlayerMobjState(player->mo, S_KART_SPINOUT); } -static void K_RemoveGrowShrink(player_t *player) +void K_RemoveGrowShrink(player_t *player) { if (player->mo && !P_MobjWasRemoved(player->mo)) { diff --git a/src/k_kart.h b/src/k_kart.h index bab501200..4529b2611 100644 --- a/src/k_kart.h +++ b/src/k_kart.h @@ -71,6 +71,7 @@ void K_AwardPlayerRings(player_t *player, INT32 rings, boolean overload); void K_DoInstashield(player_t *player); void K_DoPowerClash(player_t *t1, player_t *t2); void K_BattleAwardHit(player_t *player, player_t *victim, mobj_t *inflictor, UINT8 bumpersRemoved); +void K_RemoveGrowShrink(player_t *player); void K_SpinPlayer(player_t *player, mobj_t *inflictor, mobj_t *source, INT32 type); void K_TumblePlayer(player_t *player, mobj_t *inflictor, mobj_t *source); void K_TumbleInterrupt(player_t *player); diff --git a/src/k_objects.h b/src/k_objects.h index d0b6f6b8b..45a487c5a 100644 --- a/src/k_objects.h +++ b/src/k_objects.h @@ -10,6 +10,7 @@ void Obj_HyudoroCollide(mobj_t *special, mobj_t *toucher); /* Shrink */ void Obj_PohbeeThinker(mobj_t *pohbee); +boolean Obj_ShrinkLaserCollide(mobj_t *gun, mobj_t *victim); void Obj_CreateShrinkPohbees(player_t *owner); #endif/*k_objects_H*/ diff --git a/src/objects/shrink.c b/src/objects/shrink.c index bde2fdb35..2ea94245f 100644 --- a/src/objects/shrink.c +++ b/src/objects/shrink.c @@ -23,13 +23,13 @@ #include "../z_zone.h" #include "../k_waypoint.h" -#define POHBEE_HOVER (384 << FRACBITS) +#define POHBEE_HOVER (256 << FRACBITS) #define POHBEE_SPEED (128 << FRACBITS) #define POHBEE_TIME (15 * TICRATE) #define POHBEE_DIST (4096 << FRACBITS) -#define LASER_SPEED (20 << FRACBITS) -#define LASER_SWINGTIME (3 * TICRATE) +#define GUN_SWING (ANGLE_90 - ANG10) +#define GUN_SWINGTIME (3 * TICRATE) #define CHAIN_SIZE (16) @@ -44,17 +44,61 @@ enum #define pohbee_timer(o) ((o)->reactiontime) #define pohbee_waypoint_cur(o) ((o)->extravalue1) #define pohbee_waypoint_dest(o) ((o)->extravalue2) +#define pohbee_height(o) ((o)->movefactor) #define pohbee_owner(o) ((o)->target) -#define pohbee_lasers(o) ((o)->hnext) +#define pohbee_guns(o) ((o)->hnext) -#define laser_offset(o) ((o)->movecount) -#define laser_swing(o) ((o)->movedir) -#define laser_numsegs(o) ((o)->extravalue1) +#define gun_offset(o) ((o)->movecount) +#define gun_numsegs(o) ((o)->extravalue1) -#define laser_pohbee(o) ((o)->target) -#define laser_collider(o) ((o)->tracer) -#define laser_chains(o) ((o)->hprev) +#define gun_pohbee(o) ((o)->target) +#define gun_laser(o) ((o)->tracer) +#define gun_chains(o) ((o)->hprev) + +enum +{ + LASER_SHRINK, + LASER_GROW, +}; + +static skincolornum_t ShrinkLaserColor(mobj_t *pohbee) +{ + UINT8 laserState = LASER_SHRINK; + player_t *owner = NULL; + + if (pohbee_owner(pohbee) != NULL && P_MobjWasRemoved(pohbee_owner(pohbee)) == false) + { + owner = pohbee_owner(pohbee)->player; + } + + if (owner != NULL && P_IsDisplayPlayer(owner) == true) + { + laserState = LASER_GROW; + + if (r_splitscreen > 0 && (leveltime & 1)) + { + // TODO: make this properly screen dependent, + // instead of flashing. + laserState = LASER_SHRINK; + } + } + + switch (laserState) + { + default: + case LASER_SHRINK: + return SKINCOLOR_KETCHUP; + + case LASER_GROW: + return SKINCOLOR_SAPPHIRE; + } +} + +static boolean ShrinkLaserActive(mobj_t *pohbee) +{ + return (pohbee_mode(pohbee) == POHBEE_MODE_ACT); +} static void PohbeeMoveTo(mobj_t *pohbee, fixed_t destx, fixed_t desty, fixed_t destz) { @@ -70,9 +114,9 @@ static fixed_t GenericDistance( return P_AproxDistance(P_AproxDistance(destx - curx, desty - cury), destz - curz); } -static fixed_t PohbeeWaypointZ(mobj_t *dest) +static fixed_t PohbeeWaypointZ(mobj_t *pohbee, mobj_t *dest) { - return dest->z + (FixedMul(POHBEE_HOVER, mapobjectscale) * P_MobjFlip(dest)); + return dest->z + (pohbee_height(pohbee) + FixedMul(POHBEE_HOVER, mapobjectscale) * P_MobjFlip(dest)); } static void PohbeeSpawn(mobj_t *pohbee) @@ -110,7 +154,7 @@ static void PohbeeSpawn(mobj_t *pohbee) { fixed_t wpX = curWaypoint->mobj->x; fixed_t wpY = curWaypoint->mobj->y; - fixed_t wpZ = PohbeeWaypointZ(curWaypoint->mobj); + fixed_t wpZ = PohbeeWaypointZ(pohbee, curWaypoint->mobj); fixed_t distToNext = GenericDistance( newX, newY, newZ, @@ -210,17 +254,16 @@ static void PohbeeDespawn(mobj_t *pohbee) pohbee->momz = 16 * pohbee->scale * P_MobjFlip(pohbee); } -static void DoLaserSwing(mobj_t *laser, mobj_t *pohbee) +static void DoGunSwing(mobj_t *gun, mobj_t *pohbee) { - const angle_t angle = laser->angle + ANGLE_90; - const tic_t swingTimer = leveltime + laser_offset(laser); + const angle_t angle = gun->angle + ANGLE_90; + const tic_t swingTimer = leveltime + gun_offset(gun); - const angle_t swingAmt = swingTimer * (ANGLE_MAX / LASER_SWINGTIME); + const angle_t swingAmt = swingTimer * (ANGLE_MAX / GUN_SWINGTIME); const fixed_t swingCos = FINECOSINE(swingAmt >> ANGLETOFINESHIFT); - const fixed_t swing = FixedMul(laser_swing(laser), 9 * swingCos); - const angle_t pitch = -ANGLE_90 + swing; - const fixed_t dist = laser_numsegs(laser) * CHAIN_SIZE * laser->scale; + const angle_t pitch = -ANGLE_90 + FixedMul(swingCos, GUN_SWING); + const fixed_t dist = gun_numsegs(gun) * CHAIN_SIZE * gun->scale; fixed_t offsetX = FixedMul( dist, FixedMul( @@ -240,28 +283,76 @@ static void DoLaserSwing(mobj_t *laser, mobj_t *pohbee) dist, FINESINE(pitch >> ANGLETOFINESHIFT) ); - PohbeeMoveTo(laser, pohbee->x + offsetX, pohbee->y + offsetY, pohbee->z + offsetZ); + PohbeeMoveTo(gun, pohbee->x + offsetX, pohbee->y + offsetY, pohbee->z + offsetZ); } -static void ShrinkLaserThinker(mobj_t *laser) +static void ShrinkLaserThinker(mobj_t *pohbee, mobj_t *gun, mobj_t *laser) { - mobj_t *pohbee = laser_pohbee(laser); + PohbeeMoveTo(laser, gun->x, gun->y, gun->floorz); + + if (ShrinkLaserActive(pohbee) == true) + { + mobj_t *particle = NULL; + + laser->renderflags &= ~RF_DONTDRAW; + laser->color = gun->color; + + if (leveltime & 1) + { + laser->spritexscale = 3*FRACUNIT/2; + } + else + { + laser->spritexscale = FRACUNIT; + } + + laser->spriteyscale = FixedDiv(FixedDiv(gun->z - gun->floorz, mapobjectscale), laser->info->height); + + particle = P_SpawnMobjFromMobj( + laser, + P_RandomRange(-16, 16) * FRACUNIT, + P_RandomRange(-16, 16) * FRACUNIT, + 0, + MT_SHRINK_PARTICLE + ); + + particle->color = laser->color; + + P_SetScale(particle, particle->scale * 2); + particle->destscale = 0; + + particle->momz = 2 * particle->scale * P_MobjFlip(particle); + } + else + { + laser->renderflags |= RF_DONTDRAW; + } +} + +static void ShrinkGunThinker(mobj_t *gun) +{ + mobj_t *pohbee = gun_pohbee(gun); if (pohbee == NULL || P_MobjWasRemoved(pohbee) == true) { - P_RemoveMobj(laser); + P_RemoveMobj(gun); return; } - laser->angle = pohbee->angle; - DoLaserSwing(laser, pohbee); + gun->angle = pohbee->angle; + gun->color = ShrinkLaserColor(pohbee); - //PohbeeMoveTo(laser_collider(laser), laser->x, laser->y, laser->z); + DoGunSwing(gun, pohbee); + + if (gun_laser(gun) != NULL && P_MobjWasRemoved(gun_laser(gun)) == false) + { + ShrinkLaserThinker(pohbee, gun, gun_laser(gun)); + } } void Obj_PohbeeThinker(mobj_t *pohbee) { - mobj_t *laser = NULL; + mobj_t *gun = NULL; pohbee->momx = pohbee->momy = pohbee->momz = 0; @@ -285,11 +376,11 @@ void Obj_PohbeeThinker(mobj_t *pohbee) break; } - laser = pohbee_lasers(pohbee); - while (laser != NULL && P_MobjWasRemoved(laser) == false) + gun = pohbee_guns(pohbee); + while (gun != NULL && P_MobjWasRemoved(gun) == false) { - ShrinkLaserThinker(laser); - laser = pohbee_lasers(laser); + ShrinkGunThinker(gun); + gun = pohbee_guns(gun); } } @@ -298,7 +389,7 @@ void Obj_PohbeeRemoved(mobj_t *pohbee) { mobj_t *chain = NULL; - if (pohbee_laser(pohbee) != NULL) + if (pohbee_guns(pohbee) != NULL) { P_RemoveMobj(pohbee_laser(pohbee)); } @@ -313,6 +404,84 @@ void Obj_PohbeeRemoved(mobj_t *pohbee) } */ +boolean Obj_ShrinkLaserCollide(mobj_t *gun, mobj_t *victim) +{ + mobj_t *pohbee = gun_pohbee(gun); + mobj_t *owner = NULL; + + if (pohbee == NULL || P_MobjWasRemoved(pohbee) == true) + { + return true; + } + + if (ShrinkLaserActive(pohbee) == false) + { + return true; + } + + owner = pohbee_owner(pohbee); + + if (owner != NULL && victim == owner) + { + // Belongs to us. Give us Grow! + if (victim->player->growshrinktimer <= 0) + { + victim->scalespeed = mapobjectscale/TICRATE; + victim->destscale = FixedMul(mapobjectscale, GROW_SCALE); + + if (K_PlayerShrinkCheat(victim->player) == true) + { + victim->destscale = FixedMul(victim->destscale, SHRINK_SCALE); + } + + // TODO: gametyperules + victim->player->growshrinktimer = (gametype == GT_BATTLE ? 8 : 12) * TICRATE; + + if (victim->player->invincibilitytimer > 0) + { + ; // invincibility has priority in P_RestoreMusic, no point in starting here + } + else if (P_IsLocalPlayer(victim->player) == true) + { + S_ChangeMusicSpecial("kgrow"); + } + else //used to be "if (P_IsDisplayPlayer(victim->player) == false)" + { + S_StartSound(victim, (cv_kartinvinsfx.value ? sfx_alarmg : sfx_kgrow)); + } + + P_RestoreMusic(victim->player); + S_StartSound(victim, sfx_kc5a); + } + } + else + { + if (victim->player->growshrinktimer > 0) + { + // Take away Grow. + K_RemoveGrowShrink(victim->player); + } + else + { + // Start shrinking! + K_DropItems(victim->player); + victim->player->growshrinktimer = -(15*TICRATE); + + victim->scalespeed = mapobjectscale/TICRATE; + victim->destscale = FixedMul(mapobjectscale, SHRINK_SCALE); + + if (K_PlayerShrinkCheat(victim->player) == true) + { + victim->destscale = FixedMul(victim->destscale, SHRINK_SCALE); + } + + S_StartSound(victim, sfx_kc59); + } + } + + return true; +} + static waypoint_t *GetPohbeeStart(waypoint_t *anchor) { const UINT32 traveldist = FixedMul(POHBEE_DIST >> 1, mapobjectscale) / FRACUNIT; @@ -373,10 +542,10 @@ static void CreatePohbee(player_t *owner, waypoint_t *start, waypoint_t *end, UI { mobj_t *pohbee = NULL; - fixed_t size = INT32_MAX; + fixed_t size = 0; INT32 baseSegs = INT32_MAX; INT32 segVal = INT32_MAX; - mobj_t *prevLaser = NULL; + mobj_t *prevGun = NULL; size_t i, j; @@ -389,8 +558,8 @@ static void CreatePohbee(player_t *owner, waypoint_t *start, waypoint_t *end, UI } // Calculate number of chain segments added per laser. - size = end->mobj->radius / mapobjectscale; - baseSegs = 1 + (size / CHAIN_SIZE); + size = FixedMul(end->mobj->radius, 3*FRACUNIT/2); + baseSegs = 1 + ((size / start->mobj->scale) / CHAIN_SIZE); if (baseSegs < MAXPLAYERS) { @@ -406,39 +575,42 @@ static void CreatePohbee(player_t *owner, waypoint_t *start, waypoint_t *end, UI pohbee_mode(pohbee) = POHBEE_MODE_SPAWN; pohbee_timer(pohbee) = POHBEE_TIME; + pohbee_height(pohbee) = size; pohbee_waypoint_cur(pohbee) = (INT32)K_GetWaypointHeapIndex(start); pohbee_waypoint_dest(pohbee) = (INT32)K_GetWaypointHeapIndex(end); - prevLaser = pohbee; + prevGun = pohbee; for (i = 0; i < numLasers; i++) { const UINT8 numSegs = segVal * (i + 1); - mobj_t *laser = P_SpawnMobjFromMobj(pohbee, 0, 0, 0, MT_SHRINK_LASER); - //mobj_t *collider = NULL; + mobj_t *gun = P_SpawnMobjFromMobj(pohbee, 0, 0, 0, MT_SHRINK_GUN); + mobj_t *laser = NULL; //mobj_t *prevChain = NULL; - P_SetTarget(&laser_pohbee(laser), pohbee); - P_SetTarget(&pohbee_lasers(prevLaser), laser); + P_SetTarget(&gun_pohbee(gun), pohbee); + P_SetTarget(&pohbee_guns(prevGun), gun); - laser_numsegs(laser) = numSegs; - laser_swing(laser) = (ANGLE_45 * baseSeg) / numSegs; - laser_offset(laser) = P_RandomKey(LASER_SWINGTIME); + gun_numsegs(gun) = numSegs; + gun_offset(gun) = P_RandomKey(GUN_SWINGTIME); + + laser = P_SpawnMobjFromMobj(gun, 0, 0, 0, MT_SHRINK_LASER); + P_SetTarget(&gun_laser(gun), laser); /* - prevChain = laser; + prevChain = gun; for (j = 0; j < numSegs; j++) { - mobj_t *chain = P_SpawnMobjFromMobj(laser, 0, 0, 0, MT_SHRINK_LASER); - P_SetTarget(&laser_chains(prevChain), chain); + mobj_t *chain = P_SpawnMobjFromMobj(gun, 0, 0, 0, MT_SHRINK_CHAIN); + P_SetTarget(&gun_chains(prevChain), chain); prevChain = chain; } */ (void)j; - prevLaser = laser; + prevGun = gun; } } @@ -511,7 +683,7 @@ void Obj_CreateShrinkPohbees(player_t *owner) // Push a new poh-bee pohbees[j].start = GetPohbeeStart(player->nextwaypoint); pohbees[j].end = endWaypoint; - pohbees[j].lasers = 4; + pohbees[j].lasers = 1; numPohbees++; } } diff --git a/src/p_map.c b/src/p_map.c index ad970ee45..5c9b98ef2 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -32,6 +32,7 @@ #include "hu_stuff.h" // SRB2kart #include "i_system.h" // SRB2kart #include "k_terrain.h" +#include "k_objects.h" #include "r_splats.h" @@ -739,6 +740,51 @@ static BlockItReturn_t PIT_CheckThing(mobj_t *thing) // SRB2kart 011617 - Colission[sic] code for kart items //{ + if (thing->type == MT_SHRINK_GUN) + { + if (tmthing->type != MT_PLAYER) + { + return BMIT_CONTINUE; + } + + // Use special collision for the laser gun. + // The laser sprite itself is just a visual, + // the gun itself does the colliding for us. + if (tmthing->z > thing->z) + { + return BMIT_CONTINUE; // overhead + } + + if (tmthing->z + tmthing->height < thing->floorz) + { + return BMIT_CONTINUE; // underneath + } + + return Obj_ShrinkLaserCollide(thing, tmthing) ? BMIT_CONTINUE : BMIT_ABORT; + } + else if (tmthing->type == MT_SHRINK_GUN) + { + if (thing->type != MT_PLAYER) + { + return BMIT_CONTINUE; + } + + // Use special collision for the laser gun. + // The laser sprite itself is just a visual, + // the gun itself does the colliding for us. + if (thing->z > tmthing->z) + { + return BMIT_CONTINUE; // overhead + } + + if (thing->z + thing->height < tmthing->floorz) + { + return BMIT_CONTINUE; // underneath + } + + return Obj_ShrinkLaserCollide(tmthing, thing) ? BMIT_CONTINUE : BMIT_ABORT; + } + if (tmthing->type == MT_SMK_ICEBLOCK) { // see if it went over / under From e1cf42dcbdcfeaf5f7e31ec3f307c8c3d17042f6 Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Sun, 11 Sep 2022 21:48:30 -0400 Subject: [PATCH 04/26] Increase Shrink odds --- src/k_kart.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index f96f50182..6c1241a7d 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -355,7 +355,7 @@ static INT32 K_KartItemOddsRace[NUMKARTRESULTS-1][8] = //P-Odds 0 1 2 3 4 5 6 7 /*Sneaker*/ { 0, 0, 2, 4, 6, 0, 0, 0 }, // Sneaker /*Rocket Sneaker*/ { 0, 0, 0, 0, 0, 2, 4, 6 }, // Rocket Sneaker - /*Invincibility*/ { 0, 0, 0, 0, 3, 4, 6, 9 }, // Invincibility + /*Invincibility*/ { 0, 0, 0, 0, 3, 4, 5, 7 }, // Invincibility /*Banana*/ { 2, 3, 1, 0, 0, 0, 0, 0 }, // Banana /*Eggman Monitor*/ { 1, 2, 0, 0, 0, 0, 0, 0 }, // Eggman Monitor /*Orbinaut*/ { 5, 5, 2, 2, 0, 0, 0, 0 }, // Orbinaut @@ -365,7 +365,7 @@ static INT32 K_KartItemOddsRace[NUMKARTRESULTS-1][8] = /*Ballhog*/ { 0, 0, 2, 2, 0, 0, 0, 0 }, // Ballhog /*Self-Propelled Bomb*/ { 0, 0, 0, 0, 0, 2, 4, 0 }, // Self-Propelled Bomb /*Grow*/ { 0, 0, 0, 1, 2, 3, 0, 0 }, // Grow - /*Shrink*/ { 0, 0, 0, 0, 0, 0, 2, 0 }, // Shrink + /*Shrink*/ { 0, 0, 0, 0, 0, 0, 4, 2 }, // Shrink /*Lightning Shield*/ { 1, 0, 0, 0, 0, 0, 0, 0 }, // Lightning Shield /*Bubble Shield*/ { 0, 1, 2, 1, 0, 0, 0, 0 }, // Bubble Shield /*Flame Shield*/ { 0, 0, 0, 0, 0, 1, 3, 5 }, // Flame Shield @@ -375,7 +375,7 @@ static INT32 K_KartItemOddsRace[NUMKARTRESULTS-1][8] = /*Kitchen Sink*/ { 0, 0, 0, 0, 0, 0, 0, 0 }, // Kitchen Sink /*Drop Target*/ { 3, 0, 0, 0, 0, 0, 0, 0 }, // Drop Target /*Sneaker x2*/ { 0, 0, 2, 2, 2, 0, 0, 0 }, // Sneaker x2 - /*Sneaker x3*/ { 0, 0, 0, 1, 6,10, 5, 0 }, // Sneaker x3 + /*Sneaker x3*/ { 0, 0, 0, 1, 6,10, 4, 0 }, // Sneaker x3 /*Banana x3*/ { 0, 1, 1, 0, 0, 0, 0, 0 }, // Banana x3 /*Banana x10*/ { 0, 0, 0, 1, 0, 0, 0, 0 }, // Banana x10 /*Orbinaut x3*/ { 0, 0, 1, 0, 0, 0, 0, 0 }, // Orbinaut x3 From 892863db05d2822f4fa9cc13cc0e6cfb85fbc59f Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Sun, 11 Sep 2022 21:52:53 -0400 Subject: [PATCH 05/26] Add bot support to new Shrink They move towards lasers that belong to them, and steer away from ones that don't. --- src/k_botsearch.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/k_botsearch.c b/src/k_botsearch.c index af7464c30..74a458bce 100644 --- a/src/k_botsearch.c +++ b/src/k_botsearch.c @@ -425,6 +425,16 @@ static BlockItReturn_t K_FindObjectsForNudging(mobj_t *thing) case MT_BUBBLESHIELDTRAP: K_AddDodgeObject(thing, side, 20); break; + case MT_SHRINK_GUN: + if (thing->target == globalsmuggle.botmo) + { + K_AddAttackObject(thing, side, 20); + } + else + { + K_AddDodgeObject(thing, side, 20); + } + break; case MT_RANDOMITEM: if (anglediff >= 45) { From b8bbdda1f350001e1d8d46d5de9038aa95ed6281 Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Sun, 11 Sep 2022 23:31:53 -0400 Subject: [PATCH 06/26] Improvements from the netgame - Double active time - Increase height they spawn from - Slow down swing speed the tiniest bit - Add an extra 7 for first place - Increase hitbox - Make particles into hitbox - Tweak item odds --- src/info.c | 8 +++--- src/k_kart.c | 4 +-- src/objects/shrink.c | 30 +++++++++++++++++--- src/p_map.c | 66 ++++++++++++++++++++++++++++++++------------ 4 files changed, 80 insertions(+), 28 deletions(-) diff --git a/src/info.c b/src/info.c index c2bd3c964..56892d9c9 100644 --- a/src/info.c +++ b/src/info.c @@ -24085,7 +24085,7 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = S_NULL, // xdeathstate sfx_None, // deathsound 0, // speed - 48*FRACUNIT, // radius + 52*FRACUNIT, // radius 120*FRACUNIT, // height 0, // display offset 0, // mass @@ -24166,13 +24166,13 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = S_NULL, // xdeathstate sfx_None, // deathsound 0, // speed - 16*FRACUNIT, // radius - 16*FRACUNIT, // height + 26*FRACUNIT, // radius + 26*FRACUNIT, // height 0, // display offset 0, // mass 0, // damage sfx_None, // activesound - MF_SCENERY|MF_NOCLIP|MF_NOCLIPTHING|MF_NOCLIPHEIGHT|MF_NOGRAVITY|MF_DONTENCOREMAP, // flags + MF_NOCLIPHEIGHT|MF_NOGRAVITY|MF_DONTENCOREMAP, // flags S_NULL // raisestate }, diff --git a/src/k_kart.c b/src/k_kart.c index 6c1241a7d..61a32bd76 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -365,7 +365,7 @@ static INT32 K_KartItemOddsRace[NUMKARTRESULTS-1][8] = /*Ballhog*/ { 0, 0, 2, 2, 0, 0, 0, 0 }, // Ballhog /*Self-Propelled Bomb*/ { 0, 0, 0, 0, 0, 2, 4, 0 }, // Self-Propelled Bomb /*Grow*/ { 0, 0, 0, 1, 2, 3, 0, 0 }, // Grow - /*Shrink*/ { 0, 0, 0, 0, 0, 0, 4, 2 }, // Shrink + /*Shrink*/ { 0, 0, 0, 0, 0, 2, 4, 2 }, // Shrink /*Lightning Shield*/ { 1, 0, 0, 0, 0, 0, 0, 0 }, // Lightning Shield /*Bubble Shield*/ { 0, 1, 2, 1, 0, 0, 0, 0 }, // Bubble Shield /*Flame Shield*/ { 0, 0, 0, 0, 0, 1, 3, 5 }, // Flame Shield @@ -375,7 +375,7 @@ static INT32 K_KartItemOddsRace[NUMKARTRESULTS-1][8] = /*Kitchen Sink*/ { 0, 0, 0, 0, 0, 0, 0, 0 }, // Kitchen Sink /*Drop Target*/ { 3, 0, 0, 0, 0, 0, 0, 0 }, // Drop Target /*Sneaker x2*/ { 0, 0, 2, 2, 2, 0, 0, 0 }, // Sneaker x2 - /*Sneaker x3*/ { 0, 0, 0, 1, 6,10, 4, 0 }, // Sneaker x3 + /*Sneaker x3*/ { 0, 0, 0, 1, 6, 8, 4, 0 }, // Sneaker x3 /*Banana x3*/ { 0, 1, 1, 0, 0, 0, 0, 0 }, // Banana x3 /*Banana x10*/ { 0, 0, 0, 1, 0, 0, 0, 0 }, // Banana x10 /*Orbinaut x3*/ { 0, 0, 1, 0, 0, 0, 0, 0 }, // Orbinaut x3 diff --git a/src/objects/shrink.c b/src/objects/shrink.c index 2ea94245f..6f8cb92a1 100644 --- a/src/objects/shrink.c +++ b/src/objects/shrink.c @@ -25,14 +25,16 @@ #define POHBEE_HOVER (256 << FRACBITS) #define POHBEE_SPEED (128 << FRACBITS) -#define POHBEE_TIME (15 * TICRATE) +#define POHBEE_TIME (30 * TICRATE) #define POHBEE_DIST (4096 << FRACBITS) #define GUN_SWING (ANGLE_90 - ANG10) -#define GUN_SWINGTIME (3 * TICRATE) +#define GUN_SWINGTIME (4 * TICRATE) #define CHAIN_SIZE (16) +#define EXTRA_FOR_FIRST (7) + enum { POHBEE_MODE_SPAWN, @@ -321,7 +323,7 @@ static void ShrinkLaserThinker(mobj_t *pohbee, mobj_t *gun, mobj_t *laser) P_SetScale(particle, particle->scale * 2); particle->destscale = 0; - particle->momz = 2 * particle->scale * P_MobjFlip(particle); + //particle->momz = 2 * particle->scale * P_MobjFlip(particle); } else { @@ -570,7 +572,7 @@ static void CreatePohbee(player_t *owner, waypoint_t *start, waypoint_t *end, UI // Valid spawning conditions, // we can start creating each individual part. - pohbee = P_SpawnMobjFromMobj(start->mobj, 0, 0, POHBEE_HOVER * 3, MT_SHRINK_POHBEE); + pohbee = P_SpawnMobjFromMobj(start->mobj, 0, 0, FixedDiv(size, mapobjectscale) + POHBEE_HOVER * 3, MT_SHRINK_POHBEE); P_SetTarget(&pohbee_owner(pohbee), owner->mo); pohbee_mode(pohbee) = POHBEE_MODE_SPAWN; @@ -622,6 +624,7 @@ void Obj_CreateShrinkPohbees(player_t *owner) waypoint_t *start; waypoint_t *end; UINT8 lasers; + boolean first; } pohbees[MAXPLAYERS]; size_t numPohbees = 0; @@ -684,6 +687,12 @@ void Obj_CreateShrinkPohbees(player_t *owner) pohbees[j].start = GetPohbeeStart(player->nextwaypoint); pohbees[j].end = endWaypoint; pohbees[j].lasers = 1; + + if (player->position == 1) + { + pohbees[j].first = true; + } + numPohbees++; } } @@ -691,5 +700,18 @@ void Obj_CreateShrinkPohbees(player_t *owner) for (i = 0; i < numPohbees; i++) { CreatePohbee(owner, pohbees[i].start, pohbees[i].end, pohbees[i].lasers); + + if (pohbees[i].first == true) + { + // Add a chain of extra ones for 1st place. + waypoint_t *prev = pohbees[i].end; + + for (j = 0; j < EXTRA_FOR_FIRST; j++) + { + waypoint_t *new = GetPohbeeEnd(pohbees[i].end); + CreatePohbee(owner, prev, new, 1); + prev = new; + } + } } } diff --git a/src/p_map.c b/src/p_map.c index 5c9b98ef2..0c490ce41 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -740,46 +740,76 @@ static BlockItReturn_t PIT_CheckThing(mobj_t *thing) // SRB2kart 011617 - Colission[sic] code for kart items //{ - if (thing->type == MT_SHRINK_GUN) + if (thing->type == MT_SHRINK_GUN || thing->type == MT_SHRINK_PARTICLE) { if (tmthing->type != MT_PLAYER) { return BMIT_CONTINUE; } - // Use special collision for the laser gun. - // The laser sprite itself is just a visual, - // the gun itself does the colliding for us. - if (tmthing->z > thing->z) + if (thing->type == MT_SHRINK_GUN) { - return BMIT_CONTINUE; // overhead - } + // Use special collision for the laser gun. + // The laser sprite itself is just a visual, + // the gun itself does the colliding for us. + if (tmthing->z > thing->z) + { + return BMIT_CONTINUE; // overhead + } - if (tmthing->z + tmthing->height < thing->floorz) + if (tmthing->z + tmthing->height < thing->floorz) + { + return BMIT_CONTINUE; // underneath + } + } + else { - return BMIT_CONTINUE; // underneath + if (tmthing->z > thing->z + thing->height) + { + return BMIT_CONTINUE; // overhead + } + + if (tmthing->z + tmthing->height < thing->z) + { + return BMIT_CONTINUE; // underneath + } } return Obj_ShrinkLaserCollide(thing, tmthing) ? BMIT_CONTINUE : BMIT_ABORT; } - else if (tmthing->type == MT_SHRINK_GUN) + else if (tmthing->type == MT_SHRINK_GUN || tmthing->type == MT_SHRINK_PARTICLE) { if (thing->type != MT_PLAYER) { return BMIT_CONTINUE; } - // Use special collision for the laser gun. - // The laser sprite itself is just a visual, - // the gun itself does the colliding for us. - if (thing->z > tmthing->z) + if (thing->type == MT_SHRINK_GUN) { - return BMIT_CONTINUE; // overhead - } + // Use special collision for the laser gun. + // The laser sprite itself is just a visual, + // the gun itself does the colliding for us. + if (thing->z > tmthing->z) + { + return BMIT_CONTINUE; // overhead + } - if (thing->z + thing->height < tmthing->floorz) + if (thing->z + thing->height < tmthing->floorz) + { + return BMIT_CONTINUE; // underneath + } + } + else { - return BMIT_CONTINUE; // underneath + if (tmthing->z > thing->z + thing->height) + { + return BMIT_CONTINUE; // overhead + } + + if (tmthing->z + tmthing->height < thing->z) + { + return BMIT_CONTINUE; // underneath + } } return Obj_ShrinkLaserCollide(tmthing, thing) ? BMIT_CONTINUE : BMIT_ABORT; From 135b444b5eddf1123b0e7c6740eabe9876ceb4bc Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Mon, 12 Sep 2022 00:06:04 -0400 Subject: [PATCH 07/26] Fix bad shrink position --- src/objects/shrink.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/objects/shrink.c b/src/objects/shrink.c index 6f8cb92a1..4053d8248 100644 --- a/src/objects/shrink.c +++ b/src/objects/shrink.c @@ -708,7 +708,7 @@ void Obj_CreateShrinkPohbees(player_t *owner) for (j = 0; j < EXTRA_FOR_FIRST; j++) { - waypoint_t *new = GetPohbeeEnd(pohbees[i].end); + waypoint_t *new = GetPohbeeEnd(prev); CreatePohbee(owner, prev, new, 1); prev = new; } From 27fdb815b93d28b751f143658ea1058a8035eaac Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Mon, 12 Sep 2022 00:06:48 -0400 Subject: [PATCH 08/26] Give solid to gun & particles Fixes hitboxes for the gun, IDK why particle isn't working. Also fix typo error --- src/info.c | 4 ++-- src/p_map.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/info.c b/src/info.c index 56892d9c9..e011e7874 100644 --- a/src/info.c +++ b/src/info.c @@ -24091,7 +24091,7 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = 0, // mass 0, // damage sfx_None, // activesound - MF_SCENERY|MF_NOCLIPHEIGHT|MF_NOGRAVITY|MF_DONTENCOREMAP, // flags + MF_SOLID|MF_NOCLIPHEIGHT|MF_NOGRAVITY|MF_DONTENCOREMAP, // flags S_NULL // raisestate }, @@ -24172,7 +24172,7 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = 0, // mass 0, // damage sfx_None, // activesound - MF_NOCLIPHEIGHT|MF_NOGRAVITY|MF_DONTENCOREMAP, // flags + MF_SOLID|MF_NOCLIPHEIGHT|MF_NOGRAVITY|MF_DONTENCOREMAP, // flags S_NULL // raisestate }, diff --git a/src/p_map.c b/src/p_map.c index 0c490ce41..e00cbea1c 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -784,7 +784,7 @@ static BlockItReturn_t PIT_CheckThing(mobj_t *thing) return BMIT_CONTINUE; } - if (thing->type == MT_SHRINK_GUN) + if (tmthing->type == MT_SHRINK_GUN) { // Use special collision for the laser gun. // The laser sprite itself is just a visual, From 07f2932d3ac681a0063a533895d82c77beac9fd3 Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Mon, 12 Sep 2022 00:18:35 -0400 Subject: [PATCH 09/26] Set owner of particle --- src/info.c | 4 ++-- src/objects/shrink.c | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/info.c b/src/info.c index e011e7874..0b390cf0a 100644 --- a/src/info.c +++ b/src/info.c @@ -24091,7 +24091,7 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = 0, // mass 0, // damage sfx_None, // activesound - MF_SOLID|MF_NOCLIPHEIGHT|MF_NOGRAVITY|MF_DONTENCOREMAP, // flags + MF_SPECIAL|MF_NOCLIPHEIGHT|MF_NOGRAVITY|MF_DONTENCOREMAP, // flags S_NULL // raisestate }, @@ -24172,7 +24172,7 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = 0, // mass 0, // damage sfx_None, // activesound - MF_SOLID|MF_NOCLIPHEIGHT|MF_NOGRAVITY|MF_DONTENCOREMAP, // flags + MF_SPECIAL|MF_NOCLIPHEIGHT|MF_NOGRAVITY|MF_DONTENCOREMAP, // flags S_NULL // raisestate }, diff --git a/src/objects/shrink.c b/src/objects/shrink.c index 4053d8248..019f2db2a 100644 --- a/src/objects/shrink.c +++ b/src/objects/shrink.c @@ -318,6 +318,8 @@ static void ShrinkLaserThinker(mobj_t *pohbee, mobj_t *gun, mobj_t *laser) MT_SHRINK_PARTICLE ); + P_SetTarget(&gun_pohbee(particle), pohbee); + particle->color = laser->color; P_SetScale(particle, particle->scale * 2); From 970add8b91f43f2ebb21ccd14b090cbdac9d56d1 Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Wed, 14 Sep 2022 02:47:42 -0400 Subject: [PATCH 10/26] Add grow/shrink particles --- src/deh_tables.c | 5 +++++ src/info.c | 30 ++++++++++++++++++++++++++ src/info.h | 6 ++++++ src/k_kart.c | 56 ++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 97 insertions(+) diff --git a/src/deh_tables.c b/src/deh_tables.c index 8b25029b6..8a2713bad 100644 --- a/src/deh_tables.c +++ b/src/deh_tables.c @@ -3755,6 +3755,9 @@ const char *const STATE_LIST[] = { // array length left dynamic for sanity testi // Caked-Up Booty-Sheet Ghost "S_HYUDORO", + // Grow + "S_GROW_PARTICLE", + // Shrink "S_SHRINK_GUN", "S_SHRINK_LASER", @@ -5342,6 +5345,8 @@ const char *const MOBJTYPE_LIST[] = { // array length left dynamic for sanity t "MT_HYUDORO", "MT_HYUDORO_CENTER", + "MT_GROW_PARTICLE", + "MT_SHRINK_POHBEE", "MT_SHRINK_GUN", "MT_SHRINK_CHAIN", diff --git a/src/info.c b/src/info.c index 0b390cf0a..7f1840092 100644 --- a/src/info.c +++ b/src/info.c @@ -573,6 +573,7 @@ char sprnames[NUMSPRITES + 1][5] = "FLML", // Flame Shield speed lines "FLMF", // Flame Shield flash "HYUU", // Hyudoro + "GRWP", // Grow "SHRG", // Shrink gun / laser "SINK", // Kitchen Sink "SITR", // Kitchen Sink Trail @@ -4315,6 +4316,8 @@ state_t states[NUMSTATES] = {SPR_HYUU, FF_FULLBRIGHT, -1, {NULL}, 0, 0, S_NULL}, // S_HYUDORO + {SPR_GRWP, FF_ADD|FF_FULLBRIGHT|FF_ANIMATE, 13, {NULL}, 7, 1, S_NULL}, // S_GROW_PARTICLE + {SPR_SHRG, 0, -1, {NULL}, 0, 0, S_NULL}, // S_SHRINK_GUN {SPR_SHRG, FF_FULLBRIGHT|1, -1, {NULL}, 0, 0, S_NULL}, // S_SHRINK_LASER {SPR_SHRG, FF_FULLBRIGHT|2, -1, {NULL}, 0, 0, S_NULL}, // S_SHRINK_PARTICLE @@ -24041,6 +24044,33 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = S_NULL // raisestate }, + { // MT_GROW_PARTICLE + -1, // doomednum + S_GROW_PARTICLE, // spawnstate + 1000, // spawnhealth + S_NULL, // seestate + sfx_None, // seesound + 8, // reactiontime + sfx_None, // attacksound + S_NULL, // painstate + 0, // painchance + sfx_None, // painsound + S_NULL, // meleestate + S_NULL, // missilestate + S_NULL, // deathstate + S_NULL, // xdeathstate + sfx_None, // deathsound + 0, // speed + 4*FRACUNIT, // radius + 8*FRACUNIT, // height + 0, // display offset + 0, // mass + 0, // damage + sfx_None, // activesound + MF_SCENERY|MF_NOCLIP|MF_NOCLIPTHING|MF_NOCLIPHEIGHT|MF_NOGRAVITY|MF_DONTENCOREMAP, // flags + S_NULL // raisestate + }, + { // MT_SHRINK_POHBEE -1, // doomednum S_HYUDORO, // spawnstate diff --git a/src/info.h b/src/info.h index 0ff8f7f93..ca7264dba 100644 --- a/src/info.h +++ b/src/info.h @@ -1119,6 +1119,7 @@ typedef enum sprite SPR_FLML, // Flame Shield speed lines SPR_FLMF, // Flame Shield flash SPR_HYUU, // Hyudoro + SPR_GRWP, // Grow SPR_SHRG, // Shrink gun / laser SPR_SINK, // Kitchen Sink SPR_SITR, // Kitchen Sink Trail @@ -4746,6 +4747,9 @@ typedef enum state // Caked-Up Booty-Sheet Ghost S_HYUDORO, + // Grow + S_GROW_PARTICLE, + // Shrink S_SHRINK_GUN, S_SHRINK_LASER, @@ -6369,6 +6373,8 @@ typedef enum mobj_type MT_HYUDORO, MT_HYUDORO_CENTER, + MT_GROW_PARTICLE, + MT_SHRINK_POHBEE, MT_SHRINK_GUN, MT_SHRINK_CHAIN, diff --git a/src/k_kart.c b/src/k_kart.c index 3b9de17da..19a2dc3e6 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -2284,6 +2284,57 @@ void K_SpawnInvincibilitySpeedLines(mobj_t *mo) fast->destscale = 6*((mo->player->invincibilitytimer/TICRATE)*FRACUNIT)/8; } +static void K_SpawnGrowShrinkParticles(mobj_t *mo, INT32 timer) +{ + const boolean shrink = (timer < 0); + const INT32 maxTime = (10*TICRATE); + INT32 spawnFreq = 1; + + mobj_t *particle = NULL; + fixed_t particleSpeed = 0; + + spawnFreq = (maxTime - min(maxTime, abs(timer))) / TICRATE / 2; + if (spawnFreq == 0) + { + spawnFreq++; + } + + if (leveltime % spawnFreq != 0) + { + return; + } + + particle = P_SpawnMobjFromMobj( + mo, + P_RandomRange(-32, 32) * FRACUNIT, + P_RandomRange(-32, 32) * FRACUNIT, + (shrink ? P_RandomRange(24, 48) : P_RandomRange(0, 24)) * FRACUNIT, + MT_GROW_PARTICLE + ); + + P_SetTarget(&particle->target, mo); + + particle->momx = mo->momx; + particle->momy = mo->momy; + particle->momz = P_GetMobjZMovement(mo); + + K_MatchGenericExtraFlags(particle, mo); + + particleSpeed = particle->scale * 4 * P_MobjFlip(mo); + + if (shrink == true) + { + particle->color = SKINCOLOR_KETCHUP; + particle->momz -= particleSpeed; + particle->renderflags |= RF_VERTICALFLIP; + } + else + { + particle->color = SKINCOLOR_SAPPHIRE; + particle->momz += particleSpeed; + } +} + void K_SpawnBumpEffect(mobj_t *mo) { mobj_t *fx = P_SpawnMobj(mo->x, mo->y, mo->z, MT_BUMP); @@ -7325,6 +7376,11 @@ void K_KartPlayerThink(player_t *player, ticcmd_t *cmd) } } + if (player->growshrinktimer != 0) + { + K_SpawnGrowShrinkParticles(player->mo, player->growshrinktimer); + } + if (gametype == GT_RACE && player->rings <= 0) // spawn ring debt indicator { mobj_t *debtflag = P_SpawnMobj(player->mo->x + player->mo->momx, player->mo->y + player->mo->momy, From a4b63f3ffae6be99429f8250249d88db8dc4f9e2 Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Wed, 14 Sep 2022 03:15:03 -0400 Subject: [PATCH 11/26] Make shrink lasers add timer instead of resetting --- src/d_player.h | 2 + src/k_kart.c | 5 ++- src/objects/shrink.c | 96 ++++++++++++++++++++++++++------------------ src/p_saveg.c | 4 ++ 4 files changed, 68 insertions(+), 39 deletions(-) diff --git a/src/d_player.h b/src/d_player.h index 91989279c..5675dfb5e 100644 --- a/src/d_player.h +++ b/src/d_player.h @@ -584,6 +584,8 @@ typedef struct player_s UINT8 stairjank; + UINT8 shrinkLaserDelay; + #ifdef HWRENDER fixed_t fovadd; // adjust FOV for hw rendering #endif diff --git a/src/k_kart.c b/src/k_kart.c index 19a2dc3e6..cef0a644e 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -7545,6 +7545,9 @@ void K_KartPlayerThink(player_t *player, ticcmd_t *cmd) comebackshowninfo = true; // client has already seen the message } + if (player->shrinkLaserDelay) + player->shrinkLaserDelay--; + if (player->ringdelay) player->ringdelay--; @@ -10041,7 +10044,7 @@ void K_MoveKartPlayer(player_t *player, boolean onground) } // TODO: gametyperules - player->growshrinktimer = (gametype == GT_BATTLE ? 8 : 12) * TICRATE; + player->growshrinktimer = max(player->growshrinktimer, (gametype == GT_BATTLE ? 8 : 12) * TICRATE); if (player->invincibilitytimer > 0) { diff --git a/src/objects/shrink.c b/src/objects/shrink.c index 019f2db2a..a4717fb17 100644 --- a/src/objects/shrink.c +++ b/src/objects/shrink.c @@ -412,6 +412,7 @@ boolean Obj_ShrinkLaserCollide(mobj_t *gun, mobj_t *victim) { mobj_t *pohbee = gun_pohbee(gun); mobj_t *owner = NULL; + INT32 prevTimer = 0; if (pohbee == NULL || P_MobjWasRemoved(pohbee) == true) { @@ -423,44 +424,60 @@ boolean Obj_ShrinkLaserCollide(mobj_t *gun, mobj_t *victim) return true; } + if (victim->player->shrinkLaserDelay > 0) + { + victim->player->shrinkLaserDelay = TICRATE; + return true; + } + + victim->player->shrinkLaserDelay = TICRATE; + owner = pohbee_owner(pohbee); + prevTimer = victim->player->growshrinktimer; if (owner != NULL && victim == owner) { // Belongs to us. Give us Grow! - if (victim->player->growshrinktimer <= 0) + if (prevTimer < 0) { - victim->scalespeed = mapobjectscale/TICRATE; - victim->destscale = FixedMul(mapobjectscale, GROW_SCALE); - - if (K_PlayerShrinkCheat(victim->player) == true) - { - victim->destscale = FixedMul(victim->destscale, SHRINK_SCALE); - } - - // TODO: gametyperules - victim->player->growshrinktimer = (gametype == GT_BATTLE ? 8 : 12) * TICRATE; - - if (victim->player->invincibilitytimer > 0) - { - ; // invincibility has priority in P_RestoreMusic, no point in starting here - } - else if (P_IsLocalPlayer(victim->player) == true) - { - S_ChangeMusicSpecial("kgrow"); - } - else //used to be "if (P_IsDisplayPlayer(victim->player) == false)" - { - S_StartSound(victim, (cv_kartinvinsfx.value ? sfx_alarmg : sfx_kgrow)); - } - - P_RestoreMusic(victim->player); + // Take away Shrink. + K_RemoveGrowShrink(victim->player); + } + else + { + victim->player->growshrinktimer += 5*TICRATE; S_StartSound(victim, sfx_kc5a); + + if (prevTimer <= 0) + { + victim->scalespeed = mapobjectscale/TICRATE; + victim->destscale = FixedMul(mapobjectscale, GROW_SCALE); + + if (K_PlayerShrinkCheat(victim->player) == true) + { + victim->destscale = FixedMul(victim->destscale, SHRINK_SCALE); + } + + if (victim->player->invincibilitytimer > 0) + { + ; // invincibility has priority in P_RestoreMusic, no point in starting here + } + else if (P_IsLocalPlayer(victim->player) == true) + { + S_ChangeMusicSpecial("kgrow"); + } + else //used to be "if (P_IsDisplayPlayer(victim->player) == false)" + { + S_StartSound(victim, (cv_kartinvinsfx.value ? sfx_alarmg : sfx_kgrow)); + } + + P_RestoreMusic(victim->player); + } } } else { - if (victim->player->growshrinktimer > 0) + if (prevTimer > 0) { // Take away Grow. K_RemoveGrowShrink(victim->player); @@ -468,18 +485,21 @@ boolean Obj_ShrinkLaserCollide(mobj_t *gun, mobj_t *victim) else { // Start shrinking! - K_DropItems(victim->player); - victim->player->growshrinktimer = -(15*TICRATE); - - victim->scalespeed = mapobjectscale/TICRATE; - victim->destscale = FixedMul(mapobjectscale, SHRINK_SCALE); - - if (K_PlayerShrinkCheat(victim->player) == true) - { - victim->destscale = FixedMul(victim->destscale, SHRINK_SCALE); - } - + victim->player->growshrinktimer -= 5*TICRATE; S_StartSound(victim, sfx_kc59); + + if (prevTimer >= 0) + { + K_DropItems(victim->player); + + victim->scalespeed = mapobjectscale/TICRATE; + victim->destscale = FixedMul(mapobjectscale, SHRINK_SCALE); + + if (K_PlayerShrinkCheat(victim->player) == true) + { + victim->destscale = FixedMul(victim->destscale, SHRINK_SCALE); + } + } } } diff --git a/src/p_saveg.c b/src/p_saveg.c index f35ddc305..e1a75248d 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -367,6 +367,8 @@ static void P_NetArchivePlayers(void) WRITEUINT8(save_p, players[i].stairjank); + WRITEUINT8(save_p, players[i].shrinkLaserDelay); + // respawnvars_t WRITEUINT8(save_p, players[i].respawn.state); WRITEUINT32(save_p, K_GetWaypointHeapIndex(players[i].respawn.wp)); @@ -654,6 +656,8 @@ static void P_NetUnArchivePlayers(void) players[i].stairjank = READUINT8(save_p); + players[i].shrinkLaserDelay = READUINT8(save_p); + // respawnvars_t players[i].respawn.state = READUINT8(save_p); players[i].respawn.wp = (waypoint_t *)(size_t)READUINT32(save_p); From c65e5af718d8901da58c55adfc356634627a4af2 Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Wed, 14 Sep 2022 19:15:42 -0400 Subject: [PATCH 12/26] Reduce grow add from lasers --- src/objects/shrink.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/objects/shrink.c b/src/objects/shrink.c index a4717fb17..4595417a7 100644 --- a/src/objects/shrink.c +++ b/src/objects/shrink.c @@ -445,7 +445,7 @@ boolean Obj_ShrinkLaserCollide(mobj_t *gun, mobj_t *victim) } else { - victim->player->growshrinktimer += 5*TICRATE; + victim->player->growshrinktimer += 3*TICRATE; S_StartSound(victim, sfx_kc5a); if (prevTimer <= 0) From cee2c25e274a5eceb12b63a51e948e84a069f486 Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Wed, 14 Sep 2022 19:17:45 -0400 Subject: [PATCH 13/26] Don't drop items from Shrink --- src/objects/shrink.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/objects/shrink.c b/src/objects/shrink.c index 4595417a7..c76f3b0d3 100644 --- a/src/objects/shrink.c +++ b/src/objects/shrink.c @@ -490,7 +490,7 @@ boolean Obj_ShrinkLaserCollide(mobj_t *gun, mobj_t *victim) if (prevTimer >= 0) { - K_DropItems(victim->player); + //K_DropItems(victim->player); victim->scalespeed = mapobjectscale/TICRATE; victim->destscale = FixedMul(mapobjectscale, SHRINK_SCALE); From 72948ad49d37bbbedc6de7eaad8004fb772f2665 Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Wed, 14 Sep 2022 23:50:48 -0400 Subject: [PATCH 14/26] Make timer more obvious on grow particles --- src/info.c | 6 +++--- src/k_kart.c | 17 ++++++++++++++++- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/src/info.c b/src/info.c index 7f1840092..4da0d27e1 100644 --- a/src/info.c +++ b/src/info.c @@ -4316,7 +4316,7 @@ state_t states[NUMSTATES] = {SPR_HYUU, FF_FULLBRIGHT, -1, {NULL}, 0, 0, S_NULL}, // S_HYUDORO - {SPR_GRWP, FF_ADD|FF_FULLBRIGHT|FF_ANIMATE, 13, {NULL}, 7, 1, S_NULL}, // S_GROW_PARTICLE + {SPR_GRWP, FF_FULLBRIGHT|FF_ANIMATE, 13, {NULL}, 7, 1, S_NULL}, // S_GROW_PARTICLE {SPR_SHRG, 0, -1, {NULL}, 0, 0, S_NULL}, // S_SHRINK_GUN {SPR_SHRG, FF_FULLBRIGHT|1, -1, {NULL}, 0, 0, S_NULL}, // S_SHRINK_LASER @@ -24121,7 +24121,7 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = 0, // mass 0, // damage sfx_None, // activesound - MF_SPECIAL|MF_NOCLIPHEIGHT|MF_NOGRAVITY|MF_DONTENCOREMAP, // flags + MF_SPECIAL|MF_NOCLIP|MF_NOCLIPHEIGHT|MF_NOGRAVITY|MF_DONTENCOREMAP, // flags S_NULL // raisestate }, @@ -24202,7 +24202,7 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = 0, // mass 0, // damage sfx_None, // activesound - MF_SPECIAL|MF_NOCLIPHEIGHT|MF_NOGRAVITY|MF_DONTENCOREMAP, // flags + MF_SPECIAL|MF_NOCLIP|MF_NOCLIPHEIGHT|MF_NOGRAVITY|MF_DONTENCOREMAP, // flags S_NULL // raisestate }, diff --git a/src/k_kart.c b/src/k_kart.c index cef0a644e..de17e614a 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -2288,12 +2288,27 @@ static void K_SpawnGrowShrinkParticles(mobj_t *mo, INT32 timer) { const boolean shrink = (timer < 0); const INT32 maxTime = (10*TICRATE); + const INT32 noTime = (2*TICRATE); INT32 spawnFreq = 1; mobj_t *particle = NULL; fixed_t particleSpeed = 0; - spawnFreq = (maxTime - min(maxTime, abs(timer))) / TICRATE / 2; + spawnFreq = abs(timer); + + if (spawnFreq < noTime) + { + return; + } + + spawnFreq -= noTime; + + if (spawnFreq > maxTime) + { + spawnFreq = maxTime; + } + + spawnFreq = (maxTime - spawnFreq) / TICRATE / 4; if (spawnFreq == 0) { spawnFreq++; From 71723a803db90c9c723ff65dd73206350a0176e5 Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Thu, 15 Sep 2022 01:03:08 -0400 Subject: [PATCH 15/26] Implement pohbee chain Crashes when drawing the sprites after looking at it for like half a second and idk why tf --- src/deh_tables.c | 1 + src/info.c | 10 ++++++---- src/info.h | 2 ++ src/objects/shrink.c | 42 +++++++++++++++++++++++++++++++++++++----- 4 files changed, 46 insertions(+), 9 deletions(-) diff --git a/src/deh_tables.c b/src/deh_tables.c index 8a2713bad..5fe950e9e 100644 --- a/src/deh_tables.c +++ b/src/deh_tables.c @@ -3760,6 +3760,7 @@ const char *const STATE_LIST[] = { // array length left dynamic for sanity testi // Shrink "S_SHRINK_GUN", + "S_SHRINK_CHAIN", "S_SHRINK_LASER", "S_SHRINK_PARTICLE", diff --git a/src/info.c b/src/info.c index 4da0d27e1..186f04022 100644 --- a/src/info.c +++ b/src/info.c @@ -574,6 +574,7 @@ char sprnames[NUMSPRITES + 1][5] = "FLMF", // Flame Shield flash "HYUU", // Hyudoro "GRWP", // Grow + "POHB", // Shrink Poh-Bee "SHRG", // Shrink gun / laser "SINK", // Kitchen Sink "SITR", // Kitchen Sink Trail @@ -4319,6 +4320,7 @@ state_t states[NUMSTATES] = {SPR_GRWP, FF_FULLBRIGHT|FF_ANIMATE, 13, {NULL}, 7, 1, S_NULL}, // S_GROW_PARTICLE {SPR_SHRG, 0, -1, {NULL}, 0, 0, S_NULL}, // S_SHRINK_GUN + {SPR_POHB, 0, -1, {NULL}, 0, 0, S_NULL}, // S_SHRINK_CHAIN {SPR_SHRG, FF_FULLBRIGHT|1, -1, {NULL}, 0, 0, S_NULL}, // S_SHRINK_LASER {SPR_SHRG, FF_FULLBRIGHT|2, -1, {NULL}, 0, 0, S_NULL}, // S_SHRINK_PARTICLE @@ -24127,7 +24129,7 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = { // MT_SHRINK_CHAIN -1, // doomednum - S_SHRINK_GUN, // spawnstate + S_SHRINK_CHAIN, // spawnstate 1000, // spawnhealth S_NULL, // seestate sfx_None, // seesound @@ -24142,13 +24144,13 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = S_NULL, // xdeathstate sfx_None, // deathsound 0, // speed - 16*FRACUNIT, // radius - 120*FRACUNIT, // height + 26*FRACUNIT, // radius + 26*FRACUNIT, // height 0, // display offset 0, // mass 0, // damage sfx_None, // activesound - MF_NOTHINK|MF_NOCLIP|MF_NOCLIPTHING|MF_NOCLIPHEIGHT|MF_NOGRAVITY|MF_DONTENCOREMAP, // flags + MF_SCENERY|MF_NOCLIP|MF_NOCLIPTHING|MF_NOCLIPHEIGHT|MF_NOGRAVITY|MF_DONTENCOREMAP, // flags S_NULL // raisestate }, diff --git a/src/info.h b/src/info.h index ca7264dba..8acf73ba8 100644 --- a/src/info.h +++ b/src/info.h @@ -1120,6 +1120,7 @@ typedef enum sprite SPR_FLMF, // Flame Shield flash SPR_HYUU, // Hyudoro SPR_GRWP, // Grow + SPR_POHB, // Shrink Poh-Bee SPR_SHRG, // Shrink gun / laser SPR_SINK, // Kitchen Sink SPR_SITR, // Kitchen Sink Trail @@ -4752,6 +4753,7 @@ typedef enum state // Shrink S_SHRINK_GUN, + S_SHRINK_CHAIN, S_SHRINK_LASER, S_SHRINK_PARTICLE, diff --git a/src/objects/shrink.c b/src/objects/shrink.c index c76f3b0d3..2272c2909 100644 --- a/src/objects/shrink.c +++ b/src/objects/shrink.c @@ -31,7 +31,7 @@ #define GUN_SWING (ANGLE_90 - ANG10) #define GUN_SWINGTIME (4 * TICRATE) -#define CHAIN_SIZE (16) +#define CHAIN_SIZE (52) #define EXTRA_FOR_FIRST (7) @@ -58,6 +58,8 @@ enum #define gun_laser(o) ((o)->tracer) #define gun_chains(o) ((o)->hprev) +#define chain_index(o) ((o)->extravalue1) + enum { LASER_SHRINK, @@ -333,6 +335,34 @@ static void ShrinkLaserThinker(mobj_t *pohbee, mobj_t *gun, mobj_t *laser) } } +static void DoGunChains(mobj_t *gun, mobj_t *pohbee) +{ + const fixed_t gunZ = P_GetMobjHead(gun); + const fixed_t beeZ = P_GetMobjFeet(pohbee); + + const fixed_t offsetX = (pohbee->x - gun->x) / gun_numsegs(gun); + const fixed_t offsetY = (pohbee->y - gun->y) / gun_numsegs(gun); + const fixed_t offsetZ = (beeZ - gunZ) / gun_numsegs(gun); + + mobj_t *chain = NULL; + + fixed_t curX = gun->x + (offsetX / 2); + fixed_t curY = gun->y + (offsetY / 2); + fixed_t curZ = gunZ + (offsetZ / 2); + + chain = gun_chains(gun); + while (chain != NULL && P_MobjWasRemoved(chain) == false) + { + PohbeeMoveTo(chain, curX, curY, curZ); + + curX += offsetX; + curY += offsetY; + curZ += offsetZ; + + chain = gun_chains(chain); + } +} + static void ShrinkGunThinker(mobj_t *gun) { mobj_t *pohbee = gun_pohbee(gun); @@ -352,6 +382,8 @@ static void ShrinkGunThinker(mobj_t *gun) { ShrinkLaserThinker(pohbee, gun, gun_laser(gun)); } + + DoGunChains(gun, pohbee); } void Obj_PohbeeThinker(mobj_t *pohbee) @@ -612,7 +644,7 @@ static void CreatePohbee(player_t *owner, waypoint_t *start, waypoint_t *end, UI mobj_t *gun = P_SpawnMobjFromMobj(pohbee, 0, 0, 0, MT_SHRINK_GUN); mobj_t *laser = NULL; - //mobj_t *prevChain = NULL; + mobj_t *prevChain = NULL; P_SetTarget(&gun_pohbee(gun), pohbee); P_SetTarget(&pohbee_guns(prevGun), gun); @@ -623,16 +655,16 @@ static void CreatePohbee(player_t *owner, waypoint_t *start, waypoint_t *end, UI laser = P_SpawnMobjFromMobj(gun, 0, 0, 0, MT_SHRINK_LASER); P_SetTarget(&gun_laser(gun), laser); - /* prevChain = gun; for (j = 0; j < numSegs; j++) { mobj_t *chain = P_SpawnMobjFromMobj(gun, 0, 0, 0, MT_SHRINK_CHAIN); + P_SetTarget(&gun_chains(prevChain), chain); + chain_index(chain) = j; + prevChain = chain; } - */ - (void)j; prevGun = gun; } From e2e984ec145031c3998d9ec787efde626d95bced Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Thu, 15 Sep 2022 01:54:19 -0400 Subject: [PATCH 16/26] More consistent chain length --- src/objects/shrink.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/src/objects/shrink.c b/src/objects/shrink.c index 2272c2909..3120b1540 100644 --- a/src/objects/shrink.c +++ b/src/objects/shrink.c @@ -615,18 +615,12 @@ static void CreatePohbee(player_t *owner, waypoint_t *start, waypoint_t *end, UI // Calculate number of chain segments added per laser. size = FixedMul(end->mobj->radius, 3*FRACUNIT/2); - baseSegs = 1 + ((size / start->mobj->scale) / CHAIN_SIZE); - - if (baseSegs < MAXPLAYERS) - { - baseSegs = MAXPLAYERS; - } - - segVal = baseSegs / numLasers; + segVal = max(1, 1 + ((size / start->mobj->scale) / CHAIN_SIZE) / numLasers); + baseSegs = segVal * numLasers; // Valid spawning conditions, // we can start creating each individual part. - pohbee = P_SpawnMobjFromMobj(start->mobj, 0, 0, FixedDiv(size, mapobjectscale) + POHBEE_HOVER * 3, MT_SHRINK_POHBEE); + pohbee = P_SpawnMobjFromMobj(start->mobj, 0, 0, (baseSegs * CHAIN_SIZE * FRACUNIT) + POHBEE_HOVER * 3, MT_SHRINK_POHBEE); P_SetTarget(&pohbee_owner(pohbee), owner->mo); pohbee_mode(pohbee) = POHBEE_MODE_SPAWN; From dc44196c49ffa59845ac8f711b331cfc4c8ab423 Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Thu, 15 Sep 2022 02:27:20 -0400 Subject: [PATCH 17/26] Bigger laser shimmer --- src/objects/shrink.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/objects/shrink.c b/src/objects/shrink.c index 3120b1540..841875fc8 100644 --- a/src/objects/shrink.c +++ b/src/objects/shrink.c @@ -303,7 +303,7 @@ static void ShrinkLaserThinker(mobj_t *pohbee, mobj_t *gun, mobj_t *laser) if (leveltime & 1) { - laser->spritexscale = 3*FRACUNIT/2; + laser->spritexscale = 5*FRACUNIT/2; } else { From b1f9dd8264bf69679101c212e4987f8c3983065c Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Thu, 15 Sep 2022 02:42:16 -0400 Subject: [PATCH 18/26] Line up the laser visual better --- src/objects/shrink.c | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/src/objects/shrink.c b/src/objects/shrink.c index 841875fc8..8fcf1eb58 100644 --- a/src/objects/shrink.c +++ b/src/objects/shrink.c @@ -292,7 +292,11 @@ static void DoGunSwing(mobj_t *gun, mobj_t *pohbee) static void ShrinkLaserThinker(mobj_t *pohbee, mobj_t *gun, mobj_t *laser) { - PohbeeMoveTo(laser, gun->x, gun->y, gun->floorz); + const fixed_t gunX = gun->x + gun->momx; + const fixed_t gunY = gun->y + gun->momy; + const fixed_t gunZ = P_GetMobjFeet(gun) + gun->momz; + + PohbeeMoveTo(laser, gunX, gunY, gun->floorz); if (ShrinkLaserActive(pohbee) == true) { @@ -310,7 +314,7 @@ static void ShrinkLaserThinker(mobj_t *pohbee, mobj_t *gun, mobj_t *laser) laser->spritexscale = FRACUNIT; } - laser->spriteyscale = FixedDiv(FixedDiv(gun->z - gun->floorz, mapobjectscale), laser->info->height); + laser->spriteyscale = FixedDiv(FixedDiv(gunZ - gun->floorz, mapobjectscale), laser->info->height); particle = P_SpawnMobjFromMobj( laser, @@ -337,17 +341,22 @@ static void ShrinkLaserThinker(mobj_t *pohbee, mobj_t *gun, mobj_t *laser) static void DoGunChains(mobj_t *gun, mobj_t *pohbee) { - const fixed_t gunZ = P_GetMobjHead(gun); - const fixed_t beeZ = P_GetMobjFeet(pohbee); + const fixed_t gunX = gun->x + gun->momx; + const fixed_t gunY = gun->y + gun->momy; + const fixed_t gunZ = P_GetMobjHead(gun) + gun->momz; - const fixed_t offsetX = (pohbee->x - gun->x) / gun_numsegs(gun); - const fixed_t offsetY = (pohbee->y - gun->y) / gun_numsegs(gun); + const fixed_t beeX = pohbee->x + pohbee->momx; + const fixed_t beeY = pohbee->y + pohbee->momy; + const fixed_t beeZ = P_GetMobjFeet(pohbee) + pohbee->momz; + + const fixed_t offsetX = (beeX - gunX) / gun_numsegs(gun); + const fixed_t offsetY = (beeY - gunY) / gun_numsegs(gun); const fixed_t offsetZ = (beeZ - gunZ) / gun_numsegs(gun); mobj_t *chain = NULL; - fixed_t curX = gun->x + (offsetX / 2); - fixed_t curY = gun->y + (offsetY / 2); + fixed_t curX = gunX + (offsetX / 2); + fixed_t curY = gunY + (offsetY / 2); fixed_t curZ = gunZ + (offsetZ / 2); chain = gun_chains(gun); From 3950a228c0998bd6d279c242adb2cb9c29b8b4d6 Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Thu, 15 Sep 2022 02:51:53 -0400 Subject: [PATCH 19/26] Lower shrink odds slightly --- src/k_kart.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index de17e614a..3978fe3cd 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -365,7 +365,7 @@ static INT32 K_KartItemOddsRace[NUMKARTRESULTS-1][8] = /*Ballhog*/ { 0, 0, 2, 2, 0, 0, 0, 0 }, // Ballhog /*Self-Propelled Bomb*/ { 0, 0, 0, 0, 0, 2, 4, 0 }, // Self-Propelled Bomb /*Grow*/ { 0, 0, 0, 1, 2, 3, 0, 0 }, // Grow - /*Shrink*/ { 0, 0, 0, 0, 0, 2, 4, 2 }, // Shrink + /*Shrink*/ { 0, 0, 0, 0, 0, 1, 3, 2 }, // Shrink /*Lightning Shield*/ { 1, 0, 0, 0, 0, 0, 0, 0 }, // Lightning Shield /*Bubble Shield*/ { 0, 1, 2, 1, 0, 0, 0, 0 }, // Bubble Shield /*Flame Shield*/ { 0, 0, 0, 0, 0, 1, 3, 5 }, // Flame Shield @@ -375,7 +375,7 @@ static INT32 K_KartItemOddsRace[NUMKARTRESULTS-1][8] = /*Kitchen Sink*/ { 0, 0, 0, 0, 0, 0, 0, 0 }, // Kitchen Sink /*Drop Target*/ { 3, 0, 0, 0, 0, 0, 0, 0 }, // Drop Target /*Sneaker x2*/ { 0, 0, 2, 2, 2, 0, 0, 0 }, // Sneaker x2 - /*Sneaker x3*/ { 0, 0, 0, 1, 6, 8, 4, 0 }, // Sneaker x3 + /*Sneaker x3*/ { 0, 0, 0, 1, 6, 9, 5, 0 }, // Sneaker x3 /*Banana x3*/ { 0, 1, 1, 0, 0, 0, 0, 0 }, // Banana x3 /*Banana x10*/ { 0, 0, 0, 1, 0, 0, 0, 0 }, // Banana x10 /*Orbinaut x3*/ { 0, 0, 1, 0, 0, 0, 0, 0 }, // Orbinaut x3 From 04323fc39e61bcb58c60891574c14c585faa7770 Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Thu, 15 Sep 2022 03:19:57 -0400 Subject: [PATCH 20/26] Adjust Grow/Shrink camera with scale again --- src/p_user.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/src/p_user.c b/src/p_user.c index 78d20a794..299d42a4b 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -3044,6 +3044,10 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall subsector_t *newsubsec; #endif + fixed_t playerScale = FixedDiv(player->mo->scale, mapobjectscale); + fixed_t scaleDiff = playerScale - FRACUNIT; + fixed_t cameraScale = mapobjectscale; + thiscam->old_x = thiscam->x; thiscam->old_y = thiscam->y; thiscam->old_z = thiscam->z; @@ -3132,8 +3136,11 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall return true; } - thiscam->radius = 20*mapobjectscale; - thiscam->height = 16*mapobjectscale; + // Adjust camera to match Grow/Shrink + cameraScale = FixedMul(cameraScale, FRACUNIT + (scaleDiff / 3)); + + thiscam->radius = 20*cameraScale; + thiscam->height = 16*cameraScale; // Don't run while respawning from a starpost // Inu 4/8/13 Why not?! @@ -3159,8 +3166,8 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall camspeed = cv_cam_speed[num].value; camstill = cv_cam_still[num].value; camrotate = cv_cam_rotate[num].value; - camdist = FixedMul(cv_cam_dist[num].value, mapobjectscale); - camheight = FixedMul(cv_cam_height[num].value, mapobjectscale); + camdist = FixedMul(cv_cam_dist[num].value, cameraScale); + camheight = FixedMul(cv_cam_height[num].value, cameraScale); if (timeover) { @@ -3171,8 +3178,8 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall { const INT32 introcam = (introtime - leveltime); camrotate += introcam*5; - camdist += (introcam * mapobjectscale)*3; - camheight += (introcam * mapobjectscale)*2; + camdist += (introcam * cameraScale)*3; + camheight += (introcam * cameraScale)*2; } else if (player->exiting) // SRB2Kart: Leave the camera behind while exiting, for dramatic effect! camstill = true; @@ -3236,7 +3243,7 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall // sets ideal cam pos { - const fixed_t speedthreshold = 48*mapobjectscale; + const fixed_t speedthreshold = 48*cameraScale; const fixed_t olddist = P_AproxDistance(mo->x - thiscam->x, mo->y - thiscam->y); fixed_t lag, distoffset; @@ -3541,7 +3548,7 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall // point viewed by the camera // this point is just 64 unit forward the player - dist = 64*mapobjectscale; + dist = 64*cameraScale; viewpointx = mo->x + FixedMul(FINECOSINE((angle>>ANGLETOFINESHIFT) & FINEMASK), dist) + xpan; viewpointy = mo->y + FixedMul(FINESINE((angle>>ANGLETOFINESHIFT) & FINEMASK), dist) + ypan; From c80f46f7c79a9c390e08f18531b53a045a68e6be Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Thu, 15 Sep 2022 19:52:35 -0400 Subject: [PATCH 21/26] Reduce code duplication --- src/objects/shrink.c | 35 +++++++++++------------------------ 1 file changed, 11 insertions(+), 24 deletions(-) diff --git a/src/objects/shrink.c b/src/objects/shrink.c index 8fcf1eb58..bc99420be 100644 --- a/src/objects/shrink.c +++ b/src/objects/shrink.c @@ -547,11 +547,9 @@ boolean Obj_ShrinkLaserCollide(mobj_t *gun, mobj_t *victim) return true; } -static waypoint_t *GetPohbeeStart(waypoint_t *anchor) +static waypoint_t *GetPohbeeWaypoint(waypoint_t *anchor, const UINT32 traveldist, const boolean huntbackwards) { - const UINT32 traveldist = FixedMul(POHBEE_DIST >> 1, mapobjectscale) / FRACUNIT; const boolean useshortcuts = false; - const boolean huntbackwards = true; boolean pathfindsuccess = false; path_t pathtofinish = {0}; waypoint_t *ret = NULL; @@ -573,34 +571,23 @@ static waypoint_t *GetPohbeeStart(waypoint_t *anchor) } return ret; + +} + +static waypoint_t *GetPohbeeStart(waypoint_t *anchor) +{ + const UINT32 traveldist = FixedMul(POHBEE_DIST >> 1, mapobjectscale) / FRACUNIT; + const boolean huntbackwards = true; + + return GetPohbeeWaypoint(anchor, traveldist, huntbackwards); } static waypoint_t *GetPohbeeEnd(waypoint_t *anchor) { const UINT32 traveldist = FixedMul(POHBEE_DIST, mapobjectscale) / FRACUNIT; - const boolean useshortcuts = false; const boolean huntbackwards = false; - boolean pathfindsuccess = false; - path_t pathtofinish = {0}; - waypoint_t *ret = NULL; - pathfindsuccess = K_PathfindThruCircuit( - anchor, traveldist, - &pathtofinish, - useshortcuts, huntbackwards - ); - - if (pathfindsuccess == true) - { - ret = (waypoint_t *)pathtofinish.array[ pathtofinish.numnodes - 1 ].nodedata; - Z_Free(pathtofinish.array); - } - else - { - ret = anchor; - } - - return ret; + return GetPohbeeWaypoint(anchor, traveldist, huntbackwards); } static void CreatePohbee(player_t *owner, waypoint_t *start, waypoint_t *end, UINT8 numLasers) From eda9e0cd9d9845ce00b8b922f476f2b6763e8792 Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Thu, 15 Sep 2022 19:54:50 -0400 Subject: [PATCH 22/26] Offset for shrink particles --- src/k_kart.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/k_kart.c b/src/k_kart.c index 3978fe3cd..fb068f4f2 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -2323,7 +2323,7 @@ static void K_SpawnGrowShrinkParticles(mobj_t *mo, INT32 timer) mo, P_RandomRange(-32, 32) * FRACUNIT, P_RandomRange(-32, 32) * FRACUNIT, - (shrink ? P_RandomRange(24, 48) : P_RandomRange(0, 24)) * FRACUNIT, + P_RandomRange(0, 24) + (shrink ? 24 : 0) * FRACUNIT, MT_GROW_PARTICLE ); From cb2d2cb2ba27b60f20e4455bb9a94fedc612a90d Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Thu, 15 Sep 2022 20:03:32 -0400 Subject: [PATCH 23/26] Cleanup objects properly --- src/k_objects.h | 2 ++ src/objects/shrink.c | 28 +++++++++++++++++++--------- src/p_mobj.c | 10 ++++++++++ 3 files changed, 31 insertions(+), 9 deletions(-) diff --git a/src/k_objects.h b/src/k_objects.h index 45a487c5a..cc80d2555 100644 --- a/src/k_objects.h +++ b/src/k_objects.h @@ -10,6 +10,8 @@ void Obj_HyudoroCollide(mobj_t *special, mobj_t *toucher); /* Shrink */ void Obj_PohbeeThinker(mobj_t *pohbee); +void Obj_PohbeeRemoved(mobj_t *pohbee); +void Obj_ShrinkGunRemoved(mobj_t *gun); boolean Obj_ShrinkLaserCollide(mobj_t *gun, mobj_t *victim); void Obj_CreateShrinkPohbees(player_t *owner); diff --git a/src/objects/shrink.c b/src/objects/shrink.c index bc99420be..a37c93ac3 100644 --- a/src/objects/shrink.c +++ b/src/objects/shrink.c @@ -429,25 +429,35 @@ void Obj_PohbeeThinker(mobj_t *pohbee) } } -/* void Obj_PohbeeRemoved(mobj_t *pohbee) +{ + mobj_t *gun = pohbee_guns(pohbee); + + while (gun != NULL && P_MobjWasRemoved(gun) == false) + { + mobj_t *nextGun = pohbee_guns(gun); + P_RemoveMobj(gun); + gun = nextGun; + } +} + +void Obj_ShrinkGunRemoved(mobj_t *gun) { mobj_t *chain = NULL; - if (pohbee_guns(pohbee) != NULL) + if (gun_laser(gun) != NULL && P_MobjWasRemoved(gun_laser(gun)) == false) { - P_RemoveMobj(pohbee_laser(pohbee)); + P_RemoveMobj(gun_laser(gun)); } - chain = pohbee_chain(pohbee); - while (chain != NULL) + chain = gun_chains(gun); + while (chain != NULL && P_MobjWasRemoved(chain) == false) { - mobj_t *temp = chain; - chain = pohbee_chain(temp); - P_RemoveMobj(temp); + mobj_t *nextChain = gun_chains(chain); + P_RemoveMobj(chain); + chain = nextChain; } } -*/ boolean Obj_ShrinkLaserCollide(mobj_t *gun, mobj_t *victim) { diff --git a/src/p_mobj.c b/src/p_mobj.c index a86d1af4e..0505d6bda 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -10656,6 +10656,16 @@ void P_RemoveMobj(mobj_t *mobj) P_SetTarget(&mobj->player->followmobj, NULL); } + if (mobj->type == MT_SHRINK_POHBEE) + { + Obj_PohbeeRemoved(mobj); + } + + if (mobj->type == MT_SHRINK_GUN) + { + Obj_ShrinkGunRemoved(mobj); + } + mobj->health = 0; // Just because // unlink from sector and block lists From 94c64519d4eb319589c5a0a5c51d10bcc0804a2c Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Thu, 15 Sep 2022 21:44:08 -0400 Subject: [PATCH 24/26] Make grow/shrink particles closer to base scale --- src/k_kart.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index fb068f4f2..edefc6895 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -2292,6 +2292,7 @@ static void K_SpawnGrowShrinkParticles(mobj_t *mo, INT32 timer) INT32 spawnFreq = 1; mobj_t *particle = NULL; + fixed_t particleScale = FRACUNIT; fixed_t particleSpeed = 0; spawnFreq = abs(timer); @@ -2323,7 +2324,7 @@ static void K_SpawnGrowShrinkParticles(mobj_t *mo, INT32 timer) mo, P_RandomRange(-32, 32) * FRACUNIT, P_RandomRange(-32, 32) * FRACUNIT, - P_RandomRange(0, 24) + (shrink ? 24 : 0) * FRACUNIT, + (P_RandomRange(0, 24) + (shrink ? 48 : 0)) * FRACUNIT, MT_GROW_PARTICLE ); @@ -2335,7 +2336,11 @@ static void K_SpawnGrowShrinkParticles(mobj_t *mo, INT32 timer) K_MatchGenericExtraFlags(particle, mo); - particleSpeed = particle->scale * 4 * P_MobjFlip(mo); + particleScale = FixedMul((shrink ? SHRINK_PHYSICS_SCALE : GROW_PHYSICS_SCALE), mapobjectscale); + particleSpeed = mo->scale * 4 * P_MobjFlip(mo); // NOT particleScale + + particle->destscale = particleScale; + P_SetScale(particle, particle->destscale); if (shrink == true) { From 01b1a9d3a734385723a67aa536d527e39e222a1a Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Thu, 15 Sep 2022 21:44:45 -0400 Subject: [PATCH 25/26] Prevent poh-bees on no-respawn waypoints --- src/k_waypoint.c | 117 +++++++++++++++++++++++++++++++++++++++++++ src/k_waypoint.h | 30 +++++++++++ src/objects/shrink.c | 2 +- 3 files changed, 148 insertions(+), 1 deletion(-) diff --git a/src/k_waypoint.c b/src/k_waypoint.c index 0a8dfd0f0..2c9ebec9a 100644 --- a/src/k_waypoint.c +++ b/src/k_waypoint.c @@ -1101,6 +1101,40 @@ static boolean K_WaypointPathfindReachedGScore(void *data, void *setupData) return scoreReached; } +/*-------------------------------------------------- + static boolean K_WaypointPathfindReachedGScoreSpawnable(void *data, void *setupData) + + Returns if the current waypoint data reaches our end G score. + + Input Arguments:- + data - Should point to a pathfindnode_t to compare + setupData - Should point to the pathfindsetup_t to compare + + Return:- + True if the waypoint reached the G score, false otherwise. +--------------------------------------------------*/ +static boolean K_WaypointPathfindReachedGScoreSpawnable(void *data, void *setupData) +{ + boolean scoreReached = false; + boolean spawnable = false; + + if (data == NULL || setupData == NULL) + { + CONS_Debug(DBG_GAMELOGIC, "K_WaypointPathfindReachedGScoreSpawnable received NULL data.\n"); + } + else + { + pathfindnode_t *node = (pathfindnode_t *)data; + pathfindsetup_t *setup = (pathfindsetup_t *)setupData; + waypoint_t *wp = (waypoint_t *)node->nodedata; + + scoreReached = (node->gscore >= setup->endgscore); + spawnable = K_GetWaypointIsSpawnpoint(wp); + } + + return (scoreReached && spawnable); +} + /*-------------------------------------------------- boolean K_PathfindToWaypoint( waypoint_t *const sourcewaypoint, @@ -1266,6 +1300,89 @@ boolean K_PathfindThruCircuit( return pathfound; } +/*-------------------------------------------------- + boolean K_PathfindThruCircuitSpawnable( + waypoint_t *const sourcewaypoint, + const UINT32 traveldistance, + path_t *const returnpath, + const boolean useshortcuts, + const boolean huntbackwards) + + See header file for description. +--------------------------------------------------*/ +boolean K_PathfindThruCircuitSpawnable( + waypoint_t *const sourcewaypoint, + const UINT32 traveldistance, + path_t *const returnpath, + const boolean useshortcuts, + const boolean huntbackwards) +{ + boolean pathfound = false; + + if (sourcewaypoint == NULL) + { + CONS_Debug(DBG_GAMELOGIC, "NULL sourcewaypoint in K_PathfindThruCircuitSpawnable.\n"); + } + else if (finishline == NULL) + { + CONS_Debug(DBG_GAMELOGIC, "NULL finishline in K_PathfindThruCircuitSpawnable.\n"); + } + else if (((huntbackwards == false) && (sourcewaypoint->numnextwaypoints == 0)) + || ((huntbackwards == true) && (sourcewaypoint->numprevwaypoints == 0))) + { + CONS_Debug(DBG_GAMELOGIC, + "K_PathfindThruCircuitSpawnable: sourcewaypoint with ID %d has no next waypoint\n", + K_GetWaypointID(sourcewaypoint)); + } + else if (((huntbackwards == false) && (finishline->numprevwaypoints == 0)) + || ((huntbackwards == true) && (finishline->numnextwaypoints == 0))) + { + CONS_Debug(DBG_GAMELOGIC, + "K_PathfindThruCircuitSpawnable: finishline with ID %d has no previous waypoint\n", + K_GetWaypointID(finishline)); + } + else + { + pathfindsetup_t pathfindsetup = {0}; + getconnectednodesfunc nextnodesfunc = K_WaypointPathfindGetNext; + getnodeconnectioncostsfunc nodecostsfunc = K_WaypointPathfindGetNextCosts; + getnodeheuristicfunc heuristicfunc = K_WaypointPathfindGetHeuristic; + getnodetraversablefunc traversablefunc = K_WaypointPathfindTraversableNoShortcuts; + getpathfindfinishedfunc finishedfunc = K_WaypointPathfindReachedGScoreSpawnable; + + if (huntbackwards) + { + nextnodesfunc = K_WaypointPathfindGetPrev; + nodecostsfunc = K_WaypointPathfindGetPrevCosts; + } + + if (useshortcuts) + { + traversablefunc = K_WaypointPathfindTraversableAllEnabled; + } + + pathfindsetup.opensetcapacity = K_GetOpensetBaseSize(); + pathfindsetup.closedsetcapacity = K_GetClosedsetBaseSize(); + pathfindsetup.nodesarraycapacity = K_GetNodesArrayBaseSize(); + pathfindsetup.startnodedata = sourcewaypoint; + pathfindsetup.endnodedata = finishline; + pathfindsetup.endgscore = traveldistance; + pathfindsetup.getconnectednodes = nextnodesfunc; + pathfindsetup.getconnectioncosts = nodecostsfunc; + pathfindsetup.getheuristic = heuristicfunc; + pathfindsetup.gettraversable = traversablefunc; + pathfindsetup.getfinished = finishedfunc; + + pathfound = K_PathfindAStar(returnpath, &pathfindsetup); + + K_UpdateOpensetBaseSize(pathfindsetup.opensetcapacity); + K_UpdateClosedsetBaseSize(pathfindsetup.closedsetcapacity); + K_UpdateNodesArrayBaseSize(pathfindsetup.nodesarraycapacity); + } + + return pathfound; +} + /*-------------------------------------------------- waypoint_t *K_GetNextWaypointToDestination( waypoint_t *const sourcewaypoint, diff --git a/src/k_waypoint.h b/src/k_waypoint.h index a2201ff26..1cb659dbe 100644 --- a/src/k_waypoint.h +++ b/src/k_waypoint.h @@ -245,6 +245,36 @@ boolean K_PathfindThruCircuit( const boolean huntbackwards); +/*-------------------------------------------------- + boolean K_PathfindThruCircuitSpawnable( + waypoint_t *const sourcewaypoint, + const UINT32 traveldistance, + path_t *const returnpath, + const boolean useshortcuts, + const boolean huntbackwards) + + The same as K_PathfindThruCircuit, but continues until hitting a waypoint that + can be respawned at. + + Input Arguments:- + sourcewaypoint - The waypoint to start searching from + traveldistance - How far along the circuit it will try to pathfind. + returnpath - The path_t that will contain the final found path + useshortcuts - Whether to use waypoints that are marked as being shortcuts in the search + huntbackwards - Goes through the waypoints backwards if true + + Return:- + True if a circuit path could be constructed, false if it couldn't. +--------------------------------------------------*/ + +boolean K_PathfindThruCircuitSpawnable( + waypoint_t *const sourcewaypoint, + const UINT32 traveldistance, + path_t *const returnpath, + const boolean useshortcuts, + const boolean huntbackwards); + + /*-------------------------------------------------- waypoint_t *K_GetNextWaypointToDestination( waypoint_t *const sourcewaypoint, diff --git a/src/objects/shrink.c b/src/objects/shrink.c index a37c93ac3..0728385cf 100644 --- a/src/objects/shrink.c +++ b/src/objects/shrink.c @@ -564,7 +564,7 @@ static waypoint_t *GetPohbeeWaypoint(waypoint_t *anchor, const UINT32 traveldist path_t pathtofinish = {0}; waypoint_t *ret = NULL; - pathfindsuccess = K_PathfindThruCircuit( + pathfindsuccess = K_PathfindThruCircuitSpawnable( anchor, traveldist, &pathtofinish, useshortcuts, huntbackwards From 8f38555a86dae93ec52b847f2e6a190c3121c32c Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Fri, 16 Sep 2022 00:06:02 -0400 Subject: [PATCH 26/26] fixme for james :) --- src/objects/shrink.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/objects/shrink.c b/src/objects/shrink.c index 0728385cf..017c19829 100644 --- a/src/objects/shrink.c +++ b/src/objects/shrink.c @@ -23,6 +23,17 @@ #include "../z_zone.h" #include "../k_waypoint.h" +// +// ███████╗██╗██╗░░██╗███╗░░░███╗███████╗ +// ██╔════╝██║╚██╗██╔╝████╗░████║██╔════╝ +// █████╗░░██║░╚███╔╝░██╔████╔██║█████╗░░ +// ██╔══╝░░██║░██╔██╗░██║╚██╔╝██║██╔══╝░░ +// ██║░░░░░██║██╔╝╚██╗██║░╚═╝░██║███████╗ +// ╚═╝░░░░░╚═╝╚═╝░░╚═╝╚═╝░░░░░╚═╝╚══════╝ +// +// vertical flip +// + #define POHBEE_HOVER (256 << FRACBITS) #define POHBEE_SPEED (128 << FRACBITS) #define POHBEE_TIME (30 * TICRATE)