… | |
… | |
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); |
… | |
… | |
76 | if (is_damned ($map, $x, $y)) { |
76 | if (is_damned ($map, $x, $y)) { |
77 | $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. " |
78 | . "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.>"); |
79 | } elsif ($plevel >= $mlevel) { |
79 | } elsif ($plevel >= $mlevel) { |
80 | if (my $other = cf::player::find_active $args) { |
80 | if (my $other = cf::player::find_active $args) { |
81 | $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"); |
82 | $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>)"); |
83 | $invite{$name}{$args} = [time + $TIMEOUT, $map, $x, $y]; |
83 | $invite{$name}{$args} = [time + $INVITE_TIMEOUT, $map, $x, $y]; |
84 | } else { |
84 | } else { |
85 | $who->message ("cannot invite '$args': no such player"); |
85 | $who->message ("cannot invite '$args': no such player"); |
86 | } |
86 | } |
87 | } elsif ($plevel) { |
87 | } elsif ($plevel) { |
88 | $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. " |
… | |
… | |
110 | . "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.>"); |
111 | } elsif (!exists $invite{$args} || !exists $invite{$args}{$name}) { |
111 | } elsif (!exists $invite{$args} || !exists $invite{$args}{$name}) { |
112 | $who->message ("Sorry, $args hasn't invited you."); |
112 | $who->message ("Sorry, $args hasn't invited you."); |
113 | } elsif ($invite{$args}{$name}[0] < time) { |
113 | } elsif ($invite{$args}{$name}[0] < time) { |
114 | $who->message ("Sorry, $args\'s invitation has expired. " |
114 | $who->message ("Sorry, $args\'s invitation has expired. " |
115 | . "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.>"); |
116 | } else { |
116 | } else { |
117 | my $inv = delete $invite{$args}{$name}; |
117 | my $inv = delete $invite{$args}{$name}; |
118 | $who->message ("A godly force starts to pull you up..."); |
118 | $who->message ("A godly force starts to pull you up..."); |
119 | $who->goto (@$inv[1,2,3]); |
119 | $who->goto (@$inv[1,2,3]); |
120 | $who->message ("... and sets you down where $args invited you to."); |
120 | $who->message ("... and sets you down where $args invited you to."); |