home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-385-Vol-1of3.iso / x / xconq55.zip / xc5.5 / period.h < prev    next >
Text File  |  1991-06-17  |  11KB  |  216 lines

  1. /* Copyright (c) 1987, 1988  Stanley T. Shebs. */
  2. /* This program may be used, copied, modified, and redistributed freely */
  3. /* for noncommercial purposes, so long as this notice remains intact. */
  4.  
  5. /* Structures containing period parameters. */
  6. /* To simplify period compilation, the slots are arranged so that scalar */
  7. /* values are generally grouped together.  However, we're not too hardnosed */
  8. /* about it, and do segregate by general classes of values.  In any case, */
  9. /* the period compiler *must* be kept consistent with these structures. */
  10.  
  11. /* There is only one period object, but it's useful to get all global */
  12. /* period parameters glued into a single structure. */
  13.  
  14. typedef struct a_period {
  15.     char *name;              /* name of period */
  16.     char **notes;            /* designer's notes for period */
  17.     char *fontname;          /* name of font for period (optional) */
  18.     short countrysize;       /* radius of country in hexes */
  19.     short mindistance;       /* distance between countries in hexes */
  20.     short maxdistance;       /* distance between countries in hexes */
  21.     short numutypes;         /* number of unit types */
  22.     short numrtypes;         /* number of resource types */
  23.     short numttypes;         /* number of terrain types */
  24.     short numsnames;         /* number of random side names */
  25.     short numunames;         /* number of random unit names */
  26.     short firstutype;        /* starting unit if only one */
  27.     short firstptype;        /* what it will try to produce (check plaus) */
  28.     short knownradius;       /* area around the country that has been seen */
  29.     short allseen;           /* true if all units always seen */
  30.     short counterattack;     /* true if attacks go both ways */
  31.     short capturemoves;      /* true if captured units get to move immediately */
  32.     short nukehit;           /* how big a hit to qualify as nuke */
  33.     short neutrality;        /* how much more difficult to get neutrals */
  34.     short efficiency;        /* efficiency of unit recycling */
  35.     short altroughness;      /* fractal dimension for altitude */
  36.     short wetroughness;      /* fractal dimension for moisture */
  37.     short machineadvantage;  /* Should we set the machine up in a
  38.                 superiour position. */
  39.     short defaultterrain;    /* type of terrain to subst if unknown */
  40.     short edgeterrain;       /* type of terrain to put on N/S edge */
  41.     short spychance;         /* chance of spying each turn */
  42.     short spyquality;        /* percentage of info gathered when spying */
  43.     short leavemap;         /* true if units can leave the map */
  44.     short repairscale;         /* how many hps are repaired each time */
  45. } Period;
  46.  
  47. /* Unit type descriptions go into a single structure.  This structure */
  48. /* contains every single piece of information about all unit types. */
  49.  
  50. typedef struct utype {
  51.     char uchar;              /* character used in prompts */
  52.     char *name;              /* the name (frequently used!) */
  53.     char *help;              /* one-line description */
  54.     char **notes;            /* longer description */
  55.     char *bitmapname;        /* name of icon file (optional) */
  56.     /* attributes for initialization */
  57.     short incountry;         /* number that a side starts out with */
  58.     short density;           /* number of units per ten thousand hexes */
  59.     short named;             /* true if unit gets randomly-assigned name */
  60.     short alreadyseen;       /* true if unit seen at the outset */
  61.     short favored[MAXTTYPES];  /* chance to be found on given terrain */
  62.     short stockpile[MAXRTYPES];  /* percentage of supply at outset */
  63.     /* attributes for revolt phase */
  64.     short revolt;            /* chance to revolt */
  65.     short surrender;         /* base chance to surrender to nearby unit */
  66.     short siege;             /* extra chance to be captured in siege */
  67.     short attdamage;         /* damage when attrition happens */
  68.     char *attritionmsg;      /* what to say when attrition happens */
  69.     char *accidentmsg;       /* what to say when an accident happens */
  70.     short attrition[MAXTTYPES];  /* chance to lose hp */
  71.     short accident[MAXTTYPES];  /* chance to lose totally */
  72.     /* attributes for build phase */
  73.     short maker;             /* true if unit always builds */
  74.     short occproduce;        /* true if unit can produce when an occupant */
  75.     short startup;           /* extra prod schedule for first from unit */
  76.     short research;          /* extra production schedule for first on side */
  77.     short research_contrib[MAXUTYPES]; /* Fraction of other units research */
  78.                                        /* to add to this units R&D */
  79.     short make[MAXUTYPES];   /* base time to build a unit */
  80.     short tomake[MAXRTYPES]; /* amount of resource needed to build */
  81.     short repair[MAXUTYPES]; /* how many turns to regain a hit point */
  82.     /* attributes for supply phase */
  83.     short survival;          /* how long unit can starve */
  84.     char *starvemsg;         /* what to say when unit runs out of supplies */
  85.     short produce[MAXRTYPES];  /* rate of supply production */
  86.     short productivity[MAXTTYPES];  /* effect of terrain on production */
  87.     short storage[MAXRTYPES];  /* capacity for each type of resource */
  88.     short consume[MAXRTYPES];  /* overhead consumption in each turn */
  89.     short inlength[MAXRTYPES];  /* length of supply line coming in */
  90.     short outlength[MAXRTYPES];  /* length of supply line going out */
  91.     short consume_as_occupant;  /* should unit eat in base */
  92.     /* attributes for move phase */
  93.     short speed;             /* maximum theoretical speed in hexes/turn */
  94.     short moves[MAXTTYPES];  /* additional overhead due to terrain */
  95.     short randommove[MAXTTYPES];  /* randomness of move (.01% per turn) */
  96.     short tomove[MAXRTYPES];  /* supplies used to move with */
  97.     /* attributes for transportation */
  98.     short volume;            /* how much space one part takes */
  99.     short holdvolume;        /* space for passengers */
  100.     short capacity[MAXUTYPES];  /* carrying capacity, by unit type */
  101.     short entertime[MAXUTYPES];  /* moves to get on transport */
  102.     short leavetime[MAXUTYPES];  /* moves to get off transport */
  103.     short bridge[MAXUTYPES];  /* true if transport accessible across terr */
  104.     short mobility[MAXUTYPES];  /* true if unit is useless as occupant */
  105.     /* attributes for viewing */
  106.     short seealways;         /* true if unit view always up-to-date */
  107.     short seebest;           /* chance of seeing other units */
  108.     short seeworst;          /* see chance at max range */
  109.     short seerange;          /* how far unit can see another */
  110.     short visibility;        /* how easily others can see us */
  111.     short conceal[MAXTTYPES];  /* how visible in given terrain */
  112.     /* attributes for combat */
  113.     short hp;                /* max number of hit points */
  114.     short crippled;          /* hp at which unit loses functionality */
  115.     short selfdestruct;      /* true if unit always dies in attack */
  116.     short changeside;        /* chance of actually changing sides */
  117.     short hittime;           /* extra moves to attack */
  118.     short retreat;           /* chance of retreat to avoid a hit */
  119.     short counterable;       /* true if can counterattack */
  120.     short arearadius;        /* how big an area is hit */
  121.     char *destroymsg;        /* what to say when unit dies in combat */
  122.     short hit[MAXUTYPES];    /* chance of hitting other units */
  123.     short defense[MAXTTYPES];  /* how easy to hit in given terrain */
  124.     short damage[MAXUTYPES];  /* how many points it hits for */
  125.     short hitswith[MAXRTYPES];  /* amount of supply used for ammo */
  126.     short hitby[MAXRTYPES];  /* kind of ammo that hits unit */
  127.     short capture[MAXUTYPES];  /* chance of capturing a unit */
  128.     short guard[MAXUTYPES];  /* num parts needed to garrison/guard a capture */
  129.     short protect[MAXUTYPES];  /* effect on occupant on transport etc */
  130.     /* random general attributes */
  131.     short territory;         /* territorial value of unit */
  132.     short isneutral;         /* true if unit can change side or be neutral */
  133.     short disband;           /* true if unit can be gotten rid of */
  134.     /* attributes to help machine */
  135.     short attack_worth;      /* how many units should be used for attack */
  136.     short defense_worth;     /* how many units do we need for defence. */
  137.     short explore_worth;     /* how many units do we need for exploration. */
  138.     short min_region_size;   /* how much territory do we need to produce these */
  139.     short is_base;           /* unit is a type of base */
  140.     short is_base_builder;   /* unit can produce bases */
  141.     short is_transport;      /* unit can carry others */
  142.     short is_carrier;      /* unit can carry others */
  143.     short can_make;           /* unit can build something */
  144.     short can_capture;       /* unit can capture something */
  145. } Utype;
  146.  
  147. /* Definition of resource types.  These could maybe go in with utype stuff, */
  148. /* but are more conveniently separated. */
  149.  
  150. typedef struct rtype {
  151.     char rchar;              /* char representing resource */
  152.     char *name;              /* short name of resource */
  153.     char *help;              /* help string about resource */              
  154. } Rtype;
  155.  
  156. /* Definition of terrain types.  Most parameters are to get generation */
  157. /* right; unit interactions are all in utypes. */
  158.  
  159. typedef struct ttype {
  160.     char tchar;              /* char representing type */
  161.     char *name;              /* name of terrain */
  162.     char *color;             /* name of a color for color displays */
  163.     short dark;              /* true if terrain is "dark" */
  164.     short nuked;             /* terrain type after being nuked */
  165.     short minalt;            /* lowest altitude percentile for this type */
  166.     short maxalt;            /* highest altitude percentile for this type */
  167.     short minwet;            /* lowest moisture percentile */
  168.     short maxwet;            /* highest moisture percentile */
  169. } Ttype;
  170.  
  171. /* Macros for iterating over period description structures. */
  172.  
  173. #define for_all_unit_types(v)      for (v = 0; v < period.numutypes; ++v)
  174.  
  175. #define for_all_resource_types(v)  for (v = 0; v < period.numrtypes; ++v)
  176.  
  177. #define for_all_terrain_types(v)   for (v = 0; v < period.numttypes; ++v)
  178.  
  179. /* Macros to reduce the number of brackets and explicit structure refs. */
  180.  
  181. #define could_make(u1,u2) (utypes[u1].make[u2] > 0)
  182.  
  183. #define could_repair(u1, u2) (utypes[u1].repair[u2] > 0)
  184.  
  185. #define could_move(u,t) (utypes[u].moves[t] >= 0)
  186. #define could_move_in_dir(u, d) \
  187.   (could_move((u)->type, terrain_at(wrap((u)->x+dirx[(d)]), \
  188.                     (u)->y+diry[(d)])))
  189.  
  190. #define could_carry(u1,u2) (utypes[u1].capacity[u2] > 0)
  191.  
  192. #define could_hit(u1,u2) (utypes[u1].hit[u2] > 0)
  193.  
  194. #define could_capture(u1,u2) (utypes[u1].capture[u2] > 0)
  195.  
  196. #define impassable(u, x, y) (!could_move((u)->type, terrain_at((x), (y))))
  197.  
  198. #define isbase(u) (utypes[(u)->type].is_base)
  199.  
  200. #define base_builder(u) (utypes[(u)->type].is_base_builder)
  201.  
  202. #define istransport(u) (utypes[(u)->type].is_transport)
  203.  
  204. /* Declarations of the period description structures.  The structures */
  205. /* themselves will be in a compiled period description. */
  206.  
  207. extern Period period;
  208.  
  209. extern Utype utypes[];
  210.  
  211. extern Rtype rtypes[];
  212.  
  213. extern Ttype ttypes[];
  214.  
  215. extern char *snames[], *unames[];
  216.