Merge branch 'waypoints' into 'next'
Store waypoints at map load instead of iterating through the thinker list to find them See merge request STJr/SRB2!938
This commit is contained in:
commit
33a22331f8
|
@ -620,6 +620,18 @@ extern mapthing_t *playerstarts[MAXPLAYERS]; // Cooperative
|
||||||
extern mapthing_t *bluectfstarts[MAXPLAYERS]; // CTF
|
extern mapthing_t *bluectfstarts[MAXPLAYERS]; // CTF
|
||||||
extern mapthing_t *redctfstarts[MAXPLAYERS]; // CTF
|
extern mapthing_t *redctfstarts[MAXPLAYERS]; // CTF
|
||||||
|
|
||||||
|
#define WAYPOINTSEQUENCESIZE 256
|
||||||
|
#define NUMWAYPOINTSEQUENCES 256
|
||||||
|
extern mobj_t *waypoints[NUMWAYPOINTSEQUENCES][WAYPOINTSEQUENCESIZE];
|
||||||
|
extern UINT16 numwaypoints[NUMWAYPOINTSEQUENCES];
|
||||||
|
|
||||||
|
void P_AddWaypoint(UINT8 sequence, UINT8 id, mobj_t *waypoint);
|
||||||
|
mobj_t *P_GetFirstWaypoint(UINT8 sequence);
|
||||||
|
mobj_t *P_GetLastWaypoint(UINT8 sequence);
|
||||||
|
mobj_t *P_GetPreviousWaypoint(mobj_t *current, boolean wrap);
|
||||||
|
mobj_t *P_GetNextWaypoint(mobj_t *current, boolean wrap);
|
||||||
|
mobj_t *P_GetClosestWaypoint(UINT8 sequence, mobj_t *mo);
|
||||||
|
|
||||||
// =====================================
|
// =====================================
|
||||||
// Internal parameters, used for engine.
|
// Internal parameters, used for engine.
|
||||||
// =====================================
|
// =====================================
|
||||||
|
|
|
@ -12700,8 +12700,8 @@ void A_Boss5FindWaypoint(mobj_t *actor)
|
||||||
else // locvar1 == 0
|
else // locvar1 == 0
|
||||||
{
|
{
|
||||||
fixed_t hackoffset = P_MobjFlip(actor)*56*FRACUNIT;
|
fixed_t hackoffset = P_MobjFlip(actor)*56*FRACUNIT;
|
||||||
INT32 numwaypoints = 0;
|
INT32 numfangwaypoints = 0;
|
||||||
mobj_t **waypoints;
|
mobj_t **fangwaypoints;
|
||||||
INT32 key;
|
INT32 key;
|
||||||
|
|
||||||
actor->z += hackoffset;
|
actor->z += hackoffset;
|
||||||
|
@ -12726,7 +12726,7 @@ void A_Boss5FindWaypoint(mobj_t *actor)
|
||||||
continue;
|
continue;
|
||||||
if (!P_CheckSight(actor, mapthings[i].mobj))
|
if (!P_CheckSight(actor, mapthings[i].mobj))
|
||||||
continue;
|
continue;
|
||||||
numwaypoints++;
|
numfangwaypoints++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// players also count as waypoints apparently
|
// players also count as waypoints apparently
|
||||||
|
@ -12748,11 +12748,11 @@ void A_Boss5FindWaypoint(mobj_t *actor)
|
||||||
continue;
|
continue;
|
||||||
if (!P_CheckSight(actor, players[i].mo))
|
if (!P_CheckSight(actor, players[i].mo))
|
||||||
continue;
|
continue;
|
||||||
numwaypoints++;
|
numfangwaypoints++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!numwaypoints)
|
if (!numfangwaypoints)
|
||||||
{
|
{
|
||||||
// restore z position
|
// restore z position
|
||||||
actor->z -= hackoffset;
|
actor->z -= hackoffset;
|
||||||
|
@ -12760,8 +12760,8 @@ void A_Boss5FindWaypoint(mobj_t *actor)
|
||||||
}
|
}
|
||||||
|
|
||||||
// allocate the table and reset count to zero
|
// allocate the table and reset count to zero
|
||||||
waypoints = Z_Calloc(sizeof(*waypoints)*numwaypoints, PU_STATIC, NULL);
|
fangwaypoints = Z_Calloc(sizeof(*waypoints)*numfangwaypoints, PU_STATIC, NULL);
|
||||||
numwaypoints = 0;
|
numfangwaypoints = 0;
|
||||||
|
|
||||||
// now find them again and add them to the table!
|
// now find them again and add them to the table!
|
||||||
for (i = 0; i < nummapthings; i++)
|
for (i = 0; i < nummapthings; i++)
|
||||||
|
@ -12786,7 +12786,7 @@ void A_Boss5FindWaypoint(mobj_t *actor)
|
||||||
}
|
}
|
||||||
if (!P_CheckSight(actor, mapthings[i].mobj))
|
if (!P_CheckSight(actor, mapthings[i].mobj))
|
||||||
continue;
|
continue;
|
||||||
waypoints[numwaypoints++] = mapthings[i].mobj;
|
fangwaypoints[numfangwaypoints++] = mapthings[i].mobj;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (actor->extravalue2 > 1)
|
if (actor->extravalue2 > 1)
|
||||||
|
@ -12807,25 +12807,25 @@ void A_Boss5FindWaypoint(mobj_t *actor)
|
||||||
continue;
|
continue;
|
||||||
if (!P_CheckSight(actor, players[i].mo))
|
if (!P_CheckSight(actor, players[i].mo))
|
||||||
continue;
|
continue;
|
||||||
waypoints[numwaypoints++] = players[i].mo;
|
fangwaypoints[numfangwaypoints++] = players[i].mo;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// restore z position
|
// restore z position
|
||||||
actor->z -= hackoffset;
|
actor->z -= hackoffset;
|
||||||
|
|
||||||
if (!numwaypoints)
|
if (!numfangwaypoints)
|
||||||
{
|
{
|
||||||
Z_Free(waypoints); // free table
|
Z_Free(fangwaypoints); // free table
|
||||||
goto nowaypoints; // ???
|
goto nowaypoints; // ???
|
||||||
}
|
}
|
||||||
|
|
||||||
key = P_RandomKey(numwaypoints);
|
key = P_RandomKey(numfangwaypoints);
|
||||||
|
|
||||||
P_SetTarget(&actor->tracer, waypoints[key]);
|
P_SetTarget(&actor->tracer, fangwaypoints[key]);
|
||||||
if (actor->tracer->type == MT_FANGWAYPOINT)
|
if (actor->tracer->type == MT_FANGWAYPOINT)
|
||||||
actor->tracer->reactiontime = numwaypoints/4; // Monster Iestyn: is this how it should be? I count center waypoints as waypoints unlike the original Lua script
|
actor->tracer->reactiontime = numfangwaypoints/4; // Monster Iestyn: is this how it should be? I count center waypoints as waypoints unlike the original Lua script
|
||||||
Z_Free(waypoints); // free table
|
Z_Free(fangwaypoints); // free table
|
||||||
}
|
}
|
||||||
|
|
||||||
// now face the tracer you just set!
|
// now face the tracer you just set!
|
||||||
|
|
|
@ -12678,9 +12678,14 @@ static boolean P_SetupSpawnedMapThing(mapthing_t *mthing, mobj_t *mobj, boolean
|
||||||
mobj->threshold = min(mthing->extrainfo, 7);
|
mobj->threshold = min(mthing->extrainfo, 7);
|
||||||
break;
|
break;
|
||||||
case MT_TUBEWAYPOINT:
|
case MT_TUBEWAYPOINT:
|
||||||
mobj->health = mthing->angle & 255;
|
{
|
||||||
mobj->threshold = mthing->angle >> 8;
|
UINT8 sequence = mthing->angle >> 8;
|
||||||
|
UINT8 id = mthing->angle & 255;
|
||||||
|
mobj->health = id;
|
||||||
|
mobj->threshold = sequence;
|
||||||
|
P_AddWaypoint(sequence, id, mobj);
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case MT_IDEYAANCHOR:
|
case MT_IDEYAANCHOR:
|
||||||
mobj->health = mthing->extrainfo;
|
mobj->health = mthing->extrainfo;
|
||||||
break;
|
break;
|
||||||
|
|
196
src/p_polyobj.c
196
src/p_polyobj.c
|
@ -1571,10 +1571,8 @@ void T_PolyObjMove(polymove_t *th)
|
||||||
|
|
||||||
void T_PolyObjWaypoint(polywaypoint_t *th)
|
void T_PolyObjWaypoint(polywaypoint_t *th)
|
||||||
{
|
{
|
||||||
mobj_t *mo2;
|
|
||||||
mobj_t *target = NULL;
|
mobj_t *target = NULL;
|
||||||
mobj_t *waypoint = NULL;
|
mobj_t *waypoint = NULL;
|
||||||
thinker_t *wp;
|
|
||||||
fixed_t adjustx, adjusty, adjustz;
|
fixed_t adjustx, adjusty, adjustz;
|
||||||
fixed_t momx, momy, momz, dist;
|
fixed_t momx, momy, momz, dist;
|
||||||
INT32 start;
|
INT32 start;
|
||||||
|
@ -1593,30 +1591,9 @@ void T_PolyObjWaypoint(polywaypoint_t *th)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// check for displacement due to override and reattach when possible
|
// check for displacement due to override and reattach when possible
|
||||||
if (po->thinker == NULL)
|
if (!po->thinker)
|
||||||
po->thinker = &th->thinker;
|
po->thinker = &th->thinker;
|
||||||
|
|
||||||
/*
|
|
||||||
// Find out target first.
|
|
||||||
// We redo this each tic to make savegame compatibility easier.
|
|
||||||
for (wp = thlist[THINK_MOBJ].next; wp != &thlist[THINK_MOBJ]; wp = wp->next)
|
|
||||||
{
|
|
||||||
if (wp->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
mo2 = (mobj_t *)wp;
|
|
||||||
|
|
||||||
if (mo2->type != MT_TUBEWAYPOINT)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (mo2->threshold == th->sequence && mo2->health == th->pointnum)
|
|
||||||
{
|
|
||||||
target = mo2;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
target = th->target;
|
target = th->target;
|
||||||
|
|
||||||
if (!target)
|
if (!target)
|
||||||
|
@ -1683,38 +1660,7 @@ void T_PolyObjWaypoint(polywaypoint_t *th)
|
||||||
if (!th->stophere)
|
if (!th->stophere)
|
||||||
{
|
{
|
||||||
CONS_Debug(DBG_POLYOBJ, "Looking for next waypoint...\n");
|
CONS_Debug(DBG_POLYOBJ, "Looking for next waypoint...\n");
|
||||||
|
waypoint = (th->direction == -1) ? P_GetPreviousWaypoint(target, false) : P_GetNextWaypoint(target, false);
|
||||||
// Find next waypoint
|
|
||||||
for (wp = thlist[THINK_MOBJ].next; wp != &thlist[THINK_MOBJ]; wp = wp->next)
|
|
||||||
{
|
|
||||||
if (wp->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
mo2 = (mobj_t *)wp;
|
|
||||||
|
|
||||||
if (mo2->type != MT_TUBEWAYPOINT)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (mo2->threshold != th->sequence)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (th->direction == -1)
|
|
||||||
{
|
|
||||||
if (mo2->health == target->health - 1)
|
|
||||||
{
|
|
||||||
waypoint = mo2;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (mo2->health == target->health + 1)
|
|
||||||
{
|
|
||||||
waypoint = mo2;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!waypoint && th->wrap) // If specified, wrap waypoints
|
if (!waypoint && th->wrap) // If specified, wrap waypoints
|
||||||
{
|
{
|
||||||
|
@ -1724,35 +1670,7 @@ void T_PolyObjWaypoint(polywaypoint_t *th)
|
||||||
th->stophere = true;
|
th->stophere = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (wp = thlist[THINK_MOBJ].next; wp != &thlist[THINK_MOBJ]; wp = wp->next)
|
waypoint = (th->direction == -1) ? P_GetLastWaypoint(th->sequence) : P_GetFirstWaypoint(th->sequence);
|
||||||
{
|
|
||||||
if (wp->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
mo2 = (mobj_t *)wp;
|
|
||||||
|
|
||||||
if (mo2->type != MT_TUBEWAYPOINT)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (mo2->threshold != th->sequence)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (th->direction == -1)
|
|
||||||
{
|
|
||||||
if (waypoint == NULL)
|
|
||||||
waypoint = mo2;
|
|
||||||
else if (mo2->health > waypoint->health)
|
|
||||||
waypoint = mo2;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (mo2->health == 0)
|
|
||||||
{
|
|
||||||
waypoint = mo2;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if (!waypoint && th->comeback) // Come back to the start
|
else if (!waypoint && th->comeback) // Come back to the start
|
||||||
{
|
{
|
||||||
|
@ -1761,36 +1679,7 @@ void T_PolyObjWaypoint(polywaypoint_t *th)
|
||||||
if (!th->continuous)
|
if (!th->continuous)
|
||||||
th->comeback = false;
|
th->comeback = false;
|
||||||
|
|
||||||
for (wp = thlist[THINK_MOBJ].next; wp != &thlist[THINK_MOBJ]; wp = wp->next)
|
waypoint = (th->direction == -1) ? P_GetPreviousWaypoint(target, false) : P_GetNextWaypoint(target, false);
|
||||||
{
|
|
||||||
if (wp->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
mo2 = (mobj_t *)wp;
|
|
||||||
|
|
||||||
if (mo2->type != MT_TUBEWAYPOINT)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (mo2->threshold != th->sequence)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (th->direction == -1)
|
|
||||||
{
|
|
||||||
if (mo2->health == target->health - 1)
|
|
||||||
{
|
|
||||||
waypoint = mo2;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (mo2->health == target->health + 1)
|
|
||||||
{
|
|
||||||
waypoint = mo2;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2276,11 +2165,9 @@ boolean EV_DoPolyObjWaypoint(polywaypointdata_t *pwdata)
|
||||||
{
|
{
|
||||||
polyobj_t *po;
|
polyobj_t *po;
|
||||||
polywaypoint_t *th;
|
polywaypoint_t *th;
|
||||||
mobj_t *mo2;
|
|
||||||
mobj_t *first = NULL;
|
mobj_t *first = NULL;
|
||||||
mobj_t *last = NULL;
|
mobj_t *last = NULL;
|
||||||
mobj_t *target = NULL;
|
mobj_t *target = NULL;
|
||||||
thinker_t *wp;
|
|
||||||
|
|
||||||
if (!(po = Polyobj_GetForNum(pwdata->polyObjNum)))
|
if (!(po = Polyobj_GetForNum(pwdata->polyObjNum)))
|
||||||
{
|
{
|
||||||
|
@ -2305,10 +2192,7 @@ boolean EV_DoPolyObjWaypoint(polywaypointdata_t *pwdata)
|
||||||
th->polyObjNum = pwdata->polyObjNum;
|
th->polyObjNum = pwdata->polyObjNum;
|
||||||
th->speed = pwdata->speed;
|
th->speed = pwdata->speed;
|
||||||
th->sequence = pwdata->sequence; // Used to specify sequence #
|
th->sequence = pwdata->sequence; // Used to specify sequence #
|
||||||
if (pwdata->reverse)
|
th->direction = pwdata->reverse ? -1 : 1;
|
||||||
th->direction = -1;
|
|
||||||
else
|
|
||||||
th->direction = 1;
|
|
||||||
|
|
||||||
th->comeback = pwdata->comeback;
|
th->comeback = pwdata->comeback;
|
||||||
th->continuous = pwdata->continuous;
|
th->continuous = pwdata->continuous;
|
||||||
|
@ -2316,44 +2200,8 @@ boolean EV_DoPolyObjWaypoint(polywaypointdata_t *pwdata)
|
||||||
th->stophere = false;
|
th->stophere = false;
|
||||||
|
|
||||||
// Find the first waypoint we need to use
|
// Find the first waypoint we need to use
|
||||||
for (wp = thlist[THINK_MOBJ].next; wp != &thlist[THINK_MOBJ]; wp = wp->next)
|
first = (th->direction == -1) ? P_GetLastWaypoint(th->sequence) : P_GetFirstWaypoint(th->sequence);
|
||||||
{
|
last = (th->direction == -1) ? P_GetFirstWaypoint(th->sequence) : P_GetLastWaypoint(th->sequence);
|
||||||
if (wp->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
mo2 = (mobj_t *)wp;
|
|
||||||
|
|
||||||
if (mo2->type != MT_TUBEWAYPOINT)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (mo2->threshold != th->sequence)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (th->direction == -1) // highest waypoint #
|
|
||||||
{
|
|
||||||
if (mo2->health == 0)
|
|
||||||
last = mo2;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (first == NULL)
|
|
||||||
first = mo2;
|
|
||||||
else if (mo2->health > first->health)
|
|
||||||
first = mo2;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else // waypoint 0
|
|
||||||
{
|
|
||||||
if (mo2->health == 0)
|
|
||||||
first = mo2;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (last == NULL)
|
|
||||||
last = mo2;
|
|
||||||
else if (mo2->health > last->health)
|
|
||||||
last = mo2;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!first)
|
if (!first)
|
||||||
{
|
{
|
||||||
|
@ -2387,36 +2235,6 @@ boolean EV_DoPolyObjWaypoint(polywaypointdata_t *pwdata)
|
||||||
|
|
||||||
// Find the actual target movement waypoint
|
// Find the actual target movement waypoint
|
||||||
target = first;
|
target = first;
|
||||||
/*for (wp = thlist[THINK_MOBJ].next; wp != &thlist[THINK_MOBJ]; wp = wp->next)
|
|
||||||
{
|
|
||||||
if (wp->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
mo2 = (mobj_t *)wp;
|
|
||||||
|
|
||||||
if (mo2->type != MT_TUBEWAYPOINT)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (mo2->threshold != th->sequence)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (th->direction == -1) // highest waypoint #
|
|
||||||
{
|
|
||||||
if (mo2->health == first->health - 1)
|
|
||||||
{
|
|
||||||
target = mo2;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else // waypoint 0
|
|
||||||
{
|
|
||||||
if (mo2->health == first->health + 1)
|
|
||||||
{
|
|
||||||
target = mo2;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
|
|
||||||
if (!target)
|
if (!target)
|
||||||
{
|
{
|
||||||
|
|
|
@ -144,6 +144,101 @@ mapthing_t *playerstarts[MAXPLAYERS];
|
||||||
mapthing_t *bluectfstarts[MAXPLAYERS];
|
mapthing_t *bluectfstarts[MAXPLAYERS];
|
||||||
mapthing_t *redctfstarts[MAXPLAYERS];
|
mapthing_t *redctfstarts[MAXPLAYERS];
|
||||||
|
|
||||||
|
// Maintain waypoints
|
||||||
|
mobj_t *waypoints[NUMWAYPOINTSEQUENCES][WAYPOINTSEQUENCESIZE];
|
||||||
|
UINT16 numwaypoints[NUMWAYPOINTSEQUENCES];
|
||||||
|
|
||||||
|
void P_AddWaypoint(UINT8 sequence, UINT8 id, mobj_t *waypoint)
|
||||||
|
{
|
||||||
|
waypoints[sequence][id] = waypoint;
|
||||||
|
if (id >= numwaypoints[sequence])
|
||||||
|
numwaypoints[sequence] = id + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void P_ResetWaypoints(void)
|
||||||
|
{
|
||||||
|
UINT16 sequence, id;
|
||||||
|
for (sequence = 0; sequence < NUMWAYPOINTSEQUENCES; sequence++)
|
||||||
|
{
|
||||||
|
for (id = 0; id < numwaypoints[sequence]; id++)
|
||||||
|
waypoints[sequence][id] = NULL;
|
||||||
|
|
||||||
|
numwaypoints[sequence] = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
mobj_t *P_GetFirstWaypoint(UINT8 sequence)
|
||||||
|
{
|
||||||
|
return waypoints[sequence][0];
|
||||||
|
}
|
||||||
|
|
||||||
|
mobj_t *P_GetLastWaypoint(UINT8 sequence)
|
||||||
|
{
|
||||||
|
return waypoints[sequence][numwaypoints[sequence] - 1];
|
||||||
|
}
|
||||||
|
|
||||||
|
mobj_t *P_GetPreviousWaypoint(mobj_t *current, boolean wrap)
|
||||||
|
{
|
||||||
|
UINT8 sequence = current->threshold;
|
||||||
|
UINT8 id = current->health;
|
||||||
|
|
||||||
|
if (id == 0)
|
||||||
|
{
|
||||||
|
if (!wrap)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
id = numwaypoints[sequence] - 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
id--;
|
||||||
|
|
||||||
|
return waypoints[sequence][id];
|
||||||
|
}
|
||||||
|
|
||||||
|
mobj_t *P_GetNextWaypoint(mobj_t *current, boolean wrap)
|
||||||
|
{
|
||||||
|
UINT8 sequence = current->threshold;
|
||||||
|
UINT8 id = current->health;
|
||||||
|
|
||||||
|
if (id == numwaypoints[sequence] - 1)
|
||||||
|
{
|
||||||
|
if (!wrap)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
id = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
id++;
|
||||||
|
|
||||||
|
return waypoints[sequence][id];
|
||||||
|
}
|
||||||
|
|
||||||
|
mobj_t *P_GetClosestWaypoint(UINT8 sequence, mobj_t *mo)
|
||||||
|
{
|
||||||
|
UINT8 wp;
|
||||||
|
mobj_t *mo2, *result = NULL;
|
||||||
|
fixed_t bestdist = 0;
|
||||||
|
fixed_t curdist;
|
||||||
|
|
||||||
|
for (wp = 0; wp < numwaypoints[sequence]; wp++)
|
||||||
|
{
|
||||||
|
mo2 = waypoints[sequence][wp];
|
||||||
|
|
||||||
|
if (!mo2)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
curdist = P_AproxDistance(P_AproxDistance(mo->x - mo2->x, mo->y - mo2->y), mo->z - mo2->z);
|
||||||
|
|
||||||
|
if (result && curdist > bestdist)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
result = mo2;
|
||||||
|
bestdist = curdist;
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
/** Logs an error about a map being corrupt, then terminate.
|
/** Logs an error about a map being corrupt, then terminate.
|
||||||
* This allows reporting highly technical errors for usefulness, without
|
* This allows reporting highly technical errors for usefulness, without
|
||||||
* confusing a novice map designer who simply needs to run ZenNode.
|
* confusing a novice map designer who simply needs to run ZenNode.
|
||||||
|
@ -3545,6 +3640,8 @@ boolean P_LoadLevel(boolean fromnetsave)
|
||||||
|
|
||||||
P_ResetSpawnpoints();
|
P_ResetSpawnpoints();
|
||||||
|
|
||||||
|
P_ResetWaypoints();
|
||||||
|
|
||||||
P_MapStart();
|
P_MapStart();
|
||||||
|
|
||||||
if (!P_LoadMapFromFile())
|
if (!P_LoadMapFromFile())
|
||||||
|
|
140
src/p_spec.c
140
src/p_spec.c
|
@ -4799,9 +4799,7 @@ DoneSection2:
|
||||||
INT32 sequence;
|
INT32 sequence;
|
||||||
fixed_t speed;
|
fixed_t speed;
|
||||||
INT32 lineindex;
|
INT32 lineindex;
|
||||||
thinker_t *th;
|
|
||||||
mobj_t *waypoint = NULL;
|
mobj_t *waypoint = NULL;
|
||||||
mobj_t *mo2;
|
|
||||||
angle_t an;
|
angle_t an;
|
||||||
|
|
||||||
if (player->mo->tracer && player->mo->tracer->type == MT_TUBEWAYPOINT && player->powers[pw_carry] == CR_ZOOMTUBE)
|
if (player->mo->tracer && player->mo->tracer->type == MT_TUBEWAYPOINT && player->powers[pw_carry] == CR_ZOOMTUBE)
|
||||||
|
@ -4826,25 +4824,7 @@ DoneSection2:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// scan the thinkers
|
waypoint = P_GetFirstWaypoint(sequence);
|
||||||
// to find the first 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)
|
|
||||||
continue;
|
|
||||||
if (mo2->health != 0)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
waypoint = mo2;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!waypoint)
|
if (!waypoint)
|
||||||
{
|
{
|
||||||
|
@ -4881,9 +4861,7 @@ DoneSection2:
|
||||||
INT32 sequence;
|
INT32 sequence;
|
||||||
fixed_t speed;
|
fixed_t speed;
|
||||||
INT32 lineindex;
|
INT32 lineindex;
|
||||||
thinker_t *th;
|
|
||||||
mobj_t *waypoint = NULL;
|
mobj_t *waypoint = NULL;
|
||||||
mobj_t *mo2;
|
|
||||||
angle_t an;
|
angle_t an;
|
||||||
|
|
||||||
if (player->mo->tracer && player->mo->tracer->type == MT_TUBEWAYPOINT && player->powers[pw_carry] == CR_ZOOMTUBE)
|
if (player->mo->tracer && player->mo->tracer->type == MT_TUBEWAYPOINT && player->powers[pw_carry] == CR_ZOOMTUBE)
|
||||||
|
@ -4908,25 +4886,7 @@ DoneSection2:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// scan the thinkers
|
waypoint = P_GetLastWaypoint(sequence);
|
||||||
// to find the last 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)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (!waypoint)
|
|
||||||
waypoint = mo2;
|
|
||||||
else if (mo2->health > waypoint->health)
|
|
||||||
waypoint = mo2;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!waypoint)
|
if (!waypoint)
|
||||||
{
|
{
|
||||||
|
@ -5008,14 +4968,11 @@ DoneSection2:
|
||||||
INT32 sequence;
|
INT32 sequence;
|
||||||
fixed_t speed;
|
fixed_t speed;
|
||||||
INT32 lineindex;
|
INT32 lineindex;
|
||||||
thinker_t *th;
|
|
||||||
mobj_t *waypointmid = NULL;
|
mobj_t *waypointmid = NULL;
|
||||||
mobj_t *waypointhigh = NULL;
|
mobj_t *waypointhigh = NULL;
|
||||||
mobj_t *waypointlow = NULL;
|
mobj_t *waypointlow = NULL;
|
||||||
mobj_t *mo2;
|
|
||||||
mobj_t *closest = NULL;
|
mobj_t *closest = NULL;
|
||||||
vector3_t p, line[2], resulthigh, resultlow;
|
vector3_t p, line[2], resulthigh, resultlow;
|
||||||
mobj_t *highest = NULL;
|
|
||||||
|
|
||||||
if (player->mo->tracer && player->mo->tracer->type == MT_TUBEWAYPOINT && player->powers[pw_carry] == CR_ROPEHANG)
|
if (player->mo->tracer && player->mo->tracer->type == MT_TUBEWAYPOINT && player->powers[pw_carry] == CR_ROPEHANG)
|
||||||
break;
|
break;
|
||||||
|
@ -5061,98 +5018,16 @@ DoneSection2:
|
||||||
// Determine the closest spot on the line between the three waypoints
|
// Determine the closest spot on the line between the three waypoints
|
||||||
// Put player at that location.
|
// Put player at that location.
|
||||||
|
|
||||||
// scan the thinkers
|
waypointmid = P_GetClosestWaypoint(sequence, player->mo);
|
||||||
// to find the first 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 (!waypointmid)
|
||||||
|
|
||||||
if (mo2->type != MT_TUBEWAYPOINT)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (mo2->threshold != sequence)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (!highest)
|
|
||||||
highest = mo2;
|
|
||||||
else if (mo2->health > highest->health) // Find the highest waypoint # in case we wrap
|
|
||||||
highest = mo2;
|
|
||||||
|
|
||||||
if (closest && P_AproxDistance(P_AproxDistance(player->mo->x-mo2->x, player->mo->y-mo2->y),
|
|
||||||
player->mo->z-mo2->z) > P_AproxDistance(P_AproxDistance(player->mo->x-closest->x,
|
|
||||||
player->mo->y-closest->y), player->mo->z-closest->z))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
// Found a target
|
|
||||||
closest = mo2;
|
|
||||||
}
|
|
||||||
|
|
||||||
waypointmid = closest;
|
|
||||||
|
|
||||||
closest = NULL;
|
|
||||||
|
|
||||||
if (waypointmid == NULL)
|
|
||||||
{
|
{
|
||||||
CONS_Debug(DBG_GAMELOGIC, "ERROR: WAYPOINT(S) IN SEQUENCE %d NOT FOUND.\n", sequence);
|
CONS_Debug(DBG_GAMELOGIC, "ERROR: WAYPOINT(S) IN SEQUENCE %d NOT FOUND.\n", sequence);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Find waypoint before this one (waypointlow)
|
waypointlow = P_GetPreviousWaypoint(waypointmid, true);
|
||||||
for (th = thlist[THINK_MOBJ].next; th != &thlist[THINK_MOBJ]; th = th->next)
|
waypointhigh = P_GetNextWaypoint(waypointmid, true);
|
||||||
{
|
|
||||||
if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
mo2 = (mobj_t *)th;
|
|
||||||
|
|
||||||
if (mo2->type != MT_TUBEWAYPOINT)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (mo2->threshold != sequence)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (waypointmid->health == 0)
|
|
||||||
{
|
|
||||||
if (mo2->health != highest->health)
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
else if (mo2->health != waypointmid->health - 1)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
// Found a target
|
|
||||||
waypointlow = mo2;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Find waypoint after this one (waypointhigh)
|
|
||||||
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)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (waypointmid->health == highest->health)
|
|
||||||
{
|
|
||||||
if (mo2->health != 0)
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
else if (mo2->health != waypointmid->health + 1)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
// Found a target
|
|
||||||
waypointhigh = mo2;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
CONS_Debug(DBG_GAMELOGIC, "WaypointMid: %d; WaypointLow: %d; WaypointHigh: %d\n",
|
CONS_Debug(DBG_GAMELOGIC, "WaypointMid: %d; WaypointLow: %d; WaypointHigh: %d\n",
|
||||||
waypointmid->health, waypointlow ? waypointlow->health : -1, waypointhigh ? waypointhigh->health : -1);
|
waypointmid->health, waypointlow ? waypointlow->health : -1, waypointhigh ? waypointhigh->health : -1);
|
||||||
|
@ -5199,6 +5074,7 @@ DoneSection2:
|
||||||
|
|
||||||
if (lines[lineindex].flags & ML_EFFECT1) // Don't wrap
|
if (lines[lineindex].flags & ML_EFFECT1) // Don't wrap
|
||||||
{
|
{
|
||||||
|
mobj_t *highest = P_GetLastWaypoint(sequence);
|
||||||
highest->flags |= MF_SLIDEME;
|
highest->flags |= MF_SLIDEME;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5210,7 +5086,7 @@ DoneSection2:
|
||||||
player->mo->y = resulthigh.y;
|
player->mo->y = resulthigh.y;
|
||||||
player->mo->z = resulthigh.z - P_GetPlayerHeight(player);
|
player->mo->z = resulthigh.z - P_GetPlayerHeight(player);
|
||||||
}
|
}
|
||||||
else if ((lines[lineindex].flags & ML_EFFECT1) && waypointmid->health == highest->health)
|
else if ((lines[lineindex].flags & ML_EFFECT1) && waypointmid->health == numwaypoints[sequence] - 1)
|
||||||
{
|
{
|
||||||
closest = waypointmid;
|
closest = waypointmid;
|
||||||
player->mo->x = resultlow.x;
|
player->mo->x = resultlow.x;
|
||||||
|
|
70
src/p_user.c
70
src/p_user.c
|
@ -8709,10 +8709,7 @@ static void P_MovePlayer(player_t *player)
|
||||||
|
|
||||||
static void P_DoZoomTube(player_t *player)
|
static void P_DoZoomTube(player_t *player)
|
||||||
{
|
{
|
||||||
INT32 sequence;
|
|
||||||
fixed_t speed;
|
fixed_t speed;
|
||||||
thinker_t *th;
|
|
||||||
mobj_t *mo2;
|
|
||||||
mobj_t *waypoint = NULL;
|
mobj_t *waypoint = NULL;
|
||||||
fixed_t dist;
|
fixed_t dist;
|
||||||
boolean reverse;
|
boolean reverse;
|
||||||
|
@ -8728,8 +8725,6 @@ static void P_DoZoomTube(player_t *player)
|
||||||
|
|
||||||
speed = abs(player->speed);
|
speed = abs(player->speed);
|
||||||
|
|
||||||
sequence = player->mo->tracer->threshold;
|
|
||||||
|
|
||||||
// change slope
|
// change slope
|
||||||
dist = P_AproxDistance(P_AproxDistance(player->mo->tracer->x - player->mo->x, player->mo->tracer->y - player->mo->y), player->mo->tracer->z - player->mo->z);
|
dist = P_AproxDistance(P_AproxDistance(player->mo->tracer->x - player->mo->x, player->mo->tracer->y - player->mo->y), player->mo->tracer->z - player->mo->z);
|
||||||
|
|
||||||
|
@ -8761,28 +8756,7 @@ static void P_DoZoomTube(player_t *player)
|
||||||
CONS_Debug(DBG_GAMELOGIC, "Looking for next waypoint...\n");
|
CONS_Debug(DBG_GAMELOGIC, "Looking for next waypoint...\n");
|
||||||
|
|
||||||
// Find next waypoint
|
// Find next waypoint
|
||||||
for (th = thlist[THINK_MOBJ].next; th != &thlist[THINK_MOBJ]; th = th->next)
|
waypoint = reverse ? P_GetPreviousWaypoint(player->mo->tracer, false) : P_GetNextWaypoint(player->mo->tracer, false);
|
||||||
{
|
|
||||||
if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
mo2 = (mobj_t *)th;
|
|
||||||
|
|
||||||
if (mo2->type != MT_TUBEWAYPOINT)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (mo2->threshold != sequence)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (reverse && mo2->health != player->mo->tracer->health - 1)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (!reverse && mo2->health != player->mo->tracer->health + 1)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
waypoint = mo2;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (waypoint)
|
if (waypoint)
|
||||||
{
|
{
|
||||||
|
@ -8833,8 +8807,6 @@ static void P_DoRopeHang(player_t *player)
|
||||||
{
|
{
|
||||||
INT32 sequence;
|
INT32 sequence;
|
||||||
fixed_t speed;
|
fixed_t speed;
|
||||||
thinker_t *th;
|
|
||||||
mobj_t *mo2;
|
|
||||||
mobj_t *waypoint = NULL;
|
mobj_t *waypoint = NULL;
|
||||||
fixed_t dist;
|
fixed_t dist;
|
||||||
fixed_t playerz;
|
fixed_t playerz;
|
||||||
|
@ -8897,50 +8869,14 @@ static void P_DoRopeHang(player_t *player)
|
||||||
CONS_Debug(DBG_GAMELOGIC, "Looking for next waypoint...\n");
|
CONS_Debug(DBG_GAMELOGIC, "Looking for next waypoint...\n");
|
||||||
|
|
||||||
// Find next waypoint
|
// Find next waypoint
|
||||||
for (th = thlist[THINK_MOBJ].next; th != &thlist[THINK_MOBJ]; th = th->next)
|
waypoint = P_GetNextWaypoint(player->mo->tracer, false);
|
||||||
{
|
|
||||||
if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
mo2 = (mobj_t *)th;
|
|
||||||
|
|
||||||
if (mo2->type != MT_TUBEWAYPOINT)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (mo2->threshold != sequence)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (mo2->health != player->mo->tracer->health + 1)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
waypoint = mo2;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!(player->mo->tracer->flags & MF_SLIDEME) && !waypoint)
|
if (!(player->mo->tracer->flags & MF_SLIDEME) && !waypoint)
|
||||||
{
|
{
|
||||||
CONS_Debug(DBG_GAMELOGIC, "Next waypoint not found, wrapping to start...\n");
|
CONS_Debug(DBG_GAMELOGIC, "Next waypoint not found, wrapping to start...\n");
|
||||||
|
|
||||||
// Wrap around back to first waypoint
|
// Wrap around back to first waypoint
|
||||||
for (th = thlist[THINK_MOBJ].next; th != &thlist[THINK_MOBJ]; th = th->next)
|
waypoint = P_GetFirstWaypoint(sequence);
|
||||||
{
|
|
||||||
if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
mo2 = (mobj_t *)th;
|
|
||||||
|
|
||||||
if (mo2->type != MT_TUBEWAYPOINT)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (mo2->threshold != sequence)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (mo2->health != 0)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
waypoint = mo2;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (waypoint)
|
if (waypoint)
|
||||||
|
|
Loading…
Reference in New Issue