Creating a monster

From Eternity Wiki
Jump to: navigation, search

Though not quite as easy as creating a simple decoration, creating a monster is still a relatively basic task. In this tutorial we will define two monsters: one which only uses IWAD assets, and one that uses brand new sprites. We will also start using includes in order to keep both these monsters in separate EDF lumps.

Much like creating a simple decoration, we will start by creating a text lump named EDFROOT, but for this tutorial we will also make another two text lumps called EZOMBIE and EARACORB. We will include these lumps in EDFROOT so that the monsters defined in the files can be used.

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.

// New monsters:
lumpinclude("EZOMBIE")  // A new monster using already defined assets
lumpinclude("EARACORB") // A new monster using brand new sprites

Now we will start editing EZOMBIE to define on of our new monsters. For this tutorial we will start using DECORATE state syntax.

thingtype MutatedZombie
   doomednum   30001    // This is the thing number used to place the object in a map.

   basictype   Monster  // This uses a predefined set of flags for this object. basictype Monster is equivalent
                        // to setting cflags as SOLID | SHOOTABLE | COUNTKILL | FOOTCLIP | SPACMONSTER | PASSMOBJ.

   spawnhealth 30       // The amount of health the monster spawns with.
   painchance  128      // The likelihood that the monster goes to a pain state if it is hit.
                        // Percentage chance is (painchance/255)*100, so for this monster it would be roughly 50%.

   speed       8        // The monster moves an amount relative to this value each time it uses the Chase codepointer.

   radius      20.0     // The radius and height set the physical size
   height      56.0     // of the object, for collision detection.

   droptype    AmmoClip // The thingtype dropped by the monster when it dies.

   seesound    sawup    // The sounds made when the monster sees, attacks, is put in pain state, dies,
   attacksound sawhit   // and makes ambient noise respectively. These particular sounds are defined by sounds.edf
   painsound   sawful   // and are the DeHackEd names for the chainsaw noises.
   deathsound  sawidl
   activesound sawhit

   obituary_normal "was turned to goo by a mutated zombie" // The message displayed when the player is killed by this
                                                           // monster, using a projectile or other miscellaneous attack.

   acs_spawndata        // The identification number used by various parameterised specials, like Thing_Spawn.
   {                    // it also limits the number to a game namespace. Heretic objects use "modes heretic"
      num   255         // instead of "modes doom". Do note that the number must be <256.
      modes doom

   states                                       // This declares that the following block is the thingtype's states.
   @"                                           // The equivalent to an opening curly brace.
   Spawn:                                       // State the thing is spawned at.
      POSS AB 10 A_Look                         // Call the function A_Look, using sprites POSSA and POSSB, each for 10 frames.
      loop                                      // Loop back to the start of this label.
   See:                                         // State the monster goes into after seeing a target.
      POSS AABBCCDD 4 A_Chase                   // Call the function A_Chase, calling it twice for sprites POSSA-D, each time for 4 frames.
   Missile:                                     // State the monster goes into when deciding to shoot its target.
      POSS E 10 A_FaceTarget                    // Call the action function A_FaceTarget.
      POSS F  8 A_MissileAttack(MBFBetaPlasma1) // Call the action function A_MissileAttack with parameter MBFBetaPlasma1,
                                                // and leave the rest of the parameters as default (all 0 in this case).
      POSS E  8 
      goto See                                  // Jump to state See. Note that the next line after a goto MUST be labelled,
                                                // unlike ZDoom.
   Pain:                                        // State it goes into when hit by attack that successfully triggers this pain state.
      POSS G 3
      POSS G 3 A_Pain
      goto See
   Death:                                       // State it goes into when killed or otherwise destroyed.
      POSS H 5
      POSS I 5 A_Scream
      POSS J 5 A_Fall
      POSS K 5
      POSS L -1
   XDeath:                                      // Optional state it goes into when killed with very high damage.
      POSS M      5
      POSS N      5 A_XScream
      POSS O      5 A_Fall
      POSS PQRST  5
      POSS U     -1                             // This frame has infinite duration as it has been given a length of -1.
      stop                                      // This is the equivalent of setting the next frame to 0. If the last frame
                                                // has a finite duration (not -1), then it will disappear. otherwise it's often
                                                // used after -1 duration frames when nothing is expected to follow.
   Raise:                                       // Optional state that the corpse goes into when revived by an Arch-vile.
      POSS KJIH 5
      goto See
   "@                                           // The equivalent to a closing brace.

Now either type "summon MutatedZombie" (not case-sensitive) in the console, or place a thing with doomednum 30001 in the map, and we should have a Mutated Zombie walking around the map, making chainsaw noises and firing beta plasma balls at you. With this out of the way we can move on to defining a new monster that doesn't use IWAD assets. For the purposes of this tutorial we will be using the aracnorb from the Realm667 bestiary by James Paddock (Jimmy).

Start by copying over the contents of the wad from SS_START to SS_END inclusive into whatever wad you were previously working in. To follow this up you will need to convert the three sound files provided into Doom Sound Format, and place them in the wad. Now we will start by editing EARACORB. This example won't use comments in areas already covered by the previous one. The ACNFI states will need to be changed so that all I's are replaced with H's and ACNF is replaced with ACNB. Don't focus too much on the AracnorbBall thingtype, as we will look further into that in Creating a projectile.

thingtype Aracnorb
   doomednum   30002 
   basictype   FlyingMonster // This uses a predefined set of flags for this object. basictype FlyingMonster is equivalent
                             // to setting cflags as SOLID | SHOOTABLE | COUNTKILL | NOGRAVITY | FLOAT | SPACMONSTER | PASSMOBJ.
   addflags    FLOATBOB      // This makes it so that on top of the already defined flags, this thingtype also has the flag FLOATBOB.

   spawnhealth 170
   painchance  150

   speed       12
   radius      24.0
   height      56.0 
   mass        400      // Represents mass factor for the thingtype. This determines thrust when damaged, or how much an
                        // Arch-vile's attack will affect it.
   xscale      0.85     // How much the horizontal component of this sprite is to be scaled.
   yscale      0.85     // How much the vertical component of this sprite is to be scaled.

   // This thingtype drops nothing when it dies, so no droptype is defined and it uses the default value (nothing).

   seesound    "aracnorb/sight" // This uses sound mnemonics defined at the bottom of this EDF file, as well as pre-defined
   attacksound "aracnorb/melee" // Arachnotron sounds from the IWAD.
   painsound   dmpain
   deathsound  "aracnorb/death"
   activesound bspact

   obituary_normal "suffered psychic trauma from an aracnorb's brainwaves."
   obituary_melee "had their skull chewed by an aracnorb." // The message displayed when killed by the thingtype's melee attack.

      num   254
      modes doom

      ACNB A 1 A_Look
      Loop                                               // Note that you can capitalise keywords if you so wish.
      ACNB A 2 A_Chase
      ACNB AB 5
      ACNB C 6 A_Scratch(3, 6, "aracnorb/melee")         // This calls a generalised melee function. The parameters tell it to use the
                                                         // 2nd parameter as damage, do 6 damage, and call the sound "aracnorb/melee".
      Goto See
      ACNB B 12 Bright A_FaceTarget                      // The "Bright" keyword causes this thing to light up when performing this action.
      ACNB C 2 Bright A_MissileAttack("AracnorbBall", 1) // Attack spawning a projectile "AracnorbBall", and allow
                                                         // ball to trace (home in on) its target.
      ACNB B 2 Bright
      ACNB D 0 A_Jump(32,"See")                          // Have a 32/255 chance to jump to the state "See".
      ACNB D 0 A_SpidRefire
      Goto Missile+1                                     // This skips the first line of Missile, and goes straight to attacking.
      ACNB I 2
      ACNB I 2 A_Pain
      Goto See
      ACNB D 0 A_UnSetFlags(0, "FLOATBOB")               // Set the flag FLOATBOB to false, so that once it dies it stops bobbing.
      ACNB D 0 A_Scream
      ACNB D 6 A_Fall
      ACNB D 1
   Crash:                                                // Optional state that is called when the corpse falls and hits the floor.
      ACNB EFG 6
      ACNB H -1
      ACNB A 0 A_SetFlags(0, "FLOATBOB")                 // Set the flag FLOATBOB back to true, so that it bobs once resurrected.
      Goto See

thingtype AracnorbBall
   basictype Seeker // This uses a predefined set of flags for this object. basictype FlyingMonster is equivalent
                    // to setting cflags as NOBLOCKMAP | NOGRAVITY | DROPOFF | MISSILE | NOCROSS | SEEKERMISSILE.
   radius 13.0
   height 8.0
   speed 8.0
   damage 3
   seesound plasma
   deathsound firxpl
   addflags TRANSLUCENT|SPACMISSILE  // This adds the flags so that the projectile is translucent and can activate
                                     // generalised linedefs marked with the MISSILE special activation flag
      ACNF AABB 1 Bright A_GenTracer // This causes the projectile to trace its target.
      ACNF CDEFG 5 Bright

sound "aracnorb/sight"  { lump = "DSARACST"; } // Define the sound "aracnorb/sight" as the lump DSARACST. 
sound "aracnorb/death"  { lump = "DSARACDT"; }
sound "aracnorb/attack" { lump = "DSARACFR"; }
sound "aracnorb/melee"  { lump = "DSARACML"; }

Now just type "summon Aracnorb" into the console or place a thing with doomednum 30002 on the map and you should see your brand new monster that fires a custom homing projectile.