Classes:WeaponPiece

From ZDoom Wiki
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:
  1. This actor is already defined in GZDoom, there's no reason to define it again.
  2. In fact, trying to define an actor with the same name will cause an error (because it already exists).
  3. If you want to make your own version of this actor, use inheritance.
  4. Definitions for existing actors are put on the wiki for reference purpose only.
Weapon piece
Actor type Internal Game MiniZDoomLogoIcon.png (ZDoom)
DoomEd Number None Class Name WeaponPiece


Classes: InventoryWeaponPiece

 →ClericWeaponPiece
 →FighterWeaponPiece
 →MageWeaponPiece


WeaponPieces are items that can be used to create weapons with multiple parts that have to be assembled, like the big weapons in Hexen. The base class WeaponPiece is never used directly. It is always the base class for items defined in DECORATE.


Using in DECORATE

There are a few points to observe when using weapon pieces:

  • The piece's pickup sound and message are only used when the weapon is still incomplete.
  • If picking up a piece that completes the weapon, the weapon's pickup sound and message are being used.
  • Picking up a piece the player already owns gives some ammo. The amount is taken from the respective fields in the weapon definition.
  • Any weapon used with weapon pieces must use the Health property to define the number of pieces the weapon has.
  • This class is designed with the assumption that the whole weapon does not exist as a complete pickup item. It wouldn't do any harm to do it anyway but some messages would be obviously wrong.


WeaponPiece uses some of the basic Inventory properties to define their behavior as inventory items. They also define a few new properties:

  • WeaponPiece.Number number
The piece number. This can be a value between 1 and 32. To complete a weapon all available pieces as specified in the weapon must be picked up.
  • WeaponPiece.Weapon weapontype
The weapon this item helps to assemble.

DECORATE definition

ACTOR WeaponPiece : Inventory native
{
  +WEAPONSPAWN
}

Examples

ACTOR Ferkulator : Weapon
{
  Health 3 
  ...
}

actor FerkWeaponPiece1 : WeaponPiece 10012
{
  Inventory.PickupSound "misc/w_pkup"
  Inventory.PickupMessage "A Piece of the Ferkulator"
  WeaponPiece.Weapon "Ferkulator"
  WeaponPiece.Number 1
  States
  {
  Spawn:
    FRK1 A -1
    Stop
  }
}

actor FerkWeaponPiece2 : FerkWeaponPiece1 10013
{
  Weaponpiece.Number 2
  States
  {
  Spawn:
    FRK2 A -1
    Stop
  }
}

actor FerkWeaponPiece3 : FerkWeaponPiece1 10016
{
  WeaponPiece.Number 3
  States
  {
  Spawn:
    FRK3 A -1
    Stop
  }
}

See also