From EDukeWiki
Revision as of 04:08, 15 September 2005 by Plugwash (talk | contribs) (→‎Onevent and endevent: rm incorrect caps)
Jump to navigation Jump to search

About This Guide


This guide will get you started with the basic aspects of EDuke32's commands -- those which set it apart from vanilla DN3D. This guide makes no assumptions regarding the programming experience of the reader, other than that the reader comprehends and understands the basic CON system as was seen in Duke Nukem 3D 1.3d-1.5.

Con Basics

As stated, this guide assume that you are familiar with the original CON code from Duke3D. If you are not already familiar with the default commands, the authors of this guide recommend the following guide to the basics, imported into the EDukeWiki for your convenience:

Another good source of basic information is the following FAQ:



Gamevars were introduced in WW2GI and remain the most important aspect of the new commandset. Gamevars allow you to store, manipulate, and execute code based on defined values. Prior to gamevars, the only usable alternatives were manipulations of inventory item counters and were, as you can imagine, very limited.


There are three basic types of gamevar, each type storing a signed 32-bit fixed-point integer. The three basic types are as follows:

  • Global variable: A global variable will be the same for any actor it is used in. Changing a global variable changes it for all actors in the game.
  • Per-player variable: A per-player variable may be set independently for each player in the game. If a player performs an action that triggers a per-player variable change within an event or the APLAYER actor code, it will only change for the player that initiated that action. If an actor changes a per-player variable, it will change for the closest player to the actor that changed it.
  • Per-actor variable: A per-actor variable may be independently assigned to each copy of an actor in the game.

Use and manipulation

Custom variables are defined with the gamevar command, and the term gamevar is therefore used to describe custom variables in EDuke32.

The syntax for defining a gamevar is:

gamevar <varname> <value> <flags>

You may use upper or lowercase letters for <varname>. EDuke32 is case-sensitive, so a var named "EXAMPLE1" is different from "example1." Variable names should not begin with a digit.

The <value> of the gamevar may be positive or negative.

The <flags> may be set to either 0 (global), 1 (per-player), or 2 (per-actor).

Manipulation of gamevars is accomplished by using a variety of commands that range in functionality from simple mathematical functions to grabbing internal values for manipulation in the CONs. Here are a few of the more common variable manipulation primitives:

And some of the more rarely used ones:

Note that a complete list of primitives is, of course, available here. The importance of manipulating gamevars will become clear when we get to talking about getting and setting the members of the various structures in the game. Also note that as of EDuke32 1.3.0, all commands which accept read-only gamevars will also now accept constants in place of them.

Members of game structures








EDuke32 provides both an object-oriented and an event-oriented interface to the game's internal workings. As you already know, the object-oriented part of Duke is the actor system -- in contrast to that, we'll be talking about the event-oriented portion in this section. As the name suggests, an event is a block of code that is triggered when a certain event in the game happens. Events in the game are triggered internally whenever a certain point in the code is reached.

Events are a key component in the manipulation of the game. Using events, we can do a variety of things such as intercept keypresses, draw to the screen (more on this later), redefine what a player does when certain actions are executed, et cetera.

onevent and endevent

onevent is the command used to start the definition of a block of code to be associated with one of the events. Similiar to the actor keyword, onevent must be terminated by the equivalent of enda, an endevent.


eventloadactor runs when an actor is loaded into the map. Despite the name it is not a game event but an entirely seperate type of block ended with enda. It is most usefull for moving settings out of hitags and lotags before they have unwanted hardcoded effects.

Drawing to the screen

The ability to properly draw to the screen is a huge improvement over the hackish abominations involving quotes and unused characters that we were forced to endure when using 1.3d and 1.5. There are several different drawing commands available, ranging in functionality from drawing graphics to the screen to printing text stored in quotes (see the section on string manipulation for more information).

Drawing commands

Custom projectiles

Defining custom projectiles

Manipulating custom projectiles mid-game

String manipulation

Quote redefinition mid-game

Copying and concatenation

Dynamic quotes