Classes:HealthPickup
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:
|
Health pickup | |||
---|---|---|---|
Actor type | Internal | Game | (ZDoom) |
DoomEd Number | None | Class Name | HealthPickup |
Classes: Inventory→HealthPickup
→ArtiHealth
→ArtiSuperHealth
→MedicalKit
→MedPatch
→SurgeryKit
HealthPickups are items that are placed in the inventory and give some health when activated. The base class HealthPickup is never used directly. It is always the base class for predefined items (like Heretic's Quartz Flask or for items defined in DECORATE.
The maximum amount of health that can be given with a HealthPickup is the current default maximum health which normally is 100.
Using in ZScript and DECORATE
HealthPickups use the basic Inventory properties to define their behavior as inventory items. The only new information they require is the amount of health they give. For this they use the standard health actor property.
Additional properties
- HealthPickup.AutoUse value
- Determines whether (and how) the item is set to be automatically used when the player's health drops below a certain point.
- The following values are accepted:
- 0 - Item will never be auto-used.
- 1 - Item will be automatically used when the player would die from damage taken, but only if the currently-selected skill level has the "autousehealth" flag set. (Like the Quartz Flask from Heretic/Hexen)
- 2 - Item will be automatically used when the player would die from damage taken, but only if the currently-selected skill level has the "autousehealth" flag set or during a deathmatch game. (Like the Mystic Urn from Heretic/Hexen)
- 3 - Item is auto-used when the player drops below 50% health; if the player has more than 1 such item, they will continue to be consumed until the player is over 50% health. However, if damage takes the player below 0% health, this will not save them from death. (Like Strife's small health items).
Examples
class MedKit : HealthPickup { Default { Health 25; Inventory.MaxAmount 15; Inventory.Icon "I_MDKT"; Inventory.PickupMessage "You picked up the Medkit."; // This is an example. It's recommended to use LANGUAGE for player-facing strings. +COUNTITEM } States { Spawn: MEDK A -1; stop; } }
class MedPatch : HealthPickup { Default { Health 10; HealthPickup.Autouse 3; Inventory.MaxAmount 20; Inventory.Icon "I_STMP"; Inventory.PickupMessage "You picked up the Med patch."; // This is an example. It's recommended to use LANGUAGE for player-facing strings. } States { Spawn: STMP A -1; Stop; } }
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 HealthPickup : Inventory
{
int autousemode;
property AutoUse: autousemode;
Default
{
Inventory.DefMaxAmount;
+INVENTORY.INVBAR
+INVENTORY.ISHEALTH
}
//===========================================================================
//
// CreateCopy
//
//===========================================================================
override Inventory CreateCopy (Actor other)
{
Inventory copy = Super.CreateCopy (other);
copy.health = health;
return copy;
}
//===========================================================================
//
// CreateTossable
//
//===========================================================================
override Inventory CreateTossable (int amount)
{
Inventory copy = Super.CreateTossable (-1);
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);
}
}
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 HealthPickup : Inventory native { Inventory.DefMaxAmount +INVENTORY.INVBAR }
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