home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / vol_100 / 159_01 / itverb.c < prev    next >
C/C++ Source or Header  |  1990-05-17  |  5KB  |  365 lines

  1.  
  2. /*  ITVERB.C  no mod for V 1.43  */
  3.  
  4. #include "advent.h"
  5.  
  6. /*
  7.         Routines to process intransitive verbs
  8. */
  9. VOID PASCAL itverb(VOID)
  10. {
  11.     switch (verb)
  12.     {
  13.     case DROP:
  14.     case SAY:
  15.     case WAVE:
  16.     case CALM:
  17.     case RUB:
  18.     case THROW:
  19.     case FIND:
  20.     case FEED:
  21.     case BREAK:
  22.     case WAKE:
  23.         needobj();
  24.         break;
  25.     case TAKE:
  26.         ivtake();
  27.         break;
  28.     case OPEN:
  29.     case LOCK:
  30.         ivopen();
  31.         break;
  32.     case NOTHING:
  33.         rspeak(54);
  34.         break;
  35.     case ON:
  36.     case OFF:
  37.     case POUR:
  38.         trverb();
  39.         break;
  40.     case WALK:
  41.         actspk(verb);
  42.         break;
  43.     case KILL:
  44.         ivkill();
  45.         break;
  46. #if 0
  47.     case EAT:
  48.         iveat();
  49.         break;
  50. #endif
  51.     case DRINK:
  52.         ivdrink();
  53.         break;
  54.     case QUIT:
  55.         ivquit();
  56.         break;
  57. #if 0
  58.     case FILL:
  59.         ivfill();
  60.          break;
  61. #endif
  62.     case BLAST:
  63.         vblast();
  64.         break;
  65.     case SCORE:
  66.         score();
  67.         break;
  68.     case FOO:
  69.         ivfoo();
  70.         break;
  71.     case SUSPEND:
  72.         saveflg = 1;
  73.         break;
  74.     case INVENTORY:
  75.         inventory();
  76.         break;
  77.     case SAVE:
  78.         saveadv();
  79.         describe();
  80.         descitem();
  81.         break;
  82.     case RESTORE:
  83.         restore();
  84.         describe();
  85.         descitem();
  86.         break;
  87.     case BRIEF:
  88.     case VERBOSE:
  89.         brief_sw = (BRIEF == verb);
  90.         rspeak(54);
  91.         break;
  92.     default:
  93.         printf("This intransitive not implemented yet\n");
  94.     }
  95.  
  96.     return;
  97. }
  98.  
  99. /*
  100.         CARRY, TAKE etc.
  101. */
  102. VOID PASCAL ivtake(VOID)
  103. {
  104.     auto     SHORT    anobj, item;
  105.  
  106.     anobj = 0;
  107.     for (item = 1; item < MAXOBJ; ++item)
  108.     {
  109.     if (place[item] == loc)
  110.     {
  111.         if (anobj != 0)
  112.         {
  113.         needobj();
  114.         return;
  115.         }
  116.         anobj = item;
  117.     }
  118.     }
  119.     if (anobj == 0 || (dcheck() && dflag >= 2))
  120.     {
  121.     needobj();
  122.     return;
  123.     }
  124.     object = anobj;
  125.     vtake();
  126.     return;
  127. }
  128.  
  129. /*
  130.         OPEN, LOCK, UNLOCK
  131. */
  132. VOID PASCAL ivopen(VOID)
  133. {
  134.     if (here(CLAM))
  135.     object = CLAM;
  136.     if (here(OYSTER))
  137.     object = OYSTER;
  138.     if (at(DOOR))
  139.     object = DOOR;
  140.     if (at(GRATE))
  141.     object = GRATE;
  142.     if (here(CHAIN))
  143.     {
  144.     if (object != 0)
  145.     {
  146.         needobj();
  147.         return;
  148.     }
  149.     object = CHAIN;
  150.     }
  151.     if (object == 0)
  152.     {
  153.     rspeak(28);
  154.     return;
  155.     }
  156.     vopen();
  157.     return;
  158. }
  159.  
  160. /*
  161.         ATTACK, KILL etc
  162. */
  163. VOID PASCAL ivkill(VOID)
  164. {
  165.     object1 = 0;
  166.     if (dcheck() && dflag >= 2)
  167.     object = DWARF;
  168.     if (here(SNAKE))
  169.     addobj(SNAKE);
  170.     if (at(DRAGON) && prop[DRAGON] == 0)
  171.     addobj(DRAGON);
  172.     if (at(TROLL))
  173.     addobj(TROLL);
  174.     if (here(BEAR) && prop[BEAR] == 0)
  175.     addobj(BEAR);
  176.     if (object1 != 0)
  177.     {
  178.     needobj();
  179.     return;
  180.     }
  181.     if (object != 0)
  182.     {
  183.     vkill();
  184.     return;
  185.     }
  186.     if (here(BIRD) && verb != THROW)
  187.     object = BIRD;
  188.     if (here(CLAM) || here(OYSTER))
  189.     addobj(CLAM);
  190.     if (object1 != 0)
  191.     {
  192.     needobj();
  193.     return;
  194.     }
  195.     vkill();
  196.     return;
  197. }
  198.  
  199. /*
  200.         EAT
  201. */
  202. VOID PASCAL iveat(VOID)
  203. {
  204.     if(!here(FOOD))
  205.        needobj();
  206.     else
  207.     {
  208.     object=FOOD;
  209.     veat();
  210.     }
  211.  
  212.     return;
  213. }
  214.  
  215. /*
  216.         DRINK
  217. */
  218. VOID PASCAL ivdrink(VOID)
  219. {
  220.     if (liqloc(loc) != WATER && (liq() != WATER || !here(BOTTLE)))
  221.     needobj();
  222.     else
  223.     {
  224.     object = WATER;
  225.     vdrink();
  226.     }
  227.  
  228.     return;
  229. }
  230.  
  231. /*
  232.         QUIT
  233. */
  234. VOID PASCAL ivquit(VOID)
  235. {
  236.     if (gaveup = yes(22, 54, 54))
  237.     normend();
  238.  
  239.     return;
  240. }
  241.  
  242. /*
  243.         FILL
  244. */
  245. VOID PASCAL ivfill(VOID)
  246. {
  247.     if (!here(BOTTLE))
  248.     needobj();
  249.     else
  250.     {
  251.     object=BOTTLE;
  252.     vfill();
  253.     }
  254.  
  255.     return;
  256. }
  257.  
  258. /*
  259.         Handle fee fie foe foo...
  260. */
  261. VOID PASCAL ivfoo(VOID)
  262. {
  263.     auto     SHORT     k, msg;
  264.  
  265.     k    = vocab(word1, 3000);
  266.     msg = 42;
  267.     if (foobar != 1 - k)
  268.     {
  269.     if (foobar != 0)
  270.         msg = 151;
  271.     rspeak(msg);
  272.     return;
  273.     }
  274.     foobar = k;
  275.     if (k != 4)
  276.     return;
  277.     foobar = 0;
  278.     if (place[EGGS] == 92 ||
  279.     (toting(EGGS) && loc == 92))
  280.     {
  281.     rspeak(msg);
  282.     return;
  283.     }
  284.  
  285.     if (place[EGGS] == 0 && place[TROLL] == 0 && prop[TROLL] == 0)
  286.     prop[TROLL] = 1;
  287.  
  288.     if (here(EGGS))
  289.     k = 1;
  290.     else
  291.     {
  292.     if (loc == 92)
  293.         k = 0;
  294.     else
  295.         k = 2;
  296.     }
  297.     move(EGGS, 92);
  298.     pspeak(EGGS, k);
  299.     return;
  300. }
  301.  
  302. /*
  303.         read etc...
  304. */
  305. VOID PASCAL ivread(VOID)
  306. {
  307.     if (here(MAGAZINE))
  308.     object = MAGAZINE;
  309.     if (here(TABLET))
  310.     object = object * 100 + TABLET;
  311.     if (here(MESSAGE))
  312.     object = object*100 + MESSAGE;
  313.     if (object > 100 || object == 0 || dark())
  314.     {
  315.     needobj();
  316.     return;
  317.     }
  318.     vread();
  319.     return;
  320. }
  321.  
  322. /*
  323.         INVENTORY
  324. */
  325. VOID PASCAL inventory(VOID)
  326. {
  327.     auto     SHORT       msg;
  328.     auto     SHORT       i;
  329.  
  330.     msg = 98;
  331.     for (i = 1; i <= MAXOBJ; ++i)
  332.     {
  333.     if (i == BEAR || !toting(i))
  334.         continue;
  335.     if (msg)
  336.         rspeak(99);
  337.     msg = 0;
  338.     pspeak(i, -1);
  339.     }
  340.     if (toting(BEAR))
  341.     msg = 141;
  342.     if (msg)
  343.     rspeak(msg);
  344.  
  345.     return;
  346. }
  347.  
  348. /*
  349.         ensure uniqueness as objects are searched
  350.         out for an intransitive verb
  351. */
  352. VOID PASCAL addobj(SHORT obj)
  353. {
  354.     if (object1 != 0)
  355.     return;
  356.  
  357.     if (object != 0)
  358.     {
  359.     object1 = -1;
  360.     return;
  361.     }
  362.     object = obj;
  363.     return;
  364. }
  365.