games@tekred.TEK.COM (07/22/88)
Submitted by: "Laurence R. Brothers" <brothers@paul.rutgers.edu>
Comp.sources.games: Volume 5, Issue 15
Archive-name: omega2/Part05
#! /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 5 (of 19)."
# Contents: oaux2.c ofile.c
# Wrapped by billr@saab on Wed Jul 13 10:46:43 1988
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'oaux2.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'oaux2.c'\"
else
echo shar: Extracting \"'oaux2.c'\" \(29781 characters\)
sed "s/^X//" >'oaux2.c' <<'END_OF_FILE'
X/* omega copyright (C) by Laurence Raphael Brothers, 1987,1988 */
X
X/* oaux2.c */
X
X/* some functions called by ocom.c, also see oaux1.c and oaux3.c*/
X/* This is a real grab bag file. It contains functions used by
X oaux1 and o.c, as well as elsewhere. It is mainly here so oaux1.c
X and oaux3.c are not huge */
X
X#include "oglob.h"
X
X
X/* Player stats like str, agi, etc give modifications to various abilities
X chances to do things, etc. Positive is good, negative bad. */
Xint statmod(stat)
Xint stat;
X{
X return((stat-10)/2);
X}
X
X
X/* effects of hitting */
Xvoid p_hit (m,dmg,dtype)
Xstruct monster *m;
Xint dmg;
Xint dtype;
X{
X int dmult;
X
X /* chance for critical hit..., 3/10 */
X switch (random_range(10)) {
X case 0:
X if (random_range(100) < Player.level) {
X strcpy(Str3,"You annihilate ");
X dmult = 1000;
X }
X else {
X strcpy(Str3,"You blast ");
X dmult=5;
X }
X break;
X case 1:
X case 2:
X strcpy(Str3,"You smash ");
X dmult=2; break;
X
X default:
X dmult=1;
X if (random_range(10)) strcpy(Str3,"You hit ");
X else switch(random_range(4)) {
X case 0: strcpy(Str3,"You damage "); break;
X case 1: strcpy(Str3,"You inflict bodily harm on "); break;
X case 2: strcpy(Str3,"You injure "); break;
X case 3: strcpy(Str3,"You molest "); break;
X }
X break;
X }
X if (Lunarity == 1) dmult = dmult * 2;
X else if (Lunarity == -1) dmult = dmult / 2;
X if (m->uniqueness == COMMON) strcat(Str3,"the ");
X strcat(Str3,m->monstring);
X strcat(Str3,". ");
X if (Verbosity != TERSE) mprint(Str3);
X else mprint("You hit it.");
X m_damage(m,dmult * random_range(dmg),dtype);
X if ((Verbosity != TERSE) && (random_range(10)==3) && (m->hp > 0))
X mprint("It laughs at the injury and fights on!");
X}
X
X/* and effects of missing */
Xvoid player_miss(m,dtype)
Xstruct monster *m;
Xint dtype;
X{
X if (random_range(30)==1) /* fumble 1 in 30 */
X p_fumble(dtype);
X else {
X if (Verbosity != TERSE) {
X if (random_range(10))
X strcpy(Str3,"You miss ");
X else switch(random_range(4)) {
X case 0: strcpy(Str3,"You flail lamely at "); break;
X case 1: strcpy(Str3,"You only amuse "); break;
X case 2: strcpy(Str3,"You fail to even come close to "); break;
X case 3: strcpy(Str3,"You totally avoid contact with "); break;
X }
X if (m->uniqueness == COMMON) strcat(Str3,"the ");
X strcat(Str3,m->monstring);
X strcat(Str3,". ");
X mprint(Str3);
X }
X else mprint("You missed it.");
X }
X}
X
X/* oh nooooo, a fumble.... */
Xvoid p_fumble(dtype)
Xint dtype;
X{
X mprint("Ooops! You fumbled....");
X switch(random_range(10)) {
X case 0:
X case 1:
X case 2:
X case 3:
X case 4:
X case 5: drop_weapon(); break;
X case 6:
X case 7:
X case 8: break_weapon(); break;
X case 9: mprint("Oh No! You hit yourself!");
X p_damage(Player.dmg,dtype,"stupidity");
X break;
X }
X}
X
X/* try to drop a weapon (from fumbling) */
Xvoid drop_weapon()
X{
X if (Player.possessions[O_WEAPON_HAND] != NULL) {
X strcpy(Str1,"You dropped your ");
X strcat(Str1,Player.possessions[O_WEAPON_HAND]->objstr);
X mprint(Str1);
X morewait();
X p_drop_at(Player.x,Player.y,1,Player.possessions[O_WEAPON_HAND]);
X conform_lost_objects(1,Player.possessions[O_WEAPON_HAND]);
X }
X else mprint("You feel fortunate.");
X}
X
X
X/* try to break a weapon (from fumbling) */
Xvoid break_weapon()
X{
X if (Player.possessions[O_WEAPON_HAND] != NULL) {
X strcpy(Str1,"Your ");
X strcat(Str1,itemid(Player.possessions[O_WEAPON_HAND]));
X strcat(Str1," vibrates in your hand....");
X mprint(Str1);
X damage_item(Player.possessions[O_WEAPON_HAND]);
X morewait();
X }
X}
X
X
X/* hooray */
Xvoid p_win()
X{
X morewait();
X clearmsg();
X print1("You won!");
X morewait();
X display_win();
X endgraf();
X exit(0);
X}
X
X
X/* handle a h,j,k,l, etc., to change x and y by dx and dy */
X/* for targeting in dungeon */
Xvoid movecursor(x,y,dx,dy)
Xint *x,*y;
Xint dx,dy;
X{
X if (inbounds(*x+dx,*y+dy)) {
X *x += dx;
X *y += dy;
X screencheck(*y);
X }
X showcursor(*x,*y);
X}
X
X
X/* is Player immune to damage type dtype */
Xint p_immune(dtype)
Xint dtype;
X{
X return(Player.immunity[dtype]>0);
X}
X
X
X
X
X
X
X/* deal with each possible stati -- values are per move */
X/* this function is executed every move */
X/* A value over 1000 indicates a permanent effect */
Xvoid minute_status_check()
X{
X int i;
X
X if (Player.status[HASTED]>0) {
X if (Player.status[HASTED] < 1000) {
X Player.status[HASTED]--;
X if (Player.status[HASTED]==0) {
X mprint("The world speeds up.");
X calc_melee();
X }
X }
X }
X
X
X if (Player.status[POISONED]>0) {
X Player.status[POISONED]--;
X p_damage(3,POISON,"poison");
X if (Player.status[POISONED] == 0) {
X showflags();
X mprint("You feel better now.");
X }
X }
X
X
X if (Player.immunity[UNSTOPPABLE]>0) {
X for(i=0;i<NUMIMMUNITIES;i++)
X Player.immunity[i]--;
X if (Player.immunity[UNSTOPPABLE]==1)
X mprint("You feel vincible again.");
X }
X
X
X if (Player.status[IMMOBILE]>0) {
X Player.status[IMMOBILE]--;
X if (Player.status[IMMOBILE] == 0)
X mprint("You can move again.");
X }
X
X
X if (Player.status[SLEPT]>0) {
X Player.status[SLEPT]--;
X if (Player.status[SLEPT] == 0) {
X mprint("You woke up.");
X }
X }
X
X if (Player.status[REGENERATING]>0) {
X if ((Player.hp < Player.maxhp) && (Player.mana > 0)){
X Player.hp++;
X Player.mana--;
X dataprint();
X }
X if (Player.status[REGENERATING] < 1000) {
X Player.status[REGENERATING]--;
X if (Player.status[REGENERATING] == 0) {
X mprint("You feel less homeostatic.");
X }
X }
X }
X
X if (Player.status[SLOWED]>0) {
X if (Player.status[SLOWED] < 1000) {
X Player.status[SLOWED]--;
X if (Player.status[SLOWED] == 0) {
X mprint("You feel quicker now.");
X calc_melee();
X }
X }
X }
X
X if (Player.status[RETURNING]>0) {
X Player.status[RETURNING]--;
X if (Player.status[RETURNING] == 150)
X mprint("Your spell slowly hums towards activation...");
X else if (Player.status[RETURNING] == 100)
X mprint("There is an electric tension in the air!");
X else if (Player.status[RETURNING] == 50)
X mprint("A vortex of mana begins to form around you!");
X else if (Player.status[RETURNING] == 10)
X mprint("Your surroundings start to warp and fade!");
X if (Player.status[RETURNING] == 0) {
X mprint("The vortex of mana carries you off!");
X level_return();
X }
X }
X
X if (Player.status[AFRAID]>0) {
X if (Player.status[AFRAID] < 1000) {
X Player.status[AFRAID]--;
X if (Player.status[AFRAID] == 0) {
X mprint("You feel bolder now.");
X }
X }
X }
X
X}
X
X
X
X/* effect of gamma ray radiation... */
Xvoid moon_check()
X{
X /* 24 day lunar cycle */
X Phase = (Phase+1)%24;
X phaseprint();
X Lunarity = 0;
X if (((Player.patron == DRUID) && ((Phase/2 == 3) || (Phase/2 == 9))) ||
X ((Player.alignment > 10) && (Phase/2 == 6)) ||
X ((Player.alignment < -10) && (Phase/2 == 0))) {
X mprint("As the moon rises you feel unusually vital!");
X Lunarity = 1;
X }
X else
X if (((Player.patron == DRUID) && ((Phase/2 == 0) || (Phase/2 == 6))) ||
X ((Player.alignment > 10) && (Phase/2 == 0)) ||
X ((Player.alignment < -10) && (Phase/2 == 6))) {
X mprint("The rise of the moon tokens a strange enervation!");
X Lunarity = -1;
X }
X
X}
X
X
X
X/* check 1/hour for torch to burn out if used */
Xvoid torch_check()
X{
X int i;
X for(i=O_READY_HAND;i<=O_WEAPON_HAND;i++) {
X if (Player.possessions[i]!=NULL)
X if ((Player.possessions[i]->id == THINGID+8) && /*torch */
X (Player.possessions[i]->aux > 0)) {
X Player.possessions[i]->aux--;
X if (Player.possessions[i]->aux==0) {
X mprint("Your torch goes out!!!");
X conform_unused_object(Player.possessions[i]);
X if (Player.possessions[i]->number > 1) {
X Player.possessions[i]->number--;
X Player.possessions[i]->aux = 6;
X }
X else {
X Player.possessions[i]->usef = I_NO_OP;
X Player.possessions[i]->cursestr =
X Player.possessions[i]->truename =
X Player.possessions[i]->objstr =
X salloc("burnt-out torch");
X }
X }
X }
X }
X}
X
X
X
X/* values are in multiples of ten minutes */
X/* values over 1000 indicate a permanent effect */
Xvoid tenminute_status_check()
X{
X if ((Player.status[SHADOWFORM]>0) && (Player.status[SHADOWFORM]<1000)) {
X Player.status[SHADOWFORM]--;
X if (Player.status[SHADOWFORM] == 0) {
X Player.immunity[NORMAL_DAMAGE]--;
X Player.immunity[ACID]--;
X Player.immunity[THEFT]--;
X Player.immunity[INFECTION]--;
X mprint("You feel less shadowy now.");
X }
X }
X
X if ((Player.status[ILLUMINATION]>0) && (Player.status[ILLUMINATION]<1000)) {
X Player.status[ILLUMINATION]--;
X if (Player.status[ILLUMINATION] == 0) {
X mprint("Your light goes out!");
X }
X }
X
X
X if ((Player.status[VULNERABLE]>0) && (Player.status[VULNERABLE]<1000)){
X Player.status[VULNERABLE]--;
X if (Player.status[VULNERABLE] == 0)
X mprint("You feel less endangered.");
X }
X
X
X if ((Player.status[DEFLECTION]>0) && (Player.status[DEFLECTION]<1000)){
X Player.status[DEFLECTION]--;
X if (Player.status[DEFLECTION] == 0)
X mprint("You feel less well defended.");
X }
X
X if ((Player.status[ACCURATE]>0) && (Player.status[ACCURACY]<1000)){
X Player.status[ACCURATE]--;
X if (Player.status[ACCURATE] == 0) {
X calc_melee();
X mprint("The bulls' eyes go away.");
X }
X }
X if ((Player.status[HERO]>0) && (Player.status[HERO]<1000)){
X Player.status[HERO]--;
X if (Player.status[HERO] == 0) {
X calc_melee();
X mprint("You feel less than super.");
X }
X }
X
X if ((Player.status[LEVITATING]>0) && (Player.status[LEVITATING]<1000)){
X Player.status[LEVITATING]--;
X if (Player.status[LEVITATING] == 0)
X mprint("You're no longer walking on air.");
X }
X
X if (Player.status[DISEASED]>0) {
X Player.status[DISEASED]--;
X if (Player.status[DISEASED] == 0) {
X showflags();
X mprint("You feel better now.");
X }
X }
X
X
X if ((Player.status[INVISIBLE] > 0) && (Player.status[INVISIBLE]<1000)){
X Player.status[INVISIBLE]--;
X if (Player.status[INVISIBLE] == 0)
X mprint("You feel more opaque now.");
X }
X
X if ((Player.status[BLINDED]>0) && (Player.status[BLINDED]<1000)) {
X Player.status[BLINDED]--;
X if (Player.status[BLINDED] == 0)
X mprint("You can see again.");
X }
X
X if ((Player.status[TRUESIGHT]>0) && (Player.status[TRUESIGHT]<1000)) {
X Player.status[TRUESIGHT]--;
X if (Player.status[TRUESIGHT] == 0)
X mprint("You feel less keen now.");
X }
X
X if ((Player.status[BERSERK]>0) && (Player.status[BERSERK]<1000)) {
X Player.status[BERSERK]--;
X if (Player.status[BERSERK] == 0)
X mprint("You stop foaming at the mouth.");
X }
X
X if ((Player.status[ALERT]>0) && (Player.status[ALERT] < 1000)) {
X Player.status[ALERT]--;
X if (Player.status[ALERT] == 0)
X mprint("You feel less alert now.");
X }
X
X if ((Player.status[BREATHING]>0) && (Player.status[BREATHING] < 1000)) {
X Player.status[BREATHING]--;
X if (Player.status[BREATHING] == 0)
X mprint("You feel somewhat congested.");
X }
X
X if ((Player.status[DISPLACED]>0) && (Player.status[DISPLACED] < 1000)) {
X Player.status[DISPLACED]--;
X if (Player.status[DISPLACED]==0)
X mprint("You feel a sense of position.");
X }
X timeprint();
X dataprint();
X}
X
X
X
X/* Increase in level at appropriate experience gain */
Xvoid gain_level()
X{
X int gained=FALSE;
X morewait();
X while (expval(Player.level+1) <= Player.xp) {
X gained = TRUE;
X Player.level++;
X print1("You have attained a new experience level!");
X print2("You are now ");
X nprint2(getarticle(levelname(Player.level)));
X nprint2(levelname(Player.level));
X Player.maxhp += random_range(Player.con)+1;
X Player.mana = Player.maxmana = calcmana();
X morewait();
X }
X if (gained) clearmsg();
X calc_melee();
X}
X
X/* experience requirements */
Xint expval(plevel)
Xint plevel;
X{
X switch(plevel) {
X case 0:return(0);break;
X case 1:return(20);break;
X case 2:return(50);break;
X case 3:return(200);break;
X case 4:return(500);break;
X case 5:return(1000);break;
X case 6:return(2000);break;
X case 7:return(3000);break;
X case 8:return(5000);break;
X case 9:return(7000);break;
X case 10:return(10000);break;
X default:return((plevel-9) * 10000); break;
X }
X}
X
X/* If an item is unidentified, it isn't worth much to those who would buy it */
Xint item_value(item)
Xpob item;
X{
X if (item->known == 0) {
X if (item->objchar == THING) return(1);
X else return(true_item_value(item) / 10);
X }
X else if (item->known == 1) {
X if (item->objchar == THING) return(item->basevalue);
X else return(item->basevalue / 2);
X }
X else return(true_item_value(item));
X}
X
X
X/* figures value based on item base-value, charge, plus, and blessing */
Xint true_item_value(item)
Xpob item;
X{
X float value = item->basevalue;
X
X if (item->objchar == THING) return(item->basevalue);
X else {
X if (item->objchar == STICK) value *= (1.0 + (item->charge/20.0));
X if (item->plus > -1.0) value *= (1.0 + (item->plus/4.0));
X else value *= (1.0/abs(item->plus));
X if (item->blessing > 0) value *= 2.0;
X return((int) value);
X }
X}
X
X/* kill off player if he isn't got the "breathing" status */
Xvoid p_drown()
X{
X if (Player.status[BREATHING] > 0)
X mprint("Your breathing is unaffected!");
X else {
X print1("You try to hold your breath....");
X morewait();
X print2("You choke....");
X morewait();
X print3("Your lungs fill...");
X morewait();
X p_death("drowning");
X }
X}
X
X
X/* the effect of some weapon on monster m, with dmgmod a bonus to damage */
Xvoid weapon_use(dmgmod,weapon,m)
Xint dmgmod;
Xpob weapon;
Xstruct monster *m;
X{
X int aux = (weapon==NULL ? -2 : weapon->aux); /* bare hands */
X switch(aux) {
X case -2: weapon_bare_hands(dmgmod,m); break;
X default:
X case I_NO_OP: weapon_normal_hit(dmgmod,weapon,m); break;
X case I_ACIDWHIP: weapon_acidwhip(dmgmod,weapon,m); break;
X case I_TANGLE: weapon_tangle(dmgmod,weapon,m); break;
X case I_ARROW: weapon_arrow(dmgmod,weapon,m); break;
X case I_BOLT: weapon_bolt(dmgmod,weapon,m); break;
X case I_DEMONBLADE: weapon_demonblade(dmgmod,weapon,m); break;
X case I_LIGHTSABRE: weapon_lightsabre(dmgmod,weapon,m); break;
X case I_MACE_DISRUPT: weapon_mace_disrupt(dmgmod,weapon,m); break;
X case I_VORPAL: weapon_vorpal(dmgmod,weapon,m); break;
X case I_DESECRATE: weapon_desecrate(dmgmod,weapon,m); break;
X case I_FIRESTAR: weapon_firestar(dmgmod,weapon,m); break;
X case I_DEFEND: weapon_defend(dmgmod,weapon,m); break;
X case I_VICTRIX: weapon_victrix(dmgmod,weapon,m); break;
X case I_SCYTHE: weapon_scythe(dmgmod,weapon,m); break;
X }
X}
X
X
X/* for printing actions in printactions above */
Xchar *actionlocstr(dir)
Xchar dir;
X{
X switch(dir) {
X case 'L': strcpy(Str3,"low."); break;
X case 'C': strcpy(Str3,"center."); break;
X case 'H': strcpy(Str3,"high."); break;
X default: strcpy(Str3,"wildly."); break;
X }
X return(Str3);
X}
X
X
X/* execute player combat actions versus monster m */
Xvoid tacplayer(m)
Xstruct monster *m;
X{
X int i=0;
X
X while (i < strlen(Player.meleestr)) {
X if (m->hp > 0) {
X switch(Player.meleestr[i]) {
X case 't': case 'T':
X if (Player.possessions[O_WEAPON_HAND] == NULL)
X strcpy(Str1,"You punch ");
X else strcpy(Str1,"You thrust ");
X strcat(Str1,actionlocstr(Player.meleestr[i+1]));
X if (Verbosity == VERBOSE) mprint(Str1);
X if (player_hit(2*statmod(Player.dex),Player.meleestr[i+1],m))
X weapon_use(0,Player.possessions[O_WEAPON_HAND],m);
X else player_miss(m,NORMAL_DAMAGE);
X break;
X case 'c': case 'C':
X if (Player.possessions[O_WEAPON_HAND] == NULL)
X strcpy(Str1,"You punch ");
X else if (Player.possessions[O_WEAPON_HAND]->type == CUTTING)
X strcpy(Str1,"You cut ");
X else if (Player.possessions[O_WEAPON_HAND]->type == STRIKING)
X strcpy(Str1,"You strike ");
X else strcpy(Str1,"You attack ");
X strcat(Str1,actionlocstr(Player.meleestr[i+1]));
X if (Verbosity == VERBOSE) mprint(Str1);
X if (player_hit(0,Player.meleestr[i+1],m))
X weapon_use(2*statmod(Player.str),
X Player.possessions[O_WEAPON_HAND],
X m);
X else player_miss(m,NORMAL_DAMAGE);
X break;
X case 'l': case 'L':
X strcpy(Str1,"You lunge ");
X strcat(Str1,actionlocstr(Player.meleestr[i+1]));
X if (Verbosity == VERBOSE) mprint(Str1);
X if (player_hit(Player.level+Player.dex,Player.meleestr[i+1],m))
X weapon_use(Player.level,Player.possessions[O_WEAPON_HAND],m);
X else player_miss(m,NORMAL_DAMAGE);
X break;
X }
X }
X i+=2;
X }
X}
X
X
X
X
X/* checks to see if player hits with hitmod vs. monster m at location hitloc */
Xint player_hit(hitmod,hitloc,m)
Xint hitmod;
Xchar hitloc;
Xstruct monster *m;
X{
X int i=0,blocks=FALSE,goodblocks=0,hit;
X if (m->hp < 1) {
X mprint("Unfortunately, your opponent is already dead!");
X return(FALSE);
X }
X else {
X if (hitloc == 'X') hitloc = random_loc();
X
X transcribe_monster_actions(m);
X
X while (i<strlen(m->meleestr)) {
X if ((m->meleestr[i] == 'B') || (m->meleestr[i] == 'R')) {
X blocks = TRUE;
X if (hitloc == m->meleestr[i+1])
X goodblocks++;
X }
X i+=2;
X }
X
X if (! blocks) goodblocks = -1;
X hit = hitp(Player.hit+hitmod,m->ac+goodblocks*10);
X if ((! hit) && (goodblocks > 0)) {
X if (m->uniqueness == COMMON) {
X strcpy(Str1,"The ");
X strcat(Str1,m->monstring);
X }
X else strcpy(Str1,m->monstring);
X strcat(Str1," blocks it!");
X if (Verbosity == VERBOSE) mprint(Str1);
X }
X return(hit);
X }
X}
X
X
X
X
X
X
X
X/* This function is used to undo all items temporarily, should
Xalways be used in pairs with on being TRUE and FALSE, and may cause
Xanomalous stats and item-usage if used indiscriminately */
X
Xvoid toggle_item_use(on)
Xint on;
X{
X static int used[MAXITEMS];
X int i;
X setgamestatus(SUPPRESS_PRINTING);
X if (on)
X for(i=0;i<MAXITEMS;i++) {
X used[i] = FALSE;
X if (Player.possessions[i] != NULL) {
X if (used[i] = Player.possessions[i]->used) {
X Player.possessions[i]->used = FALSE;
X item_use(Player.possessions[i]);
X }
X }
X }
X else {
X for(i=1;i<MAXITEMS;i++)
X if (used[i]) {
X Player.possessions[i]->used = TRUE;
X item_use(Player.possessions[i]);
X }
X calc_melee();
X showflags();
X dataprint();
X timeprint();
X }
X resetgamestatus(SUPPRESS_PRINTING);
X}
X
X
Xvoid enter_site(site)
Xchar site;
X{
X switch(site) {
X case CITY: change_environment(E_CITY); break;
X case VILLAGE: change_environment(E_VILLAGE); break;
X case CAVES: change_environment(E_CAVES); break;
X case CASTLE: change_environment(E_CASTLE); break;
X case VOLCANO: change_environment(E_VOLCANO); break;
X case TEMPLE: change_environment(E_TEMPLE); break;
X case DRAGONLAIR: change_environment(E_DLAIR); break;
X case STARPEAK: change_environment(E_STARPEAK); break;
X case MAGIC_ISLE: change_environment(E_MAGIC_ISLE); break;
X default:print3("There's nothing to enter here!"); break;
X }
X}
X
X
X
X/* Switches context dungeon/countryside/city, etc */
Xvoid change_environment(new_environment)
Xchar new_environment;
X{
X int i,emerging = FALSE;
X pob o;
X
X Player.sx = -1; Player.sy = -1; /* reset sanctuary if there was one */
X
X resetgamestatus(FAST_MOVE);
X
X Last_Environment = Current_Environment;
X if (Last_Environment == E_COUNTRYSIDE) {
X LastCountryLocX = Player.x;
X LastCountryLocY = Player.y;
X }
X if (((Last_Environment == E_CITY) ||
X (Last_Environment == E_VILLAGE)) &&
X ((new_environment == E_MANSION) ||
X (new_environment == E_HOUSE) ||
X (new_environment == E_HOVEL) ||
X (new_environment == E_SEWERS) ||
X (new_environment == E_ARENA))) {
X LastTownLocX = Player.x;
X LastTownLocY = Player.y;
X }
X else if (((Last_Environment == E_MANSION) ||
X (Last_Environment == E_HOUSE) ||
X (Last_Environment == E_HOVEL) ||
X (Last_Environment == E_SEWERS) ||
X (Last_Environment == E_ARENA)) &&
X ((new_environment == E_CITY) ||
X (new_environment == E_VILLAGE))) {
X Player.x = LastTownLocX;
X Player.y = LastTownLocY;
X emerging = TRUE;
X }
X
X if (Last_Environment == E_ARENA)
X Arena_Victory = Arena_Monster->hp < 1;
X
X
X Current_Environment = new_environment;
X/* ScreenOffset = Player.y - (ScreenLength/2); */
X switch(new_environment) {
X case E_ARENA:
X LENGTH = 16;
X WIDTH = 64;
X Player.x = 5;
X Player.y = 7;
X setgamestatus(ARENA_MODE);
X locprint("The Rampart Arena");
X load_arena();
X erase_level();
X ScreenOffset = 0;
X show_screen();
X break;
X case E_ABYSS:
X LENGTH = 16;
X WIDTH = 64;
X Player.x = 32;
X Player.y = 15;
X locprint("The Adept's Challenge");
X load_abyss();
X abyss_file();
X lose_all_items();
X erase_level();
X ScreenOffset = 0;
X show_screen();
X break;
X case E_CIRCLE:
X LENGTH = 16;
X WIDTH = 64;
X Player.x = 32;
X Player.y = 14;
X locprint("The Astral Demesne of the Circle of Sorcerors");
X load_circle();
X if (find_item(&o,ARTIFACTID+21,-1)) {
X print1("A bemused voice says:");
X print2("'Why are you here? You already have the Star Gem!'");
X morewait();
X }
X else if (Player.rank[CIRCLE] > 0) {
X print1("You hear the voice of the Prime Sorceror:");
X print2("'Congratulations on your attainment of the Circle's Demesne.'");
X morewait();
X print1("For the honor of the Circle, you may take the Star Gem");
X print2("and destroy it on the acme of Star Peak.");
X morewait();
X print1("Beware the foul LawBringer who resides there...");
X print2("By the way, some of the members of the Circle seem to");
X morewait();
X print1("have become a bit jealous of your success --");
X print2("I'd watch out for them if I were you.");
X morewait();
X }
X else if (Player.alignment > 0) {
X print1("A mysterious ghostly image materializes in front of you.");
X print2("It speaks: 'Greetings, fellow abider in Law. I am called");
X morewait();
X print1("The LawBringer. If you wish to advance our cause, obtain");
X print2("the mystic Star Gem and return it to me on Star Peak.");
X morewait();
X print1("Beware the power of the evil Circle of Sorcerors and the");
X print2("forces of Chaos which guard the gem.'");
X morewait();
X print1("The strange form fades slowly.");
X morewait();
X }
X erase_level();
X ScreenOffset = 0;
X show_screen();
X break;
X case E_COURT:
X WIDTH = 64;
X LENGTH = 24;
X Player.x = 32;
X Player.y = 2;
X load_court();
X erase_level();
X ScreenOffset = 0;
X show_screen();
X break;
X case E_MANSION:
X WIDTH = 64;
X LENGTH = 16;
X Player.y = 8;
X Player.x = 2;
X load_house(E_MANSION);
X erase_level();
X ScreenOffset = 0;
X show_screen();
X break;
X case E_HOUSE:
X WIDTH = 64;
X LENGTH = 16;
X Player.y = 13;
X Player.x = 2;
X load_house(E_HOUSE);
X erase_level();
X ScreenOffset = 0;
X show_screen();
X break;
X case E_HOVEL:
X WIDTH = 64;
X LENGTH = 16;
X Player.y = 9;
X Player.x = 2;
X load_house(E_HOVEL);
X erase_level();
X ScreenOffset = 0;
X show_screen();
X break;
X case E_DLAIR:
X WIDTH = 64;
X LENGTH = 16;
X Player.y = 9;
X Player.x = 2;
X load_dlair(gamestatusp(KILLED_DRAGONLORD));
X erase_level();
X ScreenOffset = 0;
X show_screen();
X break;
X case E_STARPEAK:
X WIDTH = 64;
X LENGTH = 16;
X Player.y = 9;
X Player.x = 2;
X load_speak(gamestatusp(KILLED_LAWBRINGER));
X erase_level();
X ScreenOffset = 0;
X show_screen();
X break;
X case E_MAGIC_ISLE:
X WIDTH = 64;
X LENGTH = 16;
X Player.y = 15;
X Player.x = 63;
X load_misle(gamestatusp(KILLED_EATER));
X erase_level();
X ScreenOffset = 0;
X show_screen();
X break;
X case E_TEMPLE:
X WIDTH = 64;
X LENGTH = 16;
X load_temple(Country[Player.x][Player.y].aux);
X Player.y = 15;
X Player.x = 32;
X erase_level();
X ScreenOffset = 0;
X show_screen();
X break;
X case E_CITY:
X WIDTH = 64;
X LENGTH = 64;
X if (emerging) {
X print1("You emerge onto the street.");
X emerging = FALSE;
X }
X else {
X print1("You pass through the massive gates of Rampart, the city.");
X Player.x = 62;
X Player.y = 21;
X }
X if (City == NULL) load_city();
X Level = City;
X locprint("The City of Rampart.");
X erase_level();
X ScreenOffset = Player.y - (ScreenLength/2);
X show_screen();
X break;
X case E_VILLAGE:
X WIDTH = 64;
X LENGTH = 16;
X if (emerging) {
X print1("You emerge onto the street.");
X emerging = FALSE;
X }
X else {
X print1("You enter a small rural village.");
X /* different villages per different locations */
X switch(Country[Player.x][Player.y].aux) {
X case 1:
X Player.x = 0;
X Player.y = 6;
X Villagenum = 1;
X break;
X default:
X print3("Very strange, a nonexistent village.");
X case 2:
X Player.x = 39;
X Player.y = 15;
X Villagenum = 2;
X break;
X case 3:
X Player.x = 63;
X Player.y = 8;
X Villagenum = 3;
X break;
X case 4:
X Player.x = 32;
X Player.y = 15;
X Villagenum = 4;
X break;
X case 5:
X Player.x = 2;
X Player.y = 8;
X Villagenum = 5;
X break;
X case 6:
X Player.x = 2;
X Player.y = 2;
X Villagenum = 6;
X break;
X }
X }
X if ((! emerging) || (TempLevel == NULL)) load_village(Villagenum);
X else if (TempLevel->environment != E_VILLAGE) load_village(Villagenum);
X else Level = TempLevel;
X switch(Villagenum) {
X case 1: locprint("The Village of Star View."); break;
X case 2: locprint("The Village of Woodmere."); break;
X case 3: locprint("The Village of Stormwatch."); break;
X case 4: locprint("The Village of Thaumaris."); break;
X case 5: locprint("The Village of Skorch."); break;
X case 6: locprint("The Village of Whorfen."); break;
X default: locprint("A Deviant Village."); break;
X }
X erase_level();
X ScreenOffset = 0;
X show_screen();
X break;
X case E_CAVES:
X WIDTH = 64;
X LENGTH = 64;
X print1("You enter a dark cleft in a hillside;");
X print2("You note signs of recent passage in the dirt nearby.");
X if (gamestatusp(MOUNTED)) {
X morewait();
X print1("Seeing as you might not be coming back, you feel compelled");
X print2("to let your horse go, rather than keep him hobbled outside.");
X resetgamestatus(MOUNTED);
X calc_melee();
X }
X MaxDungeonLevels = CAVELEVELS;
X if (Current_Dungeon != E_CAVES) {
X free_dungeon();
X Dungeon = NULL;
X Level = NULL;
X Current_Dungeon = E_CAVES;
X }
X change_level(0,1,FALSE);
X break;
X case E_VOLCANO:
X WIDTH = 64;
X LENGTH = 64;
X print1("You pass down through the glowing crater.");
X if (gamestatusp(MOUNTED)) {
X morewait();
X print1("Seeing as you might not be coming back, you feel compelled");
X print2("to let your horse go, rather than keep him hobbled outside.");
X resetgamestatus(MOUNTED);
X calc_melee();
X }
X MaxDungeonLevels = VOLCANOLEVELS;
X if (Current_Dungeon != E_VOLCANO) {
X free_dungeon();
X Dungeon = NULL;
X Level = NULL;
X Current_Dungeon = E_VOLCANO;
X }
X change_level(0,1,FALSE);
X break;
X case E_ASTRAL:
X WIDTH = 64;
X LENGTH = 64;
X print1("You are in a weird flickery maze.");
X if (gamestatusp(MOUNTED)) {
X print2("Your horse doesn't seem to have made it....");
X resetgamestatus(MOUNTED);
X calc_melee();
X }
X MaxDungeonLevels = ASTRALLEVELS;
X if (Current_Dungeon != E_ASTRAL) {
X free_dungeon();
X Dungeon = NULL;
X Level = NULL;
X Current_Dungeon = E_ASTRAL;
X }
X change_level(0,1,FALSE);
X break;
X case E_CASTLE:
X WIDTH = 64;
X LENGTH = 64;
X print1("You cross the drawbridge. Strange forms move beneath the water.");
X if (gamestatusp(MOUNTED)) {
X morewait();
X print1("Seeing as you might not be coming back, you feel compelled");
X print2("to let your horse go, rather than keep him hobbled outside.");
X resetgamestatus(MOUNTED);
X }
X MaxDungeonLevels = CASTLELEVELS;
X if (Current_Dungeon != E_CASTLE) {
X free_dungeon();
X Dungeon = NULL;
X Level = NULL;
X Current_Dungeon = E_CASTLE;
X }
X change_level(0,1,FALSE);
X break;
X case E_SEWERS:
X WIDTH = 64;
X LENGTH = 64;
X print1("You pry open a manhole and descend into the sewers below.");
X if (gamestatusp(MOUNTED)) {
X print2("You horse waits patiently outside the sewer entrance....");
X dismount_steed();
X }
X MaxDungeonLevels = SEWERLEVELS;
X if (Current_Dungeon != E_SEWERS) {
X free_dungeon();
X Dungeon = NULL;
X Level = NULL;
X Current_Dungeon = E_SEWERS;
X }
X change_level(0,1,FALSE);
X break;
X case E_COUNTRYSIDE:
X WIDTH = 64;
X LENGTH = 64;
X print1("You return to the fresh air of the open countryside.");
X if (Last_Environment == E_CITY) {
X Player.x = 27;
X Player.y = 19;
X }
X else {
X Player.x = LastCountryLocX;
X Player.y = LastCountryLocY;
X }
X for(i=0;i<9;i++)
X Country[Player.x+Dirs[0][i]][Player.y+Dirs[1][i]].explored = TRUE;
X erase_level();
X ScreenOffset = Player.y - (ScreenLength/2);
X show_screen();
X break;
X case E_TACTICAL_MAP:
X WIDTH = 64;
X LENGTH = 16;
X print1("You are now on the tactical screen; exit off any side to leave");
X make_country_screen(Country[Player.x][Player.y].current_terrain_type);
X make_country_monsters(Country[Player.x][Player.y].current_terrain_type);
X Player.x = WIDTH/2;
X Player.y = LENGTH/2;
X erase_level();
X ScreenOffset = 0;
X show_screen();
X break;
X case E_NEVER_NEVER_LAND: default:
X print1("There must be some mistake. You don't look like Peter Pan.");
X print2("(But here you are in Never-Never Land)");
X erase_level();
X ScreenOffset = Player.y - (ScreenLength/2);
X show_screen();
X break;
X }
X}
X
X
X
END_OF_FILE
if test 29781 -ne `wc -c <'oaux2.c'`; then
echo shar: \"'oaux2.c'\" unpacked with wrong size!
fi
# end of 'oaux2.c'
fi
if test -f 'ofile.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'ofile.c'\"
else
echo shar: Extracting \"'ofile.c'\" \(21529 characters\)
sed "s/^X//" >'ofile.c' <<'END_OF_FILE'
X/* omega (c) 1987,1988 by Laurence Raphael Brothers */
X/* ofile.c */
X/* functions with file access in them. Also some direct calls to
X curses functions */
X
X#include <curses.h>
X#include <sys/file.h>
X#include "oglob.h"
X
X#ifndef F_OK
X#define F_OK 00
X#define R_OK 04
X#define W_OK 02
X#endif
X
XFILE *checkfopen(filestring,optionstring)
Xchar *filestring,*optionstring;
X{
X FILE *fd;
X char response;
X fd = fopen(filestring,optionstring);
X clearmsg();
X while (fd == NULL) {
X print3("Warning! Error opening file:");
X nprint3(filestring);
X print1(" Abort or Retry? [ar] ");
X do response = mcigetc(); while ((response != 'a') && (response != 'r'));
X if (response == 'r') fd = fopen(filestring,optionstring);
X else {
X print2("Sorry 'bout that.... Bye!");
X morewait();
X endgraf();
X exit(0);
X }
X }
X return(fd);
X}
X
Xvoid commandlist()
X{
X FILE *fd;
X strcpy(Str1,OMEGALIB);
X if (Current_Environment == E_COUNTRYSIDE)
X strcat(Str1,"occmds.txt");
X else strcat(Str1,"ocmds.txt");
X fd = checkfopen(Str1,"r");
X showfile(fd);
X fclose(fd);
X clear();
X refresh();
X xredraw();
X}
X
X
Xvoid user_intro()
X{
X FILE *fd;
X strcpy(Str1,OMEGALIB);
X strcat(Str1,"ointro.txt");
X fd = checkfopen(Str1,"r");
X showfile(fd);
X fclose(fd);
X clear();
X refresh();
X xredraw();
X}
X
Xvoid show_license()
X{
X FILE *fd;
X strcpy(Str1,OMEGALIB);
X strcat(Str1,"olicense.txt");
X fd = checkfopen(Str1,"r");
X showfile(fd);
X fclose(fd);
X clear();
X refresh();
X xredraw();
X}
X
X
X
Xvoid abyss_file()
X{
X FILE *fd;
X strcpy(Str1,OMEGALIB);
X strcat(Str1,"oabyss.txt");
X fd = checkfopen(Str1,"r");
X showfile(fd);
X fclose(fd);
X clear();
X refresh();
X}
X
X
X
X
Xvoid inv_help()
X{
X FILE *fd;
X strcpy(Str1,OMEGALIB);
X strcat(Str1,"ohelp3.txt");
X fd = checkfopen(Str1,"r");
X showfile(fd);
X fclose(fd);
X clear();
X refresh();
X xredraw();
X}
X
X
X
Xvoid combat_help()
X{
X FILE *fd;
X strcpy(Str1,OMEGALIB);
X strcat(Str1,"ohelp5.txt");
X fd = checkfopen(Str1,"r");
X showfile(fd);
X fclose(fd);
X clear();
X refresh();
X xredraw();
X}
X
X
X
X
Xvoid cityguidefile()
X{
X FILE *fd;
X strcpy(Str1,OMEGALIB);
X strcat(Str1,"oscroll2.txt");
X fd = checkfopen(Str1,"r");
X showfile(fd);
X fclose(fd);
X clear();
X refresh();
X xredraw();
X}
X
X
Xvoid wishfile()
X{
X FILE *fd;
X strcpy(Str1,OMEGALIB);
X strcat(Str1,"oscroll3.txt");
X fd = checkfopen(Str1,"r");
X showfile(fd);
X fclose(fd);
X clear();
X refresh();
X xredraw();
X}
X
Xvoid adeptfile()
X{
X FILE *fd;
X strcpy(Str1,OMEGALIB);
X strcat(Str1,"oscroll4.txt");
X fd = checkfopen(Str1,"r");
X showfile(fd);
X fclose(fd);
X clear();
X refresh();
X xredraw();
X}
X
Xvoid theologyfile()
X{
X FILE *fd;
X strcpy(Str1,OMEGALIB);
X strcat(Str1,"oscroll1.txt");
X fd = checkfopen(Str1,"r");
X showfile(fd);
X fclose(fd);
X clear();
X refresh();
X xredraw();
X}
X
X
Xvoid showmotd()
X{
X FILE *fd;
X strcpy(Str1,OMEGALIB);
X strcat(Str1,"omotd.txt");
X fd = checkfopen(Str1,"r");
X showfile(fd);
X fclose(fd);
X clear();
X refresh();
X}
X
X
X
X
X/* display a file page at a time */
Xvoid showfile(fd)
XFILE *fd;
X{
X int c,d=' ';
X int x,y;
X clear();
X refresh();
X c = fgetc(fd);
X while ((c != EOF)&&((char) d != 'q')&&((char) d!=ESCAPE)) {
X getyx(stdscr,y,x);
X if (y > ScreenLength) {
X printw("\n-More-");
X refresh();
X d = wgetch(stdscr);
X clear();
X }
X printw("%c",(char) c);
X c = fgetc(fd);
X }
X if (((char) d != 'q')&&((char) d!=ESCAPE)) {
X printw("\n-Done-");
X refresh();
X getch();
X }
X}
X
X
X
Xvoid showscores()
X{
X FILE *fd;
X int i;
X strcpy(Str1,OMEGALIB);
X strcat(Str1,"omega.hi");
X fd = checkfopen(Str1,"r");
X filescanstring(fd,Hiscorer);
X filescanstring(fd,Hidescrip);
X fscanf(fd,"%d\n%d\n%d\n",&Hiscore,&Hilevel,&Hibehavior);
X filescanstring(fd,Chaoslord);
X fscanf(fd,"%d\n%d\n%d\n",&Chaoslordlevel,&Chaos,&Chaoslordbehavior);
X filescanstring(fd,Lawlord);
X fscanf(fd,"%d\n%d\n%d\n",&Lawlordlevel,&Law,&Lawlordbehavior);
X filescanstring(fd,Duke);
X fscanf(fd,"%d\n%d\n",&Dukelevel,&Dukebehavior);
X filescanstring(fd,Justiciar);
X fscanf(fd,"%d\n%d\n",&Justiciarlevel,&Justiciarbehavior);
X filescanstring(fd,Commandant);
X fscanf(fd,"%d\n%d\n",&Commandantlevel,&Commandantbehavior);
X filescanstring(fd,Champion);
X fscanf(fd,"%d\n%d\n",&Championlevel,&Championbehavior);
X filescanstring(fd,Archmage);
X fscanf(fd,"%d\n%d\n",&Archmagelevel,&Archmagebehavior);
X filescanstring(fd,Prime);
X fscanf(fd,"%d\n%d\n",&Primelevel,&Primebehavior);
X filescanstring(fd,Shadowlord);
X fscanf(fd,"%d\n%d\n",&Shadowlordlevel,&Shadowlordbehavior);
X for(i=1;i<7;i++) {
X filescanstring(fd,Priest[i]);
X fscanf(fd,"%d\n%d\n",&(Priestlevel[i]),&(Priestbehavior[i]));
X }
X fclose(fd);
X clear();
X printw("High Score: %d",Hiscore);
X printw(", by %s (%s)",Hiscorer,levelname(Hilevel));
X printw("\n%s\n",Hidescrip);
X printw("\nLord of Chaos: %s (%s)",Chaoslord,levelname(Chaoslordlevel));
X printw("\nLord of Law: %s (%s)",Lawlord,levelname(Lawlordlevel));
X printw("\n\nDuke of Rampart: ");
X printw("%s (%s)",Duke,levelname(Dukelevel));
X printw("\nJusticiar: ");
X printw("%s (%s)",Justiciar,levelname(Justiciarlevel));
X printw("\nCommandant: ");
X printw("%s (%s)",Commandant,levelname(Commandantlevel));
X printw("\nChampion: ");
X printw("%s (%s)",Champion,levelname(Championlevel));
X printw("\nArchmage: ");
X printw("%s (%s)",Archmage,levelname(Archmagelevel));
X printw("\nPrime Sorceror: ");
X printw("%s (%s)",Prime,levelname(Primelevel));
X printw("\nShadowlord: ");
X printw("%s (%s)",Shadowlord,levelname(Shadowlordlevel));
X printw("\n\nHigh Priests:");
X printw("\n of Odin: ");
X printw("%s (%s)",Priest[ODIN],levelname(Priestlevel[ODIN]));
X printw("\n of Set: ");
X printw("%s (%s)",Priest[SET],levelname(Priestlevel[SET]));
X printw("\n of Athena: ");
X printw("%s (%s)",Priest[ATHENA],levelname(Priestlevel[ATHENA]));
X printw("\n of Hecate: ");
X printw("%s (%s)",Priest[HECATE],levelname(Priestlevel[HECATE]));
X printw("\n of the Lords of Destiny: ");
X printw("%s (%s)",Priest[DESTINY],levelname(Priestlevel[DESTINY]));
X printw("\nThe ArchDruid: ");
X printw("%s (%s)",Priest[DRUID],levelname(Priestlevel[DRUID]));
X printw("\n\nHit any key to continue.");
X refresh();
X wgetch(stdscr);
X}
X
X
X/* writes a new high score file */
Xvoid checkhigh(descrip,behavior)
Xchar *descrip;
Xint behavior;
X{
X int i,points;
X FILE *fd;
X
X if (FixedPoints > 0) points = FixedPoints;
X else points = calc_points();
X
X if (! gamestatusp(CHEATED)) {
X strcpy(Str1,OMEGALIB);
X strcat(Str1,"omega.hi");
X fd = checkfopen(Str1,"w");
X
X if (Hiscore < points) {
X morewait();
X mprint("Yow! A new high score!");
X fprintf(fd,"%s\n",Player.name);
X fprintf(fd,"%s\n",descrip);
X fprintf(fd,"%d\n",points);
X fprintf(fd,"%d\n",Player.level);
X fprintf(fd,"%d\n",behavior);
X }
X else {
X fprintf(fd,"%s\n",Hiscorer);
X fprintf(fd,"%s\n",Hidescrip);
X fprintf(fd,"%d\n",Hiscore);
X fprintf(fd,"%d\n",Hilevel);
X fprintf(fd,"%d\n",Hibehavior);
X }
X
X
X
X if (Player.alignment < Chaos) {
X morewait();
X mprint("Criminy! A new Lord of Chaos!");
X fprintf(fd,"%s\n",Player.name);
X fprintf(fd,"%d\n",Player.level);
X fprintf(fd,"%d\n",Player.alignment);
X fprintf(fd,"%d\n",behavior);
X }
X else {
X fprintf(fd,"%s\n",Chaoslord);
X fprintf(fd,"%d\n",Chaoslordlevel);
X fprintf(fd,"%d\n",Chaos);
X fprintf(fd,"%d\n",Chaoslordbehavior);
X }
X
X
X
X
X
X
X if (Player.alignment > Law) {
X morewait();
X mprint("Gosh! A new Lord of Law!");
X fprintf(fd,"%s\n",Player.name);
X fprintf(fd,"%d\n",Player.level);
X fprintf(fd,"%d\n",Player.alignment);
X fprintf(fd,"%d\n",behavior);
X }
X else {
X fprintf(fd,"%s\n",Lawlord);
X fprintf(fd,"%d\n",Lawlordlevel);
X fprintf(fd,"%d\n",Law);
X fprintf(fd,"%d\n",Lawlordbehavior);
X }
X
X
X
X
X fprintf(fd,"%s",Duke);
X fprintf(fd,"\n%d",Dukelevel);
X if (Player.rank[NOBILITY] == DUKE)
X fprintf(fd,"\n%d",behavior);
X else fprintf(fd,"\n%d",Dukebehavior);
X fprintf(fd,"\n%s",Justiciar);
X fprintf(fd,"\n%d",Justiciarlevel);
X if (Player.rank[ORDER] == JUSTICIAR)
X fprintf(fd,"\n%d",behavior);
X else fprintf(fd,"\n%d",Justiciarbehavior);
X fprintf(fd,"\n%s",Commandant);
X fprintf(fd,"\n%d",Commandantlevel);
X if (Player.rank[LEGION] == COMMANDANT)
X fprintf(fd,"\n%d",behavior);
X else fprintf(fd,"\n%d",Commandantbehavior);
X fprintf(fd,"\n%s",Champion);
X fprintf(fd,"\n%d",Championlevel);
X if (Player.rank[ARENA] == CHAMPION)
X fprintf(fd,"\n%d",behavior);
X else fprintf(fd,"\n%d",Championbehavior);
X fprintf(fd,"\n%s",Archmage);
X fprintf(fd,"\n%d",Archmagelevel);
X if (Player.rank[COLLEGE] == ARCHMAGE)
X fprintf(fd,"\n%d",behavior);
X else fprintf(fd,"\n%d",Archmagebehavior);
X fprintf(fd,"\n%s",Prime);
X fprintf(fd,"\n%d",Primelevel);
X if (Player.rank[CIRCLE] == PRIME)
X fprintf(fd,"\n%d",behavior);
X else fprintf(fd,"\n%d",Primebehavior);
X fprintf(fd,"\n%s",Shadowlord);
X fprintf(fd,"\n%d",Shadowlordlevel);
X if (Player.rank[THIEVES] == SHADOWLORD)
X fprintf(fd,"\n%d",behavior);
X else fprintf(fd,"\n%d",Shadowlordbehavior);
X for(i=1;i<7;i++) {
X fprintf(fd,"\n%s",Priest[i]);
X fprintf(fd,"\n%d",Priestlevel[i]);
X if ((Player.rank[PRIESTHOOD] == HIGHPRIEST) && (Player.patron == i))
X fprintf(fd,"\n%d",behavior);
X else fprintf(fd,"\n%d",Priestbehavior[i]);
X }
X fprintf(fd,"\n");
X fclose(fd);
X }
X}
X
Xvoid extendlog(descrip,lifestatus)
Xchar *descrip;
Xint lifestatus;
X{
X FILE *fd;
X char username[60];
X int npcbehavior;
X strcpy(username,getlogin());
X if ((Player.level > 0) && (! gamestatusp(CHEATED))) {
X npcbehavior=fixnpc(lifestatus);
X checkhigh(descrip,npcbehavior);
X strcpy(Str1,OMEGALIB);
X strcat(Str1,"omega.log");
X fd = checkfopen(Str1,"a");
X fprintf(fd,
X " %d %d %d %s\n",
X lifestatus,
X Player.level,
X npcbehavior,
X Player.name);
X fclose(fd);
X }
X}
X
X
X
X
X
X/* reads a string from a file. If it is a line with more than 80 char's,
X then remainder of line to \n is consumed */
Xvoid filescanstring(fd,fstr)
XFILE *fd;
Xchar *fstr;
X{
X int i= -1;
X int byte='x';
X while ((i<80) && (byte != '\n') && (byte != EOF)) {
X i++;
X byte=fgetc(fd);
X fstr[i] = byte;
X }
X if (byte != '\n')
X while((byte!='\n') && (byte != EOF))
X byte=fgetc(fd);
X fstr[i]=0;
X}
X
X
X/* Checks existence of omega data files */
X/* Returns 1 if OK, 0 if impossible to run, -1 if possible but not OK */
Xint filecheck()
X{
X int impossible=FALSE,badbutpossible=FALSE;
X int result;
X
X strcpy(Str1,OMEGALIB);
X strcat(Str1,"ocity.dat");
X result = access(Str1,F_OK|R_OK);
X if (result == -1) {
X impossible = TRUE;
X printf("\nWarning! File not accessible:");
X printf(Str1);
X }
X
X strcpy(Str1,OMEGALIB);
X strcat(Str1,"ocountry.dat");
X result = access(Str1,F_OK|R_OK);
X if (result == -1) {
X impossible = TRUE;
X printf("\nWarning! File not accessible:");
X printf(Str1);
X }
X
X strcpy(Str1,OMEGALIB);
X strcat(Str1,"odlair.dat");
X result = access(Str1,F_OK|R_OK);
X if (result == -1) {
X impossible = TRUE;
X printf("\nWarning! File not accessible:");
X printf(Str1);
X }
X
X strcpy(Str1,OMEGALIB);
X strcat(Str1,"omisle.dat");
X result = access(Str1,F_OK|R_OK);
X if (result == -1) {
X impossible = TRUE;
X printf("\nWarning! File not accessible:");
X printf(Str1);
X }
X strcpy(Str1,OMEGALIB);
X strcat(Str1,"ocourt.dat");
X result = access(Str1,F_OK|R_OK);
X if (result == -1) {
X impossible = TRUE;
X printf("\nWarning! File not accessible:");
X printf(Str1);
X }
X
X strcpy(Str1,OMEGALIB);
X strcat(Str1,"ospeak.dat");
X result = access(Str1,F_OK|R_OK);
X if (result == -1) {
X impossible = TRUE;
X printf("\nWarning! File not accessible:");
X printf(Str1);
X }
X
X strcpy(Str1,OMEGALIB);
X strcat(Str1,"otemple.dat");
X result = access(Str1,F_OK|R_OK);
X if (result == -1) {
X impossible = TRUE;
X printf("\nWarning! File not accessible:");
X printf(Str1);
X }
X
X strcpy(Str1,OMEGALIB);
X strcat(Str1,"oabyss.dat");
X result = access(Str1,F_OK|R_OK);
X if (result == -1) {
X impossible = TRUE;
X printf("\nWarning! File not accessible:");
X printf(Str1);
X }
X
X strcpy(Str1,OMEGALIB);
X strcat(Str1,"ovillage1.dat");
X result = access(Str1,F_OK|R_OK);
X if (result == -1) {
X impossible = TRUE;
X printf("\nWarning! File not accessible:");
X printf(Str1);
X }
X strcpy(Str1,OMEGALIB);
X strcat(Str1,"ovillage2.dat");
X result = access(Str1,F_OK|R_OK);
X if (result == -1) {
X impossible = TRUE;
X printf("\nWarning! File not accessible:");
X printf(Str1);
X }
X strcpy(Str1,OMEGALIB);
X strcat(Str1,"ovillage3.dat");
X result = access(Str1,F_OK|R_OK);
X if (result == -1) {
X impossible = TRUE;
X printf("\nWarning! File not accessible:");
X printf(Str1);
X }
X strcpy(Str1,OMEGALIB);
X strcat(Str1,"ovillage4.dat");
X result = access(Str1,F_OK|R_OK);
X if (result == -1) {
X impossible = TRUE;
X printf("\nWarning! File not accessible:");
X printf(Str1);
X }
X
X strcpy(Str1,OMEGALIB);
X strcat(Str1,"ohome1.dat");
X result = access(Str1,F_OK|R_OK);
X if (result == -1) {
X impossible = TRUE;
X printf("\nWarning! File not accessible:");
X printf(Str1);
X }
X
X strcpy(Str1,OMEGALIB);
X strcat(Str1,"ohome2.dat");
X result = access(Str1,F_OK|R_OK);
X if (result == -1) {
X impossible = TRUE;
X printf("\nWarning! File not accessible:");
X printf(Str1);
X }
X
X strcpy(Str1,OMEGALIB);
X strcat(Str1,"ohome3.dat");
X result = access(Str1,F_OK|R_OK);
X if (result == -1) {
X impossible = TRUE;
X printf("\nWarning! File not accessible:");
X printf(Str1);
X }
X
X strcpy(Str1,OMEGALIB);
X strcat(Str1,"oarena.dat");
X result = access(Str1,F_OK|R_OK);
X if (result == -1) {
X impossible = TRUE;
X printf("\nWarning! File not accessible:");
X printf(Str1);
X }
X
X
X strcpy(Str1,OMEGALIB);
X strcat(Str1,"omaze1.dat");
X result = access(Str1,F_OK|R_OK);
X if (result == -1) {
X impossible = TRUE;
X printf("\nWarning! File not appendable or accessible:");
X printf(Str1);
X }
X strcpy(Str1,OMEGALIB);
X strcat(Str1,"omaze2.dat");
X result = access(Str1,F_OK|R_OK);
X if (result == -1) {
X impossible = TRUE;
X printf("\nWarning! File not appendable or accessible:");
X printf(Str1);
X }
X strcpy(Str1,OMEGALIB);
X strcat(Str1,"omaze3.dat");
X result = access(Str1,F_OK|R_OK);
X if (result == -1) {
X impossible = TRUE;
X printf("\nWarning! File not appendable or accessible:");
X printf(Str1);
X }
X strcpy(Str1,OMEGALIB);
X strcat(Str1,"omaze4.dat");
X result = access(Str1,F_OK|R_OK);
X if (result == -1) {
X impossible = TRUE;
X printf("\nWarning! File not appendable or accessible:");
X printf(Str1);
X }
X
X strcpy(Str1,OMEGALIB);
X strcat(Str1,"omega.hi");
X result = access(Str1,F_OK|R_OK|W_OK);
X if (result == -1) {
X impossible = TRUE;
X printf("\nWarning! File not appendable or accessible:");
X printf(Str1);
X }
X
X strcpy(Str1,OMEGALIB);
X strcat(Str1,"omega.log");
X result = access(Str1,F_OK|R_OK|W_OK);
X if (result == -1) {
X impossible = TRUE;
X printf("\nWarning! File not appendable or accessible:");
X printf(Str1);
X }
X
X strcpy(Str1,OMEGALIB);
X strcat(Str1,"omotd.txt");
X result = access(Str1,F_OK|R_OK);
X if (result == -1) {
X impossible = TRUE;
X printf("\nWarning! File not accessible:");
X printf(Str1);
X }
X
X strcpy(Str1,OMEGALIB);
X strcat(Str1,"olicense.txt");
X result = access(Str1,F_OK|R_OK);
X if (result == -1) {
X impossible = TRUE;
X printf("\nWarning! File not accessible:");
X printf(Str1);
X }
X
X strcpy(Str1,OMEGALIB);
X strcat(Str1,"ocircle.dat");
X result = access(Str1,F_OK|R_OK);
X if (result == -1) {
X impossible = TRUE;
X printf("\nWarning! File not accessible:");
X printf(Str1);
X }
X strcpy(Str1,OMEGALIB);
X strcat(Str1,"ocmds.txt");
X result = access(Str1,F_OK|R_OK);
X if (result == -1) {
X badbutpossible = TRUE;
X printf("\nWarning! File not accessible:");
X printf(Str1);
X }
X
X strcpy(Str1,OMEGALIB);
X strcat(Str1,"occmds.txt");
X result = access(Str1,F_OK|R_OK);
X if (result == -1) {
X badbutpossible = TRUE;
X printf("\nWarning! File not accessible:");
X printf(Str1);
X }
X
X
X strcpy(Str1,OMEGALIB);
X strcat(Str1,"ohelp1.txt");
X result = access(Str1,F_OK|R_OK);
X if (result == -1) {
X badbutpossible = TRUE;
X printf("\nWarning! File not accessible:");
X printf(Str1);
X }
X strcpy(Str1,OMEGALIB);
X strcat(Str1,"ohelp2.txt");
X result = access(Str1,F_OK|R_OK);
X if (result == -1) {
X badbutpossible = TRUE;
X printf("\nWarning! File not accessible:");
X printf(Str1);
X }
X strcpy(Str1,OMEGALIB);
X strcat(Str1,"ohelp3.txt");
X result = access(Str1,F_OK|R_OK);
X if (result == -1) {
X badbutpossible = TRUE;
X printf("\nWarning! File not accessible:");
X printf(Str1);
X }
X strcpy(Str1,OMEGALIB);
X strcat(Str1,"ohelp4.txt");
X result = access(Str1,F_OK|R_OK);
X if (result == -1) {
X badbutpossible = TRUE;
X printf("\nWarning! File not accessible:");
X printf(Str1);
X }
X strcpy(Str1,OMEGALIB);
X strcat(Str1,"ohelp5.txt");
X result = access(Str1,F_OK|R_OK);
X if (result == -1) {
X badbutpossible = TRUE;
X printf("\nWarning! File not accessible:");
X printf(Str1);
X }
X strcpy(Str1,OMEGALIB);
X strcat(Str1,"ohelp6.txt");
X result = access(Str1,F_OK|R_OK);
X if (result == -1) {
X badbutpossible = TRUE;
X printf("\nWarning! File not accessible:");
X printf(Str1);
X }
X strcpy(Str1,OMEGALIB);
X strcat(Str1,"ohelp7.txt");
X result = access(Str1,F_OK|R_OK);
X if (result == -1) {
X badbutpossible = TRUE;
X printf("\nWarning! File not accessible:");
X printf(Str1);
X }
X strcpy(Str1,OMEGALIB);
X strcat(Str1,"ohelp8.txt");
X result = access(Str1,F_OK|R_OK);
X if (result == -1) {
X badbutpossible = TRUE;
X printf("\nWarning! File not accessible:");
X printf(Str1);
X }
X strcpy(Str1,OMEGALIB);
X strcat(Str1,"ohelp9.txt");
X result = access(Str1,F_OK|R_OK);
X if (result == -1) {
X badbutpossible = TRUE;
X printf("\nWarning! File not accessible:");
X printf(Str1);
X }
X strcpy(Str1,OMEGALIB);
X strcat(Str1,"ohelp10.txt");
X result = access(Str1,F_OK|R_OK);
X if (result == -1) {
X badbutpossible = TRUE;
X printf("\nWarning! File not accessible:");
X printf(Str1);
X }
X strcpy(Str1,OMEGALIB);
X strcat(Str1,"ohelp11.txt");
X result = access(Str1,F_OK|R_OK);
X if (result == -1) {
X badbutpossible = TRUE;
X printf("\nWarning! File not accessible:");
X printf(Str1);
X }
X strcpy(Str1,OMEGALIB);
X strcat(Str1,"ohelp12.txt");
X result = access(Str1,F_OK|R_OK);
X if (result == -1) {
X badbutpossible = TRUE;
X printf("\nWarning! File not accessible:");
X printf(Str1);
X }
X strcpy(Str1,OMEGALIB);
X strcat(Str1,"ohelp13.txt");
X result = access(Str1,F_OK|R_OK);
X if (result == -1) {
X badbutpossible = TRUE;
X printf("\nWarning! File not accessible:");
X printf(Str1);
X }
X
X
X strcpy(Str1,OMEGALIB);
X strcat(Str1,"oabyss.txt");
X result = access(Str1,F_OK|R_OK);
X if (result == -1) {
X badbutpossible = TRUE;
X printf("\nWarning! File not accessible:");
X printf(Str1);
X }
X strcpy(Str1,OMEGALIB);
X strcat(Str1,"oscroll1.txt");
X result = access(Str1,F_OK|R_OK);
X if (result == -1) {
X badbutpossible = TRUE;
X printf("\nWarning! File not accessible:");
X printf(Str1);
X }
X
X strcpy(Str1,OMEGALIB);
X strcat(Str1,"oscroll2.txt");
X result = access(Str1,F_OK|R_OK);
X if (result == -1) {
X badbutpossible = TRUE;
X printf("\nWarning! File not accessible:");
X printf(Str1);
X }
X
X
X strcpy(Str1,OMEGALIB);
X strcat(Str1,"oscroll3.txt");
X result = access(Str1,F_OK|R_OK);
X if (result == -1) {
X badbutpossible = TRUE;
X printf("\nWarning! File not accessible:");
X printf(Str1);
X }
X
X strcpy(Str1,OMEGALIB);
X strcat(Str1,"oscroll4.txt");
X result = access(Str1,F_OK|R_OK);
X if (result == -1) {
X badbutpossible = TRUE;
X printf("\nWarning! File not accessible:");
X printf(Str1);
X }
X
X if (impossible) {
X printf("\nFurther execution is impossible. Sorry.");
X printf("\nOMEGALIB may be badly #defined in odefs.h\n");
X return(0);
X }
X else if (badbutpossible) {
X printf("\nFurther execution may cause anomalous behavior.");
X printf("\nContinue anyhow? [yn] ");
X if (getchar()=='y') return(-1);
X else return(0);
X }
X else return(1);
X}
X
X
X/* display a file given a string name of file */
Xvoid displayfile(filestr)
Xchar *filestr;
X{
X FILE *fd = checkfopen(filestr,"r");
X int c,d=' ';
X int x,y;
X clear();
X refresh();
X c = fgetc(fd);
X while ((c != EOF)&&((char) d != 'q')&&((char) d!=ESCAPE)) {
X getyx(stdscr,y,x);
X if (y > ScreenLength) {
X printw("\n-More-");
X refresh();
X d = wgetch(stdscr);
X clear();
X }
X printw("%c",(char) c);
X c = fgetc(fd);
X }
X if (((char) d != 'q')&&((char) d!=ESCAPE)) {
X printw("\n-Done-");
X refresh();
X getch();
X }
X clear();
X refresh();
X}
X
X
X/* display a file given a string name of file */
Xvoid copyfile(srcstr)
Xchar *srcstr;
X{
X char deststr[80];
X char cmd[200];
X print1("Enter name of file to create: ");
X strcpy(deststr,msgscanstring());
X strcpy(cmd,"cp ");
X strcat(cmd,srcstr);
X strcat(cmd," ");
X strcat(cmd,deststr);
X print2("Copying file....");
X system(cmd);
X print3("Done.");
X}
X
END_OF_FILE
if test 21529 -ne `wc -c <'ofile.c'`; then
echo shar: \"'ofile.c'\" unpacked with wrong size!
fi
# end of 'ofile.c'
fi
echo shar: End of archive 5 \(of 19\).
cp /dev/null ark5isdone
MISSING=""
for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 ; do
if test ! -f ark${I}isdone ; then
MISSING="${MISSING} ${I}"
fi
done
if test "${MISSING}" = "" ; then
echo You have unpacked all 19 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