New Hugo sample game

This is a discussion / support forum for the Hugo programming language by Kent Tessman. Hugo is a powerful programming language for making text games / interactive fiction with multimedia support.

Hugo download links: https://www.generalcoffee.com/hugo
Roody Yogurt's Hugo Blog: https://notdeadhugo.blogspot.com
The Hugor interpreter by RealNC: http://ifwiki.org/index.php/Hugor

Moderators: Ice Cream Jonsey, joltcountry

Johnny
Posts: 36
Joined: Sat Oct 15, 2005 4:30 pm
Location: Humble, Texas

New Hugo sample game

Post by Johnny »

A Hugo port of Kevin Wilson's The Underoos That Ate New York!

Code: Select all

!---------------------------------------------------------------------------
! This is now working. Needs some fixes.
!---------------------------------------------------------------------------

#set DEBUG     ! Include the HugoFix Debugging Library
#set VERBSTUBS ! Include verb stub routines

#ifset DEBUG
#switches -d
#endif

verb "spray"
  *                         DoVague
  * object                  DoSpray
  * held "at" object        DoSpray
  * object "with" held      DoSpray

xverb "full"
  *                         DoFullScore
  * "score"                 DoFullScore

xverb "xyzzy"
  *                         DoXyzzy

#include "verblib.g"      ! grammar must come first

#ifset PRECOMPILED_LIBRARY
#link "hugolib.hlb"
#else
#include "hugolib.h"
#endif

global monster
global silence
global secret

attribute clatters

routine init
{
  counter = -1
  MAX_SCORE = 6

  STATUSTYPE = 1                  ! score/turns
  TEXTCOLOR = DEF_FOREGROUND
  BGCOLOR = DEF_BACKGROUND
  SL_TEXTCOLOR = DEF_SL_FOREGROUND
  SL_BGCOLOR = DEF_SL_BACKGROUND

  prompt = ">"
  color TEXTCOLOR, BGCOLOR

  cls

  "Yesterday, as you were walking through Central Park, a meteorite 
  crashed nearby, bathing you in cosmic radiation. It only made the 
  twelth page of the paper, under Dear Abby. Of course, if anyone could 
  have foreseen the awful effects of that accident, it surely would have 
  been a front page story. But there was no way for you, or anyone else, 
  to predict that the result of that accident would be...\n"

  Font(BOLD_ON | DEFAULT_FONT)
  "The Underoos That Ate New York!"
  Font(BOLD_OFF)
  "An Interactive Quickie by G. Kevin Wilson. Hugo Port by JJR."
  "(c) 1994-2009. All Rights Reserved."
  "Type \Bxyzzy\b for help and information."
  print BANNER

  player = you                    ! player initialization
  location = bedroom
  old_location = location
  
  move player to location
  FindLight(location)
  move player to shazam
  DescribePlace(location)
  location is visited

  "\nUh oh. Your date with Cindy is in 20 minutes. Better hurry and get
  dressed! Now, where's that underwear?"

  CalculateHolding(player)

#ifset USE_PLURAL_OBJECTS
  InitPluralObjects
#endif
}

#ifset PRECOMPILED_LIBRARY
replace main
{
#else
routine main
{
#endif
  counter = counter + 1
  PrintStatusLine
  run location.each_turn
  runevents
  RunScripts
  if parent(speaking)~=location
    speaking = 0
}

player_character you "you"
{}

room bedroom "Your Bedroom"
{
  long_desc
  "Home sweet home for a '60s throwback bachelor like yourself. Assorted, 
  but unimportant decorations litter the walls and ceiling. To the west is 
  a door that, as you fuzzily recall, leads into your walk-in closet. To 
  the east is a hallway, that, as you even more fuzzily recall, leads to 
  the kitchen."
  e_to
  {
    if (underoos is hidden) {
      "You don't like the chill wind blowing in off the kitchen tiles. 
      Maybe you could at least have a look round for your underoos 
      first?"
    }
    else
      return kitchen
  }
  w_to closet_door
}

scenery shazam "bed"
{
  noun "bed"
  adjective "my"
  article "your"
  long_desc
    "This is your bed."
  in bedroom
  is enterable, platform
  before
  {
    object DoLookUnder
    {
      if player in shazam
        "You lean over the edge and try to peer under the bed, but 
        the blood rushes to your head and your eyes refuse to focus."
      elseif (self is not special)
      {
        "You find your Ruby Poo underoos."
        underoos is not hidden
        self is special
      }
      else
      {
        "You don't find anything else."
      }
    }
  }
  w_to closet_door
}

object underoos "Ruby Poo underoos"
{
  noun "underoos", "underwear"
  adjective "ruby", "poo"
  article "your"
  initial_desc {print "You see "; The(self); " here."}
  in bedroom
  is clothing, hidden
  long_desc
  "Ah. Your good ole Ruby Poo underoos. The luckiest of lucky underwear. 
  You've worn them every time you've ever gotten lucky. But then, maybe 
  that has something to do with never changing them. Naaah."
  before
  {
    object DoGet
    {
      "As you pick your underwear up, something utterly unbelievable 
      happens. The underwear begins struggling in your grasp! Finally, 
      it bites you on the hand, causing you to drop it. It huddles in 
      the corner, growling."
      move liveundies to bedroom
      remove self
    }
  }
}

door closet_door "closet door"
{
  noun "door"
  adjective "closet"
  article "the"
  between closet, bedroom
  before
  {
    object DoOpen
    {
      closet is light
      return false
    }
    object DoClose
    {
      closet is not light
      return false
    }
  }
}

scenery decorations "decorations"
{
  noun "decorations"
  article "the"
  is plural
  in bedroom
  long_desc: "Assorted, but useless."
}

room closet "Your Closet"
{
  long_desc
  "Ah, the cathedral of clothes. Only, um. I wonder why it's empty? The 
  exit lies back to the east."
  e_to closet_door
  is not light
}

room kitchen "Your Kitchen"
{
  long_desc
  "Kitchen (ki' chun) n. - A place in which food is prepared. This 
  particular ki' chun has a toaster, a fridge, a hallway leading west, a 
  dark passageway leading into the cellar, and a hallway leading north to 
  the entryway."
  before
  {
    location DoDrop
    {
      if (object is clatters)
      {
        if parent(sock) = toaster
        {
          print "When you drop "; The(object); " it clatters on 
          the floor, waking up the socks! They leap from the 
          toaster, latching on to you with their terrible elastic 
          mouths. Gradually, the venom in their bite overcomes 
          you, and you pass out..."
          endflag = 2
        }
        else
        {
          print CThe(object); " clatters noisily on the kitchen 
          floor tiles."
          move object to self
        }
      }
    }
  }
  w_to bedroom
  d_to
  {
    if (self is not special and shoes is not worn)
    {
      "As you recall, there's an awful lot of broken glass, rusting 
      staples, and the like down there. It would probably be good to 
      make sure you're wearing shoes before you go down these stairs. 
      But, if you want to chance it anyways, then on your head lies 
      the blame."
      self is special
    }
    elseif (deadundies is not worn)
    {
      "You want to walk down into that freezing cellar without even 
      the barest of protection?  No way, go put some underwear on."
    }
    else
      return cellar
  }
  n_to entryway
}

object broom "broom"
{
  noun "broom"
  article "a"
  initial_desc: "There is a broom leaning against the counter."
  long_desc
  "Your broom. There is a rubbermade sticker on the end
  of it, near the bristles."
  in kitchen
  is clatters
}

component sticker "sticker"
{
  part_of broom
  noun "sticker", "rubbermade"
  article "a"
  long_desc: "It reads \"Rubbermade\"."
  before {
    object DoGet
    {
      if self.part_of = broom
        "It's stuck to the broom."
      else
      {
        "Respectfully, you pick up the sticker,
        then, on a sudden impulse, you tie it
        around your head, like a bandana. Your
        broom will not go unavenged!"
        move bandana to player
        Activate(bandaemon)
        remove self
      }
    }
  }
}

daemon bandaemon
{}

event in bandaemon
{
  local rand
  rand = random(100)
  if bandana is worn and rand <11> 0&#58; ""
for &#40;i = 0; i < 6; i++&#41; &#123;
  if tasks&#91;i&#93; ~= 0 &#123;
    print "\_   1 point for ";
    select i
    case 0&#58; "dodging tetanus";
    case 1&#58; "practicing your karate";
    case 2&#58; "freshening your shoes up";
    case 3&#58; "collecting insects";
    case 4&#58; "defeating the lurking socks";
    case 5&#58; "paying your respects &#40;easter egg&#41;";
    ""
  &#125;
&#125;
&#125;

routine DoSpray
&#123;
  if object ~= nothing or lysol and xobject = nothing and
    parent&#40;lysol&#41; = player
  &#123;
    print "&#40;with "; The&#40;lysol&#41;; "&#41;"
    xobject = lysol
  &#125;

  if xobject = lysol
  &#123;
    xobject = object
    object = lysol
  &#125;

  if object = lysol
  &#123;

    if location = closet and closet_door is not open
    &#123;
      "Probably not a good idea. These aerosols can be lethal in 
      small, enclosed areas."
    &#125;
    elseif location = kitchen and sock in toaster
    &#123;
      "The socks are awakened by the hissing of the aerosol can. They 
      leap from the toaster in a flash, fastening themselves onto your 
      body with their terrible elastic mouths. You struggle mightily 
      in their grip, but to no avail. Gradually, the venom from their 
      bite drags you down into oblivion."
      endflag = 2
    &#125;
    elseif xobject = liveshoes
      run liveshoes.flee
    else
      "Mmm. Lemon scent!"
  &#125;
  else&#58; print CThe&#40;actor&#41;; " can't spray that!"
&#125;

routine DoXyzzy
&#123;
  "A hollow voice says, \"This is a short sample 'game' designed to test 
  out some programming ideas I had. It pays homage to the bad old sci-fi B 
  movies. The material here is, I suppose, vaguely mystifying to small 
  children, so parents be warned, play it through first yourself, and make 
  your own decision about it.\""
&#125;

! New non-verb routines

routine Achieved&#40;task&#41;
&#123;
  if tasks&#91;task&#93; = 0
    tasks&#91;task&#93; = 1
  score++
&#125;

routine NumSP&#40;num, sing, plur&#41;
&#123;
  print number num; " ";
  if num = 1
    print sing;
  else
    print plur;
&#125;

routine Pardon
&#123;
  print "What?"
&#125;

routine PrintRank
&#123;
print ". This gives you a rank of&#58; ";
if monster
&#123;
  select score
  case 0&#58; "Dirty Mutant";
  case 1&#58; "Shoeless Kong";
  case 2&#58; "Gamera Wearing Matching Socks";
  case 3&#58; "Well Groomed Werewolf";
  case 4&#58; "Fashion Hound of the Baskervilles";
  case 5&#58; "Sharp Dressed Mothra";
  case 6&#58; "Easter Egg Godzilla";
&#125;
else
&#123;
  select score
  case 0&#58; "Dirty Underwear";
  case 1&#58; "Shoeless Joe";
  case 2&#58; "Color Coordinated";
  case 3&#58; "Well Groomed";
  case 4&#58; "Fashion Hound";
  case 5&#58; "Sharp Dressed Man";
  case 6&#58; "Easter Egg Guru";
&#125;
print ". "
&#125;

! Replaced routines

replace PrintEndGame&#40;end_type&#41;
&#123;
  Font&#40;BOLD_ON&#41;
  select end_type
  case 1
  &#123;
    print "\n* * * Congratulations";
    if secret&#58; ", you've found the secret ending!";
    elseif monster&#58; "... you've won, I guess...";
    else&#58; ", you've won!";
    " * * *"
  &#125;
  case 2
  &#123;
    if player_person = 2
      print "\n* * * You have died! * * *"
    else
      print "\n* * * "; CThe&#40;player&#41;; \
        MatchPlural&#40;player, "has", "have"&#41;; \
        " died! * * *"
  &#125;

  Font&#40;BOLD_OFF&#41;
  PrintScore&#40;true&#41;
&#125;

replace PrintScore&#40;end_of_game&#41;
&#123;
  print "In a total of ";
  NumSP&#40;counter, "turn", "turns"&#41;
  print ", you ";
  if not end_of_game
    print "have ";
  print "solved ";
  NumSP&#40;score, "puzzle", "puzzles"&#41;
if not secret
  PrintRank
else
  ". As for your score, you found the secret ending.
  That's all that really matters, isn't it?"
!  ". Plus, you found the secret ending!"
&#125;

global dark_warning = 0

replace DarkWarning
&#123;
if not dark_warning
&#123;
  "It's pitch black! You are likely to be eaten by a sock."
  dark_warning = 1
&#125; else &#123;
  if random&#40;3&#41; = 1 &#123;
    "Oh no! You walked into the slavering fangs of a lurking sock!"
    endflag = 2
  &#125; else
    "It's pitch black! You are likely to be eaten by a sock."
&#125;
&#125;

replace NewParseError&#40;errornumber, obj&#41;
&#123;
  local retval = false

  select errornumber

  case 0 &#123;
    Perform&#40;&Pardon, 0, 0, 0, 1&#41;

    retval = true
  &#125;

  return retval
&#125;


Last edited by Johnny on Tue Apr 27, 2010 3:59 pm, edited 5 times in total.

Hugella
Posts: 73
Joined: Mon Jun 28, 2004 4:45 pm
Location: Minneapolis, Minnesota

Post by Hugella »

Thanks, Johnny! Always good to see new Hugo material.

Post Reply