From dc024b874bb631006211d2fb35cab9930f2b342c Mon Sep 17 00:00:00 2001 From: James R Date: Sun, 19 Mar 2023 03:52:25 -0700 Subject: [PATCH] Morph Drop Target from forward thrown white to lime Blends from white into lime over 27 tics. --- src/deh_tables.c | 1 + src/info.c | 27 ++++++++++++++++ src/info.h | 1 + src/k_objects.h | 4 +++ src/objects/CMakeLists.txt | 1 + src/objects/drop-target.c | 64 ++++++++++++++++++++++++++++++++++++++ src/p_mobj.c | 12 +++++++ 7 files changed, 110 insertions(+) create mode 100644 src/objects/drop-target.c diff --git a/src/deh_tables.c b/src/deh_tables.c index 57ef8d885..66271a5f4 100644 --- a/src/deh_tables.c +++ b/src/deh_tables.c @@ -5380,6 +5380,7 @@ const char *const MOBJTYPE_LIST[] = { // array length left dynamic for sanity t "MT_DROPTARGET", // Drop Target "MT_DROPTARGET_SHIELD", + "MT_DROPTARGET_MORPH", "MT_BALLHOG", // Ballhog "MT_BALLHOGBOOM", diff --git a/src/info.c b/src/info.c index b462a8ba9..ccada9b07 100644 --- a/src/info.c +++ b/src/info.c @@ -23722,6 +23722,33 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = S_NULL // raisestate }, + { // MT_DROPTARGET_MORPH + -1, // doomednum + S_DROPTARGET, // spawnstate + 1, // 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 + 45*FRACUNIT, // radius + 32*FRACUNIT, // height + 0, // display offset + 100, // mass + 1, // damage + sfx_None, // activesound + MF_SCENERY|MF_NOBLOCKMAP|MF_NOCLIP|MF_NOGRAVITY|MF_DONTENCOREMAP, // flags + S_NULL // raisestate + }, + { // MT_BALLHOG -1, // doomednum S_BALLHOG1, // spawnstate diff --git a/src/info.h b/src/info.h index 3a1921b3c..f7496fc14 100644 --- a/src/info.h +++ b/src/info.h @@ -6452,6 +6452,7 @@ typedef enum mobj_type MT_DROPTARGET, // Drop Target MT_DROPTARGET_SHIELD, + MT_DROPTARGET_MORPH, MT_BALLHOG, // Ballhog MT_BALLHOGBOOM, diff --git a/src/k_objects.h b/src/k_objects.h index 922764c94..1578d8177 100644 --- a/src/k_objects.h +++ b/src/k_objects.h @@ -101,6 +101,10 @@ void Obj_InitLoopCenter(mobj_t *center); void Obj_LinkLoopAnchor(mobj_t *anchor, mobj_t *center, UINT8 type); void Obj_LoopEndpointCollide(mobj_t *special, mobj_t *toucher); +/* Drop Target */ +void Obj_BeginDropTargetMorph(mobj_t *target, skincolornum_t color); +boolean Obj_DropTargetMorphThink(mobj_t *morph); + #ifdef __cplusplus } // extern "C" #endif diff --git a/src/objects/CMakeLists.txt b/src/objects/CMakeLists.txt index ca8680205..ef74b299f 100644 --- a/src/objects/CMakeLists.txt +++ b/src/objects/CMakeLists.txt @@ -13,4 +13,5 @@ target_sources(SRB2SDL2 PRIVATE monitor.c item-spot.c loops.c + drop-target.c ) diff --git a/src/objects/drop-target.c b/src/objects/drop-target.c new file mode 100644 index 000000000..1f81289f4 --- /dev/null +++ b/src/objects/drop-target.c @@ -0,0 +1,64 @@ +#include "../doomdef.h" +#include "../info.h" +#include "../k_objects.h" +#include "../p_local.h" + +#define MORPH_TIME_FACTOR (3) + +#define morph_target(o) ((o)->target) +#define morph_time(o) ((o)->extravalue1) + +void +Obj_BeginDropTargetMorph +( mobj_t * target, + skincolornum_t color) +{ + mobj_t *x = P_SpawnMobjFromMobj(target, 0, 0, 0, + MT_DROPTARGET_MORPH); + + x->color = color; + x->colorized = true; + x->renderflags |= RF_FULLBRIGHT; + + P_SetTarget(&morph_target(x), target); + + morph_time(x) = tr_trans90 * MORPH_TIME_FACTOR; + + x->health = target->health; +} + +boolean +Obj_DropTargetMorphThink (mobj_t *x) +{ + mobj_t *target = morph_target(x); + + if (P_MobjWasRemoved(target)) + { + P_RemoveMobj(x); + return false; + } + + if (target->health != x->health) + { + P_RemoveMobj(x); + return false; + } + + morph_time(x)--; + + if (morph_time(x) <= 0) + { + target->health--; + target->color = x->color; + + P_RemoveMobj(x); + return false; + } + + x->renderflags = (x->renderflags & ~(RF_TRANSMASK)) + | ((morph_time(x) / MORPH_TIME_FACTOR) << RF_TRANSSHIFT); + + P_MoveOrigin(x, target->x, target->y, target->z); + + return true; +} diff --git a/src/p_mobj.c b/src/p_mobj.c index f1990a186..5dc21dd38 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -6618,6 +6618,12 @@ static void P_MobjSceneryThink(mobj_t *mobj) case MT_MONITOR_SHARD: Obj_MonitorShardThink(mobj); break; + case MT_DROPTARGET_MORPH: + if (Obj_DropTargetMorphThink(mobj) == false) + { + return; + } + break; case MT_VWREF: case MT_VWREB: { @@ -7416,6 +7422,12 @@ static boolean P_MobjRegularThink(mobj_t *mobj) if (!--mobj->reactiontime) { P_SetMobjState(mobj, mobj->info->spawnstate); + + // forward thrown + if (mobj->health == 4) + { + Obj_BeginDropTargetMorph(mobj, SKINCOLOR_LIME); + } } } else