Add "twinkle" lens flare to emeralds

- Battle: plays once the orbiting collection animation
  finishes and the player's emerald flags are updated
  - Centered on the player

- Sealed Star: plays as soon as the orbiting animation
  begins
  - Centered on the emerald
This commit is contained in:
James R 2023-08-19 03:40:17 -07:00
parent dd7f6b17dd
commit 4857d48633
6 changed files with 111 additions and 0 deletions

View file

@ -1208,6 +1208,8 @@ const char *const STATE_LIST[] = { // array length left dynamic for sanity testi
"S_EMERALDSPARK6",
"S_EMERALDSPARK7",
"S_EMERALDFLARE1",
// Emerald hunt shards
"S_SHRD1",
"S_SHRD2",
@ -4807,6 +4809,7 @@ const char *const MOBJTYPE_LIST[] = { // array length left dynamic for sanity t
"MT_EMBLEM",
"MT_EMERALD",
"MT_EMERALDSPARK",
"MT_EMERALDFLARE",
"MT_EMERHUNT", // Emerald Hunt
"MT_EMERALDSPAWN", // Emerald spawner w/ delay

View file

@ -1878,6 +1878,8 @@ state_t states[NUMSTATES] =
{SPR_ESPK, FF_FULLBRIGHT|5, 3, {NULL}, 0, 0, S_EMERALDSPARK7}, // S_EMERALDSPARK6
{SPR_ESPK, FF_FULLBRIGHT|6, 3, {NULL}, 0, 0, S_NULL}, // S_EMERALDSPARK7
{SPR_LENS, FF_FULLBRIGHT|FF_ADD|FF_TRANS10|FF_ANIMATE|11, 8, {NULL}, 7, 1, S_GAINAX_MID2}, // S_EMERALDFLARE1
// Emerald hunt shards
{SPR_SHRD, 0, -1, {NULL}, 0, 0, S_NULL}, // S_SHRD1
{SPR_SHRD, 1, -1, {NULL}, 0, 0, S_NULL}, // S_SHRD2
@ -8330,6 +8332,33 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] =
S_NULL // raisestate
},
{ // MT_EMERALDFLARE
-1, // doomednum
S_INVISIBLE, // spawnstate
1000, // spawnhealth
S_NULL, // seestate
sfx_None, // seesound
8, // 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
8*FRACUNIT, // radius
8*FRACUNIT, // height
0, // display offset
16, // mass
0, // damage
sfx_None, // activesound
MF_NOBLOCKMAP|MF_NOGRAVITY|MF_NOCLIP|MF_NOCLIPHEIGHT|MF_DONTENCOREMAP, // flags
S_NULL // raisestate
},
{ // MT_EMERHUNT
320, // doomednum
S_SHRD1, // spawnstate

View file

@ -2362,6 +2362,8 @@ typedef enum state
S_EMERALDSPARK6,
S_EMERALDSPARK7,
S_EMERALDFLARE1,
// Emerald hunt shards
S_SHRD1,
S_SHRD2,
@ -5996,6 +5998,7 @@ typedef enum mobj_type
MT_EMBLEM,
MT_EMERALD,
MT_EMERALDSPARK,
MT_EMERALDFLARE,
MT_EMERHUNT, // Emerald Hunt
MT_EMERALDSPAWN, // Emerald spawner w/ delay

View file

@ -207,6 +207,7 @@ void Obj_SneakerPanelCollide(mobj_t *pad, mobj_t *mo);
/* Emerald */
void Obj_SpawnEmeraldSparks(mobj_t *source);
void Obj_EmeraldThink(mobj_t *emerald);
void Obj_EmeraldFlareThink(mobj_t *flare);
void Obj_BeginEmeraldOrbit(mobj_t *emerald, mobj_t *target, fixed_t radius, INT32 revolution_time, tic_t fuse);
void Obj_GiveEmerald(mobj_t *emerald);

View file

@ -1,5 +1,6 @@
#include "../k_battle.h"
#include "../k_objects.h"
#include "../k_specialstage.h"
#include "../info.h"
#include "../m_random.h"
#include "../p_local.h"
@ -163,6 +164,70 @@ void Obj_EmeraldThink(mobj_t *emerald)
K_BattleOvertimeKiller(emerald);
}
void Obj_EmeraldFlareThink(mobj_t *flare)
{
const INT32 kExtraTics = 3;
const INT32 flare_tics = states[S_EMERALDFLARE1].tics + kExtraTics;
if (P_MobjWasRemoved(flare->target))
{
P_RemoveMobj(flare);
return;
}
// Target is assumed to be the emerald in orbit. When
// emerald fuse runs out, it shall update player's emerald
// flags. Time the flare animation so it ends with the
// emerald fuse.
if (!flare->fuse && flare->target->fuse > flare_tics)
{
return;
}
if (flare->state == &states[S_INVISIBLE])
{
// In special stages, just follow the emerald.
if (specialstageinfo.valid == false)
{
// Update target to player. We don't need to track
// the emerald anymore.
P_SetTarget(&flare->target, flare->target->target);
if (P_MobjWasRemoved(flare->target))
{
P_RemoveMobj(flare);
return;
}
}
P_SetMobjState(flare, S_EMERALDFLARE1);
flare->fuse = flare_tics;
}
// Focus on center of player.
P_SetOrigin(flare, flare->target->x, flare->target->y, center_of(flare->target));
}
static void spawn_lens_flare(mobj_t *emerald)
{
mobj_t *flare = P_SpawnMobjFromMobj(emerald, 0, 0, 0, MT_EMERALDFLARE);
P_SetTarget(&flare->target, emerald);
P_InstaScale(flare, emerald->target->scale);
flare->color = emerald->color;
flare->colorized = true;
flare->renderflags |= RF_ALWAYSONTOP;
// FIXME: linkdraw doesn't work consistently, so I drew it on top of everyting (and through walls)
#if 0
P_SetTarget(&flare->tracer, emerald->target);
flare->flags2 |= MF2_LINKDRAW;
flare->dispoffset = 1000;
#endif
}
void Obj_BeginEmeraldOrbit(mobj_t *emerald, mobj_t *target, fixed_t radius, INT32 revolution_time, tic_t fuse)
{
P_SetTarget(&emerald->target, target);
@ -185,6 +250,8 @@ void Obj_BeginEmeraldOrbit(mobj_t *emerald, mobj_t *target, fixed_t radius, INT3
emerald->flags |= MF_NOGRAVITY | MF_NOCLIP | MF_NOCLIPTHING | MF_NOCLIPHEIGHT;
emerald->shadowscale = 0;
spawn_lens_flare(emerald);
}
void Obj_GiveEmerald(mobj_t *emerald)

View file

@ -7551,6 +7551,14 @@ static boolean P_MobjRegularThink(mobj_t *mobj)
case MT_EMERALD:
Obj_EmeraldThink(mobj);
if (P_MobjWasRemoved(mobj))
{
return false;
}
break;
case MT_EMERALDFLARE:
Obj_EmeraldFlareThink(mobj);
if (P_MobjWasRemoved(mobj))
{
return false;