… | |
… | |
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 =~ /^~/) { |
… | |
… | |
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 | |
… | |
… | |
70 | |
72 | |
71 | my $plevel = player_level $who; |
73 | my $plevel = player_level $who; |
72 | my $mlevel = map_level $map, $x, $y; |
74 | my $mlevel = map_level $map, $x, $y; |
73 | |
75 | |
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. " |
|
|
78 | . "H<You can only use invite at places where you can use prayers.>"); |
76 | } elsif ($plevel >= $mlevel) { |
79 | } elsif ($plevel >= $mlevel) { |
77 | if (my $other = cf::player::find_active $args) { |
80 | if (my $other = cf::player::find_active $args) { |
78 | $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"); |
79 | $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>)"); |
80 | $invite{$name}{$args} = [time + $TIMEOUT, $map, $x, $y]; |
83 | $invite{$name}{$args} = [time + $INVITE_TIMEOUT, $map, $x, $y]; |
81 | } else { |
84 | } else { |
82 | $who->message ("cannot invite '$args': no such player"); |
85 | $who->message ("cannot invite '$args': no such player"); |
83 | } |
86 | } |
84 | } elsif ($plevel) { |
87 | } elsif ($plevel) { |
85 | $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. " |
|
|
89 | . "H<Your invite level is not high enough to invite to this place.>"); |
86 | } else { |
90 | } else { |
87 | $who->message ("You haven't proven your worthyness in the mountain maze."); |
91 | $who->message ("You haven't proven your worthyness in the mountain maze. " |
|
|
92 | . "H<To use the invite command you have to do one or more of the invite quests. The first one can be found south-east of Scorn.>"); |
88 | } |
93 | } |
89 | } else { |
94 | } else { |
90 | $who->message ("canceling all invites"); |
95 | $who->message ("canceling all invites"); |
91 | delete $invite{$name}; |
96 | delete $invite{$name}; |
92 | } |
97 | } |
93 | }; |
98 | }; |
94 | |
|
|
95 | sub teleport { |
|
|
96 | my ($pl, $map, $x, $y) = @_; |
|
|
97 | |
|
|
98 | my $portal = cf::object::new "exit"; |
|
|
99 | |
|
|
100 | $portal->slaying ($map->path); |
|
|
101 | $portal->stats->hp ($x); |
|
|
102 | $portal->stats->sp ($y); |
|
|
103 | |
|
|
104 | $portal->apply ($pl); |
|
|
105 | |
|
|
106 | $portal->destroy; |
|
|
107 | } |
|
|
108 | |
99 | |
109 | cf::register_command "accept-invitation" => sub { |
100 | cf::register_command "accept-invitation" => sub { |
110 | my ($who, $args) = @_; |
101 | my ($who, $args) = @_; |
111 | |
102 | |
112 | $who->speed_left ($who->speed_left - 0.2); |
103 | $who->speed_left ($who->speed_left - 0.2); |
113 | |
104 | |
114 | my $name = $who->name; |
105 | my $name = $who->name; |
115 | my ($map, $x, $y) = ($who->map, $who->x, $who->y); |
106 | my ($map, $x, $y) = ($who->map, $who->x, $who->y); |
116 | |
107 | |
117 | if (is_damned ($map, $x, $y)) { |
108 | if (is_damned ($map, $x, $y)) { |
118 | $who->message ("You can't be invited from a place where your god isn't present."); |
109 | $who->message ("You can't be invited from a place where your god isn't present. " |
|
|
110 | . "H<Go to a place where your prayers work and try again.>"); |
119 | } elsif (!exists $invite{$args} || !exists $invite{$args}{$name}) { |
111 | } elsif (!exists $invite{$args} || !exists $invite{$args}{$name}) { |
120 | $who->message ("Sorry, $args hasn't invited you."); |
112 | $who->message ("Sorry, $args hasn't invited you."); |
121 | } elsif ($invite{$args}{$name}[0] < time) { |
113 | } elsif ($invite{$args}{$name}[0] < time) { |
122 | $who->message ("Sorry, $args\'s invitation has expired."); |
114 | $who->message ("Sorry, $args\'s invitation has expired. " |
|
|
115 | . "H<Invites are only valid for $INVITE_TIMEOUT seconds, ask $args to invite you again.>"); |
123 | } else { |
116 | } else { |
124 | my $inv = delete $invite{$args}{$name}; |
117 | my $inv = delete $invite{$args}{$name}; |
125 | $who->message ("A godly force starts to pull you up..."); |
118 | $who->message ("A godly force starts to pull you up..."); |
126 | teleport $who, @{$inv}[1,2,3]; |
119 | $who->goto (@$inv[1,2,3]); |
127 | $who->message ("... and sets you down where $args invited you to."); |
120 | $who->message ("... and sets you down where $args invited you to."); |
128 | |
|
|
129 | } |
121 | } |
130 | }; |
122 | }; |
131 | |
123 | |