From 3ae8623ebb98f51ac93517d24fd4444b75e33bfe Mon Sep 17 00:00:00 2001 From: Sryder13 Date: Sun, 12 Nov 2017 01:10:02 +0000 Subject: [PATCH] Waypoint Spawning Uses object MT_WAYPOINT, mapthing type 2001 Placing one by itself will always place it on the floor or ceiling (depending on object flip) Placing one alongside another that uses Object Special will make the original use the z height of the 2nd Angle will be used to determine the waypoint's ID Z Height (threshold on mobjs) will be used to determine the ID of the previous waypoint Waypoints with the Ambush Flag will be unable to be respawned at (reactiontime on mobjs internally) --- src/info.c | 4 ++-- src/p_mobj.c | 38 ++++++++++++++++++++++++++++++++++++++ src/p_setup.c | 24 ++++++++++++++++++++++++ 3 files changed, 64 insertions(+), 2 deletions(-) diff --git a/src/info.c b/src/info.c index 0c2416133..e8a75f565 100644 --- a/src/info.c +++ b/src/info.c @@ -15195,7 +15195,7 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = { // MT_WAYPOINT 2001, // doomednum - S_NULL, // spawnstate + S_UNKNOWN, // spawnstate 1000, // spawnhealth S_NULL, // seestate sfx_None, // seesound @@ -15216,7 +15216,7 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = 100, // mass 0, // damage sfx_None, // activesound - MF_NOBLOCKMAP|MF_NOSECTOR|MF_NOCLIP|MF_NOGRAVITY, // flags + MF_NOBLOCKMAP/*|MF_NOSECTOR*/|MF_NOCLIP|MF_NOGRAVITY, // flags S_NULL // raisestate }, diff --git a/src/p_mobj.c b/src/p_mobj.c index db812519d..2fae94040 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -9641,6 +9641,26 @@ void P_SpawnMapThing(mapthing_t *mthing) else mthing->z = (INT16)(z>>FRACBITS); } + else if (i == MT_WAYPOINT && !(mthing->options & MTF_OBJECTSPECIAL)) + { + // just gets set on either the floor or ceiling + boolean flip = (!!(mobjinfo[i].flags & MF_SPAWNCEILING) ^ !!(mthing->options & MTF_OBJECTFLIP)); + + // applying offsets! (if any) + if (flip) + { + z = ONCEILINGZ; + } + else + { + z = ONFLOORZ; + } + + if (z == ONFLOORZ) + mthing->z = 0; + else + mthing->z = (INT16)(z>>FRACBITS); + } else { fixed_t offset = 0; @@ -9893,6 +9913,24 @@ ML_NOCLIMB : Direction not controllable case MT_TRAPGOYLELONG: if (mthing->angle >= 360) mobj->tics += 7*(mthing->angle / 360) + 1; // starting delay + break; + case MT_WAYPOINT: + if (!(mthing->options & MTF_OBJECTSPECIAL)) + { + // Z is already altered to account for proper height + // Use threshold to store the previous waypoint ID + // Angle is being used for the current waypoint ID + mobj->threshold = ((mthing->options >> ZSHIFT)); + } + if (mthing->options & MTF_AMBUSH) + { + mobj->reactiontime = 1; + } + else + { + mobj->reactiontime = 0; + } + break; default: break; } diff --git a/src/p_setup.c b/src/p_setup.c index e91acab69..913796253 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -915,6 +915,24 @@ void P_ScanThings(INT16 mapnum, INT16 wadnum, INT16 lumpnum) } #endif +static void P_SetWaypointsHeight(mapthing_t *mt) +{ + mapthing_t *mt2 = mapthings; + size_t i; + for (i = 0; i < nummapthings; i++, mt2++) + { + if (!(mt2->type == mobjinfo[MT_WAYPOINT].doomednum && (mt2->options & MTF_OBJECTSPECIAL))) + continue; + + if (mt->angle == mt2->angle) // same waypoint id + { + mt->z = mt2->z; + mt->mobj->z = mt2->mobj->z; + P_RemoveMobj(mt2->mobj); + } + } +} + // // P_LoadThings // @@ -1050,6 +1068,12 @@ static void P_LoadThings(void) P_SpawnHoopsAndRings (mt); } + + if (mt->type == mobjinfo[MT_WAYPOINT].doomednum && !(mt->options & MTF_OBJECTSPECIAL)) + { + // use any "2nd" waypoint mobjs to set the height of original, then remove the 2nds mobjs + P_SetWaypointsHeight(mt); + } } }