From 3f1673f34ffdfb468c5680ca0328b1f05041ccf7 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 24 Oct 2016 00:50:28 +0200 Subject: [PATCH] - scriptified A_HeadAttack, A_CyberAttack and A_Hoof. --- src/g_doom/a_cacodemon.cpp | 35 ----------------------- src/g_doom/a_cyberdemon.cpp | 29 ------------------- src/g_doom/a_doommisc.cpp | 2 -- src/scripting/thingdef_data.cpp | 1 + wadsrc/static/zscript/actor.txt | 3 -- wadsrc/static/zscript/doom/cacodemon.txt | 29 +++++++++++++++++++ wadsrc/static/zscript/doom/cyberdemon.txt | 25 ++++++++++++++++ 7 files changed, 55 insertions(+), 69 deletions(-) delete mode 100644 src/g_doom/a_cacodemon.cpp delete mode 100644 src/g_doom/a_cyberdemon.cpp diff --git a/src/g_doom/a_cacodemon.cpp b/src/g_doom/a_cacodemon.cpp deleted file mode 100644 index 354443bd6..000000000 --- a/src/g_doom/a_cacodemon.cpp +++ /dev/null @@ -1,35 +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 "s_sound.h" -#include "vm.h" -*/ - -static FRandom pr_headattack ("HeadAttack"); - -DEFINE_ACTION_FUNCTION(AActor, A_HeadAttack) -{ - PARAM_SELF_PROLOGUE(AActor); - - if (!self->target) - return 0; - - A_FaceTarget (self); - if (self->CheckMeleeRange ()) - { - int damage = (pr_headattack()%6+1)*10; - S_Sound (self, CHAN_WEAPON, self->AttackSound, 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("CacodemonBall")); - return 0; -} diff --git a/src/g_doom/a_cyberdemon.cpp b/src/g_doom/a_cyberdemon.cpp deleted file mode 100644 index 6e78759c3..000000000 --- a/src/g_doom/a_cyberdemon.cpp +++ /dev/null @@ -1,29 +0,0 @@ -/* -#include "actor.h" -#include "p_local.h" -#include "s_sound.h" -#include "p_enemy.h" -#include "a_action.h" -#include "vm.h" -*/ - -DEFINE_ACTION_FUNCTION(AActor, A_CyberAttack) -{ - PARAM_SELF_PROLOGUE(AActor); - - if (!self->target) - return 0; - - A_FaceTarget (self); - P_SpawnMissile (self, self->target, PClass::FindActor("Rocket")); - return 0; -} - -DEFINE_ACTION_FUNCTION(AActor, A_Hoof) -{ - PARAM_SELF_PROLOGUE(AActor); - - S_Sound (self, CHAN_BODY, "cyber/hoof", 1, ATTN_IDLE); - A_Chase (stack, self); - return 0; -} diff --git a/src/g_doom/a_doommisc.cpp b/src/g_doom/a_doommisc.cpp index 2115e70e1..fb5ae3b28 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_cacodemon.cpp" -#include "a_cyberdemon.cpp" #include "a_demon.cpp" #include "a_doomimp.cpp" #include "a_doomweaps.cpp" diff --git a/src/scripting/thingdef_data.cpp b/src/scripting/thingdef_data.cpp index 7e0668a0f..e11e249ce 100644 --- a/src/scripting/thingdef_data.cpp +++ b/src/scripting/thingdef_data.cpp @@ -676,6 +676,7 @@ void InitThingdef() symt.AddSymbol(new PField(NAME_VisibleStartPitch, TypeFloat64, VARF_Native, myoffsetof(AActor, VisibleStartPitch))); symt.AddSymbol(new PField(NAME_VisibleEndAngle, TypeFloat64, VARF_Native, myoffsetof(AActor, VisibleEndAngle))); symt.AddSymbol(new PField(NAME_VisibleEndPitch, TypeFloat64, VARF_Native, myoffsetof(AActor, VisibleEndPitch))); + symt.AddSymbol(new PField("AttackSound", TypeSound, VARF_Native, myoffsetof(AActor, AttackSound))); symt.AddSymbol(new PField(NAME_Target, TypeActor, VARF_Native, myoffsetof(AActor, target))); symt.AddSymbol(new PField(NAME_Master, TypeActor, VARF_Native, myoffsetof(AActor, master))); symt.AddSymbol(new PField(NAME_Tracer, TypeActor, VARF_Native, myoffsetof(AActor, tracer))); diff --git a/wadsrc/static/zscript/actor.txt b/wadsrc/static/zscript/actor.txt index caea22aae..b6d65a29e 100644 --- a/wadsrc/static/zscript/actor.txt +++ b/wadsrc/static/zscript/actor.txt @@ -112,13 +112,10 @@ class Actor : Thinker native native void A_CPosRefire(); native void A_TroopAttack(); native void A_SargAttack(); - native void A_HeadAttack(); native void A_SkullAttack(float speed = 20); native void A_BetaSkullAttack(); native void A_Metal(); native void A_SpidRefire(); - native void A_Hoof(); - native void A_CyberAttack(); native void A_PainAttack(class spawntype = "LostSoul", float angle = 0, int flags = 0, int limit = -1); native void A_DualPainAttack(class spawntype = "LostSoul"); native void A_PainDie(class spawntype = "LostSoul"); diff --git a/wadsrc/static/zscript/doom/cacodemon.txt b/wadsrc/static/zscript/doom/cacodemon.txt index 6a07feb70..b21acacd2 100644 --- a/wadsrc/static/zscript/doom/cacodemon.txt +++ b/wadsrc/static/zscript/doom/cacodemon.txt @@ -86,3 +86,32 @@ class CacodemonBall : Actor Stop; } } + + +//=========================================================================== +// +// Code (must be attached to Actor) +// +//=========================================================================== + +extend class Actor +{ + void A_HeadAttack() + { + if (target) + { + if (CheckMeleeRange()) + { + int damage = random[pr_headattack](1, 6) * 10; + A_PlaySound (AttackSound, CHAN_WEAPON); + int newdam = target.DamageMobj (self, self, damage, "Melee"); + target.TraceBleed (newdam > 0 ? newdam : damage, self); + } + else + { + // launch a missile + SpawnMissile (target, "CacodemonBall"); + } + } + } +} diff --git a/wadsrc/static/zscript/doom/cyberdemon.txt b/wadsrc/static/zscript/doom/cyberdemon.txt index 75f4fd211..1a2890f9a 100644 --- a/wadsrc/static/zscript/doom/cyberdemon.txt +++ b/wadsrc/static/zscript/doom/cyberdemon.txt @@ -62,3 +62,28 @@ class Cyberdemon : Actor } } + +//=========================================================================== +// +// Code (must be attached to Actor) +// +//=========================================================================== + +extend class Actor +{ + void A_CyberAttack() + { + if (target) + { + A_FaceTarget(); + SpawnMissile (target, "Rocket"); + } + } + + void A_Hoof() + { + A_PlaySound("cyber/hoof", CHAN_BODY, 1, false, ATTN_IDLE); + A_Chase(); + } + +}