ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/ext/dmcommands.ext
Revision: 1.24
Committed: Sat Dec 20 02:32:31 2008 UTC (15 years, 5 months ago) by root
Branch: MAIN
Changes since 1.23: +1 -1 lines
Log Message:
fix observe and other los issues

File Contents

# Content
1 #! perl # mandatory
2
3 # wizard commands
4
5 cf::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
16 cf::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 };
27
28 cf::register_command goto => sub {
29 my ($ob, $arg) = @_;
30
31 return unless $ob->may ("command_goto");
32
33 my ($path, $x, $y) = split /\s+/, $arg, 3;
34
35 $ob->goto ($path, $x, $y);
36
37 1
38 };
39
40 cf::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 };
53
54 1
55 };
56
57 cf::register_command wizpass => sub {
58 my ($ob, $arg) = @_;
59
60 return unless $ob->may ("command_wizpass");
61
62 my $new_val = length $arg ? $arg * 1 : !$ob->flag (cf::FLAG_WIZPASS);
63
64 $ob->flag (cf::FLAG_WIZPASS, $new_val);
65
66 $ob->reply (undef,
67 $new_val
68 ? "You will now walk through walls.\n"
69 : "You will now be stopped by walls.\n",
70 );
71
72 1
73 };
74
75 cf::register_command wizcast => sub {
76 my ($ob, $arg) = @_;
77
78 return unless $ob->may ("command_wizcast");
79
80 my $new_val = length $arg ? $arg * 1 : !$ob->flag (cf::FLAG_WIZCAST);
81
82 $ob->flag (cf::FLAG_WIZCAST, $new_val);
83
84 $ob->reply (undef,
85 $new_val
86 ? "You can now cast spells anywhere."
87 : "You now cannot cast spells in no-magic areas.",
88 );
89
90 1
91 };
92
93 cf::register_command wizlook => sub {
94 my ($ob, $arg) = @_;
95
96 return unless $ob->may ("command_wizlook");
97
98 $ob->contr->clear_los (0);
99
100 $ob->reply (undef, "You can temporarily see through walls.");
101
102 1
103 };
104
105 cf::register_command reset => sub {
106 my ($ob, $arg) = @_;
107
108 return unless $ob->may ("command_reset");
109
110 my $map = $ob->map;
111
112 my @pl = $map->players;
113 $_->enter_link for @pl;
114 cf::async {
115 my $name = $map->visible_name;
116 $Coro::current->{desc} = "reset $name";
117
118 $map->reset;
119 $_->leave_link for @pl;
120
121 $ob->reply (undef, "$name was reset.");
122 };
123
124 1
125 };
126
127 cf::register_command observe => sub {
128 my ($ob, $arg) = @_;
129
130 return unless $ob->may ("command_observe");
131
132 my $other = cf::player::find_active $arg;
133 $ob->contr->set_observe ($other ? $other->ob : undef);
134
135 1
136 };
137
138 for my $command (qw(summon arrest banish)) {
139 my $method = "command_$command";
140
141 cf::register_command $command => sub {
142 my ($ob, $arg) = @_;
143
144 return unless $ob->may ($method);
145
146 $ob->$method ($arg)
147 };
148 }
149