… | |
… | |
5 | # level 1: invite to private rooms only ~lvl 10 |
5 | # level 1: invite to private rooms only ~lvl 10 |
6 | # level 2: private rooms and saving maps (guilds, some other public saving maps) |
6 | # level 2: private rooms and saving maps (guilds, some other public saving maps) |
7 | # level 3: invite everywhere where no monsters are on the map |
7 | # level 3: invite everywhere where no monsters are on the map |
8 | # level 4: invite everywhere |
8 | # level 4: invite everywhere |
9 | |
9 | |
10 | my $TIMEOUT = $cf::CFG{invite_timeout} || 60; |
10 | CONF INVITE_TIMEOUT = 60 |
11 | |
11 | |
12 | # determine whether map cell is damned |
12 | # determine whether map cell is damned |
13 | sub is_damned { |
13 | sub is_damned { |
14 | my ($map, $x, $y) = @_; |
14 | my ($map, $x, $y) = @_; |
15 | return grep $_->flag (cf::FLAG_DAMNED), $map->at ($x, $y); |
15 | return grep $_->flag (cf::FLAG_DAMNED), $map->at ($x, $y); |
… | |
… | |
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 =~ /^~/) { |
… | |
… | |
74 | if (is_damned ($map, $x, $y)) { |
76 | if (is_damned ($map, $x, $y)) { |
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 $INVITE_TIMEOUT seconds"); |
80 | $other->ob->message ("$name invites you to $maplevel[$mlevel], to accept, use C<accept-invitation $name> (or C<a-i $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 + $INVITE_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) { |
86 | $who->message ("Valriel deems you not worthy yet. Gorokh is annoyed by your sacrilege. " |
88 | $who->message ("Valriel deems you not worthy yet. Gorokh is annoyed by your sacrilege. " |
… | |
… | |
108 | . "H<Go to a place where your prayers work and try again.>"); |
110 | . "H<Go to a place where your prayers work and try again.>"); |
109 | } elsif (!exists $invite{$args} || !exists $invite{$args}{$name}) { |
111 | } elsif (!exists $invite{$args} || !exists $invite{$args}{$name}) { |
110 | $who->message ("Sorry, $args hasn't invited you."); |
112 | $who->message ("Sorry, $args hasn't invited you."); |
111 | } elsif ($invite{$args}{$name}[0] < time) { |
113 | } elsif ($invite{$args}{$name}[0] < time) { |
112 | $who->message ("Sorry, $args\'s invitation has expired. " |
114 | $who->message ("Sorry, $args\'s invitation has expired. " |
113 | . "H<Invites are only valid for $TIMEOUT seconds, ask $args to invite you again.>"); |
115 | . "H<Invites are only valid for $INVITE_TIMEOUT seconds, ask $args to invite you again.>"); |
114 | } else { |
116 | } else { |
115 | my $inv = delete $invite{$args}{$name}; |
117 | my $inv = delete $invite{$args}{$name}; |
116 | $who->message ("A godly force starts to pull you up..."); |
118 | $who->message ("A godly force starts to pull you up..."); |
117 | $who->goto (@$inv[1,2,3]); |
119 | $who->goto (@$inv[1,2,3]); |
118 | $who->message ("... and sets you down where $args invited you to."); |
120 | $who->message ("... and sets you down where $args invited you to."); |