mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-14 08:30:49 +00:00
189 lines
3.8 KiB
Text
189 lines
3.8 KiB
Text
class ScoreItem : Inventory
|
|
{
|
|
Default
|
|
{
|
|
Height 10;
|
|
+COUNTITEM
|
|
Inventory.Amount 1;
|
|
+Inventory.ALWAYSPICKUP
|
|
}
|
|
|
|
override bool TryPickup (in out Actor toucher)
|
|
{
|
|
toucher.Score += Amount;
|
|
GoAwayAndDie();
|
|
return true;
|
|
}
|
|
}
|
|
|
|
class Health : Inventory native
|
|
{
|
|
native int PrevHealth;
|
|
native meta int LowHealth;
|
|
native meta String LowHealthMessage;
|
|
|
|
Default
|
|
{
|
|
Inventory.Amount 1;
|
|
Inventory.MaxAmount 0;
|
|
Inventory.PickupSound "misc/health_pkup";
|
|
}
|
|
|
|
//===========================================================================
|
|
//
|
|
// AHealth :: PickupMessage
|
|
//
|
|
//===========================================================================
|
|
override String PickupMessage ()
|
|
{
|
|
if (PrevHealth < LowHealth)
|
|
{
|
|
String message = LowHealthMessage;
|
|
|
|
if (message.Length() != 0)
|
|
{
|
|
return message;
|
|
}
|
|
}
|
|
return Super.PickupMessage();
|
|
}
|
|
|
|
//===========================================================================
|
|
//
|
|
// TryPickup
|
|
//
|
|
//===========================================================================
|
|
|
|
override bool TryPickup (in out Actor other)
|
|
{
|
|
PrevHealth = other.player != NULL ? other.player.health : other.health;
|
|
|
|
// P_GiveBody adds one new feature, applied only if it is possible to pick up negative health:
|
|
// Negative values are treated as positive percentages, ie Amount -100 means 100% health, ignoring max amount.
|
|
if (other.GiveBody(Amount, MaxAmount))
|
|
{
|
|
GoAwayAndDie();
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
|
|
}
|
|
|
|
class HealthPickup : Inventory native
|
|
{
|
|
native int autousemode;
|
|
|
|
Default
|
|
{
|
|
Inventory.DefMaxAmount;
|
|
+INVENTORY.INVBAR
|
|
}
|
|
|
|
//===========================================================================
|
|
//
|
|
// CreateCopy
|
|
//
|
|
//===========================================================================
|
|
|
|
override Inventory CreateCopy (Actor other)
|
|
{
|
|
Inventory copy = Super.CreateCopy (other);
|
|
copy.health = health;
|
|
return copy;
|
|
}
|
|
|
|
//===========================================================================
|
|
//
|
|
// CreateTossable
|
|
//
|
|
//===========================================================================
|
|
|
|
override Inventory CreateTossable ()
|
|
{
|
|
Inventory copy = Super.CreateTossable ();
|
|
if (copy != NULL)
|
|
{
|
|
copy.health = health;
|
|
}
|
|
return copy;
|
|
}
|
|
|
|
//===========================================================================
|
|
//
|
|
// HandlePickup
|
|
//
|
|
//===========================================================================
|
|
|
|
override bool HandlePickup (Inventory item)
|
|
{
|
|
// HealthPickups that are the same type but have different health amounts
|
|
// do not count as the same item.
|
|
if (item.health == health)
|
|
{
|
|
return Super.HandlePickup (item);
|
|
}
|
|
return false;
|
|
}
|
|
|
|
//===========================================================================
|
|
//
|
|
// Use
|
|
//
|
|
//===========================================================================
|
|
|
|
override bool Use (bool pickup)
|
|
{
|
|
return Owner.GiveBody (health, 0);
|
|
}
|
|
|
|
|
|
}
|
|
|
|
class Key : Inventory native
|
|
{
|
|
native uint8 KeyNumber;
|
|
|
|
Default
|
|
{
|
|
+DONTGIB; // Don't disappear due to a crusher
|
|
Inventory.InterHubAmount 0;
|
|
Inventory.PickupSound "misc/k_pkup";
|
|
}
|
|
}
|
|
|
|
class MapRevealer : Inventory
|
|
{
|
|
//===========================================================================
|
|
//
|
|
// AMapRevealer . TryPickup
|
|
//
|
|
// A MapRevealer reveals the whole map for the player who picks it up.
|
|
// The MapRevealer doesn't actually go in your inventory. Instead, it sets
|
|
// a flag on the level.
|
|
//
|
|
//===========================================================================
|
|
|
|
override bool TryPickup (in out Actor toucher)
|
|
{
|
|
level.allmap = true;
|
|
GoAwayAndDie ();
|
|
return true;
|
|
}
|
|
}
|
|
|
|
class PuzzleItem : Inventory native
|
|
{
|
|
native int PuzzleItemNumber;
|
|
|
|
Default
|
|
{
|
|
+NOGRAVITY
|
|
+INVENTORY.INVBAR
|
|
Inventory.DefMaxAmount;
|
|
Inventory.UseSound "PuzzleSuccess";
|
|
Inventory.PickupSound "misc/i_pkup";
|
|
}
|
|
}
|
|
|