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.26 by root, Fri Jul 21 08:33:52 2006 UTC vs.
Revision 1.27 by root, Sun Jul 30 19:56:57 2006 UTC

47}; 47};
48 48
49cf::register_command say => 0, sub { 49cf::register_command say => 0, sub {
50 my ($who, $msg) = @_; 50 my ($who, $msg) = @_;
51 51
52 utf8::decode $msg;
53
52 if ($msg) { 54 if ($msg) {
53 my $name = $who->name; 55 my $name = $who->name;
54 56
57 utf8::encode $msg; # ->message not yet utf8-ified
55 $_->ob->message ("$name says: $msg", cf::NDI_GREY | cf::NDI_UNIQUE) 58 $_->ob->message ("$name says: $msg", cf::NDI_GREY | cf::NDI_UNIQUE)
56 for grep $who->on_same_map_as ($_->ob), cf::player::list; 59 for grep $who->on_same_map_as ($_->ob), cf::player::list;
60 utf8::decode $msg;
57 61
58 # npcs, magic_ears etc. 62 # npcs, magic_ears etc.
59 # first find all objects and their inventories within a 5x5 square 63 # first find all objects and their inventories within a 5x5 square
60 # that have something resembling dialogue 64 # that have something resembling dialogue
61 my ($map, $x, $y) = ($who->map, $who->x - 2, $who->y - 2); 65 my ($map, $x, $y) = ($who->map, $who->x - 2, $who->y - 2);
100}; 104};
101 105
102cf::register_command chat => 0, sub { 106cf::register_command chat => 0, sub {
103 my ($who, $msg) = @_; 107 my ($who, $msg) = @_;
104 108
109 utf8::decode $msg;
110
105 if ($msg) { 111 if ($msg) {
106 my $name = $who->name; 112 my $name = $who->name;
107 my $NOW = time; 113 my $NOW = time;
108 114
115 utf8::encode $msg; # ->message not yet utf8-ified
109 cf::LOG cf::llevDebug, sprintf "QBERT [%s] %s\n", $name, $msg; 116 cf::LOG cf::llevDebug, sprintf "QBERT [%s] %s\n", $name, $msg;
110 117
111 $_->ob->message ("$name chats: $msg", cf::NDI_BLUE) 118 $_->ob->message ("$name chats: $msg", cf::NDI_BLUE)
112 for grep { $_->ob->{ext_ignore_shout}{$name} < $NOW && $_->listening >= 10 } cf::player::list; 119 for grep { $_->ob->{ext_ignore_shout}{$name} < $NOW && $_->listening >= 10 } cf::player::list;
113 120
116 } 123 }
117}; 124};
118 125
119cf::register_command shout => 0, sub { 126cf::register_command shout => 0, sub {
120 my ($who, $msg) = @_; 127 my ($who, $msg) = @_;
128
129 utf8::decode $msg;
121 130
122 if ($msg) { 131 if ($msg) {
123 my $NOW = time; 132 my $NOW = time;
124 my $name = $who->name; 133 my $name = $who->name;
125 134
126 cf::LOG cf::llevDebug, sprintf "QBERT {%s} %s\n", $name, $msg; 135 cf::LOG cf::llevDebug, sprintf "QBERT {%s} %s\n", $name, $msg;
127 136
137 utf8::encode $msg; # ->message not yet utf8-ified
128 $_->ob->message ("$name shouts: $msg", cf::NDI_RED) 138 $_->ob->message ("$name shouts: $msg", cf::NDI_RED)
129 for grep { $_->ob->{ext_ignore_shout}{$name} < $NOW && $_->listening >= 2 } cf::player::list; 139 for grep { $_->ob->{ext_ignore_shout}{$name} < $NOW && $_->listening >= 2 } cf::player::list;
130 140
131 } else { 141 } else {
132 $who->message ("Shout what?", cf::NDI_UNIQUE); 142 $who->message ("Shout what?", cf::NDI_UNIQUE);
135}; 145};
136 146
137cf::register_command tell => 0, sub { 147cf::register_command tell => 0, sub {
138 my ($who, $args) = @_; 148 my ($who, $args) = @_;
139 my ($target, $msg) = split /\s+/, $args, 2; 149 my ($target, $msg) = split /\s+/, $args, 2;
150
151 utf8::decode $msg;
140 152
141 my $name = $who->name; 153 my $name = $who->name;
142 154
143 if (my $other = cf::player::find $target) { 155 if (my $other = cf::player::find $target) {
144 156
146 if ($target eq $name) { 158 if ($target eq $name) {
147 $who->message ("You are talking to yourself, you freak!", cf::NDI_UNIQUE); 159 $who->message ("You are talking to yourself, you freak!", cf::NDI_UNIQUE);
148 } elsif ($other->ob->{ext_ignore_tell}{$name} >= time) { 160 } elsif ($other->ob->{ext_ignore_tell}{$name} >= time) {
149 $who->message ("$target ignores what you say. Give up on it.", cf::NDI_UNIQUE); 161 $who->message ("$target ignores what you say. Give up on it.", cf::NDI_UNIQUE);
150 } else { 162 } else {
163 utf8::encode $msg; # ->message not yet utf8-ified
151 cf::LOG cf::llevDebug, sprintf "TELL [%s>%s] %s\n", $name, $target, $msg; 164 cf::LOG cf::llevDebug, sprintf "TELL [%s>%s] %s\n", $name, $target, $msg;
152 165
153 $who->message ("You tell $target: $msg"); 166 $who->message ("You tell $target: $msg");
154 $other->ob->message ("$name tells you: $msg"); 167 $other->ob->message ("$name tells you: $msg");
155 $other->ob->{ext_last_tell} = $name; 168 $other->ob->{ext_last_tell} = $name;
165 178
166cf::register_command reply => 0, sub { 179cf::register_command reply => 0, sub {
167 my ($who, $args) = @_; 180 my ($who, $args) = @_;
168 my $name = $who->name; 181 my $name = $who->name;
169 182
183 utf8::decode $args;
184
170 if (my $other = cf::player::find $who->{ext_last_tell}) { 185 if (my $other = cf::player::find $who->{ext_last_tell}) {
171 if ($args) { 186 if ($args) {
172 187
173 $other->ob->{ext_ignore_tell}{$name} >= time 188 $other->ob->{ext_ignore_tell}{$name} >= time
174 or delete $other->ob->{ext_ignore_tell}{$name}; 189 or delete $other->ob->{ext_ignore_tell}{$name};
175 190
176 if ($other->ob->{ext_ignore_tell}{$name} < time) { 191 if ($other->ob->{ext_ignore_tell}{$name} < time) {
192 utf8::encode $msg; # ->message not yet utf8-ified
177 cf::LOG cf::llevDebug, sprintf "TELL [%s>%s] %s\n", $name, $other->ob->name, $args; 193 cf::LOG cf::llevDebug, sprintf "TELL [%s>%s] %s\n", $name, $other->ob->name, $args;
178 194
179 $who->message ("You tell " . $other->ob->name . ": $args"); 195 $who->message ("You tell " . $other->ob->name . ": $args");
180 $other->ob->message ("$name tells you: $args"); 196 $other->ob->message ("$name tells you: $args");
181 $who->{ext_last_tell} = $other->ob->name; 197 $who->{ext_last_tell} = $other->ob->name;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines