From 728d4a943592e6804b2b3a8d36b0889c83746526 Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Sun, 27 Sep 2020 04:51:08 -0400 Subject: [PATCH] Fixes to Battle Mode capsules --- src/g_game.c | 2 +- src/k_battle.c | 157 ++-------------------------------------- src/k_battle.h | 1 + src/p_mobj.c | 193 ++++++++++++++++++++++++++++++++++++++++--------- src/p_setup.c | 3 + 5 files changed, 169 insertions(+), 187 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index ad71f4d8b..6757fb2af 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -2790,7 +2790,7 @@ UINT32 gametypedefaultrules[NUMGAMETYPES] = // Race GTR_CIRCUIT|GTR_RINGS|GTR_BOTS, // Battle - GTR_BUMPERS|GTR_KARMA|GTR_ITEMARROWS|GTR_BATTLESTARTS|GTR_POINTLIMIT|GTR_TIMELIMIT|GTR_OVERTIME + GTR_BUMPERS|GTR_WANTED|GTR_KARMA|GTR_ITEMARROWS|GTR_CAPSULES|GTR_BATTLESTARTS|GTR_POINTLIMIT|GTR_TIMELIMIT|GTR_OVERTIME }; // diff --git a/src/k_battle.c b/src/k_battle.c index cb6659fbb..f99205cea 100644 --- a/src/k_battle.c +++ b/src/k_battle.c @@ -472,9 +472,9 @@ void K_RunBattleOvertime(void) } } -static void K_SetupMovingCapsule(mapthing_t *mt, mobj_t *mobj) +void K_SetupMovingCapsule(mapthing_t *mt, mobj_t *mobj) { - UINT8 sequence = mt->extrainfo-1; + UINT8 sequence = mt->args[0]-1; fixed_t speed = (FRACUNIT >> 3) * mt->angle; boolean backandforth = (mt->options & MTF_AMBUSH); boolean reverse = (mt->options & MTF_OBJECTSPECIAL); @@ -482,6 +482,9 @@ static void K_SetupMovingCapsule(mapthing_t *mt, mobj_t *mobj) mobj_t *target = NULL; thinker_t *th; + // TODO: This and the movement stuff in the thinker should both be using + // 2.2's new optimized functions for doing things with tube waypoints + // Find the inital target for (th = thlist[THINK_MOBJ].next; th != &thlist[THINK_MOBJ]; th = th->next) { @@ -570,155 +573,7 @@ void K_SpawnBattleCapsules(void) for (i = 0; i < nummapthings; i++, mt++) { if (mt->type == mobjinfo[MT_BATTLECAPSULE].doomednum) - { - sector_t *mtsector, *sec; - fixed_t x, y, z; - fixed_t floorheights[MAXFFLOORS+1]; - UINT8 numfloors = 1; - mobj_t *mobj = NULL; - boolean fly = true; - UINT8 j; - - mt->mobj = NULL; - - mtsector = R_PointInSubsector(mt->x << FRACBITS, mt->y << FRACBITS)->sector; - mt->z = (INT16)(P_GetZAt(mtsector->f_slope, mt->x << FRACBITS, mt->y << FRACBITS, mtsector->floorheight) / FRACUNIT); - - x = mt->x << FRACBITS; - y = mt->y << FRACBITS; - - sec = R_PointInSubsector(x, y)->sector; - - if (mt->options & MTF_OBJECTFLIP) - { - z = P_GetZAt(sec->c_slope, x, y, sec->ceilingheight) - mobjinfo[MT_BATTLECAPSULE].height; - - floorheights[0] = z; - z -= (mt->z << FRACBITS); - } - else - { - z = P_GetZAt(sec->f_slope, x, y, sec->floorheight); - - floorheights[0] = z; - z += (mt->z << FRACBITS); - } - - - if (sec->ffloors) - { - ffloor_t *rover; - for (rover = sec->ffloors; rover; rover = rover->next) - { - if ((rover->flags & FF_EXISTS) && (rover->flags & FF_BLOCKOTHERS)) - { - if (mt->options & MTF_OBJECTFLIP) - { - floorheights[numfloors] = P_GetZAt(*rover->b_slope, x, y, *rover->bottomheight) - mobjinfo[MT_BATTLECAPSULE].height; - } - else - { - floorheights[numfloors] = P_GetZAt(*rover->t_slope, x, y, *rover->topheight); - } - - numfloors++; - } - } - } - - mt->z = (INT16)(z>>FRACBITS); - - mobj = P_SpawnMobj(x, y, z, MT_BATTLECAPSULE); - mobj->spawnpoint = mt; - - if (mt->options & MTF_OBJECTFLIP) - { - mobj->eflags |= MFE_VERTICALFLIP; - mobj->flags2 |= MF2_OBJECTFLIP; - } - - for (j = 0; j < numfloors; j++) - { - if (z == floorheights[j]) - { - fly = false; - break; - } - } - - // Flying capsules - if (fly) - { - mobj->flags |= MF_NOGRAVITY; - mobj->extravalue1 = 1; // Set extravalue1 for later reference - } - - // Moving capsules! - if (mt->extrainfo && mt->angle) - K_SetupMovingCapsule(mt, mobj); - - // Moved from P_SpawnMobj due to order of operations mumbo jumbo - { - mobj_t *cur, *prev = mobj; - - // Init hnext list - // Spherical top - cur = P_SpawnMobj(mobj->x, mobj->y, mobj->z, MT_BATTLECAPSULE_PIECE); - P_SetMobjState(cur, S_BATTLECAPSULE_TOP); - - P_SetTarget(&cur->target, mobj); - P_SetTarget(&cur->hprev, prev); - P_SetTarget(&prev->hnext, cur); - prev = cur; - - // Tippity-top decorational button - cur = P_SpawnMobj(mobj->x, mobj->y, mobj->z, MT_BATTLECAPSULE_PIECE); - P_SetMobjState(cur, S_BATTLECAPSULE_BUTTON); - - P_SetTarget(&cur->target, mobj); - P_SetTarget(&cur->hprev, prev); - P_SetTarget(&prev->hnext, cur); - prev = cur; - - // Supports on the bottom - for (j = 0; j < 4; j++) - { - cur = P_SpawnMobj(mobj->x, mobj->y, mobj->z, MT_BATTLECAPSULE_PIECE); - cur->extravalue1 = j; - - if (mobj->extravalue1) // Flying capsule, moving or not - P_SetMobjState(cur, S_BATTLECAPSULE_SUPPORTFLY); - else if (mobj->target && !P_MobjWasRemoved(mobj->target)) // Grounded, moving capsule - P_SetMobjState(cur, S_KARMAWHEEL); - else - P_SetMobjState(cur, S_BATTLECAPSULE_SUPPORT); // Grounded, stationary capsule - - P_SetTarget(&cur->target, mobj); - P_SetTarget(&cur->hprev, prev); - P_SetTarget(&prev->hnext, cur); - prev = cur; - } - - // Side paneling - for (j = 0; j < 8; j++) - { - cur = P_SpawnMobj(mobj->x, mobj->y, mobj->z, MT_BATTLECAPSULE_PIECE); - cur->extravalue1 = j; - - if (j & 1) - P_SetMobjState(cur, S_BATTLECAPSULE_SIDE2); - else - P_SetMobjState(cur, S_BATTLECAPSULE_SIDE1); - - P_SetTarget(&cur->target, mobj); - P_SetTarget(&cur->hprev, prev); - P_SetTarget(&prev->hnext, cur); - prev = cur; - } - } - - mt->mobj = mobj; - } + P_SpawnMapThing(mt); } battlecapsules = true; diff --git a/src/k_battle.h b/src/k_battle.h index b69938d39..45a6b76c8 100644 --- a/src/k_battle.h +++ b/src/k_battle.h @@ -21,6 +21,7 @@ void K_CalculateBattleWanted(void); void K_SpawnBattlePoints(player_t *source, player_t *victim, UINT8 amount); void K_CheckBumpers(void); void K_RunBattleOvertime(void); +void K_SetupMovingCapsule(mapthing_t *mt, mobj_t *mobj); void K_SpawnBattleCapsules(void); #endif diff --git a/src/p_mobj.c b/src/p_mobj.c index 9a1b3915b..e2f6ac492 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -11411,43 +11411,166 @@ static boolean P_SetupSpawnedMapThing(mapthing_t *mthing, mobj_t *mobj, boolean break; } case MT_AAZTREE_HELPER: + { + fixed_t top = mobj->z; + UINT8 i; + UINT8 locnumsegs = (mthing->extrainfo)+2; + UINT8 numleaves = max(3, (abs(mthing->angle+1) % 6) + 3); + mobj_t *coconut; + + // Spawn tree segments + for (i = 0; i < locnumsegs; i++) { - fixed_t top = mobj->z; - UINT8 i; - UINT8 locnumsegs = (mthing->extrainfo)+2; - UINT8 numleaves = max(3, (abs(mthing->angle+1) % 6) + 3); - mobj_t *coconut; - - // Spawn tree segments - for (i = 0; i < locnumsegs; i++) - { - P_SpawnMobj(mobj->x, mobj->y, top, MT_AAZTREE_SEG); - top += FixedMul(mobjinfo[MT_AAZTREE_SEG].height, mobj->scale); - } - - // Big coconut topper - coconut = P_SpawnMobj(mobj->x, mobj->y, top - (8<destscale = (2*mobj->scale))); - - // Spawn all of the papersprite leaves - for (i = 0; i < numleaves; i++) - { - mobj_t *leaf; - - mobj->angle = FixedAngle((i * (360/numleaves))<x + FINECOSINE((mobj->angle>>ANGLETOFINESHIFT) & FINEMASK), - mobj->y + FINESINE((mobj->angle>>ANGLETOFINESHIFT) & FINEMASK), top, MT_AAZTREE_LEAF); - leaf->angle = mobj->angle; - - // Small coconut for each leaf - P_SpawnMobj(mobj->x + (32 * FINECOSINE((mobj->angle>>ANGLETOFINESHIFT) & FINEMASK)), - mobj->y + (32 * FINESINE((mobj->angle>>ANGLETOFINESHIFT) & FINEMASK)), top - (24<x, mobj->y, top, MT_AAZTREE_SEG); + top += FixedMul(mobjinfo[MT_AAZTREE_SEG].height, mobj->scale); } + + // Big coconut topper + coconut = P_SpawnMobj(mobj->x, mobj->y, top - (8<destscale = (2*mobj->scale))); + + // Spawn all of the papersprite leaves + for (i = 0; i < numleaves; i++) + { + mobj_t *leaf; + + mobj->angle = FixedAngle((i * (360/numleaves))<x + FINECOSINE((mobj->angle>>ANGLETOFINESHIFT) & FINEMASK), + mobj->y + FINESINE((mobj->angle>>ANGLETOFINESHIFT) & FINEMASK), top, MT_AAZTREE_LEAF); + leaf->angle = mobj->angle; + + // Small coconut for each leaf + P_SpawnMobj(mobj->x + (32 * FINECOSINE((mobj->angle>>ANGLETOFINESHIFT) & FINEMASK)), + mobj->y + (32 * FINESINE((mobj->angle>>ANGLETOFINESHIFT) & FINEMASK)), top - (24<x, mobj->y)->sector; + mobj_t *cur, *prev = mobj; + fixed_t floorheights[MAXFFLOORS+1]; + UINT8 numfloors = 0; + boolean fly = true; + UINT8 i; + + // This floor height stuff is stupid but I couldn't get it to work any other way for whatever reason + if (mthing->options & MTF_OBJECTFLIP) + { + floorheights[numfloors] = P_GetSectorCeilingZAt(sec, mobj->x, mobj->y) - mobj->height; + } + else + { + floorheights[numfloors] = P_GetSectorFloorZAt(sec, mobj->x, mobj->y); + } + + numfloors++; + + if (sec->ffloors) + { + ffloor_t *rover; + for (rover = sec->ffloors; rover; rover = rover->next) + { + if ((rover->flags & FF_EXISTS) && (rover->flags & FF_BLOCKOTHERS)) + { + if (mthing->options & MTF_OBJECTFLIP) + { + floorheights[numfloors] = P_GetFFloorBottomZAt(rover, mobj->x, mobj->y) - mobj->height; + } + else + { + floorheights[numfloors] = P_GetFFloorBottomZAt(rover, mobj->x, mobj->y); + } + + numfloors++; + } + } + } + + for (i = 0; i < numfloors; i++) + { + if (mobj->z == floorheights[i]) + { + fly = false; + break; + } + } + + // Flying capsules + if (fly) + { + mobj->flags |= MF_NOGRAVITY; + mobj->extravalue1 = 1; // Set extravalue1 for later reference + } + + // Moving capsules! + if (mthing->args[0] && mthing->angle) + { + K_SetupMovingCapsule(mthing, mobj); + } + + // NOW FOR ALL OF THE PIECES!! + // Init hnext list + // Spherical top + cur = P_SpawnMobj(mobj->x, mobj->y, mobj->z, MT_BATTLECAPSULE_PIECE); + P_SetMobjState(cur, S_BATTLECAPSULE_TOP); + + P_SetTarget(&cur->target, mobj); + P_SetTarget(&cur->hprev, prev); + P_SetTarget(&prev->hnext, cur); + prev = cur; + + // Tippity-top decorational button + cur = P_SpawnMobj(mobj->x, mobj->y, mobj->z, MT_BATTLECAPSULE_PIECE); + P_SetMobjState(cur, S_BATTLECAPSULE_BUTTON); + + P_SetTarget(&cur->target, mobj); + P_SetTarget(&cur->hprev, prev); + P_SetTarget(&prev->hnext, cur); + prev = cur; + + // Supports on the bottom + for (i = 0; i < 4; i++) + { + cur = P_SpawnMobj(mobj->x, mobj->y, mobj->z, MT_BATTLECAPSULE_PIECE); + cur->extravalue1 = i; + + if (mobj->extravalue1) // Flying capsule, moving or not + P_SetMobjState(cur, S_BATTLECAPSULE_SUPPORTFLY); + else if (mobj->target && !P_MobjWasRemoved(mobj->target)) // Grounded, moving capsule + P_SetMobjState(cur, S_KARMAWHEEL); + else + P_SetMobjState(cur, S_BATTLECAPSULE_SUPPORT); // Grounded, stationary capsule + + P_SetTarget(&cur->target, mobj); + P_SetTarget(&cur->hprev, prev); + P_SetTarget(&prev->hnext, cur); + prev = cur; + } + + // Side paneling + for (i = 0; i < 8; i++) + { + cur = P_SpawnMobj(mobj->x, mobj->y, mobj->z, MT_BATTLECAPSULE_PIECE); + cur->extravalue1 = i; + + if (i & 1) + P_SetMobjState(cur, S_BATTLECAPSULE_SIDE2); + else + P_SetMobjState(cur, S_BATTLECAPSULE_SIDE1); + + P_SetTarget(&cur->target, mobj); + P_SetTarget(&cur->hprev, prev); + P_SetTarget(&prev->hnext, cur); + prev = cur; + } + + // Increment no. of capsules on the map counter + maptargets++; + } default: break; } diff --git a/src/p_setup.c b/src/p_setup.c index b3fe54d05..4d7a34857 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -3178,6 +3178,9 @@ static void P_ConvertBinaryMap(void) } break; } + case 2333: // MT_BATTLECAPSULE + mapthings[i].args[0] = mapthings[i].extrainfo; + break; default: break; }