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

Comparing deliantra/server/ext/dmcommands.ext (file contents):
Revision 1.2 by root, Mon Jan 1 13:31:47 2007 UTC vs.
Revision 1.25 by root, Tue Dec 23 06:58:23 2008 UTC

1#! perl 1#! perl # mandatory
2 2
3# wizard commands 3# wizard commands
4
5cf::register_command shutdown => sub {
6 my ($ob, $arg) = @_;
7 return $ob->reply (undef, "Sorry, you can't shutdown the server.")
8 unless $ob->flag (cf::FLAG_WIZ);
9
10 my $name = $ob->name;
11 cf::cleanup ("dm '$name' initiated shutdown" . ($arg ? " with reason: $arg" : "."), 0);
12
13 1
14};
15
16cf::register_command kick => sub {
17 my ($ob, $arg) = @_;
18 return unless $ob->flag (cf::FLAG_WIZ);
19
20 my $other = cf::player::find_active $arg
21 or return 0;
22 $other->kick ($ob);
23 $ob->reply (undef, "$arg is kicked out of the game.", cf::NDI_UNIQUE | cf::NDI_ALL | cf::NDI_RED);
24
25 1
26};
4 27
5cf::register_command goto => sub { 28cf::register_command goto => sub {
6 my ($ob, $arg) = @_; 29 my ($ob, $arg) = @_;
7 30
8 return unless $ob->may ("command_goto"); 31 return unless $ob->may ("command_goto");
9 32
10 my $portal = cf::object::new "exit"; 33 my ($path, $x, $y) = split /\s+/, $arg, 3;
11 34
12 $portal->slaying ($arg); 35 $ob->goto ($path, $x, $y);
13 $portal->stats->hp (0);
14 $portal->stats->sp (0);
15 36
16 $portal->apply ($ob); 37 1
38};
17 39
18 $portal->destroy; 40cf::register_command teleport => sub {
41 my ($ob, $arg) = @_;
42
43 return unless $ob->may ("command_teleport");
44
45 cf::async {
46 $Coro::current->{desc} = "teleport $arg";
47
48 my $other = cf::player::find $arg
49 or return $ob->reply (undef, "$arg: no such player.");
50
51 $ob->goto ($other->maplevel, $other->ob->x, $other->ob->y);
52 };
19 53
20 1 54 1
21}; 55};
22 56
23cf::register_command wizpass => sub { 57cf::register_command wizpass => sub {
59cf::register_command wizlook => sub { 93cf::register_command wizlook => sub {
60 my ($ob, $arg) = @_; 94 my ($ob, $arg) = @_;
61 95
62 return unless $ob->may ("command_wizlook"); 96 return unless $ob->may ("command_wizlook");
63 97
64 $ob->clear_los; 98 my $new_val = length $arg ? $arg * 1 : !$ob->flag (cf::FLAG_WIZLOOK);
65 99
66 $ob->reply (undef, "You can temporarily see through walls."); 100 $ob->flag (cf::FLAG_WIZLOOK, $new_val);
67 101
68 1 102 $ob->contr->do_los (1);
69};
70 103
71cf::register_command maps => sub { 104 $ob->reply (undef,
72 my ($ob, $arg) = @_; 105 $new_val
73 106 ? "You can now look through walls."
74 no re 'eval'; $arg = qr<$arg>; 107 : "You will now see the same thing as you would normally.",
75 108 );
76 my $format = "%2s %2s %-30.30s\n";
77
78 my $msg = sprintf $format, "Pl", "Fl", "Reset", "Name";
79
80 for (sort keys %cf::MAP) {
81 my $map = $cf::MAP{$_}
82 or next;
83
84 $msg
85 }
86 109
87 1 110 1
88}; 111};
89 112
90cf::register_command reset => sub { 113cf::register_command reset => sub {
91 my ($ob, $arg) = @_; 114 my ($ob, $arg) = @_;
92 115
93 return unless $ob->may ("command_reset"); 116 return unless $ob->may ("command_reset");
94 117
95 $ob->reply (undef, "You can temporarily see through walls."); 118 my $map = $ob->map;
119
120 my @pl = $map->players;
121 $_->enter_link for @pl;
122 cf::async {
123 my $name = $map->visible_name;
124 $Coro::current->{desc} = "reset $name";
125
126 $map->reset;
127 $_->leave_link for @pl;
128
129 $ob->reply (undef, "$name was reset.");
130 };
96 131
97 1 132 1
98}; 133};
99 134
135cf::register_command observe => sub {
136 my ($ob, $arg) = @_;
137
138 return unless $ob->may ("command_observe");
139
140 my $other = cf::player::find_active $arg;
141 $ob->contr->set_observe ($other ? $other->ob : undef);
142
143 1
144};
145
100for my $command (qw(teleport summon arrest kick banish)) { 146for my $command (qw(summon arrest banish)) {
101 my $method = "command_$command"; 147 my $method = "command_$command";
102 148
103 cf::register_command $command => sub { 149 cf::register_command $command => sub {
104 my ($ob, $arg) = @_; 150 my ($ob, $arg) = @_;
105 151

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines