diff --git a/src/thingdef/thingdef_codeptr.cpp b/src/thingdef/thingdef_codeptr.cpp index df4861f721..7d22f11d78 100644 --- a/src/thingdef/thingdef_codeptr.cpp +++ b/src/thingdef/thingdef_codeptr.cpp @@ -1810,11 +1810,13 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_FadeIn) ACTION_PARAM_START(1); ACTION_PARAM_FIXED(reduce, 0); - if (reduce == 0) reduce = FRACUNIT/10; - + if (reduce == 0) + { + reduce = FRACUNIT/10; + } self->RenderStyle.Flags &= ~STYLEF_Alpha1; self->alpha += reduce; - //if (self->alpha<=0) self->Destroy(); + // Should this clamp alpha to 1.0? } //=========================================================================== @@ -1830,11 +1832,57 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_FadeOut) ACTION_PARAM_FIXED(reduce, 0); ACTION_PARAM_BOOL(remove, 1); - if (reduce == 0) reduce = FRACUNIT/10; - + if (reduce == 0) + { + reduce = FRACUNIT/10; + } self->RenderStyle.Flags &= ~STYLEF_Alpha1; self->alpha -= reduce; - if (self->alpha<=0 && remove) self->Destroy(); + if (self->alpha <= 0 && remove) + { + self->Destroy(); + } +} + +//=========================================================================== +// +// A_FadeTo +// +// fades the actor to a specified transparency by a specified amount and +// destroys it if so desired +// +//=========================================================================== +DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_FadeTo) +{ + ACTION_PARAM_START(3); + ACTION_PARAM_FIXED(target, 0); + ACTION_PARAM_FIXED(amount, 1); + ACTION_PARAM_BOOL(remove, 2); + + self->RenderStyle.Flags &= ~STYLEF_Alpha1; + + if (self->alpha > target) + { + self->alpha -= amount; + + if (self->alpha < target) + { + self->alpha = target; + } + } + else if (self->alpha < target) + { + self->alpha += amount; + + if (self->alpha > target) + { + self->alpha = target; + } + } + if (self->alpha == target && remove) + { + self->Destroy(); + } } //=========================================================================== diff --git a/wadsrc/static/actors/actor.txt b/wadsrc/static/actors/actor.txt index 5037968e2e..50d7369d2e 100644 --- a/wadsrc/static/actors/actor.txt +++ b/wadsrc/static/actors/actor.txt @@ -201,6 +201,7 @@ ACTOR Actor native //: Thinker action native A_SetTranslucent(float alpha, int style = 0); action native A_FadeIn(float reduce = 0.1); action native A_FadeOut(float reduce = 0.1, bool remove = true); + action native A_FadeTo(float target, float amount = 0.1, bool remove = false); action native A_SpawnDebris(class spawntype, bool transfer_translation = false, float mult_h = 1, float mult_v = 1); action native A_CheckSight(state label); action native A_ExtChase(bool usemelee, bool usemissile, bool playactive = true, bool nightmarefast = false);