- scriptified A_BruisAttack.

- removed 'self' as a dedicated token. Internally this gets handled as a normal but implicitly named variable so the token just gets in the way of proper processing.
- removed P_ prefix from SpawnMissile export.
- fixed a crash with misnamed function exports.
This commit is contained in:
Christoph Oelckers 2016-10-23 17:15:24 +02:00
parent da56e5908d
commit 9f8a5dae21
16 changed files with 66 additions and 50 deletions

View File

@ -1,23 +0,0 @@
static FRandom pr_bruisattack ("BruisAttack");
DEFINE_ACTION_FUNCTION(AActor, A_BruisAttack)
{
PARAM_SELF_PROLOGUE(AActor);
if (!self->target)
return 0;
if (self->CheckMeleeRange ())
{
int damage = (pr_bruisattack()%8+1)*10;
S_Sound (self, CHAN_WEAPON, "baron/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("BaronBall"));
return 0;
}

View File

@ -24,7 +24,6 @@
// Include all the other Doom stuff here to reduce compile time
#include "a_archvile.cpp"
#include "a_bossbrain.cpp"
#include "a_bruiser.cpp"
#include "a_cacodemon.cpp"
#include "a_cyberdemon.cpp"
#include "a_demon.cpp"

View File

@ -310,6 +310,12 @@ bool AActor::CheckMeleeRange ()
return true;
}
DEFINE_ACTION_FUNCTION(AActor, CheckMeleeRange)
{
PARAM_SELF_PROLOGUE(AActor);
ACTION_RETURN_INT(self->CheckMeleeRange());
}
//----------------------------------------------------------------------------
//
// FUNC P_CheckMeleeRange2

View File

@ -1555,6 +1555,18 @@ dopain:
return damage;
}
DEFINE_ACTION_FUNCTION(AActor, DamageMobj)
{
PARAM_SELF_PROLOGUE(AActor);
PARAM_OBJECT(inflictor, AActor);
PARAM_OBJECT(source, AActor);
PARAM_INT(damage);
PARAM_NAME(mod);
PARAM_INT_OPT(flags) { flags = 0; }
PARAM_FLOAT_OPT(angle) { angle = 0; }
ACTION_RETURN_INT(P_DamageMobj(self, inflictor, source, damage, mod, flags, angle));
}
void P_PoisonMobj (AActor *target, AActor *inflictor, AActor *source, int damage, int duration, int period, FName type)
{
// Check for invulnerability.

View File

@ -4574,6 +4574,16 @@ void P_TraceBleed(int damage, AActor *target, AActor *missile)
P_TraceBleed(damage, target->PosPlusZ(target->Height/2), target, missile->AngleTo(target), pitch);
}
DEFINE_ACTION_FUNCTION(AActor, TraceBleed)
{
PARAM_SELF_PROLOGUE(AActor);
PARAM_INT(damage);
PARAM_OBJECT(missile, AActor);
P_TraceBleed(damage, self, missile);
return 0;
}
//==========================================================================
//
//

View File

@ -5824,7 +5824,7 @@ AActor *P_SpawnMissile (AActor *source, AActor *dest, PClassActor *type, AActor
return P_SpawnMissileXYZ (source->PosPlusZ(32 + source->GetBobOffset()), source, dest, type, true, owner);
}
DEFINE_ACTION_FUNCTION(AActor, P_SpawnMissile)
DEFINE_ACTION_FUNCTION(AActor, SpawnMissile)
{
PARAM_SELF_PROLOGUE(AActor);
PARAM_OBJECT(dest, AActor);

View File

@ -169,7 +169,6 @@ std2:
'virtual' { RET(TK_Virtual); }
'super' { RET(TK_Super); }
'global' { RET(TK_Global); }
'self' { RET(TK_Self); }
'stop' { RET(TK_Stop); }
'null' { RET(TK_Null); }

View File

@ -108,7 +108,6 @@ xx(TK_Virtual, "'virtual'")
xx(TK_Super, "'super'")
xx(TK_Null, "'null'")
xx(TK_Global, "'global'")
xx(TK_Self, "'self'")
xx(TK_Stop, "'stop'")
xx(TK_Include, "'include'")

View File

@ -977,13 +977,6 @@ primary(X) ::= IDENTIFIER(A).
expr->Type = NULL;
X = expr;
}
primary(X) ::= NULL(T).
{
NEW_AST_NODE(Expression, expr, T);
expr->Operation = PEX_Null;
expr->Type = NULL;
X = expr;
}
primary(X) ::= SUPER(T).
{
NEW_AST_NODE(Expression, expr, T);
@ -992,13 +985,7 @@ primary(X) ::= SUPER(T).
X = expr;
}
primary(X) ::= constant(A). { X = A; /*X-overwrites-A*/ }
primary(X) ::= SELF(T).
{
NEW_AST_NODE(Expression, expr, T);
expr->Operation = PEX_Self;
expr->Type = NULL;
X = expr;
}
primary(X) ::= LPAREN expr(A) RPAREN.
{
X = A; /*X-overwrites-A*/

View File

@ -2001,7 +2001,10 @@ void ZCCCompiler::InitFunctions()
{
Error(f, "The function '%s' has not been exported from the executable.", FName(f->Name).GetChars());
}
(*afd->VMPointer)->ImplicitArgs = BYTE(implicitargs);
else
{
(*afd->VMPointer)->ImplicitArgs = BYTE(implicitargs);
}
}
SetImplicitArgs(&args, &argflags, &argnames, c->Type(), varflags);
auto p = f->Params;

View File

@ -4,7 +4,6 @@ xx(Nil, TK_None)
xx(ID, TK_Identifier)
xx(Super, TK_Super)
xx(Null, TK_Null)
xx(Self, TK_Self)
xx(ConstValue, TK_Const)
xx(FuncCall, '(')
xx(ArrayAccess, TK_Array)

View File

@ -155,7 +155,6 @@ static void InitTokenMap()
TOKENDEF (TK_Optional, ZCC_OPTIONAL);
TOKENDEF (TK_Super, ZCC_SUPER);
TOKENDEF (TK_Null, ZCC_NULLPTR);
TOKENDEF (TK_Self, ZCC_SELF);
TOKENDEF ('~', ZCC_TILDE);
TOKENDEF ('!', ZCC_BANG);
TOKENDEF (TK_SizeOf, ZCC_SIZEOF);

View File

@ -44,7 +44,6 @@ enum
};
// Syntax tree structures.
enum EZCCTreeNodeType
{

View File

@ -47,7 +47,10 @@ class Actor : Thinker native
}
// Functions
native Actor P_SpawnMissile(Actor dest, class<Actor> type, Actor owner = null);
native Actor SpawnMissile(Actor dest, class<Actor> type, Actor owner = null);
native void TraceBleed(int damage, Actor missile);
native bool CheckMeleeRange();
native int DamageMobj(Actor inflictor, Actor source, int damage, Name mod, int flags = 0, double angle = 0);
// DECORATE compatible functions
native bool CheckClass(class<Actor> checkclass, int ptr_select = AAPTR_DEFAULT, bool match_superclass = false);
@ -110,13 +113,10 @@ class Actor : Thinker native
native void A_TroopAttack();
native void A_SargAttack();
native void A_HeadAttack();
native void A_BruisAttack();
native void A_SkullAttack(float speed = 20);
native void A_BetaSkullAttack();
native void A_Metal();
native void A_SpidRefire();
//native void A_BabyMetal();
//native void A_BspiAttack();
native void A_Hoof();
native void A_CyberAttack();
native void A_PainAttack(class<Actor> spawntype = "LostSoul", float angle = 0, int flags = 0, int limit = -1);

View File

@ -101,7 +101,7 @@ extend class Actor
if (target)
{
A_FaceTarget();
P_SpawnMissile(target, "ArachnotronPlasma");
SpawnMissile(target, "ArachnotronPlasma");
}
}

View File

@ -138,3 +138,30 @@ class BaronBall : Actor
}
}
//===========================================================================
//
// Code (must be attached to Actor)
//
//===========================================================================
extend class Actor
{
void A_BruisAttack()
{
if (target)
{
if (CheckMeleeRange())
{
int damage = random[pr_bruisattack](1, 8) * 10;
A_PlaySound ("baron/melee", CHAN_WEAPON);
int newdam = target.DamageMobj (self, self, damage, "Melee");
target.TraceBleed (newdam > 0 ? newdam : damage, self);
}
else
{
// launch a missile
SpawnMissile (target, "BaronBall");
}
}
}
}