-+-+-+-+-+-+-+-+ START OF PART 3 -+-+-+-+-+-+-+-+ X prt_in_disp(dsp_create,"Add 1 point to which attribute? ",10,1); X smg$read_keystroke(&cboard,&add); X switch( (char)add) `7B X `09case 'a': make_choice( "a) STR",++STR,3,dsp_create); break; X `09case 'b': make_choice( "b) INT",++INT,4,dsp_create); break; X case 'c': make_choice( "c) DEX",++DEX,5,dsp_create); break; X`09case 'd': make_choice( "d) CON",++CON,6,dsp_create); break; X`09default : prt_in_disp(dsp_create,"Value out of range. ",1 V0,1); X`09`09 sleep( 1); X`09`09 changes++; X/* `09`09 changes = add_points( changes, dsp_create, cboard); */ X `7D`20 Xreturn( --changes); X`7D X Xprt_difficulty(board) Xint board; X`7B Xprt_in_disp(board,"Select difficulty level",1,5); Xprt_in_disp(board,"-----------------------",2,5); Xprt_in_disp(board,"1) Slow",3,1); Xprt_in_disp(board,"2) Fast",4,1); Xprt_in_disp(board,"3) Look out (very fast)",5,1); Xprt_in_disp(board,"4) 1200 baud rate",6,1); Xprt_in_disp(board,"5) Normal (default)",7,1); X`7D X X Xshort create_character() X`7B Xint cpb, cboard, dsp_create; Xint changes, diff_num; Xshort ret = 0; Xchar left`5B20`5D; X XSTR = INT = DEX = CON = 11; Xchanges = 16;`09`09`09/* how many changes player gets to make */ X X/* put choices up on the screen and read keystrokes to change stats */ Xsmg$create_pasteboard(&cpb); Xsmg$create_virtual_keyboard(&cboard); Xsmg$set_cursor_mode(&cpb,&SMG$M_SCROLL_JUMP); Xsmg$create_virtual_display(&10,&32,&dsp_create,&SMG$M_BORDER); Xsmg$paste_virtual_display(&dsp_create,&cpb,&6,&25); Xprt_difficulty(dsp_create); Xsmg$read_keystroke(&cboard,&diff_num); Xswitch( (char)diff_num) `7B`09/* Note: these values are VERY touchy */ X case '1': DIFFICULTY = 0.2; break; X case '2': DIFFICULTY = 0.05; break; X case '3': DIFFICULTY = 0.01; break; X case '4': DIFFICULTY = 0.40; break; X default: DIFFICULTY = 0.1; X`7D Xsmg$erase_display(&dsp_create); Xprt_in_disp(dsp_create,"Attributes",1,12); Xprt_in_disp(dsp_create,"------------",2,11); Xmake_choice( "a) STR",STR,3,dsp_create); Xmake_choice( "b) INT",INT,4,dsp_create); Xmake_choice( "c) DEX",DEX,5,dsp_create); Xmake_choice( "d) CON",CON,6,dsp_create); Xsprintf(left,"Points left: %2d",changes); Xprt_in_disp(dsp_create,left,7,1); Xwhile( (changes = add_points( changes, dsp_create, cboard)) > 0) `7B X sprintf(left,"Points left: %2d",changes); X prt_in_disp(dsp_create,left,7,1); X`7D /* End while */ X X/* All done, get rid of initial created boards and windows */ Xsmg$delete_virtual_keyboard(&cboard); Xsmg$delete_virtual_display(&dsp_create); Xsmg$delete_pasteboard(&cpb); X X/* initialize player before beginning game */ Xunderchar = SPACE; Xspeed = level = 1; XMAXHEALTH = health = ((CON+level)*8); Xkills = delx = dely = monkilled = 0; XCURWEIGHT = 0; XMAXWEIGHT = (STR*20); XBUSE = 0; XALTWEAP = WORN = WIELD = 0; X Xreturn( ret); X`7D $ CALL UNPACK CREATE.C;1 542668451 $ create 'f' X#include stdio X#include "aralu.h" X X Xexplode( y, x, object, number, dir) Xint y, x, number; Xchar object, dir; X`7B Xint i, j, damage, monnum; Xint lexdist, rexdist, uexdist, dexdist; Xchar map_char; Xchar item_killer`5B20`5D; X Xlexdist = rexdist = uexdist = dexdist = 2; Xswitch( dir) `7B X case UP: dexdist = 0; break; X case DOWN: uexdist = 0; break; X case LEFT: lexdist = 0; break; X case RIGHT: rexdist = 0; break; X default: break; X`7D /* End switch */ X Xsmg$begin_pasteboard_update(&pb); Xfor( i = y-dexdist; i <= y+uexdist; i++) X if ( i > 0 && i < MAXROWS)`20 X for( j = x-lexdist; j <= x+rexdist; j++) `7B X if ( j > 0 && j < MAXCOLS) `7B X if ( obstacle( map`5Bi`5D`5Bj`5D.mapchar)) `7B X if ( isamonster( map`5Bi`5D`5Bj`5D.mapchar)) `7B X monnum = map`5Bi`5D`5Bj`5D.number;`20 X`09 if ( ping_monster( j, i, monnum)) return; X if ( object == 'b' `7C`7C object == 'c' )`20 X`09 do_attack( monnum, 99, object, dir); X else /* Multiple mines */ X`09 while( number-- >0 && !monsters`5Bmonnum`5D.dead) X `09 do_attack( monnum, 88, MINE, dir); X `7D X else if ( map`5Bi`5D`5Bj`5D.mapchar == '@') `7B X if ( object == 'b' `7C`7C object == 'c')`20 X strcpy( item_killer, spells`5Bobject-MAGIC_NUMBER`5D); X else strcpy( item_killer, object_names`5Bget_name( object)`5D); X damage = number*(5*(2+1) - 2*abs(y-i) - 2*abs(x-j)); X`09 prt_msg("You are enveloped in the ball!"); X take_damage( damage, item_killer); X `7D X prt_char( map`5Bi`5D`5Bj`5D.mapchar, i, j); X `7D X else X prt_char( '*', i, j); X `7D X `7D /* End FOR2 */ Xsmg$end_pasteboard_update(&pb); X X/* clean up the mess */ X/* don't have to print out obstacles, since we didn't write over them */ Xfor( i = y-dexdist; i <= y+uexdist; i++) X if ( i > 0 && i < MAXROWS) X for( j = x-lexdist; j <= x+rexdist; j++) X if ( j > 0 && j < MAXCOLS) X if ( !obstacle( map`5Bi`5D`5Bj`5D.mapchar)) prt_char( SPACE, i, j); X`7D $ CALL UNPACK EXPLODE.C;1 1833585176 $ create 'f' X#include stdio X#include descrip X#include smgdef X#include "aralu.h" X X Xchar *helptext`5B`5D = `7B X" A R A L U ", X" - - - - - - - - -", X" Aralu is a game based on real time in which the player tries to maneuver" V, X"throughout the realm obtaining weapons, armor, health, magic items, etc. to V", X"help kill the monsters in the realm. Experience is given for each monster" V, X"killed and as you gain levels, the monsters get more numerous and more", X"difficult to kill. The object of the game is to kill all the monsters on t Vhe", X"current level and then find the key to the exits to the next level.", X" ", X" Commands in the game are given by single keystrokes and are as follows:", X" u - use magic orb r - read scroll`09`09", X" b - check backpack t - show time ", X" c - center window w - wear/wield item ", X" d - drop item Q - quit and save game ", X" v - look any direction `5EZ - abort game/no save ", X" i,j,k,l - move up,down,left,right `5EL - redraw screen ", X" `5EB - reset priority SPACE - fire arrow`09`09", X" q - quaff potion s - show status`09`09", X" x - exchange primary weapon h - heal wounds`09`09", X" e - exit level or enter store S - change speed of game", XNULL /* End help listing */ X`7D; X Xchar *ophelp`5B`5D = `7B X" Commands for Operators only:", X" ", X" `5EP - create object (enter character to create)", X" `5EM - show monster locations and stats in (x,y)", X" `5ED - delete wall or object (enter direction)", X" `5EH - heal self to maxhealth", X" `5EN - toggle stop/start all monsters from moving", X" `5EK - kill all monsters on level (enter letter of monster to kill)" V, X" `5EE - set stats to desired values", X" `5EG - go to level 'n'", X" ", X" Please note: Game will not be scored if any of the above commands are ", X" entered, and it really reduces the challenge and fun of the" V, X" game, so try not to use these commands often.", X" Remember, a true test of how good a player is is not how wel Vl", X" he knows the Op commands, but how little he uses them.", XNULL /* End of OP help listing */ X`7D; X X X Xhelp() X`7B Xint i; Xchar dummy; X$DESCRIPTOR( help_d, helptext); X$DESCRIPTOR( ophelp_d, ophelp); X$DESCRIPTOR( return_d, "Press any key to return to game"); X$DESCRIPTOR( opreturn_d, "Press any key to continue list"); X Xi = 0; Xsmg$paste_virtual_display(&dsp_help,&pb,&2,&2); X while( helptext`5Bi`5D != NULL) `7B X`09help_d.dsc$w_length = strlen( helptext`5Bi`5D); X`09help_d.dsc$a_pointer = helptext`5Bi++`5D; X `09smg$put_line(&dsp_help,&help_d,0,0,0,0); X `7D Xif (operator) `7B Xsmg$put_chars(&dsp_help,&opreturn_d,&21,&23,&SMG$M_ERASE_LINE,&SMG$M_REVERSE V); Xsmg$read_keystroke(&kboard,&dummy); Xsmg$erase_display(&dsp_help); Xi = 0; X while( ophelp`5Bi`5D != NULL) `7B X`09ophelp_d.dsc$w_length = strlen( ophelp`5Bi`5D); X`09ophelp_d.dsc$a_pointer = ophelp`5Bi++`5D; X `09smg$put_line(&dsp_help,&ophelp_d,0,0,0,0); X `7D X`7D Xsmg$put_chars(&dsp_help,&return_d,&21,&23,&SMG$M_ERASE_LINE,&SMG$M_REVERSE); Xsmg$read_keystroke(&kboard,&dummy); Xsmg$erase_display(&dsp_help); Xsmg$unpaste_virtual_display(&dsp_help,&pb); X`7D $ CALL UNPACK HELP.C;1 318971696 $ create 'f' Xcc = cc Xlink = link X X#cc = cc/debug/noopt X#link = link/traceback/debug X Xall : aralu.exe X Xaralu.exe: aralu.obj play2.obj save.obj score.obj monsters.obj create.obj pl Vay.obj wizard.obj explode.obj windows.obj help.obj X`09write sys$output "Linking." X`09$(link) aralu,save,play,play2,score,windows,explode,create,monsters,wizar Vd,help,o/opt X write sys$output "Done." X Xaralu.obj: aralu.c aralu.h`20 X`09write sys$output "Aralu.c" X`09$(cc) aralu X Xcreate.obj: create.c aralu.h X`09write sys$output "Create.c" X`09$(cc) create X Xexplode.obj: explode.c aralu.h X`09write sys$output "Explode.c" X`09$(cc) explode X Xhelp.obj: help.c aralu.h X`09write sys$output "Help.c" X`09$(cc) help X Xmonsters.obj: monsters.c aralu.h X`09write sys$output "Monsters.c" X`09$(cc) monsters X Xplay.obj: play.c aralu.h X`09write sys$output "Play.c" X`09$(cc) play X Xplay2.obj: play2.c aralu.h X`09write sys$output "Play2.c" X`09$(cc) play2 X Xsave.obj: save.c aralu.h X`09write sys$output "Save.c" X`09$(cc) save X Xscore.obj: score.c aralu.h X`09write sys$output "Score.c" X`09$(cc) score X Xwindows.obj: windows.c aralu.h X`09write sys$output "Windows.c" X`09$(cc) windows X Xwizard.obj: wizard.c aralu.h`20 X`09write sys$output "Wizard.c" X`09$(cc) wizard $ CALL UNPACK MAKEFILE.;1 157683714 $ create 'f' X#include stdio X#include descrip X#include ctype X#include "aralu.h" X Xint eat( object)`20 Xchar object; X`7B Xswitch( object) `7B X case WALL: X case DOOR: X case STORE: X case BONES: X case ARENA: X case KEY: X case BRIDGE: X case BRIDGE2: X case PIT: X case WATER: return( FALSE); X`7D Xreturn( TRUE); X`7D X `20 X Xchar get_move( dir, i, newx, newy) Xint dir, i, *newx, *newy; X`7B Xint dx, dy; X Xmonsters_struct *mon_ptr; Xmon_ptr = &monsters`5Bi`5D; X X switch( dir) `7B X`09case NORTH: dx = 0; dy = -1; break; X`09case SOUTH: dx = 0; dy = 1; break; X`09case WEST: dx = -1; dy = 0; break; X`09case EAST: dx = 1; dy = 0; break; X`09default: printf("Error finding direction.\n"); exit(1); /* Impossible */ X `7D /* End switch */ X X if ( (random( 100) < mon_ptr->follow) `7C`7C flags`5BMON_CONFUSE`5D.valid V) `7B`20 X if ( random(4) < 2) dx = -dx;`20 X else dy = -dy;`20 X `7D `09`09`09`09/* if monsters are confused or their follow */ X`09`09`09`09/* is poor, make them go the wrong way */ X`09`09`09`09/* if monsters are hurting, they run away`20 X`09`09`09`09 and hide -- flying monsters can't run */ X if ( mon_ptr->health < .25*3*(i+5) && !mon_ptr->fly) `7B dx = -dx; dy = -d Vy; `7D`20 X X *newy = mon_ptr->posy + dy; X *newx = mon_ptr->posx + dx; X return( map`5B*newy`5D`5B*newx`5D.mapchar); X`7D X X X Xmove_monsters( i)`09`09/* move the monster 'i' toward the player */ Xint i; X`7B X/* For tdir`5B5`5D, 0 = primary direction; 1 = alternate direction, X `09 2 = monster's current direcion, 3 = -primary, 4 = -alternate * V/ Xint movedir, testdir`5B5`5D, newy, newx, firex, firey, ax, ay, moveoff, hlsp Veed; Xint m_spell, fdr; Xint distance = 0; Xint k = 1; Xchar direction, testchar, firechar; Xchar fire_msg`5B80`5D; Xchar mon_heal`5B80`5D; Xchar dropped`5B80`5D; X Xmonsters_struct *mon_ptr; Xmon_ptr = &monsters`5Bi`5D; X X/* First see if the monster can fire -- is it in line with the player and if X the fire percentage is high enough */ Xif ( (mon_ptr->posy == ppos.y `7C`7C mon_ptr->posx == ppos.x) && X random( 100) < mon_ptr->firec) `7B X if ( mon_ptr->posy == ppos.y) `7B`20 X if ( ppos.x < mon_ptr->posx)`20 X `7B firey = 0; firex = -1; firechar = '-'; fdr = LEFT;`7D X else `7B firey = 0; firex = 1; firechar = '-'; fdr = RIGHT;`7D X `7D X else if ( mon_ptr->posx == ppos.x) `7B`20 X if ( ppos.y < mon_ptr->posy)`20 X `7B firex = 0; firey = -1; firechar = '`7C'; fdr = UP;`7D X else `7B firex = 0; firey = 1; firechar = '`7C'; fdr = DOWN;`7D X `7D X else printf("Error moving monster #%d.\n", i); /* should never happen */ X ax = mon_ptr->posx+firex; ay = mon_ptr->posy+firey; X /* Check to see if the monster casts a spell -- 15% chance */ X if ( mon_ptr->magic && random(100) < 15) `7B X firechar = '*'; X m_spell = random( 2)+2; X sprintf( fire_msg,"%s summons a %s!", X`09 `09`09 mon_names`5Bmon_ptr->n_num`5D, spells`5Bm_spell-1`5D); X prt_msg( fire_msg); X mon_ptr->health -= 3; X `7D X X while( map`5Bay`5D`5Bax`5D.mapchar != WALL && (++distance < ARROWDIST) & V& X map`5Bay`5D`5Bax`5D.mapchar != '@' && !isamonster(map`5Bay`5D`5Bax` V5D.mapchar)) `7B X prt_char( firechar, ay, ax); X prt_char( map`5Bay`5D`5Bax`5D.mapchar, ay, ax); X ax = ax + firex; ay = ay + firey; X `7D /* End while */ X if ( map`5Bay`5D`5Bax`5D.mapchar == '@') `7B X if ( firechar != '*') monster_attack( i, ARROW); X else explode( ay, ax, m_spell+MAGIC_NUMBER, 1, fdr);`20 X `7D X else if ( isamonster( map`5Bay`5D`5Bax`5D.mapchar)) `7B X if ( firechar != '*') do_attack( map`5Bay`5D`5Bax`5D.number, 999, NULL, V fdr); X else explode( ay, ax, m_spell+MAGIC_NUMBER, 1, fdr); X `7D X else if ( distance != ARROWDIST && map`5Bay`5D`5Bax`5D.mapchar != WALL)`20 X prt_msg("Error in monster firing."); X`7D Xelse `7B`09`09`09`09`09`09/* can't fire anything */ X X/* first see if monster is close enough to the player to move */ Xif ( abs(ppos.y - mon_ptr->posy) < mon_ptr->range/2 && X abs(ppos.x - mon_ptr->posx) < mon_ptr->range) `7B X if ( abs(mon_ptr->posx - ppos.x) > abs(mon_ptr->posy - ppos.y)) `7B X if ( mon_ptr->posx > ppos.x) testdir`5B0`5D = WEST; X else testdir`5B0`5D = EAST; X if ( mon_ptr->posy > ppos.y) testdir`5B1`5D = NORTH; X else testdir`5B1`5D = SOUTH; X/* contiue moving the monster in the same direction (not back and forth) */ +-+-+-+-+-+-+-+- END OF PART 3 +-+-+-+-+-+-+-+-