Thursday, May 8, 2014

>EXAMINE HACKER'S KEYRING

One of the things I've wanted for Hugo was an automated way to support possessive adjectives when referring to characters' belongings.  Since Hugo doesn't really give you complete control over the grammar, this is pretty hard to do.  Recently, I coded the best solution I could come up with.  Basically, it's a wrapper routine for Acquire that sets or clears adjectives as needed.  The downside is, you'd have to add an extra empty element to any object that might be used with it, like this:

       

object potato "potato"
{
 article "a"
 adjective "hot" 0
 noun "potato"
 in you
}

       
 

Now, I couldn't really decide on an intuitive name for the routine, but since I figured it was for games where objects are passed around between characters a lot, I opted for the name "HotPotato":

       

attribute keep_adjectives
routine HotPotato(obj,new_parent)
{
 local a
 a = parent(obj)
 if a is living and obj is not keep_adjectives
 {
  if CharacterKey(a)
   obj.adjective #(obj.#adjectives) = 0
 }
 if not new_parent
  remove obj
 else
 {
  a = CharacterKey(new_parent)
  if Acquire(new_parent, obj) and obj is not keep_adjectives
  {
   if a
    obj.adjective #(obj.#adjectives) = a
  }
 
}
       
 

If not provided with a "new_parent" object, HotPotato just removes the object after clearing any applicable adjectives.  Any game that uses this would have to provide its own CharacterKey routine, which would look like this:

       
routine CharacterKey(char)
{
 local a
 select char
  case fred: a = "fred's"
  case player: a = "my"
 return a
}
       
 

Now, all of this work is kind of useless since among games with characters, there usually isn't so much object-swapping that most of this couldn't be done by hand.  Plus, you'll notice that HotPotato only checks for one layer of containment in characters and there might be games where you'd want to check for grandchildren (or further).  Still, this is as close to automating this in Hugo as it's going to get, I think.

There's also the issue of words like "your","my","his", and "her" (>ASK FRED ABOUT HIS HAT).  I find the best solution is to just define these words as removals so the parser completely ignores them.

       
removal "his","her"
removal "my","your"
       
 
How many of these you define as removals depends on your game (games like Spur use "your" as a permanent adjective for certain things).  Also, because of games like Spur where some objects keep a certain ownership despite who is carrying them (like, "your gun" compared to "O'Grady's gun"), I added that keep_adjectives attribute to give objects that should be left alone.