#!/usr/local/bin/perl

# This script will write (to stdout) all the needed exits to connect maps
# in a tiled fashion.  The variables at the start will need to be set
# for things to work.

# Set these as appropriate to the maps it should connect to.  If one is left
# blank, then exits for that direction will not be created.
$NORTH="world_c3";
$NORTHWEST="world_b2";
$WEST="world_b3";
$SOUTHWEST="";
$SOUTH="";
$SOUTHEAST="";
$EAST="";
$NORTHEAST="";

$WIDTH=42;
$HEIGHT=34;
# DELTA What the overlap is - it should always be 5 for smooth transitions
$DELTA=5;


# End of configurable options.
# Quick reminder - hp is the destination x, sp is the destination y

# Lets do the corners first
if ($NORTHWEST ne "") {
	print "arch exit\n";
	print "slaying $NORTHWEST\n";
	print "x $DELTA\n";
	print "y $DELTA\n";
	print "hp ".($WIDTH-$DELTA-1)."\n";
	print "sp ".($HEIGHT-$DELTA-1)."\n";
	print "end\n";
}
if ($SOUTHWEST ne "") {
	print "arch exit\n";
	print "slaying $SOUTHWEST\n";
	print "x $DELTA\n";
	print "y ".($HEIGHT-$DELTA)."\n";
	print "hp ".($WIDTH-$DELTA-1)."\n";
	print "sp ".($DELTA+1)."\n";
	print "end\n";
}
if ($SOUTHEAST ne "") {
	print "arch exit\n";
	print "slaying $SOUTHEAST\n";
	print "x ".($WIDTH-$DELTA)."\n";
	print "y ".($HEIGHT-$DELTA)."\n";
	print "hp ".($DELTA+1)."\n";
	print "sp ".($DELTA+1)."\n";
	print "end\n";
}
if ($NORTHEAST ne "") {
	print "arch exit\n";
	print "slaying $NORTHEAST\n";
	print "x ".($WIDTH-$DELTA)."\n";
	print "y ".$DELTA."\n";
	print "hp ".($DELTA+1)."\n";
	print "sp ".($HEIGHT-$DELTA-1)."\n";
	print "end\n";
}

# Now lets do the edges.
	
if ($NORTH ne "") {
	$x=$DELTA+1;
	while ($x < ($WIDTH-$DELTA-1)) {
	    	print "arch exit\n";
		print "slaying $NORTH\n";
		print "x ".$x."\n";
		print "y ".$DELTA."\n";
		print "hp ".$x."\n";
		print "sp ".($HEIGHT-$DELTA-1)."\n";
		print "end\n";
		$x=$x+1;
	}
}

if ($SOUTH ne "") {
	$x=$DELTA+1;
	while ($x < ($WIDTH-$DELTA-1)) {
	    	print "arch exit\n";
		print "slaying $SOUTH\n";
		print "x ".$x."\n";
		print "y ".($HEIGHT-$DELTA)."\n";
		print "hp ".$x."\n";
		print "sp ".($DELTA+1)."\n";
		print "end\n";
		$x=$x+1;
	}
}


if ($WEST ne "") {
	$y=$DELTA+1;
	while ($y < ($HEIGHT-$DELTA-1)) {
	    	print "arch exit\n";
		print "slaying $WEST\n";
		print "x ".$DELTA."\n";
		print "y ".$y."\n";
		print "hp ".($WIDTH-$DELTA-1)."\n";
		print "sp ".$y."\n";
		print "end\n";
		$y=$y+1;
	}
}


if ($EAST ne "") {
	$y=$DELTA+1;
	while ($y < ($HEIGHT-$DELTA-1)) {
	    	print "arch exit\n";
		print "slaying $EAST\n";
		print "x ".($WIDHT-$DELTA)."\n";
		print "y ".$y."\n";
		print "hp ".($DELTA_1)."\n";
		print "sp ".$y."\n";
		print "end\n";
		$y=$y+1;
	}
}

