- Duke: fixed the explosion's lighting hackery.

The animatesprites handler in the old code got called on the already animated sprite, meaning it will only activate for the first frame.
To do this right the code had to be moved to applyanimations and be guarded by a flag.
This commit is contained in:
Christoph Oelckers 2023-09-10 20:42:26 +02:00
parent b9eced0d11
commit a41ebfeb73
6 changed files with 14 additions and 27 deletions

View file

@ -199,6 +199,7 @@ static FFlagDef DukeActorFlagDefs[] =
DEFINE_FLAG(SFLAG3, NOSHOTGUNBLOOD, DDukeActor, flags3),
DEFINE_FLAG(SFLAG4, DOUBLEHITDAMAGE, DDukeActor, flags4),
DEFINE_FLAG(SFLAG4, NODAMAGETURN, DDukeActor, flags4),
DEFINE_FLAG(SFLAG4, FLASHFRAME0, DDukeActor, flags4),
};

View file

@ -214,6 +214,16 @@ void applyanimations(tspritetype* t, DDukeActor* h, const DVector2& viewVec, DAn
}
else if (display_mirror == 1)
t->cstat |= CSTAT_SPRITE_XFLIP;
if (h->flags4 & SFLAG4_FLASHFRAME0)
{
if (t->spritetexture() == h->spr.spritetexture())
{
ps[screenpeek].visibility = -127;
lastvisinc = PlayClock + 32;
}
}
}
}
END_DUKE_NS

View file

@ -450,6 +450,7 @@ enum sflags4_t
SFLAG4_NODAMAGETURN = 0x00000002,
SFLAG4_CONOVERRIDE = 0x00000004, // this is strictly internal
SFLAG4_INRUNSTATE = 0x00000008, // exception throwing guard.
SFLAG4_FLASHFRAME0 = 0x00000010, // lousy hack for Duke's explosion.
};
using EDukeFlags4 = TFlags<sflags4_t, uint32_t>;

View file

@ -189,19 +189,6 @@ DEFINE_ACTION_FUNCTION_NATIVE(_Duke, getPlayerIndex, getPlayerIndex)
ACTION_RETURN_INT(getPlayerIndex(p));
}
void setlastvisinc(int v)
{
lastvisinc = PlayClock + v;
}
DEFINE_ACTION_FUNCTION_NATIVE(_Duke, setlastvisinc, setlastvisinc)
{
PARAM_PROLOGUE;
PARAM_INT(v);
setlastvisinc(v);
return 0;
}
int Duke_isaccessswitch(int texint)
{
return isaccessswitch(FSetTextureID(texint));

View file

@ -30,16 +30,10 @@ class DukeExplosion2 : DukeActor
+FULLBRIGHT;
+FORCERUNCON;
+TRIGGER_IFHITSECTOR;
+FLASHFRAME0;
Strength 1;
}
override bool animate(tspritetype t)
{
Duke.GetViewPlayer().visibility = -127;
Duke.setlastvisinc(32);
return false;
}
override void Initialize(DukeActor spawner)
{
if (spawner && spawner != self)
@ -71,13 +65,8 @@ class DukeExplosion2Bot : DukeExplosion2
{
pic "EXPLOSION2BOT";
-TRIGGER_IFHITSECTOR;
-FLASHFRAME0;
}
override bool animate(tspritetype t)
{
return false;
}
}
//---------------------------------------------------------------------------

View file

@ -177,7 +177,6 @@ struct Duke native
native static bool StartCommentary(int tag, DukeActor act);
native static void StopCommentary();
static native int getPlayerIndex(DukePlayer p);
static native void setlastvisinc(int amount);
static native bool isaccessswitch(TextureID tex);
static native bool isshootableswitch(TextureID tex);
static native bool CheckSprite(class<DukeActor> tex);