WEAPON CODING  v1-01-2003  Release 1  © RTCM Reaper_Man

/!\ Attention: These FAQ's where written before the development of EDuke, many limits do not apply anymore.

These CON FAQs was written because I believe that there is no one place where CON information can be found - from the simplest ideas to the most complex effects. After the fall of Dukeworld and 3D Portal, a web-edition of the CON FAQ seems to have been lost, and that leaves Duke RTCM as the only other source of CON information. Though they do have information on CONs and how to edit them, I don't believe that this information is easily understood by the newest of newbie's.

The information here is for those newbie's, moderate programmers', and the experts alike. Know one knows everything there is to know about CONs, or any computer programming language for that matter. Everyone has their own style and their own ideas, and that leads to the limitless possibilities.

These FAQs are not a solid piece of work - it is an ever changing, ever evolving compilation of the DukeC programming language - the unofficial name of the CON language.

Enjoy!

Introduction | Bullet Based | Pipebomb | Freezer | Least Editable

Introduction

Weapons seem to be the most wanted effect to be changed in a TC, and that is rightfully so. The weapons are things you constantly use, so it is understandable why they are one of the first things to be changed when a TC's code is written.

But no other part about the game seems to be unchangeable. There are several ways you can get around these weapon restrictions, but there is absolutely no possible way to directly change what a weapon fires.


Bullet Based


Until recently, I was convinced that bullet-based weapons were one of the weapons that are unchangeable. Thanks to the help and motivation of the Usurper, I did some experiments with bullet-based weapons and found out that they are editable, to an extent.

When you fire a bullet-based weapon close to a wall, you will notice a small, yellow-orange spark. This is an actor, called SHOTSPARK1. Depending on what weapon you fired, the SHOTSPARK1 will do a certain amount of damage to actors. This amount of damage is stored as the actor's strength.

If you set the strength of the weapon you want to change, the Pistol for example, to a number between (CHAINGUN_DAMAGE +7) and (SHOTGUN_DAMAGE + 7), then you are able to isolate the damage of the Pistol. You have to add 7 to compensate for the bullet's random strength additions.

Somewhere in the code of the SHOTSPARK1 actor, you can add in something similar to the following:

ifstrength (PISTOL_DAMAGE + 7)
{
  spawn EXPLOSION2
  hitradius 1024 20 25 30 40
  debris SCRAP1 5
  debris SCRAP3 5
  sound PIPEBOMB_EXPLODE
  killit
}

What this will do is make the Pistol's bullets seem as if they're exploding. They will create an explosion, a damage-area, some debris, and play the sound PIPEBOMB_EXPLODE. It will then delete itself from the game.

Problem - play the game with any enemies that shoot bullet weapons, excluding the Pigcop. You will notice that _their_ bullets are exploding, too! The reason for this is because they shoot the weapon SHOTSPARK1, which is the same thing the Pistol shoots. You can fix this by going through the code and replacing all instances of shoot SHOTSPARK1 with shoot CHAINGUN, but then anything you do to the Chaingun will be affected by the new code.


Pipebomb


The next weapon we have up is the Pipebomb. For years before eDuke came out, I was hearing about people wanting to turn the Pipebomb into a timer-delayed grenade. The pipe-bomb is one of the few weapons we have almost zero control over. We can, however, change the effects the Pipebomb has on the environment.

If you search through GAME.CON, you will come across the code for the standard explosion. The explosion actor, EXPLOSION2, is spawned by all explosive weapons in the game, and is the key to changing a few of them. If you wanted to change the pipebomb to do a new effect when it explodes, you would have to add code similar to this to the existing EXPLOSION2 code:

ifspawnedby HEAVYHBOMB
{
  spritepal 2
  spawn LIZTROOP
}

This would create a creative, albeit useless weapon - the Liz Trooper Grenade!


Freezer


In my opinion, the easiest weapon to modify is the Freezer. There is so much room for additions and changes, I believe that Todd Replogle intentionally made the Freezer this way.

When your fire the Freezer, it bounces around on walls and surfaces 3 times, and finally dissipates on the third surface it hits. When it does so, it creates a small bluish star that quickly flashes away. The actor creates is called TRANSPORTERSTAR.

In USER.CON, there is a variable called NUMFREEZEBOUNCES, which is set to 3 by default. You can change this to 0, which makes the Freezeblast be destroyed as soon as it is shot. We can add to the existing TRANSPORTERSTAR code, so that the Freezer sets an inventory item...:

ifspawnedby FREEZEBLAST
{
  addinventory (inventory item) (value)
  killit
}

Then in the Player code, actor APLAYER, we would add something like this directly beneath the actor primitive:

ifpinventory (inventory item) (value) { }
else
{
  shoot SHOTSPARK1
  addinventory (inventory item) (value)
}

This would force the player to shoot SHOTSPARK1 whenever the desired inventory item is set to the same value as the one in the TRANSPORTERSTAR code. It would then set the inventory item back to a desired value, usually 0. Since this all happens in a split second, it gives the illusion that the Freezer is shooting bullets.


Least Editable


The Devistator and the Tripmine are the two least-editable weapons. Like the pipebomb, the only thing that we can change about the Tripmine is it's explosion, so we could have it react differently when someone or something crosses it's beam.

The Devistator is the ultimate exception, it has the least editable projectile in the game. Since all the Devistator does is shoot 2 small RPG rockets in quick succession, any sort of modification we do to the RPG translates to the Devistator. This poses a lot of framerate issues, especially if you modify the RPG to spawn a lot of other actors.

Take for example the Starship Troopers TC. They change the RPG into the shoulder-mounted Nuke launcher. Whenever the Nuke hits something, it creates a massive explosion that destroys anything in it's path. It also creates several after-shock explosion and some fire.

This is the reason why they had to take out the Devistator - imagine shooting 15 nukes in under 7 seconds. This would bog the game down to a halt, and ultimately crash it due to too many sprites spawned in. The bottom line is that if you want to make the RPG into a large, powerful weapon, you are going to have to either take the Devistator out of the game completely, or sacrifice an inventory item as a flag when to have the RPG detonate like a rocket and like the Devistator.