- scriptified two of the Acolyte's functions.

- added a DActorIterator class.
- fixed: It was not possible to have functions of the same name in two different classes because the name they were searched for was not qualified by the class. Changed so that the class name is included now, but to avoid renaming several hundreds of functions all at once, if the search fails, it will repeat with 'Actor' as class name.

This commit contains preparations for scriptifying Hexen's Dragon, but that doesn't work yet so it's not included.
This commit is contained in:
Christoph Oelckers 2016-11-16 01:36:21 +01:00
parent a2e17c0ab5
commit 633da6e5d8
32 changed files with 334 additions and 260 deletions

View file

@ -881,7 +881,6 @@ set( NOT_COMPILED_SOURCE_FILES
g_hexen/a_clericholy.cpp g_hexen/a_clericholy.cpp
g_hexen/a_clericmace.cpp g_hexen/a_clericmace.cpp
g_hexen/a_clericstaff.cpp g_hexen/a_clericstaff.cpp
g_hexen/a_dragon.cpp
g_hexen/a_fighteraxe.cpp g_hexen/a_fighteraxe.cpp
g_hexen/a_fighterhammer.cpp g_hexen/a_fighterhammer.cpp
g_hexen/a_fighterplayer.cpp g_hexen/a_fighterplayer.cpp

View file

@ -1442,6 +1442,10 @@ public:
return base; return base;
} }
void Reinit()
{
base = nullptr;
}
private: private:
AActor *base; AActor *base;
int id; int id;

View file

@ -185,17 +185,17 @@ DECLARE_ACTION(A_FireRailgun)
// Default ammo use of the various weapon attacks // Default ammo use of the various weapon attacks
static AmmoPerAttack AmmoPerAttacks[] = { static AmmoPerAttack AmmoPerAttacks[] = {
{ &A_Punch_VMPtr, 0}, { &AActor_A_Punch_VMPtr, 0},
{ &A_FirePistol_VMPtr, 1}, { &AActor_A_FirePistol_VMPtr, 1},
{ &A_FireShotgun_VMPtr, 1}, { &AActor_A_FireShotgun_VMPtr, 1},
{ &A_FireShotgun2_VMPtr, 2}, { &AActor_A_FireShotgun2_VMPtr, 2},
{ &A_FireCGun_VMPtr, 1}, { &AActor_A_FireCGun_VMPtr, 1},
{ &A_FireMissile_VMPtr, 1}, { &AActor_A_FireMissile_VMPtr, 1},
{ &A_Saw_VMPtr, 0}, { &AActor_A_Saw_VMPtr, 0},
{ &A_FirePlasma_VMPtr, 1}, { &AActor_A_FirePlasma_VMPtr, 1},
{ &A_FireBFG_VMPtr, -1}, // uses deh.BFGCells { &AActor_A_FireBFG_VMPtr, -1}, // uses deh.BFGCells
{ &A_FireOldBFG_VMPtr, 1}, { &AActor_A_FireOldBFG_VMPtr, 1},
{ &A_FireRailgun_VMPtr, 1}, { &AActor_A_FireRailgun_VMPtr, 1},
{ NULL, 0} { NULL, 0}
}; };

View file

@ -14,7 +14,7 @@
static FRandom pr_spawnfly ("SpawnFly"); static FRandom pr_spawnfly ("SpawnFly");
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_BrainSpit) DEFINE_ACTION_FUNCTION(AActor, A_BrainSpit)
{ {
PARAM_SELF_PROLOGUE(AActor); PARAM_SELF_PROLOGUE(AActor);
PARAM_CLASS_DEF(spawntype, AActor); PARAM_CLASS_DEF(spawntype, AActor);

View file

@ -113,7 +113,7 @@ enum SAW_Flags
SF_STEALARMOR = 128, SF_STEALARMOR = 128,
}; };
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Saw) DEFINE_ACTION_FUNCTION(AActor, A_Saw)
{ {
PARAM_ACTION_PROLOGUE(AActor); PARAM_ACTION_PROLOGUE(AActor);
PARAM_SOUND_DEF (fullsound) PARAM_SOUND_DEF (fullsound)
@ -454,7 +454,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FireMissile)
// //
// A_FireSTGrenade: not exactly backported from ST, but should work the same // A_FireSTGrenade: not exactly backported from ST, but should work the same
// //
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_FireSTGrenade) DEFINE_ACTION_FUNCTION(AActor, A_FireSTGrenade)
{ {
PARAM_ACTION_PROLOGUE(AActor); PARAM_ACTION_PROLOGUE(AActor);
PARAM_CLASS_DEF(grenade, AActor); PARAM_CLASS_DEF(grenade, AActor);
@ -607,7 +607,7 @@ enum BFG_Flags
BFGF_MISSILEORIGIN = 2, BFGF_MISSILEORIGIN = 2,
}; };
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_BFGSpray) DEFINE_ACTION_FUNCTION(AActor, A_BFGSpray)
{ {
PARAM_SELF_PROLOGUE(AActor); PARAM_SELF_PROLOGUE(AActor);
PARAM_CLASS_DEF (spraytype, AActor) PARAM_CLASS_DEF (spraytype, AActor)

View file

@ -148,7 +148,7 @@ void AScriptedMarine::Tick ()
// //
//============================================================================ //============================================================================
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_M_Refire) DEFINE_ACTION_FUNCTION(AActor, A_M_Refire)
{ {
PARAM_SELF_PROLOGUE(AActor); PARAM_SELF_PROLOGUE(AActor);
PARAM_BOOL_DEF(ignoremissile); PARAM_BOOL_DEF(ignoremissile);
@ -247,7 +247,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_MarineLook)
// //
//============================================================================ //============================================================================
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_M_Saw) DEFINE_ACTION_FUNCTION(AActor, A_M_Saw)
{ {
PARAM_SELF_PROLOGUE(AActor); PARAM_SELF_PROLOGUE(AActor);
PARAM_SOUND_DEF (fullsound) PARAM_SOUND_DEF (fullsound)
@ -345,7 +345,7 @@ static void MarinePunch(AActor *self, int damagemul)
} }
} }
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_M_Punch) DEFINE_ACTION_FUNCTION(AActor, A_M_Punch)
{ {
PARAM_SELF_PROLOGUE(AActor); PARAM_SELF_PROLOGUE(AActor);
PARAM_INT(mult); PARAM_INT(mult);
@ -382,7 +382,7 @@ void P_GunShot2 (AActor *mo, bool accurate, DAngle pitch, PClassActor *pufftype)
// //
//============================================================================ //============================================================================
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_M_FirePistol) DEFINE_ACTION_FUNCTION(AActor, A_M_FirePistol)
{ {
PARAM_SELF_PROLOGUE(AActor); PARAM_SELF_PROLOGUE(AActor);
PARAM_BOOL(accurate); PARAM_BOOL(accurate);
@ -481,7 +481,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_M_FireShotgun2)
// //
//============================================================================ //============================================================================
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_M_FireCGun) DEFINE_ACTION_FUNCTION(AActor, A_M_FireCGun)
{ {
PARAM_SELF_PROLOGUE(AActor); PARAM_SELF_PROLOGUE(AActor);
PARAM_BOOL(accurate); PARAM_BOOL(accurate);

View file

@ -42,7 +42,7 @@ static FRandom pr_volcimpact ("VolcBallImpact");
// //
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_PodPain) DEFINE_ACTION_FUNCTION(AActor, A_PodPain)
{ {
PARAM_SELF_PROLOGUE(AActor); PARAM_SELF_PROLOGUE(AActor);
PARAM_CLASS_DEF (gootype, AActor) PARAM_CLASS_DEF (gootype, AActor)
@ -97,7 +97,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_RemovePod)
#define MAX_GEN_PODS 16 #define MAX_GEN_PODS 16
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_MakePod) DEFINE_ACTION_FUNCTION(AActor, A_MakePod)
{ {
PARAM_SELF_PROLOGUE(AActor); PARAM_SELF_PROLOGUE(AActor);
PARAM_CLASS_DEF(podtype, AActor) PARAM_CLASS_DEF(podtype, AActor)

View file

@ -59,7 +59,7 @@ extern bool P_AutoUseChaosDevice (player_t *player);
// //
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_StaffAttack) DEFINE_ACTION_FUNCTION(AActor, A_StaffAttack)
{ {
PARAM_ACTION_PROLOGUE(AActor); PARAM_ACTION_PROLOGUE(AActor);
@ -245,7 +245,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FireCrossbowPL2)
// //
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_GauntletAttack) DEFINE_ACTION_FUNCTION(AActor, A_GauntletAttack)
{ {
PARAM_ACTION_PROLOGUE(AActor); PARAM_ACTION_PROLOGUE(AActor);

View file

@ -93,7 +93,7 @@ enum
// //
//========================================================================== //==========================================================================
DEFINE_ACTION_FUNCTION_PARAMS (AActor, A_Blast) DEFINE_ACTION_FUNCTION (AActor, A_Blast)
{ {
PARAM_ACTION_PROLOGUE(AActor); PARAM_ACTION_PROLOGUE(AActor);
PARAM_INT_DEF (blastflags) PARAM_INT_DEF (blastflags)

View file

@ -24,7 +24,7 @@ static FRandom pr_fswordflame ("FSwordFlame");
// //
//============================================================================ //============================================================================
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_DropWeaponPieces) DEFINE_ACTION_FUNCTION(AActor, A_DropWeaponPieces)
{ {
PARAM_SELF_PROLOGUE(AActor); PARAM_SELF_PROLOGUE(AActor);
PARAM_CLASS(p1, AActor); PARAM_CLASS(p1, AActor);

View file

@ -255,7 +255,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_LightningZap)
// //
//============================================================================ //============================================================================
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_MLightningAttack) DEFINE_ACTION_FUNCTION(AActor, A_MLightningAttack)
{ {
PARAM_ACTION_PROLOGUE(AActor); PARAM_ACTION_PROLOGUE(AActor);
PARAM_CLASS_DEF(floor, AActor); PARAM_CLASS_DEF(floor, AActor);

View file

@ -119,7 +119,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_BridgeOrbit)
} }
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_BridgeInit) DEFINE_ACTION_FUNCTION(AActor, A_BridgeInit)
{ {
PARAM_SELF_PROLOGUE(AActor); PARAM_SELF_PROLOGUE(AActor);
PARAM_CLASS_DEF(balltype, AActor); PARAM_CLASS_DEF(balltype, AActor);

View file

@ -377,7 +377,7 @@ void ASpecialSpot::Destroy()
// will build a list of all mace spots in the level and spawn a // will build a list of all mace spots in the level and spawn a
// mace. The rest of the spots will do nothing. // mace. The rest of the spots will do nothing.
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SpawnSingleItem) DEFINE_ACTION_FUNCTION(AActor, A_SpawnSingleItem)
{ {
PARAM_SELF_PROLOGUE(AActor); PARAM_SELF_PROLOGUE(AActor);
PARAM_CLASS (cls, AActor); PARAM_CLASS (cls, AActor);

View file

@ -1923,7 +1923,7 @@ PClassWeapon *Net_ReadWeapon(BYTE **stream)
// //
//=========================================================================== //===========================================================================
DEFINE_ACTION_FUNCTION_PARAMS(AWeapon, A_ZoomFactor) DEFINE_ACTION_FUNCTION(AWeapon, A_ZoomFactor)
{ {
PARAM_ACTION_PROLOGUE(AActor); PARAM_ACTION_PROLOGUE(AActor);
PARAM_FLOAT_DEF(zoom); PARAM_FLOAT_DEF(zoom);
@ -1951,7 +1951,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AWeapon, A_ZoomFactor)
// //
//=========================================================================== //===========================================================================
DEFINE_ACTION_FUNCTION_PARAMS(AWeapon, A_SetCrosshair) DEFINE_ACTION_FUNCTION(AWeapon, A_SetCrosshair)
{ {
PARAM_ACTION_PROLOGUE(AActor); PARAM_ACTION_PROLOGUE(AActor);
PARAM_INT(xhair); PARAM_INT(xhair);

View file

@ -84,47 +84,3 @@ DEFINE_ACTION_FUNCTION(AActor, A_AcolyteDie)
return 0; return 0;
} }
//============================================================================
//
// A_BeShadowyFoe
//
//============================================================================
DEFINE_ACTION_FUNCTION(AActor, A_BeShadowyFoe)
{
PARAM_SELF_PROLOGUE(AActor);
self->RenderStyle = STYLE_Translucent;
self->Alpha = HR_SHADOW;
self->flags &= ~MF_FRIENDLY;
return 0;
}
//============================================================================
//
// A_AcolyteBits
//
//============================================================================
DEFINE_ACTION_FUNCTION(AActor, A_AcolyteBits)
{
PARAM_SELF_PROLOGUE(AActor);
if (self->SpawnFlags & MTF_SHADOW)
{
CALL_ACTION(A_BeShadowyFoe, self);
}
if (self->SpawnFlags & MTF_ALTSHADOW)
{
//self->flags |= MF_STRIFEx8000000;
if (self->flags & MF_SHADOW)
{
// I dunno.
}
else
{
self->RenderStyle.BlendOp = STYLEOP_None;
}
}
return 0;
}

View file

@ -144,7 +144,7 @@ enum
AMF_EMITFROMTARGET = 4, AMF_EMITFROMTARGET = 4,
}; };
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_AlertMonsters) DEFINE_ACTION_FUNCTION(AActor, A_AlertMonsters)
{ {
PARAM_SELF_PROLOGUE(AActor); PARAM_SELF_PROLOGUE(AActor);
PARAM_FLOAT_DEF(maxdist); PARAM_FLOAT_DEF(maxdist);
@ -246,7 +246,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_ShowElectricFlash)
// //
//============================================================================ //============================================================================
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_FireArrow) DEFINE_ACTION_FUNCTION(AActor, A_FireArrow)
{ {
PARAM_ACTION_PROLOGUE(AActor); PARAM_ACTION_PROLOGUE(AActor);
PARAM_CLASS(ti, AActor); PARAM_CLASS(ti, AActor);
@ -686,7 +686,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_Burnination)
// //
//============================================================================ //============================================================================
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_FireGrenade) DEFINE_ACTION_FUNCTION(AActor, A_FireGrenade)
{ {
PARAM_ACTION_PROLOGUE(AActor); PARAM_ACTION_PROLOGUE(AActor);
PARAM_CLASS(grenadetype, AActor); PARAM_CLASS(grenadetype, AActor);

View file

@ -26,7 +26,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_Bang4Cloud)
// ------------------------------------------------------------------- // -------------------------------------------------------------------
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_GiveQuestItem) DEFINE_ACTION_FUNCTION(AActor, A_GiveQuestItem)
{ {
PARAM_SELF_PROLOGUE(AActor); PARAM_SELF_PROLOGUE(AActor);
PARAM_INT(questitem); PARAM_INT(questitem);

File diff suppressed because it is too large Load diff

View file

@ -1942,7 +1942,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_Look)
// //
//========================================================================== //==========================================================================
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_LookEx) DEFINE_ACTION_FUNCTION(AActor, A_LookEx)
{ {
PARAM_SELF_PROLOGUE(AActor); PARAM_SELF_PROLOGUE(AActor);
PARAM_INT_DEF (flags) PARAM_INT_DEF (flags)
@ -2159,7 +2159,7 @@ enum ChaseFlags
CHF_STOPIFBLOCKED = 256, CHF_STOPIFBLOCKED = 256,
}; };
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Wander) DEFINE_ACTION_FUNCTION(AActor, A_Wander)
{ {
PARAM_SELF_PROLOGUE(AActor); PARAM_SELF_PROLOGUE(AActor);
PARAM_INT_DEF(flags); PARAM_INT_DEF(flags);
@ -2801,7 +2801,7 @@ static bool P_CheckForResurrection(AActor *self, bool usevilestates)
// //
//========================================================================== //==========================================================================
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Chase) DEFINE_ACTION_FUNCTION(AActor, A_Chase)
{ {
PARAM_SELF_PROLOGUE(AActor); PARAM_SELF_PROLOGUE(AActor);
PARAM_STATE_DEF (melee) PARAM_STATE_DEF (melee)
@ -2840,7 +2840,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_VileChase)
return 0; return 0;
} }
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_ExtChase) DEFINE_ACTION_FUNCTION(AActor, A_ExtChase)
{ {
PARAM_SELF_PROLOGUE(AActor); PARAM_SELF_PROLOGUE(AActor);
PARAM_BOOL (domelee); PARAM_BOOL (domelee);
@ -2980,7 +2980,7 @@ void A_FaceTarget(AActor *self)
A_Face(self, self->target); A_Face(self, self->target);
} }
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Face) DEFINE_ACTION_FUNCTION(AActor, A_Face)
{ {
PARAM_SELF_PROLOGUE(AActor); PARAM_SELF_PROLOGUE(AActor);
PARAM_OBJECT(faceto, AActor) PARAM_OBJECT(faceto, AActor)

View file

@ -3098,6 +3098,13 @@ void AActor::RemoveFromHash ()
tid = 0; tid = 0;
} }
DEFINE_ACTION_FUNCTION(AActor, RemoveFromHash)
{
PARAM_SELF_PROLOGUE(AActor);
self->RemoveFromHash();
return 0;
}
//========================================================================== //==========================================================================
// //
// P_IsTIDUsed // P_IsTIDUsed
@ -6886,6 +6893,42 @@ void AActor::SetTranslation(const char *trname)
// silently ignore if the name does not exist, this would create some insane message spam otherwise. // silently ignore if the name does not exist, this would create some insane message spam otherwise.
} }
class DActorIterator : public DObject, public NActorIterator
{
DECLARE_CLASS(DActorIterator, DObject)
public:
DActorIterator(PClassActor *cls= nullptr, int tid = 0)
: NActorIterator(cls, tid)
{
}
};
IMPLEMENT_CLASS(DActorIterator, false, false, false, false);
DEFINE_ACTION_FUNCTION(DActorIterator, Create)
{
PARAM_PROLOGUE;
PARAM_INT_DEF(tid);
PARAM_CLASS_DEF(type, AActor);
ACTION_RETURN_OBJECT(new DActorIterator(type, tid));
}
DEFINE_ACTION_FUNCTION(DActorIterator, Next)
{
PARAM_SELF_PROLOGUE(DActorIterator);
ACTION_RETURN_OBJECT(self->Next());
}
DEFINE_ACTION_FUNCTION(DActorIterator, Reinit)
{
PARAM_SELF_PROLOGUE(DActorIterator);
self->Reinit();
return 0;
}
DEFINE_ACTION_FUNCTION(AActor, deltaangle) // should this be global? DEFINE_ACTION_FUNCTION(AActor, deltaangle) // should this be global?
{ {
PARAM_PROLOGUE; PARAM_PROLOGUE;
@ -6894,6 +6937,14 @@ DEFINE_ACTION_FUNCTION(AActor, deltaangle) // should this be global?
ACTION_RETURN_FLOAT(deltaangle(DAngle(a1), DAngle(a2)).Degrees); ACTION_RETURN_FLOAT(deltaangle(DAngle(a1), DAngle(a2)).Degrees);
} }
DEFINE_ACTION_FUNCTION(AActor, absangle) // should this be global?
{
PARAM_PROLOGUE;
PARAM_FLOAT(a1);
PARAM_FLOAT(a2);
ACTION_RETURN_FLOAT(absangle(DAngle(a1), DAngle(a2)).Degrees);
}
DEFINE_ACTION_FUNCTION(AActor, Distance2D) DEFINE_ACTION_FUNCTION(AActor, Distance2D)
{ {
PARAM_SELF_PROLOGUE(AActor); PARAM_SELF_PROLOGUE(AActor);

View file

@ -772,7 +772,7 @@ void DoReadyWeapon(AActor *self)
DoReadyWeaponToGeneric(self, ~0); DoReadyWeaponToGeneric(self, ~0);
} }
DEFINE_ACTION_FUNCTION_PARAMS(AInventory, A_WeaponReady) DEFINE_ACTION_FUNCTION(AStateProvider, A_WeaponReady)
{ {
PARAM_ACTION_PROLOGUE(AActor); PARAM_ACTION_PROLOGUE(AActor);
PARAM_INT_DEF(flags); PARAM_INT_DEF(flags);
@ -904,7 +904,7 @@ static void P_CheckWeaponButtons (player_t *player)
// //
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
DEFINE_ACTION_FUNCTION_PARAMS(AInventory, A_ReFire) DEFINE_ACTION_FUNCTION(AStateProvider, A_ReFire)
{ {
PARAM_ACTION_PROLOGUE(AActor); PARAM_ACTION_PROLOGUE(AActor);
PARAM_STATE_ACTION_DEF(state); PARAM_STATE_ACTION_DEF(state);
@ -942,7 +942,7 @@ void A_ReFire(AActor *self, FState *state)
} }
} }
DEFINE_ACTION_FUNCTION(AInventory, A_ClearReFire) DEFINE_ACTION_FUNCTION(AStateProvider, A_ClearReFire)
{ {
PARAM_ACTION_PROLOGUE(AActor); PARAM_ACTION_PROLOGUE(AActor);
player_t *player = self->player; player_t *player = self->player;
@ -964,7 +964,7 @@ DEFINE_ACTION_FUNCTION(AInventory, A_ClearReFire)
// //
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
DEFINE_ACTION_FUNCTION(AInventory, A_CheckReload) DEFINE_ACTION_FUNCTION(AStateProvider, A_CheckReload)
{ {
PARAM_ACTION_PROLOGUE(AActor); PARAM_ACTION_PROLOGUE(AActor);
@ -1152,7 +1152,7 @@ DEFINE_ACTION_FUNCTION(AActor, OverlayID)
// //
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
DEFINE_ACTION_FUNCTION(AInventory, A_Lower) DEFINE_ACTION_FUNCTION(AStateProvider, A_Lower)
{ {
PARAM_ACTION_PROLOGUE(AActor); PARAM_ACTION_PROLOGUE(AActor);
@ -1200,7 +1200,7 @@ DEFINE_ACTION_FUNCTION(AInventory, A_Lower)
// //
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
DEFINE_ACTION_FUNCTION(AInventory, A_Raise) DEFINE_ACTION_FUNCTION(AActor, A_Raise)
{ {
PARAM_ACTION_PROLOGUE(AActor); PARAM_ACTION_PROLOGUE(AActor);
@ -1241,7 +1241,7 @@ DEFINE_ACTION_FUNCTION(AInventory, A_Raise)
// //
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Overlay) DEFINE_ACTION_FUNCTION(AActor, A_Overlay)
{ {
PARAM_ACTION_PROLOGUE(AActor); PARAM_ACTION_PROLOGUE(AActor);
PARAM_INT (layer); PARAM_INT (layer);
@ -1261,7 +1261,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Overlay)
ACTION_RETURN_BOOL(true); ACTION_RETURN_BOOL(true);
} }
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_ClearOverlays) DEFINE_ACTION_FUNCTION(AActor, A_ClearOverlays)
{ {
PARAM_SELF_PROLOGUE(AActor); PARAM_SELF_PROLOGUE(AActor);
PARAM_INT_DEF(start); PARAM_INT_DEF(start);
@ -1312,7 +1312,7 @@ enum GF_Flags
GFF_NOEXTCHANGE = 1, GFF_NOEXTCHANGE = 1,
}; };
DEFINE_ACTION_FUNCTION_PARAMS(AInventory, A_GunFlash) DEFINE_ACTION_FUNCTION(AStateProvider, A_GunFlash)
{ {
PARAM_ACTION_PROLOGUE(AActor); PARAM_ACTION_PROLOGUE(AActor);
PARAM_STATE_ACTION_DEF(flash); PARAM_STATE_ACTION_DEF(flash);
@ -1415,7 +1415,7 @@ void P_GunShot (AActor *mo, bool accurate, PClassActor *pufftype, DAngle pitch)
P_LineAttack (mo, angle, PLAYERMISSILERANGE, pitch, damage, NAME_Hitscan, pufftype); P_LineAttack (mo, angle, PLAYERMISSILERANGE, pitch, damage, NAME_Hitscan, pufftype);
} }
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Light) DEFINE_ACTION_FUNCTION(AActor, A_Light)
{ {
PARAM_SELF_PROLOGUE(AActor); PARAM_SELF_PROLOGUE(AActor);
PARAM_INT(light); PARAM_INT(light);

View file

@ -343,7 +343,7 @@ DEFINE_ACTION_FUNCTION(AActor, FindState)
} }
// same as above but context aware. // same as above but context aware.
DEFINE_ACTION_FUNCTION_PARAMS(AActor, ResolveState) DEFINE_ACTION_FUNCTION(AActor, ResolveState)
{ {
PARAM_ACTION_PROLOGUE(AActor); PARAM_ACTION_PROLOGUE(AActor);
PARAM_STATE_ACTION(newstate); PARAM_STATE_ACTION(newstate);

View file

@ -1626,7 +1626,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_PlayerScream)
// //
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SkullPop) DEFINE_ACTION_FUNCTION(AActor, A_SkullPop)
{ {
PARAM_SELF_PROLOGUE(AActor); PARAM_SELF_PROLOGUE(AActor);
PARAM_CLASS_DEF(spawntype, APlayerChunk); PARAM_CLASS_DEF(spawntype, APlayerChunk);

View file

@ -7962,7 +7962,7 @@ FxExpression *FxReturnStatement::Resolve(FCompileContext &ctx)
else else
{ {
// If we already know the real return type we need at least try to cast the value to its proper type (unless in an anonymous function.) // If we already know the real return type we need at least try to cast the value to its proper type (unless in an anonymous function.)
if (ctx.ReturnProto != nullptr && ctx.Function->SymbolName != NAME_None) if (ctx.ReturnProto != nullptr && ctx.ReturnProto->ReturnTypes.Size() > 0 && ctx.Function->SymbolName != NAME_None)
{ {
Value = new FxTypeCast(Value, ctx.ReturnProto->ReturnTypes[0], false, false); Value = new FxTypeCast(Value, ctx.ReturnProto->ReturnTypes[0], false, false);
Value = Value->Resolve(ctx); Value = Value->Resolve(ctx);

View file

@ -147,7 +147,7 @@ inline void ResetBaggage (Baggage *bag, PClassActor *stateclass)
// //
//========================================================================== //==========================================================================
AFuncDesc *FindFunction(const char * string); AFuncDesc *FindFunction(PClass *cls, const char * string);
FxExpression *ParseExpression(FScanner &sc, PClassActor *cls, bool mustresolve = false); FxExpression *ParseExpression(FScanner &sc, PClassActor *cls, bool mustresolve = false);

View file

@ -571,28 +571,33 @@ FPropertyInfo *FindProperty(const char * string)
// //
//========================================================================== //==========================================================================
AFuncDesc *FindFunction(const char * string) AFuncDesc *FindFunction(PClass *cls, const char * string)
{ {
int min = 0, max = AFTable.Size()-1; for (int i = 0; i < 2; i++)
while (min <= max)
{ {
int mid = (min + max) / 2; if (i == 1 && !cls->IsDescendantOf(RUNTIME_CLASS(AActor))) break;
int lexval = stricmp (string, AFTable[mid].Name); FStringf fullname("%s_%s", i == 0 ? cls->TypeName.GetChars() : "Actor", string);
if (lexval == 0) int min = 0, max = AFTable.Size() - 1;
while (min <= max)
{ {
return &AFTable[mid]; int mid = (min + max) / 2;
} int lexval = stricmp(fullname, AFTable[mid].Name + 1);
else if (lexval > 0) if (lexval == 0)
{ {
min = mid + 1; return &AFTable[mid];
} }
else else if (lexval > 0)
{ {
max = mid - 1; min = mid + 1;
}
else
{
max = mid - 1;
}
} }
} }
return NULL; return nullptr;
} }
@ -627,7 +632,7 @@ static int propcmp(const void * a, const void * b)
static int funccmp(const void * a, const void * b) static int funccmp(const void * a, const void * b)
{ {
return stricmp( ((AFuncDesc*)a)->Name, ((AFuncDesc*)b)->Name); return stricmp(((AFuncDesc*)a)->Name + 1, ((AFuncDesc*)b)->Name + 1); // +1 to get past the prefix letter of the native class name, which gets omitted by the FName for the class.
} }
//========================================================================== //==========================================================================

View file

@ -1020,26 +1020,21 @@ struct AFuncDesc
// Macros to handle action functions. These are here so that I don't have to // Macros to handle action functions. These are here so that I don't have to
// change every single use in case the parameters change. // change every single use in case the parameters change.
#define DECLARE_ACTION(name) extern VMNativeFunction *name##_VMPtr; #define DECLARE_ACTION(name) extern VMNativeFunction *AActor_##name##_VMPtr;
// This distinction is here so that CALL_ACTION produces errors when trying to // This distinction is here so that CALL_ACTION produces errors when trying to
// access a function that requires parameters. // access a function that requires parameters.
#define DEFINE_ACTION_FUNCTION(cls, name) \ #define DEFINE_ACTION_FUNCTION(cls, name) \
static int AF_##name(VM_ARGS); \ static int AF_##cls##_##name(VM_ARGS); \
VMNativeFunction *name##_VMPtr; \ VMNativeFunction *cls##_##name##_VMPtr; \
static const AFuncDesc cls##_##name##_Hook = { #name, AF_##name, &name##_VMPtr }; \ static const AFuncDesc cls##_##name##_Hook = { #cls "_" #name, AF_##cls##_##name, &cls##_##name##_VMPtr }; \
extern AFuncDesc const *const cls##_##name##_HookPtr; \ extern AFuncDesc const *const cls##_##name##_HookPtr; \
MSVC_ASEG AFuncDesc const *const cls##_##name##_HookPtr GCC_ASEG = &cls##_##name##_Hook; \ MSVC_ASEG AFuncDesc const *const cls##_##name##_HookPtr GCC_ASEG = &cls##_##name##_Hook; \
static int AF_##name(VM_ARGS) static int AF_##cls##_##name(VM_ARGS)
#define DEFINE_ACTION_FUNCTION_PARAMS(cls, name) DEFINE_ACTION_FUNCTION(cls, name)
//#define DECLARE_PARAMINFO AActor *self, AActor *stateowner, FState *CallingState, int ParameterIndex, StateCallData *statecall
//#define PUSH_PARAMINFO self, stateowner, CallingState, ParameterIndex, statecall
class AActor; class AActor;
void CallAction(VMFrameStack *stack, VMFunction *vmfunc, AActor *self); void CallAction(VMFrameStack *stack, VMFunction *vmfunc, AActor *self);
#define CALL_ACTION(name, self) CallAction(stack, name##_VMPtr, self); #define CALL_ACTION(name, self) CallAction(stack, AActor_##name##_VMPtr, self);
#define ACTION_RETURN_STATE(v) do { FState *state = v; if (numret > 0) { assert(ret != NULL); ret->SetPointer(state, ATAG_STATE); return 1; } return 0; } while(0) #define ACTION_RETURN_STATE(v) do { FState *state = v; if (numret > 0) { assert(ret != NULL); ret->SetPointer(state, ATAG_STATE); return 1; } return 0; } while(0)

View file

@ -2128,7 +2128,7 @@ void ZCCCompiler::InitFunctions()
if (f->Flags & ZCC_Native) if (f->Flags & ZCC_Native)
{ {
varflags |= VARF_Native; varflags |= VARF_Native;
afd = FindFunction(FName(f->Name).GetChars()); afd = FindFunction(c->Type(), FName(f->Name).GetChars());
if (afd == nullptr) if (afd == nullptr)
{ {
Error(f, "The function '%s' has not been exported from the executable.", FName(f->Name).GetChars()); Error(f, "The function '%s' has not been exported from the executable.", FName(f->Name).GetChars());

View file

@ -63,7 +63,9 @@ class Actor : Thinker native
native static readonly<Actor> GetDefaultByType(class<Actor> cls); native static readonly<Actor> GetDefaultByType(class<Actor> cls);
native static float deltaangle(float ang1, float ang2); native static float deltaangle(float ang1, float ang2);
native static float absangle(float ang1, float ang2);
native static float GetDefaultSpeed(class<Actor> type); native static float GetDefaultSpeed(class<Actor> type);
native void RemoveFromHash();
native float GetBobOffset(float frac = 0); native float GetBobOffset(float frac = 0);
native void SetDamage(int dmg); native void SetDamage(int dmg);
native static bool isDehState(state st); native static bool isDehState(state st);

View file

@ -20,6 +20,13 @@ class ThinkerIterator : Object native
native void Reinit(); native void Reinit();
} }
class ActorIterator : Object native
{
native static ActorIterator Create(int tid, class<Actor> type = "Actor");
native Actor Next();
native void Reinit();
}
class DropItem : Object native class DropItem : Object native
{ {
/* native fields listed for reference only for now /* native fields listed for reference only for now

View file

@ -898,3 +898,22 @@ const HR_SHADOW = (0x6800 / 65536.);
// Hexen's TINTTAB is the same as Heretic's, just reversed. // Hexen's TINTTAB is the same as Heretic's, just reversed.
const HX_SHADOW = (0x9800 / 65536.); const HX_SHADOW = (0x9800 / 65536.);
const HX_ALTSHADOW = (0x6800 / 65536.); const HX_ALTSHADOW = (0x6800 / 65536.);
enum EMapThingFlags
{
MTF_AMBUSH = 0x0008, // Thing is deaf
MTF_DORMANT = 0x0010, // Thing is dormant (use Thing_Activate)
MTF_SINGLE = 0x0100, // Thing appears in single-player games
MTF_COOPERATIVE = 0x0200, // Thing appears in cooperative games
MTF_DEATHMATCH = 0x0400, // Thing appears in deathmatch games
MTF_SHADOW = 0x0800,
MTF_ALTSHADOW = 0x1000,
MTF_FRIENDLY = 0x2000,
MTF_STANDSTILL = 0x4000,
MTF_STRIFESOMETHING = 0x8000,
MTF_SECRET = 0x080000, // Secret pickup
MTF_NOINFIGHTING = 0x100000,
};

View file

@ -26,8 +26,6 @@ class Acolyte : StrifeHumanoid
Obituary "$OB_ACOLYTE"; Obituary "$OB_ACOLYTE";
} }
native void A_BeShadowyFoe ();
native void A_AcolyteBits ();
native void A_AcolyteDie (); native void A_AcolyteDie ();
States States
@ -76,6 +74,44 @@ class Acolyte : StrifeHumanoid
GIBS L 1400; GIBS L 1400;
Stop; Stop;
} }
//============================================================================
//
// A_BeShadowyFoe
//
//============================================================================
void A_BeShadowyFoe()
{
A_SetRenderStyle(HR_SHADOW, STYLE_Translucent);
bFriendly = false;
}
//============================================================================
//
// A_AcolyteBits
//
//============================================================================
void A_AcolyteBits()
{
if (SpawnFlags & MTF_SHADOW)
{
A_BeShadowyFoe();
}
if (SpawnFlags & MTF_ALTSHADOW)
{
if (bShadow)
{
// I dunno.
}
else
{
A_SetRenderStyle(0, STYLE_None);
}
}
}
} }