ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/maps/perl/chat.ext
(Generate patch)

Comparing deliantra/maps/perl/chat.ext (file contents):
Revision 1.20 by root, Wed Jul 19 08:52:57 2006 UTC vs.
Revision 1.21 by root, Wed Jul 19 22:20:07 2006 UTC

2 2
3# implement a replacement for the built-in say/chat/shout/tell/reply commands 3# implement a replacement for the built-in say/chat/shout/tell/reply commands
4# adds ignore/unignore functionality 4# adds ignore/unignore functionality
5 5
6use NPC_Dialogue; 6use NPC_Dialogue;
7
8sub valid_user($) {
9 cf::player::find $_[0]
10 or -f sprintf "%s/%s/%s/%s.pl", cf::localdir, cf::playerdir, ($_[0]) x 2;
11}
12 7
13sub clean_timeouts($) { 8sub clean_timeouts($) {
14 my ($player) = @_; 9 my ($player) = @_;
15 my $NOW = time; 10 my $NOW = time;
16 11
48 } else { 43 } else {
49 $who->message ("Your verbose level is " . $player->listening . ".", cf::NDI_UNIQUE); 44 $who->message ("Your verbose level is " . $player->listening . ".", cf::NDI_UNIQUE);
50 } 45 }
51}; 46};
52 47
53cf::register_command xsay => 0, sub { 48cf::register_command say => 0, sub {
54 my ($who, $msg) = @_; 49 my ($who, $msg) = @_;
55 50
56 if ($msg) { 51 if ($msg) {
57 my $name = $who->name; 52 my $name = $who->name;
58 53
59 my @messages = (["$name says: $msg", cf::NDI_GREY | cf::NDI_UNIQUE]); 54 $_->ob->message ("$name says: $msg", cf::NDI_GREY | cf::NDI_UNIQUE)
55 for grep $who->on_same_map_as ($_->ob), cf::player::list;
60 56
61 # npcs, magic_ears etc. 57 # npcs, magic_ears etc.
62 # first find all objects and their inventories within a 5x5 square 58 # first find all objects and their inventories within a 5x5 square
63 # that have something resembling dialogue 59 # that have something resembling dialogue
64 my ($map, $x, $y) = ($who->map, $who->x - 2, $who->y - 2); 60 my ($map, $x, $y) = ($who->map, $who->x - 2, $who->y - 2);
76 my $dialog = new NPC_Dialogue ob => $who, npc => $npc; 72 my $dialog = new NPC_Dialogue ob => $who, npc => $npc;
77 my $reply = $dialog->tell ($msg); 73 my $reply = $dialog->tell ($msg);
78 74
79 if (defined $reply) { 75 if (defined $reply) {
80 if ($npc->type == cf::MAGIC_EAR) { 76 if ($npc->type == cf::MAGIC_EAR) {
81 push @messages, [$reply, cf::NDI_BROWN | cf::NDI_UNIQUE] if length $reply; 77 if (length $reply) {
78 $_->ob->message ($reply, cf::NDI_BROWN | cf::NDI_UNIQUE)
79 for grep $who->on_same_map_as ($_->ob), cf::player::list;
80 }
82 $npc->use_trigger; 81 $npc->use_trigger;
83 } else { 82 } else {
83 if (length $reply) {
84 push @messages, [$npc->name . " says: $reply", cf::NDI_BROWN | cf::NDI_UNIQUE] if length $reply; 84 $_->ob->message ($npc->name . " says: $reply", cf::NDI_BROWN | cf::NDI_UNIQUE)
85 for grep $who->on_same_map_as ($_->ob), cf::player::list;
86 }
85 } 87 }
86 } 88 }
87 }
88
89 # send replies to all players on this map
90 for (@messages) {
91 my ($msg, $flags) = @$_;
92
93 $_->ob->message ($msg, $flags)
94 for grep $who->on_same_map_as ($_->ob), cf::player::list;
95 } 89 }
96 90
97 } else { 91 } else {
98 $who->message ("What do you want to say?", cf::NDI_UNIQUE); 92 $who->message ("What do you want to say?", cf::NDI_UNIQUE);
99 } 93 }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines