btmux-0.6-rc4/doc/
btmux-0.6-rc4/event/
btmux-0.6-rc4/game/
btmux-0.6-rc4/game/maps/
btmux-0.6-rc4/game/mechs/
btmux-0.6-rc4/game/text/help/
btmux-0.6-rc4/game/text/help/cat_faction/
btmux-0.6-rc4/game/text/help/cat_inform/
btmux-0.6-rc4/game/text/help/cat_misc/
btmux-0.6-rc4/game/text/help/cat_mux/
btmux-0.6-rc4/game/text/help/cat_mux/cat_commands/
btmux-0.6-rc4/game/text/help/cat_mux/cat_functions/
btmux-0.6-rc4/game/text/help/cat_templates/
btmux-0.6-rc4/game/text/wizhelp/
btmux-0.6-rc4/include/
btmux-0.6-rc4/misc/
btmux-0.6-rc4/python/
btmux-0.6-rc4/src/hcode/btech/
btmux-0.6-rc4/tree/
/*
 * $Id: btspath.c,v 1.1.1.1 2005/01/11 21:18:04 kstevens Exp $
 *
 * Author: Markus Stenberg <fingon@iki.fi>
 *
 *  Copyright (c) 1997 Markus Stenberg
 *       All rights reserved
 *
 * Created: Tue Sep 23 19:49:20 1997 fingon
 * Last modified: Thu Mar  5 18:50:58 1998 fingon
 *
 */

#include "mech.h"

extern MAP *spath_map;

#define XSIZE spath_map->map_width
#define YSIZE spath_map->map_height

extern int (*TileCost) (int fx, int fy, int tx, int ty);

int MechTileCost(int fx, int fy, int tx, int ty)
{
	int z1, z2;
	int bonus;
	char terr;

	if(tx < 0 || ty >= XSIZE || ty < 0 || ty >= YSIZE)
		return 0;
	z1 = Elevation(spath_map, fx, fy);
	z2 = Elevation(spath_map, tx, ty);
	if((bonus = abs(z1 - z2)) > 2)
		return 0;
	terr = GetRTerrain(spath_map, tx, ty);
	if(terr == WATER && z2)		/* No waterwalking, yet */
		return 0;
	if(terr == GRASSLAND)
		return 1 + bonus;
	switch (terr) {
	case LIGHT_FOREST:
	case ROUGH:
		bonus++;
		break;
	case HEAVY_FOREST:
	case MOUNTAINS:
		bonus += 2;
		break;
	}
	return bonus + 1;
}

int HoverTankTileCost(int fx, int fy, int tx, int ty)
{
	int z1, z2;
	int bonus;
	char terr;

	if(tx < 0 || ty >= XSIZE || ty < 0 || ty >= YSIZE)
		return 0;
	z1 = Elevation(spath_map, fx, fy);
	z2 = Elevation(spath_map, tx, ty);
	if((bonus = abs(z1 - z2)) > 1)
		return 0;
	terr = GetRTerrain(spath_map, tx, ty);
	if(terr == WATER)			/* Hovers LOVE water */
		return 1;
	if(terr == GRASSLAND)
		return 1 + bonus;
	if(terr == HEAVY_FOREST)
		return 0;
	switch (terr) {
	case LIGHT_FOREST:
	case ROUGH:
		bonus++;
		break;
	case MOUNTAINS:
		bonus += 2;
		break;
	}
	return bonus + 1;
}

int TrackedTankTileCost(int fx, int fy, int tx, int ty)
{
	int z1, z2;
	int bonus;
	char terr;

	if(tx < 0 || ty >= XSIZE || ty < 0 || ty >= YSIZE)
		return 0;
	z1 = Elevation(spath_map, fx, fy);
	z2 = Elevation(spath_map, tx, ty);
	if((bonus = abs(z1 - z2)) > 1)
		return 0;
	terr = GetRTerrain(spath_map, tx, ty);
	if(terr == GRASSLAND)
		return 1 + bonus;
	if(terr == WATER)
		return 0;
	if(terr == HEAVY_FOREST)
		return 0;
	switch (terr) {
	case LIGHT_FOREST:
	case ROUGH:
		bonus++;
		break;
	case HEAVY_FOREST:
	case MOUNTAINS:
		bonus += 2;
		break;
	}
	return bonus + 1;
}