Added A_OverlayOffset

Like A_WeaponOffset except it can access any psprites
This commit is contained in:
Leonard2 2016-05-18 14:20:36 +02:00
parent 1ecfb5897b
commit 8c205ebac3
3 changed files with 53 additions and 10 deletions

View file

@ -532,6 +532,7 @@ public:
void TickPSprites();
void DestroyPSprites();
DPSprite *GetPSprite(psprnum_t layer); // Used ONLY for compatibility with the old hardcoded layers.
DPSprite *FindPSprite(int layer);
};
// Bookkeeping on players - state.

View file

@ -158,6 +158,29 @@ DPSprite *player_t::GetPSprite(psprnum_t layer)
return pspr;
}
//------------------------------------------------------------------------
//
//
//
//------------------------------------------------------------------------
DPSprite *player_t::FindPSprite(int layer)
{
if (layer == 0)
return nullptr;
DPSprite *pspr = psprites;
while (pspr)
{
if (pspr->ID == layer)
break;
pspr = pspr->Next;
}
return pspr;
}
//---------------------------------------------------------------------------
//
// PROC P_NewPspriteTick
@ -863,7 +886,7 @@ DEFINE_ACTION_FUNCTION(AInventory, A_CheckReload)
//---------------------------------------------------------------------------
//
// PROC A_WeaponOffset
// PROC A_OverlayOffset
//
//---------------------------------------------------------------------------
enum WOFFlags
@ -873,16 +896,11 @@ enum WOFFlags
WOF_ADD = 1 << 2,
};
DEFINE_ACTION_FUNCTION(AInventory, A_WeaponOffset)
void A_OverlayOffset(AActor *self, int layer, double wx, double wy, int flags)
{
PARAM_ACTION_PROLOGUE;
PARAM_FLOAT_OPT(wx) { wx = 0.; }
PARAM_FLOAT_OPT(wy) { wy = 32.; }
PARAM_INT_OPT(flags) { flags = 0; }
if ((flags & WOF_KEEPX) && (flags & WOF_KEEPY))
{
return 0;
return;
}
player_t *player = self->player;
@ -890,7 +908,11 @@ DEFINE_ACTION_FUNCTION(AInventory, A_WeaponOffset)
if (player && (player->playerstate != PST_DEAD))
{
psp = player->GetPSprite(ps_weapon);
psp = player->FindPSprite(layer);
if (psp == nullptr)
return;
if (!(flags & WOF_KEEPX))
{
if (flags & WOF_ADD)
@ -914,7 +936,26 @@ DEFINE_ACTION_FUNCTION(AInventory, A_WeaponOffset)
}
}
}
}
DEFINE_ACTION_FUNCTION(AInventory, A_OverlayOffset)
{
PARAM_ACTION_PROLOGUE;
PARAM_INT_OPT(layer) { layer = ps_weapon; }
PARAM_FLOAT_OPT(wx) { wx = 0.; }
PARAM_FLOAT_OPT(wy) { wy = 32.; }
PARAM_INT_OPT(flags) { flags = 0; }
A_OverlayOffset(self, layer, wx, wy, flags);
return 0;
}
DEFINE_ACTION_FUNCTION(AInventory, A_WeaponOffset)
{
PARAM_ACTION_PROLOGUE;
PARAM_FLOAT_OPT(wx) { wx = 0.; }
PARAM_FLOAT_OPT(wy) { wy = 32.; }
PARAM_INT_OPT(flags) { flags = 0; }
A_OverlayOffset(self, ps_weapon, wx, wy, flags);
return 0;
}

View file

@ -50,6 +50,7 @@ ACTOR Inventory native
action native A_RestoreSpecialThing1();
action native A_RestoreSpecialThing2();
action native A_WeaponOffset(float wx = 0, float wy = 32, int flags = 0);
action native A_OverlayOffset(int layer = 1, float wx = 0, float wy = 32, int flags = 0);
States
{