Egg Capsules use args + optimized tube waypoints

This commit is contained in:
Sally Coolatta 2022-10-10 07:48:55 -04:00
parent 436c763a02
commit c1581d0f75
4 changed files with 32 additions and 91 deletions

View file

@ -18,6 +18,7 @@
#include "m_random.h"
#include "r_sky.h" // skyflatnum
#include "k_grandprix.h" // K_CanChangeRules
#include "p_spec.h"
// Battle overtime info
struct battleovertime battleovertime;
@ -701,44 +702,18 @@ void K_SetupMovingCapsule(mapthing_t *mt, mobj_t *mobj)
{
UINT8 sequence = mt->args[0] - 1;
fixed_t speed = (FRACUNIT >> 3) * mt->args[1];
boolean backandforth = (mt->options & MTF_AMBUSH);
boolean reverse = (mt->options & MTF_OBJECTSPECIAL);
mobj_t *mo2;
boolean backandforth = (mt->args[2] & TMBCF_BACKANDFORTH);
boolean reverse = (mt->args[2] & TMBCF_REVERSE);
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)
if (reverse)
{
if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed)
continue;
mo2 = (mobj_t *)th;
if (mo2->type != MT_TUBEWAYPOINT)
continue;
if (mo2->threshold == sequence)
{
if (reverse) // Use the highest waypoint number as first
{
if (mo2->health != 0)
{
if (target == NULL)
target = mo2;
else if (mo2->health > target->health)
target = mo2;
}
}
else // Use the lowest waypoint number as first
{
if (mo2->health == 0)
target = mo2;
}
}
target = P_GetLastTubeWaypoint(sequence);
}
else
{
target = P_GetFirstTubeWaypoint(sequence);
}
if (!target)

View file

@ -8857,11 +8857,9 @@ static boolean P_MobjRegularThink(mobj_t *mobj)
{
fixed_t speed = mobj->movefactor;
UINT8 sequence = mobj->lastlook;
UINT8 num = mobj->movecount;
boolean backandforth = (mobj->flags2 & MF2_AMBUSH);
SINT8 direction = mobj->cvmem;
mobj_t *next = NULL;
thinker_t *th;
fixed_t dist, momx, momy, momz;
dist = P_AproxDistance(mobj->target->x - mobj->x, mobj->target->y - mobj->y);
@ -8884,8 +8882,6 @@ static boolean P_MobjRegularThink(mobj_t *mobj)
}
else
{
mobj_t *mo2;
speed -= dist;
P_UnsetThingPosition(mobj);
@ -8898,25 +8894,7 @@ static boolean P_MobjRegularThink(mobj_t *mobj)
mobj->ceilingz = mobj->subsector->sector->ceilingheight;
// Onto the next waypoint!
for (th = thlist[THINK_MOBJ].next; th != &thlist[THINK_MOBJ]; th = th->next)
{
if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed)
continue;
mo2 = (mobj_t *)th;
if (mo2->type != MT_TUBEWAYPOINT)
continue;
if (mo2->threshold == sequence)
{
if (mo2->health == num + direction)
{
next = mo2;
break;
}
}
}
next = (direction < 0) ? P_GetPreviousTubeWaypoint(mobj->target, false) : P_GetNextTubeWaypoint(mobj->target, false);
// Are we at the end of the waypoint chain?
// If so, search again for the first/previous waypoint (depending on settings)
@ -8924,44 +8902,16 @@ static boolean P_MobjRegularThink(mobj_t *mobj)
{
if (backandforth)
{
// Back and forth movement.
mobj->cvmem = -mobj->cvmem;
direction = mobj->cvmem;
next = (direction < 0) ? P_GetPreviousTubeWaypoint(mobj->target, false) : P_GetNextTubeWaypoint(mobj->target, false);
}
for (th = thlist[THINK_MOBJ].next; th != &thlist[THINK_MOBJ]; th = th->next)
else
{
if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed)
continue;
mo2 = (mobj_t *)th;
if (mo2->type != MT_TUBEWAYPOINT)
continue;
if (mo2->threshold == sequence)
{
if (backandforth)
{
if (mo2->health == num + direction)
{
next = mo2;
break;
}
}
else
{
if (direction < 0)
{
if (next == NULL || mo2->health > next->health)
next = mo2;
}
else
{
if (next == NULL || mo2->health < next->health)
next = mo2;
}
}
}
// Looping circular movement.
next = (direction < 0) ? P_GetLastTubeWaypoint(sequence) : P_GetFirstTubeWaypoint(sequence);
}
}

View file

@ -6500,6 +6500,16 @@ static void P_ConvertBinaryThingTypes(void)
case 2333: // MT_BATTLECAPSULE
mapthings[i].args[0] = mapthings[i].extrainfo;
mapthings[i].args[1] = mapthings[i].angle;
if (mapthings[i].options & MTF_OBJECTSPECIAL)
{
mapthings[i].args[2] |= TMBCF_REVERSE;
}
if (mapthings[i].options & MTF_AMBUSH)
{
mapthings[i].args[2] |= TMBCF_BACKANDFORTH;
}
break;
default:
break;

View file

@ -57,6 +57,12 @@ typedef enum
TMWPF_FINISHLINE = 1<<3,
} textmapwaypointflags_t;
typedef enum
{
TMBCF_BACKANDFORTH = 1,
TMBCF_REVERSE = 1<<1,
} textmapbattlecapsuleflags_t;
typedef enum
{
TMFF_AIMLESS = 1,