- scriptified MorphProjectile and CustomSprite.

This should for now conclude actor class scriptification. The remaining ten classes with the exception of MorphedMonster are all too essential or too closely tied to engine feature so they should remain native.
This commit is contained in:
Christoph Oelckers 2017-01-20 01:11:36 +01:00
parent 3c30b59bab
commit c880b26d98
12 changed files with 83 additions and 160 deletions

View file

@ -157,13 +157,13 @@ bool P_MorphPlayer (player_t *activator, player_t *p, PClassPlayerPawn *spawntyp
DEFINE_ACTION_FUNCTION(_PlayerInfo, MorphPlayer)
{
PARAM_SELF_STRUCT_PROLOGUE(player_t);
PARAM_POINTER(victim, player_t);
PARAM_POINTER(activator, player_t);
PARAM_CLASS(spawntype, APlayerPawn);
PARAM_INT(duration);
PARAM_INT(style);
PARAM_CLASS_DEF(enter_flash, AActor);
PARAM_CLASS_DEF(exit_flash, AActor);
ACTION_RETURN_BOOL(P_MorphPlayer(self, victim, spawntype, duration, style, enter_flash, exit_flash));
ACTION_RETURN_BOOL(P_MorphPlayer(activator, self, spawntype, duration, style, enter_flash, exit_flash));
}
//----------------------------------------------------------------------------
@ -396,7 +396,7 @@ bool P_MorphMonster (AActor *actor, PClassActor *spawntype, int duration, int st
if (actor == NULL || actor->player || spawntype == NULL ||
actor->flags3 & MF3_DONTMORPH ||
!(actor->flags3 & MF3_ISMONSTER) ||
!spawntype->IsDescendantOf (RUNTIME_CLASS(AMorphedMonster)))
!spawntype->IsDescendantOf (PClass::FindActor(NAME_MorphedMonster)))
{
return false;
}
@ -440,6 +440,17 @@ bool P_MorphMonster (AActor *actor, PClassActor *spawntype, int duration, int st
return true;
}
DEFINE_ACTION_FUNCTION(AActor, MorphMonster)
{
PARAM_SELF_PROLOGUE(AActor);
PARAM_CLASS(spawntype, APlayerPawn);
PARAM_INT(duration);
PARAM_INT(style);
PARAM_CLASS_DEF(enter_flash, AActor);
PARAM_CLASS_DEF(exit_flash, AActor);
ACTION_RETURN_BOOL(P_MorphMonster(self, spawntype, duration, style, enter_flash, exit_flash));
}
//----------------------------------------------------------------------------
//
// FUNC P_UndoMonsterMorph
@ -635,50 +646,6 @@ void InitAllPowerupEffects(AInventory *item)
}
}
// Base class for morphing projectiles --------------------------------------
IMPLEMENT_CLASS(AMorphProjectile, false, true)
IMPLEMENT_POINTERS_START(AMorphProjectile)
IMPLEMENT_POINTER(PlayerClass)
IMPLEMENT_POINTER(MonsterClass)
IMPLEMENT_POINTER(MorphFlash)
IMPLEMENT_POINTER(UnMorphFlash)
IMPLEMENT_POINTERS_END
DEFINE_FIELD(AMorphProjectile, PlayerClass)
DEFINE_FIELD(AMorphProjectile, MonsterClass)
DEFINE_FIELD(AMorphProjectile, MorphFlash)
DEFINE_FIELD(AMorphProjectile, UnMorphFlash)
DEFINE_FIELD(AMorphProjectile, Duration)
DEFINE_FIELD(AMorphProjectile, MorphStyle)
int AMorphProjectile::DoSpecialDamage (AActor *target, int damage, FName damagetype)
{
if (target->player)
{
P_MorphPlayer (NULL, target->player, PlayerClass, Duration, MorphStyle, MorphFlash, UnMorphFlash);
}
else
{
P_MorphMonster (target, MonsterClass, Duration, MorphStyle, MorphFlash, UnMorphFlash);
}
return -1;
}
void AMorphProjectile::Serialize(FSerializer &arc)
{
Super::Serialize (arc);
auto def = (AMorphProjectile*)GetDefault();
arc("playerclass", PlayerClass, def->PlayerClass)
("monsterclass", MonsterClass, def->MonsterClass)
("duration", Duration, def->Duration)
("morphstyle", MorphStyle, def->MorphStyle)
("morphflash", MorphFlash, def->MorphFlash)
("unmorphflash", UnMorphFlash, def->UnMorphFlash);
}
// Morphed Monster (you must subclass this to do something useful) ---------
IMPLEMENT_CLASS(AMorphedMonster, false, true)

View file

@ -76,31 +76,6 @@ private:
DImpactDecal();
};
class ASkyViewpoint : public AActor
{
DECLARE_CLASS (ASkyViewpoint, AActor)
public:
void BeginPlay ();
void OnDestroy() override;
};
// For an EE compatible linedef based definition.
class ASkyCamCompat : public ASkyViewpoint
{
DECLARE_CLASS (ASkyCamCompat, ASkyViewpoint)
public:
void BeginPlay();
};
class AStackPoint : public ASkyViewpoint
{
DECLARE_CLASS (AStackPoint, ASkyViewpoint)
public:
void BeginPlay ();
};
class DFlashFader : public DThinker
{
DECLARE_CLASS (DFlashFader, DThinker)
@ -177,20 +152,6 @@ private:
DEarthquake ();
};
class AMorphProjectile : public AActor
{
DECLARE_CLASS (AMorphProjectile, AActor)
HAS_OBJECT_POINTERS;
public:
int DoSpecialDamage (AActor *target, int damage, FName damagetype);
void Serialize(FSerializer &arc);
PClassPlayerPawn *PlayerClass;
PClassActor *MonsterClass, *MorphFlash, *UnMorphFlash;
int Duration, MorphStyle;
};
class AMorphedMonster : public AActor
{
DECLARE_CLASS (AMorphedMonster, AActor)

View file

@ -779,8 +779,10 @@ void GLSprite::Process(AActor* thing, sector_t * sector, int thruportal)
vt = gltexture->GetSpriteVT();
vb = gltexture->GetSpriteVB();
if (thing->renderflags & RF_YFLIP) std::swap(vt, vb);
gltexture->GetSpriteRect(&r);
if (mirror)
if (mirror ^ !!(thing->renderflags & RF_XFLIP))
{
r.left = -r.width - r.left; // mirror the sprite's x-offset
ul = gltexture->GetSpriteUL();

View file

@ -726,8 +726,11 @@ xx(MoveBob)
xx(StillBob)
xx(WBobSpeed)
xx(PlayerClass)
xx(MonsterClass)
xx(MorphedMonster)
xx(Wi_NoAutostartMap)
xx(Duration)
xx(MorphStyle)
xx(MorphFlash)
xx(UnMorphFlash)

View file

@ -854,45 +854,3 @@ static void Decrypt (void *to_, const void *from_, int len, int key)
}
#endif
//==========================================================================
//
// Just an actor to make the Build sprites show up. It doesn't do anything
// with them other than display them.
//
//==========================================================================
class ACustomSprite : public AActor
{
DECLARE_CLASS (ACustomSprite, AActor);
public:
void BeginPlay ();
};
IMPLEMENT_CLASS(ACustomSprite, false, false)
void ACustomSprite::BeginPlay ()
{
char name[9];
Super::BeginPlay ();
mysnprintf (name, countof(name), "BTIL%04d", args[0] & 0xffff);
picnum = TexMan.GetTexture (name, FTexture::TEX_Build);
Scale.X = args[2] / 64.;
Scale.Y = args[3] / 64.;
int cstat = args[4];
if (cstat & 2)
{
RenderStyle = STYLE_Translucent;
Alpha = (cstat & 512) ? 0.6666 : 0.3333;
}
if (cstat & 4)
renderflags |= RF_XFLIP;
if (cstat & 8)
renderflags |= RF_YFLIP;
// set face/wall/floor flags
renderflags |= ActorRenderFlags::FromInt (((cstat >> 4) & 3) << 12);
}

View file

@ -278,20 +278,6 @@ enum
SECSPAC_HitFakeFloor= 1024, // Trigger when player hits fake floor
};
class ASectorAction : public AActor
{
DECLARE_CLASS (ASectorAction, AActor)
public:
void OnDestroy() override;
void BeginPlay ();
void Activate (AActor *source);
void Deactivate (AActor *source);
bool CanTrigger (AActor *triggerer) const;
virtual bool DoTriggerAction(AActor *triggerer, int activationType);
protected:
bool CheckTrigger(AActor *triggerer) const;
};
struct secplane_t
{
// the plane is defined as a*x + b*y + c*z + d = 0

View file

@ -324,6 +324,8 @@ static FFlagDef ActorFlagDefs[]=
DEFINE_FLAG(RF, MASKROTATION, AActor, renderflags),
DEFINE_FLAG(RF, ABSMASKANGLE, AActor, renderflags),
DEFINE_FLAG(RF, ABSMASKPITCH, AActor, renderflags),
DEFINE_FLAG(RF, XFLIP, AActor, renderflags),
DEFINE_FLAG(RF, YFLIP, AActor, renderflags),
// Bounce flags
DEFINE_FLAG2(BOUNCE_Walls, BOUNCEONWALLS, AActor, BounceFlags),

View file

@ -2780,55 +2780,55 @@ DEFINE_CLASS_PROPERTY_PREFIX(player, viewbob, F, PlayerPawn)
//==========================================================================
// (non-fatal with non-existent types only in DECORATE)
//==========================================================================
DEFINE_CLASS_PROPERTY(playerclass, S, MorphProjectile)
DEFINE_SCRIPTED_PROPERTY(playerclass, S, MorphProjectile)
{
PROP_STRING_PARM(str, 0);
defaults->PlayerClass = FindClassTentativePlayerPawn(str, bag.fromDecorate);
defaults->PointerVar<PClassActor>(NAME_PlayerClass) = FindClassTentativePlayerPawn(str, bag.fromDecorate);
}
//==========================================================================
// (non-fatal with non-existent types only in DECORATE)
//==========================================================================
DEFINE_CLASS_PROPERTY(monsterclass, S, MorphProjectile)
DEFINE_SCRIPTED_PROPERTY(monsterclass, S, MorphProjectile)
{
PROP_STRING_PARM(str, 0);
defaults->MonsterClass = FindClassTentative(str, RUNTIME_CLASS(AActor), bag.fromDecorate);
defaults->PointerVar<PClassActor>(NAME_MonsterClass) = FindClassTentative(str, RUNTIME_CLASS(AActor), bag.fromDecorate);
}
//==========================================================================
//
//==========================================================================
DEFINE_CLASS_PROPERTY(duration, I, MorphProjectile)
DEFINE_SCRIPTED_PROPERTY(duration, I, MorphProjectile)
{
PROP_INT_PARM(i, 0);
defaults->Duration = i >= 0 ? i : -i*TICRATE;
defaults->IntVar(NAME_Duration) = i >= 0 ? i : -i*TICRATE;
}
//==========================================================================
//
//==========================================================================
DEFINE_CLASS_PROPERTY(morphstyle, M, MorphProjectile)
DEFINE_SCRIPTED_PROPERTY(morphstyle, M, MorphProjectile)
{
PROP_INT_PARM(i, 0);
defaults->MorphStyle = i;
defaults->IntVar(NAME_MorphStyle) = i;
}
//==========================================================================
// (non-fatal with non-existent types only in DECORATE)
//==========================================================================
DEFINE_CLASS_PROPERTY(morphflash, S, MorphProjectile)
DEFINE_SCRIPTED_PROPERTY(morphflash, S, MorphProjectile)
{
PROP_STRING_PARM(str, 0);
defaults->MorphFlash = FindClassTentative(str, RUNTIME_CLASS(AActor), bag.fromDecorate);
defaults->PointerVar<PClassActor>(NAME_MorphFlash) = FindClassTentative(str, RUNTIME_CLASS(AActor), bag.fromDecorate);
}
//==========================================================================
//
//==========================================================================
DEFINE_CLASS_PROPERTY(unmorphflash, S, MorphProjectile)
DEFINE_SCRIPTED_PROPERTY(unmorphflash, S, MorphProjectile)
{
PROP_STRING_PARM(str, 0);
defaults->UnMorphFlash = FindClassTentative(str, RUNTIME_CLASS(AActor), bag.fromDecorate);
defaults->PointerVar<PClassActor>(NAME_UnMorphFlash) = FindClassTentative(str, RUNTIME_CLASS(AActor), bag.fromDecorate);
}
//==========================================================================

View file

@ -497,6 +497,7 @@ class Actor : Thinker native
native bool GiveAmmo (Class<Ammo> type, int amount);
native bool UsePuzzleItem(int PuzzleItemType);
native float AccuracyFactor();
native bool MorphMonster (Class<Actor> spawntype, int duration, int style, Class<Actor> enter_flash, Class<Actor> exit_flash);
// DECORATE compatible functions
native int CountInv(class<Inventory> itemtype, int ptr_select = AAPTR_DEFAULT);

View file

@ -65,6 +65,7 @@ class Inventory : Actor native
Stop;
}
//===========================================================================
//
// AInventory :: BeginPlay

View file

@ -1,9 +1,9 @@
class MorphProjectile : Actor native
class MorphProjectile : Actor
{
native Class<PlayerPawn> PlayerClass;
native Class<Actor> MonsterClass, MorphFlash, UnMorphFlash;
native int Duration, MorphStyle;
Class<PlayerPawn> PlayerClass;
Class<Actor> MonsterClass, MorphFlash, UnMorphFlash;
int Duration, MorphStyle;
Default
{
@ -12,6 +12,21 @@ class MorphProjectile : Actor native
-ACTIVATEIMPACT
-ACTIVATEPCROSS
}
override int DoSpecialDamage (Actor target, int damage, Name damagetype)
{
if (target.player)
{
target.player.MorphPlayer (NULL, PlayerClass, Duration, MorphStyle, MorphFlash, UnMorphFlash);
}
else
{
target.MorphMonster (MonsterClass, Duration, MorphStyle, MorphFlash, UnMorphFlash);
}
return -1;
}
}
class MorphedMonster : Actor native

View file

@ -140,7 +140,7 @@ class Gibs : RealGibs
// Needed for loading Build maps -------------------------------------------
class CustomSprite : Actor native
class CustomSprite : Actor
{
Default
{
@ -153,6 +153,33 @@ class CustomSprite : Actor native
TNT1 A -1;
Stop;
}
override void BeginPlay ()
{
String name;
Super.BeginPlay ();
format(name, "BTIL%04d", args[0] & 0xffff);
picnum = TexMan.CheckForTexture (name, TexMan.TYPE_Build);
if (!picnum.Exists())
{
Destroy();
return;
}
Scale.X = args[2] / 64.;
Scale.Y = args[3] / 64.;
int cstat = args[4];
if (cstat & 2)
{
A_SetRenderStyle((cstat & 512) ? 0.6666 : 0.3333, STYLE_Translucent);
}
if (cstat & 4) bXFlip = true;
if (cstat & 8) bYFlip = true;
if (cstat & 16) bWallSprite = true;
if (cstat & 32) bFlatSprite = true;
}
}
// SwitchableDecoration: Activate and Deactivate change state --------------