From e71a952d709bdca005234b4d91aaa81c5bf27980 Mon Sep 17 00:00:00 2001 From: MascaraSnake <jonassauer27@gmail.com> Date: Tue, 28 Dec 2021 17:54:26 +0100 Subject: [PATCH] Adapt monitors to UDMF --- extras/conf/udb/Includes/SRB222_misc.cfg | 7 ++ extras/conf/udb/Includes/SRB222_things.cfg | 110 +++++++++++++++++++++ src/p_enemy.c | 8 +- src/p_mobj.c | 56 ++++------- src/p_setup.c | 20 +++- src/p_spec.h | 7 ++ 6 files changed, 166 insertions(+), 42 deletions(-) diff --git a/extras/conf/udb/Includes/SRB222_misc.cfg b/extras/conf/udb/Includes/SRB222_misc.cfg index dbcd226298..3547266cb2 100644 --- a/extras/conf/udb/Includes/SRB222_misc.cfg +++ b/extras/conf/udb/Includes/SRB222_misc.cfg @@ -590,6 +590,13 @@ enums 2 = "Immovable"; 3 = "Classic"; } + + monitorrespawn + { + 0 = "Same item"; + 1 = "Random (Weak)"; + 2 = "Random (Strong)"; + } } //Default things filters diff --git a/extras/conf/udb/Includes/SRB222_things.cfg b/extras/conf/udb/Includes/SRB222_things.cfg index 02d90eacfe..ab1ce5ad5a 100644 --- a/extras/conf/udb/Includes/SRB222_things.cfg +++ b/extras/conf/udb/Includes/SRB222_things.cfg @@ -4472,56 +4472,131 @@ udmf title = "Monitors"; width = 18; height = 40; + arg0 + { + title = "Death trigger tag"; + type = 15; + } 400 { title = "Super Ring (10 Rings)"; sprite = "TVRIA0"; + arg1 + { + title = "Respawn behavior"; + type = 11; + enum = "monitorrespawn"; + } } 401 { title = "Pity Shield"; sprite = "TVPIA0"; + arg1 + { + title = "Respawn behavior"; + type = 11; + enum = "monitorrespawn"; + } } 402 { title = "Attraction Shield"; sprite = "TVATA0"; + arg1 + { + title = "Respawn behavior"; + type = 11; + enum = "monitorrespawn"; + } } 403 { title = "Force Shield"; sprite = "TVFOA0"; + arg1 + { + title = "Respawn behavior"; + type = 11; + enum = "monitorrespawn"; + } } 404 { title = "Armageddon Shield"; sprite = "TVARA0"; + arg1 + { + title = "Respawn behavior"; + type = 11; + enum = "monitorrespawn"; + } } 405 { title = "Whirlwind Shield"; sprite = "TVWWA0"; + arg1 + { + title = "Respawn behavior"; + type = 11; + enum = "monitorrespawn"; + } } 406 { title = "Elemental Shield"; sprite = "TVELA0"; + arg1 + { + title = "Respawn behavior"; + type = 11; + enum = "monitorrespawn"; + } } 407 { title = "Super Sneakers"; sprite = "TVSSA0"; + arg1 + { + title = "Respawn behavior"; + type = 11; + enum = "monitorrespawn"; + } } 408 { title = "Invincibility"; sprite = "TVIVA0"; + arg1 + { + title = "Respawn behavior"; + type = 11; + enum = "monitorrespawn"; + } } 409 { title = "Extra Life"; sprite = "TV1UA0"; + arg1 + { + title = "Respawn behavior"; + type = 11; + enum = "monitorrespawn"; + } + arg2 + { + title = "Points"; + type = 11; + enum + { + 0 = "1,000"; + 1 = "10,000"; + } + } } 410 { @@ -4532,6 +4607,12 @@ udmf { title = "Teleporter"; sprite = "TVMXA0"; + arg1 + { + title = "Respawn behavior"; + type = 11; + enum = "monitorrespawn"; + } } 413 { @@ -4552,6 +4633,12 @@ udmf { title = "Recycler"; sprite = "TVRCA0"; + arg1 + { + title = "Respawn behavior"; + type = 11; + enum = "monitorrespawn"; + } } 418 { @@ -4567,16 +4654,34 @@ udmf { title = "Flame Shield"; sprite = "TVFLA0"; + arg1 + { + title = "Respawn behavior"; + type = 11; + enum = "monitorrespawn"; + } } 421 { title = "Water Shield"; sprite = "TVBBA0"; + arg1 + { + title = "Respawn behavior"; + type = 11; + enum = "monitorrespawn"; + } } 422 { title = "Lightning Shield"; sprite = "TVZPA0"; + arg1 + { + title = "Respawn behavior"; + type = 11; + enum = "monitorrespawn"; + } } } @@ -4587,6 +4692,11 @@ udmf title = "Monitors (Respawning)"; width = 20; height = 44; + arg0 + { + title = "Death trigger tag"; + type = 15; + } 431 { diff --git a/src/p_enemy.c b/src/p_enemy.c index e077b39261..bbbb9495f3 100644 --- a/src/p_enemy.c +++ b/src/p_enemy.c @@ -3717,8 +3717,8 @@ void A_MonitorPop(mobj_t *actor) // Run a linedef executor immediately upon popping // You may want to delay your effects by 18 tics to sync with the reward giving - if (actor->spawnpoint && actor->lastlook) - P_LinedefExecute(actor->lastlook, actor->target, NULL); + if (actor->spawnpoint && actor->spawnpoint->args[0]) + P_LinedefExecute(actor->spawnpoint->args[0], actor->target, NULL); } // Function: A_GoldMonitorPop @@ -3803,8 +3803,8 @@ void A_GoldMonitorPop(mobj_t *actor) // Run a linedef executor immediately upon popping // You may want to delay your effects by 18 tics to sync with the reward giving - if (actor->spawnpoint && actor->lastlook) - P_LinedefExecute(actor->lastlook, actor->target, NULL); + if (actor->spawnpoint && actor->spawnpoint->args[0]) + P_LinedefExecute(actor->spawnpoint->args[0], actor->target, NULL); } // Function: A_GoldMonitorRestore diff --git a/src/p_mobj.c b/src/p_mobj.c index fa3bba57a8..09c518fe78 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -12033,7 +12033,7 @@ static mobjtype_t P_GetMobjtypeSubstitute(mapthing_t *mthing, mobjtype_t i) case 2: // Unchanging if (i == MT_MYSTERY_BOX) return MT_NULL; // don't spawn - mthing->options &= ~(MTF_AMBUSH|MTF_OBJECTSPECIAL); // no random respawning! + mthing->args[1] = TMMR_SAME; // no random respawning! return i; case 3: // Don't spawn return MT_NULL; @@ -12063,8 +12063,7 @@ static mobjtype_t P_GetMobjtypeSubstitute(mapthing_t *mthing, mobjtype_t i) if (modeattacking && i == MT_1UP_BOX) // 1UPs -->> Score TVs { - // Either or, doesn't matter which. - if (mthing->options & (MTF_AMBUSH | MTF_OBJECTSPECIAL)) + if (mthing->args[2]) return MT_SCORE10K_BOX; // 10,000 else return MT_SCORE1K_BOX; // 1,000 @@ -13157,22 +13156,27 @@ static boolean P_SetupSpawnedMapThing(mapthing_t *mthing, mobj_t *mobj, boolean if (mthing->args[0]) mobj->flags2 |= MF2_AMBUSH; } - + if ((mobj->flags & MF_MONITOR) && mobj->info->speed != 0) + { + switch (mthing->args[1]) + { + case TMMR_SAME: + default: + break; + case TMMR_WEAK: + mobj->flags2 |= MF2_AMBUSH; + break; + case TMMR_STRONG: + mobj->flags2 |= MF2_STRONGBOX; + } + } return true; } static void P_SetAmbush(mobj_t *mobj) { - if ((mobj->flags & MF_MONITOR) && mobj->info->speed != 0) - { - // flag for strong/weak random boxes - // any monitor with nonzero speed is allowed to respawn like this - mobj->flags2 |= MF2_AMBUSH; - } - - //TODO: Make this obsolete - else if (mobj->type != MT_AXIS && + if (mobj->type != MT_AXIS && mobj->type != MT_AXISTRANSFER && mobj->type != MT_AXISTRANSFERLINE && mobj->type != MT_NIGHTSBUMPER && @@ -13198,20 +13202,11 @@ static void P_SetAmbush(mobj_t *mobj) mobj->type != MT_MINECARTSWITCHPOINT && mobj->type != MT_ROLLOUTSPAWN && mobj->type != MT_STARPOST && - !(mobj->flags & MF_SPRING && mobj->info->painchance == 3)) + !((mobj->flags & MF_SPRING) && mobj->info->painchance == 3) && + !((mobj->flags & MF_MONITOR) && mobj->info->speed != 0)) mobj->flags2 |= MF2_AMBUSH; } -static void P_SetObjectSpecial(mobj_t *mobj) -{ - if ((mobj->flags & MF_MONITOR) && mobj->info->speed != 0) - { - // flag for strong/weak random boxes - // any monitor with nonzero speed is allowed to respawn like this - mobj->flags2 |= MF2_STRONGBOX; - } -} - static mobj_t *P_SpawnMobjFromMapThing(mapthing_t *mthing, fixed_t x, fixed_t y, fixed_t z, mobjtype_t i) { mobj_t *mobj = NULL; @@ -13241,9 +13236,6 @@ static mobj_t *P_SpawnMobjFromMapThing(mapthing_t *mthing, fixed_t x, fixed_t y, if (mthing->options & MTF_AMBUSH) P_SetAmbush(mobj); - if (mthing->options & MTF_OBJECTSPECIAL) - P_SetObjectSpecial(mobj); - // Generic reverse gravity for individual objects flag. if (mthing->options & MTF_OBJECTFLIP) { @@ -13251,16 +13243,6 @@ static mobj_t *P_SpawnMobjFromMapThing(mapthing_t *mthing, fixed_t x, fixed_t y, mobj->flags2 |= MF2_OBJECTFLIP; } - // Extra functionality - if (mthing->options & MTF_EXTRA) - { - if (mobj->flags & MF_MONITOR && (mthing->angle & 16384)) - { - // Store line exec tag to run upon popping - mobj->lastlook = (mthing->angle & 16383); - } - } - // Final set of not being able to draw nightsitems. if (mobj->flags & MF_NIGHTSITEM) mobj->flags2 |= MF2_DONTDRAW; diff --git a/src/p_setup.c b/src/p_setup.c index c267167fed..0f92347677 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -4914,8 +4914,23 @@ static void P_ConvertBinaryMap(void) else mapthings[i].args[0] = TMP_NORMAL; } - if (mobjinfo[mobjtype].flags & MF_SPRING && mobjinfo[mobjtype].painchance == 3) + if ((mobjinfo[mobjtype].flags & MF_SPRING) && mobjinfo[mobjtype].painchance == 3) mapthings[i].args[0] = !!(mapthings[i].options & MTF_AMBUSH); + if (mobjinfo[mobjtype].flags & MF_MONITOR) + { + if ((mapthings[i].options & MTF_EXTRA) && mapthings[i].angle & 16384) + mapthings[i].args[0] = mapthings[i].angle & 16383; + + if (mobjinfo[mobjtype].speed != 0) + { + if (mapthings[i].options & MTF_OBJECTSPECIAL) + mapthings[i].args[1] = TMMR_STRONG; + else if (mapthings[i].options & MTF_AMBUSH) + mapthings[i].args[1] = TMMR_WEAK; + else + mapthings[i].args[1] = TMMR_SAME; + } + } } if (mapthings[i].type >= 1 && mapthings[i].type <= 35) //Player starts @@ -5024,6 +5039,9 @@ static void P_ConvertBinaryMap(void) case 1800: //Coin mapthings[i].args[0] = !(mapthings[i].options & MTF_AMBUSH); break; + case 409: //Extra life monitor + mapthings[i].args[2] = !(mapthings[i].options & (MTF_AMBUSH|MTF_OBJECTSPECIAL)); + break; case 500: //Air bubble patch mapthings[i].args[0] = !!(mapthings[i].options & MTF_AMBUSH); break; diff --git a/src/p_spec.h b/src/p_spec.h index 0fc7c6ee10..994db8cf46 100644 --- a/src/p_spec.h +++ b/src/p_spec.h @@ -103,6 +103,13 @@ typedef enum TMED_LEFT = 2, } textmapeggrobodirection_t; +typedef enum +{ + TMMR_SAME = 0, + TMMR_WEAK = 1, + TMMR_STRONG = 2, +} textmapmonitorrespawn_t; + //FOF flags typedef enum { -- GitLab