From 36c4b396885e154ad7cf3c817306b2f84667316a Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Mon, 26 Apr 2010 01:56:25 +0000 Subject: [PATCH] - Added DavidPH's A_FadeTo patch: A_FadeTo(float target, float amount = 0.10, bool remove = false) Alters transparency towards target by amount. If remove is true, the actor is destroyed if it reaches target. SVN r2305 (trunk) --- src/thingdef/thingdef_codeptr.cpp | 60 +++++++++++++++++++++++++++---- wadsrc/static/actors/actor.txt | 1 + 2 files changed, 55 insertions(+), 6 deletions(-) diff --git a/src/thingdef/thingdef_codeptr.cpp b/src/thingdef/thingdef_codeptr.cpp index df4861f72..7d22f11d7 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 5037968e2..50d7369d2 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);