From 8db84ffef9c6da8a845d8c07158a2adb40772651 Mon Sep 17 00:00:00 2001 From: MascaraSnake Date: Mon, 27 Dec 2021 15:37:21 +0100 Subject: [PATCH] Adapt boss waypoint to UDMF --- extras/conf/udb/Includes/SRB222_things.cfg | 8 +++ src/p_enemy.c | 24 +++------ src/p_mobj.c | 62 +++++++++------------- src/p_setup.c | 5 ++ 4 files changed, 44 insertions(+), 55 deletions(-) diff --git a/extras/conf/udb/Includes/SRB222_things.cfg b/extras/conf/udb/Includes/SRB222_things.cfg index 31d6b794d..318981f18 100644 --- a/extras/conf/udb/Includes/SRB222_things.cfg +++ b/extras/conf/udb/Includes/SRB222_things.cfg @@ -4142,6 +4142,14 @@ udmf width = 8; height = 16; sprite = "internal:eggmanway"; + arg0 + { + title = "Sea Egg sequence"; + } + arg1 + { + title = "Brak Eggman sequence"; + } } 293 { diff --git a/src/p_enemy.c b/src/p_enemy.c index 5d7cacb36..7e00ad91d 100644 --- a/src/p_enemy.c +++ b/src/p_enemy.c @@ -8114,10 +8114,6 @@ void A_Boss3TakeDamage(mobj_t *actor) actor->movecount = var1; actor->movefactor = -512*FRACUNIT; - - /*if (actor->target && actor->target->spawnpoint) - actor->threshold = actor->target->spawnpoint->extrainfo;*/ - } // Function: A_Boss3Path @@ -8157,27 +8153,21 @@ void A_Boss3Path(mobj_t *actor) if (!(actor->flags2 & MF2_STRONGBOX)) { - thinker_t *th; mobj_t *mo2; + INT32 i; P_SetTarget(&actor->target, NULL); - // scan the thinkers - // to find a point that matches - // the number - for (th = thlist[THINK_MOBJ].next; th != &thlist[THINK_MOBJ]; th = th->next) + // Find waypoint + TAG_ITER_THINGS(actor->cusval, i) { - if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) - continue; + mo2 = mapthings[i].mobj; - mo2 = (mobj_t *)th; + if (!mo2) + continue; if (mo2->type != MT_BOSS3WAYPOINT) continue; - if (!mo2->spawnpoint) - continue; - if (mo2->spawnpoint->angle != actor->threshold) - continue; - if (mo2->spawnpoint->extrainfo != actor->cusval) + if (mapthings[i].args[0] != actor->threshold) continue; P_SetTarget(&actor->target, mo2); diff --git a/src/p_mobj.c b/src/p_mobj.c index 406519e22..b1b9db68a 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -4520,27 +4520,21 @@ static void P_Boss3Thinker(mobj_t *mobj) if (!(mobj->flags2 & MF2_STRONGBOX)) { - thinker_t *th; mobj_t *mo2; + INT32 i; P_SetTarget(&mobj->tracer, NULL); - // scan the thinkers - // to find a point that matches - // the number - for (th = thlist[THINK_MOBJ].next; th != &thlist[THINK_MOBJ]; th = th->next) + // Find waypoint + TAG_ITER_THINGS(mobj->cusval, i) { - if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) - continue; + mo2 = mapthings[i].mobj; - mo2 = (mobj_t *)th; + if (!mo2) + continue; if (mo2->type != MT_BOSS3WAYPOINT) continue; - if (!mo2->spawnpoint) - continue; - if (mo2->spawnpoint->angle != mobj->threshold) - continue; - if (mo2->spawnpoint->extrainfo != mobj->cusval) + if (mapthings[i].args[0] != mobj->threshold) continue; P_SetTarget(&mobj->tracer, mo2); @@ -5283,8 +5277,7 @@ static void P_Boss7Thinker(mobj_t *mobj) fixed_t vertical, horizontal; fixed_t airtime = 5*TICRATE; INT32 waypointNum = 0; - thinker_t *th; - INT32 i; + INT32 i, j; boolean foundgoop = false; INT32 closestNum; UINT8 bossid = (mobj->spawnpoint ? mobj->spawnpoint->args[0] : 0); @@ -5307,19 +5300,15 @@ static void P_Boss7Thinker(mobj_t *mobj) closestdist = INT32_MAX; // Just in case... // Find waypoint he is closest to - for (th = thlist[THINK_MOBJ].next; th != &thlist[THINK_MOBJ]; th = th->next) + TAG_ITER_THINGS(bossid, j) { - if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) - continue; + mo2 = mapthings[j].mobj; - mo2 = (mobj_t *)th; + if (!mo2) + continue; if (mo2->type != MT_BOSS3WAYPOINT) continue; - if (!mo2->spawnpoint) - continue; - if (mo2->spawnpoint->extrainfo != bossid) - continue; - if (mobj->health <= mobj->info->damage && !(mo2->spawnpoint->options & 7)) + if (mobj->health <= mobj->info->damage && !mapthings[j].args[1]) continue; // don't jump to center dist = P_AproxDistance(players[i].mo->x - mo2->x, players[i].mo->y - mo2->y); @@ -5327,7 +5316,7 @@ static void P_Boss7Thinker(mobj_t *mobj) if (!(closestNum == -1 || dist < closestdist)) continue; - closestNum = (mo2->spawnpoint->options & 7); + closestNum = mapthings[j].args[1]; closestdist = dist; foundgoop = true; } @@ -5347,7 +5336,7 @@ static void P_Boss7Thinker(mobj_t *mobj) } if (mobj->tracer && mobj->tracer->type == MT_BOSS3WAYPOINT - && mobj->tracer->spawnpoint && (mobj->tracer->spawnpoint->options & 7) == waypointNum) + && mobj->tracer->spawnpoint && mobj->tracer->spawnpoint->args[1] == waypointNum) { if (P_RandomChance(FRACUNIT/2)) waypointNum++; @@ -5360,28 +5349,25 @@ static void P_Boss7Thinker(mobj_t *mobj) waypointNum = ((waypointNum + 5) % 5); } - // scan the thinkers to find - // the waypoint to use - for (th = thlist[THINK_MOBJ].next; th != &thlist[THINK_MOBJ]; th = th->next) + // Scan mapthings to find the waypoint to use + TAG_ITER_THINGS(bossid, i) { - if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) + mo2 = mapthings[i].mobj; + + if (!mo2) continue; - mo2 = (mobj_t *)th; if (mo2->type != MT_BOSS3WAYPOINT) continue; - if (!mo2->spawnpoint) - continue; - if ((mo2->spawnpoint->options & 7) != waypointNum) - continue; - if (mo2->spawnpoint->extrainfo != bossid) + + if (mapthings[i].args[1] != waypointNum) continue; hitspot = mo2; break; } - if (hitspot == NULL) + if (!hitspot) { CONS_Debug(DBG_GAMELOGIC, "BlackEggman unable to find waypoint #%d!\n", waypointNum); P_SetMobjState(mobj, mobj->info->spawnstate); @@ -12735,7 +12721,7 @@ static boolean P_SetupSpawnedMapThing(mapthing_t *mthing, mobj_t *mobj, boolean } break; case MT_EGGMOBILE3: - mobj->cusval = mthing->extrainfo; + mobj->cusval = mthing->args[0]; break; case MT_FAN: if (mthing->options & MTF_OBJECTSPECIAL) diff --git a/src/p_setup.c b/src/p_setup.c index 7fe66148f..c9237bef8 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -3131,6 +3131,7 @@ static void P_AddBinaryMapTags(void) Tag_FSet(&mapthings[i].tags, mapthings[i].angle); break; case 290: + case 292: case 294: case 780: Tag_FSet(&mapthings[i].tags, mapthings[i].extrainfo); @@ -4936,6 +4937,10 @@ static void P_ConvertBinaryMap(void) case 209: //Brak Eggman mapthings[i].args[4] = LE_BRAKVILEATACK + mapthings[i].extrainfo*LE_PARAMWIDTH; break; + case 292: //Boss waypoint + mapthings[i].args[0] = mapthings[i].angle; + mapthings[i].args[1] = mapthings[i].options & 7; + break; case 294: mapthings[i].args[0] = !!(mapthings[i].options & MTF_AMBUSH); break;