- scriptified BecomeItem and BecomePickup

This commit is contained in:
Christoph Oelckers 2018-11-24 21:25:26 +01:00
parent 3d892d3970
commit 337750b874
3 changed files with 49 additions and 70 deletions

View File

@ -200,71 +200,6 @@ bool AInventory::Grind(bool items)
return Super::Grind(items);
}
//===========================================================================
//
// AInventory :: BecomeItem
//
// Lets this actor know that it's about to be placed in an inventory.
//
//===========================================================================
void AInventory::BecomeItem ()
{
if (!(flags & (MF_NOBLOCKMAP|MF_NOSECTOR)))
{
UnlinkFromWorld (nullptr);
flags |= MF_NOBLOCKMAP|MF_NOSECTOR;
LinkToWorld (nullptr);
}
RemoveFromHash ();
flags &= ~MF_SPECIAL;
ChangeStatNum(STAT_INVENTORY);
// stop all sounds this item is playing.
for(int i = 1;i<=7;i++) S_StopSound(this, i);
SetState (FindState("Held"));
}
DEFINE_ACTION_FUNCTION(AInventory, BecomeItem)
{
PARAM_SELF_PROLOGUE(AInventory);
self->BecomeItem();
return 0;
}
//===========================================================================
//
// AInventory :: BecomePickup
//
// Lets this actor know it should wait to be picked up.
//
//===========================================================================
void AInventory::BecomePickup ()
{
if (Owner != NULL)
{
Owner->RemoveInventory (this);
}
if (flags & (MF_NOBLOCKMAP|MF_NOSECTOR))
{
UnlinkFromWorld (nullptr);
flags &= ~(MF_NOBLOCKMAP|MF_NOSECTOR);
LinkToWorld (nullptr);
P_FindFloorCeiling (this);
}
flags = (GetDefault()->flags | MF_DROPPED) & ~MF_COUNTITEM;
renderflags &= ~RF_INVISIBLE;
ChangeStatNum(STAT_DEFAULT);
SetState (SpawnState);
}
DEFINE_ACTION_FUNCTION(AInventory, BecomePickup)
{
PARAM_SELF_PROLOGUE(AInventory);
self->BecomePickup();
return 0;
}
//===========================================================================
//
// AInventory :: GetSpeedFactor

View File

@ -86,9 +86,6 @@ public:
double GetSpeedFactor(); // virtual on the script side.
bool GetNoTeleportFreeze(); // virtual on the script side.
void BecomeItem ();
void BecomePickup ();
bool DoRespawn();
AInventory *PrevItem(); // Returns the item preceding this one in the list.

View File

@ -50,8 +50,6 @@ class Inventory : Actor native
}
native bool DoRespawn();
native void BecomeItem();
native void BecomePickup();
native static void PrintPickupMessage (bool localview, String str);
States(Actor)
@ -145,6 +143,55 @@ class Inventory : Actor native
}
//===========================================================================
//
// AInventory :: BecomeItem
//
// Lets this actor know that it's about to be placed in an inventory.
//
//===========================================================================
void BecomeItem ()
{
if (!bNoBlockmap || !bNoSector)
{
A_ChangeLinkFlags(1, 1);
}
ChangeTid(0);
bSpecial = false;
ChangeStatNum(STAT_INVENTORY);
// stop all sounds this item is playing.
for(int i = 1;i<=7;i++) A_StopSound(i);
SetState (FindState("Held"));
}
//===========================================================================
//
// AInventory :: BecomePickup
//
// Lets this actor know it should wait to be picked up.
//
//===========================================================================
void BecomePickup ()
{
if (Owner != NULL)
{
Owner.RemoveInventory (self);
}
if (bNoBlockmap || bNoSector)
{
A_ChangeLinkFlags(0, 0);
FindFloorCeiling();
}
bSpecial = true;
bDropped = true;
bCountItem = false;
bInvisible = false;
ChangeStatNum(STAT_DEFAULT);
SetState (SpawnState);
}
//===========================================================================
//
// AInventory :: CreateCopy