games-request@tekred.TEK.COM (01/21/88)
Submitted by: "Laurence R. Brothers" <brothers@paul.rutgers.edu> Comp.sources.games: Volume 3, Issue 57 Archive-name: omega/Part10 #! /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 <file", e.g.. If this archive is complete, you # will see the following message at the end: # "End of archive 10 (of 15)." # Contents: ochar.c ocity.c ocommands.txt omon.c # Wrapped by billr@tekred on Mon Jan 18 10:20:37 1988 PATH=/bin:/usr/bin:/usr/ucb ; export PATH if test -f ochar.c -a "${1}" != "-c" ; then echo shar: Will not over-write existing file \"ochar.c\" else echo shar: Extracting \"ochar.c\" \(8842 characters\) sed "s/^X//" >ochar.c <<'END_OF_ochar.c' X/* omega copyright (C) by Laurence Raphael Brothers, 1987 */ X/* ochar.c */ X/* Player generation */ X X#include <stdio.h> X#include <strings.h> X#include "oglob.h" X X/* from oscr */ Xextern void printm(),mprint(),displaystats(),menuclear(),menuprint(),xredraw(); Xextern void menuaddch(); Xextern char mgetc(),*msgscanstring(),menugetc(); X X/* from oaux */ Xextern void calc_melee(),optionset(); X X/* from ocom */ Xextern void setoptions(); X X/* ochar functions */ Xvoid initplayer(),initstats(),changestat(),save_omegarc(); Xint calcmana(),fixnpc(),competence_check(); XFILE *omegarc_check(); X X/* ofile functions */ Xvoid filescanstring(); X X/* olev functions */ Xextern void write_int(); Xextern int read_int(); X X/* set player to begin with */ Xvoid initplayer() X{ X int i; X char option; X int oldchar=FALSE; X FILE *fd; X X Player.x = -1; X Player.y = -1; X Player.str = Player.maxstr = 13; X Player.con = Player.maxcon = 13; X Player.dex = Player.maxdex = 13; X Player.agi = Player.maxagi = 13; X Player.iq = Player.maxiq = 13; X Player.pow = Player.maxpow = 13; X Player.defense = 0; X Player.absorption = 0; X Player.vision = 1; X Player.itemweight = 0; X Player.armor = NULL; X Player.primary = NULL; X Player.secondary = NULL; X Player.cloak = NULL; X Player.boots = NULL; X Player.numrings = 0; X Player.food = 19; X Player.options = 0; X for (i=0;i<MAXITEMS;i++) Player.possessions[i] = NULL; X for (i=0;i<NUMIMMUNITIES;i++) Player.immunity[i] = 0; X for (i=0;i<NUMSTATI;i++) Player.status[i] = 0; X for (i=0;i<NUMRANKS;i++) Player.rank[i] = 0; X Player.alignment = 0; X if ((fd=omegarc_check())!=NULL) { X oldchar = TRUE; X filescanstring(fd,Player.name); X Player.options=read_int(fd); X Searchnum=read_int(fd); X Player.str=read_int(fd); X Player.con=read_int(fd); X Player.dex=read_int(fd); X Player.agi=read_int(fd); X Player.iq=read_int(fd); X Player.pow=read_int(fd); X Player.preference = getc(fd); X fclose(fd); X Player.maxstr = Player.str; X Player.maxcon = Player.con; X Player.maxdex = Player.dex; X Player.maxagi = Player.agi; X Player.maxiq = Player.iq; X Player.maxpow = Player.pow; X if (Searchnum > 9) Searchnum = 9; X else if (Searchnum < 1) Searchnum = 1; X if (Player.str+Player.con+Player.dex+ X Player.agi+Player.iq+Player.pow > 78) { X mprint("Stats too high! You can't fool me, un-huh, un-huh, un-huh..."); X oldchar = FALSE; X } X } X if (! oldchar) { X initstats(); X optionset(ASKME); X optionset(RUNSTOP); X optionset(CONFIRM); X } X Player.hp = Player.maxhp = Player.maxcon; X Player.cash = 250; X calc_melee(); X Player.mana = Player.maxmana = calcmana(); X Player.click = 1; X dataprint(); X } X X XFILE *omegarc_check() X{ X FILE *fd; X strcpy(Str3,".omegarc"); X if ((fd = fopen(Str3,"r")) != NULL) { X mprint("Use .omegarc in wd? [yn]"); X if (ynq()!='y') fd = NULL; X } X return(fd); X} X Xvoid initstats() X{ X int done = FALSE; X int statpoints = 0; X X mprint("*********Character Generation Module*********"); X X menuclear(); X menuprint("\n\nExpend points on statistics\n\n"); X menuprint("s: lower strength --- S: raise strength\n"); X menuprint("c: lower constitution --- C: raise constitution\n"); X menuprint("d: lower dexterity --- D: raise dexterity\n"); X menuprint("a: lower agility --- A: raise agility\n"); X menuprint("i: lower intelligence --- I: raise intelligence\n"); X menuprint("p: lower power --- P: raise power\n"); X menuprint("\n\nESCAPE when you are satisfied with your statistics"); X displaystats(statpoints); X while(! done) { X switch(mgetc()) { X case ESCAPE: done = TRUE; break; X case 's': changestat(&statpoints,&Player.maxstr,-1); break; X case 'S': changestat(&statpoints,&Player.maxstr,1); break; X case 'c': changestat(&statpoints,&Player.maxcon,-1); break; X case 'C': changestat(&statpoints,&Player.maxcon,1); break; X case 'd': changestat(&statpoints,&Player.maxdex,-1); break; X case 'D': changestat(&statpoints,&Player.maxdex,1); break; X case 'a': changestat(&statpoints,&Player.maxagi,-1); break; X case 'A': changestat(&statpoints,&Player.maxagi,1); break; X case 'i': changestat(&statpoints,&Player.maxiq,-1); break; X case 'I': changestat(&statpoints,&Player.maxiq,1); break; X case 'p': changestat(&statpoints,&Player.maxpow,-1); break; X case 'P': changestat(&statpoints,&Player.maxpow,1); break; X } X displaystats(statpoints); X } X Player.str = Player.maxstr; X Player.hp = Player.maxhp = Player.con = Player.maxcon; X Player.dex = Player.maxdex; X Player.agi = Player.maxagi; X Player.iq = Player.maxiq; X Player.pow = Player.maxpow; X printm("\nPlease enter your character's name: "); X strcpy(Player.name,msgscanstring()); X printm("\nWhat is your character's sexual preference? [mf] "); X do Player.preference = mgetc(); X while ((Player.preference != 'm') && (Player.preference != 'f')); X printm("\nDo you want to save this set-up to .omegarc in this wd? [yn]"); X if (ynq()=='y') X save_omegarc(); X xredraw(); X} X Xvoid save_omegarc() X{ X FILE *fd = fopen(".omegarc","w"); X if (fd == NULL) X mprint("Sorry, couldn't save .omegarc for some reason."); X else { X mprint("First, set options."); X setoptions(); X fprintf(fd,"%s\n",Player.name); X write_int(fd,Player.options); X write_int(fd,Searchnum); X write_int(fd,Player.str); X write_int(fd,Player.con); X write_int(fd,Player.dex); X write_int(fd,Player.agi); X write_int(fd,Player.iq); X write_int(fd,Player.pow); X putc(Player.preference,fd); X fclose(fd); X } X} X X Xvoid changestat(statpoints,stat,delta) Xint *statpoints,*stat,delta; X{ X if ((*statpoints > 0) || (delta == -1)) X if ((*stat+delta < 19) && (*stat+delta > 2)) { X *statpoints -= delta; X *stat += delta; X } X} X X Xint calcmana() X{ X return(Player.pow * (Player.level+1)); X} X X X/* npcbehavior digits 1234 X X4 : alignment (LAWFUL,CHAOTIC, or NEUTRAL) X3 : primary combat action (melee,missile,spell,thief,flight,1..5) X2 : competence at 4 (0..9, 0 = incompetent, 9 = masterful) X1 : conversation mode X Xstatus : 1 = dead, 2 = saved, 3 = retired X*/ Xint fixnpc(status) Xint status; X{ X int npcbehavior=0; X char response; X if (status == 1) { /* player is dead, all undead are chaotic */ X npcbehavior+=CHAOTIC; X npcbehavior+=10; /* melee */ X npcbehavior+=100*min(9,((int) (Player.level/3))); X npcbehavior+=3000; /* evil */ X } X else { X printm("NPC Behavior Determination Module"); X menuclear(); X menuprint("Your overall NPC behavior is:"); X if (Player.alignment < -10) { X npcbehavior += CHAOTIC; X menuprint("\n\n CHAOTIC"); X } X else if (Player.alignment > 10) { X npcbehavior += LAWFUL; X menuprint("\n\n LAWFUL"); X } X else { X npcbehavior += NEUTRAL; X menuprint("\n\n NEUTRAL"); X } X menuprint("\n\n1: hand-to-hand combat"); X menuprint("\n2: missile combat"); X menuprint("\n3: spellcasting"); X menuprint("\n4: thieving"); X menuprint("\n5: escape"); X menuprint("\n\nEnter NPC response to combat: "); X response = '0'; X while ((response != '1') && X (response != '2') && X (response != '3') && X (response != '4') && X (response != '5')) X response = menugetc(); X menuaddch(response); X npcbehavior+=10*(response - '0'); X npcbehavior+=100*competence_check(response-'0'); X response = '0'; X menuprint("\n\n1: threaten"); X menuprint("\n2: greet"); X menuprint("\n3: aid"); X menuprint("\n4: beg"); X menuprint("\n5: silence"); X menuprint("\n\nEnter NPC response to conversation: "); X while ((response != '1') && X (response != '2') && X (response != '3') && X (response != '4') && X (response != '5')) X response = menugetc(); X menuaddch(response); X npcbehavior+=1000*(response - '0'); X xredraw(); X } X return(npcbehavior); X} X X X/* estimates on a 0..9 scale how good a player is at something */ Xint competence_check(attack) Xint attack; X{ X int ability = 0; X switch(attack) { X case 1: /* melee */ X ability += statmod(Player.str); X case 2: /* missle */ X ability += statmod(Player.dex); X ability += Player.rank[LEGION]; X ability += ((int) (Player.dmg / 10) - 1); X break; X case 3: /* spellcasting */ X ability += statmod(Player.iq); X ability += statmod(Player.pow); X ability += Player.rank[CIRCLE]; X ability += Player.rank[COLLEGE]; X ability += Player.rank[PRIEST]; X break; X case 4: /* thieving */ X ability += statmod(Player.dex); X ability += statmod(Player.agi); X ability += Player.rank[THIEVES]; X break; X case 5: /* escape */ X ability += 2 * statmod(Player.agi); X break; X } X ability += ((int) (Player.level / 5)); X if (ability < 0) ability = 0; X if (ability > 9) ability = 9; X return(ability); X} END_OF_ochar.c if test 8842 -ne `wc -c <ochar.c`; then echo shar: \"ochar.c\" unpacked with wrong size! fi # end of overwriting check fi if test -f ocity.c -a "${1}" != "-c" ; then echo shar: Will not over-write existing file \"ocity.c\" else echo shar: Extracting \"ocity.c\" \(8309 characters\) sed "s/^X//" >ocity.c <<'END_OF_ocity.c' X/* omega copyright (C) by Laurence Raphael Brothers, 1987 */ X/* ocity.c */ X/* some functions to make the city level */ X X#include <stdio.h> X#include <strings.h> X#include "oglob.h" X X X/* from olev */ Xextern pmt m_create(),make_creature(); Xextern pob create_object(); X X/* from omon */ Xextern void m_status_reset(); X X/* ocity functions */ Xvoid load_city(),makecityguard(),makecitymonster(),makecitytreasure(); Xvoid mysterycitysite(),assign_city_function(); X X/* loads the city level */ Xvoid load_city() X{ X int i,j,seen=TRUE; X char site,locsite,digit; X X FILE *fd; X X strcpy(Str3,OMEGALIB); X strcat(Str3,"ocity.dat"); X fd = fopen(Str3,"r"); X Mlist[0] = NULL; X X for(j=0;j<LENGTH;j++) { X for(i=0;i<WIDTH;i++) { X Dungeon[0][i][j].seen = seen; X site = getc(fd); X X switch(site) { X case 'g': X Dungeon[0][i][j].locchar = FLOOR; X Dungeon[0][i][j].p_locf = L_GARDEN; X seen = ! seen; X break; X case 'z': X Dungeon[0][i][j].locchar = FLOOR; X Dungeon[0][i][j].p_locf = L_MAZE; X break; X case 'y': X Dungeon[0][i][j].locchar = FLOOR; X Dungeon[0][i][j].p_locf = L_CEMETARY; X break; X case 'x': X assign_city_function(i,j); X break; X case 'T': X Dungeon[0][i][j].locchar = FLOOR; X Dungeon[0][i][j].p_locf = L_TEMPLE; X break; X case 'C': X Dungeon[0][i][j].locchar = OPEN_DOOR; X Dungeon[0][i][j].p_locf = L_COLLEGE; X break; X case 's': X Dungeon[0][i][j].locchar = OPEN_DOOR; X Dungeon[0][i][j].p_locf = L_SORCERORS; X break; X case 'M': X Dungeon[0][i][j].locchar = OPEN_DOOR; X Dungeon[0][i][j].p_locf = L_MERC_GUILD; X break; X case 'c': X Dungeon[0][i][j].locchar = OPEN_DOOR; X Dungeon[0][i][j].p_locf = L_CASTLE; X break; X case '?': X mysterycitysite(i,j); X break; X case 'J': X Dungeon[0][i][j].locchar = CLOSED_DOOR; X Dungeon[0][i][j].p_locf = L_JAIL; X break; X case 'A': X Dungeon[0][i][j].locchar = OPEN_DOOR; X Dungeon[0][i][j].p_locf = L_ARENA; X break; X case 'B': X Dungeon[0][i][j].locchar = OPEN_DOOR; X Dungeon[0][i][j].p_locf = L_BANK; X Dungeon[0][i][j+1].stopsrun = TRUE; X Dungeon[0][i+1][j].stopsrun = TRUE; X Dungeon[0][i-1][j].stopsrun = TRUE; X Dungeon[0][i][j-1].stopsrun = TRUE; X break; X case 'X': X Dungeon[0][i][j].locchar = FLOOR; X Dungeon[0][i][j].p_locf = L_CITYGATE; X break; X case 'Y': X Dungeon[0][i][j].locchar = CLOSED_DOOR; X Dungeon[0][i][j].p_locf = L_CHAOSSTORM; X Dungeon[0][i][j].aux = LOCKED; X break; X case 'V': X Dungeon[0][i][j].locchar = FLOOR; X Dungeon[0][i][j].p_locf = L_VAULT; X break; X case 'S': X Dungeon[0][i][j].locchar = FLOOR; X Dungeon[0][i][j].secret = TRUE; X break; X case 'G': X Dungeon[0][i][j].locchar = FLOOR; X makecityguard(i,j); X break; X case '$': X Dungeon[0][i][j].locchar = FLOOR; X makecitytreasure(i,j); X break; X case '2': X Dungeon[0][i][j].locchar = ALTAR; X Dungeon[0][i][j].p_locf = L_ALTAR; X Dungeon[0][i][j].aux = ODIN; X break; X case '3': X Dungeon[0][i][j].locchar = ALTAR; X Dungeon[0][i][j].p_locf = L_ALTAR; X Dungeon[0][i][j].aux = SET; X break; X case '4': X Dungeon[0][i][j].locchar = ALTAR; X Dungeon[0][i][j].p_locf = L_ALTAR; X Dungeon[0][i][j].aux = ATHENA; X break; X case '5': X Dungeon[0][i][j].locchar = ALTAR; X Dungeon[0][i][j].p_locf = L_ALTAR; X Dungeon[0][i][j].aux = HECATE; X break; X case '6': X Dungeon[0][i][j].locchar = ALTAR; X Dungeon[0][i][j].p_locf = L_ALTAR; X Dungeon[0][i][j].aux = DESTINY; X break; X case 'D': X Dungeon[0][i][j].locchar = ALTAR; X Dungeon[0][i][j].p_locf = L_DRUID; X Dungeon[0][i][j].aux = DRUID; X break; X case '^': X Dungeon[0][i][j].locchar = FLOOR; X Dungeon[0][i][j].p_locf = TRAP_BASE+random_range(NUMTRAPS); X break; X case '"': X Dungeon[0][i][j].locchar = HEDGE; X if (random_range(20)) X Dungeon[0][i][j].p_locf = L_HEDGE; X else X Dungeon[0][i][j].p_locf = L_TRIFID; X break; X case '\'': X Dungeon[0][i][j].locchar = HEDGE; X if (random_range(20)) X Dungeon[0][i][j].p_locf = L_HEDGE; X else X Dungeon[0][i][j].p_locf = L_TRIFID; X seen = ! seen; X break; X case '~': X Dungeon[0][i][j].locchar = WATER; X Dungeon[0][i][j].p_locf = L_WATER; X break; X case '&': X Dungeon[0][i][j].locchar = WALL; X Dungeon[0][i][j].aux = 100; X seen = ! seen; X break; X case '>': X Dungeon[0][i][j].locchar = DOWN; X Dungeon[0][i][j].p_locf = L_SEWER; X Dungeon[0][i][j].aux = 1; X break; X case '*': X Dungeon[0][i][j].locchar = WALL; X Dungeon[0][i][j].aux = 10; X break; X case '#': X Dungeon[0][i][j].locchar = WALL; X Dungeon[0][i][j].aux = 100; X break; X default: X Dungeon[0][i][j].locchar = site; X break; X } X X if (Dungeon[0][i][j].seen) { X if (Dungeon[0][i][j].secret) X Dungeon[0][i][j].showchar = '#'; X else Dungeon[0][i][j].showchar = Dungeon[0][i][j].locchar; X } X } X fscanf(fd,"\n"); X } X} X Xvoid makecityguard(i,j) Xint i,j; X{ X pml tml = ((pml) (calloc(1,sizeof(mltype)))); X tml->m = (Dungeon[0][i][j].creature = make_creature(ML0+3)); X tml->m->x = i; X tml->m->y = j; X tml->next = Mlist[0]; X Mlist[0] = tml; X} X X Xvoid makecitymonster(i,j) Xint i,j; X{ X pml tml = ((pml) (calloc(1,sizeof(mltype)))); X tml->m = (Dungeon[0][i][j].creature = m_create(i,j,FALSE,-1)); X m_status_reset(tml->m,AWAKE); X tml->m->wakeup = 1; X tml->next = Mlist[0]; X Mlist[0] = tml; X} X Xvoid makecitytreasure(i,j) Xint i,j; X{ X pol tol = ((pol) (calloc(1,sizeof(oltype)))); X X tol->next=NULL; X Dungeon[0][i][j].things = tol; X tol->thing = NULL; X tol->thing = create_object(); X Dungeon[0][i][j].things = tol; X} X Xvoid assign_city_function(x,y) Xint x,y; X{ X static int setup=0; X static int next=0; X static int permutation[64]; /* number of x's in city map */ X int i,j,k,l; X X Dungeon[0][x][y+1].stopsrun = TRUE; X Dungeon[0][x+1][y].stopsrun = TRUE; X Dungeon[0][x-1][y].stopsrun = TRUE; X Dungeon[0][x][y-1].stopsrun = TRUE; X X X if (setup == 0) { X setup = 1; X for(i=0;i<64;i++) X permutation[i] = i; X for(i=0;i<500;i++) { X j = random_range(64); X k = random_range(64); X l = permutation[j]; X permutation[j] = permutation[k]; X permutation[k] = l; X } X } X if (next > 63) { /* in case someone changes the no. of x's */ X Dungeon[0][x][y].locchar = CLOSED_DOOR; X Dungeon[0][x][y].p_locf = L_RESIDENCE; X if(random_range(5)) Dungeon[0][x][y].aux = LOCKED; X } X else switch(permutation[next]) { X case 0: X Dungeon[0][x][y].locchar = OPEN_DOOR; X Dungeon[0][x][y].p_locf = L_ARMORER; X break; X case 1: X Dungeon[0][x][y].locchar = OPEN_DOOR; X Dungeon[0][x][y].p_locf = L_CLUB; X break; X case 2: X Dungeon[0][x][y].locchar = OPEN_DOOR; X Dungeon[0][x][y].p_locf = L_GYM; X break; X case 3: X Dungeon[0][x][y].locchar = CLOSED_DOOR; X Dungeon[0][x][y].p_locf = L_THIEVES_GUILD; X Dungeon[0][x][y].aux = LOCKED; X break; X case 4: X Dungeon[0][x][y].locchar = OPEN_DOOR; X Dungeon[0][x][y].p_locf = L_HEALER; X break; X case 5: X Dungeon[0][x][y].locchar = OPEN_DOOR; X Dungeon[0][x][y].p_locf = L_CASINO; X break; X case 6: case 7: case 8: case 9: case 20: case 21: X Dungeon[0][x][y].locchar = OPEN_DOOR; X Dungeon[0][x][y].p_locf = L_TAVERN; X break; X case 10: X Dungeon[0][x][y].locchar = OPEN_DOOR; X Dungeon[0][x][y].p_locf = L_ALCHEMIST; X break; X case 11: X Dungeon[0][x][y].locchar = OPEN_DOOR; X Dungeon[0][x][y].p_locf = L_DPW; X break; X case 12: X Dungeon[0][x][y].locchar = OPEN_DOOR; X Dungeon[0][x][y].p_locf = L_LIBRARY; X break; X case 13: X Dungeon[0][x][y].locchar = OPEN_DOOR; X Dungeon[0][x][y].p_locf = L_PAWN_SHOP; X break; X case 14: X Dungeon[0][x][y].locchar = OPEN_DOOR; X Dungeon[0][x][y].p_locf = L_CONDO; X break; X case 15: X Dungeon[0][x][y].locchar = CLOSED_DOOR; X Dungeon[0][x][y].p_locf = L_BROTHEL; X break; X default: X Dungeon[0][x][y].locchar = CLOSED_DOOR; X Dungeon[0][x][y].p_locf = L_RESIDENCE; X if(random_range(5)) Dungeon[0][x][y].aux = LOCKED; X break; X } X next++; X} X X X Xvoid mysterycitysite(i,j) Xint i,j; X{ X switch(random_range(7)) { X case 0: case 1: X Dungeon[0][i][j].locchar = FLOOR; X Dungeon[0][i][j].p_locf = TRAP_BASE+random_range(NUMTRAPS); X break; X case 2: case 3: X Dungeon[0][i][j].locchar = FLOOR; X makecitymonster(i,j); X break; X case 4: case 5: X Dungeon[0][i][j].locchar = FLOOR; X makecitytreasure(i,j); X break; X default: X Dungeon[0][i][j].locchar = FLOOR; X } X} X END_OF_ocity.c if test 8309 -ne `wc -c <ocity.c`; then echo shar: \"ocity.c\" unpacked with wrong size! fi # end of overwriting check fi if test -f ocommands.txt -a "${1}" != "-c" ; then echo shar: Will not over-write existing file \"ocommands.txt\" else echo shar: Extracting \"ocommands.txt\" \(3674 characters\) sed "s/^X//" >ocommands.txt <<'END_OF_ocommands.txt' Xkey : description : # turns X______________________________________________________________________________ X^p : print previous message : 0 X^r : redraw screen : 0 Xa : activate a wand, staff, or rod : 1 Xc : close door : 1 Xd : drop object at current location : 1 Xe : eat something : 1 Xf : fire/throw something : 1 Xg : pick up object at current location : 1 Xi : inventory of things in pack : 0 Xm : cast a magic spell : 1 Xo : open door : 1 Xp : pick the pocket of an adjacent monster : 1 Xq : quaff a potion : 1 Xr : read a scroll : 1 Xs : search all around you, time depends on SEARCHNUM option : 1...9 Xt : talk to an adjacent monster : 1 Xv : vault over a few intervening spaces : 1 Xw : wield, wear, or otherwise employ an object : 1 Xx : examine a location : 0 Xz : bash something (adjacent location) : 1 XA : activate an artifact : 1 XC : call an item something : 0 XD : disarm an adjacent trap : 1 XF : fight an adjacent monster (Enter Tactical Combat Mode) : 1 XG : give something to an adjacent monster : 1 XI : inventory of things on ground : 0 XO : set options : 0 XP : public license information : 0 XQ : quit : - XR : rename character : 0 XS : save game and quit : - XT : dig a tunnel through a wall : 1 XV : version information : 0 XW : unwield, remove, or stop using an object : 1 XZ : bash something (item carried) : 1 X. : rest a turn : 1 X, : sleep some number of turns (100 turns/hour) : 1...1000 X> : go down a level : 1 X< : go up a level : 1 X/ : identify the onscreen usage of some character : 0 Xvi keys & keypad number: X walk one space or fight adjacent monster (Regular Combat X Mode), pick up things if PICKUP option set : 1 Xcapitalized vi keys, or 5 followed by keypad number: X run in that direction, fight adjacent monster if X BELLIGERENT option set,don't display slowly if JUMPMOVE X option set, stop for doorways, etc. if RUNSTOP option X set : variable X? : this list : 0 END_OF_ocommands.txt if test 3674 -ne `wc -c <ocommands.txt`; then echo shar: \"ocommands.txt\" unpacked with wrong size! fi # end of overwriting check fi if test -f omon.c -a "${1}" != "-c" ; then echo shar: Will not over-write existing file \"omon.c\" else echo shar: Extracting \"omon.c\" \(33354 characters\) sed "s/^X//" >omon.c <<'END_OF_omon.c' X/* omega copyright (c) 1987 by Laurence Raphael Brothers */ X/* omon.c */ X/* various functions to do with monsters */ X X#include <stdio.h> X#include <strings.h> X#include "oglob.h" X X/* from oscr */ Xextern void mprint(),printm(),drawspot(),locprint(),filescanstring(); Xextern void erase_level(),menuprint(); Xextern void levelrefresh(); Xextern char ynq(); X X/* from ocity */ Xextern void load_city(); X X/* from omovef */ Xextern void l_jail(); X X/* from outil */ Xextern int random_range(),sign(),max(),distance(),bitp(); Xextern void do_los(),bitset(),bitreset(); Xextern int pow2(); X X/* from oaux */ Xextern void p_damage(),drop_at(),p_poison(),p_teleport(); Xextern void sleep_player(); Xextern void gain_experience(),calc_melee(),weapon_use(),p_miss(); Xextern char *itemid(),*actionlocstr(); Xextern int p_immune(),player_on_sanctuary(); X X X X/* from oeffect 1 or 2*/ Xextern void lball(),fbolt(),fball(),summon(),aggravate(),findspace(); Xextern void acid_cloud(),snowball(),nbolt(),level_drain(),disintegrate(); Xextern void disrupt(); X X/* from oitem */ Xextern pob create_object(); X X/* from omonf.c */ Xextern void m_normal_melee(),m_normal_move(),m_no_op(),m_sp_blackout(); Xextern void m_smart_move(),m_simple_move(),m_spirit_move(),m_vanish(); Xextern void m_fire_melee(),m_firebolt(),m_guard_talk(),m_random_move(); Xextern void m_abyss(); Xextern void m_flutter_move(),m_nbolt(),m_sp_surprise(),m_dragon_melee(); Xextern void m_stupid_talk(),m_hungry_talk(),m_silent_talk(),m_greedy_talk(); Xextern void m_mp_talk(),m_follow_move(),m_mp_melee(),m_sp_mp(),m_evil_talk(); Xextern void m_elec_melee(),m_lball(),m_fireball(),m_poison_melee(),m_titter(); Xextern void m_ng_melee(),m_sp_poison_cloud(),m_huge_sounds(),m_robot_talk(); Xextern void m_sleep_melee(),m_blind_strike(),m_im_talk(); Xextern void m_thief_f(),m_man_talk(),m_spectral_melee(),m_summon(); Xextern void m_teleport(),m_disease_melee(),m_illusion(),m_aggravate(); Xextern void m_sp_explode(),m_cold_melee(),m_sp_acid_cloud(); Xextern void m_sp_whirl(),m_sp_escape(),m_sp_ghost(),m_ghost_talk(); Xextern void m_mimsy_talk(),m_slithy_talk(),m_burble_talk(),m_sp_spell(); Xextern void m_hint_talk(),m_beg_talk(),m_scaredy_move(); Xextern void m_evil_fairy_talk(),m_good_fairy_talk(),m_sp_seductor(); Xextern void m_snowball(),m_sp_demon(),m_seductor_talk(),m_demonlover_talk(); Xextern void m_sp_demonlover(),m_sp_dragonlord(),m_sp_eater(),m_ninja_talk(); Xextern void m_assassin_talk(); X X/* omon functions */ Xint m_statusp(),m_immunityp(),tacticalp(); Xvoid m_pulse(),m_status_set(),m_damage(); Xvoid m_death(),m_hit(),m_miss(),m_pickup(),m_dropstuff(); Xvoid m_status_reset(),monster_strike(),tacmonster(); Xvoid monster_talk(),monster_melee(),monster_move(),monster_special(); Xvoid movemonster(),make_log_npc(); Xvoid m_movefunction(); X Xvoid m_water(),m_lava(),m_altar(),m_whirlwind(),m_fire(); Xvoid m_trap_dart(),m_trap_pit(),m_trap_door(),m_trap_snare(); Xvoid m_trap_blade(),m_trap_fire(),m_trap_disintegrate(),m_trap_teleport(); Xvoid m_trap_manadrain(),m_trap_acid(),m_trap_sleepgas(),m_trap_abyss(); Xint m_open_door(),corpsevalue(); Xpmt make_hiscore_npc(); X X/* consider one monster's action */ Xvoid m_pulse(m) Xstruct monster *m; X{ X int i,range = distance(m->x, m->y, Player.x,Player.y); X X if (Time % 10 == 0) X if (m->hp < Monsters[m->id].hp) X m->hp++; X X if ((! m_statusp(m,AWAKE)) && (range <= m->wakeup)) { X m_status_set(m,AWAKE); X Fastmove = FALSE; X } X X if (m_statusp(m,AWAKE)) { X if (m_statusp(m,WANDERING)) { X if (m_statusp(m,MOBILE)) m_random_move(m); X if (range <= m->sense) m_status_reset(m,WANDERING); X } X else /* not wandering */ { X if (m_statusp(m,HOSTILE)) { X if ((range > 2) && (range < m->sense) && (random_range(2) == 1)) X if (los_p(m->x,m->y,Player.x,Player.y)) monster_strike(m); X } X if ((m_statusp(m,HOSTILE) || m_statusp(m,NEEDY)) X && (range > 1) X && m_statusp(m,MOBILE)) { X monster_move(m); X /* if monster is greedy, picks up treasure it finds */ X if (m_statusp(m,GREEDY)) X while (Dungeon[Dlevel][m->x][m->y].things != NULL) { X m_pickup(m,Dungeon[Dlevel][m->x][m->y].things->thing); X Dungeon[Dlevel][m->x][m->y].things = X Dungeon[Dlevel][m->x][m->y].things->next; X } X } X if (m_statusp(m,HOSTILE) && (range ==1)) { X Fastmove = FALSE; X monster_melee(m); X } X } X /* prevents monsters from casting spells from other side of dungeon */ X if (range < max(4,m->level)) X monster_special(m); X } X} X X X X/* try to open a door */ Xint m_open_door(m,x,y,canopen) Xstruct monster *m; Xint x,y,canopen; X{ X if (canopen && X (Dungeon[Dlevel][x][y].locchar==CLOSED_DOOR) && X (! Dungeon[Dlevel][x][y].secret)) { X if (Dungeon[Dlevel][x][y].aux != LOCKED) X Dungeon[Dlevel][x][y].locchar==OPEN_DOOR; X else { X if (((20*(random_range(10)+1)) < m->dmg)) { X mprint("You hear a door splintering!"); X Dungeon[Dlevel][x][y].locchar==FLOOR; X } X } X } X return(TRUE); X} X X X X X X/* actually make a move */ Xvoid movemonster(m,newx,newy) Xstruct monster *m; Xint newx,newy; X{ X Dungeon[Dlevel][m->x][m->y].creature = NULL; X m->x = newx; X m->y = newy; X Dungeon[Dlevel][m->x][m->y].creature = m; X m_movefunction(m,Dungeon[Dlevel][m->x][m->y].p_locf); X} X X X/* give object o to monster m */ Xvoid m_pickup(m,o) Xstruct monster *m; Xstruct object *o; X{ X pol tmp = ((pol) malloc(sizeof(oltype))); X tmp->thing = o; X tmp->next = m->possessions; X m->possessions = tmp; X} X Xvoid m_dropstuff(m) Xstruct monster *m; X{ X pol tmp = m->possessions; X if (tmp != NULL) { X while (tmp->next != NULL) X tmp = tmp->next; X X tmp->next = Dungeon[Dlevel][m->x][m->y].things; X Dungeon[Dlevel][m->x][m->y].things = m->possessions; X m->possessions = NULL; X } X} X X X Xvoid m_status_set(m,s) Xstruct monster *m; Xint s; X{ X bitset(&(m->status),s); X} X Xvoid m_status_reset(m,s) Xstruct monster *m; Xint s; X{ X bitreset(&(m->status),s); X} X X X X/* monster status predicate */ Xint m_statusp(m,s) Xstruct monster *m; Xint s; X{ X return(bitp(m->status,s)); X} X X/* monster immunity predicate */ Xint m_immunityp(m,s) Xstruct monster *m; Xint s; X{ X return(bitp(m->immunity,pow2(s))); X} X X X Xvoid m_damage(m,dmg,dtype) Xstruct monster *m; Xint dmg,dtype; X{ X m_status_set(m,AWAKE); X m_status_set(m,HOSTILE); X if (m_immunityp(m,dtype)) { X if (los_p(Player.x,Player.y,m->x,m->y)) { X if (m->uniqueness != COMMON) strcpy(Str1,m->monstring); X else { X strcpy(Str1,"The "); X strcat(Str1,m->monstring); X } X strcat(Str1," ignores the attack!"); X mprint(Str1); X } X } X else if ((m->hp -= dmg) < 1) m_death(m); X} X X Xvoid m_death(m) Xstruct monster *m; X{ X int newlevel; X pob corpse; X Tacmode = FALSE; X m->hp = -1; X if (los_p(Player.x,Player.y,m->x,m->y)) { X gain_experience(m->xpv); X calc_melee(); X if (m->uniqueness != COMMON) strcpy(Str1,m->monstring); X else { X strcpy(Str1,"The "); X strcat(Str1,m->monstring); X } X strcat(Str1," is dead! "); X mprint(Str1); X } X m_dropstuff(m); X Dungeon[Dlevel][m->x][m->y].creature = NULL; X if ((! Arena)&&(! Final)) { X corpse=((pob) malloc(sizeof(objtype))); X *corpse = Objects[CORPSEID]; X corpse->aux = m->id; X corpse->weight = m->corpseweight; X corpse->basevalue = m->corpsevalue; X corpse->known = 2; X strcpy(corpse->objstr,m->corpsestr); X strcpy(corpse->truename,m->corpsestr); X strcpy(corpse->cursestr,m->corpsestr); X if (strcmp(corpse->objstr,"a greasy spot") == 0) { X corpse->basevalue = 0; X corpse->weight = 0; X corpse->aux = 0; X } X drop_at(m->x,m->y,corpse); X plotspot(m->x,m->y,FALSE); X } X} X X X X Xvoid m_hit(m,dtype) Xstruct monster *m; Xint dtype; X{ X if (m->uniqueness == COMMON) { X strcpy(Str3,"a "); X strcat(Str3,m->monstring); X } X else strcpy(Str3,m->monstring); X if ((Player.status[DISPLACED] > 0) && (random_range(2) == 1)) X mprint("The attack was displaced!"); X else p_damage(random_range(m->dmg),dtype,Str3); X} X X X X Xvoid monster_move(m) Xstruct monster *m; X{ X switch(m->movef) { X case M_NO_OP:m_no_op(m); break; X case M_MOVE_NORMAL:m_normal_move(m); break; X case M_MOVE_FLUTTER:m_flutter_move(m); break; X case M_MOVE_FOLLOW:m_follow_move(m); break; X case M_MOVE_TELEPORT:m_teleport(m); break; X case M_MOVE_RANDOM:m_random_move(m); break; X case M_MOVE_SMART:m_smart_move(m); break; X case M_MOVE_SPIRIT:m_spirit_move(m); break; X case M_MOVE_CONFUSED:m_confused_move(m); break; X case M_MOVE_SCAREDY:m_scaredy_move(m); break; X } X} X Xvoid monster_melee(m) Xstruct monster *m; X{ X /* It's lawful to wait to be attacked */ X if (player_on_sanctuary()) X mprint("The aegis of your deity protects you!"); X else { X if (m->attacked==0) Player.alignment++; X m->attacked++; X switch(m->meleef) { X case M_NO_OP:m_no_op(m); break; X case M_MELEE_NORMAL:m_normal_melee(m); break; X case M_MELEE_FIRE:m_fire_melee(m); break; X case M_MELEE_DRAGON:m_dragon_melee(m); break; X case M_MELEE_MP:m_mp_melee(m); break; X case M_MELEE_ELEC:m_elec_melee(m); break; X case M_MELEE_COLD:m_cold_melee(m); break; X case M_MELEE_POISON:m_poison_melee(m); break; X case M_MELEE_NG:m_ng_melee(m); break; X case M_MELEE_SPIRIT:m_spectral_melee(m); break; X case M_MELEE_DISEASE:m_disease_melee(m); break; X case M_MELEE_SLEEP:m_sleep_melee(m); break; X } X } X} X Xvoid monster_strike(m) Xstruct monster *m; X{ X if (player_on_sanctuary()) X mprint("The aegis of your deity protects you!"); X else { X /* It's lawful to wait to be attacked */ X if (m->attacked==0) Player.alignment++; X m->attacked++; X switch(m->strikef) { X case M_NO_OP:m_no_op(m); break; X case M_STRIKE_MISSILE:m_nbolt(m); break; X case M_STRIKE_FBOLT:m_firebolt(m); break; X case M_STRIKE_LBALL:m_lball(m); break; X case M_STRIKE_FBALL:m_fireball(m); break; X case M_STRIKE_SNOWBALL:m_snowball(m); break; X case M_STRIKE_BLIND:m_blind_strike(m); break; X } X } X} X Xvoid monster_special(m) Xstruct monster *m; X{ X if (! player_on_sanctuary()) X switch(m->specialf) { X case M_NO_OP:m_no_op(m); break; X case M_SP_SURPRISE:m_sp_surprise(m); break; X case M_SP_MP:m_sp_mp(m); break; X case M_SP_THIEF:m_thief_f(m); break; X case M_SP_DEMONLOVER:m_sp_demonlover(m); break; X case M_SP_AGGRAVATE:m_aggravate(m); break; X case M_SP_POISON_CLOUD:m_sp_poison_cloud(m); break; X case M_SP_HUGE:m_huge_sounds(m); break; X case M_SP_SUMMON:m_summon(m); break; X case M_SP_ILLUSION:m_illusion(m); break; X case M_SP_ESCAPE:m_sp_escape(m); break; X case M_SP_FLUTTER:m_flutter_move(m); break; X case M_SP_EXPLODE:m_sp_explode(m); break; X case M_SP_DEMON:m_sp_demon(m); break; X case M_SP_ACID_CLOUD:m_sp_acid_cloud(m); break; X case M_SP_WHIRL:m_sp_whirl(m); break; X case M_SP_GHOST:m_sp_ghost(m); break; X case M_SP_SPELL:m_sp_spell(m); break; X case M_SP_SEDUCTOR:m_sp_seductor(m); break; X case M_SP_EATER:m_sp_eater(m); break; X case M_SP_DRAGONLORD:m_sp_dragonlord(m); break; X case M_SP_BLACKOUT:m_sp_blackout(m); break; X case M_MOVE_TELEPORT:m_teleport(m); break; X } X} X X Xvoid monster_talk(m) Xstruct monster *m; X{ X switch(m->talkf) { X case M_NO_OP:m_no_op(m); break; X case M_TALK_THIEF:m_thief_talk(m);break; X case M_TALK_STUPID:m_stupid_talk(m); break; X case M_TALK_SILENT:m_silent_talk(m); break; X case M_TALK_HUNGRY:m_hungry_talk(m); break; X case M_TALK_GREEDY:m_greedy_talk(m); break; X case M_TALK_TITTER:m_titter(m); break; X case M_TALK_MP:m_mp_talk(m); break; X case M_TALK_IM:m_im_talk(m); break; X case M_TALK_MAN:m_man_talk(m); break; X case M_TALK_ROBOT:m_robot_talk(m); break; X case M_TALK_EVIL:m_evil_talk(m); break; X case M_TALK_GUARD:m_guard_talk(m); break; X case M_TALK_MIMSY:m_mimsy_talk(m); break; X case M_TALK_SLITHY:m_slithy_talk(m); break; X case M_TALK_BURBLE:m_burble_talk(m); break; X case M_TALK_GHOST:m_ghost_talk(m); break; X case M_TALK_BEG:m_beg_talk(m); break; X case M_TALK_HINT:m_hint_talk(m); break; X case M_TALK_EF:m_evil_fairy_talk(m); break; X case M_TALK_GF:m_good_fairy_talk(m); break; X case M_TALK_SEDUCTOR:m_seductor_talk(m); break; X case M_TALK_DEMONLOVER:m_demonlover_talk(m); break; X case M_TALK_NINJA:m_ninja_talk(m); break; X case M_TALK_ASSASSIN:m_assassin_talk(m); break; X } X} X X X/* monster id arg */ Xint corpsevalue(mid) Xint mid; X{ X switch(mid) { X default: X return(0); X break; X case ML1+2: X return(250); X break; X case ML1+4: X return(50); X break; X case ML1+5: X return(200); X break; X case ML1+7: X return(100); X break; X case ML2+3: X return(300); X break; X case ML2+5: X return(200); X break; X case ML3+0: X return(100); X break; X case ML3+1: X return(100); X break; X case ML3+4: X return(200); X break; X case ML4+0: X return(200); X break; X case ML4+3: X return(100); X break; X case ML5+0: X return(400); X break; X case ML5+1: X return(300); X break; X case ML5+2: X return(500); X break; X case ML5+4: X return(750); X break; X case ML6+0: X return(1000); X break; X case ML6+1: X return(1000); X break; X case ML6+2: X return(1000); X break; X case ML6+3: X return(1000); X break; X case ML7+0: X return(1000); X break; X case ML7+2: X return(10000); X break; X } X} X X X Xpmt make_hiscore_npc(npcid) Xint npcid; X{ X pmt npc = ((pmt) malloc(sizeof(montype))); X pob ob; X int i,treasures,behavior,level,combatype,competence,talktype; X *npc = Monsters[ML0+4]; X X /* each of the high score npc's can be created here */ X switch(npcid) { X case 1: X level = Priestlevel[1]; X behavior = Priestbehavior[1]; X break; X case 2: X level = Priestlevel[2]; X behavior = Priestbehavior[2]; X break; X case 3: X level = Priestlevel[3]; X behavior = Priestbehavior[3]; X break; X case 4: X level = Priestlevel[4]; X behavior = Priestbehavior[4]; X break; X case 5: X level = Priestlevel[5]; X behavior = Priestbehavior[5]; X break; X case 6: X level = Priestlevel[6]; X behavior = Priestbehavior[6]; X break; X case 7: X level = Shadowlordlevel; X behavior = Shadowlordbehavior; X break; X case 8: X level = Commandantlevel; X behavior = Commandantbehavior; X break; X case 9: X level = Archmagelevel; X behavior = Archmagebehavior; X break; X case 10: X level = Primelevel; X behavior = Primebehavior; X break; X case 11: X level = Championlevel; X behavior = Championbehavior; X break; X case 12: X level = Primelevel; X behavior = Primebehavior; X break; X case 13: X level = Dukelevel; X behavior = Dukebehavior; X break; X } X strcpy(npc->monstring,Str2); X npc->hp = level*20; X npc->status = AWAKE+MOBILE+WANDERING; X combatype = ((int) ((behavior % 100) / 10)); X competence = ((int) ((behavior % 1000) / 100)); X talktype = ((int) (behavior / 1000)); X npc->level = competence; X if (npc->level < 2*Dlevel) npc->status += HOSTILE; X npc->xpv = npc->level*20; X if (npcid == 0) npc->xpv *= 10; /* high scorer worth more xpv */ X switch (combatype) { X case 1: /* melee */ X npc->meleef = M_MELEE_NORMAL; X npc->actions = competence; X if (competence < 3) X npc->tactics = MM_POOR; X else if (competence < 6) X npc->tactics = MM_AVERAGE; X else npc->tactics = MM_GOOD; X npc->dmg = competence*5; X npc->hit = competence*3; X break; X case 2: /*missile*/ X npc->meleef = M_MELEE_NORMAL; X npc->actions = max(2,(2 * competence / 3)); X if (competence < 5) X npc->tactics = MM_POOR; X else if (competence < 8) X npc->tactics = MM_AVERAGE; X else npc->tactics = MM_GOOD; X npc->strikef = M_STRIKE_MISSILE; X npc->dmg = competence*3; X npc->hit = competence*2; X break; X case 3: /* spellcasting */ X npc->meleef = M_MELEE_NORMAL; X npc->actions = max(2,(competence / 3)); X npc->tactics = MM_POOR+MM_TIMID; X npc->dmg = competence; X npc->hit = competence; X npc->specialf = M_SP_SPELL; X break; X case 4: /* thievery */ X npc->meleef = M_MELEE_NORMAL; X npc->actions = max(2,(2 * competence / 3)); X if (competence < 5) X npc->tactics = MM_POOR; X else if (competence < 8) X npc->tactics = MM_AVERAGE; X else npc->tactics = MM_GOOD; X npc->tactics += MM_TIMID; X npc->dmg = competence; X npc->hit = competence; X npc->specialf=M_SP_THIEF; X break; X case 5: /* flee */ X npc->actions = max(2,(competence / 3)); X npc->tactics = MM_TIMID+MM_AVERAGE; X npc->meleef = M_MELEE_NORMAL; X npc->specialf = M_MOVE_SCAREDY; X break; X X } X switch (talktype) { X case 1: npc->talkf = M_TALK_EVIL; break; X case 2: npc->talkf = M_TALK_MAN; break; X case 3: npc->talkf = M_TALK_HINT; break; X case 4: npc->talkf = M_TALK_BEG; break; X case 5: npc->talkf = M_TALK_SILENT; break; X default: mprint("Say Whutt? (npc talk weirdness)"); break; X } X npc->uniqueness = UNIQUE_MADE; X return(npc); X} X X Xvoid make_log_npc(npc) Xstruct monster *npc; X{ X int i,n = random_range(Logsize)+1; X int behavior,status,level,combatype,competence,talktype; X FILE *fd; X strcpy(Str1,OMEGALIB); X strcat(Str1,"omega.log"); X fd = fopen(Str1,"r"); X for (i=0;i<n;i++) { X filescanstring(fd,Str2); /* eats the username */ X filescanstring(fd,Str2); X fscanf(fd,"%d %d %d\n",&status,&level,&behavior); X } X fclose(fd); X npc->hp = level*20; X if (status==1) { X if (level < 7) { X *npc = Monsters[ML2+6]; X strcpy(npc->monstring,"ghost named "); X } X else if (level < 13) { X *npc = Monsters[ML4+5]; X strcpy(npc->monstring,"haunt named "); X } X else if (level < 23) { X *npc = Monsters[ML5+5]; X strcpy(npc->monstring,"spectre named "); X } X else { X *npc = Monsters[ML6+5]; X strcpy(npc->monstring,"lich named "); X } X strcat(npc->monstring,Str2); X } X else { X strcpy(npc->monstring,Str2); X npc->status = AWAKE+MOBILE+WANDERING; X combatype = ((int) ((behavior % 100) / 10)); X competence = ((int) ((behavior % 1000) / 100)); X talktype = ((int) (behavior / 1000)); X npc->level = competence; X if (npc->level < 2*Dlevel) npc->status += HOSTILE; X npc->xpv = npc->level*20; X switch (combatype) { X case 1: /* melee */ X npc->meleef = M_MELEE_NORMAL; X npc->actions = competence; X if (competence < 3) X npc->tactics = MM_POOR; X else if (competence < 6) X npc->tactics = MM_AVERAGE; X else npc->tactics = MM_GOOD; X npc->dmg = competence*5; X npc->hit = competence*3; X break; X case 2: /*missile*/ X npc->meleef = M_MELEE_NORMAL; X npc->actions = max(2,(2 * competence / 3)); X if (competence < 5) X npc->tactics = MM_POOR; X else if (competence < 8) X npc->tactics = MM_AVERAGE; X else npc->tactics = MM_GOOD; X npc->strikef = M_STRIKE_MISSILE; X npc->dmg = competence*3; X npc->hit = competence*2; X break; X case 3: /* spellcasting */ X npc->meleef = M_MELEE_NORMAL; X npc->actions = max(2,(competence / 3)); X npc->tactics = MM_POOR+MM_TIMID; X npc->dmg = competence; X npc->hit = competence; X npc->specialf = M_SP_SPELL; X break; X case 4: /* thievery */ X npc->meleef = M_MELEE_NORMAL; X npc->actions = max(2,(2 * competence / 3)); X if (competence < 5) X npc->tactics = MM_POOR; X else if (competence < 8) X npc->tactics = MM_AVERAGE; X else npc->tactics = MM_GOOD; X npc->tactics += MM_TIMID; X npc->dmg = competence; X npc->hit = competence; X npc->specialf=M_SP_THIEF; X break; X case 5: /* flee */ X npc->actions = max(2,(competence / 3)); X npc->tactics = MM_TIMID+MM_AVERAGE; X npc->meleef = M_MELEE_NORMAL; X npc->specialf = M_MOVE_SCAREDY; X break; X } X switch (talktype) { X case 1: npc->talkf = M_TALK_EVIL; break; X case 2: npc->talkf = M_TALK_MAN; break; X case 3: npc->talkf = M_TALK_HINT; break; X case 4: npc->talkf = M_TALK_BEG; break; X case 5: npc->talkf = M_TALK_SILENT; break; X default: mprint("Say Whutt? (npc talk weirdness)"); break; X } X } X npc->uniqueness = UNIQUE_MADE; X} X X X/* decide monster actions in tactical combat mode */ X Xvoid tacmonster(p_actions,pnumactions,m_actions,mnumactions,m) Xint p_actions[10],pnumactions; Xint m_actions[10],*mnumactions; Xstruct monster *m; X{ X int i,attacks,blocks; X int blocknot,blockcounter,loc1,loc2; X int p_attacks[4]; X int p_blocks[4]; X X *mnumactions = min(10,m->actions); X X /* First decide whether or not to disengage */ X if ((tacticalp(m,MM_TIMID) && (m->hp < Monsters[m->id].hp / 2)) || X (! tacticalp(m,MM_BERSERK) && (m->hp < Monsters[m->id].hp / 4))) { X *mnumactions = 1; X m_actions[0] = DISENGAGE; X } X X else { /* some combination of blocks and cuts to some locations */ X X /* decide based on monster behavior what combo of cuts and blocks */ X if (tacticalp(m,MM_BERSERK)) X for(i=0;i<*mnumactions;i++) { X m_actions[i] = CUT; X attacks = *mnumactions; X } X X else if (tacticalp(m,MM_TIMID)) X for(i=0;i<*mnumactions;i++) { X m_actions[i] = BLOCK; X blocks = *mnumactions; X } X X else { X attacks = *mnumactions / 2; X blocks = *mnumactions / 2; X if (attacks + blocks < *mnumactions) { X if (m->hp > Player.hp) attacks++; X else blocks++; X } X for(i=0;i<attacks;i++) X m_actions[i] = CUT; X for(i=0;i<blocks;i++) X m_actions[i+attacks] = BLOCK; X } X X /* decide where to cuts and blocks should go */ X X /* forced location */ X if (tacticalp(m,MM_FORCED)) X for(i=0;i<*mnumactions;i++) { X if (m_actions[i] == CUT) X m_actions[i]+=m->hitloc; X else m_actions[i]+=(random_range(3)+1); X } X X /* random locations for attacks and blocks */ X else if (tacticalp(m,MM_POOR)) { X loc1 = random_range(3)+1; X loc2 = random_range(3)+1; X for(i=0;i<*mnumactions;i++) { X if (m_actions[i] == BLOCK) m_actions[i] += loc1; X else m_actions[i] += loc2; X } X } X X /* distributed location */ X else if (tacticalp(m,MM_AVERAGE)) { X blocknot = random_range(3)+1; X blockcounter = random_range(3)+1; X for(i=0;i<*mnumactions;i++) { X if (m_actions[i] == BLOCK) { X if (blockcounter != blocknot) X m_actions[i] += ((blockcounter % 3)+1); X else m_actions[i] += (((++blockcounter) % 3) + 1); X blockcounter++; X } X else if (m_actions[i] == CUT) X m_actions[i] += blocknot; X } X } X X else { /* If monster is competent enough, will see player's actions */ X if (m->level+random_range(30) > Player.level+random_range(20)) { X X /* Find which area player blocks and attacks least in */ X X for (i=0;i<pnumactions;i++) X if ((p_actions[i] - (p_actions[i] % 10) == BLOCK) || X (p_actions[i] - (p_actions[i] % 10) == RIPOSTE)) X p_blocks[p_actions[i] % 10]++; X X if ((p_blocks[LOW] <= p_blocks[CENTER]) && X (p_blocks[LOW] <= p_blocks[HIGH])) X loc1 = LOW; X else if ((p_blocks[CENTER] <= p_blocks[LOW]) && X (p_blocks[CENTER] <= p_blocks[HIGH])) X loc1 = CENTER; X else loc1 = HIGH; X X X for (i=0;i<pnumactions;i++) X if ((p_actions[i] - (p_actions[i] % 10) == CUT) || X (p_actions[i] - (p_actions[i] % 10) == THRUST) || X (p_actions[i] - (p_actions[i] % 10) == LUNGE)) X p_attacks[p_actions[i] % 10]++; X X if ((p_attacks[LOW] <= p_attacks[CENTER]) && X (p_attacks[LOW] <= p_attacks[HIGH])) X loc2 = LOW; X else if ((p_attacks[CENTER] <= p_attacks[LOW]) && X (p_attacks[CENTER] <= p_attacks[HIGH])) X loc2 = CENTER; X else loc2 = HIGH; X X for(i=0;i<*mnumactions;i++) { X if (m_actions[i] == CUT) X m_actions[i] += loc1; X else if (m_actions[i] == BLOCK) X m_actions[i] += loc2; X } X } X else { /* monster was not clever enough so use average result */ X blocknot = random_range(3)+1; X blockcounter = random_range(3)+1; X for(i=0;i<*mnumactions;i++) { X if (m_actions[i] == BLOCK) { X if (blockcounter != blocknot) X m_actions[i] += ((blockcounter % 3)+1); X else m_actions[i] += (((++blockcounter) % 3) + 1); X blockcounter++; X } X else if (m_actions[i] == CUT) X m_actions[i] += blocknot; X } X } X } X } X} X Xint tacticalp(m,tac) Xstruct monster *m; Xint tac; X{ X return(bitp(m->tactics,tac)); X} X X X/* execute some move function for a monster */ Xvoid m_movefunction(m,movef) Xstruct monster *m; Xint movef; X{ X /* loc functs above traps should be activated whether levitating or not */ X if (! m_statusp(m,FLYING)) X switch(movef) { X X /* miscellaneous */ X case L_NO_OP:m_no_op(m); break; X case L_WATER:m_water(m); break; X case L_WHIRLWIND:m_whirlwind(m); break; X case L_LAVA:m_lava(m); break; X case L_FIRE:m_fire(m); break; X case L_MAGIC_POOL:m_water(m); break; X case L_ABYSS: m_abyss(m); break; X X case L_TRAP_DART:m_trap_dart(m); break; X case L_TRAP_PIT:m_trap_pit(m); break; X case L_TRAP_DOOR:m_trap_door(m); break; X case L_TRAP_SNARE:m_trap_snare(m); break; X case L_TRAP_BLADE:m_trap_blade(m); break; X case L_TRAP_FIRE:m_trap_fire(m); break; X case L_TRAP_TELEPORT:m_trap_teleport(m); break; X case L_TRAP_DISINTEGRATE:m_trap_disintegrate(m); break; X case L_TRAP_MANADRAIN:m_trap_manadrain(m); break; X case L_TRAP_SLEEP_GAS:m_trap_sleepgas(m); break; X case L_TRAP_ACID:m_trap_acid(m); break; X case L_TRAP_ABYSS:m_trap_abyss(m);break; X X case L_ALTAR:m_altar(m); break; X } X} X X Xvoid m_trap_dart(m) Xstruct monster *m; X{ X if (los_p(m->x,m->y,Player.x,Player.y)) { X if (m->uniqueness != COMMON) strcpy(Str1,m->monstring); X else { X strcpy(Str1,"The "); X strcat(Str1,m->monstring); X } X strcat(Str1," was hit by a dart!"); X mprint(Str1); X Dungeon[Dlevel][m->x][m->y].locchar = TRAP; X } X m_damage(m,Dlevel*2,NORMAL_DAMAGE); X} X Xvoid m_trap_pit(m) Xstruct monster *m; X{ X if (los_p(m->x,m->y,Player.x,Player.y)) { X if (m->uniqueness != COMMON) strcpy(Str1,m->monstring); X else { X strcpy(Str1,"The "); X strcat(Str1,m->monstring); X } X strcat(Str1," fell into a pit!"); X mprint(Str1); X Dungeon[Dlevel][m->x][m->y].locchar = TRAP; X } X if (! m_statusp(m,INTANGIBLE)) X m_status_reset(m,MOBILE); X m_damage(m,Dlevel*5,NORMAL_DAMAGE); X X} X Xvoid m_trap_door(m) Xstruct monster *m; X{ X if (los_p(m->x,m->y,Player.x,Player.y)) { X if (m->uniqueness != COMMON) strcpy(Str1,m->monstring); X else { X strcpy(Str1,"The "); X strcat(Str1,m->monstring); X } X strcat(Str1," fell into a trap door!"); X mprint(Str1); X Dungeon[Dlevel][m->x][m->y].locchar = TRAP; X } X m_vanish(m); X} X Xvoid m_trap_abyss(m) Xstruct monster *m; X{ X char Str1[80]; X if (los_p(m->x,m->y,Player.x,Player.y)) { X if (m->uniqueness != COMMON) strcpy(Str1,m->monstring); X else { X strcpy(Str1,"The "); X strcat(Str1,m->monstring); X } X strcat(Str1," fell into the infinite abyss!"); X mprint(Str1); X Dungeon[Dlevel][m->x][m->y].locchar = ABYSS; X Dungeon[Dlevel][m->x][m->y].p_locf = L_ABYSS; X } X m_vanish(m); X} X Xvoid m_trap_snare(m) Xstruct monster *m; X{ X char Str1[80]; X Dungeon[Dlevel][m->x][m->y].locchar = TRAP; X if (los_p(m->x,m->y,Player.x,Player.y)) { X if (m->uniqueness != COMMON) strcpy(Str1,m->monstring); X else { X strcpy(Str1,"The "); X strcat(Str1,m->monstring); X } X strcat(Str1," was caught in a snare!"); X mprint(Str1); X } X if (! m_statusp(m,INTANGIBLE)) m_status_reset(m,MOBILE); X} X Xvoid m_trap_blade(m) Xstruct monster *m; X{ X char Str1[80]; X Dungeon[Dlevel][m->x][m->y].locchar = TRAP; X if (los_p(m->x,m->y,Player.x,Player.y)) { X if (m->uniqueness != COMMON) strcpy(Str1,m->monstring); X else { X strcpy(Str1,"The "); X strcat(Str1,m->monstring); X } X strcat(Str1," was hit by a blade trap!"); X mprint(Str1); } X m_damage(m,(Dlevel+1)*7-Player.defense,NORMAL_DAMAGE); X} X Xvoid m_trap_fire(m) Xstruct monster *m; X{ X char Str1[80]; X Dungeon[Dlevel][m->x][m->y].locchar = TRAP; X if (los_p(m->x,m->y,Player.x,Player.y)) { X if (m->uniqueness != COMMON) strcpy(Str1,m->monstring); X else { X strcpy(Str1,"The "); X strcat(Str1,m->monstring); X } X strcat(Str1," was hit by a fire trap!"); X mprint(Str1); X } X m_damage(m,(Dlevel+1)*5,FLAME); X} X X Xvoid m_fire(m) Xstruct monster *m; X{ X char Str1[80]; X if (los_p(m->x,m->y,Player.x,Player.y)) { X if (m->uniqueness != COMMON) strcpy(Str1,m->monstring); X else { X strcpy(Str1,"The "); X strcat(Str1,m->monstring); X } X strcat(Str1," was blasted by fire!"); X mprint(Str1); X } X m_damage(m,random_range(100),FLAME); X} X Xvoid m_trap_teleport(m) Xstruct monster *m; X{ X char Str1[80]; X Dungeon[Dlevel][m->x][m->y].locchar = TRAP; X if (los_p(m->x,m->y,Player.x,Player.y)) { X if (m->uniqueness != COMMON) strcpy(Str1,m->monstring); X else { X strcpy(Str1,"The "); X strcat(Str1,m->monstring); X } X strcat(Str1," walked into a teleport trap!"); X mprint(Str1); X } X m_teleport(m); X} X Xvoid m_trap_disintegrate(m) Xstruct monster *m; X{ X char Str1[80]; X if (los_p(m->x,m->y,Player.x,Player.y)) { X if (m->uniqueness != COMMON) strcpy(Str1,m->monstring); X else { X strcpy(Str1,"The "); X strcat(Str1,m->monstring); X } X strcat(Str1," walked into a disintegration trap!"); X mprint(Str1); X Dungeon[Dlevel][m->x][m->y].locchar = TRAP; X } X disintegrate(m->x,m->y); X} X Xvoid m_trap_sleepgas(m) Xstruct monster *m; X{ X char Str1[80]; X if (los_p(m->x,m->y,Player.x,Player.y)) { X if (m->uniqueness != COMMON) strcpy(Str1,m->monstring); X else { X strcpy(Str1,"The "); X strcat(Str1,m->monstring); X } X strcat(Str1," walked into a sleepgas trap!"); X mprint(Str1); X Dungeon[Dlevel][m->x][m->y].locchar = TRAP; X } X if (! m_immunityp(m,SLEEP)) m_status_reset(m,AWAKE); X} X Xvoid m_trap_acid(m) Xstruct monster *m; X{ X char Str1[80]; X if (los_p(m->x,m->y,Player.x,Player.y)) { X if (m->uniqueness != COMMON) strcpy(Str1,m->monstring); X else { X strcpy(Str1,"The "); X strcat(Str1,m->monstring); X } X strcat(Str1," walked into an acid bath trap!"); X mprint(Str1); X Dungeon[Dlevel][m->x][m->y].locchar = TRAP; X } X m_damage(m,random_range(Dlevel*Dlevel),ACID); X} X Xvoid m_trap_manadrain(m) Xstruct monster *m; X{ X char Str1[80]; X if (los_p(m->x,m->y,Player.x,Player.y)) { X if (m->uniqueness != COMMON) strcpy(Str1,m->monstring); X else { X strcpy(Str1,"The "); X strcat(Str1,m->monstring); X } X strcat(Str1," walked into a manadrain trap!"); X mprint(Str1); X Dungeon[Dlevel][m->x][m->y].locchar = TRAP; X } X if (m->specialf == M_SP_SPELL) m->specialf = M_NO_OP; X} X X Xvoid m_water(m) Xstruct monster *m; X{ X char Str1[80]; X if ((! m_statusp(m,INTANGIBLE)) && (! m_statusp(m,SWIMMING))) { X if (los_p(m->x,m->y,Player.x,Player.y)) { X if (m->uniqueness != COMMON) strcpy(Str1,m->monstring); X else { X strcpy(Str1,"The "); X strcat(Str1,m->monstring); X } X strcat(Str1," drowned!"); X mprint(Str1); X } X m_death(m); X } X} X Xvoid m_whirlwind(m) Xstruct monster *m; X{ X char Str1[80]; X if (! m_statusp(m,INTANGIBLE)) { X if (los_p(m->x,m->y,Player.x,Player.y)) { X if (m->uniqueness != COMMON) strcpy(Str1,m->monstring); X else { X strcpy(Str1,"The "); X strcat(Str1,m->monstring); X } X strcat(Str1," was caught in a whirlwind!"); X mprint(Str1); X } X m_damage(m,25,ELECTRICITY); X m_teleport(m); X } X} X Xvoid m_abyss(m) Xstruct monster *m; X{ X char Str1[80]; X if (los_p(m->x,m->y,Player.x,Player.y)) { X if (m->uniqueness != COMMON) strcpy(Str1,m->monstring); X else { X strcpy(Str1,"The "); X strcat(Str1,m->monstring); X } X strcat(Str1," fell into the infinite abyss!"); X mprint(Str1); X } X m_vanish(m); X} X X X Xvoid m_lava(m) Xstruct monster *m; X{ X char Str1[80]; X if ((! m_immunityp(m,FLAME)) && (! m_statusp(m,SWIMMING))) { X if (los_p(m->x,m->y,Player.x,Player.y)) { X if (m->uniqueness != COMMON) strcpy(Str1,m->monstring); X else { X strcpy(Str1,"The "); X strcat(Str1,m->monstring); X } X strcat(Str1," died in a pool of lava!"); X mprint(Str1); X } X m_death(m); X } X} X Xvoid m_altar(m) Xstruct monster *m; X{ X if (m->uniqueness != COMMON) strcpy(Str1,m->monstring); X else { X strcpy(Str1,"The "); X strcat(Str1,m->monstring); X } X strcat(Str1," walks next to an altar..."); X mprint(Str1); X if (Dungeon[Dlevel][m->x][m->y].aux==Player.patron) { X mprint("Your deity is angry!"); X mprint("A bolt of godsfire strikes the monster...."); X disrupt(m->x,m->y,Player.rank[PRIESTHOOD]*50); X } X else if ((Player.patron == ODIN) || (Player.patron == ATHENA)) { X if ((Dungeon[Dlevel][m->x][m->y].aux == SET) || X (Dungeon[Dlevel][m->x][m->y].aux == HECATE)) { X mprint("The deity of the altar smiles on the monster...."); X mprint("A shaft of light zaps the altar..."); X m->hp = Monsters[m->id].hp*2; X } X else mprint("but nothing much seems to happen"); X } X else if ((Player.patron == SET) || (Player.patron == HECATE)) { X if ((Dungeon[Dlevel][m->x][m->y].aux == ODIN) || X (Dungeon[Dlevel][m->x][m->y].aux == ATHENA)) { X mprint("The deity of the altar smiles on the monster...."); X mprint("A shaft of light zaps the altar..."); X m->hp = Monsters[m->id].hp*2; X } X else mprint("but nothing much seems to happen"); X } X else mprint("but nothing much seems to happen"); X} X END_OF_omon.c if test 33354 -ne `wc -c <omon.c`; then echo shar: \"omon.c\" unpacked with wrong size! fi # end of overwriting check fi echo shar: End of archive 10 \(of 15\). cp /dev/null ark10isdone MISSING="" for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ; do if test ! -f ark${I}isdone ; then MISSING="${MISSING} ${I}" fi done if test "${MISSING}" = "" ; then echo You have unpacked all 15 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