CON Script Examples  v7-27-2004  Release 3 © RTCM Usurper

Introduction | Contents

Introduction

The examples on this page are intended primarily for newbie consumption. They are written with the assumption that you have read at least one con editing guide. See: RTCM's other Online Con Related Documents

Downloads for this Document: spikeart.zip and newrockt.zip

 

Contents

Contents (Some examples are designed for ver. 1.4/1.5 only.)

 

FUN WITH ACTIONS: Multiple Types of Explosions
  • About the explosion actor:
  • The explosion actor is one of the few actors in the game that stays at the same brightness no matter how dark a sector it is in. Sprites generally conform to the shade of the floor or (parallaxed) ceiling. The explosion actor (EXPLOSION2), it's ground flame (EXPLOSION2BOT) and the shrinker's blast (SHRINKEREXPLOSION) share this property.
    br> The RPG, Pipebomb, and Tripbomb all use the explosion actor.

    The explosion is light generating. It will, for a moment, increase the brightness of visible sectors.

  • Plain English explanation of how to achieve explosion variants:
  • The explosion uses the same action, EXPLOSION_FRAMES, every time it is spawned. You can code the explosion to behave differently depending upon what spawned it. We can give the explosion actor different actions, each using a different set of art tiles. The actor remains the same, but the appearance would be different.

  • Some reasons to have multiple explosion types:
    • You want the explosions to be different for the Pipebomb, RPG, and Tripbomb
    • You want random types of explosions to break up the monotony
    • You want another actor to spawn an explosion to generate light without visible explosion graphics, or with different graphics than the usual explosion
    • You want to spawn an actor that remains at full brightness
  • The acutal work involved:
    The code associated with the explosion actor reads:

    action EXPLOSION_FRAMES 0 20 1 1 4
    actor EXPLOSION2 1 EXPLOSION_FRAMES
    ifactioncount 20
    killit
    enda

    The first line is merely defines the action.
    Leave this line alone. On the first actual line of the actor, which starts with "actor", delete "EXPLOSION_FRAMES" from the line. There is really no action now when it is spawned, so the current action becomes "0".

    You should add in the new action(s) above the line that begins with actor. Give the action a name. If your new art has 15 frames and begins on tile number 4000 in editart, your action would read:

    action NEWEXPLOSION 2110 15 1 1 4

    NEWEXPLOSION is simply the action name; any word will work as long as it isn't already used. I believe actions are case-sensitive as well. Using caps for all actions, actors, and AI routines helps avoid confusion.

    2110 is the starting frame in relation to the actor. Since the explosion is defined in the defs.con file at tile 1890, we can determine that our action, which starts at tile 4000, is 2110 tiles ahead of the starting tile for the explosion.

    15 is the number of frames in the animation.

    The next number, 1, is the number of viewable angles the action has. Since this action will look the same from all sides, it's value is 1.

    After that is the number of tiles to increment the animation. Since it will go forward one frame at a time, this number is 1.

    The last number is the speed at which the animation moves. The higher the number, the slower the animation. I've chosen 4 for this explosion variant.

    Your code should now read:

    action NEWEXPLOSION 2110 15 1 1 4
    action EXPLOSION_FRAMES 0 20 1 1 4
    actor EXPLOSION2 1
    ifactioncount 20
    killit
    enda

    Let's say that we want the Pipebomb to use the new explosion frames and leave the other explosions the same as usual. We need to tell the actor when to use each action. Then we need to tell it what to do when it is using each action. We would write our code like this:

    action NEWEXPLOSION 2110 15 1 1 4
    action EXPLOSION_FRAMES 0 20 1 1 4
    actor EXPLOSION2 1
    ifaction 0
    {
    ifspawnedby HEAVYHBOMB
    {
    action NEWEXPLOSION
    }
    else
    {
    action EXPLOSION_FRAMES
    }
    }
    ifaction NEWEXPLOSION
    {
    ifactioncount 15
    killit
    }
    ifaction EXPLOSION_FRAMES
    {
    ifactioncount 20
    killit
    }
    enda

    "HEAVYHBOMB" is the name used for the pipebomb thrown by the player. We've simply associated the NEWEXPLOSION action with the explosion when it is spawned by the pipebomb. You must add in the "else" statement in order for the EXPLOSION_FRAMES action to be used for other explosions.

    Additional adjustments can be made as well. We can make one of the explosion types partially transparent by giving the actor a certain cstat value when it uses a particular action. For example:

    ifaction NEWEXPLOSION
    {
    cstat 2
    ifactioncount 15
    killit
    }

     

FUN WITH SPAWNING: Exploding Recon Cars spawn other actors

Because the Recon cars are hard-coded, and therefore cannot be modified directly in the cons, there is little that can be modified.  However, it is easy to change the enemy that is spawned by them.  If we want it to spawn Lizmen instead, we would add the following lines to the pigcop code right under the line that begins "actor PIGCOP."

ifspawnedby RECON { cstat 32768 spawn LIZMAN killit }

The cstat value immediately makes the pigcop invisible on the off chance that we are able to catch a glimpse of him before he spawns the Lizman and dies.  If Lizmen aren't your cup of tea, simply substitute the appropriate actor's name.

 

FUN WITH SPAWNING: Exploding Bullets

This line of code affects the pistol, shotgun, and chaingun. If there is a way to affect only one of them, I do not know what it is. Each of these weapons fires a variation of the shotspark actor. The pistol fires it in its purest form, SHOTSPARK1. The shotgun fires a burst of 7 shotsparks, and the chaingun fires rapid fire shotsparks. While enemies may fire the pistol, shotgun, or chaingun weapons, they produce only the impact spark, called WEAP2FRAMES, when their shots hit a wall. The actual bullet hole is probably deleted immediately by the game, the same way the game deletes the bullet hole when you shoot a door or elevator or any sector that moves.  The shotspark is actually the "bullet hole" that appears when you shoot a wall, and it spawns a puff of SMALLSMOKE when shot by the player.

Method 1:  To make the player's bullets explode, add the following lines of code directly under the line that reads "actor SMALLSMOKE 0 SMOKEFRAMES":
  {
   ifspawnedby SHOTSPARK1
    {
     ifactioncount 0
     {
      spawn EXPLOSION2
      hitradius **** a b c d
     }
     ifactioncount 1
     {
      killit
     }
    }
  }

The line under your last bracket should read "ifmove 0".
After "hitradius", **** is the size of the blast area from the point of impact. 1024 is the largest grid size, I believe. The letters a, b, c, and d represent the strength of the explosion in each of its four blast regions. "A" is the blast region farthest from the center of the blast, and "d" is the blast region at the center of the blast. Logically, the explosion will do more damage to something at the center of the blast than something on the edge of the blast. Customize this to your liking. I should note that these exploding bullets will blow up cracked walls the same way the RPG, Devastator, and Pipebomb will.

Method 2:  This method isn't as good as the previous one, but it does allow the enemies' bullets to explode as well. It makes the shotspark's impact animation, WEAP2FRAMES, show the same frames as the explosion.  Find the line that starts "action WEAP2FRAMES" and change that line and the rest of the shotspark code to look like this:

action WEAP2FRAMES -705 20  1  1  4        // 0 4 1 1 6
actor SHOTSPARK1 PISTOL_WEAPON_STRENGTH WEAP2FRAMES
  sizeto 64 64
  ifdead
    killit
  ifactioncount 20  // 4
    killit
  else
  {
    ifactioncount 3
    {
      ifinwater
      spawn WATERBUBBLE
    }
    else
      ifcount 2 nullop
      else
        ifonwater
          spawn WATERSPLASH2
  }
enda

I put the original values after a double slash and space ("// ") in case I wanted to change them back later. I recommend you do the same whenever you edit lines of code, as it could save you time later.  The drawbacks to this method are:

  • The explosion is partially transparent (hard-coded into the game)
  • The explosion is affected by the shade and palette of the floor, unlike the explosion actor that is spawned in method 1.  So you could have a dark explosion, when the explosion should be generating its own light and thus remain at a constant shade (I assume this is built into the game's exe file).
  • You can insert the line "hitradius **** a b c d" into the code, but the hitradius doesn't die a split second after impact.  While the explosion is on its 20th frame, barely visible any longer, you can still stumble into the hitradius area and get hurt. If the animation for the explosion were only 3 or 4 frames, this might not be noticeable, but 20 frames go a long way.

 

FUN WITH ACTORS: Proximity Mines

Exploding Recon Cars spawn other actors. Because the Recon cars are hard-coded, and therefore cannot be modified directly in the cons, there is little that can be modified. However, it is easy to change the enemy that is spawned by them. If we want it to spawn Lizmen instead, we would add the following lines to the pigcop code right under the line that begins "actor PIGCOP.":

ifspawnedby RECON { cstat 32768 spawn LIZMAN killit }

The cstat value immediately makes the pigcop invisible on the off chance that we are able to catch a glimpse of him before he spawns the Lizman and dies. If Lizmen aren't your cup of tea, simply substitute the appropriat actor's name.

 

SPIKE SHOOTERS

These are based on the code from the cannon (v1.4/1.5).  Theoretically you could probably adapt these to v1.3d by replacing a minor actor, but I don't have the time or means to cater to the inferior version of Duke Nukem.  The spike shooter should be put in a hole in the wall because the spike itself hovers when it is spawned instead of moving immediately.

Here's the art I've used for the spike shooter.  If you don't like it, feel free to make your own.  The spawner, since it can't be seen behind a maskwall, is just a simple icon so you can identify it.
ART-.pcx { spikeart.zip }

Here's the code used for the spikes and spikeshooters (defines are shown as xxxx so you can put the appropriate art numbers in when you've imported the art, and you'll have to find your own sound effects):
 
 

// HAPPYSPIKE is shot by a Spiker.  It is a trap, (similar to the one in Quake)
// and is based on the
// CANNONBALL code.  It's best to put the Spiker in a deep hole in the
// wall and put a 1-way mask wall in front of it
// because the spike hovers a moment before moving forward, which looks
// stupid.

define HAPPYSPIKE xxxx
define HAPPYSPIKESTRENGTH 400
move HAPPYSPIKE1 512 0
move HAPPYSPIKE2 512 10
move HAPPYSPIKE3 512 20
move HAPPYSPIKE4 512 40
move HAPPYSPIKE5 512 80

action SPIKEACTION  0  1  7

useractor notenemy HAPPYSPIKE HAPPYSPIKESTRENGTH

  ifaction 0
  {
    sizeat 32 32
    cstat 257         // Force actor to block
    action SPIKEACTION
  }

    ifactioncount 46
    {
      ifactioncount 47 nullop
      else
        move HAPPYSPIKE5 geth getv
    }
    else
      ifactioncount 44
    {
      ifactioncount 45 nullop
      else
        move HAPPYSPIKE4 geth getv
    }
    else
      ifactioncount 40
    {
      ifactioncount 41 nullop
      else
        move HAPPYSPIKE3 geth getv
    }
    else
      ifactioncount 32
    {
      ifactioncount 33 nullop
      else
        move HAPPYSPIKE2 geth getv
    }
    else
      ifactioncount 16
    {
      ifactioncount 17 nullop
      else move HAPPYSPIKE1 geth getv
    }

  ifnotmoving
  {
    debris SCRAP1 2
    debris SCRAP2 2
    hitradius 650 20 30 40 50
    killit
  }

  ifhitweapon
  {
    ifdead
    {
      spawn HEXPLODE
      hitradius 4096 WEAKEST WEAK MEDIUMSTRENGTH TOUGH
      killit
    }
    else
      debris SCRAP1 3
  }

enda
 

define SPIKERSTRENGTH 100000
define SPIKER xxxx
action ASPIKERWAIT 0 1 1 1 1
action ASPIKERSHOOTING 0 1 1 1 1
move SPIKERSTOP

useractor enemy SPIKER SPIKERSTRENGTH // fall
  cstat 0
  ifaction 0
  {
//    sizeat 64 64
    action ASPIKERWAIT
  }
  else
    ifaction ASPIKERSHOOTING
  {
    spawn HAPPYSPIKE
    action ASPIKERWAIT
  }
  else
    ifaction ASPIKERWAIT
  {
    ifactioncount 64
    {
      ifrnd 128
        action ASPIKERSHOOTING
      else
        resetactioncount
    }
  }

  ifhitweapon
  {
    ifdead
    {
      hitradius 4096 WEAKEST WEAK MEDIUMSTRENGTH TOUGH
      spawn EXPLOSION2
      killit
    }
    else debris SCRAP1 3
  }

  ifpdistl 1024
    ifhitspace
  {
    ifp pfacing
      ifcanshoottarget
        spawn HAPPYSPIKE
      else break
  }
enda

 

FUN WITH SPAWNING: Rocket Spawners

Here's the code and art for the rocket spawners.  They're placed the same as the spike shooters.  Again, since the rocket spawner is not visible if placed behind a maskwall, it is only a basic icon so you can identify it in build.

ART-.pcx { newrockt.zip }

action NEWROCKETEXISTING 0 1 7
define NEWROCKET xxxx
define NEWROCKETSTRENGTH 400
move NEWROCKET1 512 0
move NEWROCKET2 512 10
move NEWROCKET3 512 20
move NEWROCKET4 512 40
move NEWROCKET5 512 80

useractor notenemy NEWROCKET NEWROCKETSTRENGTH

  ifaction 0
  {
    sizeat 32 32
    cstat 257         // Force actor to block
    action NEWROCKETEXISTING
  }

    ifactioncount 46
    {
      ifactioncount 47 nullop
      else
        move NEWROCKET5 geth getv
    }
    else
      ifactioncount 44
    {
      ifactioncount 45 nullop
      else
        move NEWROCKET4 geth getv
    }
    else
      ifactioncount 40
    {
      ifactioncount 41 nullop
      else
        move NEWROCKET3 geth getv
    }
    else
      ifactioncount 32
    {
      ifactioncount 33 nullop
      else
        move NEWROCKET2 geth getv
    }
    else
      ifactioncount 16
    {
      ifactioncount 17 nullop
      else move NEWROCKET1 geth getv
    }

  ifnotmoving
  {
    spawn EXPLOSION2
    sound PIPEBOMB_EXPLODE
    hitradius 2500 30 85 100 200
    killit
  }

  ifhitweapon
  {
    ifdead
    {
      spawn EXPLOSION2
      hitradius 4096 WEAKEST WEAK MEDIUMSTRENGTH TOUGH
      killit
    }
    else
      debris SCRAP1 3
  }

  ifaction NEWROCKETEXISTING
     spawn SMALLSMOKE
 
 
 

enda
 

define NEWROCKETLAUNCHER xxxx
define NEWROCKETLAUNCHERSTRENGTH 15000
action ANEWROCKETLAUNCHERWAIT 0 1 1 1 1
action ANEWROCKETLAUNCHERSHOOTING 0 1 1 1 1
move NEWROCKETLAUNCHERSTOP

useractor enemy NEWROCKETLAUNCHER NEWROCKETLAUNCHERSTRENGTH // fall
  cstat 0
  ifaction 0
  {
//    sizeat 64 64
    action ANEWROCKETLAUNCHERWAIT
  }
  else
    ifaction ANEWROCKETLAUNCHERSHOOTING
  {
    spawn NEWROCKET
    action ANEWROCKETLAUNCHERWAIT
  }
  else
    ifaction ANEWROCKETLAUNCHERWAIT
  {
    ifactioncount 64
    {
      ifrnd 128
        action ANEWROCKETLAUNCHERSHOOTING
      else
        resetactioncount
    }
  }

  ifhitweapon
  {
    ifdead
    {
      addkills 1
      hitradius 4096 WEAKEST WEAK MEDIUMSTRENGTH TOUGH
      spawn EXPLOSION2
      killit
    }
    else debris SCRAP1 3
  }

  ifpdistl 1024
    ifhitspace
  {
    ifp pfacing
      ifcanshoottarget
        spawn NEWROCKET
      else break
  }
enda

 

FUN WITH THE USER.CON: Making cameras destructible

Lets address a few of the simple user.con game tweaks. Read On.

-Sample:  Making camers destructable via the USER.CON

  1. Open the USER.CON with Notepad or any other plain text editiors.
  2. Scroll down to MISC Game Settings and take a look at this line[L37]: define CAMERASDESTRUCTABLE NO // YES
  3. This line simply tells the game to either allow the cameras to be destroyed (YES) or not destructible (NO)
  4. The // portion of the line tells the game to ignore anything after it. Thus the YES is ignored and it is present just for a reminder.
  5. Change the NO to a YES and //YES to //YES or NO.
  6. Now save the con file and replace the one that is there.
  7. Load and Run the game normally and locate a security camera, sometimes they scan and rotate an area other times they are fixed in one direction.
  8. Now shoot the camera until its destroyed. Now the cameras in the game can be 'switched off' with a shotgun blast. This of course makes the view screen of this camera useless.

 

Easy... Lets do some more.

 

FUN WITH THE USER.CON: Making the Freeze 'ball' bounce more than three times

 

-Sample:  Making the Freeze 'ball' bounce more than three times via the USER.CON

  1. Open the USER.CON with Notepad or any other plain text editiors.
  2. Scroll down to MISC Game Settings and take a look at this line[L74]: define NUMFREEZEBOUNCES 3 // 0 - 255
  3. This line will indacte to the game how many times the freeze 'ball' should bounce. 3 times is the default.
  4. The values follow // indicate that the ball can be a single shot and hit, or bounce from 1 to 255 times max.
  5. Change the value to 8 for eight bounces including the first hit.
  6. Now save the con file and replace the one that is there.
  7. Load and Run the game normally and shoot the Freeze Gun and watch the ball bounce around.

-The ball bounces off a wall texture at ?45? degree angle.


If you want to try more samples try the following:

 

FUN WITH THE USER.CON: More Health for the player

 

-Sample: More Health for the player via the USER.CON

  1. Open the USER.CON with Notepad or any other plain text editiors.
  2. Scroll down to MISC Game Settings and take a look at this line[L40]: define MAXPLAYERHEALTH 100
  3. This line controls how much health the player will start at. It also indicates the maxium in game health level (using only first aids)
  4. Change the value to 400.
  5. Now save the con file and replace the one that is there.
  6. Load and Run the game normally and look at your health readout. It will indicate 400.

 

Zoom

Zoom is really easy and simple to do, but pulling off a really good effect is harder. Here is the cheesy, rough effect with a twist...

/*
Zoom CON
By James Hollidge (Cyborg) 2000 (c)
*/

state zoom
ifpinventory GET_HEATS 0 { } else { addinventory GET_HEATS 1200 }
ifpinventory GET_HEATS 1199 { } else { addinventory GET_HEATS 1200 addinventory GET_HOLODUKE 1 break } // if the Nightvision is used zoom
ifpinventory GET_HOLODUKE 1 { } else { sizeat 4095 4095 addinventory GET_HOLODUKE 0 break }
ifpinventory GET_HOLODUKE 0 { } else { sizeat 42 36 break } // If the nigtvision is not used stop zooming
ends

All you need do now is find the start of the player code (actor APLAYER) and insert a 'state zoom' after that line. You can see the zoom in effect just by using the nightgoggles. The player, you might notice, becomes huge when the zoom is used: this is how the effect is achieved. Fixing the graphics basically involves spawning a new actor to display the correct graphics for the player and making the player invisible.
Try it, love it: zoom is cool.

 

Freezer as a Melee weapon.  V1

Hello, Im BlitZ and Im explaining the way to make an extra melee weapon in 1.5 Duke. First off it replaces the freezer and goes a bit fast.

What it does is:

  1. Shoots a projectile (preferably the SHOTSPARK1 but can be anything) into the ground in front of Duke.
  2. If a wall or sprite is in front of Duke it will make the effect of something hitting it.
  3. If its not hitting it then you arent close enough.

Now for the code!

  • Go into your user.con find the line that says something like NUMFREEZEBOUNCES 3 \\0-255. Turn the 3 into a 0.
  • Next go into the game.con and find the transporterstar actor. under actor TRANSPORTERSTAR 0 TRANSFOWARD add this code:

            ifspawnedby FREEZEBLAST { shoot SHOTSPARK1 killit }

Now it should look like this:

action TRANSFOWARD 0 6 1 1 2
action TRANSBACK 5 6 1 -1 2
actor TRANSPORTERSTAR 0 TRANSFOWARD

ifspawnedby FREEZEBLAST { shoot SHOTSPARK1 killit }
ifaction TRANSFOWARD { ifactioncount 6 action TRANSBACK }
else ifactioncount 6 killit
enda

VIOLA!You did it, if you encountered a problem remove all of what you did previously and restart. If for any reason you really can't get it working email me : See my RTCM Contact page.