Fixes to Battle Mode capsules

This commit is contained in:
Sally Coolatta 2020-09-27 04:51:08 -04:00
parent 857f295836
commit 728d4a9435
5 changed files with 169 additions and 187 deletions

View file

@ -2790,7 +2790,7 @@ UINT32 gametypedefaultrules[NUMGAMETYPES] =
// Race // Race
GTR_CIRCUIT|GTR_RINGS|GTR_BOTS, GTR_CIRCUIT|GTR_RINGS|GTR_BOTS,
// Battle // 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
}; };
// //

View file

@ -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; fixed_t speed = (FRACUNIT >> 3) * mt->angle;
boolean backandforth = (mt->options & MTF_AMBUSH); boolean backandforth = (mt->options & MTF_AMBUSH);
boolean reverse = (mt->options & MTF_OBJECTSPECIAL); boolean reverse = (mt->options & MTF_OBJECTSPECIAL);
@ -482,6 +482,9 @@ static void K_SetupMovingCapsule(mapthing_t *mt, mobj_t *mobj)
mobj_t *target = NULL; mobj_t *target = NULL;
thinker_t *th; 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 // Find the inital target
for (th = thlist[THINK_MOBJ].next; th != &thlist[THINK_MOBJ]; th = th->next) 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++) for (i = 0; i < nummapthings; i++, mt++)
{ {
if (mt->type == mobjinfo[MT_BATTLECAPSULE].doomednum) if (mt->type == mobjinfo[MT_BATTLECAPSULE].doomednum)
{ P_SpawnMapThing(mt);
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;
}
} }
battlecapsules = true; battlecapsules = true;

View file

@ -21,6 +21,7 @@ void K_CalculateBattleWanted(void);
void K_SpawnBattlePoints(player_t *source, player_t *victim, UINT8 amount); void K_SpawnBattlePoints(player_t *source, player_t *victim, UINT8 amount);
void K_CheckBumpers(void); void K_CheckBumpers(void);
void K_RunBattleOvertime(void); void K_RunBattleOvertime(void);
void K_SetupMovingCapsule(mapthing_t *mt, mobj_t *mobj);
void K_SpawnBattleCapsules(void); void K_SpawnBattleCapsules(void);
#endif #endif

View file

@ -11448,6 +11448,129 @@ static boolean P_SetupSpawnedMapThing(mapthing_t *mthing, mobj_t *mobj, boolean
P_RemoveMobj(mobj); // Don't need this helper obj anymore P_RemoveMobj(mobj); // Don't need this helper obj anymore
return false; return false;
} }
case MT_BATTLECAPSULE:
{
sector_t *sec = R_PointInSubsector(mobj->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: default:
break; break;
} }

View file

@ -3178,6 +3178,9 @@ static void P_ConvertBinaryMap(void)
} }
break; break;
} }
case 2333: // MT_BATTLECAPSULE
mapthings[i].args[0] = mapthings[i].extrainfo;
break;
default: default:
break; break;
} }