ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/ext/cfplus.ext
(Generate patch)

Comparing deliantra/server/ext/cfplus.ext (file contents):
Revision 1.9 by root, Mon Jul 23 21:02:50 2007 UTC vs.
Revision 1.12 by root, Mon Jul 14 23:57:45 2008 UTC

62 my %res; 62 my %res;
63 63
64 if ($pl->cell_visible ($dx, $dy)) { 64 if ($pl->cell_visible ($dx, $dy)) {
65 for my $ob ($pl->ob->map->at ($pl->ob->x + $dx, $pl->ob->y + $dy)) { 65 for my $ob ($pl->ob->map->at ($pl->ob->x + $dx, $pl->ob->y + $dy)) {
66 $res{npc_dialog} = [$ob->name, $dx, $dy] 66 $res{npc_dialog} = [$ob->name, $dx, $dy]
67 if $near && NPC_Dialogue::has_dialogue $ob && !$pl->{npc_dialog}; 67 if $near && $ob->has_dialogue && !$pl->{npc_dialog};
68 } 68 }
69 } 69 }
70 70
71 %res 71 %res
72}; 72};
96 return (error => "too far away") unless (abs $dx) <= 2 && (abs $dy) <= 2; 96 return (error => "too far away") unless (abs $dx) <= 2 && (abs $dy) <= 2;
97 return (error => "nothing to talk there") unless $pl->cell_visible ($dx, $dy); 97 return (error => "nothing to talk there") unless $pl->cell_visible ($dx, $dy);
98 return (error => "only one dialog can be open at a time") if $pl->{npc_dialog}; # only one dialog at a time 98 return (error => "only one dialog can be open at a time") if $pl->{npc_dialog}; # only one dialog at a time
99 99
100 for my $npc ($pl->ob->map->at ($pl->ob->x + $dx, $pl->ob->y + $dy)) { 100 for my $npc ($pl->ob->map->at ($pl->ob->x + $dx, $pl->ob->y + $dy)) {
101 if (NPC_Dialogue::has_dialogue $npc) { 101 if ($npc->has_dialogue) {
102 $pl->attach ("npc_dialog_active"); 102 $pl->attach ("npc_dialog_active");
103 $pl->{npc_dialog} = new NPC_Dialogue pl => $pl, npc => $npc, id => $id; 103 $pl->{npc_dialog} = new NPC_Dialogue pl => $pl, npc => $npc, id => $id;
104 dialog_tell $id, $pl->{npc_dialog}, "hi"; 104 dialog_tell $id, $pl->{npc_dialog}, "hi";
105 return; 105 return;
106 } 106 }
194 }, 194 },
195 on_move => sub { 195 on_move => sub {
196 my ($pl, $dir) = @_; 196 my ($pl, $dir) = @_;
197 197
198 # must delay a bit :/ 198 # must delay a bit :/
199 Event->timer (after => 0, cb => sub { 199 my $delay; $delay = EV::timer 0, 0, sub {
200 $_[0]->w->cancel; 200 undef $delay;
201 201
202 if (my $dialog = $pl->{npc_dialog}) { 202 if (my $dialog = $pl->{npc_dialog}) {
203 my (undef, $dx, $dy) = $pl->ob->rangevector ($dialog->{npc}); 203 my (undef, $dx, $dy) = $pl->ob->rangevector ($dialog->{npc});
204 204
205 return if (abs $dx) <= 2 && (abs $dy) <= 2; 205 return if (abs $dx) <= 2 && (abs $dy) <= 2;
207 $pl->ext_msg ($dialog->{id} => error => "out of range"); 207 $pl->ext_msg ($dialog->{id} => error => "out of range");
208 } 208 }
209 209
210 delete $pl->{npc_dialog}; 210 delete $pl->{npc_dialog};
211 $pl->detach ("npc_dialog_active"); 211 $pl->detach ("npc_dialog_active");
212 }); 212 };
213 }, 213 },
214; 214;
215 215
216cf::player->attach ( 216cf::player->attach (
217 on_login => sub { 217 on_login => sub {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines