home *** CD-ROM | disk | FTP | other *** search
/ Collection of Hack-Phreak Scene Programs / cleanhpvac.zip / cleanhpvac / ABERMUD.ZIP / OBJSYS.C < prev    next >
C/C++ Source or Header  |  1989-07-08  |  12KB  |  600 lines

  1. /*
  2.  
  3.  Object structure
  4.  
  5.  Name,
  6.  Long Text 1
  7.  Long Text 2
  8.  Long Text 3
  9.  Long Text 4
  10.  statusmax
  11.  Value
  12.  flags (0=Normal 1+flannel)
  13.  
  14.  */
  15.  
  16. #define NOBS 194
  17. #define OBMUL 8
  18. #include <stdio.h>
  19.  
  20. long numobs=NOBS;
  21. extern FILE *openlock();
  22. extern FILE *openworld();
  23. extern char * oname();
  24. extern char * pname();
  25.  
  26. long objinfo[NOBS*4];
  27.  
  28.  
  29.  inventory()
  30.     {
  31.     extern long mynum;
  32.    bprintf("You are carrying\n");
  33.     lobjsat(mynum);
  34.     }
  35.  
  36.  /*
  37.  Objinfo
  38.  
  39.  Loc
  40.  Status
  41.  Stamina
  42.  Flag 1=carr 0=here
  43.  */
  44.  
  45. lobjsat(loc)
  46. {
  47. aobjsat(loc,1);
  48. }
  49.  
  50.  
  51. aobjsat(loc,mode)  /* Carried Loc ! */
  52.     {
  53.     long a,b,c,d,e,f;
  54.     char x[6],y[6];
  55.     extern long debug_mode;
  56.     b=0;
  57.     c=0;
  58.     d=0;
  59.     e=0;
  60.     f=0;
  61.     while(c<NOBS)
  62.        {
  63.        if(((iscarrby(c,loc))&&(mode==1))||
  64. ((iscontin(c,loc))&&(mode==3)))
  65.           {
  66.           e=1;
  67.               f+=1+strlen(oname(c));
  68. if(debug_mode){ f+=5;sprintf(x,"%d",c);sprintf(y,"{%-3s}",x);}
  69. if(isdest(c)) f+=2;
  70. if(iswornby(c,loc)) f+=strlen("<worn> ");
  71.           if(f>79)
  72.              {
  73.              f=0;
  74.             bprintf("\n");
  75.              }
  76. if(isdest(c)) bprintf("(");
  77.          bprintf("%s",oname(c));
  78.          if(debug_mode) bprintf(y);
  79. if(iswornby(c,loc)) bprintf(" <worn>");
  80. if(isdest(c)) bprintf(")");
  81. bprintf(" ");
  82.           f++;
  83.           }
  84.        d+=4;
  85.        c++;
  86.        }
  87.     if(!e)bprintf("Nothing");
  88.    bprintf("\n");
  89.     }
  90.  
  91.  
  92. iscontin(o1,o2)
  93. {
  94. extern long my_lev;
  95. if(ocarrf(o1)!=3) return(0)
  96. ;
  97. if(oloc(o1)!=o2) return(0);
  98. if((my_lev<10)&&(isdest(o1)))return(0);
  99. return(1);
  100. }
  101.  
  102. fobnsys(nam,ctrl,ct_inf)
  103. char *nam;
  104. long ctrl,ct_inf;
  105. {
  106.     extern char wd_it[];
  107.     extern long mynum;
  108.     long a;
  109.     long l1[32],l2[32];
  110.     extern char wordbuf[];
  111.     strcpy(l1,nam);lowercase(l1);
  112.     a=0;
  113. if(!strcmp(l1,"red")) {brkword();return(4);}
  114. if(!strcmp(l1,"blue")) {brkword();return(5);}
  115. if(!strcmp(l1,"green")) {brkword();return(6);}
  116.     while(a<NOBS)
  117.        {
  118.        strcpy(l2,oname(a));lowercase(l2);
  119.        if(!strcmp(l1,l2))
  120.           {
  121.       strcpy(wd_it,nam);
  122.           switch(ctrl)
  123.              {
  124.              case 0:
  125.                 return(a);
  126.              case 1:/* Patch for shields */
  127.                 if((a==112)&&(iscarrby(113,mynum))) return(113);
  128.                 if((a==112)&&(iscarrby(114,mynum))) return(114);
  129.                 if(isavl(a)) return(a);
  130.                 break;
  131.              case 2:
  132.                 if(iscarrby(a,mynum)) return(a);
  133.                 break;
  134.              case 3:
  135.                 if(iscarrby(a,ct_inf)) return(a);
  136.                 break
  137.                 ;
  138.              case 4:
  139.                 if(ishere(a)) return(a);
  140.                 break;
  141.              case 5:
  142.                 if(iscontin(a,ct_inf)) return(a);
  143.                 break;
  144.              default:
  145.                 return(a);
  146.                 }
  147.           }
  148.        a++;
  149.        }
  150.     return(-1);
  151.     }
  152.  
  153.  fobn(word)
  154.  char *word;
  155.     {
  156. long x;
  157. x=fobna(word);
  158. if(x!=-1) return(x);
  159.     return(fobnsys(word,0,0));
  160.     }
  161.  
  162.  fobna(word)
  163.  char *word;
  164.     {
  165.     return(fobnsys(word,1,0));
  166.     }
  167.  
  168.  fobnin(word,ct)
  169.  char *word;
  170.  long ct;
  171.  {
  172.      return(fobnsys(word,5,ct));    
  173.  }
  174.  
  175.  fobnc(word)
  176.  char *word;
  177.     {
  178.     return(fobnsys(word,2,0));
  179.     }
  180.  
  181.  fobncb(word,by)
  182.  char *word;
  183.     {
  184.     return(fobnsys(word,3,by));
  185.     }
  186.  
  187.  fobnh(word)
  188.  char *word;
  189.     {
  190.     return(fobnsys(word,4,0));
  191.     }
  192.     
  193.  getobj()
  194.     {
  195.     extern long mynum;
  196.     extern char globme[];
  197.     extern long curch;
  198.     extern char wordbuf[];
  199.     long a,b;
  200.     long i;
  201.     long des_inf= -1;
  202.     extern long stp;
  203.     char bf[256];
  204.     if(brkword()==-1)
  205.        {
  206.       bprintf("Get what ?\n");
  207.        return;
  208.        }
  209.     a=fobnh(wordbuf);
  210.     /* Hold */
  211.     i=stp;
  212.     strcpy(bf,wordbuf);
  213.     if((brkword()!=-1)&&((strcmp(wordbuf,"from")==0)||(strcmp(wordbuf,"out")==0)))
  214.     {
  215.         if(brkword()==-1)
  216.         {
  217.             bprintf("From what ?\n");
  218.             return;
  219.         }
  220.         des_inf=fobna(wordbuf);
  221.         if(des_inf==-1)
  222.         {
  223.             bprintf("You can't take things from that - it's not here\n");
  224.             return;
  225.         }
  226.         a=fobnin(bf,des_inf);
  227.     }
  228.     stp=i;
  229.     if(a==-1)
  230.        {
  231.       bprintf("That is not here.\n");
  232.        return;
  233.        }
  234. if((a==112)&&(des_inf==-1))
  235. {
  236. if(isdest(113)) a=113;
  237. else if(isdest(114)) a=114;
  238. if((a==113)||(a==114)) oclrbit(a,0);
  239. else bprintf("The shields are all to firmly secured to the walls\n");
  240. }
  241.     if(obflannel(a)==1)
  242.        {
  243.       bprintf("You can't take that!\n");
  244.        return;
  245.        }
  246. if(dragget()) return;
  247.     if(!cancarry(mynum))
  248.        {
  249.       bprintf("You can't carry any more\n");
  250.        return;
  251. }
  252. if((a==32)&&(state(a)==1)&&(ptothlp(mynum)==-1))
  253. {
  254.     bprintf("Its too well embedded to shift alone.\n");
  255.     return;
  256. }
  257.     setoloc(a,mynum,1);
  258.     sprintf(bf,"\001D%s\001\001c takes the %s\n\001",globme,oname(a));
  259.    bprintf("Ok...\n");
  260.     sendsys(globme,globme,-10000,curch,bf);
  261. if(otstbit(a,12)) setstate(a,0);
  262. if(curch==-1081) 
  263. {
  264.     setstate(20,1);
  265.     bprintf("The door clicks shut....\n");
  266. }
  267.     }
  268.  
  269.  ishere(item)
  270.     {
  271.     extern long curch;
  272.     long a;
  273. extern long my_lev;
  274.     if((my_lev<10)&&(isdest(item)))return(0);
  275.     if(ocarrf(item)==1) return(0);
  276.     if(oloc(item)!=curch) return(0);
  277.     return(1);
  278.     }
  279.  
  280.  iscarrby(item,user)
  281.     {
  282.     extern long curch;
  283. extern long my_lev;
  284.     if((my_lev<10)&&(isdest(item)))return(0);
  285.     if((ocarrf(item)!=1)&&(ocarrf(item)!=2)) return(0);
  286.     if(oloc(item)!=user) return(0);
  287.     return(1);
  288.     }
  289.  
  290.  dropitem()
  291.     {
  292.     extern long mynum,curch;
  293.     extern char wordbuf[],globme[];
  294.     extern long my_sco;
  295.     long a,b,bf[32];
  296.     extern long my_lev;
  297.     if(brkword()==-1)
  298.        {
  299.       bprintf("Drop what ?\n");
  300.        return;
  301.        }
  302.     a=fobnc(wordbuf);
  303.     if(a==-1)
  304.        {
  305.       bprintf("You are not carrying that.\n");
  306.        return;
  307.        }
  308.  
  309. if((my_lev<10)&&(a==32))
  310. {
  311. bprintf("You can't let go of it!\n");
  312. return;
  313. }
  314.     setoloc(a,curch,0);
  315.    bprintf("OK..\n");
  316.     sprintf(bf,"\001D%s\001\001c drops the %s.\n\n\001",globme,wordbuf);
  317.     sendsys(globme,globme,-10000,curch,bf);
  318.     if((curch!=-183)&&(curch!=-5))return;
  319.    sprintf(bf,"The %s disappears into the bottomless pit.\n",wordbuf);
  320.    bprintf("It disappears down into the bottomless pit.....\n");
  321.     sendsys(globme,globme,-10000,curch,bf);
  322.     my_sco+=(tscale()*obaseval(a))/5;
  323.     calibme();
  324. setoloc(a,-6,0);
  325.     }
  326.  lisobs()
  327.     {
  328.     lojal2(1);
  329.     showwthr();
  330.     lojal2(0);
  331.     }
  332.  
  333.  lojal2(n)
  334.     {
  335.     extern char wd_it[];
  336.     long a;
  337.     a=0;
  338.     while(a<NOBS)
  339.        {
  340.        if((ishere(a))&&(oflannel(a)==n))
  341.           {
  342.               if(state(a)>3) continue;
  343.               if(!!strlen(olongt(a,state(a)))) /*OLONGT NOTE TO BE ADDED */
  344.         {
  345.             if(isdest(a)) bprintf("--");
  346.  
  347.                 oplong(a);
  348.                   strcpy(wd_it,oname(a));
  349.         }
  350.           }
  351.        a++;
  352.        }
  353.     }
  354.  dumpitems()
  355.     {
  356.     extern long mynum;
  357.     extern long curch;
  358.     dumpstuff(mynum,curch);
  359.     }
  360.  
  361.  dumpstuff(n,loc)
  362.     {
  363.     long b;
  364.     b=0;
  365.     while(b<NOBS)
  366.        {
  367.        if(iscarrby(b,n))
  368.  
  369.           {
  370.           setoloc(b,loc,0);
  371.           }
  372.        b++;
  373.        }
  374.     }
  375.  
  376. long ublock[16*49];
  377.  
  378.  
  379.  whocom()
  380.     {
  381.     long a;
  382.     extern long my_lev;
  383.     long bas;
  384.     a=0;
  385.     bas=16;
  386.     if(my_lev>9)
  387.        {
  388.       bprintf("Players\n");
  389.        bas=48;
  390.        }
  391.     while(a<bas)
  392.        {
  393.        if(a==16)bprintf("----------\nMobiles\n");
  394.        if(!strlen(pname(a))) goto npas;
  395.        dispuser(a);
  396.        npas:a++;
  397.        }
  398.    bprintf("\n");
  399.     }
  400.  
  401.  dispuser(ubase)
  402.     {
  403. extern long my_lev;
  404.     if(pstr(ubase)<0) return; /* On  Non game mode */
  405.     if(pvis(ubase)>my_lev) return;
  406. if(pvis(ubase)) bprintf("(");
  407.    bprintf("%s ",pname(ubase));
  408.     disl4(plev(ubase),psex(ubase));
  409. if(pvis(ubase)) bprintf(")");
  410. if(ppos(ubase)==-2) bprintf(" [Absent From Reality]");
  411. bprintf("\n");
  412.     }
  413.  
  414.  disle3(n,s)
  415.     {
  416.     disl4(n,s);
  417.    bprintf("\n");
  418.     }
  419.  disl4(n,s)
  420.     {
  421.     extern long hasfarted;
  422.     switch(n)
  423.        {
  424.        case 1:
  425.          bprintf("The Novice");
  426.           break;
  427.        case 2:
  428.           if(!s)bprintf("The Adventurer");
  429.           else
  430.             bprintf("The Adventuress");
  431.           break;
  432.        case 3:
  433.          bprintf("The Hero");
  434.           if(s)bprintf("ine");
  435.           break;
  436.        case 4:
  437.          bprintf("The Champion");
  438.           break;
  439.        case 5:
  440.           if(!s)bprintf("The Conjurer");
  441.           else
  442.             bprintf("The Conjuress");
  443.           break;
  444.        case 6:
  445.          bprintf("The Magician");
  446.           break;
  447.        case 7:
  448.           if(s)bprintf("The Enchantress");
  449.           else
  450.             bprintf("The Enchanter");
  451.           break;
  452.        case 8:
  453.           if(s)bprintf("The Sorceress");
  454.           else
  455.             bprintf("The Sorceror");
  456.           break;
  457. case 9:bprintf("The Warlock");
  458. break;
  459.        case 10:
  460.           if(s)bprintf("The Apprentice Witch");
  461.           else
  462.             bprintf("The Apprentice Wizard");
  463.           break;
  464. case 11:bprintf("The 370");
  465. break;
  466. case 12:bprintf("The Hilbert-Space");
  467. break;
  468. case 14:bprintf("The Completely Normal Naughty Spud");
  469. break;
  470. case 15:bprintf("The Wimbledon Weirdo");
  471. break;
  472. case 16:bprintf("The DangerMouse");
  473. break;
  474. case 17:bprintf("The Charred Wi");
  475. if(s) bprintf("tch");
  476. else bprintf("zard");
  477. break;
  478. case 18:bprintf("The Cuddly Toy");
  479. break;
  480. case 19:if(!hasfarted) bprintf("Of The Opera");
  481. else bprintf("Raspberry Blower Of Old London Town");
  482. break;
  483. case 20:bprintf("The 50Hz E.R.C.S");
  484. break;
  485. case 21:bprintf("who couldn't decide what to call himself");
  486. break;
  487. case 22:bprintf("The Summoner");
  488. break;
  489. case 10000:
  490. bprintf("The 159 IQ Mega-Creator");
  491. break;
  492. case 10033:
  493. case 10001:bprintf("The Arch-Wi");
  494. if(s)bprintf("tch");
  495. else bprintf("zard");
  496. break;
  497. case 10002:bprintf("The Wet Kipper");
  498. break;
  499. case 10003:bprintf("The Thingummy");
  500. break;
  501. case 68000:
  502. bprintf("The Wanderer");
  503. break;
  504. case -2:
  505. bprintf("\010");
  506. break;
  507. case -11:bprintf("The Broke Dwarf");break;
  508. case -12:bprintf("The Radioactive Dwarf");break;
  509. case -10:bprintf("The Heavy-Fan Dwarf");break;
  510. case -13:bprintf("The Upper Class Dwarven Smith");break;
  511. case -14:bprintf("The Singing Dwarf");break;
  512. case -30:bprintf("The Sorceror");break;
  513. case -31:bprintf("the Acolyte");break;
  514.        default:
  515.          bprintf("The Cardboard Box");
  516.           break;
  517.           }
  518.     }
  519. fpbn(name)
  520. char *name;
  521. {
  522. long s;
  523. extern char wd_them[],wd_him[],wd_her[],wd_it[];
  524. s=fpbns(name);
  525. if(s==-1) return(s);
  526. if(!seeplayer(s)) return(-1);
  527. return(s);
  528. }
  529.  
  530.  fpbns(name)
  531.  char *name;
  532.     {
  533.     char *n1[40],n2[40];
  534.     long a;
  535.     a=0;
  536.     while(a<48)
  537.        {
  538.        strcpy(n1,name);strcpy(n2,pname(a));
  539.        lowercase(n1);lowercase(n2);
  540. if((!!strlen(n2))&&(!strcmp(n1,n2))) return(a);
  541.        if(strncmp(n2,"the ",4)==0)
  542.        if((!!strlen(n2))&&(!strcmp(n1,n2+4)))return(a);
  543.        a++;
  544.        }
  545.     return(-1);
  546.     }
  547.  lispeople()
  548.     {
  549.     extern long debug_mode;
  550.     extern long curch;
  551.     extern long mynum;
  552.     extern char wd_him[],wd_her[];
  553.     long a,b;
  554.     b=0;
  555.     a=0;
  556.     while(a<48)
  557.        {
  558.        if(a==mynum)
  559.           {
  560.           a++;
  561.           continue;
  562.           }
  563.        if((!!strlen(pname(a)))&&(ploc(a)==curch)&&(seeplayer(a)))
  564.           {
  565.           b=1;
  566.          bprintf("%s ",pname(a));
  567.          if(debug_mode) bprintf("{%d}",a);
  568.           disl4(plev(a),psex(a));
  569.           if(psex(a)) strcpy(wd_her,pname(a));
  570.           else strcpy(wd_him,pname(a));
  571.          bprintf(" is here carrying\n");
  572.           lobjsat(a);
  573.           }
  574.        a++;
  575.        }
  576.     }
  577.  
  578. usercom()
  579. {
  580. extern long my_lev;
  581. long a;
  582. a=my_lev;
  583. my_lev=0;
  584. whocom();
  585. my_lev=a;
  586. }
  587.  
  588. oplong(x)
  589. {
  590. extern long debug_mode;
  591. if(debug_mode) 
  592. {
  593.     bprintf("{%d} %s\n",x,olongt(x,state(x)));    
  594.     return;
  595. }
  596. if(strlen(olongt(x,state(x))))
  597.    bprintf("%s\n",olongt(x,state(x)));
  598. }
  599.  
  600.