From ea7ad31fefbd62157c3f04879fa16680ba7f7b4d Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Sat, 26 Aug 2023 20:28:50 -0400 Subject: [PATCH] Add Radius Action thing Thing type 4096, activates its action when a player enters the specified radius --- src/deh_tables.c | 2 ++ src/info.c | 27 +++++++++++++++++++++++++++ src/info.h | 2 ++ src/p_mobj.c | 43 +++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 74 insertions(+) diff --git a/src/deh_tables.c b/src/deh_tables.c index e51e2e878..e39a910cb 100644 --- a/src/deh_tables.c +++ b/src/deh_tables.c @@ -5810,6 +5810,8 @@ const char *const MOBJTYPE_LIST[] = { // array length left dynamic for sanity t "MT_BATTLEUFO_BEAM", "MT_POWERUP_AURA", + + "MT_SCRIPT_THING", }; const char *const MOBJFLAG_LIST[] = { diff --git a/src/info.c b/src/info.c index a1fca74c2..6db8ffdf1 100644 --- a/src/info.c +++ b/src/info.c @@ -30313,6 +30313,33 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = MF_NOBLOCKMAP|MF_NOGRAVITY|MF_NOCLIPHEIGHT|MF_SCENERY, // flags S_NULL // raisestate }, + + { // MT_SCRIPT_THING + 4096, // doomednum + S_INVISIBLE, // spawnstate + 1000, // spawnhealth + S_NULL, // seestate + sfx_None, // seesound + 0, // reactiontime + sfx_None, // attacksound + S_NULL, // painstate + 0, // painchance + sfx_None, // painsound + S_NULL, // meleestate + S_NULL, // missilestate + S_NULL, // deathstate + S_NULL, // xdeathstate + sfx_None, // deathsound + 0, // speed + 16*FRACUNIT, // radius + 16*FRACUNIT, // height + 0, // display offset + 0, // mass + 0, // damage + sfx_None, // activesound + MF_NOBLOCKMAP|MF_NOCLIP|MF_NOCLIPHEIGHT|MF_NOCLIPTHING|MF_NOGRAVITY|MF_SCENERY, // flags + S_NULL // raisestate + }, }; skincolor_t skincolors[MAXSKINCOLORS] = { diff --git a/src/info.h b/src/info.h index dec72563c..c7a3c2e02 100644 --- a/src/info.h +++ b/src/info.h @@ -7000,6 +7000,8 @@ typedef enum mobj_type MT_POWERUP_AURA, + MT_SCRIPT_THING, + MT_FIRSTFREESLOT, MT_LASTFREESLOT = MT_FIRSTFREESLOT + NUMMOBJFREESLOTS - 1, NUMMOBJTYPES diff --git a/src/p_mobj.c b/src/p_mobj.c index 1e6a797d1..bd000ffb1 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -6716,6 +6716,49 @@ static void P_MobjSceneryThink(mobj_t *mobj) case MT_ARKARROW: Obj_ArkArrowThink(mobj); break; + case MT_SCRIPT_THING: + { + if (mobj->thing_args[2] != 0) + { + // turned off + break; + } + + UINT8 i; + for (i = 0; i < MAXPLAYERS; i++) + { + if (playeringame[i] == false) + { + continue; + } + + player_t *player = &players[i]; + if (P_MobjWasRemoved(player->mo) == true) + { + continue; + } + + fixed_t dist = R_PointToDist2( + mobj->x, mobj->y, + player->mo->x, player->mo->y + ); + + if (dist < mobj->thing_args[0] * FRACUNIT) + { + P_ActivateThingSpecial(mobj, player->mo); + + if (mobj->thing_args[1] == 0) + { + P_RemoveMobj(mobj); + return; + } + + break; + } + } + + break; + } case MT_VWREF: case MT_VWREB: {