/* omega copyright (C) by Laurence Raphael Brothers, 1987,1988,1989 */ /* aux3.c */ /* some functions called by com.c, also see aux1.c, aux2.c */ /* This is a real grab bag file. It contains functions used by aux1.c and omega.c, as well as elsewhere. It is mainly here so aux1.c and aux2.c are not huge */ #include "glob.h" /* check every ten minutes */ void tenminute_check(void) { if (Time % 60 == 0) hourly_check(); else { if (Current_Environment == Current_Dungeon) wandercheck(); minute_status_check(); tenminute_status_check(); if ((Player.status[DISEASED] < 1) && (Player.hp < Player.maxhp)) Player.hp = min(Player.maxhp,Player.hp+Player.level+1); if (Current_Environment != E_COUNTRYSIDE && Current_Environment != E_ABYSS) indoors_random_event(); } } /* hourly check is same as ten_minutely check except food is also checked, and since time moves in hours out of doors, also outdoors_random_event is possible */ void hourly_check(void) { Player.food--; foodcheck(); if (hour()==0) { /* midnight, a new day */ moon_check(); Date++; } torch_check(); if (Current_Environment == Current_Dungeon) wandercheck(); minute_status_check(); tenminute_status_check(); if ((Player.status[DISEASED] == 0) && (Player.hp < Player.maxhp)) Player.hp = min(Player.maxhp,Player.hp+Player.level+1); if (Current_Environment != E_COUNTRYSIDE && Current_Environment != E_ABYSS) indoors_random_event(); } void indoors_random_event(void) { pml ml; pol ol; switch(random_range(1000)) { case 0: print3("You feel an unexplainable elation."); morewait(); break; case 1: print3("You hear a distant rumbling."); morewait(); break; case 2: print3("You realize your fly is open."); morewait(); break; case 3: print3("You have a sudden craving for a pecan twirl."); morewait(); break; case 4: print3("A mysterious healing flux settles over the level."); morewait(); for (ml=Level->mlist;ml!=NULL;ml=ml->next) if (ml->m->hp > 0) ml->m->hp = Monsters[ml->m->id].hp; Player.hp = max(Player.hp,Player.maxhp); break; case 5: print3("You discover an itch just where you can't scratch it."); morewait(); break; case 6: print3("A cosmic ray strikes!"); p_damage(10,UNSTOPPABLE,"a cosmic ray"); morewait(); break; case 7: print3("You catch your second wind...."); Player.maxhp++; Player.hp = max(Player.hp, Player.maxhp); Player.mana = max(Player.mana, calcmana()); morewait(); break; case 8: print3("You find some spare change in a hidden pocket."); morewait(); Player.cash += Player.level*Player.level+1; break; case 9: print3("You feel strangely lucky."); morewait(); break; case 10: print3("You trip over something hidden in a shadow..."); morewait(); ol = ((pol) checkmalloc(sizeof(oltype))); ol->thing = create_object(difficulty()); /* FIXED! 12/30/98 */ assert(ol->thing); /* WDT I want to make sure... */ ol->next = Level->site[Player.x][Player.y].things; Level->site[Player.x][Player.y].things = ol; pickup(); break; case 11: print3("A mysterious voice echoes all around you...."); morewait(); hint(); morewait(); break; #if 0 #ifdef NEW_BANK case 12: { int num_accounts; bank_account *account; num_accounts = 0; for(account = bank; account; account = account->next_account) { if (account->player && account->balance > 0) { ++num_accounts; account->balance = 0; } } if (num_accounts) print3( "You feel unlucky." ); else print3( "You feel lucky." ); } break; case 13: { int num_accounts; bank_account *account; num_accounts = 0; for(account = bank; account; account = account->next_account) if (account->player && account->balance > 0) ++num_accounts; if (num_accounts) { num_accounts = random_range(num_accounts); for(account = bank; account; account = account->next_account) { if (account->player) { if (0 == num_accounts) { account->balance += random_range( 4000 ) + 1000; break; } --num_accounts; } } print3( "You feel lucky." ); } else { print3( "You feel unlucky." ); } } break; #else /* !NEW_BANK */ case 12: if (Balance > 0) { print3("You get word of the failure of your bank!"); Balance = 0; } else { print3("You feel lucky."); } break; case 13: if (Balance > 0) { print3("You get word of a bank error in your favor!"); Balance += 5000; } else { print3("You feel unlucky."); } break; #endif /* !NEW_BANK */ #endif /* 0 */ } dataprint(); showflags(); } void outdoors_random_event(void) { int num,i,j; pob ob; switch(random_range(300)) { case 0: switch(Country[Player.x][Player.y].current_terrain_type) { case TUNDRA: mprint("It begins to snow. Heavily."); break; case DESERT: mprint("A sandstorm swirls around you."); break; default: if ((Date > 75) && (Date < 330)) mprint("You are drenched by a sudden downpour!"); else mprint("It begins to snow. Heavily."); } morewait(); mprint("Due to the inclement weather conditions, you have become lost."); morewait(); Precipitation+=random_range(12)+1; setgamestatus(LOST); break; case 1: mprint("You enter a field of brightly colored flowers..."); mprint("Wow, man! These are some pretty poppies..."); morewait(); mprint("poppies..."); morewait(); mprint("poppies..."); morewait(); print3("You become somewhat disoriented..."); setgamestatus(LOST); break; case 2: mprint("You discover a sprig of athelas growing lonely in the wild."); morewait(); mprint("Using your herbalist lore you cook a cake of lembas...."); morewait(); ob = ((pob) checkmalloc(sizeof(objtype))); *ob = Objects[OB_LEMBAS]; gain_item(ob); break; case 3: if (Precipitation > 0) { mprint("You are struck by a bolt of lightning!"); p_damage(random_range(25),ELECTRICITY,"a lightning strike"); morewait(); } else mprint("You feel static cling"); break; case 4: mprint("You find a fast-food establishment."); morewait(); l_commandant(); break; case 5: mprint("A weird howling tornado hits from out of the West!"); morewait(); mprint("You've been caught in a chaos storm!"); morewait(); num = random_range(300); if (num <10) { mprint("Your cell-structure was disrupted!"); p_damage(random_range(100),UNSTOPPABLE,"a chaos storm"); morewait(); } else if (num < 20) { mprint("The chaos storm warps your frame!"); morewait(); mprint("Your statistical entropy has been maximized."); morewait(); mprint("You feel average..."); morewait(); toggle_item_use(TRUE); /* FIXED! 12/30/98 */ Player.str = Player.maxstr = Player.con = Player.maxcon = Player.dex = Player.maxdex = Player.agi = Player.maxagi = Player.iq = Player.maxiq = Player.pow = Player.maxpow = ((Player.maxstr+Player.maxcon+Player.maxdex+Player.maxagi+ Player.maxiq+Player.maxpow+12)/6); toggle_item_use(FALSE); /* FIXED! 12/30/98 */ } else if (num < 30) { mprint("Your entire body glows with an eerie flickering light."); morewait(); toggle_item_use(TRUE); /* FIXED! 12/30/98 */ for(i=1;iplus++; if (Player.possessions[i]->objchar == STICK) Player.possessions[i]->charge+=10; Player.possessions[i]->blessing+=10; } toggle_item_use(FALSE); /* FIXED! 12/30/98 */ cleanse(1); mprint("You feel filled with energy!"); morewait(); Player.maxpow += 5; Player.pow += 5; Player.mana = Player.maxmana = calcmana() * 5; mprint("You also feel weaker. Paradoxical, no?"); morewait(); Player.con -= 5; Player.maxcon -= 5; if (Player.con < 3) p_death("congestive heart failure"); } else if (num < 40) { mprint("Your entire body glows black."); morewait(); dispel(-1); dispel(-1); Player.pow-=10; Player.mana=0; } else if (num < 60) { mprint("The storm deposits you in a strange place...."); morewait(); setPlayerXY( random_range(COUNTRY_WIDTH), random_range(COUNTRY_LENGTH)); screencheck(Player.x,Player.y); } else if (num < 70) { mprint("A tendril of the storm condenses and falls into your hands."); morewait(); ob = ((pob) checkmalloc(sizeof(objtype))); make_artifact(ob,-1); gain_item(ob); } else if (num < 80) { if (gamestatusp(MOUNTED)) { mprint("Your horse screams as he is transformed into an"); morewait(); mprint("imaginary unseen dead tortoise."); morewait(); mprint("You are now on foot."); morewait(); resetgamestatus(MOUNTED); } else { mprint("You notice you are riding a horse. Odd. Very odd...."); morewait(); mprint("Now that's a horse of a different color!"); morewait(); setgamestatus(MOUNTED); } } else if (num < 90) { mprint("You feel imbued with godlike power...."); morewait(); wish(1); } else if (num < 100) { mprint("The chaos storm has wiped your memory!"); morewait(); mprint("You feel extraordinarily naive...."); morewait(); mprint("You can't remember a thing! Not even your name."); morewait(); Player.xp = 0; Player.level = 0; for (i=0;i 0) && (Player.level/2 + random_range(20) > hostile_magic + random_range(20))) { if (Player.mana > hostile_magic * hostile_magic) { mprint("Thinking fast, you defend youself with a counterspell!"); Player.mana -= hostile_magic * hostile_magic; dataprint(); return(TRUE); } } if (Player.level/4 + Player.status[PROTECTION] + random_range(20) > hostile_magic + random_range(30)) { mprint("You resist the spell!"); return(TRUE); } else return(FALSE); } void terrain_check(int takestime) { int faster = 0; if (Player.patron == DRUID) { faster = 1; switch(random_range(32)) { case 0:print2("Along the many paths of nature..."); break; case 1:print2("You move swiftly through the wilderness."); break; } } else if (gamestatusp(MOUNTED)) { faster = 1; switch(random_range(32)) { case 0: case 1:print2("Clippity Clop.");break; case 2:print2("....my spurs go jingle jangle jingle....");break; case 3:print2("....as I go riding merrily along....");break; } } else if (Player.possessions[O_BOOTS] && Player.possessions[O_BOOTS]->usef == I_BOOTS_7LEAGUE) { takestime = 0; switch(random_range(32)) { case 0:print2("Boingg!"); break; case 1:print2("Whooosh!"); break; case 2:print2("Over hill, over dale...."); break; case 3:print2("...able to leap over 7 leagues in a single bound...."); break; } } else if (Player.status[SHADOWFORM]) { faster = 1; switch(random_range(32)) { case 0:print2("As swift as a shadow."); break; case 1:print2("\"I walk through the trees...\""); break; } } else switch(random_range(32)) { case 0:print2("Trudge. Trudge."); break; case 1:print2("The road goes ever onward...."); break; } switch(Country[Player.x][Player.y].current_terrain_type) { case RIVER: if ((Player.y < 6) && (Player.x > 20)) locprint("Star Lake."); else if (Player.y < 41) { if (Player.x < 10) locprint("Aerie River."); else locprint("The Great Flood."); } else if (Player.x < 42) locprint("The Swamp Runs."); else locprint("River Greenshriek."); if (takestime) { Time += 60; hourly_check(); Time += 60; hourly_check(); Time += 60; hourly_check(); } break; case ROAD: locprint("A well-maintained road."); if (takestime) { Time += 60; hourly_check(); } break; case PLAINS: locprint("A rippling sea of grass."); if (takestime) { Time += 60; hourly_check(); if (! faster) { Time += 60; hourly_check(); } } break; case TUNDRA: locprint("The Great Northern Wastes."); if (takestime) { Time += 60; hourly_check(); if (! faster) { Time += 60; hourly_check(); } } break; case FOREST: if (Player.y < 10) locprint("The Deepwood."); else if (Player.y < 18) locprint("The Forest of Erelon."); else if (Player.y < 46) locprint("The Great Forest."); if (takestime) { Time += 60; hourly_check(); if (Player.rank[PRIESTHOOD] == 0 || Player.patron != DRUID) { Time += 60; hourly_check(); if (! faster) { Time += 60; hourly_check(); } } } break; case JUNGLE: locprint("Greenshriek Jungle."); if (takestime) { Time += 60; hourly_check(); Time += 60; hourly_check(); if (! faster) { Time += 60; hourly_check(); Time += 60; hourly_check(); } } break; case DESERT: locprint("The Waste of Time."); if (takestime) { Time += 60; hourly_check(); Time += 60; hourly_check(); if (! faster) { Time += 60; hourly_check(); Time += 60; hourly_check(); } } break; case MOUNTAINS: if ((Player.y < 9) && (Player.x < 12)) locprint("The Magic Mountains"); else if ((Player.y < 9) && (Player.y > 2) && (Player.x < 40)) locprint("The Peaks of the Fist."); else if (Player.x < 52) locprint("The Rift Mountains."); else locprint("Borderland Mountains."); if (takestime) { Time += 60; hourly_check(); Time += 60; hourly_check(); Time += 60; hourly_check(); Time += 60; hourly_check(); Time += 60; hourly_check(); if (! faster) { Time += 60; hourly_check(); Time += 60; hourly_check(); Time += 60; hourly_check(); } } break; case PASS: locprint("A hidden pass."); if (takestime) { Time += 60; hourly_check(); } break; case CHAOS_SEA: locprint("The Sea of Chaos."); if (takestime) { Time += 60; hourly_check(); } mprint("You have entered the sea of chaos..."); morewait(); l_chaos(); break; case SWAMP: locprint("The Loathly Swamp."); if (takestime) { Time += 60; hourly_check(); Time += 60; hourly_check(); Time += 60; hourly_check(); Time += 60; hourly_check(); Time += 60; hourly_check(); Time += 60; hourly_check(); if (! faster) { Time += 60; hourly_check(); Time += 60; hourly_check(); } } break; case CITY: if (gamestatusp(LOST)) { resetgamestatus(LOST); mprint("Well, I guess you know where you are now...."); } locprint("Outside Rampart, the city."); break; case VILLAGE: if (gamestatusp(LOST)) { resetgamestatus(LOST); mprint("The village guards let you know where you are...."); } locprint("Outside a small village."); break; case CAVES: locprint("A deserted hillside."); if (takestime) { Time += 60; hourly_check(); } mprint("You notice a concealed entrance into the hill."); break; case CASTLE: locprint("Near a fortified castle."); if (takestime) { Time += 60; hourly_check(); } mprint("The castle is hewn from solid granite. The drawbridge is down."); break; case TEMPLE: switch(Country[Player.x][Player.y].aux) { case ODIN: locprint("A rough-hewn granite temple."); break; case SET: locprint("A black pyramidal temple made of sandstone."); break; case ATHENA: locprint("A classical marble-columned temple."); break; case HECATE: locprint("A temple of ebony adorned with ivory."); break; case DRUID: locprint("A temple formed of living trees."); break; case DESTINY: locprint("A temple of some mysterious blue crystal."); break; } if (takestime) { Time += 60; hourly_check(); } mprint("You notice an entrance conveniently at hand."); break; case MAGIC_ISLE: locprint("A strange island in the midst of the Sea of Chaos."); if (takestime) { Time += 60; hourly_check(); } mprint("There is a narrow causeway to the island from here."); break; case STARPEAK: locprint("Star Peak."); if (takestime) { Time += 60; hourly_check(); } mprint("The top of the mountain seems to glow with a allochroous aura."); break; case DRAGONLAIR: locprint("A rocky chasm."); if (takestime) { Time += 60; hourly_check(); } mprint("You are at a cave entrance from which you see the glint of gold."); break; case PALACE: locprint("The ruins of a once expansive palace."); if (takestime) { Time += 60; hourly_check(); } mprint("The palace dungeons are still intact..."); break; case VOLCANO: locprint("HellWell Volcano."); if (takestime) { Time += 60; hourly_check(); } mprint("A shimmer of heat lightning plays about the crater rim."); break; default: locprint("I haven't any idea where you are!!!"); break; } outdoors_random_event(); } void countrysearch(void) { int x,y; Time+=60; hourly_check(); for (x=Player.x-1;x