home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / games / volume3 / trek73 / part01 / src / bpv.c next >
Text File  |  1987-12-17  |  1KB  |  64 lines

  1. #ident "@(#) TREK73 $Header: bpv.c,v 1.2 87/10/09 15:48:35 okamoto Exp $"
  2. /*
  3.  * $Source: /ccc/okamoto/src/trek/src/RCS/bpv.c,v $
  4.  *
  5.  * $Header: bpv.c,v 1.2 87/10/09 15:48:35 okamoto Exp $
  6.  *
  7.  * $Log:    bpv.c,v $
  8.  * Revision 1.2  87/10/09  15:48:35  15:48:35  okamoto (Jeff Okamoto)
  9.  * Added declaration of round as a function returning a double.
  10.  * 
  11.  * Revision 1.1  87/10/09  11:00:29  11:00:29  okamoto (Jeff Okamoto)
  12.  * Initial revision
  13.  * 
  14.  */
  15. /*
  16.  * TREK73: bpv.c
  17.  *
  18.  * Calculate the Basic Point Value of a ships
  19.  *
  20.  */
  21.  
  22. void
  23. calculate(regen, pods, p_div, t_div, weapons, crew, bpv, eff, turn, max)
  24. double regen;    /* Regeneration */
  25. float pods;    /* Number of antimatter pods */
  26. float p_div;    /* Shield divisor for phasers */
  27. float t_div;    /* Shield divisor for torps */
  28. int weapons;    /* Number of weapons */
  29. int crew;    /* Number of crew */
  30. double *bpv;    /* Return for BPV */
  31. double *eff;    /* Return for efficiency */
  32. int *turn;    /* Turn per segment */
  33. int *max;    /* Maximum speed */
  34. {
  35.     double floor(), round();
  36.  
  37.     *bpv = 0.;
  38.     *bpv += regen * 12;
  39.     *bpv += pods / 2;
  40.     *bpv += p_div * 30;
  41.     *bpv += t_div * 40;
  42.     *bpv += weapons * 10;
  43.     *bpv += crew / 15;
  44.  
  45.     *eff = round(4 * (0.0034 * *bpv - 0.78)) / 4.0;
  46.     if (*eff< 0.25)
  47.         *eff= 0.25;
  48.     *turn = (int) (10 - floor(*bpv / 100.0));
  49.     if (*turn < 1)
  50.         *turn = 1;
  51.     *max= (int) round(-0.004 * *bpv + 11.0);
  52.     if (*max < 1)
  53.         *max = 1;
  54. }
  55.  
  56. double
  57. round(x)
  58. double x;
  59. {
  60.     double floor();
  61.  
  62.     return(floor(x + 0.5));
  63. }
  64.