… | |
… | |
32 | my ($map, $x, $y) = @_; |
32 | my ($map, $x, $y) = @_; |
33 | |
33 | |
34 | for my $x (0 .. $map->width - 1) { |
34 | for my $x (0 .. $map->width - 1) { |
35 | for my $y (0 .. $map->height - 1) { |
35 | for my $y (0 .. $map->height - 1) { |
36 | return 4 |
36 | return 4 |
37 | if grep $_->flag (cf::FLAG_MONSTER), |
37 | if grep $_->flag (cf::FLAG_MONSTER) |
|
|
38 | && !$_->flag (cf::FLAG_FRIENDLY) |
|
|
39 | && !$_->flag (cf::FLAG_UNAGGRESSIVE), |
38 | $map->at ($x, $y); |
40 | $map->at ($x, $y); |
39 | } |
41 | } |
40 | } |
42 | } |
41 | |
43 | |
42 | if ($map->path =~ /^~/) { |
44 | if ($map->path =~ /^~/) { |
… | |
… | |
48 | } |
50 | } |
49 | } |
51 | } |
50 | |
52 | |
51 | my @maplevel = ( |
53 | my @maplevel = ( |
52 | "some mysterious hideout", |
54 | "some mysterious hideout", |
53 | "his home", |
55 | "a private apartment", |
54 | "his guild", # wrong, this is any unique place !player-specific |
56 | "a guild", # wrong, this is any unique place !player-specific |
55 | "a nice place", |
57 | "some nice and safe place", |
56 | "a place with monsters", |
58 | "a place with monsters", |
57 | ); |
59 | ); |
58 | |
60 | |
59 | my %invite; |
61 | my %invite; |
60 | |
62 | |
… | |
… | |
75 | $who->message ("Your god isn't present here, you can't invite someone to unholy ground. " |
77 | $who->message ("Your god isn't present here, you can't invite someone to unholy ground. " |
76 | . "H<You can only use invite at places where you can use prayers.>"); |
78 | . "H<You can only use invite at places where you can use prayers.>"); |
77 | } elsif ($plevel >= $mlevel) { |
79 | } elsif ($plevel >= $mlevel) { |
78 | if (my $other = cf::player::find_active $args) { |
80 | if (my $other = cf::player::find_active $args) { |
79 | $who->message ("inviting player '$args', to cancel, use invite with no arguments or wait $TIMEOUT seconds"); |
81 | $who->message ("inviting player '$args', to cancel, use invite with no arguments or wait $TIMEOUT seconds"); |
80 | $other->ob->message ("$name invites you to $maplevel[$mlevel], to accept, use 'accept-invitation $name"); |
82 | $other->ob->message ("$name invites you to $maplevel[$mlevel], to accept, use C<accept-invitation $name> (or C<a-i $name>)"); |
81 | $invite{$name}{$args} = [time + $TIMEOUT, $map, $x, $y]; |
83 | $invite{$name}{$args} = [time + $TIMEOUT, $map, $x, $y]; |
82 | } else { |
84 | } else { |
83 | $who->message ("cannot invite '$args': no such player"); |
85 | $who->message ("cannot invite '$args': no such player"); |
84 | } |
86 | } |
85 | } elsif ($plevel) { |
87 | } elsif ($plevel) { |
… | |
… | |
92 | } else { |
94 | } else { |
93 | $who->message ("canceling all invites"); |
95 | $who->message ("canceling all invites"); |
94 | delete $invite{$name}; |
96 | delete $invite{$name}; |
95 | } |
97 | } |
96 | }; |
98 | }; |
97 | |
|
|
98 | sub teleport { |
|
|
99 | my ($pl, $map, $x, $y) = @_; |
|
|
100 | |
|
|
101 | my $portal = cf::object::new "exit"; |
|
|
102 | |
|
|
103 | $portal->slaying ($map->path); |
|
|
104 | $portal->stats->hp ($x); |
|
|
105 | $portal->stats->sp ($y); |
|
|
106 | |
|
|
107 | $portal->apply ($pl); |
|
|
108 | |
|
|
109 | $portal->destroy; |
|
|
110 | } |
|
|
111 | |
99 | |
112 | cf::register_command "accept-invitation" => sub { |
100 | cf::register_command "accept-invitation" => sub { |
113 | my ($who, $args) = @_; |
101 | my ($who, $args) = @_; |
114 | |
102 | |
115 | $who->speed_left ($who->speed_left - 0.2); |
103 | $who->speed_left ($who->speed_left - 0.2); |
… | |
… | |
126 | $who->message ("Sorry, $args\'s invitation has expired. " |
114 | $who->message ("Sorry, $args\'s invitation has expired. " |
127 | . "H<Invites are only valid for $TIMEOUT seconds, ask $args to invite you again.>"); |
115 | . "H<Invites are only valid for $TIMEOUT seconds, ask $args to invite you again.>"); |
128 | } else { |
116 | } else { |
129 | my $inv = delete $invite{$args}{$name}; |
117 | my $inv = delete $invite{$args}{$name}; |
130 | $who->message ("A godly force starts to pull you up..."); |
118 | $who->message ("A godly force starts to pull you up..."); |
131 | teleport $who, @{$inv}[1,2,3]; |
119 | $who->goto (@$inv[1,2,3]); |
132 | $who->message ("... and sets you down where $args invited you to."); |
120 | $who->message ("... and sets you down where $args invited you to."); |
133 | } |
121 | } |
134 | }; |
122 | }; |
135 | |
123 | |