#! perl # wizard commands cf::register_command kick => sub { my ($ob, $arg) = @_; return unless $ob->flag (cf::FLAG_WIZ); my $other = cf::player::find_active $arg or return 0; $other->kick ($ob); $ob->reply (undef, "$arg is kicked out of the game.", cf::NDI_UNIQUE | cf::NDI_ALL | cf::NDI_RED); 1 }; cf::register_command goto => sub { my ($ob, $arg) = @_; return unless $ob->may ("command_goto"); my ($path, $x, $y) = split /\s+/, $arg, 3; $ob->goto ($path, $x, $y); 1 }; cf::register_command teleport => sub { my ($ob, $arg) = @_; return unless $ob->may ("command_teleport"); cf::async { my $other = cf::player::find $arg or return $ob->reply (undef, "$arg: no such player."); $ob->goto ($other->maplevel, $other->ob->x, $other->ob->y); }; 1 }; cf::register_command wizpass => sub { my ($ob, $arg) = @_; return unless $ob->may ("command_wizpass"); my $new_val = length $arg ? $arg * 1 : !$ob->flag (cf::FLAG_WIZPASS); $ob->flag (cf::FLAG_WIZPASS, $new_val); $ob->reply (undef, $new_val ? "You will now walk through walls.\n" : "You will now be stopped by walls.\n", ); 1 }; cf::register_command wizcast => sub { my ($ob, $arg) = @_; return unless $ob->may ("command_wizcast"); my $new_val = length $arg ? $arg * 1 : !$ob->flag (cf::FLAG_WIZCAST); $ob->flag (cf::FLAG_WIZCAST, $new_val); $ob->reply (undef, $new_val ? "You can now cast spells anywhere." : "You now cannot cast spells in no-magic areas.", ); 1 }; cf::register_command wizlook => sub { my ($ob, $arg) = @_; return unless $ob->may ("command_wizlook"); $ob->clear_los; $ob->reply (undef, "You can temporarily see through walls."); 1 }; cf::register_command reset => sub { my ($ob, $arg) = @_; return unless $ob->may ("command_reset"); my $map = $ob->map; my @pl = $map->players; $_->enter_link for @pl; cf::async { my $name = $map->visible_name; $map->reset; $_->leave_link for @pl; $ob->reply (undef, "$name was reset."); }; 1 }; for my $command (qw(summon arrest banish)) { my $method = "command_$command"; cf::register_command $command => sub { my ($ob, $arg) = @_; return unless $ob->may ($method); $ob->$method ($arg) }; }