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

  1. #include <stdio.h>
  2. #include "files.h"
  3. extern FILE *openlock();
  4. extern FILE *openuaf();
  5. extern FILE *openroom();
  6. extern FILE *openworld();
  7. extern char *oname();
  8. extern char *pname();
  9. extern char globme[];
  10. extern char wordbuf[];
  11.  
  12.  
  13.  /*
  14.  
  15.  The next part of the universe...
  16.  
  17.  
  18.  */
  19.  
  20.  /*
  21.  
  22.  Weather Routines
  23.  
  24.  Current weather defined by state of object 47
  25.  
  26.  states are
  27.  
  28.  0   Sunny
  29.  1   Rain
  30.  2   Stormy
  31.  3   Snowing
  32.  
  33.  */
  34.  
  35.  
  36.  setwthr(n)
  37.     {
  38.     extern long my_lev;
  39.     if(my_lev<10)
  40.        {
  41.        bprintf("What ?\n");
  42.        return;
  43.        }
  44.     adjwthr(n);
  45.     }
  46.  
  47.  suncom()
  48.     {
  49.     setwthr(0);
  50.     }
  51.  
  52.  raincom()
  53.     {
  54.     setwthr(1);
  55.     }
  56.  
  57.  stormcom()
  58.     {
  59.     setwthr(2);
  60.     }
  61.  
  62.  snowcom()
  63.     {
  64.     setwthr(3);
  65.     }
  66.  
  67.  blizzardcom()
  68.     {
  69.         setwthr(4);
  70.     }
  71.  adjwthr(n)
  72.     {
  73.     long x;
  74.     extern char globme[];
  75.     extern long curch;
  76.     x=state(0);
  77.     setstate(0,n);
  78.     if(x!=n) sendsys(globme,globme,-10030,n,"");
  79.     }
  80.  
  81.  longwthr()
  82.     {
  83.     long a;
  84.     a=randperc();
  85.     if(a<50)
  86.        {
  87.        adjwthr(1);
  88.        return;
  89.        }
  90.     if(a>90)
  91.        {
  92.        adjwthr(2);
  93.        return;
  94.        }
  95.     adjwthr(0);
  96.     return;
  97.     }
  98.  
  99.  
  100.  wthrrcv(type)
  101.     {
  102.     if(!outdoors()) return;
  103. type=modifwthr(type);
  104.     switch(type)
  105.        {
  106.        case 0:
  107.           bprintf("\001cThe sun comes out of the clouds\n\001");
  108.           break;
  109.        case 1:
  110.           bprintf("\001cIt has started to rain\n\001");
  111.           break;
  112.        case 2:
  113.           break;
  114.        case 3:
  115.           bprintf("\001cIt has started to snow\n\001");
  116.           break;
  117.                case 4:
  118.           bprintf("\
  119.           }
  120.     }
  121.  
  122.  showwthr()
  123.     {
  124.     extern long curch;
  125.     if(!outdoors()) return;
  126.     switch(modifwthr(state(0)))
  127.        {
  128.        case 1:
  129. if((curch>-199)&&(curch<-178))
  130. {
  131. }
  132. else
  133.           bprintf("\001cIt is raining\n\001");
  134.           break;
  135.        case 2:
  136.           bprintf("\001cThe skies are dark and stormy\n\001");
  137.           break;
  138.        case 3:
  139.           bprintf("\001cIt is snowing\001\n");
  140.           break;
  141.               case 4:
  142.                    bprintf("\001cA blizzard is howling around you\001\n");
  143.                     break;
  144.           }
  145.     }
  146.  
  147.  outdoors()
  148.     {
  149.     extern long curch;
  150. switch(curch)
  151. {
  152. case -100:;
  153. case -101:;
  154. case -102:return(1);
  155. case -183:return(0);
  156. case -170:return(0);
  157. default:
  158. if((curch>-191)&&(curch<-168)) return(1);
  159. if((curch>-172)&&(curch<-181)) return(1);
  160. return(0);
  161. }
  162.     }
  163.  
  164.  
  165.  /* Silly Section */
  166.  
  167.  sillycom(txt)
  168.  char *txt;
  169.     {
  170.     extern char globme[];
  171.     extern long curch;
  172.     char bk[256];
  173.     sprintf(bk,txt,globme,globme);
  174.     sendsys(globme,globme,-10000,curch,bk);
  175.     }
  176.  
  177.  laughcom()
  178.     {
  179.     if(chkdumb()) return;
  180.     sillycom("\001P%s\001\001d falls over laughing\n\001");
  181.     bprintf("You start to laugh\n");
  182.     }
  183.  purrcom()
  184.     {
  185.     if(chkdumb()) return;
  186.     sillycom("\001P%s\001\001d starts purring\n\001");
  187.     bprintf("MMMMEMEEEEEEEOOOOOOOWWWWWWW!!\n");
  188.     }
  189.  
  190.  
  191.  crycom()
  192.     {
  193.     if(chkdumb()) return;
  194.     sillycom("\001s%s\001%s bursts into tears\n\001");
  195.     bprintf("You burst into tears\n");
  196.     }
  197.  
  198.  sulkcom()
  199.     {
  200.     sillycom("\001s%s\001%s sulks\n\001");
  201.     bprintf("You sulk....\n");
  202.     }
  203.  
  204.  burpcom()
  205.     {
  206.     if(chkdumb()) return;
  207.     sillycom("\001P%s\001\001d burps loudly\n\001");
  208.     bprintf("You burp rudely\n");
  209.     }
  210.  
  211.  hiccupcom()
  212.     {
  213.     if(chkdumb()) return;
  214.     sillycom("\001P%s\001\001d hiccups\n\001");
  215.     bprintf("You hiccup\n");
  216.     }
  217.  
  218. long hasfarted=0;
  219.  
  220. fartcom()
  221.    {
  222. extern long hasfarted;
  223. hasfarted=1;
  224. sillycom("\001P%s\001\001d lets off a real rip roarer\n\001");
  225. bprintf("Fine...\n");
  226.     }
  227.  
  228.  grincom()
  229.     {
  230.     sillycom("\001s%s\001%s grins evilly\n\001");
  231.     bprintf("You grin evilly\n");
  232.     }
  233.  
  234.  smilecom()
  235.     {
  236.     sillycom("\001s%s\001%s smiles happily\n\001");
  237.     bprintf("You smile happily\n");
  238.     }
  239.  
  240.  winkcom()
  241.     {                    /* At person later maybe ? */
  242.     sillycom("\001s%s\001%s winks suggestively\n\001");
  243.     bprintf("You wink\n");
  244.     }
  245.  
  246.  sniggercom()
  247.     {
  248.     if(chkdumb()) return;
  249.     sillycom("\001P%s\001\001d sniggers\n\001");
  250.     bprintf("You snigger\n");
  251.     }
  252.  
  253.  posecom()
  254.     {
  255.     long a;
  256.     extern long my_lev;
  257.     if(my_lev<10)
  258.        {
  259.        bprintf("You are just not up to this yet\n");
  260.        return;
  261.        }
  262.     time(&a);
  263.     srand(a);
  264.     a=randperc();
  265.     a=a%5;
  266.     bprintf("POSE :%d\n",a);
  267.     switch(a)
  268.        {
  269.        case 0:
  270.           break;
  271.        case 1:
  272. into the sky\n\001");
  273.           broad("\001cA massive ball of fire explodes high up in the sky\n\001");
  274.           break;
  275.        case 2:
  276.           break;
  277.        case 3:
  278.           sillycom("\001s%s\001%s \
  279. starts sizzling with magical energy\n\001");
  280.           break;
  281.        case 4:
  282.           sillycom("\001s%s\001%s begins to crackle with magical fire\n\001");
  283.           break;
  284.           }
  285.     }
  286.  
  287.  emotecom()
  288.  /*
  289.   (C) Jim Finnis
  290.  */
  291.  {
  292.      extern long my_lev;
  293.      char buf[100];
  294.      strcpy(buf,"\001P%s\001 ");
  295.      getreinput(buf+6);
  296.      strcat(buf,"\n");
  297.      if (my_lev<10000)
  298.          bprintf("Your emotions are strictly limited!\n");
  299.     else
  300.         sillycom(buf);
  301. }
  302.         
  303.  praycom()
  304.     {
  305.     extern long curch;
  306.     sillycom("\001s%s\001%s falls down and grovels in the dirt\n\001");
  307.     bprintf("Ok\n");
  308.     }
  309.  yawncom()
  310.     {
  311.     sillycom("\001P%s\001\001d yawns\n\001");
  312.     }
  313.  
  314.  groancom()
  315.     {
  316.     sillycom("\001P%s\001\001d groans loudly\n\001");
  317.     bprintf("You groan\n");
  318.     }
  319.  
  320.  moancom()
  321.     {
  322.     sillycom("\001P%s\001\001d starts making moaning noises\n\001");
  323.     bprintf("You start to moan\n");
  324.     }
  325.  
  326.  cancarry(plyr)
  327.     {
  328.     extern long numobs;
  329.     long a,b;
  330.     a=0;
  331.     b=0;
  332.     if(plev(plyr)>9) return(1);
  333.     if(plev(plyr)<0) return(1);
  334.     while(a<numobs)
  335.        {
  336.        if((iscarrby(a,plyr))&&(!isdest(a))) b++;
  337.        a++;
  338.        }
  339.     if(b<plev(plyr)+5) return(1);
  340.     return(0);
  341.     }
  342.  
  343.  
  344.  setcom()
  345.     {
  346.     long a,b,c;
  347.     extern long my_lev;
  348.     extern char wordbuf[];
  349.     if(brkword()== -1)
  350.        {
  351.        bprintf("set what\n");
  352.        return;
  353.        }
  354.     if(my_lev<10)
  355.        {
  356.        bprintf("Sorry, wizards only\n");
  357.        return;
  358.        }
  359.     a=fobna(wordbuf);
  360.     if(a== -1)
  361.        {
  362.          goto setmobile;
  363.        }
  364.     if(brkword()== -1)
  365.        {
  366.        bprintf("Set to what value ?\n");
  367.        return;
  368.        }
  369.        if(strcmp(wordbuf,"bit")==0) goto bitset;
  370.        if(strcmp(wordbuf,"byte")==0) goto byteset;
  371.     b=numarg(wordbuf);
  372.     if(b>omaxstate(a))
  373.        {
  374.        bprintf("Sorry max state for that is %d\n",omaxstate(a));
  375.        return;
  376.        }
  377.     if(b<0)
  378.        {
  379.        bprintf("States start at 0\n");
  380.        return;
  381.        }
  382.     setstate(a,b);
  383.     return;
  384. bitset:if(brkword()==-1)
  385.        {
  386.               bprintf("Which bit ?\n");
  387.               return;
  388.            }
  389.            b=numarg(wordbuf);
  390.            if(brkword()==-1)
  391.            {
  392.               bprintf("The bit is %s\n",otstbit(a,b)?"TRUE":"FALSE");
  393.               return;
  394.            }
  395.            c=numarg(wordbuf);
  396.            if((c<0)||(c>1)||(b<0)||(b>15))
  397.            {
  398.                bprintf("Number out of range\n");
  399.                return;
  400.            }
  401.            if(c==0) oclrbit(a,b);
  402.            else osetbit(a,b);
  403.            return;
  404. byteset:if(brkword()==-1)
  405.        {
  406.               bprintf("Which byte ?\n");
  407.               return;
  408.            }
  409.            b=numarg(wordbuf);
  410.            if(brkword()==-1)
  411.            {
  412.               bprintf("Current Value is : %d\n",obyte(a,b));
  413.               return;
  414.            }
  415.            c=numarg(wordbuf);
  416.            if((b<0)||(b>1)||(c<0)||(c>255))
  417.            {
  418.                bprintf("Number out of range\n");
  419.                return;
  420.            }
  421.     osetbyte(a,b,c);
  422.            return;       
  423. setmobile:a=fpbn(wordbuf);
  424.            if(a==-1)
  425.            {
  426.                bprintf("Set what ?\n");
  427.                return;
  428.            }
  429.            if(a<16)
  430.            {
  431.                bprintf("Mobiles only\n");
  432.                return;
  433.            }
  434.            if(brkword()==-1)
  435.            {
  436.                bprintf("To what value ?\n");
  437.                return;
  438.            }
  439.            b=numarg(wordbuf);
  440.            setpstr(a,b);
  441.     }
  442.  
  443.  
  444.  
  445. isdark()
  446.     {
  447. long c;
  448. extern long curch,my_lev;
  449. extern long numobs;
  450. if(my_lev>9) return(0);
  451. if((curch==-1100)||(curch==-1101)) return(0);
  452. if((curch<=-1113)&&(curch>=-1123)) goto idk;
  453. if((curch<-399)||(curch>-300)) return(0);
  454. idk:c=0;
  455. while(c<numobs)
  456. {
  457. if((c!=32)&&(otstbit(c,13)==0)) {c++;continue;}
  458. if(ishere(c)) return(0);
  459. if((ocarrf(c)==0)||(ocarrf(c)==3)) {c++;continue;}
  460. if(ploc(oloc(c))!=curch) {c++;continue;}
  461. return(0);
  462. }
  463. return(1);
  464. }
  465.  
  466.  
  467.  
  468. modifwthr(n)
  469. {
  470. extern long curch;
  471. switch(curch)
  472. {
  473. default:
  474. if((curch>=-179)&&(curch<=-199)) 
  475. {
  476.     if(n>1)return(n%2);
  477.     else return(n);
  478. }
  479. if((curch>=-178)&&(curch<=-100))
  480. {
  481.     if((n==1)||(n==2)) n+=2;
  482.     return(n);
  483. }
  484. return(n);
  485. }
  486. }
  487.  
  488. setpflags()
  489. {
  490.     long a,b,c,d;
  491.     extern long mynum;
  492.     extern char wordbuf[];
  493.     if(!ptstbit(mynum,2))
  494.     {
  495.         bprintf("You can't do that\n");
  496.         return;
  497.     }
  498.     if(brkword()==-1) 
  499.     {
  500.         bprintf("Whose PFlags ?\n");
  501.         return;
  502.     }
  503.     a=fpbn(wordbuf);
  504.     if(a==-1)
  505.     {
  506.         bprintf("Who is that ?\n");
  507.         return;
  508.     }
  509.     if(brkword()==-1)
  510.     {
  511.         bprintf("Flag number ?\n");
  512.         return;
  513.     }
  514.     b=numarg(wordbuf);
  515.     if(brkword()==-1)
  516.     {
  517.         bprintf("Value is %s\n",ptstflg(a,b)?"TRUE":"FALSE");
  518.         return;
  519.     }
  520.     c=numarg(wordbuf);
  521.     if((c<0)||(c>1)||(b<0)||(b>31))
  522.     {
  523.         bprintf("Out of range\n");
  524.         return;
  525.     }
  526.     if(c) psetflg(a,b);
  527.     else pclrflg(a,b);
  528. }
  529.