--- deliantra/server/ext/NPC_Dialogue.pm 2007/08/25 16:51:38 1.7 +++ deliantra/server/ext/NPC_Dialogue.pm 2008/09/22 01:33:09 1.11 @@ -14,12 +14,6 @@ use strict; -sub has_dialogue($) { - my ($ob) = @_; - - $ob->msg =~ /^\@match /; -} - sub parse_message($) { map [split /\n/, $_, 2], grep length, @@ -127,7 +121,7 @@ @match found earhorn @cond grep $_->slaying =~ /Gramp's walking stick/, $who->inv - @eval my @g = grep { $_->slaying =~ /Gramp's walking stick/ } $who->inv; $g[0]->decrease_ob_nr (1); + @eval my @g = grep { $_->slaying =~ /Gramp's walking stick/ } $who->inv; $g[0]->decrease; Thanks for the earhorn! This example is a bit more complex. The C<@eval> statement will search @@ -215,6 +209,17 @@ Trigger all objects with the given connected-id by 'releasing' the connection. +=item @playersound face-name + +Plays the given sound face (either an alias or sound file path) so that +only the player talking to the npc can hear it. + +=item @npcsound face-name + +Plays the given sound face (either an alias or sound file path) as if +the npc had made that sound, i.e. it will be located at the npc and all +players near enough can hear it. + =item @addtopic topic Adds the given topic names (separated by C<|>) to the list of topics @@ -265,6 +270,12 @@ } elsif ($cmd eq "comment") { # nop + } elsif ($cmd eq "playersound") { + $self->{ob}->contr->play_sound (cf::sound::find $args); + + } elsif ($cmd eq "npcsound") { + $self->{npc}->play_sound (cf::sound::find $args); + } elsif ($cmd eq "cond") { cf::safe_eval $args, %vars or next topic; @@ -323,10 +334,6 @@ delete $self->{npc}{$self->{ob}->name}{dialog_state} unless %$state; delete $self->{ob}{dialog_flag} unless %$flag; - # combine lines into paragraphs - $reply =~ s/(?<=\S)\n(?=\w)/ /g; - $reply =~ s/\n\n/\n/g; - # ignores flags and npc from replies $reply = join "\n", (map $_->[1], @replies), $reply;