Allow psprite layers to be manipulated directly from the player's own body

This commit is contained in:
Leonard2 2016-06-03 19:18:58 +02:00
parent eeff17c550
commit afa708c138
5 changed files with 20 additions and 19 deletions

View File

@ -110,7 +110,7 @@ END_POINTERS
//
//------------------------------------------------------------------------
DPSprite::DPSprite(player_t *owner, AInventory *caller, int id)
DPSprite::DPSprite(player_t *owner, AActor *caller, int id)
: processPending(true),
firstTic(true),
x(.0), y(.0),
@ -142,7 +142,7 @@ DPSprite::DPSprite(player_t *owner, AInventory *caller, int id)
if (Next && Next->ID == ID && ID != 0)
Next->Destroy(); // Replace it.
if (Caller->IsKindOf(RUNTIME_CLASS(AWeapon)))
if (Caller->IsKindOf(RUNTIME_CLASS(AWeapon)) || Caller->IsKindOf(RUNTIME_CLASS(APlayerPawn)))
Flags = (PSPF_ADDWEAPON|PSPF_ADDBOB|PSPF_POWDOUBLE|PSPF_CVARFAST);
}
@ -177,8 +177,8 @@ DPSprite *player_t::FindPSprite(int layer)
DPSprite *player_t::GetPSprite(PSPLayers layer)
{
AInventory *oldcaller = nullptr;
AInventory *newcaller = nullptr;
AActor *oldcaller = nullptr;
AActor *newcaller = nullptr;
if (layer >= PSP_TARGETCENTER)
{
@ -972,7 +972,7 @@ void A_OverlayOffset(AActor *self, int layer, double wx, double wy, int flags)
}
}
DEFINE_ACTION_FUNCTION(AInventory, A_OverlayOffset)
DEFINE_ACTION_FUNCTION(AActor, A_OverlayOffset)
{
PARAM_ACTION_PROLOGUE;
PARAM_INT_OPT(layer) { layer = PSP_WEAPON; }
@ -983,7 +983,7 @@ DEFINE_ACTION_FUNCTION(AInventory, A_OverlayOffset)
return 0;
}
DEFINE_ACTION_FUNCTION(AInventory, A_WeaponOffset)
DEFINE_ACTION_FUNCTION(AActor, A_WeaponOffset)
{
PARAM_ACTION_PROLOGUE;
PARAM_FLOAT_OPT(wx) { wx = 0.; }
@ -999,7 +999,7 @@ DEFINE_ACTION_FUNCTION(AInventory, A_WeaponOffset)
//
//---------------------------------------------------------------------------
DEFINE_ACTION_FUNCTION(AInventory, A_OverlayFlags)
DEFINE_ACTION_FUNCTION(AActor, A_OverlayFlags)
{
PARAM_ACTION_PROLOGUE;
PARAM_INT(layer);
@ -1118,7 +1118,7 @@ DEFINE_ACTION_FUNCTION(AInventory, A_Raise)
//
//---------------------------------------------------------------------------
DEFINE_ACTION_FUNCTION_PARAMS(AInventory, A_Overlay)
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Overlay)
{
PARAM_ACTION_PROLOGUE;
PARAM_INT (layer);
@ -1130,7 +1130,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AInventory, A_Overlay)
return 0;
DPSprite *pspr;
pspr = new DPSprite(player, reinterpret_cast<AInventory *>(stateowner), layer);
pspr = new DPSprite(player, stateowner, layer);
pspr->SetState(state);
return 0;
}
@ -1312,7 +1312,7 @@ void player_t::TickPSprites()
// Destroy the psprite if it's from a weapon that isn't currently selected by the player
// or if it's from an inventory item that the player no longer owns.
if ((pspr->Caller == nullptr ||
(pspr->Caller->Owner != pspr->Owner->mo) ||
(pspr->Caller->IsKindOf(RUNTIME_CLASS(AInventory)) && barrier_cast<AInventory *>(pspr->Caller)->Owner != pspr->Owner->mo) ||
(pspr->Caller->IsKindOf(RUNTIME_CLASS(AWeapon)) && pspr->Caller != pspr->Owner->ReadyWeapon)))
{
pspr->Destroy();

View File

@ -64,7 +64,7 @@ class DPSprite : public DObject
DECLARE_CLASS (DPSprite, DObject)
HAS_OBJECT_POINTERS
public:
DPSprite(player_t *owner, AInventory *caller, int id);
DPSprite(player_t *owner, AActor *caller, int id);
static void NewTick();
void SetState(FState *newstate, bool pending = false);
@ -74,7 +74,7 @@ public:
int GetFrame() const { return Frame; }
FState* GetState() const { return State; }
DPSprite* GetNext() { return Next; }
AInventory* GetCaller() { return Caller; }
AActor* GetCaller() { return Caller; }
double x, y;
double oldx, oldy;
@ -89,7 +89,7 @@ private:
void Tick();
void Destroy();
TObjPtr<AInventory> Caller;
TObjPtr<AActor> Caller;
TObjPtr<DPSprite> Next;
player_t *Owner;
FState *State;

View File

@ -5706,7 +5706,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SetTics)
PARAM_ACTION_PROLOGUE;
PARAM_INT(tics_to_set);
if (stateowner != self && self->player != nullptr && stateowner->IsKindOf(RUNTIME_CLASS(AInventory)))
if (self->player != nullptr)
{ // Need to check psp states for a match, then. Blah.
DPSprite *pspr = self->player->psprites;
while (pspr)

View File

@ -331,6 +331,11 @@ ACTOR Actor native //: Thinker
native void A_TransferPointer(int ptr_source, int ptr_recepient, int sourcefield, int recepientfield=AAPTR_DEFAULT, int flags=0);
action native A_CopyFriendliness(int ptr_source = AAPTR_MASTER);
action native A_Overlay(int layer, state start = "");
action native A_WeaponOffset(float wx = 0, float wy = 32, int flags = 0);
action native A_OverlayOffset(int layer = PSP_WEAPON, float wx = 0, float wy = 32, int flags = 0);
action native A_OverlayFlags(int layer, int flags, bool set);
native int ACS_NamedExecute(name script, int mapnum=0, int arg1=0, int arg2=0, int arg3=0);
native int ACS_NamedSuspend(name script, int mapnum=0);
native int ACS_NamedTerminate(name script, int mapnum=0);

View File

@ -40,7 +40,6 @@ ACTOR Inventory native
action native A_ReFire(state flash = "");
action native A_ClearReFire();
action native A_CheckReload();
action native A_Overlay(int layer, state start = "");
action native A_GunFlash(state flash = "", int flags = 0);
action native A_Saw(sound fullsound = "weapons/sawfull", sound hitsound = "weapons/sawhit", int damage = 2, class<Actor> pufftype = "BulletPuff", int flags = 0, float range = 0, float/*angle*/ spread_xy = 2.8125, float/*angle*/ spread_z = 0, float lifesteal = 0, int lifestealmax = 0, class<BasicArmorBonus> armorbonustype = "ArmorBonus");
action native state A_CheckForReload(int counter, state label, bool dontincrement = false);
@ -49,9 +48,6 @@ ACTOR Inventory native
action native A_RestoreSpecialDoomThing();
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 = PSP_WEAPON, float wx = 0, float wy = 32, int flags = 0);
action native A_OverlayFlags(int layer, int flags, bool set);
States
{