… | |
… | |
65 | =cut |
65 | =cut |
66 | |
66 | |
67 | cf::register_extcmd lookat => sub { |
67 | cf::register_extcmd lookat => sub { |
68 | my ($pl, $msg) = @_; |
68 | my ($pl, $msg) = @_; |
69 | my ($dx, $dy) = @$msg{qw(dx dy)}; |
69 | my ($dx, $dy) = @$msg{qw(dx dy)}; |
|
|
70 | |
|
|
71 | return unless $pl->ob && $pl->ob->map; |
70 | |
72 | |
71 | my $near = (abs $dx) <= 2 && (abs $dy) <= 2; |
73 | my $near = (abs $dx) <= 2 && (abs $dy) <= 2; |
72 | |
74 | |
73 | my %res; |
75 | my %res; |
74 | |
76 | |
… | |
… | |
96 | |
98 | |
97 | cf::register_extcmd npc_dialog_begin => sub { |
99 | cf::register_extcmd npc_dialog_begin => sub { |
98 | my ($pl, $msg) = @_; |
100 | my ($pl, $msg) = @_; |
99 | my ($id, $dx, $dy) = @$msg{qw(msgid dx dy)}; |
101 | my ($id, $dx, $dy) = @$msg{qw(msgid dx dy)}; |
100 | |
102 | |
|
|
103 | return unless $pl->ob && $pl->ob->map; |
101 | return unless (abs $dx) <= 2 && (abs $dy) <= 2; |
104 | return unless (abs $dx) <= 2 && (abs $dy) <= 2; |
102 | return unless $pl->cell_visible ($dx, $dy); |
105 | return unless $pl->cell_visible ($dx, $dy); |
103 | |
106 | |
104 | for my $npc ($pl->ob->map->at ($pl->ob->x + $dx, $pl->ob->y + $dy)) { |
107 | for my $npc ($pl->ob->map->at ($pl->ob->x + $dx, $pl->ob->y + $dy)) { |
105 | if (NPC_Dialogue::has_dialogue $npc) { |
108 | if (NPC_Dialogue::has_dialogue $npc) { |
… | |
… | |
146 | delete $dialog{$msg->{msgid}}; |
149 | delete $dialog{$msg->{msgid}}; |
147 | |
150 | |
148 | () |
151 | () |
149 | }; |
152 | }; |
150 | |
153 | |
151 | cf::attach_to_players |
154 | cf::player->attach ( |
152 | on_logout => sub { |
155 | on_logout => sub { |
153 | my ($pl) = @_; |
156 | my ($pl) = @_; |
154 | |
157 | |
155 | delete $dialog{$_} for grep $pl->ob == $dialog{$_}{ob}, keys %dialog; |
158 | delete $dialog{$_} for grep $pl->ob == $dialog{$_}{ob}, keys %dialog; |
156 | }, |
159 | }, |
157 | ; |
160 | ); |
158 | |
161 | |
159 | =item ... = extcmd editor_support |
162 | =item ... = extcmd editor_support |
160 | |
163 | |
161 | Returns the value required by clients that have an editor to download and |
164 | Returns the value required by clients that have an editor to download and |
162 | upload maps from/to the server. |
165 | upload maps from/to the server. |