home *** CD-ROM | disk | FTP | other *** search
/ Shareware Overload / ShartewareOverload.cdr / games / abermud.zip / MAGIC.C < prev    next >
C/C++ Source or Header  |  1989-07-08  |  6KB  |  275 lines

  1. #include <stdio.h>
  2. #include "files.h"
  3.  
  4. extern long curch;
  5. extern long mynum;
  6. extern long my_lev;
  7. extern char globme[];
  8. extern char wordbuf[];
  9. extern char *pname();
  10. extern char *oname();
  11. extern FILE *openroom();
  12. extern FILE *openuaf();
  13. extern FILE *openlock();
  14.  
  15. randperc()
  16. {
  17.     long x;
  18.     time(&x);
  19.     srand(x);
  20.     x=rand();
  21.     return(x%100);
  22. }
  23.  
  24. sumcom()
  25.     {
  26.     long a,b;
  27.     extern char wordbuf[];
  28.     extern long curch,mynum;
  29.     extern long my_lev;
  30.     extern long my_str;
  31.     extern char globme[];
  32.     char seg[128];
  33.     char mes[128];
  34.     char ms[128];
  35.     long c,d,x;
  36.     if(brkword()== -1)
  37.        {
  38.        bprintf("Summon who ?\n");
  39.        return;
  40.        }
  41.     a=fobn(wordbuf);
  42.     if(a!= -1) goto sumob;
  43.     a=fpbn(wordbuf);
  44.     if(a== -1)
  45.        {
  46.        bprintf("I dont know who that is\n");
  47.        return;
  48.        }
  49.     if(my_str<10)
  50.        {
  51.        bprintf("You are too weak\n");
  52.        return;
  53.        }
  54.     if(my_lev<10)my_str-=2;
  55.     c=my_lev*2;
  56.     if(my_lev>9) c=101;
  57. if(iscarrby(111,mynum)) c+=my_lev;
  58. if(iscarrby(121,mynum)) c+=my_lev;
  59. if(iscarrby(163,mynum)) c+=my_lev;
  60.     d=randperc();
  61.     if(my_lev>9) goto willwork;
  62.     if((iswornby(90,a))||(c<d))
  63.        {
  64.        bprintf("The spell fails....\n");
  65.        return;
  66.        }
  67. if((a==fpbn("wraith"))||((iscarrby(32,a))||(iscarrby(159,a))||iscarrby(174,a)))
  68. {
  69. bprintf("Something stops your summoning from succeeding\n");
  70. return;
  71. }
  72.     if(a==mynum)
  73.        {
  74.        bprintf("Seems a waste of effort to me....\n");
  75.        return;
  76.        }
  77.     if((curch>=-1082)&&(curch<=-1076))
  78.     {
  79.         bprintf("Something about this place makes you fumble the magic\n");
  80.         return;
  81.     }
  82. willwork:bprintf("You cast the summoning......\n");
  83.     if(a<16)
  84.        {
  85.           sendsys(pname(a),globme,-10020,curch,"");
  86.        return;
  87.        }
  88. if((a==17)||(a==23)) return;
  89.     dumpstuff(a,ploc(a));
  90.     sprintf(seg,"\001s%s\001%s has arrived\n\001",pname(a),pname(a));
  91. sendsys("","",-10000,curch,seg);
  92.     setploc(a,curch);
  93.     return;
  94.     sumob:;
  95.     if(my_lev<10)
  96.        {
  97.        bprintf("You can only summon people\n");
  98.        return;
  99.        }
  100.     x=oloc(a);
  101.     if(ocarrf(a)>0) x=ploc(x);
  102.     sprintf(ms,"\001p%s\001 has summoned the %s\n",globme,oname(a));
  103.     sendsys(globme,globme,-10000,x,ms);
  104.     bprintf("The %s flies into your hand ,was ",oname(a));
  105.     desrm(oloc(a),ocarrf(a));
  106.     setoloc(a,mynum,1);
  107.     }
  108.  delcom()
  109.     {
  110.     extern long my_lev;
  111.     extern char wordbuf[];
  112.     if(my_lev<11)
  113.        {
  114.        bprintf("What ?\n");
  115.        return;
  116.        }
  117.     if(brkword()== -1)
  118.        {
  119.        bprintf("Who ?\n");
  120.        return;
  121.        }
  122.     if(delu2(wordbuf)== -1)bprintf("failed\n");
  123.     }
  124.  
  125.  passcom()
  126.     {
  127.     extern char globme[];
  128.     chpwd(globme);
  129.     }
  130.  
  131.  goloccom()
  132.     {
  133.     extern long curch,my_lev;
  134.     extern char globme[];
  135.     char n1[128];
  136.     char bf[128];
  137.     extern char mout_ms[],min_ms[];
  138.     extern char wordbuf[];
  139.     long a;
  140.     FILE *b;
  141.     if(my_lev<10)
  142.        {
  143.        bprintf("huh ?\n");
  144.        return;
  145.        }
  146.     if(brkword()== -1)
  147.        {
  148.        bprintf("Go where ?\n");
  149.        return;
  150.        }
  151.     strcpy(n1,wordbuf);
  152.     if(brkword()== -1) strcpy(wordbuf,"");
  153.     a=roomnum(n1,wordbuf);
  154.     if((a>=0)||((b=openroom(a,"r"))==0))
  155.        {
  156.        bprintf("Unknown Room\n");
  157.        return;
  158.        }
  159.     fclose(b);
  160.     sprintf(bf,"\001s%%s\001%%s %s\n\001",mout_ms);
  161.     sillycom(bf);
  162.     curch=a;
  163.     trapch(curch);
  164.     sprintf(bf,"\001s%%s\001%%s %s\n\001",min_ms);    
  165.     sillycom(bf);
  166.     }
  167.  
  168.  
  169.  
  170.  
  171.  wizcom()
  172.     {
  173.     extern long my_lev;
  174.     extern char globme[],wordbuf[];
  175.     extern long curch;
  176.     extern long rd_qd;
  177.     char bf[128];
  178.     if(my_lev<10)
  179.        {
  180.        bprintf("Such advanced conversation is beyond you\n");
  181.        return;
  182.        }
  183.     getreinput(wordbuf);
  184.     sprintf(bf,"\001p%s\001 : %s\n",globme,wordbuf);
  185.     sendsys(globme,globme,-10113,curch,bf);
  186.     rd_qd=1;
  187.     }
  188.  
  189.  viscom()
  190.     {
  191.     long f;
  192.     extern long my_lev;
  193.     extern long mynum;
  194.     extern char globme[];
  195.     long ar[4];
  196.     if(my_lev<10)
  197.        {
  198.        bprintf("You can't just do that sort of thing at will you know.\n");
  199.        return;
  200.        }
  201.     if(!pvis(mynum))
  202.        {
  203.        bprintf("You already are visible\n");
  204.        return;
  205.        }
  206.     setpvis(mynum,0);
  207.     ar[0]=mynum;
  208.     ar[1]=pvis(mynum);
  209.     sendsys("","",-9900,0,ar);
  210.     bprintf("Ok\n");
  211.     sillycom("\001s%s\001%s suddenely appears in a puff of smoke\n\001");
  212.     }
  213.  
  214.  inviscom()
  215.     {
  216.     extern long mynum,my_lev;
  217.     extern char globme[];
  218.     extern char wordbuf[];
  219.     long f,x;
  220.     long ar[4];
  221.     if(my_lev<10)
  222.        {
  223.        bprintf("You can't just turn invisible like that!\n");
  224.        return;
  225.        }
  226.     x=10;
  227.     if(my_lev>9999) x=10000;
  228. if((my_lev==10033)&&(brkword()!=-1)) x=numarg(wordbuf);
  229.     if(pvis(mynum)==x)
  230.        {
  231.        bprintf("You are already invisible\n");
  232.        return;
  233.        }
  234.     setpvis(mynum,x);
  235.     ar[0]=mynum;
  236.     ar[1]=pvis(mynum);
  237.     sendsys("","",-9900,0,ar);
  238.     bprintf("Ok\n");
  239.     sillycom("\001c%s vanishes!\n\001");
  240.     }
  241.  
  242.  ressurcom()
  243.     {
  244.     extern long my_lev;
  245.     long bf[32];
  246.     extern long curch;
  247.     long a,b;
  248.     extern char wordbuf[];
  249.     if(my_lev<10)
  250.        {
  251.        bprintf("Huh ?\n");
  252.        return;
  253.        }
  254.     if(brkword()== -1)
  255.        {
  256.        bprintf("Yes but what ?\n");
  257.        return;
  258.        }
  259.     a=fobn(wordbuf);
  260.     if(a== -1)
  261.        {
  262.        bprintf("You can only ressurect objects\n");
  263.        return;
  264.        }
  265.     if(ospare(a)!= -1)
  266.        {
  267.        bprintf("That already exists\n");
  268.        return;
  269.        }
  270.     ocreate(a);
  271.     setoloc(a,curch,0);
  272.     sprintf(bf,"The %s suddenly appears\n",oname(a));
  273.     sendsys("","",-10000,curch,bf);
  274.     }
  275.