How to create a Light Thing

From Doomsday Wiki
Jump to: navigation, search

Cleanup Note: This article should be cleaned up to be more readable and/or to more closely follow the Wiki article guidelines.

For this HOW TO, I'm going to guide you through the process of creating a new placeable Light Thing for use in your wads. Doomsday offers many ways to create lighting in your custom wads. Lights can be attached to surfaces using Decoration definitions, however this has a potential draw back in that every time you use a texture with a Decoration you'll get a light whether you wanted one or not.

Note: For this HOW TO I'm going to assume you are already familar with creating and using DED files and how to load them in Doomsday.

The technique I'm going to show you will enable you to place a light anywhere in your level. It will behave much like a light in more recent engines such as UnrealED due to the fact that it is a completely new entiy, because of this we also gain many potential possibilities like being able to freely spawn and destroy lights at will (I'm sure you can think of some interesting uses for that).

So what are the qualities of the light thing we are going to create?

  • It will be spawned at the ceiling and won't be effected by gravity
  • It's a red, flashing animated warning light
  • There will be no need for any sprite graphics.
  • It will live forever (once spawned) and can't be destroyed

Lets get started.

Possibilities

This method of dynamic lighting is almost endless in the number of possibilities it offers mod authors. Almost ANY kind of light can be created, pulsers, strobes, flickering etc, etc, etc...

Also because we have created a NEW Thing it becomes entirely possible to create interactive lights. For instance a lamp could be shot out or an invisible demonic force could act as a guide, following the player around, lighting the way in hellish red ambiance.

Also you will need to know how to create a WAD and add THINGS to it. You need to have a WAD editor capable of editing the ID number of a THING, I will be using [DoomBuilder] but there are many other editors that can do this.

STEP 1: Header and Thing definitions

First thing we need to do is create our new DED file.

  • Create a new DED file called LightThing.ded

Now open LightThing.ded in your favorite text editor (I will be using notepad). I always like to include the Header in my DED files and force of habit makes me put a nice big comment to make the content of the DED instantly obvious. So lets do that next.

  • Type the following:
	 Header { Version = 6 }

	 # -----------------------------------------------
	 # -				  Red Warning Light				  -
	 # -----------------------------------------------

The first step in defining our Red Warning Light is the Thing definition.

We will be creating new State definitions for the states we will need in order to animate the light.

Note the line that says DoomEd number = 8001, this is the ID of our Red Warning Light we'll use to place it in our level so remember it for latter.

  • Type the following starting on a new line:
	 #------------------------------------------------------------------
	 # THING DEFINITION

	 Thing {
		ID = "REDWARNLIGHT"
		Name = "RedWarnLight"
		DoomEd number = 8001;
		Spawn state = "REDWARNLIGHT"
		Spawn health = -1
		Radius = 10
		Height = 10
		Mass = 25
		Flags = spawnceiling | nogravity
	 }

As you can see, the Thing definition is pretty straight forward, so lets get on to the State definitons.

STEP 2: State definitions

The next stage in creating our Red Warning Light is creating the new State definitions. From the above Thing definition you'll see that in total we need at least one new State; REDWARNLIGHT

Now because we want an animated light we need two states (you could have as many states as you want to create fancier lights). In fact there are no differences between the two States, they are just there to allow us to animate our light.

  • Type the following starting on a new line:
	 #------------------------------------------------------------------
	 # STATE DEFINITIONS

	 State {
		ID = "REDWARNLIGHT"
		Sprite = "CAND"
		Frame = 32768
		Tics = 6
		Next state = "REDWARNLIGHT2"
	 }

	 State {
		ID = "REDWARNLIGHT2"
		Sprite = "CAND"
		Frame = 32768 
		Tics = 6
		Next state = "REDWARNLIGHT"
	 }

Thats it! Surprising really but the above is all we need to define the entity - Red Warning Light. However, we now need to setup the light. Atm Doomsday would create a light for us but there would be two problems, first of all it would be the wrong colour (this is because in our above state definitons we have used the candle sprite (CAND) as a place holder and Doomsday cleverly averages the colour of the sprite and automatically generates a Light based on these calculations), secondly our light wouldn't be animated and thirdly we'd get a floating candle sprite. Hmm, not really what we want is it. That means we need to do some extra work in finishing off our Red Warning Light.

STEP 3: Light definition and hiding the candle

Ok lets deal with the first two problems mentioned above. To do that we need some Light definitions. Notice below I'm using the * asterix character to save time by telling Doomsday to Copy the missing paramaters from the previous definition.

  • Type the following starting on a new line:
	 #------------------------------------------------------------------
	 # LIGHT DEFINITIONS

	 Light{
		State = "REDWARNLIGHT"
		Size = 3.5
		Color { .9 .1 .1}
	 }

	 * Light { State = "REDWARNLIGHT2" Size = 7 }

Now in order to hide the candle sprite we have two choices A) Create a new blank sprite and change our State definitons above or B) Use a trick to hide the sprite by using a null model definition. Now because it would be beyond the scope of this HOW TO I am going to go for option B.

  • Type the following starting on a new line:
	 #------------------------------------------------------------------
	 # MODEL DEFINITIONS

	 Model { State = "REDWARNLIGHT" Sub{}}
	 * Model { State = "REDWARNLIGHT2"}

Notice how we have a model definition for each of the States we created.

We now have everything we need for Doomsday to be able to create and understand our new Red Warning Light. However there is still one thing that we need to do, we need to place a few of them in our level.

  • *Save* your LightThing.ded
  • *Close* your text editor.

STEP 4: Placing the new Red Warning Light in our level

Now we need to place our new light in our level. The following details how to use [DoomBuilder] to accomplish this.

  • Launch DoomBuilder and *Open* the wad you want to edit (remembering to select jDoom from the *Game* selection box).

The problem we now have is that DoomBuilder doesn't know about our Red Warning Light, so we can't just select it from the Edit Thing dialog. What we need to do is to manually edit the Thing ID.

  • Switch to Thing mode by pressing *T* on your keyboard
  • *Right click* to place a new Thing where you want our Red Warning Light
  • Now *Right click* again on the new Thing to open the *Edit Thing* dialog

At the bottom of the *Edit Thing* dialog you'll see a box labeled *Thing Type*. Remember that the DoomEd number for the Red Warning Light is 8001.

  • Enter *8001* in the Thing Type entry box
  • Click *OK*

After that the Edit Thing dialog will disappear and you'll see that the Thing object has changed to the ? character. This is fine, it just means that DoomBuilder doesn't know what Thing 8000 is.

  • You can now Save your level
  • Close DoomBuilder

Finished!

All you need to do now is load Doomsday with our LightThing.wad and LightThing.ded.

As you'll be able to tell, this basic light can now be expanded upon to create some far more interesting lights. Have fun! DaniJ