Classes:DehackedPickup
Jump to navigation
Jump to search
Note: Wait! Stop! You do not need to copy this actor's code into your project! Here's why:
|
DeHackEd pickup | |||
---|---|---|---|
Actor type | Internal | Game | (ZDoom) |
DoomEd Number | None | Class Name | DehackedPickup |
Classes: Inventory→DehackedPickup
DehackedPickup is a class used to emulate Doom's original behavior of determining a pickup's type by its sprite. This class is never used by mods directly; GZDoom makes use of it automatically when detecting an Inventory item modified by DEHACKED.
The real item that should be given is determined with a special private function, DetermineType(), which is invoked in DehackedPickup's TryPickup override.
ZScript definition
Note: The ZScript definition below is for reference and may be different in the current version of GZDoom.The most up-to-date version of this code can be found on GZDoom GitHub. |
class DehackedPickup : Inventory
{
Inventory RealPickup;
bool droppedbymonster;
private native class<Inventory> DetermineType();
override bool TryPickup (in out Actor toucher)
{
let type = DetermineType ();
if (type == NULL)
{
return false;
}
RealPickup = Inventory(Spawn (type, Pos, NO_REPLACE));
if (RealPickup != NULL)
{
// The internally spawned item should never count towards statistics.
RealPickup.ClearCounters();
if (!bDropped)
{
RealPickup.bDropped = false;
}
// If this item has been dropped by a monster the
// amount of ammo this gives must be adjusted.
if (droppedbymonster)
{
RealPickup.ModifyDropAmount(0);
}
if (!RealPickup.CallTryPickup (toucher))
{
RealPickup.Destroy ();
RealPickup = NULL;
return false;
}
GoAwayAndDie ();
return true;
}
return false;
}
override String PickupMessage ()
{
if (RealPickup != null)
return RealPickup.PickupMessage ();
else return "";
}
override bool ShouldStay ()
{
if (RealPickup != null)
return RealPickup.ShouldStay ();
else return true;
}
override bool ShouldRespawn ()
{
if (RealPickup != null)
return RealPickup.ShouldRespawn ();
else return false;
}
override void PlayPickupSound (Actor toucher)
{
if (RealPickup != null)
RealPickup.PlayPickupSound (toucher);
}
override void DoPickupSpecial (Actor toucher)
{
Super.DoPickupSpecial (toucher);
// If the real pickup hasn't joined the toucher's inventory, make sure it
// doesn't stick around.
if (RealPickup != null && RealPickup.Owner != toucher)
{
RealPickup.Destroy ();
}
RealPickup = null;
}
override void OnDestroy ()
{
if (RealPickup != null)
{
RealPickup.Destroy ();
RealPickup = null;
}
Super.OnDestroy();
}
override void ModifyDropAmount(int dropamount)
{
// Must forward the adjustment to the real item.
// dropamount is not relevant here because Dehacked cannot change it.
droppedbymonster = true;
}
}
DECORATE definition
Note: This is legacy code, kept for archival purposes only. DECORATE is deprecated in GZDoom and is completely superseded by ZScript. GZDoom internally uses the ZScript definition above. |
ACTOR DehackedPickup : Inventory native {}
Categories:
- Chex Quest actors
- Chex Quest internal actors
- Chex Quest 3 actors
- Chex Quest 3 internal actors
- Doom actors
- Doom internal actors
- Doom II actors
- Doom II internal actors
- Heretic actors
- Heretic internal actors
- Hexen actors
- Hexen internal actors
- Strife actors
- Strife internal actors
- ZDoom actors
- ZDoom internal actors
- Internal