Making any command affect a different object (Quest)

I've seen a few people mention this, and thought I should give it a try.
The basic idea is making a command or verb apply to a different example. For example, making "switch on chandelier" act as if the player typed "switch on light switch", while allowing both objects to have separate descriptions for the purpose of looking at them. Or making "unlock gate" be the same as "unlock brass padlock", if the lock is a separate object.

The idea here is that you might want using a specific command (or list of commands) automatically transfer to a different object. This might be easy to do with verbs, but with some commands (such as "open") it can be needlessly complex. So why not let the parser do it?

  <function name="AddToResolvedNames" parameters="var, result">
    if (TypeOf(result) = "object") {
      result = GetIndirectObject (result, game.pov.currentcommandpattern.name, var)
    else if (EndsWith (TypeOf(result), "list")) {
      indirect = NewObjectList()
      foreach (obj, result) {
        list add (indirect, GetIndirectObject (result, game.pov.currentcommandpattern.name, var)
      }
      result = indirect
    }
    if (TypeOf(result) = "object") {
      if (result.type = "object") {
        list add (game.pov.currentcommandresolvedobjects, result)
      }
    }
    else if (TypeOf(result) = "objectlist") {
      foreach (obj, result) {
        if (obj.type = "object") {
          list add (game.pov.currentcommandresolvedobjects, obj)
        }
      }
    }
    dictionary add(game.pov.currentcommandresolvedelements, var, result)
    ResolveNextName
  </function>

  <function name="GetIndirectObject" parameters="object, command, var" type="object">
    if (object = null) {
      return (object)
    }
    if (not HasAttribute (object, "indirectcommandobjects")) {
      return (object)
    }
    if (DictionaryContains (object.indirectcommandobjects, command.name + "/" + var)) {
      return (ObjectDictionaryItem (object.indirectcommandobjects, command.name + "/" + var))
    }
    if (DictionaryContains (object.indirectcommandobjects, command.name)) {
      return (ObjectDictionaryItem (object.indirectcommandobjects, command.name))
    }
  </function>

This allows any object to have a dictionary indirectcommandobjects which is an objectdictionary. Its key is the name of the command (so "switch on" for the chandelier, or "open" for the desk in my examples), and the value is the object which the command should apply to instead.

The object is replaced with its indirect object after all the fiddling with disambiguation menus and similar, so I think it will allow compound objects (such as separate objects for a door, latch, and keyhole, for example) to be handled more elegantly without causing any other problems.


This topic is now closed. Topics are closed after 60 days of inactivity.

Support

Forums