Author Topic: 75's painless DECORATE for beginners  (Read 2790 times)

Offline 75

  • [IFOC] Server Admin
  • Multiplayer Team Leader
  • Chex Master
  • *****
  • Thank You
  • -Given: 32
  • -Receive: 30
  • Posts: 4251
75's painless DECORATE for beginners
« on: July 08, 2010, 10:00:09 PM »
This is not meant to be read in any particular order. Feel free to skip the terms section and get right to editing if you want.

First, some background. Don't worry if you don't get everything I'm talking about, I'm going to go into more detail later.

A state is a grouping of frames and actions that are associated with a certain monster's reactions.

The spawn state is the state the monster is created in. If you type in "summon <actorname>" in the console, the actor will be created then enter this state

The see state is called from the spawn state when the player enters the actor's field of view. In monsters, this state usually uses A_Chase or something similar to have the monster chase the player. If the monster is within range, A_Chase can cause the actor to attack, causing the actor to enter the Melee or Missile states.

The melee state is called from A_Chase when the actor is extremely close to its target.

The missile state is called randomly from A_Chase. Its likelihood of being called from A_Chase depends on difficulty, the monster's distance from the player, and a few other factors.This state is usually used to cause the monster to attack with a projectile, such as the imp's fireball.

The Pain state is the state the actor enters if it takes a certain amount of damage. The amount of damage to cause the actor to enter the pain state is defined in "Painchance"

The Death state is the state the actor enters if its last bit of health is depleted. In chex quest, this is the state where the actor is teleported.

It is not necessary to use all of these states. A potted plant, for example, has no use for a Missile state, unless you want it to shoot rockets, which is doable.

ok, now let's look at some actual DECORATE code. This is the code for the zombieman from doom, copied from

Code: [Select]
actor ZombieMan 3004
  spawnid 4
  obituary "%o was killed by a zombieman."
  health 20
  radius 20
  height 56
  mass 100
  speed 8
  painchance 200
  seesound "grunt/sight"
  attacksound "grunt/attack"
  painsound "grunt/pain"
  deathsound "grunt/death"
  activesound "grunt/active"
  dropitem "Clip" 256
    POSS AB 10 A_Look
    POSS E 10 A_FaceTarget
    POSS F 8 A_PosAttack
    POSS E 8
    goto See
    POSS G 3
    POSS G 3 A_Pain
    goto See
    POSS H 5
    POSS I 5 A_Scream
    POSS J 5 A_NoBlocking
    POSS K 5
    POSS L -1
    POSS M 5
    POSS N 5 A_XScream
    POSS O 5 A_NoBlocking
    POSS U -1
    goto See

too complicated, didn't read? That's ok, I'm going to explain each part separately.

right now, let's just look at the states.

Code: [Select]
    POSS AB 10 A_Look

right under Spawn:, you see POSS AB 10 A_Look

POSS AB refers to the sprite frames used in the state.

POSS A and POSS B are sprites, if you look in the wad, you will find something like this

You'll note that there are many sprites with the name POSSA#. Don't worry about that number, the number on the end of the sprite name designates rotation. The engine will decide which rotation to call for you, since it depends on the position of the player.

Remember, the number designating rotation has nothing to do with the time the frame is shown. The rotation number NEVER shows up in DECORATE, since the engine decides for itself which rotation to show, DECORATE only specifies the frame (given by A, B, C, D).

the 10 after POSS AB refers to the time, in tics, that the frame will be displayed. A time value of -1 tells zdoom to display that frame indefinitely.

A_Look is an action, and it is called on every frame. All actions in decorate begin with "A_".

A_Look is a very common action, this action looks for players to attack.

Basically, zdoom interprets your code like this

Code: [Select]
Show POSS A for 10 tics, look for players
Show POSS B for 10 tics, look for players
loop (repeat the state)

Another command commonly used in DECORATE is "stop". That tells zdoom to continue rendering the last frame associated with that actor indefinitely. It will not run any commands, so the actor will not move for the rest of the game, unless it is resurrected (i.e., ArchViles/Teleportus).

Basically, the zombieman will rock back and forth slightly until he sees the player. If you've never noticed that in doom, or chex quest, use a no clipping cheat and enter the room from a direction in which the monsters/flemoids can't see you. They move very slightly back and forth, and this is the part of DECORATE that tells them to do that.

For some reason ID liked to have their monsters twitch back and forth rather than stand still. Looks like they're doing some sort of weird marching routine.

Now... let's say you don't want that in your mod. In your mod, zombiemen stand still! It's easy to do.

You could achieve that with this code

Code: [Select]
actor DecafZombie : Zombieman replaces Zombieman

// this is a comment, DECORATE, along with most other text lumps in zdoom accepts C++ style comments
/* or
C style comments. MAKE SURE YOU END THESE THINGS, or half your DECORATE will be missing and you'll be at a loss as to why.  */

// You should probably use comments to inform people about what this monster/actor does

              POSS  A 10 A_Look

The first thing you will notice is the top line of my actor definition. You might also notice that our actor definition is very small compared to the definition on the zdoom wiki.

It's small because we are only defining the CHANGES we made to this actor. Since all we want to do is change the Spawn: state, we can just modify that and inherit the rest of the actor's properties.

Code: [Select]
actor DecafZombie : Zombieman replaces Zombieman
DecafZombie is the actor name of our new monster. The colon signifies  inheritance. DecafZombie inherits the properties of the Doom actor "Zombieman". That means that every facet of our new monster not defined in the code below will be identical to the Zombieman's. Our monster will have the same health, painchance, attacks, etc. All we are doing is changing the Spawn: state

After that, I put "replaces Zombieman". This tells zdoom to replace every zombieman it finds with our decafzombie.

now, for our changes to the spawn state

Code: [Select]
              POSS  A 10 A_Look

Now zdoom will read it as such

Code: [Select]
Display Frame POSS A for 10 tics, run A_Look


DO NOT use "stop" instead of "loop" or a time of -1 for this! Since A_Look is only called when the frame changes, if the frame never changes, the actor has no chance of seeing the player, so the actor will stay in the Spawn: state indefinitely, for all intensive purposes, becoming a statue.

The See state will loop until a player is found. If that happens, A_Look will cause the actor to enter the See: state.

COMING SOON - The See state explained!

NOTE : If you're confused by the Doom sprites, read this

Sorry but you are not allowed to view spoiler contents.

« Last Edit: July 08, 2010, 10:04:38 PM by 75 »
"Give us those nice bright colors, give us the greens of summer, makes you think all the world's a sunny day."

You can find me on the CQFF discord:


Web Hosting by InMotion Hosting