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

Comparing deliantra/server/ext/invite.ext (file contents):
Revision 1.3 by root, Sun Feb 11 02:25:25 2007 UTC vs.
Revision 1.7 by root, Sun Feb 1 19:13:21 2009 UTC

48 } 48 }
49} 49}
50 50
51my @maplevel = ( 51my @maplevel = (
52 "some mysterious hideout", 52 "some mysterious hideout",
53 "his home", 53 "a private apartment",
54 "his guild", # wrong, this is any unique place !player-specific 54 "a guild guild", # wrong, this is any unique place !player-specific
55 "a nice place", 55 "some nice and safe place",
56 "a place with monsters", 56 "a place with monsters",
57); 57);
58 58
59my %invite; 59my %invite;
60 60
70 70
71 my $plevel = player_level $who; 71 my $plevel = player_level $who;
72 my $mlevel = map_level $map, $x, $y; 72 my $mlevel = map_level $map, $x, $y;
73 73
74 if (is_damned ($map, $x, $y)) { 74 if (is_damned ($map, $x, $y)) {
75 $who->message ("Your god isn't present here, you can't invite someone to unholy ground."); 75 $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.>");
76 } elsif ($plevel >= $mlevel) { 77 } elsif ($plevel >= $mlevel) {
77 if (my $other = cf::player::find_active $args) { 78 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"); 79 $who->message ("inviting player '$args', to cancel, use invite with no arguments or wait $TIMEOUT seconds");
79 $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 C<accept-invitation $name> (or C<a-i $name>)");
80 $invite{$name}{$args} = [time + $TIMEOUT, $map, $x, $y]; 81 $invite{$name}{$args} = [time + $TIMEOUT, $map, $x, $y];
81 } else { 82 } else {
82 $who->message ("cannot invite '$args': no such player"); 83 $who->message ("cannot invite '$args': no such player");
83 } 84 }
84 } elsif ($plevel) { 85 } elsif ($plevel) {
85 $who->message ("Valriel deems you not worthy yet. Gorokh is annoyed by your sacrilege."); 86 $who->message ("Valriel deems you not worthy yet. Gorokh is annoyed by your sacrilege. "
87 . "H<Your invite level is not high enough to invite to this place.>");
86 } else { 88 } else {
87 $who->message ("You haven't proven your worthyness in the mountain maze."); 89 $who->message ("You haven't proven your worthyness in the mountain maze. "
90 . "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 } 91 }
89 } else { 92 } else {
90 $who->message ("canceling all invites"); 93 $who->message ("canceling all invites");
91 delete $invite{$name}; 94 delete $invite{$name};
92 } 95 }
93}; 96};
94
95sub 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 97
109cf::register_command "accept-invitation" => sub { 98cf::register_command "accept-invitation" => sub {
110 my ($who, $args) = @_; 99 my ($who, $args) = @_;
111 100
112 $who->speed_left ($who->speed_left - 0.2); 101 $who->speed_left ($who->speed_left - 0.2);
113 102
114 my $name = $who->name; 103 my $name = $who->name;
115 my ($map, $x, $y) = ($who->map, $who->x, $who->y); 104 my ($map, $x, $y) = ($who->map, $who->x, $who->y);
116 105
117 if (is_damned ($map, $x, $y)) { 106 if (is_damned ($map, $x, $y)) {
118 $who->message ("You can't be invited from a place where your god isn't present."); 107 $who->message ("You can't be invited from a place where your god isn't present. "
108 . "H<Go to a place where your prayers work and try again.>");
119 } elsif (!exists $invite{$args} || !exists $invite{$args}{$name}) { 109 } elsif (!exists $invite{$args} || !exists $invite{$args}{$name}) {
120 $who->message ("Sorry, $args hasn't invited you."); 110 $who->message ("Sorry, $args hasn't invited you.");
121 } elsif ($invite{$args}{$name}[0] < time) { 111 } elsif ($invite{$args}{$name}[0] < time) {
122 $who->message ("Sorry, $args\'s invitation has expired."); 112 $who->message ("Sorry, $args\'s invitation has expired. "
113 . "H<Invites are only valid for $TIMEOUT seconds, ask $args to invite you again.>");
123 } else { 114 } else {
124 my $inv = delete $invite{$args}{$name}; 115 my $inv = delete $invite{$args}{$name};
125 $who->message ("A godly force starts to pull you up..."); 116 $who->message ("A godly force starts to pull you up...");
126 teleport $who, @{$inv}[1,2,3]; 117 $who->goto (@$inv[1,2,3]);
127 $who->message ("... and sets you down where $args invited you to."); 118 $who->message ("... and sets you down where $args invited you to.");
128
129 } 119 }
130}; 120};
131 121

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines