Crossfire Archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: CF: Suggestion: Talking (was Re: CF: Suggestion: Reg exps...)



On Thu, 24 Sep 1998, Risto Järvinen <rjarvine@cc.hut.fi> wrote:
> An extension, of some kind, would be sub-listing the keywords by 'mood' :
> When you cite a certain keyword the mood of the listener changes, changing
> the active list of keywords and perhaps other variables?  (You could
> actually make some-CF-creature angry by talking...)
> 
> In addition it would seem proper to allow peoples to have 'connections',
> so you wouldn't have to scatter weird magic-ears all over the places...

Some time ago, I thought about improving the NPC interaction in
Crossfire.  I think that I mentioned it on this list two years ago,
but I am not sure.  Anyway, I never had the time to implement it, so
these are only some ideas.

Instead of integrating a sophisticated scripting language into
Crossfire, I wanted to keep it simple.  So I was planning to extend
the "@match" stuff with three new commands:

* Two conditional statements:
    @match <expr> ...
    @if <var>=<number> ...

* Two "actions":
    @activate <number>
    @set <var>=<number>

The <var> above are some variables that could be associated with the
NPC.  I'm sure that there are one or two unused fields in the object
structure that we could use to store this info.  So we could have
three variables named A, B and C, for example.  These variables would
be initialized at 0 when the character is created, and their meaning
would be left up to the map author.

The combination of @set and @if could be used to implement a simple
state machine for the NPC.  For example, we could use the variable A
to store the mood of the character:

  @if A=0
    ... (the ususal @match commands and replies)
    @match moron
      @set A=1
      Stop insulting me!
  @if A=1
    @match *
      I do not talk to rude people...
    @match sorry
      @set A=0

The @activate command can also be added somewhere, and it would
trigger all objects (doors, teleporters, etc.) that are connected to
that number.  That would be the same as the magic ear, except that it
could use the @if statement to activate the other objects only if some
condition is true.

The @if statements could not be used inside another @if or @match
condition, in order to keep the parser simple.  There is no need for a
@endif, because it is implicit.  Even with this limited language, it
would already be possible to do a lot of things, because the variables
could be used to tell the character to "remember" something from a
previous discussion.

I also considered adding another conditional statement @connect, which
would be the opposite of @activate: the NPC would be activated (and
would say something or execute some @set statements) if some button,
lever or altar is activated.  For example, the NPC could have an
invisible altar in front of him, and say "Give me some food" until
some food is dropped.  When the food is dropped on the altar, that
would trigger the @connect statement, which in turn would cause the
NPC to say "Thank you" and @set his mood differently.  But adding this
@connect stuff could cause some problems, and it would be necessary to
forbid @activate inside @connect statements (potential deadlocks).

Of course, a more complex scripting language could do much more than
that.  But implementing these 4 or 5 commands should not be too hard.
Errr...  I never did it, but if there are any volunteers out there...

-Raphael