mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-11 15:21:51 +00:00
- named class functions are working. Yay!!
- converted A_BspiAttack and A_BabyMetal to script functions to test the implementation.
This commit is contained in:
parent
46c7f1151f
commit
5b952b116a
6 changed files with 33 additions and 33 deletions
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
}
|
|
@ -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"
|
||||
|
|
|
@ -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;i<item.Func->Variants[0].Proto->ArgumentTypes.Size();i++)
|
||||
{
|
||||
auto type = item.Func->Variants[0].Proto->ArgumentTypes[i];
|
||||
|
|
|
@ -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.
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue