NPCs and Conversations?

Here’s a bit of advanced trickery that may be helpful:

(understand [test])
(perform [test])
        Hello.
        (if) (dbg) (then) Dumping some info. (endif)
        World?

(dbg)   (fail)

The compiler will figure out that (dbg) always fails, so the entire if-clause will be eliminated, and does not appear in the output from (trace on). Neither will the text string “Dumping some info.” appear in the compiled storyfile.

To enable debug printouts, add this definition anywhere:

@(dbg)

You could even put that line in a separate file, and mention that file on the command-line when starting the debugger. The trick here is that @(dbg) is declared as an access predicate for a conjunction of no terms. Such a conjunction always succeeds. Meanwhile, the line (dbg) (fail) is now interpreted as an instruction to add no rule definitions, each having a body of (fail); that is, it has no effect.

The if-condition no longer contains a query, so it doesn’t clutter the trace output. But it always succeeds, so the debug text is printed.

Finally, you have the option to do something like this (instead of defining an access predicate):

(understand command [debug on])
(perform [debug on])
        (now) (dbg)

(understand command [debug off])
(perform [debug off])
        (now) ~(dbg)

This adds a little bit of clutter to the trace output, since a global flag needs to be checked.

1 Like

Some sugar syntax, like (debug) Dumping some info. (end) would be very nice. Perhaps it could add a (line) before and after. Possibly some color change to the output to highlight that it is debug only.

I’ve found that (trace on) just overloads me with output; perhaps because most of what I’m doing is deep in the understand predicates which are very complicated before, during, and after the threaded conversation quip recognizing code. I do get more manageable output by tracing a manual call to understand though.

Threaded Conversations: I wanted links for the suggested quips so I made some simple edits; feel free to incorporate these changes into the library.

(describe action [discuss (questioning quip $Quip)])
    (if) (library links enabled) (then)
        (collect words)
            (name $Quip)
        (into $Words)
        (link [ask | $Words]) { ask (name $Quip) }
    (else)
        ask (name $Quip)
    (endif)

(describe action [discuss (informative quip $Quip)])
    (if) (library links enabled) (then)
        (collect words)
            (name $Quip)
        (into $Words)
        (link [say | $Words]) { say (name $Quip) }
    (else)
        say (name $Quip)
    (endif)

(describe action [discuss (performative quip $Quip)])
    (if) (library links enabled) (then)
        (collect words)
            (name $Quip)
        (into $Words)
        (link $Words) (name $Quip)
    (else)
        (name $Quip)
    (endif)

Threaded Conversations seems to fit most of my needs, but there is one behavior that I don’t like that I would argue should be changed. Currently, repeatable quips do not get suggested after the player has selected them once. I think this defeats the purpose of making a quip repeatable; my specific use case is that I want to be able to “say follow me” and “say stay here” as commands to an NPC, and it would be a pain to have to type it out when they could be suggested (and linked with code from my previous post). Is there a good reason this shouldn’t be done? Maybe to preserve the current behavior as well it would be best for there to be another quip property saying if threaded conversations recommends a repeatable quip repeatedly or not?

I’m glad to accept PRs. I haven’t played with the link functionality so far. Also, seems like there might be a common rule that could encapsulate a lot of this logic.

I could imagine another trait to control this behavior. Maybe also better breakdown of rules related to quips, and the ability to identify them as likely, unlikely, or dubious; as in, a repeatable quip would normally be unlikely to repeat, but if we lay out the rules correctly, this could be overridden for specific quips, allowying your “follow me” quip to be likely,