home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / games / volume6 / gb / patch1 / max.c < prev    next >
C/C++ Source or Header  |  1989-07-06  |  2KB  |  78 lines

  1. /*
  2.  * Galactic Bloodshed (Robert Chansky, smq@b)
  3.  * max() -- return how many people one sector can support
  4.  * Distmap() -- map-oriented distance that does not look square
  5.  * compatibility() -- return how much race is compatible with planet
  6.  * gravity() -- return gravity for planet
  7.  * prin_ship_orbits() -- prints place ship orbits
  8.  */
  9.  
  10. #include "vars.h"
  11. #include "races.h"
  12. #include "ships.h"
  13. #include <math.h>
  14.  
  15. int maxsupport(p)
  16. reg sectortype *p;
  17. {
  18.  return(
  19.     (int)(powscale(p->eff)*FACTOR_FERT_SUPPORT*p->fert+p->fert + 1)
  20.        );
  21. }
  22.  
  23.  
  24.  
  25. int Distmap(x,y,x2,y2)
  26. reg int x,y,x2,y2;
  27. {
  28.  return( round_rand(fabs((double)x-x2) + fabs( (double)y-y2)*(RATIOXY*0.5) ) );
  29. }
  30.  
  31.  
  32. float compatibility(planet, race)
  33. reg planettype *planet;
  34. reg racetype *race;
  35. {
  36.  reg int i,add;
  37.  reg float sum=1.0;
  38.  
  39.     /* step through and report compatibility of each planetary gas */
  40.   for (i=TEMP; i<=OTHER; i++) {
  41.     add = ((float)planet->conditions[i] - race->conditions[i]);
  42.     sum *= 1.0 - (abs(add)/100.0);
  43.   }
  44.   return sum * 100.0; /** planet->conditions[TOXIC]*/
  45. }
  46.  
  47.  
  48.  
  49. float gravity(p)
  50. planettype *p;
  51. {
  52.  return (float)p->Maxx * p->Maxy * GRAV_FACTOR;
  53. }
  54.  
  55.  
  56.  
  57. char Dispshiporbits_buf[PLACENAMESIZE+13];
  58.  
  59. char *prin_ship_orbits(s)
  60. shiptype *s;
  61. {
  62.  
  63.   switch (s->whatorbits) {
  64.     case LEVEL_UNIV:
  65.         sprintf(Dispshiporbits_buf,"-");
  66.         break;
  67.     case LEVEL_STAR:
  68.         sprintf(Dispshiporbits_buf,"/%s", Stars[s->storbits]->name);
  69.         break;
  70.     case LEVEL_PLAN:
  71.         sprintf(Dispshiporbits_buf,"/%s/%s", 
  72.             Stars[s->storbits]->name,
  73.             Stars[s->storbits]->pnames[s->pnumorbits]);
  74.         break;
  75.   }
  76.   return Dispshiporbits_buf;
  77. }
  78.