From 8f8017836ffb6839fb767991ac06ea92ca1b85e4 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 12 Nov 2016 16:32:26 +0100 Subject: [PATCH] - scriptified Hexen's Bishop. --- src/CMakeLists.txt | 1 - src/g_hexen/a_bishop.cpp | 230 ------------------------- src/g_hexen/a_hexenmisc.cpp | 1 - src/p_mobj.cpp | 24 +++ wadsrc/static/zscript/actor.txt | 2 +- wadsrc/static/zscript/hexen/bishop.txt | 180 ++++++++++++++++++- 6 files changed, 196 insertions(+), 242 deletions(-) delete mode 100644 src/g_hexen/a_bishop.cpp diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 66371220b..d0f73bc9b 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -857,7 +857,6 @@ set( NOT_COMPILED_SOURCE_FILES g_heretic/a_hereticartifacts.cpp g_heretic/a_hereticweaps.cpp g_heretic/a_ironlich.cpp - g_hexen/a_bishop.cpp g_hexen/a_blastradius.cpp g_hexen/a_boostarmor.cpp g_hexen/a_centaur.cpp diff --git a/src/g_hexen/a_bishop.cpp b/src/g_hexen/a_bishop.cpp deleted file mode 100644 index bd9f24061..000000000 --- a/src/g_hexen/a_bishop.cpp +++ /dev/null @@ -1,230 +0,0 @@ -/* -#include "actor.h" -#include "info.h" -#include "p_local.h" -#include "s_sound.h" -#include "a_action.h" -#include "m_random.h" -#include "a_hexenglobal.h" -#include "vm.h" -*/ - -static FRandom pr_boom ("BishopBoom"); -static FRandom pr_atk ("BishopAttack"); -static FRandom pr_decide ("BishopDecide"); -static FRandom pr_doblur ("BishopDoBlur"); -static FRandom pr_sblur ("BishopSpawnBlur"); -static FRandom pr_pain ("BishopPainBlur"); - -//============================================================================ -// -// A_BishopAttack -// -//============================================================================ - -DEFINE_ACTION_FUNCTION(AActor, A_BishopAttack) -{ - PARAM_SELF_PROLOGUE(AActor); - - if (!self->target) - { - return 0; - } - S_Sound (self, CHAN_BODY, self->AttackSound, 1, ATTN_NORM); - if (self->CheckMeleeRange()) - { - int damage = pr_atk.HitDice (4); - int newdam = P_DamageMobj (self->target, self, self, damage, NAME_Melee); - P_TraceBleed (newdam > 0 ? newdam : damage, self->target, self); - return 0; - } - self->special1 = (pr_atk() & 3) + 5; - return 0; -} - -//============================================================================ -// -// A_BishopAttack2 -// -// Spawns one of a string of bishop missiles -//============================================================================ - -DEFINE_ACTION_FUNCTION(AActor, A_BishopAttack2) -{ - PARAM_SELF_PROLOGUE(AActor); - - AActor *mo; - - if (!self->target || !self->special1) - { - self->special1 = 0; - self->SetState (self->SeeState); - return 0; - } - mo = P_SpawnMissile (self, self->target, PClass::FindActor("BishopFX")); - if (mo != NULL) - { - mo->tracer = self->target; - } - self->special1--; - return 0; -} - -//============================================================================ -// -// A_BishopMissileWeave -// -//============================================================================ - -DEFINE_ACTION_FUNCTION(AActor, A_BishopMissileWeave) -{ - PARAM_SELF_PROLOGUE(AActor); - - A_Weave(self, 2, 2, 2., 1.); - return 0; -} - -//============================================================================ -// -// A_BishopDecide -// -//============================================================================ - -DEFINE_ACTION_FUNCTION(AActor, A_BishopDecide) -{ - PARAM_SELF_PROLOGUE(AActor); - - if (pr_decide() < 220) - { - return 0; - } - else - { - self->SetState (self->FindState ("Blur")); - } - return 0; -} - -//============================================================================ -// -// A_BishopDoBlur -// -//============================================================================ - -DEFINE_ACTION_FUNCTION(AActor, A_BishopDoBlur) -{ - PARAM_SELF_PROLOGUE(AActor); - - self->special1 = (pr_doblur() & 3) + 3; // Random number of blurs - if (pr_doblur() < 120) - { - self->Thrust(self->Angles.Yaw + 90, 11); - } - else if (pr_doblur() > 125) - { - self->Thrust(self->Angles.Yaw - 90, 11); - } - else - { // Thrust forward - self->Thrust(11); - } - S_Sound (self, CHAN_BODY, "BishopBlur", 1, ATTN_NORM); - return 0; -} - -//============================================================================ -// -// A_BishopSpawnBlur -// -//============================================================================ - -DEFINE_ACTION_FUNCTION(AActor, A_BishopSpawnBlur) -{ - PARAM_SELF_PROLOGUE(AActor); - - AActor *mo; - - if (!--self->special1) - { - self->Vel.X = self->Vel.Y = 0; - if (pr_sblur() > 96) - { - self->SetState (self->SeeState); - } - else - { - self->SetState (self->MissileState); - } - } - mo = Spawn ("BishopBlur", self->Pos(), ALLOW_REPLACE); - if (mo) - { - mo->Angles.Yaw = self->Angles.Yaw; - } - return 0; -} - -//============================================================================ -// -// A_BishopChase -// -//============================================================================ - -DEFINE_ACTION_FUNCTION(AActor, A_BishopChase) -{ - PARAM_SELF_PROLOGUE(AActor); - - double newz = self->Z() - BobSin(self->special2) / 2.; - self->special2 = (self->special2 + 4) & 63; - newz += BobSin(self->special2) / 2.; - self->SetZ(newz); - return 0; -} - -//============================================================================ -// -// A_BishopPuff -// -//============================================================================ - -DEFINE_ACTION_FUNCTION(AActor, A_BishopPuff) -{ - PARAM_SELF_PROLOGUE(AActor); - - AActor *mo; - - mo = Spawn ("BishopPuff", self->PosPlusZ(40.), ALLOW_REPLACE); - if (mo) - { - mo->Vel.Z = -.5; - } - return 0; -} - -//============================================================================ -// -// A_BishopPainBlur -// -//============================================================================ - -DEFINE_ACTION_FUNCTION(AActor, A_BishopPainBlur) -{ - PARAM_SELF_PROLOGUE(AActor); - - AActor *mo; - - if (pr_pain() < 64) - { - self->SetState (self->FindState ("Blur")); - return 0; - } - double xo = pr_pain.Random2() / 16.; - double yo = pr_pain.Random2() / 16.; - double zo = pr_pain.Random2() / 32.; - mo = Spawn ("BishopPainBlur", self->Vec3Offset(xo, yo, zo), ALLOW_REPLACE); - if (mo) - { - mo->Angles.Yaw = self->Angles.Yaw; - } - return 0; -} diff --git a/src/g_hexen/a_hexenmisc.cpp b/src/g_hexen/a_hexenmisc.cpp index da17d37be..1bb722d06 100644 --- a/src/g_hexen/a_hexenmisc.cpp +++ b/src/g_hexen/a_hexenmisc.cpp @@ -27,7 +27,6 @@ #include "vm.h" // Include all the Hexen stuff here to reduce compile time -#include "a_bishop.cpp" #include "a_blastradius.cpp" #include "a_boostarmor.cpp" #include "a_centaur.cpp" diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index 83e4d0282..bd05941b3 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -6939,6 +6939,30 @@ DEFINE_ACTION_FUNCTION(AActor, VelFromAngle) return 0; } +// This combines all 3 variations of the internal function +DEFINE_ACTION_FUNCTION(AActor, Thrust) +{ + PARAM_SELF_PROLOGUE(AActor); + if (numparam == 1) + { + self->Thrust(); + } + else + { + PARAM_FLOAT(speed); + if (numparam == 2) + { + self->Thrust(speed); + } + else + { + PARAM_ANGLE(angle); + self->Thrust(angle, speed); + } + } + return 0; +} + DEFINE_ACTION_FUNCTION(AActor, AngleTo) { PARAM_SELF_PROLOGUE(AActor); diff --git a/wadsrc/static/zscript/actor.txt b/wadsrc/static/zscript/actor.txt index 8a5b56e0c..97b961eea 100644 --- a/wadsrc/static/zscript/actor.txt +++ b/wadsrc/static/zscript/actor.txt @@ -95,6 +95,7 @@ class Actor : Thinker native native vector3 Vec3Angle(float length, float angle, float z = 0, bool absolute = false); native vector3 Vec2OffsetZ(float x, float y, float atz, bool absolute = false); native void VelFromAngle(float speed = 0, float angle = 0); + native void Thrust(float speed = 0, float angle = 0); native bool isFriend(Actor other); native void AdjustFloorClip(); native DropItem GetDropItems(); @@ -292,7 +293,6 @@ class Actor : Thinker native native void A_GenericFreezeDeath(); native void A_IceGuyDie(); native void A_CentaurDefend(); - native void A_BishopMissileWeave(); native void A_CStaffMissileSlither(); native void A_PlayerScream(); native void A_SkullPop(class skulltype = "BloodySkull"); diff --git a/wadsrc/static/zscript/hexen/bishop.txt b/wadsrc/static/zscript/hexen/bishop.txt index d116ee932..d846a6402 100644 --- a/wadsrc/static/zscript/hexen/bishop.txt +++ b/wadsrc/static/zscript/hexen/bishop.txt @@ -3,6 +3,9 @@ class Bishop : Actor { + int missilecount; + int bobstate; + Default { Health 130; @@ -23,14 +26,6 @@ class Bishop : Actor Obituary"$OB_BISHOP"; } - native void A_BishopChase(); - native void A_BishopDecide(); - native void A_BishopDoBlur(); - native void A_BishopSpawnBlur(); - native void A_BishopPainBlur(); - native void A_BishopAttack(); - native void A_BishopAttack2(); - States { Spawn: @@ -67,7 +62,7 @@ class Bishop : Actor BISH J 5 BRIGHT A_Explode(random[BishopBoom](25,40)); BISH K 5 Bright; BISH LM 4 Bright; - BISH N 4 A_SpawnItemEx("BishopPuff", 0,0,40, 0,0,0.5); + BISH N 4 A_SpawnItemEx("BishopPuff", 0,0,40, 0,0,-0.5); BISH O 4 A_QueueCorpse; BISH P -1; Stop; @@ -76,6 +71,172 @@ class Bishop : Actor BISH X 1 A_FreezeDeathChunks; Wait; } + + + + //============================================================================ + // + // A_BishopAttack + // + //============================================================================ + + void A_BishopAttack() + { + if (!target) + { + return; + } + A_PlaySound (AttackSound, CHAN_BODY); + if (CheckMeleeRange()) + { + int damage = random[BishopAttack](1, 8) * 4; + int newdam = target.DamageMobj (self, self, damage, 'Melee'); + target.TraceBleed (newdam > 0 ? newdam : damage, self); + return; + } + missilecount = (random[BishopAttack]() & 3) + 5; + } + + //============================================================================ + // + // A_BishopAttack2 + // + // Spawns one of a string of bishop missiles + //============================================================================ + + void A_BishopAttack2() + { + if (!target || !missilecount) + { + missilecount = 0; + SetState (SeeState); + return; + } + Actor mo = SpawnMissile (target, "BishopFX"); + if (mo != null) + { + mo.tracer = target; + } + missilecount--; + return; + } + + //============================================================================ + // + // A_BishopDecide + // + //============================================================================ + + void A_BishopDecide() + { + if (random[BishopDecide]() >= 220) + { + SetState ("Blur"); + } + } + + //============================================================================ + // + // A_BishopDoBlur + // + //============================================================================ + + void A_BishopDoBlur() + { + missilecount = (random[BishopDoBlur]() & 3) + 3; // Random number of blurs + if (random[BishopDoBlur]() < 120) + { + Thrust(11, Angle + 90); + } + else if (random[BishopDoBlur]() > 125) + { + Thrust(11, Angle - 90); + } + else + { // Thrust forward + Thrust(11); + } + A_PlaySound ("BishopBlur", CHAN_BODY); + } + + //============================================================================ + // + // A_BishopSpawnBlur + // + //============================================================================ + + void A_BishopSpawnBlur() + { + if (!--missilecount) + { + Vel.XY = (0,0);// = Vel.Y = 0; + if (random[BishopSpawnBlur]() > 96) + { + SetState (SeeState); + } + else + { + SetState (MissileState); + } + } + Actor mo = Spawn ("BishopBlur", Pos, ALLOW_REPLACE); + if (mo) + { + mo.angle = angle; + } + } + + //============================================================================ + // + // A_BishopChase + // + //============================================================================ + + void A_BishopChase() + { + double newz = pos.z - BobSin(bobstate) / 2.; + bobstate = (bobstate + 4) & 63; + newz += BobSin(bobstate) / 2.; + SetZ(newz); + } + + //============================================================================ + // + // A_BishopPainBlur + // + //============================================================================ + + void A_BishopPainBlur() + { + if (random[BishopPainBlur]() < 64) + { + SetState ("Blur"); + return; + } + double xo = random2[BishopPainBlur]() / 16.; + double yo = random2[BishopPainBlue]() / 16.; + double zo = random2[BishopPainBlue]() / 32.; + Actor mo = Spawn ("BishopPainBlur", Vec3Offset(xo, yo, zo), ALLOW_REPLACE); + if (mo) + { + mo.angle = angle; + } + } + +} + +extend class Actor +{ + //============================================================================ + // + // A_BishopMissileWeave (this function must be in Actor) + // + //============================================================================ + + void A_BishopMissileWeave() + { + A_Weave(2, 2, 2., 1.); + } } // Bishop puff -------------------------------------------------------------- @@ -164,3 +325,4 @@ class BishopBlur : Actor Stop; } } +