http://qs321.pair.com?node_id=358023

#!/usr/bin/perl -w # +------------------------------------------------------------------- ++ # | +| # | Programme: Freedale Wizard +| # | Author: Dave Barr <barrd@mac.com> +| # | Version: 2.01 (23/01/06) +| # | +| # | Credits: Tua Xiong & ROW (Various ASCII art) +| # | Kevin Cohe (For original concept) +| # | +| # +------------------------------------------------------------------- ++ use strict; # ==================================================================== += # >> Constants # ==================================================================== += my $level = 1; # Initial game level to start on my $weapon = "Hands Only"; # Original weapon of player my $gold = 5; # Initial amount of gold given to player my $kills = 0; # Tally the melee count my $melees_per_level = 2; # Number of melees to achieve before level+ ++ my @creatures_array = (); # Will be an array of all critters fought my $start_done = 0; # Show initial welcome message my $eagle_seen = 0; # Eagle random event (mountain sub) my $tavern_seen = 0; # Tally of tavern visits my $tavern_seen2 = 0; # Used to display 2nd tavern msg only once my $cave_seen = 0; # Only see the cave once my $inv_key = 0; # Inventory: Key, set to nill my @inv_arr = (); # Inventory array my $hawk_key_seen = 0; # Hawk drop key random one time event my $chest_seen = 0; # Display diff txt after seeing chest in du +ngeon 1st time my $scroll_seen = 0; # The scroll hidden inside chest in the dun +geons my $decipher_seen = 0; # The scroll that can decipher the hidden w +ords on scroll my @msgs = (); # Print msgs various my ($creat, $creat_health, $creat_damage, $reward, $announce, $has_hav +e, $add_msg, $character, $extra, $new, $player_health, $player_damage, $max_dam +age, $lvl_msg, $max_spell, $spell_level, $orig_health, $orig_spell_level, $orig_d +amage, $decipher); my $err_msg = "<< ERROR >> Please choose a suitable number;\n\n"; # Set up the secret word(s) for the scroll in the dungeon my @scrt_arr = ('Grumpy Bosker', 'Larry Wall', 'Abracadabra', 'Hey Presto', 'Alacazam', 'Scooby Doo', 'Doo Wop Wop', 'Ecky Thump', 'All Hail Erus', ); my $secret_txt = splice(@scrt_arr, int(rand(@scrt_arr)) ,1); my @txt_arr = unpack("C*", $secret_txt); my @print_arr = (); foreach (@txt_arr) { push(@print_arr, $_); } my $scroll_txt = join ' ', @print_arr; # ==================================================================== += # >> Set up the character # ==================================================================== += print `clear`; # Blank terminal screen character(); # Choose a character to play character_stats(); # Assign stats to character print `clear`; print "\n\n** CHARACTER NAME **\n\n"; print "Please type your ". $character . "'s name\n>> "; chomp(my $name = <STDIN>); $name = $name eq '' ? "Anonymous Coward" : $name; # If name blank assi +gn one #substr($name, 24) = "..."; # Truncate name to 24 characters $name =~ s/(\w+)/\u\L$1/g; # Uppercase first character of each word i +n name # ==================================================================== += # >> Let the game commence... # ==================================================================== += print `clear`; freedale(); # ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ++ # >> Subroutines after this point # ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ++ sub character_stats { if ($character eq "Elf") { $player_health = 50; $player_damage = 2; $max_damage = 5; $spell_level = 1; $max_spell = 2; } elsif ($character eq "Warrior") { $player_health = 60; $player_damage = 3; $max_damage = 6; $spell_level = 0; $max_spell = 1; } elsif ($character eq "Wizard") { $player_health = 45; $player_damage = 1; $max_damage = 4; $spell_level = 2; $max_spell = 3; } ## Set values for stats (+/-) and to reinitalise original values if +req $orig_health = $player_health; $orig_spell_level = $spell_level; $orig_damage = $player_damage; } sub magic_spells { dead(); # Ensure we haven't snuffed it my $magic_spells = int(rand 4) + 1; if ($magic_spells <= $spell_level) { print `clear`; $gold = $gold + $reward; $kills++; # Up Melees 1 notch levels(); # Do we go up a level? bonus(); # Do we get any goodies? # Choose a random spell to befall a creature my @spells = ('zapped into frogs', 'sliced, diced and deep fried', 'whisked away to the 6th dimension', 'transformed into several roast chickens', 'shrunk in size and stood upon', 'attacked by your pet giant arachnid', ); my $rspell = splice(@spells, int(rand(@spells)) ,1); $add_msg = "** Success with the spell! **\nThe $creat $has_have be +en $rspell!\n"; $add_msg .="Good job! You gained $reward gold piece(s) and return +to Freedale.\n\n"; freedale(); } elsif ($magic_spells > $spell_level) { $player_health = $player_health - $creat_damage; print `clear`; print "\n** Spell failed! **\n\nLose $creat_damage health point(s) + leaving"; print " $player_health from $orig_health.\n\n"; battle(); } } sub battle { dead(); # Ensure we haven't snuffed it print "What do you want to do?...\n\n"; print "Type [1] for Spells\nType [2] for Combat (using $weapon)\nTyp +e [3] for Analysis\n>> "; chomp(my $choice = <STDIN>); if ($choice !~ /[0-9]/) { print `clear`; print $err_msg; battle(); } elsif ($choice == 1) { magic_spells(); } elsif ($choice == 0 || $choice > 3) { print `clear`; print $err_msg; battle(); } elsif ($choice == 3) { my $plrh = sprintf("%02d", $player_health); my $creh = sprintf("%02d", $creat_health); my $plrd = sprintf("%02d", $player_damage); my $cred = sprintf("%02d", $creat_damage); my $p_wizardl = sprintf("%02d", $spell_level); # Warn player not to use spells if spell level is zero my $spl_warn = $spell_level < 1 ? "(WARNING - Do Not Use Spells!)" + : ""; print `clear`; print "\n** Combat Analysis **\n\n"; print "====================================================\n"; print "-- You --\n"; print "Character ........ $character\n"; print "Magic level ...... " . $p_wizardl . " " . $spl_warn ."\n"; print "Your health ...... $plrh\n"; print "Your damage ...... $plrd per melee round\n"; print "====================================================\n"; print "-- Enemy --\n"; print "$creat health is $creh\n"; print "$creat damage is $cred per melee round\n"; print "====================================================\n\n"; battle(); } elsif ($choice == 2) { print `clear`; my $beast = uc($creat); print "\n** You are battling with the $beast **\n\n"; do { $creat_health = $creat_health - $player_damage; $player_health = $player_health - $creat_damage; # Make sure we don't print fugly negative numbers $creat_health = 0 if $creat_health < 0 ; $player_health = 0 if $player_health < 0; print "=> $character health: $player_health "; print "$creat health: $creat_health\n"; sleep 1; # Staggers the countdown (esthetically pleasing :) } until ($creat_health <= 0 || $player_health <= 0); if ($player_health > 0) { print "\n+--------------+\n"; print "| Success! |\n"; print "+--------------+\n"; sleep 2; $gold = $gold + $reward; $kills++; # Up Melees 1 notch levels(); # Do we go up a level? bonus(); # Do we get any goodies? $add_msg = "** You defeated the $creat, good job! **\n"; $add_msg .= "You gained $reward gold piece(s) and return to Free +dale\n\n"; freedale(); } elsif ($player_health <= 0) { dead(); } } } sub forest { print `clear`; print "\n** THE FOREST **\n"; # Hawk drops key as a one time event on any level above level 1 if ($level > 1 && $hawk_key_seen == 0) { my @key_nums = qw(6 16 26 36 46 56 66 76 86 96); # 10% chance of g +etting key my $key_rndm = int(rand 100); foreach (@key_nums) { if ($_ == $key_rndm && $hawk_key_seen == 0) { $hawk_key_seen = 1; # Make sure we don't get another key $inv_key = 1; # Add 'key' to inventory push(@inv_arr, "Chest Key"); print <<_EOF_; \n __. .__ /'( _ )`\\ As you wander through the dense rank water / . \\/^\\/ . \\ logged forest an impulse makes you look t +o / _)_`-'_(_ \\ the skies. Far above you a hawk is gently /.-~ ).( ~-.\\ hovering on a light breeze. You see a brigh +t /' /\\_/\\ `\\ object fall from its talons... Its a Key! "-V-" _EOF_ return2game("\n\nHit 'enter' to continue once you have picked +up the key.\n>> "); } } } if ($cave_seen == 0 && $scroll_seen == 1) { # Enter cave and 'say' the magic word(s) only once if ($level >= 2 && $decipher_seen == 1) { forest_cave(); } } print <<_EOF_; \nThe forest is dark and smells of old mould and rotten fish. The foul waters have turned this once peaceful place in to a dark evil realm. _EOF_ my $attack = int(rand 6) + 1; if ($attack >= 4) { creature_attack(); # Assign a critter to fight and its stats battle(); # Fight the critter or do some voodoo magic } else { $add_msg = "** There where no monsters in the forest, you return t +o Freedale... **\n\n"; freedale(); } } sub forest_cave { print `clear`; print "\n** THE FOREST CAVE **\n\n"; print <<_EOF_; As you wander through the bleak and dank wooded areas you spy what loo +ks like a cave opening. Gathering your courage together you enter the da +rk forboding space.\n Once inside a light that seems to come from nowhere and everywhere fil +ls the inner sanctum. A wizened old man appears and asks if you have mana +ged to decipher the scroll. "If so speak them out loud" he says.\n Enter the magic word(s). _EOF_ print ">> "; chomp(my $attempt = <STDIN>); if ($attempt eq $secret_txt) { $cave_seen = 1; $player_health = $player_health + 10; $player_damage = $player_damage + 1; $orig_health = $player_health; $orig_damage = $player_damage; push(@inv_arr, "Plate Armour"); $add_msg = "\"Congratulations, you said the correct thing.\" the o +ld man says.\n"; $add_msg .= "\"Please accept this armour and strength potion as a +reward\" he "; $add_msg .= " continues. You feel great, very strong and well defe +nded. He then "; $add_msg .= " dissapears and you are left standing alone in the da +rk. Only a "; $add_msg .= " few moments though, you open your eyes and you are b +ack in "; $add_msg .= " Freedale town square.\n\n"; freedale(); } else { $add_msg = "** Your attempt at speaking the magic words failed. ** +\n\n"; freedale(); } } sub dungeon { print `clear`; print "\n** THE DUNGEONS **\n"; print <<_EOF_; There is a heavy feeling in the air, it's very dark and musty down her +e. You can see clear signs that Goblins have been here, and maybe worse t +hings yet to come! _EOF_ if ($inv_key == 0) { # ---------------------------------------------------------------- +- # No key yet found # ---------------------------------------------------------------- +- dungeon_key_txt(); my $attack = int(rand 6) + 1; if ($attack >= 3) { creature_attack(); # Assign a critter to fight and its stats battle(); # Fight the critter or do some voodoo magic } else { if ($chest_seen == 0) { return2game("\n\nHit 'enter' to continue the game.\n>> "); } else { $add_msg = "** There where no monsters in the dungeon,"; $add_msg = " you return to Freedale... **\n\n"; freedale(); } } } elsif ($inv_key == 1 && $scroll_seen == 0) { # ----------------------------------------------------------------- # Key found, now open chest and get the scroll # ----------------------------------------------------------------- $scroll_seen = 1; push(@inv_arr, "Magic Scroll"); print <<_EOF_; \nNow that you have the key you make a beeline for the chest with all +haste. After inserting and turning the key you lift the metal lid whincing at + the rusty creaking noises that the heavy lid is making. There is some spo +iled food a few articles of clothing and a SCROLL inside...\n _EOF_ scroll(); print "\nYou look in puzzlement at the numbers printed on the scro +ll.\n"; print "However you fold the scroll up and carry on with your adven +ture."; return2game("\n\nHit 'enter' to continue the game.\n>> "); } else { # ----------------------------------------------------------------- # Key found, scroll found (and read) now return to normal... # ----------------------------------------------------------------- my $attack = int(rand 6) + 1; if ($attack >= 3) { creature_attack(); # Assign a critter to fight and its stats battle(); # Fight the critter or do some voodoo magic } else { $add_msg = "** There where no monsters in the dungeon,"; $add_msg = " you return to Freedale... **\n\n"; freedale(); } } } sub scroll { format STDOUT = ______________________________________________________ _______| |____ +__ | | | + | | | @||||||||||||||||||||||||||||||||||||||||||||||||||| | + | $scroll_txt | | | + | | |______________________________________________________| + | |__________) (_______ +__| . write(STDOUT); } sub dungeon_key_txt { if ($chest_seen == 0) { # Show this txt first time entering the dung +eon $chest_seen = 1; # We've now seen the chest print <<_EOF_; \n+------------------------------------------------------------------- +-------+ | You spot a large metal chest half hidden away at the rear of one of +the | | cells. No matter how hard you try to pry it open it will not budge +. A | | quick examination reveals that a 'key' will be required to get it op +en. | +--------------------------------------------------------------------- +-----+ _EOF_ return2game("\n\nHit 'enter' to continue the game.\n>> "); } else { # txt displayed for subsequent visits till the key is found print <<_EOF_; \nYou look forlornly at the chest and ponder what wonders it may conta +in. With new resolve you decide to keep an eye out for any keys you come across on your travels.\n _EOF_ } } sub mountain { print `clear`; # Just a nice random event that is shown once per game my $eagle = int(rand 9) + 1; if ($eagle == 9 && $eagle_seen != 1) { print <<_EOF_; \n** THE MOUNTAINS **\n ///, //// You hear a shrill eerie cry above, you look \\ /, / >. upwards and see a dazzling Golden Eagle with \\ /, _/ /. not a care in the world. You take this as a \\_ /_/ /. good omen and continue your journey to the to +p \\__/_ < of the mountain. /<<< \\_\\_ /,)^>>_._ \\ Seeing the majestic creature puts a new sprin +g (/ \\\\ /\\\\\\ in your step as you continue onto adventu +res // ```` new and bold. ((` _EOF_ $eagle_seen = 1; # Make sure we don't see it again this game health_check(5); # Add some health gratis ;^) sleep 8; # Wait awhile as critters may attack } my $attack = int(rand 6) + 1; if ($attack >= 4) { print `clear`; print <<_EOF_; \n** THE MOUNTAINS **\n\n Its pretty cold up here, but from this altitude you can see the whole town below you. Although it is clear that you are not the first one here! _EOF_ creature_attack(); # Assign a critter to fight and its stats battle(); # Fight the critter or do some voodoo magic } elsif ($attack !~ /[4-6]/) { $add_msg = "** There where no monsters in the mountains, you retur +n"; $add_msg = " to Freedale... **\n\n"; freedale(); } } sub shop { my $shop_msg = shift; print `clear`; if ($gold < 10) { $add_msg = "** Sorry, you do not have enough gold pieces to buy an +ything! **\n\n"; freedale(); } else { print <<_EOF_; \n++ FREEDALE MARKET PLACE ++ \nHow may we help you? Please select a choice from below...\n _EOF_ } if ($shop_msg) { # Show error or addition msg txt if appropriate print $shop_msg; } print "You have $gold gold pieces to spend.\n\n"; print "Type [1] for Healing ............... 10 gold pieces\n"; print "Type [2] for Additional Weapons .... 15 gold pieces\n"; print "Type [3] for Magic Staff ........... 30 gold pieces\n"; print "Type [4] to EXIT the shop\n"; print ">> "; chomp(my $shop = <STDIN>); if ($shop !~ /[0-9]/) { shop($err_msg); } elsif ($shop == 1) { $gold = $gold - 10; $player_health = $orig_health; $add_msg = "++ Thank you for purchasing HEALING ++\n\n"; freedale(); } elsif ($shop == 2) { ## ADDITIONAL WEAPONS if ($gold < 15) { shop("** You don't have enough gold pieces! **\n\n"); } elsif ($player_damage >= $max_damage) { # Limit the player damage level shop("** You are already carrying all the weaponry you can! **\n +\n"); } # Assign a different weapon each time one is purchased if ($player_damage == 2) { $gold = $gold - 15; $weapon = "a Dagger"; $player_damage++; $add_msg = "++ Thank you for purchasing a DAGGER ++\n\n"; freedale(); } elsif ($player_damage == 3) { $gold = $gold - 15; $weapon = "a Mace"; $player_damage++; $add_msg = "++ Thank you for purchasing a MACE ++\n\n"; freedale(); } elsif ($player_damage == 4) { $gold = $gold - 15; $weapon = "a Broad Sword"; $player_damage++; $add_msg = "++ Thank you for purchasing a BROAD SWORD ++\n\n"; freedale(); } else { $gold = $gold - 15; $weapon = "a Magic Sword"; $player_damage++; $add_msg = "++ Thank you for purchasing a MAGIC SWORD ++\n\n"; freedale(); } } elsif ($shop == 3) { ## MAGIC STAFF if ($gold < 30) { shop("** You don't have enough gold pieces! **\n\n"); } elsif ($spell_level >= $max_spell) { # Limit the player spell level shop("** You are a truly formidable magician already! **\n\n"); } $gold = $gold - 30; $spell_level = $spell_level + 1; $add_msg = "++ Thank you for purchasing a MAGIC STAFF ++\n\n"; freedale(); } elsif ($shop == 4) { $add_msg = "\n** You have left the shop... **\n\n"; freedale(); } elsif ($shop == 0 || $shop > 4) { shop($err_msg); } } sub creature_attack { # The "BIG BOSS" fight before going up a level my $boss = $melees_per_level * $level - 1; if ($boss == $kills) { $creat = "Dragon"; $creat_health = 30; $creat_damage = 5 + $level - 1; $reward = 10; $has_have = "has"; dragon(); # Print the ASCII dragon... } else { # Decide on creature and its stats for battle # Increment the damage levels up each level my $creat_chose = int(rand 9) + 1; if ($creat_chose == 9) { $announce = "A HILL GIANT strides forward and attacks!"; $creat = "Hill Giant"; $creat_health = 16; $creat_damage = 3 + $level - 1; $reward = 5; $has_have = "has"; } elsif ($creat_chose == 8) { $announce = "A screaming family of TROLLS attack!"; $creat = "Trolls"; $creat_health = 13; $creat_damage = 3 + $level - 1; $reward = 4; $has_have = "have"; } elsif ($creat_chose =~ /[6-7]/) { $announce = "A band of ORCS bent on mayhem attack!"; $creat = "Orcs"; $creat_health = 12; $creat_damage = 3 + $level - 1; $reward = 3; $has_have = "have"; } elsif ($creat_chose =~ /[4-5]/) { $announce = "A cadre of EVIL DWARVES lunge to the attack!"; $creat = "Dwarves"; $creat_health = 10; $creat_damage = 2 + $level - 1; $reward = 3; $has_have = "have"; } else { $announce = "A gang of GOBLINS foolishly attack!"; $creat = "Goblins"; $creat_health = 8; $creat_damage = 1 + $level - 1; $reward = 2; $has_have = "have"; } print <<_EOF_; \n=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- += ** $announce ** =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\ +n _EOF_ } # Add to an array of all critters fought (see stats sub for why) push(@creatures_array, $creat); } sub stats { print `clear`; # Create a hash of creatures seen and number of times fought, the # @creatures_array is assigned at the end of the creature_attack sub my %critters = (); foreach my $elem (@creatures_array) { $critters{ $elem }++; } my $critters_killed = scalar(@creatures_array); # Show string 'None' in stats if no critters killed yet my $none = $critters_killed == 0 ? "None" : ''; my $date = `date "+on %d/%m/%y at %H:%M:%S"`; my $new_wizard = $orig_health - $player_health; my $new_damage = $player_damage - $orig_damage; my $new_wizardl = $spell_level - $orig_spell_level; # Format numbers using sprintf, pads single numbers with a 0 (zero) my $p_level = sprintf("%02d", $level); my $p_wizard = sprintf("%02d", $player_health); my $p_damage = sprintf("%02d", $player_damage); my $p_wizardl = sprintf("%02d", $spell_level); my $p_gold = sprintf("%02d", $gold); my $p_kills = sprintf("%02d", $kills); print "\n** Your Statistics $date\n\n"; print "Character ............ $character\n"; print "Name ................. $name\n"; print "Game level ........... $p_level\n"; print "Health ............... $p_wizard (-$new_wizard)\n"; print "Damage ............... $p_damage (+$new_damage) Using $weapon +\n"; print "Magic level .......... $p_wizardl (+$new_wizardl)\n"; print "Gold pieces .......... $p_gold\n"; print "Melees won ........... $p_kills\n"; print "Creatures fought ..... $none"; print map { "$_ => ($critters{ $_ })\n " } sort(keys %critters); return2game("\n\nHit 'return' to continue the game.\n>> "); } sub return2game { my $display_txt = shift; print $display_txt; chomp(my $input = <STDIN>); if ($input || $input eq '') { freedale(); } } sub welcome { print <<_EOF_; Welcome $name to Freedale. You are now in Merlyn's castle. ---------------------------------------------------------------------- +- You are surrounded by many people and discussion flows back and forth in the room. Suddenly Merlyn stands up in front of you all and says, \ +"I need a powerful $character to go slay all the monsters that have plag- ued my land, which one of you can raise to the challenge?\". Slowly al +l those in the room rise, including yourself. \"Good, good\" Merlyn mutt +ers. \"Then be off\" Merlyn commands while pointing toward the big oak door +...\n\n _EOF_ $start_done = 1; } sub freedale { dead(); # Ensure we haven't snuffed it print `clear`; print "\n** THE VILLAGE OF FREEDALE **\n\n"; welcome() if $start_done != 1; @msgs = \($lvl_msg, $add_msg); foreach (@msgs) { if (${ $_ }) { print ${ $_ }; ${ $_ } = ''; } } # Show decipher link or not $decipher = $decipher_seen == 1 ? "Type [8] to view Decipher Scroll" + : ''; print "You are in the town square of Freedale.\nWhere would you like + to go next?\n\n"; print "Type [1] for the Forest Type [5] for Freedale Market\n +"; print "Type [2] for the Mountain Type [6] for your Statistics\n +"; print "Type [3] for the Dungeon Type [7] for your Inventory\n" +; print "Type [4] for the Tavern $decipher\n>> "; chomp(my $location = <STDIN>); if ($location !~ /[0-9]/) { freedale($err_msg); } elsif ($location == 1) { forest(); } elsif ($location == 2) { mountain(); } elsif ($location == 3) { dungeon(); } elsif ($location == 4) { tavern(); } elsif ($location == 5) { shop(); } elsif ($location == 6) { stats(); } elsif ($location == 7) { inventory(); } elsif ($location == 8 && $decipher_seen == 1) { decipher(); } elsif ($location == 8 && $decipher_seen == 0) { freedale($err_msg) } elsif ($location == 0 || $location > 8) { freedale($err_msg); } } sub decipher { print `clear`; print <<_EOF_; \n++ DECIPHER SCROLL ++ (type '7' to view the Magic Scroll in the ma +in menu)\n ______________________________________________________________ _____| | +_____ | | 65 = A 75 = K 85 = U 97 = a 107 = k 117 = u | + | | | 66 = B 76 = L 86 = V 98 = b 108 = l 118 = v | + | | | 67 = C 77 = M 87 = W 99 = c 109 = m 119 = w | + | | | 68 = D 78 = N 88 = X 100 = d 110 = n 120 = x | + | | | 69 = E 79 = O 89 = Y 101 = e 111 = o 121 = y | + | | | 70 = F 80 = P 90 = Z 102 = f 112 = p 122 = z | + | | | 71 = G 81 = Q 103 = g 113 = q | + | | | 72 = H 82 = R 104 = h 114 = r | + | | | 73 = I 83 = S 105 = i 115 = s | + | | | 74 = J 84 = T 106 = j 116 = t | + | | | | + | | | NOTE >> The number 32 is a whitespace (hit the space bar) | + | | |______________________________________________________________| + | |________) (___ +_____| _EOF_ return2game("\n\nHit 'return' to continue the game.\n>> "); } sub inventory { print `clear`; print <<_EOF_; ** INVENTORY FOR $name ** \nBelow is a list of the items you are currently carrying;\n\n Weapon .............. $weapon\n _EOF_ print "Items ............... "; if (scalar(@inv_arr) < 1) { print "None"; } else { print join "\n ", @inv_arr; print "\n\n" if $scroll_seen == 1; } scroll() unless $scroll_seen == 0; return2game("\n\nHit 'return' to continue the game.\n>> "); } sub tavern { if ($gold < 2) { $add_msg = "** You are thrown out into the street for not having e +nough money! **\n\n"; freedale(); } print `clear`; print "\n** You enter Freedales TWO PIGS tavern **\n\n"; $gold = $gold - 2; if ($level == 1 || $tavern_seen == 0) { # Only show multiple times on level 1 or once if higher than level + 1 $tavern_seen++; health_check(3); print <<_EOF_; As you enter the tavern you notice a very attractive buxom serving lass, however she doesn't give you more than a cursory glance. The atmosphere is thick with smoke and the mood dark as the locals one by one stare in your direction. \"Get the temperature right\" you hear one drunken old man shout from the shadowy rear of the room, with that you drink your ale, eat your meagre rations and move on... _EOF_ return2game("\n\nHit 'return' to continue the game.\n>> "); } elsif ($level >= 2 && $tavern_seen2 == 0) { # Show only once on any level higher than level 1 $tavern_seen++; $tavern_seen2++; health_check(5); print <<_EOF_; This time as you enter the tavern there are hushed whisperings as one and all turn to face you. "Congratulations on slaying that big Dragon" says the buxom barmaid, "have one on the house" she continues whilst pouring a generous amount of fine wine into a silver goblet. "Come up and see me later" she shouts across the room "I've got a special place in my heart for heroes like you". A smile crosses your face as you quaff your drink and all around you slap your back... _EOF_ return2game("\n\nHit 'return' to continue the game.\n>> "); } elsif ($decipher_seen == 0 && $scroll_seen == 1) { # Strange man with decipher scroll $decipher_seen = 1; push(@inv_arr, "Decipher Scroll"); print <<_EOF_; As you sit minding your own business a strange man who had been watching you from the dark recesses of the room approaches your table as has spotted you pondering the scroll you found. \n\n\"What do the numbers mean?\" you ask yourself. \"I can decipher that scroll for you\" the stranger says in a low voice. \"For the price of a meal and a drink I'll give you the codes you need to read what the scroll has written on it..." \n\nWith that you pay for his meal and leave with a scroll that can be used to decipher the numbers (type '8' in the main menu to view). _EOF_ return2game("\n\nHit 'return' to continue the game.\n>> "); } else { # Default tavern catch routine for third+ visit $tavern_seen++; health_check(10); print <<_EOF_; Treated as an old timer and long time friend you re-enter the tavern, greeted by the usual hussle and torrid smoke you glance the barmaid wink at you through the dense smog. All those around you offer drink and the chance to sit down and relate your tales of 'daring-do'. With a smile and a wink back at the barmaid you sit yourself down and tell those interested of your battles won and deeds accomplished. _EOF_ return2game("\n\nHit 'return' to continue the game.\n>> "); } } sub health_check { # Ensures we cannot give health above the $orig_health setting $extra = shift; $new = $player_health + $extra; if ($new > $orig_health) { $player_health = $orig_health; } else { $player_health = $new; } } sub dead { if ($player_health <= 0) { print `clear`; print <<_EOF_; + _( (~\\ _ _ / ( \\> > \ +\ -/~/ / ~\\ :; \\ _ > /(~\ +\/ || | | /\\ ;\\ |l _____ |; ( \\/ > + > _\\\\)\\)\\)/ ;;; `8o __-~ ~\\ d| \\ + // ///(())(__/~;;\\ "88p;. -. _\\_;.oP (_._/ / (((__ __ \\\\ \\ `>,% (\\ (\\./)8" ;:' +i )))--`.'-- (( ;,8 \\ ,;%%%: ./V^^^V' ;. ;. ((\\ | /)) .,88 `: ..,,;;;;,-::::::'_::\\ ||\\ ;[8: ; )| ~-~ |(|(888; ..``'::::8888oooooo. :\\`^^^/,,~--._ |88:: | |\\ -===- /| \\8;; ``:. oo.8888888888:`((( o.ooo8888Oo;:;:' | |_~-___-~_| `-\\. ` `o`88888888b` )) 888b88888P""' ; ; ~~~~;~~ "`--_`. b`888888888;(.,"888b888" ..::;-' ; ; ~"-.... b`8888888:::::.`8888. .:;;;'' ; ; `:::. `:::OOO:::::::.`OO' ;;;'' : ; `. "``::::::'' .' ; `. \\_ / ; ; +: ~~-- `:' -'; `: : .::/ ; ;;+_ :::. :..;;;\n _EOF_ print "\"Sorry $name\" says Merlyn, \"Thanks for playing, but you +are now dead\".\n"; print "The $creat $has_have taken your life, please try again...\n +"; # Now for some pointless silliness ;^) sleep 12; print `clear`; print <<_EOF_; \n\n ''' |..| o o A CODED WHILST DRUNK PRODUCTION c >) o Dave Barr <barrd\@mac.com> \\'/ Original concept: Kevin Cohe (legolas) /><\\ \n\n _EOF_ exit(0); } } sub dragon { # The BOSS routine that is displayed before going up a level print `clear`; my $glevel = sprintf("%02d", $level); my $ltxt = "Level = $glevel"; print <<_EOF_; _ __,----'~~~~~~~~~`-----. +__ $ltxt . . `//====-_ ___,-' ` -. \\_|// . /||\\\\ `~~~~`---.___./ ______-==. _-~o~ \\/ ||| \\\\ _,'` __,--' ,=='||\\=_ ;_--~/_-'|- |`\\ \\\\ ,' _-' ,=' | \\\\`. '-'~7 /- / || `\\. / .' ,' | \\\\ \\_ / /- / || \\ / / _____ / | \\\\.`-_/ /|- _/ ,|| \\ / ,-' `-|--'~~`--_ \\ `==-/ `| \\'--===-' _/` ' `-| /| )-'\\~' _,--~' '-~~\\_/ | | `\\_ ,~ /\\ / \\ \\__ \\/~ `\\__ _,-' _/'\\ ,-'~____-'`-/ ``=== +\\ A DRAGON appears, ((->/' \\|||' `. ~`-/ , _| +| you must overcome \\_ ~\\ `^---|__i__i__\\--~' +_/ the beast to continue __-^-_ `) \\-.______________,-~' your adventure... //,-'~~`__--^- |-------~~~~~' //,--~~`-\\ _EOF_ } sub levels { # This sub allows a multi level game. Has been added to allow for # expansion. Different monsters may be added, different challenges, # in fact just about anything you can think of... my $num = $kills / $melees_per_level; if ($num =~ /^\d+$/) { # Ensure $num is an integer (fugly) $level++; # Up the level 1 notch $player_health = $orig_health; # Health back to original level (bo +nus) # Up damage level 1 notch (bonus) unless at max $player_damage++ unless $player_damage == $max_damage; $lvl_msg = <<_EOF_; ====================================================================== += CONGRATULATIONS! You have reached level $level ====================================================================== += Merlyn magically appears offering you a health drink, after drinking i +t you feel on top of the world and are ready to continue onward...\n _EOF_ } } sub character { my $ch_err_txt = shift; print `clear`; print "\n\n** CHARACTER CHOICE **\n\n"; if ($ch_err_txt) { print $ch_err_txt; } print "Welcome to Freedale\nWhich character would you like to be?\n\ +n"; print "Type [1] for Elf\nType [2] for Warrior\nType [3] for Wizard\n +>> "; chomp(my $char = <STDIN>); if ($char == 1) { $character = "Elf"; } elsif ($char == 2) { $character = "Warrior"; } elsif ($char == 3) { $character = "Wizard"; } else { character($err_msg); } } sub bonus { # This sub is called after battle/magic and randomly chooses whether + or # not to give the player some goodies in the form of extra gold piec +es # and health my $bonus = int(rand 9) + 1; if ($bonus >= 8) { my $bonus_gold = int(rand 2) + 2; $add_msg = "** The Gods smile upon you, you've found another $bonu +s_gold gold pieces. **\n\n"; $gold = $gold + $bonus_gold; health_check($bonus); } }