diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 8e5c022cb..f1fc1bab5 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -887,7 +887,6 @@ set( NOT_COMPILED_SOURCE_FILES g_hexen/a_fighterquietus.cpp g_hexen/a_flechette.cpp g_hexen/a_flies.cpp - g_hexen/a_fog.cpp g_hexen/a_healingradius.cpp g_hexen/a_heresiarch.cpp g_hexen/a_hexenspecialdecs.cpp diff --git a/src/g_hexen/a_fog.cpp b/src/g_hexen/a_fog.cpp deleted file mode 100644 index 6b2bc9706..000000000 --- a/src/g_hexen/a_fog.cpp +++ /dev/null @@ -1,99 +0,0 @@ -/* -#include "m_random.h" -#include "p_local.h" -#include "vm.h" -*/ - -static FRandom pr_fogspawn ("FogSpawn"); - -//========================================================================== -// Fog Variables: -// -// args[0] Speed (0..10) of fog -// args[1] Angle of spread (0..128) -// args[2] Frequency of spawn (1..10) -// args[3] Lifetime countdown -// args[4] Boolean: fog moving? -// special1 Internal: Counter for spawn frequency -// WeaveIndexZ Internal: Index into floatbob table -// -//========================================================================== - -//========================================================================== -// -// A_FogSpawn -// -//========================================================================== - -DEFINE_ACTION_FUNCTION(AActor, A_FogSpawn) -{ - PARAM_SELF_PROLOGUE(AActor); - - static const char *fogs[3] = - { - "FogPatchSmall", - "FogPatchMedium", - "FogPatchLarge" - }; - - AActor *mo = NULL; - int delta; - - if (self->special1-- > 0) - { - return 0; - } - self->special1 = self->args[2]; // Reset frequency count - - mo = Spawn (fogs[pr_fogspawn()%3], self->Pos(), ALLOW_REPLACE); - - if (mo) - { - delta = self->args[1]; - if (delta==0) delta=1; - mo->Angles.Yaw = self->Angles.Yaw + (((pr_fogspawn() % delta) - (delta >> 1)) * (360 / 256.)); - mo->target = self; - if (self->args[0] < 1) self->args[0] = 1; - mo->args[0] = (pr_fogspawn() % (self->args[0]))+1; // Random speed - mo->args[3] = self->args[3]; // Set lifetime - mo->args[4] = 1; // Set to moving - mo->WeaveIndexZ = pr_fogspawn()&63; - } - return 0; -} - -//========================================================================== -// -// A_FogMove -// -//========================================================================== - -DEFINE_ACTION_FUNCTION(AActor, A_FogMove) -{ - PARAM_SELF_PROLOGUE(AActor); - - double speed = self->args[0]; - int weaveindex; - - if (!self->args[4]) - { - return 0; - } - - if (self->args[3]-- <= 0) - { - self->SetState (self->FindState(NAME_Death), true); - return 0; - } - - if ((self->args[3] % 4) == 0) - { - weaveindex = self->WeaveIndexZ; - self->AddZ(BobSin(weaveindex) / 2); - self->WeaveIndexZ = (weaveindex + 1) & 63; - } - - self->VelFromAngle(speed); - return 0; -} - diff --git a/src/g_hexen/a_hexenmisc.cpp b/src/g_hexen/a_hexenmisc.cpp index f1f4a86fe..9003405e4 100644 --- a/src/g_hexen/a_hexenmisc.cpp +++ b/src/g_hexen/a_hexenmisc.cpp @@ -39,7 +39,6 @@ #include "a_fighterquietus.cpp" #include "a_flechette.cpp" #include "a_flies.cpp" -#include "a_fog.cpp" #include "a_healingradius.cpp" #include "a_heresiarch.cpp" #include "a_hexenspecialdecs.cpp" diff --git a/wadsrc/static/zscript/hexen/fog.txt b/wadsrc/static/zscript/hexen/fog.txt index 93b5e9593..276cf2d73 100644 --- a/wadsrc/static/zscript/hexen/fog.txt +++ b/wadsrc/static/zscript/hexen/fog.txt @@ -1,3 +1,15 @@ +//========================================================================== +// Fog Variables: +// +// args[0] Speed (0..10) of fog +// args[1] Angle of spread (0..128) +// args[2] Frequency of spawn (1..10) +// args[3] Lifetime countdown +// args[4] Boolean: fog moving? +// special1 Internal: Counter for spawn frequency +// WeaveIndexZ Internal: Index into floatbob table +// +//========================================================================== // Fog Spawner -------------------------------------------------------------- @@ -11,7 +23,6 @@ class FogSpawner : Actor +INVISIBLE } - native void A_FogSpawn(); States { @@ -19,6 +30,45 @@ class FogSpawner : Actor TNT1 A 20 A_FogSpawn; Loop; } + + //========================================================================== + // + // A_FogSpawn + // + //========================================================================== + + void A_FogSpawn() + { + if (special1-- > 0) + { + return; + } + special1 = args[2]; // Reset frequency count + + class fog; + switch (random[FogSpawn](0,2)) + { + default: + case 0: fog = "FogPatchSmall"; break; + case 1: fog = "FogPatchMedium"; break; + case 2: fog = "FogPatchLarge"; break; + } + Actor mo = Spawn (fog, Pos, ALLOW_REPLACE); + + if (mo) + { + int delta = args[1]; + if (delta == 0) delta = 1; + mo.angle = angle + (((random[FogSpawn]() % delta) - (delta >> 1)) * (360 / 256.)); + mo.target = self; + if (args[0] < 1) args[0] = 1; + mo.args[0] = (random[FogSpawn]() % (args[0]))+1; // Random speed + mo.args[3] = args[3]; // Set lifetime + mo.args[4] = 1; // Set to moving + mo.WeaveIndexZ = random[FogSpawn](0, 63); + } + } + } // Small Fog Patch ---------------------------------------------------------- @@ -34,7 +84,6 @@ class FogPatchSmall : Actor Alpha 0.6; } - native void A_FogMove(); States { @@ -45,6 +94,37 @@ class FogPatchSmall : Actor FOGS E 5; Stop; } + + //========================================================================== + // + // A_FogMove + // + //========================================================================== + + void A_FogMove() + { + double speed = args[0]; + int weaveindex; + + if (!args[4]) + { + return; + } + + if (args[3]-- <= 0) + { + SetStateLabel ('Death', true); + return; + } + + if ((args[3] % 4) == 0) + { + weaveindex = WeaveIndexZ; + AddZ(BobSin(weaveindex) / 2); + WeaveIndexZ = (weaveindex + 1) & 63; + } + VelFromAngle(speed); + } } // Medium Fog Patch --------------------------------------------------------- @@ -76,3 +156,4 @@ class FogPatchLarge : FogPatchMedium Goto Super::Death; } } +