From 6d0dad3b38d9f9e89c492a5af51f35fcadeaf753 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 25 Oct 2016 14:41:58 +0200 Subject: [PATCH] - scriptified the code for the Demon and DoomImp. --- src/CMakeLists.txt | 2 -- src/g_doom/a_demon.cpp | 29 -------------------- src/g_doom/a_doomimp.cpp | 38 -------------------------- src/g_doom/a_doommisc.cpp | 2 -- wadsrc/static/zscript/actor.txt | 2 -- wadsrc/static/zscript/doom/demon.txt | 18 ++++++++++++ wadsrc/static/zscript/doom/doomimp.txt | 28 +++++++++++++++++++ 7 files changed, 46 insertions(+), 73 deletions(-) delete mode 100644 src/g_doom/a_demon.cpp delete mode 100644 src/g_doom/a_doomimp.cpp diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 9e64f1d29..5a3351880 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -837,8 +837,6 @@ set( NOT_COMPILED_SOURCE_FILES sc_man_scanner.re g_doom/a_archvile.cpp g_doom/a_bossbrain.cpp - g_doom/a_demon.cpp - g_doom/a_doomimp.cpp g_doom/a_doomweaps.cpp g_doom/a_fatso.cpp g_doom/a_keen.cpp diff --git a/src/g_doom/a_demon.cpp b/src/g_doom/a_demon.cpp deleted file mode 100644 index 5ac3e9e74..000000000 --- a/src/g_doom/a_demon.cpp +++ /dev/null @@ -1,29 +0,0 @@ -/* -#include "actor.h" -#include "info.h" -#include "m_random.h" -#include "p_local.h" -#include "p_enemy.h" -#include "gstrings.h" -#include "a_action.h" -#include "vm.h" -*/ - -static FRandom pr_sargattack ("SargAttack"); - -DEFINE_ACTION_FUNCTION(AActor, A_SargAttack) -{ - PARAM_SELF_PROLOGUE(AActor); - - if (!self->target) - return 0; - - A_FaceTarget (self); - if (self->CheckMeleeRange ()) - { - int damage = ((pr_sargattack()%10)+1)*4; - int newdam = P_DamageMobj (self->target, self, self, damage, NAME_Melee); - P_TraceBleed (newdam > 0 ? newdam : damage, self->target, self); - } - return 0; -} diff --git a/src/g_doom/a_doomimp.cpp b/src/g_doom/a_doomimp.cpp deleted file mode 100644 index 1b9dd9485..000000000 --- a/src/g_doom/a_doomimp.cpp +++ /dev/null @@ -1,38 +0,0 @@ -/* -#include "actor.h" -#include "info.h" -#include "m_random.h" -#include "s_sound.h" -#include "p_local.h" -#include "p_enemy.h" -#include "gstrings.h" -#include "a_action.h" -#include "vm.h" -*/ - -static FRandom pr_troopattack ("TroopAttack"); - -// -// A_TroopAttack -// -DEFINE_ACTION_FUNCTION(AActor, A_TroopAttack) -{ - PARAM_SELF_PROLOGUE(AActor); - - if (!self->target) - return 0; - - A_FaceTarget (self); - if (self->CheckMeleeRange ()) - { - int damage = (pr_troopattack()%8+1)*3; - S_Sound (self, CHAN_WEAPON, "imp/melee", 1, ATTN_NORM); - int newdam = P_DamageMobj (self->target, self, self, damage, NAME_Melee); - P_TraceBleed (newdam > 0 ? newdam : damage, self->target, self); - return 0; - } - - // launch a missile - P_SpawnMissile (self, self->target, PClass::FindActor("DoomImpBall")); - return 0; -} diff --git a/src/g_doom/a_doommisc.cpp b/src/g_doom/a_doommisc.cpp index fb5ae3b28..de53dc3af 100644 --- a/src/g_doom/a_doommisc.cpp +++ b/src/g_doom/a_doommisc.cpp @@ -24,8 +24,6 @@ // Include all the other Doom stuff here to reduce compile time #include "a_archvile.cpp" #include "a_bossbrain.cpp" -#include "a_demon.cpp" -#include "a_doomimp.cpp" #include "a_doomweaps.cpp" #include "a_fatso.cpp" #include "a_keen.cpp" diff --git a/wadsrc/static/zscript/actor.txt b/wadsrc/static/zscript/actor.txt index fa45eb0e6..872a3ef98 100644 --- a/wadsrc/static/zscript/actor.txt +++ b/wadsrc/static/zscript/actor.txt @@ -110,8 +110,6 @@ class Actor : Thinker native native void A_BossDeath(); native void A_CPosAttack(); native void A_CPosRefire(); - native void A_TroopAttack(); - native void A_SargAttack(); native void A_SkullAttack(float speed = 20); native void A_BetaSkullAttack(); native void A_Metal(); diff --git a/wadsrc/static/zscript/doom/demon.txt b/wadsrc/static/zscript/doom/demon.txt index 398888e45..d4cd9002c 100644 --- a/wadsrc/static/zscript/doom/demon.txt +++ b/wadsrc/static/zscript/doom/demon.txt @@ -75,3 +75,21 @@ class Spectre : Demon } +//=========================================================================== +// +// Code (must be attached to Actor) +// +//=========================================================================== + +extend class Actor +{ + void A_SargAttack() + { + if (target && CheckMeleeRange()) + { + int damage = random[pr_sargattack](1, 10) * 4; + int newdam = target.DamageMobj (self, self, damage, "Melee"); + target.TraceBleed (newdam > 0 ? newdam : damage, self); + } + } +} diff --git a/wadsrc/static/zscript/doom/doomimp.txt b/wadsrc/static/zscript/doom/doomimp.txt index 318e81471..d2b93acdd 100644 --- a/wadsrc/static/zscript/doom/doomimp.txt +++ b/wadsrc/static/zscript/doom/doomimp.txt @@ -92,3 +92,31 @@ class DoomImpBall : Actor Stop; } } + +//=========================================================================== +// +// Code (must be attached to Actor) +// +//=========================================================================== + +extend class Actor +{ + void A_TroopAttack() + { + if (target) + { + if (CheckMeleeRange()) + { + int damage = random[pr_troopattack](1, 8) * 3; + A_PlaySound ("imp/melee", CHAN_WEAPON); + int newdam = target.DamageMobj (self, self, damage, "Melee"); + target.TraceBleed (newdam > 0 ? newdam : damage, self); + } + else + { + // launch a missile + SpawnMissile (target, "DoomImpBall"); + } + } + } +}