src/hcode/btech/btspath.c

Go to the documentation of this file.
00001 
00002 /*
00003  * $Id: btspath.c,v 1.1.1.1 2005/01/11 21:18:04 kstevens Exp $
00004  *
00005  * Author: Markus Stenberg <fingon@iki.fi>
00006  *
00007  *  Copyright (c) 1997 Markus Stenberg
00008  *       All rights reserved
00009  *
00010  * Created: Tue Sep 23 19:49:20 1997 fingon
00011  * Last modified: Thu Mar  5 18:50:58 1998 fingon
00012  *
00013  */
00014 
00015 #include "mech.h"
00016 
00017 extern MAP *spath_map;
00018 
00019 #define XSIZE spath_map->map_width
00020 #define YSIZE spath_map->map_height
00021 
00022 extern int (*TileCost) (int fx, int fy, int tx, int ty);
00023 
00024 int MechTileCost(int fx, int fy, int tx, int ty)
00025 {
00026         int z1, z2;
00027         int bonus;
00028         char terr;
00029 
00030         if(tx < 0 || ty >= XSIZE || ty < 0 || ty >= YSIZE)
00031                 return 0;
00032         z1 = Elevation(spath_map, fx, fy);
00033         z2 = Elevation(spath_map, tx, ty);
00034         if((bonus = abs(z1 - z2)) > 2)
00035                 return 0;
00036         terr = GetRTerrain(spath_map, tx, ty);
00037         if(terr == WATER && z2)         /* No waterwalking, yet */
00038                 return 0;
00039         if(terr == GRASSLAND)
00040                 return 1 + bonus;
00041         switch (terr) {
00042         case LIGHT_FOREST:
00043         case ROUGH:
00044                 bonus++;
00045                 break;
00046         case HEAVY_FOREST:
00047         case MOUNTAINS:
00048                 bonus += 2;
00049                 break;
00050         }
00051         return bonus + 1;
00052 }
00053 
00054 int HoverTankTileCost(int fx, int fy, int tx, int ty)
00055 {
00056         int z1, z2;
00057         int bonus;
00058         char terr;
00059 
00060         if(tx < 0 || ty >= XSIZE || ty < 0 || ty >= YSIZE)
00061                 return 0;
00062         z1 = Elevation(spath_map, fx, fy);
00063         z2 = Elevation(spath_map, tx, ty);
00064         if((bonus = abs(z1 - z2)) > 1)
00065                 return 0;
00066         terr = GetRTerrain(spath_map, tx, ty);
00067         if(terr == WATER)                       /* Hovers LOVE water */
00068                 return 1;
00069         if(terr == GRASSLAND)
00070                 return 1 + bonus;
00071         if(terr == HEAVY_FOREST)
00072                 return 0;
00073         switch (terr) {
00074         case LIGHT_FOREST:
00075         case ROUGH:
00076                 bonus++;
00077                 break;
00078         case MOUNTAINS:
00079                 bonus += 2;
00080                 break;
00081         }
00082         return bonus + 1;
00083 }
00084 
00085 int TrackedTankTileCost(int fx, int fy, int tx, int ty)
00086 {
00087         int z1, z2;
00088         int bonus;
00089         char terr;
00090 
00091         if(tx < 0 || ty >= XSIZE || ty < 0 || ty >= YSIZE)
00092                 return 0;
00093         z1 = Elevation(spath_map, fx, fy);
00094         z2 = Elevation(spath_map, tx, ty);
00095         if((bonus = abs(z1 - z2)) > 1)
00096                 return 0;
00097         terr = GetRTerrain(spath_map, tx, ty);
00098         if(terr == GRASSLAND)
00099                 return 1 + bonus;
00100         if(terr == WATER)
00101                 return 0;
00102         if(terr == HEAVY_FOREST)
00103                 return 0;
00104         switch (terr) {
00105         case LIGHT_FOREST:
00106         case ROUGH:
00107                 bonus++;
00108                 break;
00109         case HEAVY_FOREST:
00110         case MOUNTAINS:
00111                 bonus += 2;
00112                 break;
00113         }
00114         return bonus + 1;
00115 }

Generated on Mon May 28 04:25:21 2007 for BattletechMUX by  doxygen 1.4.7