Path: utzoo!attcan!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!zephyr.ens.tek.com!tekred!saab!billr From: billr@saab.CNA.TEK.COM (Bill Randle) Newsgroups: comp.sources.games Subject: v11i092: larn - dungeon type adventure game, Part09/11 Message-ID: <6723@tekred.CNA.TEK.COM> Date: 18 Dec 90 18:35:21 GMT Sender: news@tekred.CNA.TEK.COM Lines: 1888 Approved: billr@saab.CNA.TEK.COM Submitted-by: routley@tle.ENET.DEC.COM (Kevin Routley) Posting-number: Volume 11, Issue 92 Archive-name: larn/Part09 Environment: Unix, VMS, MS-DOS, termcap #! /bin/sh # This is a shell archive. Remove anything before this line, then unpack # it by saving it into a file and typing "sh file". To overwrite existing # files, type "sh file -c". You can also feed this as standard input via # unshar, or by typing "sh 'action.c' <<'END_OF_FILE' X/* X action.c X X Routines to perform the actual actions associated with various X player entered commands. X X act_remove_gems remove gems from a throne X act_sit_throne sit on a throne X act_kick_stairs kick the stairs X act_up_stairs go up stairs X act_down_stairs go down stairs X act_drink_fountain drink from a fountain X act_wash_fountain wash at a fountain X act_up_shaft up volcanic shaft X act_down_shaft down volcanic shaft X volshaft_climbed place player near volcanic shaft X act_desecrate_altar desecrate an altar X act_donation_pray pray, donating money X act_just_pray pray, not donating money X act_prayer_heard prayer was heard X act_ignore_altar ignore an altar X act_open_chest open a chest X act_open_door open a door X*/ X X#include "header.h" X X/* X act_remove_gems X X Remove gems from a throne. X X arg is zero if there is a gnome king associated with the throne X X Assumes that cursors() has been called previously, and that a check X has been made that the throne actually has gems. X*/ Xact_remove_gems( arg ) Xint arg ; X { X int i, k ; X X k=rnd(101); X if (k<25) X { X for (i=0; i= 2 && level != 11) X { X newcavelevel( level - 1 ) ; X draws( 0, MAXX, 0, MAXY ); X bot_linex() ; X } X else X lprcat("\nThe stairs lead to a dead end!") ; X return ; X } X X/* X assumes that cursors() has been called and that a check has been made that X the user is actually standing at a set of down stairs. X*/ Xact_down_stairs() X { X if (level != 0 && level != 10 && level != 13) X { X newcavelevel( level + 1 ) ; X draws( 0, MAXX, 0, MAXY ); X bot_linex() ; X } X else X lprcat("\nThe stairs lead to a dead end!") ; X return ; X } X X/* X Code to perform the action of drinking at a fountian. Assumes that X cursors() has already been called, and that a check has been made that X the player is actually standing at a live fountain. X*/ Xact_drink_fountain() X { X int x ; X X if (rnd(1501)<2) X { X lprcat("\nOops! You seem to have caught the dreadful sleep!"); X beep(); X lflush(); X sleep(3); X died(280); X return; X } X X x = rnd(100); X if (x<7) X { X c[HALFDAM] += 200 + rnd(200); X lprcat("\nYou feel a sickness coming on"); X } X X else if (x < 13) X quaffpotion(23, FALSE ); /* see invisible,but don't know the potion */ X X else if (x < 45) X lprcat("\nnothing seems to have happened"); X X else if (rnd(3) != 2) X fntchange(1); /* change char levels upward */ X X else X fntchange(-1); /* change char levels downward */ X X if (rnd(12)<3) X { X lprcat("\nThe fountains bubbling slowly quiets"); X item[playerx][playery]=ODEADFOUNTAIN; /* dead fountain */ X know[playerx][playery]=0; X } X return; X } X X/* X Code to perform the action of washing at a fountain. Assumes that X cursors() has already been called and that a check has been made that X the player is actually standing at a live fountain. X*/ Xact_wash_fountain() X { X int x ; X X if (rnd(100) < 11) X { X x=rnd((level<<2)+2); X lprintf("\nOh no! The water was foul! You suffer %d hit points!",(long)x); X lastnum=273; X losehp(x); X bottomline(); X cursors(); X } X X else if (rnd(100) < 29) X lprcat("\nYou got the dirt off!"); X X else if (rnd(100) < 31) X lprcat("\nThis water seems to be hard water! The dirt didn't come off!"); X X else if (rnd(100) < 34) X createmonster(WATERLORD); /* make water lord */ X X else X lprcat("\nnothing seems to have happened"); X X return; X } X X/* X Perform the act of climbing down the volcanic shaft. Assumes X cursors() has been called and that a check has been made that X are actually at a down shaft. X*/ Xact_down_shaft() X { X if (level!=0) X { X lprcat("\nThe shaft only extends 5 feet downward!"); X return; X } X X if (packweight() > 45+3*(c[STRENGTH]+c[STREXTRA])) X { X lprcat("\nYou slip and fall down the shaft"); X beep(); X lastnum=275; X losehp(30+rnd(20)); X bottomhp(); X } X else if (prompt_mode) X lprcat("climb down"); X X nap(3000); X newcavelevel(MAXLEVEL); X volshaft_climbed( OVOLUP ); X return; X } X X/* X Perform the action of climbing up the volcanic shaft. Assumes X cursors() has been called and that a check has been made that X are actually at an up shaft. X X*/ Xact_up_shaft() X { X if (level!=11) X { X lprcat("\nThe shaft only extends 8 feet upwards before you find a blockage!"); X return; X } X X if (packweight() > 45+5*(c[STRENGTH]+c[STREXTRA])) X { X lprcat("\nYou slip and fall down the shaft"); X beep(); X lastnum=275; X losehp(15+rnd(20)); X bottomhp(); X return; X } X X if (prompt_mode) X lprcat("climb up"); X lflush(); X nap(3000); X newcavelevel(0); X volshaft_climbed( OVOLDOWN ); X return; X } X X/* X Perform the action of placing the player near the volcanic shaft X after it has been climbed. X X Takes one parameter: the volcanic shaft object to be found. If have X climbed up, search for OVOLDOWN, otherwise search for OVOLUP. X*/ Xstatic volshaft_climbed(object) Xint object; X { X int i,j ; X X /* place player near the volcanic shaft */ X for (i=0; i 50) X { X act_prayer_heard(); X return; X } X else if (rnd(43) == 5) X { X if (c[WEAR]) X lprcat("You feel your armor vibrate for a moment"); X enchantarmor(); X return; X } X else if (rnd(43) == 8) X { X if (c[WIELD]) X lprcat("You feel your weapon vibrate for a moment"); X enchweapon(); X return; X } X else X lprcat("Thank You."); X bottomline(); X return ; X } X X/* X Performs the actions associated with 'just praying' at the altar. Called X when the user responds 'just pray' when in prompt mode, or enters 0 to X the money prompt when praying. X X Assumes cursors(), and that any leading \n have been printed (to get X around VMS echo mode problem. X*/ Xact_just_pray() X { X if (rnd(100)<75) X lprcat("nothing happens"); X else if (rnd(43) == 10) X { X if (c[WEAR]) X lprcat("You feel your armor vibrate for a moment"); X enchantarmor(); X return; X } X else if (rnd(43) == 10) X { X if (c[WIELD]) X lprcat("You feel your weapon vibrate for a moment"); X enchweapon(); X return; X } X else X createmonster(makemonst(level+1)); X return; X } X X/* X function to cast a +3 protection on the player X */ Xstatic act_prayer_heard() X { X lprcat("You have been heard!"); X if (c[ALTPRO]==0) X c[MOREDEFENSES]+=3; X c[ALTPRO] += 500; /* protection field */ X bottomline(); X } X X/* X Performs the act of ignoring an altar. X X Assumptions: cursors() has been called. X*/ Xact_ignore_altar() X { X if (rnd(100)<30) X { X createmonster(makemonst(level+1)); X c[AGGRAVATE] += rnd(450); X } X else X lprcat("\nNothing happens"); X return; X } X X/* X Performs the act of opening a chest. X X Parameters: x,y location of the chest to open. X Assumptions: cursors() has been called previously X*/ Xact_open_chest(x,y) Xint x,y ; X { X int i,k; X X k=rnd(101); X if (k<40) X { X lprcat("\nThe chest explodes as you open it"); beep(); X i = rnd(10); lastnum=281; /* in case he dies */ X lprintf("\nYou suffer %d hit points damage!",(long)i); X checkloss(i); X switch(rnd(10)) /* see if he gets a curse */ X { X case 1: c[ITCHING]+= rnd(1000)+100; X lprcat("\nYou feel an irritation spread over your skin!"); X beep(); X break; X X case 2: c[CLUMSINESS]+= rnd(1600)+200; X lprcat("\nYou begin to lose hand to eye coordination!"); X beep(); X break; X X case 3: c[HALFDAM]+= rnd(1600)+200; X beep(); X lprcat("\nA sickness engulfs you!"); break; X }; X item[x][y]=know[x][y]=0; /* destroy the chest */ X if (rnd(100)<69) creategem(); /* gems from the chest */ X dropgold(rnd(110*iarg[playerx][playery]+200)); X for (i=0; i3) c[STRENGTH]--; X bottomline(); break; X X default: break; X } X return( 0 ); X } X else X { X know[x][y]=0; X item[x][y]=OOPENDOOR; X return( 1 ); X } X } END_OF_FILE if test 13238 -ne `wc -c <'action.c'`; then echo shar: \"'action.c'\" unpacked with wrong size! fi # end of 'action.c' fi if test -f 'larn_hlp.uue' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'larn_hlp.uue'\" else echo shar: Extracting \"'larn_hlp.uue'\" \(11215 characters\) sed "s/^X//" >'larn_hlp.uue' <<'END_OF_FILE' Xbegin 644 larn.hlp XM-R`@("!796QC;VUE('1O('1H92!G86UE(&]F($QA2!E9F9E8W0N XM("!9;W4@2!T;R!S879E(&AE2X* XM4&5R:&%P65A2!M:7)A8W5L;W5S('-U8V-E XM6]U"!S=&%T=7,*:2`@:6YV96YT;W)Y('EO=7(@<&]C XM:V5T2!A="!A XM;B!A;'1A3"!R961R87<@=&AE('-C7!E("6]U6]U(&YE960@82!L:7-T(&]F XM('-P96QL6EN9R!F;W(@4')O9FET(&ES(%!R;VAI8FET960*0V]P>7)I9VAT(#$Y XM.#8@8GD@3F]A:"!-;W)G86XL($%L;"!2:6=H=',@4F5S97)V960N"@H*"B`@ XM("`@("`@("`@("`@("`@("`@("`@(!M;-VU,87)N($-O;6UA;F0@3&EN92!/ XM<'1I;VYS&UMM"@IL87)N("LK("`@("`@("`@("`@("`@("!R97-T;W)E(&-H XM96-K<&]I;G1E9"!G86UE"FQA2!O9B!T:&4@9V%M92`H;6%Y(&)E('5S960@ XM=VET:"`M;BD*;&%R;B`M;SQO<'1S9FEL93X@("`@("`@2!T:&4@ XM;W!T:6]N(&9I;&4@=&\@8F4@=7-E9`IL87)N("UC("`@("`@("`@("`@("`@ XM("!C6]U(&9A8V4@ XM82!G2!E9F9E8W0N("!9;W4@2!T XM;R!S879E(&AE2X*4&5R:&%P65A2!M:7)A8W5L;W5S('-U8V-E6]U6]U(&AA=F4@=&AA="!C;VUP=71E<@H@("`@96YA8FQE+6-H96-K<&]I XM;G1I;F<@("`@='5R;B!O;B!P97)I;V1I8R!C:&5C:W!O:6YT:6YG"B`@("!G XM7!A9"!F;W(@;6]V:6YG"B`@("!L87)N9&ER.B`@9&ER96-T;W)Y XM("`@("!T:&4@9&ER96-T;W)Y('1O('5S92!F;W(@;&%R;B!F:6QE6]U XM0IB92!U<"!T;R`S-"!C:&%R86-T97)S XM(&QO;F71H:6YG XM(&5N8VQO'!L86YA=&EO;B!O XM9B!T:&4@3&%R;B!S8V]R96)O87)D(&9A8VEL:71Y&UMM"@H@("`@3&%R;B!S XM=7!P;W)T65R("AB XM>2!U65R:60L('-E92!524130T]212!I;B!-86ME9FEL XM92D*:7,@86QL;W=E9"!O;F4@65R2!I65R(B!H87,@ XM82!S8V]R92!O9B`Q,C@P,#,@;VX@=&AE('-C;W)E8F]A2!O;B!T:&4@65R(&1I97,L('1H92!I;G9E XM;G1O'moreobj.c' <<'END_OF_FILE' X/* moreobj.c Larn is copyrighted 1986 by Noah Morgan. X X Routines in this file: X X oaltar() X othrone() X odeadthrone() X ochest() X ofountain() X fntchange() X fch() X drink_fountain() X wash_fountain() X enter() X remove_gems() X sit_on_throne() X kick_stairs() X up_stairs() X down_stairs() X open_something() X close_something() X desecrate_altar() X pray_at_altar() X*/ X#include "header.h" X X/* X subroutine to process an altar object X*/ Xoaltar() X { X unsigned long k; X X lprcat("\nDo you (p) pray (d) desecrate"); iopts(); X while (1) switch(ttgetch()) X { X case 'p': X lprcat(" pray\nDo you (m) give money or (j) just pray? "); X while (1) switch(ttgetch()) X { X case 'j': X lprcat("\n"); X act_just_pray(); X return; X X case 'm': X act_donation_pray(); X return; X X case '\33': X return; X }; X X case 'd': X lprcat(" desecrate"); X act_desecrate_altar(); X return; X X case 'i': X case '\33': X ignore(); X act_ignore_altar(); X return; X }; X } X X/* X subroutine to process a throne object X*/ Xothrone(arg) X int arg; X { X X lprcat("\nDo you (p) pry off jewels, (s) sit down"); iopts(); X while (1) X { X while (1) switch(ttgetch()) X { X case 'p': X lprcat(" pry off"); X act_remove_gems( arg ); X return; X X case 's': X lprcat(" sit down"); X act_sit_throne( arg ); X return; X X case 'i': X case '\33': ignore(); return; X }; X } X } X Xodeadthrone() X { X X lprcat("\nDo you (s) sit down"); iopts(); X while (1) X { X while (1) switch(ttgetch()) X { X case 's': X lprcat(" sit down"); X act_sit_throne(1); X return; X X case 'i': X case '\33': ignore(); return; X }; X } X } X X/* X subroutine to process a chest object X*/ Xochest() X { X lprcat("\nDo you (t) take it, (o) try to open it"); iopts(); X while (1) X { X switch(ttgetch()) X { X case 'o': X lprcat(" open it"); X act_open_chest( playerx, playery ); X return; X X case 't': X lprcat(" take"); X if (take(OCHEST,iarg[playerx][playery])==0) X item[playerx][playery]=know[playerx][playery]=0; X return; X X case 'i': X case '\33': ignore(); return; X }; X } X } X X/* X process a fountain object X*/ Xofountain() X { X cursors(); X lprcat("\nDo you (d) drink, (w) wash yourself"); iopts(); X while (1) switch(ttgetch()) X { X case 'd': X act_drink_fountain(); X return; X X case '\33': X case 'i': X ignore(); X return; X X case 'w': X act_wash_fountain(); X return; X } X } X X/* X a subroutine to raise or lower character levels X if x > 0 they are raised if x < 0 they are lowered X*/ Xfntchange(how) X int how; X { X register long j; X lprc('\n'); X switch(rnd(9)) X { X case 1: X lprcat("Your strength"); X fch(how,&c[STRENGTH]); break; X case 2: X lprcat("Your intelligence"); X fch(how,&c[INTELLIGENCE]); break; X case 3: X lprcat("Your wisdom"); X fch(how,&c[WISDOM]); break; X case 4: X lprcat("Your constitution"); X fch(how,&c[CONSTITUTION]); break; X case 5: X lprcat("Your dexterity"); X fch(how,&c[DEXTERITY]); break; X case 6: X lprcat("Your charm"); X fch(how,&c[CHARISMA]); break; X case 7: X j=rnd(level+1); X if (how < 0) X { X lprintf("You lose %d hit point",(long)j); X if (j>1) lprcat("s!"); else lprc('!'); X losemhp((int)j); X } X else X { lprintf("You gain %d hit point",(long)j); if (j>1) lprcat("s!"); else lprc('!'); raisemhp((int)j); } X bottomline(); break; X X case 8: j=rnd(level+1); X if (how > 0) X { X lprintf("You just gained %d spell",(long)j); raisemspells((int)j); X if (j>1) lprcat("s!"); else lprc('!'); X } X else X { X lprintf("You just lost %d spell",(long)j); losemspells((int)j); X if (j>1) lprcat("s!"); else lprc('!'); X } X bottomline(); break; X X case 9: j = 5*rnd((level+1)*(level+1)); X if (how < 0) X { X lprintf("You just lost %d experience point",(long)j); X if (j>1) lprcat("s!"); else lprc('!'); loseexperience((long)j); X } X else X { X lprintf("You just gained %d experience point",(long)j); X if (j>1) lprcat("s!"); else lprc('!'); raiseexperience((long)j); X } X break; X } X cursors(); X } X X/* X subroutine to process an up/down of a character attribute for ofountain X*/ Xstatic fch(how,x) X int how; X long *x; X { X if (how < 0) { lprcat(" went down by one!"); --(*x); } X else { lprcat(" went up by one!"); (*x)++; } X bottomline(); X } X X/* X For command mode. Perform drinking at a fountain. X*/ Xdrink_fountain() X { X cursors() ; X if (item[playerx][playery] == ODEADFOUNTAIN) X lprcat("\nThere is no water to drink!") ; X X else if (item[playerx][playery] != OFOUNTAIN) X lprcat("\nI see no fountain to drink from here!") ; X X else X act_drink_fountain(); X return; X } X X/* X For command mode. Perform washing (tidying up) at a fountain. X*/ Xwash_fountain() X { X cursors() ; X if (item[playerx][playery] == ODEADFOUNTAIN) X lprcat("\nThere is no water to wash in!") ; X X else if (item[playerx][playery] != OFOUNTAIN) X lprcat("\nI see no fountain to wash at here!") ; X X else X act_wash_fountain(); X return; X } X X/* X For command mode. Perform entering a building. X*/ Xenter() X { X cursors() ; X switch ( item[playerx][playery] ) X { X case OSCHOOL: X oschool(); X break ; X X case OBANK: X obank() ; X break ; X X case OBANK2: X obank2() ; X break ; X X case ODNDSTORE: X dndstore() ; X break ; X X case OENTRANCE: X newcavelevel( 1 ); X playerx = 33 ; X playery = MAXY - 2 ; X item[33][MAXY - 1] = know[33][MAXY - 1] = mitem[33][MAXY - 1] = 0 ; X draws( 0, MAXX, 0, MAXY ); X showcell(playerx, playery); /* to show around player */ X bot_linex() ; X break ; X X case OTRADEPOST: X otradepost(); X break; X X case OLRS: X olrs(); X break; X X case OHOME: X ohome(); X break; X X default : X lprcat("\nThere is no place to enter here!\n"); X break; X } X } X X/* X For command mode. Perform removal of gems from a jeweled throne. X*/ Xremove_gems ( ) X { X X cursors(); X if (item[playerx][playery] == ODEADTHRONE) X lprcat("\nThere are no gems to remove!"); X X else if (item[playerx][playery] == OTHRONE) X act_remove_gems(0); X X else if (item[playerx][playery] == OTHRONE2) X act_remove_gems(1); X X else X lprcat("\nI see no throne here to remove gems from!"); X return; X } X X/* X For command mode. Perform sitting on a throne. X*/ Xsit_on_throne( ) X { X X cursors(); X if (item[playerx][playery] == OTHRONE) X act_sit_throne(0); X X else if ((item[playerx][playery] == OTHRONE2) || X (item[playerx][playery] == ODEADTHRONE)) X act_sit_throne(1); X X else X lprcat("\nI see no throne to sit on here!"); X X return; X } X X/* X For command mode. Checks that the player is actually standing at a set X of stairs before letting him kick them. X*/ Xkick_stairs() X { X cursors(); X if (item[playerx][playery] != OSTAIRSUP && X item[playerx][playery] != OSTAIRSDOWN) X lprcat("\nI see no stairs to kick here!"); X X else X act_kick_stairs(); X } X X/* X For command mode. Checks that player is actually standing at a set up X up stairs or volcanic shaft. X*/ Xup_stairs() X { X cursors(); X if (item[playerx][playery] == OSTAIRSDOWN) X lprcat("\nThe stairs don't go up!"); X X else if (item[playerx][playery] == OVOLUP) X act_up_shaft(); X X else if (item[playerx][playery] != OSTAIRSUP) X lprcat("\nI see no way to go up here!"); X X else X act_up_stairs(); X } X X/* X For command mode. Checks that player is actually standing at a set of X down stairs or volcanic shaft. X*/ Xdown_stairs() X { X cursors(); X if (item[playerx][playery] == OSTAIRSUP) X lprcat("\nThe stairs don't go down!"); X X else if (item[playerx][playery] == OVOLDOWN) X act_down_shaft(); X X else if (item[playerx][playery] != OSTAIRSDOWN) X lprcat("\nI see no way to go down here!"); X X else X act_down_stairs(); X } X X/* X For command mode. Perform opening an object (door, chest). X*/ Xopen_something( ) X { X int x,y; /* direction to open */ X char tempc; /* result of prompting to open a chest */ X X cursors(); X /* check for confusion. X */ X if (c[CONFUSE]) X { X lprcat("You're too confused!"); X beep(); X return; X } X X /* check for player standing on a chest. If he is, prompt for and X let him open it. If player ESCs from prompt, quit the Open X command. X */ X if (item[playerx][playery] == OCHEST) X { X lprcat("There is a chest here. Open it?"); X if ((tempc = getyn()) == 'y') X { X act_open_chest( playerx, playery ); X return; X } X else if (tempc != 'n' ) X return; X } X X /* get direction of object to open. test 'openability' of object X indicated, call common command/prompt mode routines to actually open. X */ X dirsub( &x, &y ); X switch( item[x][y] ) X { X case OOPENDOOR: X lprcat("The door is already open!"); X beep(); X break; X X case OCHEST: X act_open_chest( x, y ); X break; X X case OCLOSEDDOOR: X act_open_door( x, y ); X break; X X default: X lprcat("You can't open that!"); X beep(); X break; X } X } X X/* X For command mode. Perform the action of closing something (door). X*/ Xclose_something() X { X int x,y; X X cursors(); X /* check for confusion. X */ X if (c[CONFUSE]) X { X lprcat("You're too confused!"); X beep(); X return; X } X X /* get direction of object to close. test 'closeability' of object X indicated. X */ X dirsub( &x, &y ); X switch( item[x][y] ) X { X case OCLOSEDDOOR: X lprcat("The door is already closed!"); X beep(); X break; X X case OOPENDOOR: X if (mitem[x][y]) X { X lprcat("Theres a monster in the way!"); X return; X } X item[x][y] = OCLOSEDDOOR; X know[x][y] = 0 ; X iarg[x][y] = 0 ; X break; X X default: X lprcat("You can't close that!"); X beep(); X break; X } X } X X/* X For command mode. Perform the act of descecrating an altar. X*/ Xdesecrate_altar() X { X cursors(); X if (item[playerx][playery] == OALTAR) X act_desecrate_altar(); X else X lprcat("\nI see no altar to desecrate here!"); X } X X/* X For command mode. Perform the act of praying at an altar. X*/ Xpray_at_altar() X { X extern char prayed ; X X cursors(); X if (item[playerx][playery] != OALTAR) X lprcat("\nI see no altar to pray at here!"); X else X act_donation_pray(); X prayed = 1 ; X } END_OF_FILE if test 12276 -ne `wc -c <'moreobj.c'`; then echo shar: \"'moreobj.c'\" unpacked with wrong size! fi # end of 'moreobj.c' fi if test -f 'regen.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'regen.c'\" else echo shar: Extracting \"'regen.c'\" \(3513 characters\) sed "s/^X//" >'regen.c' <<'END_OF_FILE' X/* regen.c Larn is copyrighted 1986 by Noah Morgan. */ X#include "header.h" X/* X ******* X REGEN() X ******* X regen() X X subroutine to regenerate player hp and spells X */ Xregen() X { X register int i,flag; X register long *d; X d = c; X#ifdef EXTRA X d[MOVESMADE]++; X#endif X if (d[TIMESTOP]) { if(--d[TIMESTOP]<=0) bottomline(); return; } /* for stop time spell */ X flag=0; X X if (d[STRENGTH]<3) { d[STRENGTH]=3; flag=1; } X if ((d[HASTESELF]==0) || ((d[HASTESELF] & 1) == 0)) X gtime++; X X if (d[HP] != d[HPMAX]) X if (d[REGENCOUNTER]-- <= 0) /* regenerate hit points */ X { X d[REGENCOUNTER] = 22 + (d[HARDGAME]<<1) - d[LEVEL]; X if ((d[HP] += d[REGEN]) > d[HPMAX]) d[HP] = d[HPMAX]; X bottomhp(); X } X X if (d[SPELLS] < d[SPELLMAX]) /* regenerate spells */ X if (d[ECOUNTER]-- <= 0) X { X d[ECOUNTER] = 100+4*(d[HARDGAME]-d[LEVEL]-d[ENERGY]); X d[SPELLS]++; bottomspell(); X } X X if (d[HERO]) if (--d[HERO]<=0) { for (i=0; i<6; i++) d[i] -= 10; flag=1; } X if (d[ALTPRO]) if (--d[ALTPRO]<=0) { d[MOREDEFENSES]-=3; flag=1; } X if (d[PROTECTIONTIME]) if (--d[PROTECTIONTIME]<=0) { d[MOREDEFENSES]-=2; flag=1; } X if (d[DEXCOUNT]) if (--d[DEXCOUNT]<=0) { d[DEXTERITY]-=3; flag=1; } X if (d[STRCOUNT]) if (--d[STRCOUNT]<=0) { d[STREXTRA]-=3; flag=1; } X if (d[BLINDCOUNT]) if (--d[BLINDCOUNT]<=0) { cursors(); lprcat("\nThe blindness lifts "); beep(); } X if (d[CONFUSE]) if (--d[CONFUSE]<=0) { cursors(); lprcat("\nYou regain your senses"); beep(); } X if (d[GIANTSTR]) if (--d[GIANTSTR]<=0) { d[STREXTRA] -= 20; flag=1; } X if (d[CHARMCOUNT]) if ((--d[CHARMCOUNT]) <= 0) flag=1; X if (d[INVISIBILITY]) if ((--d[INVISIBILITY]) <= 0) flag=1; X if (d[CANCELLATION]) if ((--d[CANCELLATION]) <= 0) flag=1; X if (d[WTW]) if ((--d[WTW]) <= 0) flag=1; X if (d[HASTESELF]) if ((--d[HASTESELF]) <= 0) flag=1; X if (d[AGGRAVATE]) --d[AGGRAVATE]; X if (d[SCAREMONST]) if ((--d[SCAREMONST]) <= 0) flag=1; X if (d[STEALTH]) if ((--d[STEALTH]) <= 0) flag=1; X if (d[AWARENESS]) --d[AWARENESS]; X if (d[HOLDMONST]) if ((--d[HOLDMONST]) <= 0) flag=1; X if (d[HASTEMONST]) --d[HASTEMONST]; X if (d[FIRERESISTANCE]) if ((--d[FIRERESISTANCE]) <= 0) flag=1; X if (d[GLOBE]) if (--d[GLOBE]<=0) { d[MOREDEFENSES]-=10; flag=1; } X if (d[SPIRITPRO]) if (--d[SPIRITPRO] <= 0) flag=1; X if (d[UNDEADPRO]) if (--d[UNDEADPRO] <= 0) flag=1; X if (d[HALFDAM]) if (--d[HALFDAM]<=0) { cursors(); lprcat("\nYou now feel better "); beep(); } X if (d[SEEINVISIBLE]) X if (--d[SEEINVISIBLE]<=0) X# ifdef DGK X { monstnamelist[INVISIBLESTALKER] = floorc; X if (!d[BLINDCOUNT]) { X cursors(); X lprcat("\nYou feel your vision return to normal"); X beep(); X } X } X# else X { monstnamelist[INVISIBLESTALKER] = ' '; X cursors(); lprcat("\nYou feel your vision return to normal"); beep(); } X# endif X if (d[ITCHING]) X { X if (d[ITCHING]>1) X if ((d[WEAR]!= -1) || (d[SHIELD]!= -1)) X if (rnd(100)<50) X { X d[WEAR]=d[SHIELD]= -1; cursors(); X lprcat("\nThe hysteria of itching forces you to remove your armor!"); X beep(); recalc(); bottomline(); X } X if (--d[ITCHING]<=0) { cursors(); lprcat("\nYou now feel the irritation subside!"); beep(); } X } X if (d[CLUMSINESS]) X { X if (d[WIELD] != -1) X if (d[CLUMSINESS]>1) X if (item[playerx][playery]==0) /* only if nothing there */ X if (rnd(100)<33) /* drop your weapon due to clumsiness */ X drop_object((int)d[WIELD]); X if (--d[CLUMSINESS]<=0) { cursors(); lprcat("\nYou now feel less awkward!"); beep(); } X } X if (flag) bottomline(); X } X END_OF_FILE if test 3513 -ne `wc -c <'regen.c'`; then echo shar: \"'regen.c'\" unpacked with wrong size! fi # end of 'regen.c' fi if test -f 'tgetent.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'tgetent.c'\" else echo shar: Extracting \"'tgetent.c'\" \(9420 characters\) sed "s/^X//" >'tgetent.c' <<'END_OF_FILE' X/************************************************************************ X * * X * Copyright (c) 1982, Fred Fish * X * All Rights Reserved * X * * X * This software and/or documentation is released for public * X * distribution for personal, non-commercial use only. * X * Limited rights to use, modify, and redistribute are hereby * X * granted for non-commercial purposes, provided that all * X * copyright notices remain intact and all changes are clearly * X * documented. The author makes no warranty of any kind with * X * respect to this product and explicitly disclaims any implied * X * warranties of merchantability or fitness for any particular * X * purpose. * X * * X ************************************************************************ X */ X X/* X * LIBRARY FUNCTION X * X * tgetent load buffer with entry for specified terminal X * X * KEY WORDS X * X * termcap functions X * utility routines X * X * SYNOPSIS X * X * int tgetent(bp,name) X * char *bp; X * char *name; X * X * DESCRIPTION X * X * Extracts the entry for terminal from the termcap file X * and places it in the character buffer . It is currently X * assumed that bp is at least 1024 characters. If the entry in X * the termcap file is larger than 1023 characters the excess X * characters will be discarded and appropriate status will X * be returned. X * X * Also note that since bp is used by other termcap X * routines, the storage associated with the termcap entry X * cannot be freed until all termcap calls are completed. X * X * Tgetent can be directed to look in a file other than X * the default (/etc/termcap) by defining an environment X * variable called TERMCAP to be the pathname of the desired X * termcap file. This is useful for debugging new entries. X#ifndef VMS X * NOTE: the pathname MUST begin with a '/' character. X * X * Also, if the string assigned to TERMCAP does not begin with X * a '/' and if the environment variable TERM matches then X * the string assigned to TERMCAP is copied to buffer X * instead of reading a termcap file. X#endif X * X * If the termcap entry contains a "tc" string then the termcap X * entry named in the string is appended to the buffer (minus the X * names). X * X * RETURNS X * X * -1 if the termcap file cannot be opened X * 0 if no entry in termcap file matches X * 1 if extraction is successful with no errors X * 2 if extraction is successful but entry truncated X * X * SEE ALSO X * X * tgetnum extract numeric type capability X * tgetflag test boolean type capability X * tgetstr get string value of capability X * X * AUTHOR X * X * Fred Fish X * X */ X X#include X X#define TRUE 1 X#define FALSE 0 X#define BUFSIZE 1024 /* Assumed size of external buffer */ X X#define NO_FILE -1 /* Returned if can't open file */ X#define NO_ENTRY 0 /* Returned if can't find entry */ X#define SUCCESS 1 /* Returned if entry found ok */ X#define TRUNCATED 2 /* Returned if entry found but trunc */ X X#ifdef DGK_MSDOS XFILE *fopenp(); X#endif X X#define DEFAULT_ROOT "termcap" /* name without path component */ X#ifdef VMS X#define DEFAULT_FILE "sys$library:termcap" X#else X#define DEFAULT_FILE "/etc/termcap" /* default termcap filename */ X#endif VMS X Xchar *_tcpbuf; /* Place to remember buffer pointer */ X X/* X * PSEUDO CODE X * X * Begin tgetent X * Erase any previous buffer contents. X * Remember the buffer pointer. X * If termcap file is not found then X * If buffer was filled anyway then X * Return SUCCESS. X * Else X * Return NO_FILE. X * End if X * Else X * While records left to process X * If this is entry is what we want then X * Close the termcap file. X * If entry was truncated then X * Return TRUNCATED status X * Else X * Return SUCCESS status. X * End if X * End if X * End while X * Return NO_ENTRY status. X * End if X * End tgetent X * X */ X Xint tgetent(bp,name) Xchar *bp; /* Pointer to buffer (1024 char min) */ Xchar *name; /* Pointer to terminal entry to find */ X{ X FILE *fp, *find_file(); X char *nbp, tc[80]; X X *bp = (char)NULL; X _tcpbuf = bp; X if ((fp = find_file(bp)) == NULL) { X if (*bp != NULL) { X return(SUCCESS); X } else { X return(NO_FILE); X } X } else { X while (fgetlr(bp,BUFSIZE,fp)) { X if (gotcha(bp,name)) { X fclose(fp); X nbp = &bp[strlen(bp)-1]; X if (*nbp != '\n') { X return(TRUNCATED); X } else { X /* check for a recursive call (i.e. :tc=vt100:) X * added 18-dec-86 RDE (single recursion...) X */ X char *area; X area = &tc[0]; X if (tgetstr("tc", &area) == NULL) X return(SUCCESS); X else { X fp = find_file(0); /* know it works and is file */ X while (fgetlr(nbp, BUFSIZE-(nbp-bp), fp)) { X if (gotcha(nbp,tc)) { X char *cp1, *cp2; /* scrunch out names */ X fclose(fp); X cp1 = nbp; X while (*cp1++ != ':') /* search for first */ X ; X cp2 = nbp; X while (*cp2++ = *cp1++) /* move the chars. */ X ; X if (bp[strlen(bp)-1] != '\n') { X return(TRUNCATED); X } else { X return(SUCCESS); X } X } X } X return (NO_ENTRY); X } X } X } X } X return(NO_ENTRY); X } X} X X/* X * INTERNAL FUNCTION X * X * find_file find the termcap file and open it if possible X * X * KEY WORDS X * X * internal functions X * find_file X * X * SYNOPSIS X * X * static FILE *find_file(bp) X * char *bp; X * X * DESCRIPTION X * X * Attempts to locate and open the termcap file. Also handles X * using the environment TERMCAP string as the actual buffer X * (that's why bp has to be an input parameter). X * X#ifdef VMS X * If TERMCAP is defined as a valid filespec then it will be X * opened. If this fails then the default termcap file will X * be used. X#else X * If TERMCAP is defined an begins with a '/' character then X * it is taken to be the pathname of the termcap file and X * an attempt is made to open it. If this fails then X * the default termcap file is used instead. X * X * If TERMCAP is defined but does not begin with a '/' then X * it is assumed to be the actual buffer contents provided X * that matches the environment variable TERM. X#endif X * X * BUGS X * X * There is currently no way to be sure which termcap X * file was opened since the default will always be X * tried. X * X */ X X/* X * PSEUDO CODE X * X * Begin find_file X * If there is a TERMCAP environment string then X * If the string is not null then X * If the string is a pathname then X * If that file is opened successfully then X * Return its pointer. X * End if X * Else X * If there is a TERM environment string then X * If TERM matches then X * Copy TERMCAP string to buffer. X * Return NULL for no file. X * End if X * End if X * End if X * End if X * End if X * Open default termcap file and return results. X * End find_file X * X */ X Xstatic FILE *find_file(bp) Xchar *bp; X{ X FILE *fp, *fopen(); X char *cp, *ncp, *getenv(); X X if ((cp = getenv("TERMCAP")) != NULL) { X if (*cp != NULL) { X#ifdef VMS X if ((fp = fopen(cp, "r")) != NULL) X return(fp); X#else X if (*cp == '/' || *cp == '\\') { X if ((fp = fopen(cp,"r")) != NULL) { X return(fp); X } X } else { X if ((ncp = getenv("TERM")) != NULL) { X if (strcmp(cp,ncp) == 0) { X strcpy(bp,cp); X return((FILE *)NULL); X } X } X } X#endif X } X } X /* X * Try current directory, then /etc/termcap X */ X if (fp = fopen(DEFAULT_ROOT, "r")) X return fp; X else X#ifdef DGK_MSDOS X if (fp = fopen(DEFAULT_FILE, "r") ) X return fp; X else /* try along the PATH */ X return( fopenp(DEFAULT_ROOT, "r", NULL)); X#else X return (fopen(DEFAULT_FILE, "r")); X#endif X} X X X/* X * INTERNAL FUNCTION X * X * gotcha test to see if entry is for specified terminal X * X * SYNOPSIS X * X * gotcha(bp,name) X * char *bp; X * char *name; X * X * DESCRIPTION X * X * Tests to see if the entry in buffer bp matches the terminal X * specified by name. Returns TRUE if match is detected, FALSE X * otherwise. X * X */ X X/* X * PSEUDO CODE X * X * Begin gotcha X * If buffer character is comment character then X * Return FALSE since remainder is comment X * Else X * Initialize name scan pointer. X * Compare name and buffer until end or mismatch. X * If valid terminators for both name and buffer strings X * Return TRUE since a match was found. X * Else X * Find next non-name character in buffer. X * If not an alternate name separater character X * Return FALSE since no more names to check. X * Else X * Test next name and return results. X * End if X * End if X * End if X * End gotcha X * X */ X Xgotcha(bp,name) Xchar *bp; Xchar *name; X{ X char *np; X X if (*bp == '#') { X return(FALSE); X } else { X np = name; X while (*np == *bp && *np != NULL) {np++; bp++;} X if (*np == NULL && (*bp == NULL || *bp == '|' || *bp == ':')) { X return(TRUE); X } else { X while (*bp != NULL && *bp != ':' && *bp != '|') {bp++;} X if (*bp != '|') { X return(FALSE); X } else { X return(gotcha(++bp,name)); X } X } X } X} X X#ifdef MSDOS X/* X * index(buffer, char) X * Find character in buffer. Return the pointer X * to it. Shouldn't be necessary to write this X * myself but VMS didn't. Oh Well... X * Used by lots of files in the termcap library. X * Rich Ellison, 16-DEC-1986 X */ Xchar X*index(buf, ch) Xchar *buf; Xchar ch; X{ X register int c; X while ((c= *buf++) != '\0') X if (c == ch) X return (buf-1); X return (NULL); X} X#endif END_OF_FILE if test 9420 -ne `wc -c <'tgetent.c'`; then echo shar: \"'tgetent.c'\" unpacked with wrong size! fi # end of 'tgetent.c' fi echo shar: End of archive 9 \(of 11\). cp /dev/null ark9isdone MISSING="" for I in 1 2 3 4 5 6 7 8 9 10 11 ; do if test ! -f ark${I}isdone ; then MISSING="${MISSING} ${I}" fi done if test "${MISSING}" = "" ; then echo You have unpacked all 11 archives. rm -f ark[1-9]isdone ark[1-9][0-9]isdone else echo You still need to unpack the following archives: echo " " ${MISSING} fi ## End of shell archive. exit 0