… | |
… | |
23 | cf::register_extcmd cfplus_support => sub { |
23 | cf::register_extcmd cfplus_support => sub { |
24 | my ($pl, $msg) = @_; |
24 | my ($pl, $msg) = @_; |
25 | |
25 | |
26 | # $msg->{version} |
26 | # $msg->{version} |
27 | |
27 | |
|
|
28 | ( |
28 | (version => 2) |
29 | version => 2, |
|
|
30 | ) |
29 | }; |
31 | }; |
30 | |
32 | |
31 | my %dialog; # currently active dialogs |
33 | my %dialog; # currently active dialogs |
32 | |
34 | |
33 | my $timer = Event->timer (interval => 0.2, parked => 1, data => cf::WF_AUTOCANCEL, cb => sub { |
35 | my $timer = Event->timer (interval => 0.2, parked => 1, data => cf::WF_AUTOCANCEL, cb => sub { |
… | |
… | |
65 | =cut |
67 | =cut |
66 | |
68 | |
67 | cf::register_extcmd lookat => sub { |
69 | cf::register_extcmd lookat => sub { |
68 | my ($pl, $msg) = @_; |
70 | my ($pl, $msg) = @_; |
69 | my ($dx, $dy) = @$msg{qw(dx dy)}; |
71 | my ($dx, $dy) = @$msg{qw(dx dy)}; |
|
|
72 | |
|
|
73 | return unless $pl->ob && $pl->ob->map; |
70 | |
74 | |
71 | my $near = (abs $dx) <= 2 && (abs $dy) <= 2; |
75 | my $near = (abs $dx) <= 2 && (abs $dy) <= 2; |
72 | |
76 | |
73 | my %res; |
77 | my %res; |
74 | |
78 | |
… | |
… | |
96 | |
100 | |
97 | cf::register_extcmd npc_dialog_begin => sub { |
101 | cf::register_extcmd npc_dialog_begin => sub { |
98 | my ($pl, $msg) = @_; |
102 | my ($pl, $msg) = @_; |
99 | my ($id, $dx, $dy) = @$msg{qw(msgid dx dy)}; |
103 | my ($id, $dx, $dy) = @$msg{qw(msgid dx dy)}; |
100 | |
104 | |
|
|
105 | return unless $pl->ob && $pl->ob->map; |
101 | return unless (abs $dx) <= 2 && (abs $dy) <= 2; |
106 | return unless (abs $dx) <= 2 && (abs $dy) <= 2; |
102 | return unless $pl->cell_visible ($dx, $dy); |
107 | return unless $pl->cell_visible ($dx, $dy); |
103 | |
108 | |
104 | for my $npc ($pl->ob->map->at ($pl->ob->x + $dx, $pl->ob->y + $dy)) { |
109 | for my $npc ($pl->ob->map->at ($pl->ob->x + $dx, $pl->ob->y + $dy)) { |
105 | if (NPC_Dialogue::has_dialogue $npc) { |
110 | if (NPC_Dialogue::has_dialogue $npc) { |
… | |
… | |
146 | delete $dialog{$msg->{msgid}}; |
151 | delete $dialog{$msg->{msgid}}; |
147 | |
152 | |
148 | () |
153 | () |
149 | }; |
154 | }; |
150 | |
155 | |
151 | cf::attach_to_players |
156 | cf::player->attach ( |
152 | on_logout => sub { |
157 | on_logout => sub { |
153 | my ($pl) = @_; |
158 | my ($pl) = @_; |
154 | |
159 | |
155 | delete $dialog{$_} for grep $pl->ob == $dialog{$_}{ob}, keys %dialog; |
160 | delete $dialog{$_} for grep $pl->ob == $dialog{$_}{ob}, keys %dialog; |
156 | }, |
161 | }, |
157 | ; |
162 | ); |
158 | |
163 | |
159 | =item ... = extcmd editor_support |
164 | =item ... = extcmd editor_support |
160 | |
165 | |
161 | Returns the value required by clients that have an editor to download and |
166 | Returns the value required by clients that have an editor to download and |
162 | upload maps from/to the server. |
167 | upload maps from/to the server. |