#! perl # wizard commands cf::register_command goto => sub { my ($ob, $arg) = @_; return unless $ob->may ("command_goto"); my $portal = cf::object::new "exit"; $portal->slaying ($arg); $portal->stats->hp (0); $portal->stats->sp (0); $portal->apply ($ob); $portal->destroy; 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 maps => sub { my ($ob, $arg) = @_; no re 'eval'; $arg = qr<$arg>; my $format = "%2s %2s %-30.30s\n"; my $msg = sprintf $format, "Pl", "Fl", "Reset", "Name"; for (sort keys %cf::MAP) { my $map = $cf::MAP{$_} or next; $msg } 1 }; cf::register_command reset => sub { my ($ob, $arg) = @_; return unless $ob->may ("command_reset"); $ob->reply (undef, "You can temporarily see through walls."); 1 }; for my $command (qw(teleport summon arrest kick banish)) { my $method = "command_$command"; cf::register_command $command => sub { my ($ob, $arg) = @_; return unless $ob->may ($method); $ob->$method ($arg) }; }