ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/ext/dmcommands.ext
Revision: 1.17
Committed: Fri Mar 2 13:32:50 2007 UTC (17 years, 2 months ago) by pippijn
Branch: MAIN
Changes since 1.16: +13 -1 lines
Log Message:
kick in perl

File Contents

# Content
1 #! perl
2
3 # wizard commands
4
5 cf::register_command kick => sub {
6 my ($ob, $arg) = @_;
7 return unless $ob->flag (cf::FLAG_WIZ);
8
9 my $other = cf::player::find_active $arg
10 or return 0;
11 $other->kick ($ob);
12 $ob->reply (undef, "$arg is kicked out of the game.", cf::NDI_UNIQUE | cf::NDI_ALL | cf::NDI_RED);
13
14 1
15 };
16
17 cf::register_command goto => sub {
18 my ($ob, $arg) = @_;
19
20 return unless $ob->may ("command_goto");
21
22 my ($path, $x, $y) = split /\s+/, $arg, 3;
23
24 $ob->goto ($path, $x, $y);
25
26 1
27 };
28
29 cf::register_command teleport => sub {
30 my ($ob, $arg) = @_;
31
32 return unless $ob->may ("command_teleport");
33
34 cf::async {
35 my $other = cf::player::find $arg
36 or return $ob->reply (undef, "$arg: no such player.");
37
38 $ob->goto ($other->maplevel, $other->ob->x, $other->ob->y);
39 };
40
41 1
42 };
43
44 cf::register_command wizpass => sub {
45 my ($ob, $arg) = @_;
46
47 return unless $ob->may ("command_wizpass");
48
49 my $new_val = length $arg ? $arg * 1 : !$ob->flag (cf::FLAG_WIZPASS);
50
51 $ob->flag (cf::FLAG_WIZPASS, $new_val);
52
53 $ob->reply (undef,
54 $new_val
55 ? "You will now walk through walls.\n"
56 : "You will now be stopped by walls.\n",
57 );
58
59 1
60 };
61
62 cf::register_command wizcast => sub {
63 my ($ob, $arg) = @_;
64
65 return unless $ob->may ("command_wizcast");
66
67 my $new_val = length $arg ? $arg * 1 : !$ob->flag (cf::FLAG_WIZCAST);
68
69 $ob->flag (cf::FLAG_WIZCAST, $new_val);
70
71 $ob->reply (undef,
72 $new_val
73 ? "You can now cast spells anywhere."
74 : "You now cannot cast spells in no-magic areas.",
75 );
76
77 1
78 };
79
80 cf::register_command wizlook => sub {
81 my ($ob, $arg) = @_;
82
83 return unless $ob->may ("command_wizlook");
84
85 $ob->clear_los;
86
87 $ob->reply (undef, "You can temporarily see through walls.");
88
89 1
90 };
91
92 cf::register_command reset => sub {
93 my ($ob, $arg) = @_;
94
95 return unless $ob->may ("command_reset");
96
97 my $map = $ob->map;
98
99 my @pl = $map->players;
100 $_->enter_link for @pl;
101 cf::async {
102 my $name = $map->visible_name;
103
104 $map->reset;
105 $_->leave_link for @pl;
106
107 $ob->reply (undef, "$name was reset.");
108 };
109
110 1
111 };
112
113 for my $command (qw(summon arrest banish)) {
114 my $method = "command_$command";
115
116 cf::register_command $command => sub {
117 my ($ob, $arg) = @_;
118
119 return unless $ob->may ($method);
120
121 $ob->$method ($arg)
122 };
123 }
124