From 2daeb81f36f0d70134d8c334d9bd93a3ac04de68 Mon Sep 17 00:00:00 2001 From: lachwright Date: Sat, 12 Oct 2019 04:23:11 +0800 Subject: [PATCH 1/3] Create new linedef special type 153: Dynamically Sinking Platform --- src/p_floor.c | 47 +++++++++++++++++++++++++++++++++++++++++++++-- src/p_spec.c | 19 +++++++++++++------ 2 files changed, 58 insertions(+), 8 deletions(-) diff --git a/src/p_floor.c b/src/p_floor.c index 19b7611b8..40bd6a6b2 100644 --- a/src/p_floor.c +++ b/src/p_floor.c @@ -2425,7 +2425,7 @@ void T_RaiseSector(levelspecthink_t *raise) mobj_t *thing; sector_t *sector; INT32 i; - boolean playeronme = false; + boolean playeronme = false, active = false; fixed_t ceilingdestination, floordestination; result_e res = 0; @@ -2459,8 +2459,49 @@ void T_RaiseSector(levelspecthink_t *raise) break; } } + + if (raise->vars[9]) // Dynamically Sinking Platform^tm + { + tic_t shaketime = 10; + if (raise->vars[11] > shaketime) // State: moving + { + if (playeronme) // If player is standing on the platform, accelerate + { + raise->vars[10] += (FRACUNIT >> 5); + } + else // otherwise, decelerate until inflection + { + raise->vars[10] -= FRACUNIT >> 3; + if (raise->vars[10] <= 0) // inflection! + { + raise->vars[10] = 0; + raise->vars[11] = 0; // allow the shake to occur again (fucks over players attempting to jump-cheese) + } + } + active = raise->vars[10] > 0; + } + else // State: shaking + { + if (playeronme || raise->vars[11]) + { + active = true; + raise->vars[11]++; + if (raise->vars[11] > shaketime) + { + if (playeronme) + raise->vars[10] = FRACUNIT >> 5; + else + raise->vars[10] = FRACUNIT << 1; + } + else + raise->vars[10] = 2*(shaketime/2 - raise->vars[11]) << FRACBITS; + } + } + } + else // Air bobbing platform (not a Dynamically Sinking Platform^tm) + active = playeronme; - if (playeronme) + if (active) { raise->vars[3] = raise->vars[2]; @@ -2553,6 +2594,8 @@ void T_RaiseSector(levelspecthink_t *raise) else if (raise->vars[3] > origspeed) raise->vars[3] = origspeed; } + + raise->vars[3] += raise->vars[10]; res = T_MovePlane ( diff --git a/src/p_spec.c b/src/p_spec.c index 256ca3453..26c4250d5 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -6132,7 +6132,7 @@ static void P_AddRaiseThinker(sector_t *sec, line_t *sourceline) } // Function to maintain backwards compatibility -static void P_AddOldAirbob(sector_t *sec, line_t *sourceline, boolean noadjust) +static void P_AddOldAirbob(sector_t *sec, line_t *sourceline, boolean noadjust, boolean dynamic) { levelspecthink_t *airbob; @@ -6169,6 +6169,8 @@ static void P_AddOldAirbob(sector_t *sec, line_t *sourceline, boolean noadjust) airbob->vars[5] = sec->ceilingheight; airbob->vars[4] = airbob->vars[5] - (sec->ceilingheight - sec->floorheight); + + airbob->vars[9] = dynamic ? 1 : 0; airbob->sourceline = sourceline; } @@ -6987,11 +6989,16 @@ void P_SpawnSpecials(INT32 fromnetsave) case 151: // Adjustable air bobbing platform P_AddFakeFloorsByLine(i, FF_EXISTS|FF_SOLID|FF_RENDERALL|FF_CUTLEVEL, secthinkers); lines[i].flags |= ML_BLOCKMONSTERS; - P_AddOldAirbob(lines[i].frontsector, lines + i, (lines[i].special != 151)); + P_AddOldAirbob(lines[i].frontsector, lines + i, (lines[i].special != 151), false); break; case 152: // Adjustable air bobbing platform in reverse P_AddFakeFloorsByLine(i, FF_EXISTS|FF_SOLID|FF_RENDERALL|FF_CUTLEVEL, secthinkers); - P_AddOldAirbob(lines[i].frontsector, lines + i, true); + P_AddOldAirbob(lines[i].frontsector, lines + i, true, false); + break; + case 153: // Dynamic Sinking Platform + P_AddFakeFloorsByLine(i, FF_EXISTS|FF_SOLID|FF_RENDERALL|FF_CUTLEVEL, secthinkers); + lines[i].flags |= ML_BLOCKMONSTERS; + P_AddOldAirbob(lines[i].frontsector, lines + i, false, true); break; case 160: // Float/bob platform @@ -7042,14 +7049,14 @@ void P_SpawnSpecials(INT32 fromnetsave) case 176: // Air bobbing platform that will crumble and bob on the water when it falls and hits P_AddFakeFloorsByLine(i, FF_EXISTS|FF_SOLID|FF_RENDERALL|FF_FLOATBOB|FF_CRUMBLE, secthinkers); lines[i].flags |= ML_BLOCKMONSTERS; - P_AddOldAirbob(lines[i].frontsector, lines + i, true); + P_AddOldAirbob(lines[i].frontsector, lines + i, true, false); break; case 177: // Air bobbing platform that will crumble and bob on // the water when it falls and hits, then never return P_AddFakeFloorsByLine(i, FF_EXISTS|FF_SOLID|FF_RENDERALL|FF_CUTLEVEL|FF_FLOATBOB|FF_CRUMBLE|FF_NORETURN, secthinkers); lines[i].flags |= ML_BLOCKMONSTERS; - P_AddOldAirbob(lines[i].frontsector, lines + i, true); + P_AddOldAirbob(lines[i].frontsector, lines + i, true, false); break; case 178: // Crumbling platform that will float when it hits water @@ -7063,7 +7070,7 @@ void P_SpawnSpecials(INT32 fromnetsave) case 180: // Air bobbing platform that will crumble P_AddFakeFloorsByLine(i, FF_EXISTS|FF_SOLID|FF_RENDERALL|FF_CUTLEVEL|FF_CRUMBLE, secthinkers); lines[i].flags |= ML_BLOCKMONSTERS; - P_AddOldAirbob(lines[i].frontsector, lines + i, true); + P_AddOldAirbob(lines[i].frontsector, lines + i, true, false); break; case 190: // Rising Platform FOF (solid, opaque, shadows) From 9d425b21e2830e84a2a6b98298b87c2e5c605bec Mon Sep 17 00:00:00 2001 From: toaster Date: Sun, 20 Oct 2019 19:13:46 +0100 Subject: [PATCH 2/3] Modify initial platform sink to be more natural, while still toeing the line between "forgiving" and "punishing". --- src/p_floor.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/p_floor.c b/src/p_floor.c index 40bd6a6b2..1360375a7 100644 --- a/src/p_floor.c +++ b/src/p_floor.c @@ -2462,7 +2462,7 @@ void T_RaiseSector(levelspecthink_t *raise) if (raise->vars[9]) // Dynamically Sinking Platform^tm { - tic_t shaketime = 10; +#define shaketime 10 if (raise->vars[11] > shaketime) // State: moving { if (playeronme) // If player is standing on the platform, accelerate @@ -2485,8 +2485,7 @@ void T_RaiseSector(levelspecthink_t *raise) if (playeronme || raise->vars[11]) { active = true; - raise->vars[11]++; - if (raise->vars[11] > shaketime) + if (++raise->vars[11] > shaketime) { if (playeronme) raise->vars[10] = FRACUNIT >> 5; @@ -2494,9 +2493,14 @@ void T_RaiseSector(levelspecthink_t *raise) raise->vars[10] = FRACUNIT << 1; } else - raise->vars[10] = 2*(shaketime/2 - raise->vars[11]) << FRACBITS; + { + raise->vars[10] = ((shaketime/2) - raise->vars[11]) << FRACBITS; + if (raise->vars[10] < -raise->vars[2]/2) + raise->vars[10] = -raise->vars[2]/2; + } } } +#undef shaketime } else // Air bobbing platform (not a Dynamically Sinking Platform^tm) active = playeronme; @@ -2594,7 +2598,7 @@ void T_RaiseSector(levelspecthink_t *raise) else if (raise->vars[3] > origspeed) raise->vars[3] = origspeed; } - + raise->vars[3] += raise->vars[10]; res = T_MovePlane From 46d105dd53197812129e10b628dd15611fd4d7ac Mon Sep 17 00:00:00 2001 From: MascaraSnake Date: Fri, 25 Oct 2019 22:55:10 +0200 Subject: [PATCH 3/3] Some basic code hygiene: Remove references to the air bob code being "old" or "outdated" --- src/p_spec.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/src/p_spec.c b/src/p_spec.c index 1ec1c3021..2a138f42a 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -5984,8 +5984,6 @@ static void P_AddBlockThinker(sector_t *sec, line_t *sourceline) * to the lowest nearby height if not * there already. * - * Replaces the old "AirBob". - * * \param sec Control sector. * \param actionsector Target sector. * \param sourceline Control linedef. @@ -6030,8 +6028,7 @@ static void P_AddRaiseThinker(sector_t *sec, line_t *sourceline) raise->sourceline = sourceline; } -// Function to maintain backwards compatibility -static void P_AddOldAirbob(sector_t *sec, line_t *sourceline, boolean noadjust, boolean dynamic) +static void P_AddAirbob(sector_t *sec, line_t *sourceline, boolean noadjust, boolean dynamic) { levelspecthink_t *airbob; @@ -6893,16 +6890,16 @@ void P_SpawnSpecials(INT32 fromnetsave) case 151: // Adjustable air bobbing platform P_AddFakeFloorsByLine(i, FF_EXISTS|FF_SOLID|FF_RENDERALL|FF_CUTLEVEL, secthinkers); lines[i].flags |= ML_BLOCKMONSTERS; - P_AddOldAirbob(lines[i].frontsector, lines + i, (lines[i].special != 151), false); + P_AddAirbob(lines[i].frontsector, lines + i, (lines[i].special != 151), false); break; case 152: // Adjustable air bobbing platform in reverse P_AddFakeFloorsByLine(i, FF_EXISTS|FF_SOLID|FF_RENDERALL|FF_CUTLEVEL, secthinkers); - P_AddOldAirbob(lines[i].frontsector, lines + i, true, false); + P_AddAirbob(lines[i].frontsector, lines + i, true, false); break; case 153: // Dynamic Sinking Platform P_AddFakeFloorsByLine(i, FF_EXISTS|FF_SOLID|FF_RENDERALL|FF_CUTLEVEL, secthinkers); lines[i].flags |= ML_BLOCKMONSTERS; - P_AddOldAirbob(lines[i].frontsector, lines + i, false, true); + P_AddAirbob(lines[i].frontsector, lines + i, false, true); break; case 160: // Float/bob platform @@ -6953,14 +6950,14 @@ void P_SpawnSpecials(INT32 fromnetsave) case 176: // Air bobbing platform that will crumble and bob on the water when it falls and hits P_AddFakeFloorsByLine(i, FF_EXISTS|FF_SOLID|FF_RENDERALL|FF_FLOATBOB|FF_CRUMBLE, secthinkers); lines[i].flags |= ML_BLOCKMONSTERS; - P_AddOldAirbob(lines[i].frontsector, lines + i, true, false); + P_AddAirbob(lines[i].frontsector, lines + i, true, false); break; case 177: // Air bobbing platform that will crumble and bob on // the water when it falls and hits, then never return P_AddFakeFloorsByLine(i, FF_EXISTS|FF_SOLID|FF_RENDERALL|FF_CUTLEVEL|FF_FLOATBOB|FF_CRUMBLE|FF_NORETURN, secthinkers); lines[i].flags |= ML_BLOCKMONSTERS; - P_AddOldAirbob(lines[i].frontsector, lines + i, true, false); + P_AddAirbob(lines[i].frontsector, lines + i, true, false); break; case 178: // Crumbling platform that will float when it hits water @@ -6974,7 +6971,7 @@ void P_SpawnSpecials(INT32 fromnetsave) case 180: // Air bobbing platform that will crumble P_AddFakeFloorsByLine(i, FF_EXISTS|FF_SOLID|FF_RENDERALL|FF_CUTLEVEL|FF_CRUMBLE, secthinkers); lines[i].flags |= ML_BLOCKMONSTERS; - P_AddOldAirbob(lines[i].frontsector, lines + i, true, false); + P_AddAirbob(lines[i].frontsector, lines + i, true, false); break; case 190: // Rising Platform FOF (solid, opaque, shadows)