home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 2 BBS / 02-BBS.zip / OP2DEV.ZIP / ITVERB.C < prev    next >
C/C++ Source or Header  |  1990-05-10  |  4KB  |  329 lines

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