From c9a4087c18fe35d82a2d6891c780590da80d6b28 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 28 Nov 2016 13:11:27 +0100 Subject: [PATCH] - scriptified a_entityboss.cpp. --- src/CMakeLists.txt | 1 - src/g_strife/a_entityboss.cpp | 114 -------------------- src/g_strife/a_strifestuff.cpp | 1 - wadsrc/static/zscript/strife/entityboss.txt | 101 +++++++++++++++-- 4 files changed, 94 insertions(+), 123 deletions(-) delete mode 100644 src/g_strife/a_entityboss.cpp diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 21637c59b..211411f20 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -863,7 +863,6 @@ set( NOT_COMPILED_SOURCE_FILES g_hexen/a_spike.cpp g_strife/a_coin.cpp g_strife/a_crusader.cpp - g_strife/a_entityboss.cpp g_strife/a_inquisitor.cpp g_strife/a_loremaster.cpp g_strife/a_oracle.cpp diff --git a/src/g_strife/a_entityboss.cpp b/src/g_strife/a_entityboss.cpp deleted file mode 100644 index 7a6b6f027..000000000 --- a/src/g_strife/a_entityboss.cpp +++ /dev/null @@ -1,114 +0,0 @@ -/* -#include "actor.h" -#include "m_random.h" -#include "a_action.h" -#include "p_local.h" -#include "p_enemy.h" -#include "s_sound.h" -#include "a_strifeglobal.h" -#include "vm.h" -#include "g_level.h" -*/ - -static FRandom pr_entity ("Entity"); - -DEFINE_ACTION_FUNCTION(AActor, A_SubEntityDeath) -{ - PARAM_SELF_PROLOGUE(AActor); - - if (CheckBossDeath (self)) - { - G_ExitLevel (0, false); - } - return 0; -} - -void A_SpectralMissile (AActor *self, const char *missilename) -{ - if (self->target != NULL) - { - AActor *missile = P_SpawnMissileXYZ (self->PosPlusZ(32.), self, self->target, PClass::FindActor(missilename), false); - if (missile != NULL) - { - missile->tracer = self->target; - P_CheckMissileSpawn(missile, self->radius); - } - } -} - -DECLARE_ACTION(A_Spectre3Attack) - - -DEFINE_ACTION_FUNCTION(AActor, A_EntityAttack) -{ - PARAM_SELF_PROLOGUE(AActor); - - // Apparent Strife bug: Case 5 was unreachable because they used % 5 instead of % 6. - // I've fixed that by making case 1 duplicate it, since case 1 did nothing. - switch (pr_entity() % 5) - { - case 0: - //CALL_ACTION(A_SpotLightning, self); - break; - - case 2: - A_SpectralMissile (self, "SpectralLightningH3"); - break; - - case 3: - //CALL_ACTION(A_Spectre3Attack, self); - break; - - case 4: - A_SpectralMissile (self, "SpectralLightningBigV2"); - break; - - case 1: - case 5: - A_SpectralMissile (self, "SpectralLightningBigBall2"); - break; - } - return 0; -} - - -DEFINE_ACTION_FUNCTION(AActor, A_SpawnEntity) -{ - PARAM_SELF_PROLOGUE(AActor); - - AActor *entity = Spawn("EntityBoss", self->PosPlusZ(70.), ALLOW_REPLACE); - if (entity != NULL) - { - entity->Angles.Yaw = self->Angles.Yaw; - entity->CopyFriendliness(self, true); - entity->Vel.Z = 5; - entity->tracer = self; - } - return 0; -} - -DEFINE_ACTION_FUNCTION(AActor, A_EntityDeath) -{ - PARAM_SELF_PROLOGUE(AActor); - - AActor *second; - double secondRadius = GetDefaultByName("EntitySecond")->radius * 2; - - static const double turns[3] = { 0, 90, -90 }; - const double velmul[3] = { 4.8828125f, secondRadius*4, secondRadius*4 }; - - AActor *spot = self->tracer; - if (spot == NULL) spot = self; - - for (int i = 0; i < 3; i++) - { - DAngle an = self->Angles.Yaw + turns[i]; - DVector3 pos = spot->Vec3Angle(secondRadius, an, self->tracer ? 70. : 0.); - - second = Spawn("EntitySecond", pos, ALLOW_REPLACE); - second->CopyFriendliness(self, true); - A_FaceTarget(second); - second->VelFromAngle(velmul[i], an); - } - return 0; -} diff --git a/src/g_strife/a_strifestuff.cpp b/src/g_strife/a_strifestuff.cpp index ad6afce60..df89e614a 100644 --- a/src/g_strife/a_strifestuff.cpp +++ b/src/g_strife/a_strifestuff.cpp @@ -26,7 +26,6 @@ // Include all the other Strife stuff here to reduce compile time #include "a_coin.cpp" #include "a_crusader.cpp" -#include "a_entityboss.cpp" #include "a_inquisitor.cpp" #include "a_loremaster.cpp" //#include "a_macil.cpp" diff --git a/wadsrc/static/zscript/strife/entityboss.txt b/wadsrc/static/zscript/strife/entityboss.txt index 8ccdbbd02..daf1a78ee 100644 --- a/wadsrc/static/zscript/strife/entityboss.txt +++ b/wadsrc/static/zscript/strife/entityboss.txt @@ -32,7 +32,6 @@ class EntityPod : Actor SeeSound "misc/gibbed"; } - native void A_SpawnEntity (); States { @@ -47,10 +46,23 @@ class EntityPod : Actor PODD E -1; Stop; } + + void A_SpawnEntity () + { + Actor entity = Spawn("EntityBoss", pos + (0,0,70), ALLOW_REPLACE); + if (entity != null) + { + entity.Angle = self.Angle; + entity.CopyFriendliness(self, true); + entity.Vel.Z = 5; + entity.tracer = self; + } + } + } -// Entity Boss -------------------------------------------------------------- +// -------------------------------------------------------------- class EntityBoss : SpectralMonster { @@ -87,9 +99,6 @@ class EntityBoss : SpectralMonster Obituary "$OB_ENTITY"; } - native void A_EntityAttack(); - native void A_EntityDeath(); - States { Spawn: @@ -129,6 +138,76 @@ class EntityBoss : SpectralMonster MNAL Q 6 Bright A_EntityDeath; Stop; } + + // -------------------------------------------------------------- + + private void A_SpectralMissile (class missilename) + { + if (target != null) + { + Actor missile = SpawnMissileXYZ (Pos + (0,0,32), target, missilename, false); + if (missile != null) + { + missile.tracer = target; + missile.CheckMissileSpawn(radius); + } + } + } + + // -------------------------------------------------------------- + + void A_EntityAttack() + { + // Apparent Strife bug: Case 5 was unreachable because they used % 5 instead of % 6. + // I've fixed that by making case 1 duplicate it, since case 1 did nothing. + switch (random[Entity]() % 5) + { + case 0: + A_SpotLightning(); + break; + + case 2: + A_SpectralMissile ("SpectralLightningH3"); + break; + + case 3: + A_Spectre3Attack(); + break; + + case 4: + A_SpectralMissile ("SpectralLightningBigV2"); + break; + + default: + A_SpectralMissile ("SpectralLightningBigBall2"); + break; + } + } + + // -------------------------------------------------------------- + + void A_EntityDeath() + { + Actor second; + double secondRadius = GetDefaultByType("EntitySecond").radius * 2; + + static const double turns[] = { 0, 90, -90 }; + + Actor spot = tracer; + if (spot == null) spot = self; + + for (int i = 0; i < 3; i++) + { + double an = Angle + turns[i]; + Vector3 pos = spot.Vec3Angle(secondRadius, an, tracer ? 70. : 0.); + + second = Spawn("EntitySecond", pos, ALLOW_REPLACE); + second.CopyFriendliness(self, true); + second.A_FaceTarget(); + second.VelFromAngle(i == 0? 4.8828125 : secondRadius * 4., an); + } + } + } // Second Entity Boss ------------------------------------------------------- @@ -167,8 +246,6 @@ class EntitySecond : SpectralMonster Obituary "$OB_ENTITY"; } - native void A_SubEntityDeath (); - States { Spawn: @@ -202,6 +279,16 @@ class EntitySecond : SpectralMonster MDTH O 3 Bright A_SubEntityDeath; Stop; } + + // -------------------------------------------------------------- + + void A_SubEntityDeath () + { + if (CheckBossDeath ()) + { + Exit_Normal(0); + } + } }