Chapter 8

                   Programming the .CON files


In this chapter I'll attempt to explain just what the .CON files
are about and how they work.
8.1  The language of the .CON files


Here's just some stuff I wrote up when I still only had the
shareware version - in the next version of this FAQ I'll expand
on this:

state    Defines a subroutine.

ends           Called via state .  See state rats for an
               example.

include 
               Includes  in the code.

/*  */   Comment block (can be several lines)

//       Comment to end of line

spawn  Creates  on nearest floor. See also
               ifspawnedby.

ifrnd  
               If x is smaller than Random(255) then .
               See state rats for an example.

debris   Creates an exploding debris shower.
                is the debris graphic:
               Normally SCRAPn:
               SCRAP1 : Metal barrel pieces
               SCRAP2 : Edged metal barrel pieces
               SCRAP3 : White fluff
               SCRAP4 : Gray/brown boxes
               SCRAP5 : Gray/brown squashed boxes
               SCRAP6 : Pottery shards
                is the amount*3 of debris to show.
               Typical values are 2,3,4,5 or 12.

guts     Similar to debris, but throws guts about, which
               cause a blood splat on the ground.
                is guts graphics: JIBS1..JIBS6

hitradius  <1 2 3 4>
               Causes damage in radius  (always 1024).
               Damage is normally WEAKEST WEAK MEDIUMSTRENGTH
               TOUGH (see USER.CON).

addweapon  
               Add weapon  with ammo  to players inventory.

addammo  
               Add  amount of ammo for weapon  in
               inventory.

killit         Remove current actor.

sizeto   Resizes an actor.

palfrom  
               Changes actor palette.

sound       Play sound  locally.

globalsound 
               Like sound, but heard in whole map.

ifhitweapon 
               Execute  if hit by weapon.

ifhitspace     TRUE if player is pressing the spacebar.

ifcansee       TRUE if player can see this object.

ifwasweapon  
               Checks to see what weapon hit the actor:
               THROWFLAME       Flamethrower
               RADIUSEXPLOSION  Exploding device
               RPG              Rocket launcher
               FIREEXT          Fire extinguisher
               SHRINKSPARK      Shrinker beam
               SHOTSPARK1       Bullet
               COOLEXPLOSION1   ?
               KNEE             The Mighty Foot
               FIRELASER        Laser

ifspawnedby 
               TRUE if actor was spawned by object .

ifsquished     TRUE if actor was squished.

ifpdistg    TRUE if distance to player > x.

ifpdistl    TRUE if distance to player < x.

addphealth  Add  to players health (can be < 0).

resetplayer    Player resets in DM mode.

Some fun objects to spawn:
(see DEFS.CON as well)

AMMO           Pistol ammo.

BURNING        Starts fire on nearest floor, burns out soon.
               Doesn't start if no player near.

COLA           Small first-aid box.

EXPLOSION2     Nuke explosion. Image only - no damage...

EXPLOSION2BOT  Top part of explosion. Image only

FIRE           Small flame, burns out soon.

FIRE2          Shorter fatter flame, permanent, can be stamped
               out.

OOZ            Slime stretching to the ceiling.

PIGCOP         Pig Cop (can be spawned!).

RAT            Squeak!

SHIELD         Armor

SHRINKEREXPLOSION
               Green oval shrinker impact - image only.
STEAM          Hissing steam, causes damage, horizontal.


8.2  Notes


Just some random notes - I'll rewrite the whole of this chapter
anyway in the next FAQ.

    *  The language is C - so if you can program in C, you won't
       need this chapter at all as you can work nearly everything
       out yourself.

    *  The commands are case-sensitive.


8.3  Cute tricks


Here are some nice tricks to do with your .CON files - if you
know of any other, let me know! ##

8.3.1  Picking up weapons

Don't you hate it when you have the RPG selected, are running
towards somebody, run over the shotgun and automatically pick it
up, selecting it as your current weapon?

With this patch you'll have to press [SpaceBar] to pick up any
weapon.

It's easy, too: look in GAME.CON at line 874. See all the
requirements that have to be true before Duke will pick up the
shotgun? Well, just add the work 'ifhitspace' (must be in
lowercase) to the end of that line and you're done!

Of course, you'll have to do this with all other weapons as well,
but I'm sure you're able to handle that.

The disadvantage? Unless you hack around a bit yourself, you'll
have to press spacebar to pick up an existing weapon as ammo as
well.

8.3.2  Explosive ammunition

Lots of fun can be had with the SHOTSPARK1 actor (the spark
created by a bullet striking anything).

After line 1404 in GAME.CON, add the following lines:

ifactioncount 3
{
 hitradius 1024 WEAKEST WEAK MEDIUMSTRENGTH TOUGH
 spawn EXPLOSION2
 debris SCRAP2 2
 sound PIPEBOMB_EXPLODE
}

What does this do?

ifactioncount  is probably the animation frame number; we use it
               to make sure the code is only executed once per
               shotspark.

hitradius      causes damage in a 1024 unit radius, with the most
               damage in the middle of the circle.

spawn          spawns an object named EXPLOSION2 at the actors
               spot. In this case, the actor is SHOTSPARK1. This
               line makes sure the explosion animation is shown.

debris         throws some debris around, but not much (try
               "SCRAP1 10").

sound          plays the proper sound for the explosion.

{ }            are the begin/end delimiters of the "if" command.

So your bullets now cause more pain and suffering and more fun
for you. However, even the lowly pigcops are suddenly really
dangerous.
Because, you see, the monster bullets generate SHOTSPARK1's as
well...

8.3.3  Splat!

Lots more fun can be had with SHOTSPARK1.

Try adding this line just after line number 1404 in GAME.CON:

if actioncount 3 { spawn PIGCOP }

This will cause a pigcop to appear every time you fire a shot. As
soon as he shoots at you, eight more pigcops warp in. And then 72
more. And then...
Soon your system will hang itself...

Thus rather don't shoot. Take the jetpack, fly high up the street
in E1M1 and shoot and the wall. The pigcops appear and
immediately fall to a messy death many stories below >:)