		    _   ________________ __ _____________   __
		   / | / / ____/_  __/ //_// ____/ ____/ | / /
		  /  |/ / __/   / / / ,<  / __/ / __/ /  |/ / 
		 / /|  / /___  / / / /| |/ /___/ /___/ /|  /  
		/_/ |_/_____/ /_/ /_/ |_/_____/_____/_/ |_/   
                                              
===============================================================================
NETKEEN

 by Lemm (Owen P.) 2010-2011

A multiplayer reverse/hack of Commander Keen : Galaxy

current version: 2011-07-01


===============================================================================
July 3, 2011
In a team game, you can switch view between teammates (doesn't change scorebox though).
Added different colors for teams (reddish vs bluish team).
Fixed a menu bug not allowing one to assign left/right keys.
Changed all instances of "kills" to stuns and removed points/kill limit from in game status menu if unlimited
Increased default extratics to 12 (~1/3rd second) and removed -et parm
Added left/right scrolling


May 15, 2011:
Fixed a few more things.  Added the -et parameter which GREATLY reduces lag.

Apr 22, 2011:
Fixed a few final glitches (goplat hitboxes)
Put frameskip back in


Apr 9, 2011:
Second release
Added -server parameter for choosing game host
Reduced the bomb damage to 50 from 60.
Fixed crash on songs > level 20.
Fixed demomode scorebox to display focused player's stats
Fixed points modes issues
Fixed double kills (sprites don't absorb shots when they are dead anymore)
Removed adjustable gemdoor open time.
Added four more spritesets (graphics courtesy of ceilick)
Switched over to KeenGraph for importing exporting

Pretty much everything i want to accomplish has been done in this release, so I think that's it for DOS netkeen


Feb 20:
First release.
DemoMode fixed.
Maps, Gfx, Sound put together by Ceilick.
Gravis GamePad in.
Mostly fixing little bugs here and there.

Feb 09:
Bombs in (although small bomb sprites still glitch through walls)
Zoom up and down
Demo Mode
Non-cosmetic animations synced across network
Map info preview
Scorebox + Game Summary improved
Team mode , and points, time, kills to win
Sprite idle frames removed
Game Info packs (ie. specify the file extension for game data)

Jan 23:
All four sprites nearly complete (spot, lindsey, keen, mort) players can choose
Scorebox HUD done (could be altered slightly)
Key config done
Music+Adlib sound in, SD_ module stripped of all things wolf
Mapheads cached individually
RF_ should be bug free now


Jan 14:
Fixed some stuff
Internalized ipxdriver
new maps and spot and lindsey
stuff respawns
wristwatch menu
rudimentary deathmatch mode with stunners, vitalins


Jan3:
PlaceSound()
Change ID kbddef
NOTE: the "maxsend" of ticcmds (NK_NET) has effect on lag 
	- playing on LAN, when maxsend = 17, lag of 1/2 second
	- when maxsend changed to 3, lag almost gone

Crashes:
	- Game just hangs; if router stopped, this will happen
	- If dosbox stopped, game just hangs
	- Game ran for 30 minutes on remote server vs remote server
		- could be my flaky connection causing random lockups

Jan2:
Started RF_PlaceText
Compressed Ticcmds
colorcombo memtoscreen







About:

NetKeen was originally an attempt to reverse engineer the Commander KeeKeep /new/ out of /n/.n Galaxy smooth scrolling engine, using the source code from the Wolf 3D "Id engine" and the keen 4 disassembly by Andy Durdin.  It grew into a actual multiplayer arena deathmatch-style game after the addition of the DoomNet IPX driver.
NetKeen runs in DOS in mode 0Dh EGA 16 colour graphics and 386 instructions in 16-bit real mode.  The smooth scrolling engine, game physics, and keen behaviours are near 100% accurate.  Using the DosBox IPX network emulation, multiplayer games (up to four players) can be played via LAN or over the internet.  Games are quite playable if the sum of the ping from DosBox IPX client A to the DosBox IPX server, and from client B to the DosBox server is under 200 ms.
The source code is included.  It will compile using Borland C++ version 5.0.x (the last one that supports DOS real mode programs), and perhaps using earlier versions as well running under windows XP, 2000, NT, or 98.

-------------------------------------------------------------------------------

Requirements:

A computer capable of running DosBox.  (Anything made since 2000 should be fine)
The latest version of DosBox (0.74 at the time of this writing).
An internet or LAN connection.
An instant messaging or IRC client.
One to Three opponents.


-------------------------------------------------------------------------------
How to get started:

There are several steps to running NetKeen.  It might be a little tricky at first if you are not used to a command line interface, but it is simple once you get the hang of it.

A) Enabling IPX networking in DosBox
B) Connecting the DosBoxen
C) Starting NetKeen

A: Enabling IPX (performed once)

In Windows, go to your DosBox installation folder (default Program Files\DosBox v x.xx) and look for a file named DosBox x.xx Options.bat (where x.xx is the version number).  Running this batch file opens the dosbox configuration file.  Find "ipx" and change ipx=false to ipx=true, then save and exit the text editor.

Under Linux, the DosBox configuration file is found in ~/.dosbox/


B: Connecting the DosBoxes

For network play, one or more DosBoxes must act as an IPX server.  The others will be clients that connect to the server.  

Internet Server setup:

Over the internet, the server must first forward a UDP port that is to be used for DosBox.  On a home network, this is accomplished by logging into the router control panel and forwarding a UDP port between 1024 and 65536 (3140 in this example).  For more information on port forwarding for your router, please visit http://www.portforward.com/.  Once you have forwarded UDP port 3140, enter at the dosbox command line:

	ipxnet startserver 3140

Internet Client Setup:

The clients connect to the server by typing, at the DosBox command line:

	ipxnet connect <host ip address> 3140

Other connection notes:

Over a LAN game, specifying a port is generally not required.  All that the client needs to know is the LAN IP address of the server.

In choosing a server for a 3 or 4 player internet game, the computer which is geographically central is usually the best choice.  Server choice can have a dramatic impact on lag, so make sure to try all possibilities.

Visit the DosBox Wiki for more information on IPX networking


C: Starting Netkeen

Netkeen is started from the command line by typing:

	netkeen <switches>

There are several switches required for operation.  Examples follow at the end of this section.

General Switches:

-server : Tells the dosbox to act as a game host.  ONE, and ONLY ONE player MUST specify this switch!  The game host starts the games from the lobby and controls all of the game settings.

-nodes <number of nodes> : Signifies that you want to play a network game with <number of nodes> players.  By default, a 2 player game is started if the number of nodes is left out.

-ext <game extension> :  The extension of the game data (i.e. which episode) you want to play.  All parties must use the same extension, or the game will not start.  By default, CK5 is used as the extension.

Example: play a local game (no opponents) using episode keen 4 files:

	netkeen -ext ck4

Example: host a 3 player game for keen 6:

	netkeen -server -ext ck6 -nodes 3

Example: join a 3 player game for keen 5:

	netkeen -ext ck5 -nodes 3

	

Advanced Switches (not necessary for normal game play):

-debug : Logs debug information to file DEBUG.TXT in the NetKeen folder.  (Useful for identifying lag sources.)

-port <port number> : Specifies the port to use.  Don't really need to fool with this in DosBox.  (This isn't the UDP port described earlier; it's the faux IPX port which doesn't need to be tampered with.)


-------------------------------------------------------------------------------

Menu:

The familiar wristwatch menu lets you choose the game options.

NEW GAME:  Start a new game and set game parameters.  Note that you must set the game options BEFORE starting a new game.

-	LOCAL GAME:  Starts a local game (single player, just for testing the levels)

-	HOST/JOIN NETGAME:  Starts a net game.  The machine that is designated host (using the -server parameter) will send its game options to all of the other machines.

-	GAME OPTIONS:  Lets you choose the game parameters:
	-   TEAM GAME: Yes means a 2-team game
	-	NUMBER OF PLAYERS: From 1 - 4, the number of players that will be spawned
	-	LAG BUFFER: Estimate the ping by typing IPXNET PING at the DOS prompt.  The lag buffer should be this amount (in ms)/28.If you're not sure, just try 6.  If the game is lagging, increase this amount.  If the game isn't lagging, but the character feels unresponsive, lower this amount.
	-	EXTRA OPTIONS:
		-	VICTORY CONDITIONS: select the number of stuns or points to win the game.
		-	MISC OPTIONS:
			-	Starting Ammo/Bombs:  Munitions you are given upon spawning.
			-	Hazard Penalty Off: You don't lose a life from a hazard death.

-	MAP SETUP: Select a map
-	PLAYER SETUP:	Lets you choose your character
-	DEMO SETUP:  Record demos.  
		If you select a free demo slot, the next game will be recorded so that you can play it back later.  
		You must delete demos from outside the game.
		Note that demos will only work with the version of netkeen under which they were recorded (and they might even crash the game, so don't reuse).

CONFIGURE:

	Configure a subset of the game options as per normal.  Here's a few of them:
		THROW: Throw Boobus Bombs.  Note that holding the movement arrows will modulate throw power and angle.  Useful for attacking enemies hiding in pole shafts or beyond a slope.
		Look Up/Down:  These quickly scroll the screen up and down, and the screen returns to normal upon their release
		Status: Display a quick in-game summary of players' scores.
		Look up/down speed:  Speed at which screen will scroll up/down when player is looking up/ducking.  If you use the quick-scroll buttons, you can set this to zero.  If not, you can set it to a higher value so that you don't get wasted while scanning for an enemy.
		Demo Zip:  Speeds through demo replays.
		Change View:  During demo replays, cycles camera focus over different players.


-------------------------------------------------------------------------------

Game:

The game is a multiplayer deathmatch, (or more appropriately, stunmatch).  Stunning your opponent will garner you one point.  If you succumb to an auto gun or hit a lethal tile, then you will lose one point.  Your health, score, and ammo are displayed in the scorebox in the top left corner.


Damage rules:
You start with 100 hit points, 3 seconds of invincibility, and a small allowance of ammunition.  You max out at 200 HP, 99 shots and 9 bombs.

Stunners deplete 40 hit points, and bombs deplete 50 hit points.
Auto guns deplete 60 hit points, and deadly tiles or the bottom of the map is an instant stun!

Items:
Stunners yield 5 shots, and a bomb icon is 3 bombs.  Both respawn every 30 seconds.
Life items restore 5 hit points and respawn every minute.  Kegs supercharge your health and respawn every few minutes.

Treasure items work as usual and respawn every minute.
Gems will open doors, however, the doors will close immediately afterwards, so be quick!  Gems respawn every minute.


Issues:
	This is an amateurish hack; there's bound to be some bugs.  Here's some notable ones:

Memory errors:  Playing 4 player games with all 4 characters pushes the memory limits.  If you are bombing back to DOS on memory errors, try playing a smaller map with fewer unique tiles.  Or, only play with three characters.
Flaky/long distance connections:  If you're playing over the internet, a bad connection can hang the game indefinitely.  If this happens, HOLD ESC to go back to the watch and try to reset the game.   (In this situation, the tiles should still animate, albeit very slowly).  Try to increase the lag buffer, or the -et parameter.
DOSBOX:  In dosbox.conf, make sure that ipx=true and machine=svga_s3, and that ems, xms and umb are all TRUE.  You might need to forward your ports.  (Read the dosbox connectivity guide for further details).
Network:  earlier versions were known to pause all traffic on a home network.   I think this was fixed.


-------------------------------------------------------------------------------

Modding NetKeen:


You can mod netkeen by making your own levels, graphics, or audio.

In general, treat your episode as if you were making a keen 5 mod.  (You'll need to go learn about Keen Modding at www.keenmodding.org)

For graphics editing, use the newest version of KeenGraph, and export an existing episode as Keen 5, and work from there.

If you want to synchronize an animation across the network (FG tiles only), then tiles in the animation loop cannot share the same properties for all frames (i.e., blocking or miscflags must vary between tiles in the animation loop).  Only syncronize what is necessary; cosmetic animations need not be synced.

Don't put too many respawning items, player spawn points, sprites, or netsynced animated tiles in your level.  (80 is the limit, the game should crash with an error if you do.)

If you make bridges, make sure they are at least 4 or 5 tiles in length.  If they are too short and someone is hanging on the left edge when the bridge is close by another player, then the first player will clip through the top of the bridge to the right if he drops.  If they bridge is < 4 tiles wide, this can be erratic...

For assigning songs to levels, open EPISODE.EXT in a hex editor.  The value of the n'th byte will set that song number to the n'th level.  Use Wolf Data Compiler to make your audio files.

-------------------------------------------------------------------------------

Credits:

Ceilick, for making the the additional player sprites and nearly all of the maps, and for his extensive testing.  A good portion of the work gone into NetKeen is his own.
Andy Durdin, for his work in reverse engineering the source code and making tools to edit pretty much everything in keendom.   Much of his reverse-engineering output was used or adapted to make this game.
Levellass, Mink, and others who made tools for altering Keen Graphics, Maps, etc.
The Commander Keen IRC channel, for making maps and testing.
Peter Matjeschk, for reversing a few of the keen behaviours.
The original Id team, for making Keen, Wolf3D, and DOOM, and making the source code for the latter two games freely available.


