ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/maps/perl/invite.ext
(Generate patch)

Comparing deliantra/maps/perl/invite.ext (file contents):
Revision 1.6 by root, Thu Feb 9 01:15:25 2006 UTC vs.
Revision 1.11 by root, Thu Apr 6 19:57:56 2006 UTC

5# level 3: invite everywhere where no monsters are on the map 5# level 3: invite everywhere where no monsters are on the map
6# level 4: invite everywhere 6# level 4: invite everywhere
7 7
8# implement a 'follow' command 8# implement a 'follow' command
9 9
10#TODO: fon't invite on damned ground 10my $TIMEOUT = 60;
11 11
12my $TIMEOUT = 60; 12# determine whether map cell is damned
13sub is_damned {
14 my ($map, $x, $y) = @_;
15 return grep $_->flag (cf::FLAG_DAMNED), $map->at ($x, $y);
16}
13 17
14# determine level available to the player 18# determine level available to the player
15sub player_level { 19sub player_level {
16 my ($ob) = @_; 20 my ($ob) = @_;
17 21
66 my ($map, $x, $y) = ($who->map, $who->x, $who->y); 70 my ($map, $x, $y) = ($who->map, $who->x, $who->y);
67 71
68 my $plevel = player_level $who; 72 my $plevel = player_level $who;
69 my $mlevel = map_level $map, $x, $y; 73 my $mlevel = map_level $map, $x, $y;
70 74
75 if (is_damned ($map, $x, $y)) {
76 $who->message ("Your god isn't present here, you can't invite someone to unholy ground.");
71 if ($plevel >= $mlevel) { 77 } elsif ($plevel >= $mlevel) {
72 if (my $other = cf::player::find $args) { 78 if (my $other = cf::player::find $args) {
73 $who->message ("inviting player '$args', to cancel, type: 'invite or wait $TIMEOUT seconds"); 79 $who->message ("inviting player '$args', to cancel, type: 'invite or wait $TIMEOUT seconds");
74 $other->ob->message ("$name invites you to $maplevel[$mlevel], to accept, use 'accept-invitation $name"); 80 $other->ob->message ("$name invites you to $maplevel[$mlevel], to accept, use 'accept-invitation $name");
75 $invite{$name}{$args} = [time + $TIMEOUT, $map, $x, $y]; 81 $invite{$name}{$args} = [time + $TIMEOUT, $map, $x, $y];
76 } else { 82 } else {
88}; 94};
89 95
90sub teleport { 96sub teleport {
91 my ($pl, $map, $x, $y) = @_; 97 my ($pl, $map, $x, $y) = @_;
92 98
93 my $portal = cf::object::new ("exit"); 99 my $portal = cf::object::new "exit";
94 100
95 $portal->set_slaying ($map->path); 101 $portal->set_slaying ($map->path);
96 $portal->set_hp ($x); 102 $portal->set_hp ($x);
97 $portal->set_sp ($y); 103 $portal->set_sp ($y);
98 104
103 109
104cf::register_command "accept-invitation" => 10, sub { 110cf::register_command "accept-invitation" => 10, sub {
105 my ($who, $args) = @_; 111 my ($who, $args) = @_;
106 112
107 my $name = $who->name; 113 my $name = $who->name;
114 my ($map, $x, $y) = ($who->map, $who->x, $who->y);
108 115
116 if (is_damned ($map, $x, $y)) {
117 $who->message ("You can't be invited from a place where your god isn't present.");
109 if (!exists $invite{$args} || !exists $invite{$args}{$name}) { 118 } elsif (!exists $invite{$args} || !exists $invite{$args}{$name}) {
110 $who->message ("Sorry, $args hasn't invited you."); 119 $who->message ("Sorry, $args hasn't invited you.");
111 } elsif ($invite{$args}{$name}[0] < time) { 120 } elsif ($invite{$args}{$name}[0] < time) {
112 $who->message ("Sorry, $args\'s invitation has expired."); 121 $who->message ("Sorry, $args\'s invitation has expired.");
113 } else { 122 } else {
114 my $inv = delete $invite{$args}{$name}; 123 my $inv = delete $invite{$args}{$name};
115 $who->message ("A godly force starts to pull you up..."); 124 $who->message ("A godly force starts to pull you up...");
116 teleport $who, @{$inv}[1,2,3]; 125 teleport $who, @{$inv}[1,2,3];
117 $who->message ("... and sets you down where $args invited you to."); 126 $who->message ("... and sets you down where $args invited you to.");
118 127
119 } 128 }
120} 129};
121 130

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines