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, 3 months ago) by pippijn
Branch: MAIN
Changes since 1.16: +13 -1 lines
Log Message:
kick in perl

File Contents

# User Rev Content
1 root 1.1 #! perl
2    
3     # wizard commands
4    
5 pippijn 1.17 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 root 1.1 cf::register_command goto => sub {
18     my ($ob, $arg) = @_;
19    
20     return unless $ob->may ("command_goto");
21    
22 root 1.13 my ($path, $x, $y) = split /\s+/, $arg, 3;
23 root 1.1
24 root 1.13 $ob->goto ($path, $x, $y);
25 root 1.1
26 root 1.13 1
27     };
28    
29     cf::register_command teleport => sub {
30     my ($ob, $arg) = @_;
31 root 1.1
32 root 1.13 return unless $ob->may ("command_teleport");
33    
34     cf::async {
35 pippijn 1.16 my $other = cf::player::find $arg
36 pippijn 1.14 or return $ob->reply (undef, "$arg: no such player.");
37 root 1.13
38     $ob->goto ($other->maplevel, $other->ob->x, $other->ob->y);
39     };
40 root 1.1
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 root 1.2 cf::register_command reset => sub {
93     my ($ob, $arg) = @_;
94    
95     return unless $ob->may ("command_reset");
96    
97 root 1.4 my $map = $ob->map;
98    
99 root 1.6 my @pl = $map->players;
100     $_->enter_link for @pl;
101 root 1.11 cf::async {
102 root 1.12 my $name = $map->visible_name;
103 root 1.9
104 root 1.4 $map->reset;
105     $_->leave_link for @pl;
106 root 1.5
107 root 1.9 $ob->reply (undef, "$name was reset.");
108 root 1.4 };
109    
110 root 1.2 1
111     };
112    
113 pippijn 1.17 for my $command (qw(summon arrest banish)) {
114 root 1.1 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