Creating a pickup: Difference between revisions

From Eternity Wiki
Jump to navigationJump to search
(Add health section.)
m (Add armor section. Improve health section.)
Line 44: Line 44:
                                                                           // has less then twice the health given.
                                                                           // has less then twice the health given.
  }
  }
Now either type "summon UglyKit" (not case-sensitive) in the console, or place a thing with doomednum 30001 in the map. When you pick it up, it should heal you up to 150 health, and if your health is less than 30 prior to pickup then it will display the lowmessage.


===Armor===
===Armor===
Create a new lump, called EARMOR. Add the following to EDFROOT, on a line after the stdinclude.
lumpinclude("EARMOR") // A new armor pickup
Now, start editting EARMOR.
thingtype RedArmor
{
  doomednum  30002  // This is the thing number used to place the object in a map.
  flags      SPECIAL // Sets flags for item, which in this case means it's a collectable item.
  pickupeffect        // This defines what happens when the item is picked up.
  {
    effects RedArmor  // The actual effects that happen when the item is picked up (can be a comma separated list).
    message "Picked up the HyperArmor!" // The message given when picked up.
    sound  itemup    // The sound made when the item is picked up.
  }
  states
  @"
  Spawn:
    RARM A 6
    RARM B 7 bright
    loop
  "@
}
armoreffect RedArmor
{
  saveamount  150 // The number the armor % is set to.
  savefactor  2  // The numerator for the damage absorption fraction (2/n).
  savedivisor 3  // The denominator for the damage absorption fraction (n/3).
                  // These two properties combine to the armor absorbing 2/3 the damage the player would usually would take (66%).
}
Now either type "summon RedArmor" (not case-sensitive) in the console, or place a thing with doomednum 30002 in the map. When you pick it up, it should set your armor to 150. In addition, 66% of damage dealt to you will be absorbed by the armor.


===Ammo===
===Ammo===

Revision as of 12:22, 25 January 2018

Creating a pickup is effectively creating a simple decoration, but with a few more steps. You should read that tutorial first before continuing on here. In this tutorial we will define several pickups, each with its own section. In addition, the multiple ways in which a pickup can be defined will also be explored.

Much like creating a simple decoration, we will start by creating a text lump named EDFROOT, but for this tutorial each section will have its own unique lump name. We will include these lumps in EDFROOT so that the relevant pickups defined in the files can be used. For this tutorial we will use DECORATE state syntax.

stdinclude("root.edf") // Includes the file base/root.edf, which in turns includes the other files
                       // that are required for definition of all sprites, sounds, things etc.

Thing-based pickup

Thing-based pickups offer a more streamlined end-user experience than sprite-based pickups, and so it is suggested that you use thing-based pickups. In addition, thing-based pickups take priority over sprite-based pickups, and if a pickup has both available, it will only use the one that is in its thingtype definition.

Health

Create a new lump, called EHEALTH. Add the following to EDFROOT, on a line after the stdinclude.

lumpinclude("EHEALTH") // A new health pickup

Now, start editting EHEALTH.

thingtype UglyKit
{
  doomednum   30001   // This is the thing number used to place the object in a map.
  flags       SPECIAL // Sets flags for item, which in this case means it's a collectable item.

  pickupeffect        // This defines what happens when the item is picked up.
  {
    effects UglyKit   // The actual effects that happen when the item is picked up (can be a comma separated list).
    message "You got health, but you didn't like it..." // The message given when picked up.
    sound   itemup    // The sound made when the item is picked up.
  } 

  states // This declares that the following block is the thingtype's states.
  @"
  Spawn:
    UMED A -1
    stop
  "@
}

healtheffect UglyKit
{
  amount    15  // The amount of health given per pickup.
  maxamount 150 // The maximum amount the pickup will heal up to.

  lowmessage "You got health, but you're not sure how to feel about it." // The message displayed if the player
                                                                         // has less then twice the health given.
}

Now either type "summon UglyKit" (not case-sensitive) in the console, or place a thing with doomednum 30001 in the map. When you pick it up, it should heal you up to 150 health, and if your health is less than 30 prior to pickup then it will display the lowmessage.

Armor

Create a new lump, called EARMOR. Add the following to EDFROOT, on a line after the stdinclude.

lumpinclude("EARMOR") // A new armor pickup

Now, start editting EARMOR.

thingtype RedArmor 
{
  doomednum   30002   // This is the thing number used to place the object in a map.
  flags       SPECIAL // Sets flags for item, which in this case means it's a collectable item.

  pickupeffect        // This defines what happens when the item is picked up.
  {
   effects RedArmor   // The actual effects that happen when the item is picked up (can be a comma separated list).
   message "Picked up the HyperArmor!" // The message given when picked up.
   sound   itemup    // The sound made when the item is picked up.
  }

  states
  @"
  Spawn:
    RARM A 6
    RARM B 7 bright
    loop
  "@
}

armoreffect RedArmor
{
  saveamount  150 // The number the armor % is set to.
  savefactor  2   // The numerator for the damage absorption fraction (2/n).
  savedivisor 3   // The denominator for the damage absorption fraction (n/3).
                  // These two properties combine to the armor absorbing 2/3 the damage the player would usually would take (66%).
}

Now either type "summon RedArmor" (not case-sensitive) in the console, or place a thing with doomednum 30002 in the map. When you pick it up, it should set your armor to 150. In addition, 66% of damage dealt to you will be absorbed by the armor.

Ammo

Power-up

Weapon

Artifact

Sprite-based pickup

Sprite-based pickups are what almost all IWAD pickups use, and are mostly there for backwards-compatibility.