mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2025-10-30 08:01:28 +00:00
Egg Capsules use args + optimized tube waypoints
This commit is contained in:
parent
436c763a02
commit
c1581d0f75
4 changed files with 32 additions and 91 deletions
|
|
@ -18,6 +18,7 @@
|
||||||
#include "m_random.h"
|
#include "m_random.h"
|
||||||
#include "r_sky.h" // skyflatnum
|
#include "r_sky.h" // skyflatnum
|
||||||
#include "k_grandprix.h" // K_CanChangeRules
|
#include "k_grandprix.h" // K_CanChangeRules
|
||||||
|
#include "p_spec.h"
|
||||||
|
|
||||||
// Battle overtime info
|
// Battle overtime info
|
||||||
struct battleovertime battleovertime;
|
struct battleovertime battleovertime;
|
||||||
|
|
@ -701,44 +702,18 @@ void K_SetupMovingCapsule(mapthing_t *mt, mobj_t *mobj)
|
||||||
{
|
{
|
||||||
UINT8 sequence = mt->args[0] - 1;
|
UINT8 sequence = mt->args[0] - 1;
|
||||||
fixed_t speed = (FRACUNIT >> 3) * mt->args[1];
|
fixed_t speed = (FRACUNIT >> 3) * mt->args[1];
|
||||||
boolean backandforth = (mt->options & MTF_AMBUSH);
|
boolean backandforth = (mt->args[2] & TMBCF_BACKANDFORTH);
|
||||||
boolean reverse = (mt->options & MTF_OBJECTSPECIAL);
|
boolean reverse = (mt->args[2] & TMBCF_REVERSE);
|
||||||
mobj_t *mo2;
|
|
||||||
mobj_t *target = NULL;
|
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
|
// 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)
|
target = P_GetLastTubeWaypoint(sequence);
|
||||||
continue;
|
}
|
||||||
|
else
|
||||||
mo2 = (mobj_t *)th;
|
{
|
||||||
|
target = P_GetFirstTubeWaypoint(sequence);
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!target)
|
if (!target)
|
||||||
|
|
|
||||||
64
src/p_mobj.c
64
src/p_mobj.c
|
|
@ -8857,11 +8857,9 @@ static boolean P_MobjRegularThink(mobj_t *mobj)
|
||||||
{
|
{
|
||||||
fixed_t speed = mobj->movefactor;
|
fixed_t speed = mobj->movefactor;
|
||||||
UINT8 sequence = mobj->lastlook;
|
UINT8 sequence = mobj->lastlook;
|
||||||
UINT8 num = mobj->movecount;
|
|
||||||
boolean backandforth = (mobj->flags2 & MF2_AMBUSH);
|
boolean backandforth = (mobj->flags2 & MF2_AMBUSH);
|
||||||
SINT8 direction = mobj->cvmem;
|
SINT8 direction = mobj->cvmem;
|
||||||
mobj_t *next = NULL;
|
mobj_t *next = NULL;
|
||||||
thinker_t *th;
|
|
||||||
fixed_t dist, momx, momy, momz;
|
fixed_t dist, momx, momy, momz;
|
||||||
|
|
||||||
dist = P_AproxDistance(mobj->target->x - mobj->x, mobj->target->y - mobj->y);
|
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
|
else
|
||||||
{
|
{
|
||||||
mobj_t *mo2;
|
|
||||||
|
|
||||||
speed -= dist;
|
speed -= dist;
|
||||||
|
|
||||||
P_UnsetThingPosition(mobj);
|
P_UnsetThingPosition(mobj);
|
||||||
|
|
@ -8898,25 +8894,7 @@ static boolean P_MobjRegularThink(mobj_t *mobj)
|
||||||
mobj->ceilingz = mobj->subsector->sector->ceilingheight;
|
mobj->ceilingz = mobj->subsector->sector->ceilingheight;
|
||||||
|
|
||||||
// Onto the next waypoint!
|
// Onto the next waypoint!
|
||||||
for (th = thlist[THINK_MOBJ].next; th != &thlist[THINK_MOBJ]; th = th->next)
|
next = (direction < 0) ? P_GetPreviousTubeWaypoint(mobj->target, false) : P_GetNextTubeWaypoint(mobj->target, false);
|
||||||
{
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Are we at the end of the waypoint chain?
|
// Are we at the end of the waypoint chain?
|
||||||
// If so, search again for the first/previous waypoint (depending on settings)
|
// 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)
|
if (backandforth)
|
||||||
{
|
{
|
||||||
|
// Back and forth movement.
|
||||||
mobj->cvmem = -mobj->cvmem;
|
mobj->cvmem = -mobj->cvmem;
|
||||||
direction = mobj->cvmem;
|
direction = mobj->cvmem;
|
||||||
|
|
||||||
|
next = (direction < 0) ? P_GetPreviousTubeWaypoint(mobj->target, false) : P_GetNextTubeWaypoint(mobj->target, false);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
for (th = thlist[THINK_MOBJ].next; th != &thlist[THINK_MOBJ]; th = th->next)
|
|
||||||
{
|
{
|
||||||
if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed)
|
// Looping circular movement.
|
||||||
continue;
|
next = (direction < 0) ? P_GetLastTubeWaypoint(sequence) : P_GetFirstTubeWaypoint(sequence);
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6500,6 +6500,16 @@ static void P_ConvertBinaryThingTypes(void)
|
||||||
case 2333: // MT_BATTLECAPSULE
|
case 2333: // MT_BATTLECAPSULE
|
||||||
mapthings[i].args[0] = mapthings[i].extrainfo;
|
mapthings[i].args[0] = mapthings[i].extrainfo;
|
||||||
mapthings[i].args[1] = mapthings[i].angle;
|
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;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
|
|
@ -57,6 +57,12 @@ typedef enum
|
||||||
TMWPF_FINISHLINE = 1<<3,
|
TMWPF_FINISHLINE = 1<<3,
|
||||||
} textmapwaypointflags_t;
|
} textmapwaypointflags_t;
|
||||||
|
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
TMBCF_BACKANDFORTH = 1,
|
||||||
|
TMBCF_REVERSE = 1<<1,
|
||||||
|
} textmapbattlecapsuleflags_t;
|
||||||
|
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
TMFF_AIMLESS = 1,
|
TMFF_AIMLESS = 1,
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue