home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / games / volume13 / jetpack / part02 / message.c < prev    next >
C/C++ Source or Header  |  1992-04-10  |  3KB  |  115 lines

  1. /*    message.c : routines that implement a message display system
  2. */
  3.  
  4. #include "copyright.h"
  5. #include "defs.h"
  6. #include "message.h"
  7.  
  8. struct levelmessage    lmessage[MAXLEVELMESSAGES];
  9. int                    numlmessage;
  10.  
  11. char    messagestring[MAXMESSAGELENGTH],
  12.         bigmessagestring[MAXBIGMESSAGELENGTH];
  13. int        messagex, messagey, bigmessagex, bigmessagey,
  14.         messagetime = 0, bigmessagetime = 0,
  15.         messagecolor, bigmessagecolor,
  16.         messagelength = 0, bigmessagelength = 0,
  17.         messagewidth, bigmessagewidth;
  18.  
  19. /*    message puts a message s on the screen in color for time
  20. */
  21. message(s, color, time)
  22. char    *s;
  23. int        color, time;
  24. {
  25.     messagecolor = color;
  26.     messagetime = time;
  27.     strncpy(messagestring, s, MAXMESSAGELENGTH);
  28.     messagelength = strlen(messagestring);
  29.     messagewidth = XTextWidth(fontinfo, messagestring, messagelength);
  30.     messagey = WINDOWHEIGHT / 5 + 50;
  31.     messagex = WINDOWWIDTH / 2 - messagewidth / 2;
  32. }
  33.  
  34. /*    message puts a big message s on the screen in color for time
  35. */
  36. bigmessage(s, color, time)
  37. char    *s;
  38. int        color, time;
  39. {
  40.     bigmessagecolor = color;
  41.     bigmessagetime = time;
  42.     strncpy(bigmessagestring, s, MAXBIGMESSAGELENGTH);
  43.     bigmessagelength = strlen(bigmessagestring);
  44.     bigmessagewidth = XTextWidth(bigfontinfo, bigmessagestring,
  45.                                     bigmessagelength);
  46.     bigmessagey = WINDOWHEIGHT / 5;
  47.     bigmessagex = WINDOWWIDTH / 2 - bigmessagewidth / 2;
  48. }
  49.  
  50. /*    dumb_message puts up a message to the player when something happens.
  51.     Called dumb because the procedure is ugly and the messages are mostly
  52.     snide remarks.
  53. */
  54. dumb_message(kind)
  55. int    kind;
  56. {
  57.     register int    opinion, num;
  58.  
  59.     if(gameover) return;
  60.     if((messagetime != 0) && (kind != MKILL) && (kind != MSUICIDE) &&
  61.         (kind != MEXIT)) return;
  62.     if(exploded > -1) return;
  63.     if((dumbmessagechance[kind] > 1) &&
  64.         (random() % (dumbmessagechance[kind]) == 0)) return;
  65.     opinion = -1;
  66.     switch(kind) {
  67.         case MKILL:
  68.         case MCLOSE:
  69.         case MSUICIDE:
  70.         case MQUIT:
  71.             opinion = 0;
  72.             break;
  73.         case MFUEL:
  74.             if(playerfuel > FUELCAPACITY - FUELINCREMENT) opinion = 0;
  75.             if(playerfuel < 300) opinion = 1;
  76.             break;
  77.         case MKEY:
  78.             if(playerfuel < 400) {
  79.                 opinion = 2;
  80.                 break;
  81.             }
  82.             if(bonus < initbonus / 3) {
  83.                 opinion = 0;
  84.                 break;
  85.             }
  86.             if(bonus > (initbonus * 3) / 4) {
  87.                 opinion = 1;
  88.                 break;
  89.             }
  90.             opinion = 3;
  91.             break;
  92.         case MEXIT:
  93.             if(bonus == 0) {
  94.                 opinion = 0;
  95.                 break;
  96.             }
  97.             if(bonus >  (2 * initbonus) / 3) {
  98.                 opinion = 1;
  99.                 break;
  100.             }
  101.             if(bonus < initbonus / 3) {
  102.                 opinion = 2;
  103.                 break;
  104.             }
  105.             opinion = 3;
  106.             break;
  107.         default:
  108.             break;
  109.     }
  110.     if(opinion == -1) return;
  111.     num = random() % numdumbmessages[kind][opinion];
  112.     message(dumbmessage[kind][opinion][num], random() % (NCOLORS - 1) + 1,
  113.     dumbmessagetime[kind]);
  114. }
  115.