diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index ddd027c80..2720f026d 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -835,7 +835,6 @@ set( NOT_COMPILED_SOURCE_FILES ${OTHER_SYSTEM_SOURCES} sc_man_scanner.h sc_man_scanner.re - g_doom/a_arachnotron.cpp g_doom/a_archvile.cpp g_doom/a_bossbrain.cpp g_doom/a_bruiser.cpp diff --git a/src/g_doom/a_arachnotron.cpp b/src/g_doom/a_arachnotron.cpp deleted file mode 100644 index 22223d24b..000000000 --- a/src/g_doom/a_arachnotron.cpp +++ /dev/null @@ -1,30 +0,0 @@ -/* -#include "actor.h" -#include "s_sound.h" -#include "p_local.h" -#include "p_enemy.h" -#include "a_action.h" -#include "vm.h" -*/ - -DEFINE_ACTION_FUNCTION(AActor, A_BspiAttack) -{ - PARAM_SELF_PROLOGUE(AActor); - - if (!self->target) - return 0; - - A_FaceTarget (self); - - // launch a missile - P_SpawnMissile (self, self->target, PClass::FindActor("ArachnotronPlasma")); - return 0; -} - -DEFINE_ACTION_FUNCTION(AActor, A_BabyMetal) -{ - PARAM_SELF_PROLOGUE(AActor); - S_Sound (self, CHAN_BODY, "baby/walk", 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 a4eca67b7..81e5a253a 100644 --- a/src/g_doom/a_doommisc.cpp +++ b/src/g_doom/a_doommisc.cpp @@ -22,7 +22,6 @@ #include "vm.h" // Include all the other Doom stuff here to reduce compile time -#include "a_arachnotron.cpp" #include "a_archvile.cpp" #include "a_bossbrain.cpp" #include "a_bruiser.cpp" diff --git a/src/scripting/vm/vmbuilder.cpp b/src/scripting/vm/vmbuilder.cpp index b58de0ea4..1b7c4ce70 100644 --- a/src/scripting/vm/vmbuilder.cpp +++ b/src/scripting/vm/vmbuilder.cpp @@ -693,7 +693,7 @@ void FFunctionBuildList::Build() FCompileContext ctx(item.Func, item.Func->SymbolName == NAME_None ? nullptr : item.Func->Variants[0].Proto, item.FromDecorate); // Allocate registers for the function's arguments and create local variable nodes before starting to resolve it. - VMFunctionBuilder buildit(true); + VMFunctionBuilder buildit(!!(item.Func->Variants[0].Flags & VARF_Action)); for(unsigned i=0;iVariants[0].Proto->ArgumentTypes.Size();i++) { auto type = item.Func->Variants[0].Proto->ArgumentTypes[i]; diff --git a/src/scripting/zscript/zcc_compile.cpp b/src/scripting/zscript/zcc_compile.cpp index 8389975ef..723e82c8d 100644 --- a/src/scripting/zscript/zcc_compile.cpp +++ b/src/scripting/zscript/zcc_compile.cpp @@ -2042,6 +2042,15 @@ void ZCCCompiler::InitFunctions() sym->AddVariant(NewPrototype(rets, args), argflags, argnames, afd == nullptr? nullptr : *(afd->VMPointer), varflags); c->Type()->Symbols.ReplaceSymbol(sym); + if (!(f->Flags & ZCC_Native)) + { + auto code = ConvertAST(f->Body); + if (code != nullptr) + { + sym->Variants[0].Implementation = FunctionBuildList.AddFunction(sym, code, FStringf("%s.%s", c->Type()->TypeName.GetChars(), FName(f->Name).GetChars()), false); + } + } + // todo: Check inheritance. // todo: Process function bodies. } diff --git a/wadsrc/static/zscript/doom/arachnotron.txt b/wadsrc/static/zscript/doom/arachnotron.txt index e3aa17d48..0e093323b 100644 --- a/wadsrc/static/zscript/doom/arachnotron.txt +++ b/wadsrc/static/zscript/doom/arachnotron.txt @@ -88,4 +88,27 @@ class ArachnotronPlasma : Actor } } +//=========================================================================== +// +// Code (must be attached to Actor) +// +//=========================================================================== + +extend class Actor +{ + void A_BspiAttack() + { + if (target) + { + A_FaceTarget(); + P_SpawnMissile(target, "ArachnotronPlasma"); + } + } + + void A_BabyMetal() + { + A_PlaySound("baby/walk", CHAN_BODY, 1, false, ATTN_IDLE); + A_Chase(); + } +}