From 51cc7feb4c26110b0495944d5bb39b8cb2c00685 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 13 Jan 2017 19:29:54 +0100 Subject: [PATCH] - scriptified the particle fountains. --- src/CMakeLists.txt | 1 - src/actor.h | 5 +- src/g_shared/a_fountain.cpp | 70 ----------------------- src/p_effect.cpp | 6 +- src/p_effect.h | 10 ---- src/p_mobj.cpp | 2 + wadsrc/static/zscript/actor.txt | 1 + wadsrc/static/zscript/shared/fountain.txt | 46 ++++++++++++--- 8 files changed, 47 insertions(+), 94 deletions(-) delete mode 100644 src/g_shared/a_fountain.cpp diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 7826ec6ab0..e076529c9d 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1160,7 +1160,6 @@ set (PCH_SOURCES g_shared/a_action.cpp g_shared/a_decals.cpp g_shared/a_flashfader.cpp - g_shared/a_fountain.cpp g_shared/a_lightning.cpp g_shared/a_morph.cpp g_shared/a_movingcamera.cpp diff --git a/src/actor.h b/src/actor.h index 562984577f..a764426e5b 100644 --- a/src/actor.h +++ b/src/actor.h @@ -1014,12 +1014,13 @@ public: double FloatSpeed; int sprite; // used to find patch_t and flip value - BYTE frame; // sprite frame to draw + uint8_t frame; // sprite frame to draw + uint8_t effects; // [RH] see p_effect.h + uint8_t fountaincolor; // Split out of 'effect' to have easier access. DVector2 Scale; // Scaling values; 1 is normal size FRenderStyle RenderStyle; // Style to draw this actor with ActorRenderFlags renderflags; // Different rendering flags FTextureID picnum; // Draw this instead of sprite if valid - DWORD effects; // [RH] see p_effect.h double Alpha; // Since P_CheckSight makes an alpha check this can't be a float. It has to be a double. DWORD fillcolor; // Color to draw when STYLE_Shaded diff --git a/src/g_shared/a_fountain.cpp b/src/g_shared/a_fountain.cpp deleted file mode 100644 index 7d7e2e412f..0000000000 --- a/src/g_shared/a_fountain.cpp +++ /dev/null @@ -1,70 +0,0 @@ -/* -** a_fountain.cpp -** Actors that make particle fountains -** -**--------------------------------------------------------------------------- -** Copyright 1998-2006 Randy Heit -** All rights reserved. -** -** Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions -** are met: -** -** 1. Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** 2. Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in the -** documentation and/or other materials provided with the distribution. -** 3. The name of the author may not be used to endorse or promote products -** derived from this software without specific prior written permission. -** -** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, -** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -**--------------------------------------------------------------------------- -** -*/ - -#include "actor.h" -#include "info.h" -#include "p_effect.h" -#include "doomdata.h" - -class AParticleFountain : public AActor -{ - DECLARE_CLASS (AParticleFountain, AActor) -public: - void PostBeginPlay (); - void Activate (AActor *activator); - void Deactivate (AActor *activator); -}; - -IMPLEMENT_CLASS(AParticleFountain, false, false) - -void AParticleFountain::PostBeginPlay () -{ - Super::PostBeginPlay (); - if (!(SpawnFlags & MTF_DORMANT)) - CallActivate (NULL); -} - -void AParticleFountain::Activate (AActor *activator) -{ - Super::Activate (activator); - effects &= ~FX_FOUNTAINMASK; - effects |= health << FX_FOUNTAINSHIFT; -} - -void AParticleFountain::Deactivate (AActor *activator) -{ - Super::Deactivate (activator); - effects &= ~FX_FOUNTAINMASK; -} - diff --git a/src/p_effect.cpp b/src/p_effect.cpp index 0f784fa067..f6b54b34a2 100644 --- a/src/p_effect.cpp +++ b/src/p_effect.cpp @@ -358,7 +358,7 @@ void P_RunEffects () while ( (actor = iterator.Next ()) ) { - if (actor->effects) + if (actor->effects || actor->fountaincolor) { // Only run the effect if the actor is potentially visible int rnum = pnum + actor->Sector->Index(); @@ -494,7 +494,7 @@ void P_RunEffect (AActor *actor, int effects) P_DrawSplash2 (6, pos, moveangle + 180, 2, 2); } - if (effects & FX_FOUNTAINMASK) + if (actor->fountaincolor) { // Particle fountain @@ -508,7 +508,7 @@ void P_RunEffect (AActor *actor, int effects) &black, &grey3, &grey4, &white }; - int color = (effects & FX_FOUNTAINMASK) >> 15; + int color = actor->fountaincolor*2; MakeFountain (actor, *fountainColors[color], *fountainColors[color+1]); } if (effects & FX_RESPAWNINVUL) diff --git a/src/p_effect.h b/src/p_effect.h index 4e8e73d09e..6a9f5ccf9e 100644 --- a/src/p_effect.h +++ b/src/p_effect.h @@ -38,16 +38,6 @@ #define FX_RESPAWNINVUL 0x00000020 #define FX_VISIBILITYPULSE 0x00000040 -#define FX_FOUNTAINMASK 0x00070000 -#define FX_FOUNTAINSHIFT 16 -#define FX_REDFOUNTAIN 0x00010000 -#define FX_GREENFOUNTAIN 0x00020000 -#define FX_BLUEFOUNTAIN 0x00030000 -#define FX_YELLOWFOUNTAIN 0x00040000 -#define FX_PURPLEFOUNTAIN 0x00050000 -#define FX_BLACKFOUNTAIN 0x00060000 -#define FX_WHITEFOUNTAIN 0x00070000 - struct subsector_t; // [RH] Particle details diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index c3a7ac4241..128455a39c 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -314,6 +314,7 @@ DEFINE_FIELD(AActor, MissileState) DEFINE_FIELD(AActor, ConversationRoot) DEFINE_FIELD(AActor, Conversation) DEFINE_FIELD(AActor, DecalGenerator) +DEFINE_FIELD(AActor, fountaincolor) DEFINE_FIELD(PClassActor, Obituary) DEFINE_FIELD(PClassActor, HitObituary) @@ -366,6 +367,7 @@ void AActor::Serialize(FSerializer &arc) A("lastlookpn", LastLookPlayerNumber) ("lastlookactor", LastLookActor) A("effects", effects) + A("fountaincolor", fountaincolor) A("alpha", Alpha) A("fillcolor", fillcolor) A("sector", Sector) diff --git a/wadsrc/static/zscript/actor.txt b/wadsrc/static/zscript/actor.txt index 00d80c49c1..8133b1ad2f 100644 --- a/wadsrc/static/zscript/actor.txt +++ b/wadsrc/static/zscript/actor.txt @@ -182,6 +182,7 @@ class Actor : Thinker native native State MeleeState; native State MissileState; native voidptr /*DecalBase*/ DecalGenerator; + native uint8 fountaincolor; native meta String Obituary; // Player was killed by this actor native meta String HitObituary; // Player was killed by this actor in melee diff --git a/wadsrc/static/zscript/shared/fountain.txt b/wadsrc/static/zscript/shared/fountain.txt index 60129a8c59..02e42007c9 100644 --- a/wadsrc/static/zscript/shared/fountain.txt +++ b/wadsrc/static/zscript/shared/fountain.txt @@ -1,5 +1,16 @@ -class ParticleFountain : Actor native +class ParticleFountain : Actor { + enum EColor + { + REDFOUNTAIN = 1, + GREENFOUNTAIN = 2, + BLUEFOUNTAIN = 3, + YELLOWFOUNTAIN = 4, + PURPLEFOUNTAIN = 5, + BLACKFOUNTAIN = 6, + WHITEFOUNTAIN = 7 + } + default { Height 0; @@ -7,13 +18,32 @@ class ParticleFountain : Actor native +NOGRAVITY +INVISIBLE } + + override void PostBeginPlay () + { + Super.PostBeginPlay (); + if (!(SpawnFlags & MTF_DORMANT)) + Activate (null); + } + + override void Activate (Actor activator) + { + Super.Activate (activator); + fountaincolor = health; + } + + override void Deactivate (Actor activator) + { + Super.Deactivate (activator); + fountaincolor = 0; + } } class RedParticleFountain : ParticleFountain { default { - Health 1; + Health REDFOUNTAIN; } } @@ -21,7 +51,7 @@ class GreenParticleFountain : ParticleFountain { default { - Health 2; + Health GREENFOUNTAIN; } } @@ -29,7 +59,7 @@ class BlueParticleFountain : ParticleFountain { default { - Health 3; + Health BLUEFOUNTAIN; } } @@ -37,7 +67,7 @@ class YellowParticleFountain : ParticleFountain { default { - Health 4; + Health YELLOWFOUNTAIN; } } @@ -45,7 +75,7 @@ class PurpleParticleFountain : ParticleFountain { default { - Health 5; + Health PURPLEFOUNTAIN; } } @@ -53,7 +83,7 @@ class BlackParticleFountain : ParticleFountain { default { - Health 6; + Health BLACKFOUNTAIN; } } @@ -61,6 +91,6 @@ class WhiteParticleFountain : ParticleFountain { default { - Health 7; + Health WHITEFOUNTAIN; } }