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.32 by root, Fri Aug 25 13:33:57 2006 UTC vs.
Revision 1.36 by root, Wed Aug 30 08:34:20 2006 UTC

1#! perl 1#! perl
2#CONVERSION: PARTIAL
2 3
3# implement a replacement for the built-in say/chat/shout/tell/reply commands 4# implement a replacement for the built-in say/chat/shout/tell/reply commands
4# adds ignore/unignore functionality 5# adds ignore/unignore functionality
5 6
6use NPC_Dialogue; 7use NPC_Dialogue;
52cf::register_command say => 0, sub { 53cf::register_command say => 0, sub {
53 my ($who, $msg) = @_; 54 my ($who, $msg) = @_;
54 55
55 utf8::decode $msg; 56 utf8::decode $msg;
56 57
58 return if $who->contr->invoke (cf::EVENT_PLAYER_SAY, $msg);
59
57 if ($msg) { 60 if ($msg) {
58 my $name = $who->name; 61 my $name = $who->name;
59 62
60 utf8::encode $msg; # ->message not yet utf8-ified 63 utf8::encode $msg; # ->message not yet utf8-ified
61 $_->ob->message ("$name says: $msg", cf::NDI_GREY | cf::NDI_UNIQUE) 64 $_->ob->message ("$name says: $msg", cf::NDI_GREY | cf::NDI_UNIQUE)
62 for grep $who->on_same_map_as ($_->ob), cf::player::list; 65 for grep $who->on_same_map_as ($_->ob), cf::player::list;
63 utf8::decode $msg; 66 utf8::decode $msg;
64 67
65 # npcs, magic_ears etc. 68 # npcs, magic_ears etc.
66 # first find all objects and their inventories within a 5x5 square 69 # first find all objects and theirt-level inventories
67 # that have something resembling dialogue 70 # within a 5x5 square # that have something resembling
71 # dialogue or support on_say.
68 my ($map, $x, $y) = ($who->map, $who->x - 2, $who->y - 2); 72 my ($map, $x, $y) = ($who->map, $who->x - 2, $who->y - 2);
69 73
70 for my $npc ( 74 for my $npc (
71 grep NPC_Dialogue::has_dialogue $_, 75 grep +($_->invoke (cf::EVENT_OBJECT_SAY, $who->contr, $msg) && return) || NPC_Dialogue::has_dialogue $_,
72 map +($_, $_->inv), 76 map +($_, $_->inv),
73 grep $_, 77 grep $_,
74 map $map->at ($x + $_ % 5, $y + (int $_ / 5)), 78 map $map->at ($x + $_ % 5, $y + (int $_ / 5)),
75 0..24 79 0..24
76 ) { 80 ) {
109cf::register_command chat => 0, sub { 113cf::register_command chat => 0, sub {
110 my ($who, $msg) = @_; 114 my ($who, $msg) = @_;
111 115
112 utf8::decode $msg; 116 utf8::decode $msg;
113 117
118 return if $who->contr->invoke (cf::EVENT_PLAYER_CHAT, $msg);
119
114 if ($msg) { 120 if ($msg) {
115 my $name = $who->name; 121 my $name = $who->name;
116 my $NOW = time; 122 my $NOW = time;
117 123
118 utf8::encode $msg; # ->message not yet utf8-ified 124 utf8::encode $msg; # ->message not yet utf8-ified
119# cf::LOG cf::llevDebug, sprintf "QBERT [%s] %s\n", $name, $msg; 125# cf::LOG cf::llevDebug, sprintf "QBERT [%s] %s\n", $name, $msg;
120 cf::ext::schmorp_irc::do_notice (sprintf "[%s] %s", $name, $msg); 126 ext::schmorp_irc::do_notice (sprintf "[%s] %s", $name, $msg);
121 127
122 $_->ob->message ("$name chats: $msg", cf::NDI_BLUE) 128 $_->ob->message ("$name chats: $msg", cf::NDI_BLUE)
123 for grep { $_->ob->{ext_ignore_shout}{$name} < $NOW && $_->listening >= 10 } cf::player::list; 129 for grep { $_->ob->{ext_ignore_shout}{$name} < $NOW && $_->listening >= 10 } cf::player::list;
124 130
125 } else { 131 } else {
129 135
130cf::register_command shout => 0, sub { 136cf::register_command shout => 0, sub {
131 my ($who, $msg) = @_; 137 my ($who, $msg) = @_;
132 138
133 utf8::decode $msg; 139 utf8::decode $msg;
140
141 return if $who->contr->invoke (cf::EVENT_PLAYER_SHOUT, $msg);
134 142
135 if ($msg) { 143 if ($msg) {
136 my $NOW = time; 144 my $NOW = time;
137 my $name = $who->name; 145 my $name = $who->name;
138 146
139# cf::LOG cf::llevDebug, sprintf "QBERT {%s} %s\n", $name, $msg; 147# cf::LOG cf::llevDebug, sprintf "QBERT {%s} %s\n", $name, $msg;
140 cf::ext::schmorp_irc::do_notice (sprintf "{%s} %s\n", $name, $msg); 148 ext::schmorp_irc::do_notice (sprintf "{%s} %s\n", $name, $msg);
141 149
142 utf8::encode $msg; # ->message not yet utf8-ified 150 utf8::encode $msg; # ->message not yet utf8-ified
143 $_->ob->message ("$name shouts: $msg", cf::NDI_RED) 151 $_->ob->message ("$name shouts: $msg", cf::NDI_RED)
144 for grep { $_->ob->{ext_ignore_shout}{$name} < $NOW && $_->listening >= 2 } cf::player::list; 152 for grep { $_->ob->{ext_ignore_shout}{$name} < $NOW && $_->listening >= 2 } cf::player::list;
145 153
152cf::register_command tell => 0, sub { 160cf::register_command tell => 0, sub {
153 my ($who, $args) = @_; 161 my ($who, $args) = @_;
154 my ($target, $msg) = split /\s+/, $args, 2; 162 my ($target, $msg) = split /\s+/, $args, 2;
155 163
156 utf8::decode $msg; 164 utf8::decode $msg;
165
166 return if $who->contr->invoke (cf::EVENT_PLAYER_TELL, $target, $msg);
157 167
158 my $name = $who->name; 168 my $name = $who->name;
159 169
160 if (my $other = cf::player::find $target) { 170 if (my $other = cf::player::find $target) {
161 171
185 my ($who, $args) = @_; 195 my ($who, $args) = @_;
186 my $name = $who->name; 196 my $name = $who->name;
187 197
188 utf8::decode $args; 198 utf8::decode $args;
189 199
200 return if $who->contr->invoke (cf::EVENT_PLAYER_TELL, $who->{ext_last_tell}, $args);
201
190 if (my $other = cf::player::find $who->{ext_last_tell}) { 202 if (my $other = cf::player::find $who->{ext_last_tell}) {
203
191 if ($args) { 204 if ($args) {
192
193 $other->ob->{ext_ignore_tell}{$name} >= time 205 $other->ob->{ext_ignore_tell}{$name} >= time
194 or delete $other->ob->{ext_ignore_tell}{$name}; 206 or delete $other->ob->{ext_ignore_tell}{$name};
195 207
196 if ($other->ob->{ext_ignore_tell}{$name} < time) { 208 if ($other->ob->{ext_ignore_tell}{$name} < time) {
197 utf8::encode $args; # ->message not yet utf8-ified 209 utf8::encode $args; # ->message not yet utf8-ified

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines