From ab03b016e9263d03b368a3b4298e5d95bb529558 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 27 Nov 2016 00:41:06 +0100 Subject: [PATCH] - scriptified the IceGuy. --- src/CMakeLists.txt | 2 - src/g_hexen/a_hexenmisc.cpp | 1 - src/g_hexen/a_iceguy.cpp | 132 ------------------------- src/p_mobj.cpp | 14 +++ wadsrc/static/zscript/actor.txt | 2 +- wadsrc/static/zscript/hexen/iceguy.txt | 103 ++++++++++++++++++- 6 files changed, 113 insertions(+), 141 deletions(-) delete mode 100644 src/g_hexen/a_iceguy.cpp diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 06028ecff..c5a54d1ba 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -857,10 +857,8 @@ set( NOT_COMPILED_SOURCE_FILES sc_man_scanner.re g_hexen/a_flechette.cpp g_hexen/a_flies.cpp - g_hexen/a_healingradius.cpp g_hexen/a_heresiarch.cpp g_hexen/a_hexenspecialdecs.cpp - g_hexen/a_iceguy.cpp g_hexen/a_magecone.cpp g_hexen/a_magelightning.cpp g_hexen/a_magestaff.cpp diff --git a/src/g_hexen/a_hexenmisc.cpp b/src/g_hexen/a_hexenmisc.cpp index 4fc0d4590..3223575c8 100644 --- a/src/g_hexen/a_hexenmisc.cpp +++ b/src/g_hexen/a_hexenmisc.cpp @@ -28,7 +28,6 @@ #include "a_flies.cpp" #include "a_heresiarch.cpp" #include "a_hexenspecialdecs.cpp" -#include "a_iceguy.cpp" #include "a_magecone.cpp" #include "a_magelightning.cpp" #include "a_magestaff.cpp" diff --git a/src/g_hexen/a_iceguy.cpp b/src/g_hexen/a_iceguy.cpp deleted file mode 100644 index 1163a117a..000000000 --- a/src/g_hexen/a_iceguy.cpp +++ /dev/null @@ -1,132 +0,0 @@ -/* -#include "actor.h" -#include "info.h" -#include "p_local.h" -#include "s_sound.h" -#include "p_enemy.h" -#include "a_action.h" -#include "m_random.h" -#include "vm.h" -*/ - -static FRandom pr_iceguylook ("IceGuyLook"); -static FRandom pr_iceguychase ("IceGuyChase"); - -static const char *WispTypes[2] = -{ - "IceGuyWisp1", - "IceGuyWisp2", -}; - -//============================================================================ -// -// A_IceGuyLook -// -//============================================================================ - -DEFINE_ACTION_FUNCTION(AActor, A_IceGuyLook) -{ - PARAM_SELF_PROLOGUE(AActor); - - double dist; - DAngle an; - - CALL_ACTION(A_Look, self); - if (pr_iceguylook() < 64) - { - dist = (pr_iceguylook() - 128) * self->radius / 128.; - an = self->Angles.Yaw + 90; - Spawn(WispTypes[pr_iceguylook() & 1], self->Vec3Angle(dist, an, 60.), ALLOW_REPLACE); - } - return 0; -} - -//============================================================================ -// -// A_IceGuyChase -// -//============================================================================ - -DEFINE_ACTION_FUNCTION(AActor, A_IceGuyChase) -{ - PARAM_SELF_PROLOGUE(AActor); - - double dist; - DAngle an; - AActor *mo; - - A_Chase(stack, self); - if (pr_iceguychase() < 128) - { - dist = (pr_iceguychase() - 128) * self->radius / 128.; - an = self->Angles.Yaw + 90; - mo = Spawn(WispTypes[pr_iceguylook() & 1], self->Vec3Angle(dist, an, 60.), ALLOW_REPLACE); - if (mo) - { - mo->Vel = self->Vel; - mo->target = self; - } - } - return 0; -} - -//============================================================================ -// -// A_IceGuyAttack -// -//============================================================================ - -DEFINE_ACTION_FUNCTION(AActor, A_IceGuyAttack) -{ - PARAM_SELF_PROLOGUE(AActor); - - if(!self->target) - { - return 0; - } - P_SpawnMissileXYZ(self->Vec3Angle(self->radius / 2, self->Angles.Yaw + 90, 40.), self, self->target, PClass::FindActor("IceGuyFX")); - P_SpawnMissileXYZ(self->Vec3Angle(self->radius / 2, self->Angles.Yaw - 90, 40.), self, self->target, PClass::FindActor("IceGuyFX")); - S_Sound (self, CHAN_WEAPON, self->AttackSound, 1, ATTN_NORM); - return 0; -} - -//============================================================================ -// -// A_IceGuyDie -// -//============================================================================ - -DEFINE_ACTION_FUNCTION(AActor, A_IceGuyDie) -{ - PARAM_SELF_PROLOGUE(AActor); - - self->Vel.Zero(); - self->Height = self->GetDefault()->Height; - CALL_ACTION(A_FreezeDeathChunks, self); - return 0; -} - -//============================================================================ -// -// A_IceGuyMissileExplode -// -//============================================================================ - -DEFINE_ACTION_FUNCTION(AActor, A_IceGuyMissileExplode) -{ - PARAM_SELF_PROLOGUE(AActor); - - AActor *mo; - unsigned int i; - - for (i = 0; i < 8; i++) - { - mo = P_SpawnMissileAngleZ (self, self->Z()+3, PClass::FindActor("IceGuyFX2"), DAngle(i*45.), -0.3); - if (mo) - { - mo->target = self->target; - } - } - return 0; -} - diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index 5abc02e96..2e87729d0 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -6375,6 +6375,20 @@ AActor *P_SpawnMissileXYZ (DVector3 pos, AActor *source, AActor *dest, PClassAct return (!checkspawn || P_CheckMissileSpawn (th, source->radius)) ? th : NULL; } +DEFINE_ACTION_FUNCTION(AActor, SpawnMissileXYZ) +{ + PARAM_SELF_PROLOGUE(AActor); + PARAM_FLOAT(x); + PARAM_FLOAT(y); + PARAM_FLOAT(z); + PARAM_OBJECT(dest, AActor); + PARAM_CLASS(type, AActor); + PARAM_BOOL_DEF(check); + PARAM_OBJECT_DEF(owner, AActor); + ACTION_RETURN_OBJECT(P_SpawnMissileXYZ(DVector3(x,y,z), self, dest, type, check, owner)); +} + + AActor *P_OldSpawnMissile(AActor *source, AActor *owner, AActor *dest, PClassActor *type) { if (source == NULL) diff --git a/wadsrc/static/zscript/actor.txt b/wadsrc/static/zscript/actor.txt index cefcd6511..92f1073fd 100644 --- a/wadsrc/static/zscript/actor.txt +++ b/wadsrc/static/zscript/actor.txt @@ -296,6 +296,7 @@ class Actor : Thinker native native bool TestMobjLocation(); native static Actor Spawn(class type, vector3 pos = (0,0,0), int replace = NO_REPLACE); native Actor SpawnMissile(Actor dest, class type, Actor owner = null); + native Actor SpawnMissileXYZ(Vector3 pos, Actor dest, Class type, bool checkspawn = true, Actor owner = null); native Actor SpawnMissileZ (double z, Actor dest, class type); native Actor SpawnMissileAngleZSpeed (double z, class type, double angle, double vz, double speed, Actor owner = null, bool checkspawn = true); native Actor, Actor SpawnPlayerMissile(class type, double angle = 0, double x = 0, double y = 0, double z = 0, out FTranslatedLineTarget pLineTarget = null, bool nofreeaim = false, bool noautoaim = false, int aimflags = 0); @@ -592,7 +593,6 @@ class Actor : Thinker native native void A_FreezeDeath(); native void A_FreezeDeathChunks(); native void A_GenericFreezeDeath(); - native void A_IceGuyDie(); native void A_PlayerScream(); native void A_SkullPop(class skulltype = "BloodySkull"); native void A_CheckPlayerDone(); diff --git a/wadsrc/static/zscript/hexen/iceguy.txt b/wadsrc/static/zscript/hexen/iceguy.txt index 8081d5a61..41105b728 100644 --- a/wadsrc/static/zscript/hexen/iceguy.txt +++ b/wadsrc/static/zscript/hexen/iceguy.txt @@ -22,9 +22,6 @@ class IceGuy : Actor Obituary "$OB_ICEGUY"; } - native void A_IceGuyLook(); - native void A_IceGuyChase(); - native void A_IceGuyAttack(); States { @@ -51,6 +48,84 @@ class IceGuy : Actor ICEY A -1; Goto See; } + + //============================================================================ + // + // SpawnWisp + // + //============================================================================ + + private void SpawnWisp() + { + static const class WispTypes[] = { "IceGuyWisp1", "IceGuyWisp2" }; + + double dist = (random[IceGuyLook]() - 128) * radius / 128.; + double an = angle + 90; + Actor mo = Spawn(WispTypes[random[IceGuyLook]() & 1], Vec3Angle(dist, an, 60.), ALLOW_REPLACE); + if (mo) + { + mo.Vel = Vel; + mo.target = self; + } + } + + //============================================================================ + // + // A_IceGuyLook + // + //============================================================================ + + void A_IceGuyLook() + { + A_Look(); + if (random[IceGuyLook]() < 64) SpawnWisp(); + } + + //============================================================================ + // + // A_IceGuyChase + // + //============================================================================ + + void A_IceGuyChase() + { + A_Chase(); + if (random[IceGuyLook]() < 128) SpawnWisp(); + } + + //============================================================================ + // + // A_IceGuyAttack + // + //============================================================================ + + void A_IceGuyAttack() + { + if(!target) + { + return; + } + SpawnMissileXYZ(Vec3Angle(radius / 2, angle + 90, 40.), target, "IceGuyFX"); + SpawnMissileXYZ(Vec3Angle(radius / 2, angle - 90, 40.), target, "IceGuyFX"); + A_PlaySound (AttackSound, CHAN_WEAPON); + } +} + +extend class Actor +{ + //============================================================================ + // + // A_IceGuyDie (globally accessible) + // + //============================================================================ + + void A_IceGuyDie() + { + Vel = (0,0,0); + Height = Default.Height; + A_FreezeDeathChunks(); + } + } // Ice Guy Projectile ------------------------------------------------------- @@ -69,8 +144,6 @@ class IceGuyFX : Actor DeathSound "IceGuyMissileExplode"; } - native void A_IceGuyMissileExplode(); - States { Spawn: @@ -83,6 +156,25 @@ class IceGuyFX : Actor ICPR H 3 Bright; Stop; } + + + //============================================================================ + // + // A_IceGuyMissileExplode + // + //============================================================================ + + void A_IceGuyMissileExplode() + { + for (int i = 0; i < 8; i++) + { + Actor mo = SpawnMissileAngleZ (pos.z+3, "IceGuyFX2", i*45., -0.3); + if (mo) + { + mo.target = target; + } + } + } } // Ice Guy Projectile's Puff ------------------------------------------------ @@ -183,3 +275,4 @@ class IceGuyWisp2 : IceGuyWisp1 Stop; } } +